Harryxun/stf_run huggingface dataset:
import sys
sys.setrecursionlimit(100000)

def f(a,b,N):
    def cur(n):
        if n<0: return -2
        elif memo[n]!=-1: return memo[n]
        tmp=[]
        for i in range(3):
            if cur(n-a[i])!=-2: tmp.append(cur(n-a[i])+b[i])
        if max(tmp)>=0: memo[n]=max(tmp)
        else: memo[n]=-2
        return memo[n]
    
    memo=[0]+[-1]*(N)
    return cur(N)

import sys
N=int(input())

A=list(map(int,input().split()))
B=list(map(int,input().split()))

N=f(A,B,N)
N=f(B,A,N)
print(N)


### FIXED CODE ###

def f(a,b,N):

    tmpa,tmpb=[],[]
    for i in range(3):
        if a[i]<b[i]:
            tmpa.append(a[i])
            tmpb.append(b[i])
    a,b=tmpa,tmpb

    if len(a)==0: return N
    elif len(a)==1: return (N//a[0])*b[0]+N%a[0]

    elif len(a)==2:
        if a[0]<a[1]: a,b=a[::-1],b[::-1]

        i,ans=0,N
        while i*a[0]<=N:
            j=(N-i*a[0])//a[1]
            ans=max(ans,i*b[0]+j*b[1]+(N-i*a[0]-j*a[1]))
            i+=1
        return ans

    else:
        memo=[i for i in range(N+1)]

        for i in range(1,N+1):
            tmp=[]
            for j in range(len(a)):
                if i-a[j]>=0: tmp.append(memo[i-a[j]]+b[j])
            if tmp!=[]: memo[i]=max(tmp)
        return memo[N]

import sys
N=int(input())

A=list(map(int,input().split()))
B=list(map(int,input().split()))

N=f(A,B,N)
N=f(B,A,N)
print(N)
s,t = map(input().split())
a,b = map(int,input().spli())
u = input()
if u==s:
    print(a-1,b)
else:
    print(a,b-1)

### FIXED CODE ###

s = input().split()
a,b = map(int,input().split())
u = input()
if u==s[0]:
    print(a-1,b)
else:
    print(a,b-1)
import numpy as np
from sympy import isprime

def divisor_num(n,prime_list):
    if n == 1:
        return 1
    arr = []
    temp = n
    for i in prime_list:
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(cnt)
    
    if temp!=1:
        arr.append(1)

    if arr==[]:
        arr.append(1)
    
    ans = 1
    for num in arr:
        ans *= num+1
    
    return ans

n = int(input())

prime_list = []
for i in range(2,int(np.sqrt(n))+1):
    if isprime(i):
        prime_list.append(i)

total = 0
for i in range(1,n+1):
    total += i*divisor_num(i,prime_list)
print(total)

### FIXED CODE ###

n = int(input())

ans = 0
for i in range(1,n+1):
    num = n//i
    ans += num*(i+i*num)//2

print(ans)
N = int(input())
A = [int(input()) for i in range(N)]
M = max(A)
c = A.count(M)
a = list(set(A))
a.sort(reverse=True)

for i in range(N):
  if A[i] != M:
    print(M)
  elif:
    if c >= 2:
      print(M)
    elif:
      print(a[1])
    

### FIXED CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
M = max(A)
c = A.count(M)
a = list(set(A))
a.sort(reverse=True)
 
for i in range(N):
  if A[i] != M:
    print(M)
  else:
    if c >= 2:
      print(M)
    else:
      print(a[1])
a,b,k=map(int,input().split())
count=0
for i in range(ab):
  if a%i==0 and b%i==0:
    count+=1
    if count==k:
      print(i)
      exit()
    


### FIXED CODE ###

a,b,k=map(int,input().split())
count=0
for i in range(105):
  j=101-i
  if a%j==0 and b%j==0:
    count+=1
    if count==k:
      print(j)
      exit()
A,B,C=map(int,input().split())

S=set(A,B,C)

if len(S)==2:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

A,B,C=map(int,input().split())

S={A,B,C}

if len(S)==2:
    print('Yes')
else:
    print('No')
s = input()
l = 0
lenmax = 0
 
for i in s:
  if i in "ACGT":
    l += 1
  else:
    lenmax = max(lenmax,l)
    l = 0
lenmax = max(lenmax,l)
print(lenmaax)

### FIXED CODE ###

s = input()
l = 0
lenmax = 0
 
for i in s:
  if i in "ACGT":
    l += 1
  else:
    lenmax = max(lenmax,l)
    l = 0
lenmax = max(lenmax,l)
print(lenmax)
n = int(input())
s = list(input().split())

for i in range(n):
    if s[i] == "Y":
        print("four")
        break
        elif i == n-1:
            print("Tree")

### FIXED CODE ###

n = int(input())
s = list(input().split())

for i in range(n):
    if s[i] == "Y":
        print("Four")
        break
    elif i == n-1:
        print("Three")
k, x = map(int, input().split())

start = x - k + 1
last = x + k - 1

result = []
result.append(start)

for i in range(1, last - start + 1):
    result.append(start + i)
for i in result:
    if i == start:
	output = str(i)
    else:
        output = output + " " + str(i)
print(output)

### FIXED CODE ###

k, x = map(int, input().split())

start = x - k + 1
last = x + k - 1

result = []
result.append(start)

for i in range(1, last - start + 1):
    result.append(start + i)
for i in result:
    if i == start:
	    output = str(i)
    else:
        output = output + " " + str(i)

print(output)
import math
while True:
	n = int(raw_input())
	if n==0:
		break
	sum = 0
	for i in xrange(n):
		s = map(int,raw_input())
		sum += s
	ave = sum/n
	sum = 0
	for i in xnrange(n):
		sum += pow(s[i] - ave,2.0)
	print math.sqrt(sum/n)
	

### FIXED CODE ###

import math
while True:
	n = int(raw_input())
	if n==0:
		break
	s = map(int,raw_input().split())
	ave = sum = 0.0
	for i in xrange(n):
		ave += s[i]
	ave /= n
	for i in xrange(n):
		sum += math.pow(s[i] - ave, 2.0)
	print math.sqrt(sum/n)
x = input()
digits = [int(a) for a in x]
fx = sum(digits)
if x % fx == 0:
  print("Yes")
else:
  print("No")



### FIXED CODE ###

x_str = input()
x = int(x_str)
digits = [int(a) for a in x_str]
fx = sum(digits)
if x % fx == 0:
  print("Yes")
else:
  print("No")
N= int(input())
lead_N = int(str(N)[0]) 
end_N = int(str(N)[len(str(N)) - 1])
ans = 0
#print(str(100)[len(str(100)) - 1])
for i in range(1, N + 1):
  lead = int(str(i)[0])
  end = int(str(i)[len(str(i)) - 1])
  # 一桁
  if lead == end:
    ans += 1
  #2桁以上ループ lead + 中間 + end　
  for j in range((len(str(N)) - 2) + 1):
    if end == 0:
      #末尾が0
      continue
    elif end > lead_N and j == (len(str(N)) - 2) :
      #生成する整数がNに収まらない場合
      continue
    elif end == lead_N and j == (len(str(N)) - 2):
      #生成する整数の一部がNに収まらない場合
      #中間の数字
      if len(str(N)) >= 3
        ans += int(str(N)[1:len(str(N)) - 1])

      if lead <= end_N:
        ans += 1
      #print("b")
      pass
    else:
      #何も気にしないときは組み合わせの分だけたす
      ans += 10 ** j

print(ans)

### FIXED CODE ###

N= int(input())
lead_N = int(str(N)[0]) 
end_N = int(str(N)[len(str(N)) - 1])
ans = 0
#print(str(100)[len(str(100)) - 1])
for i in range(1, N + 1):
  lead = int(str(i)[0])
  end = int(str(i)[len(str(i)) - 1])
  # 一桁
  if lead == end:
    ans += 1
  #2桁以上ループ lead + 中間 + end　
  for j in range((len(str(N)) - 2) + 1):
    if end == 0:
      #末尾が0
      continue
    elif end > lead_N and j == (len(str(N)) - 2) :
      #生成する整数がNに収まらない場合
      continue
    elif end == lead_N and j == (len(str(N)) - 2):
      #生成する整数の一部がNに収まらない場合
      #中間の数字
      if len(str(N)) >= 3:
        ans += int(str(N)[1:len(str(N)) - 1])

      if lead <= end_N:
        ans += 1
      #print("b")
      pass
    else:
      #何も気にしないときは組み合わせの分だけたす
      ans += 10 ** j

print(ans)
S = input().strip()

MOD = 10 ** 9 + 7

N = len(S)
DP = np.zeros((N+1, 13), dtype=np.int32)
DP[0, 0] = 1

for _i, s in enumerate(S):
    i = _i + 1

    if s == '?':
        candidate = range(10)
    else:
        candidate = [int(s)]

    for j in range(13):
        for c in candidate:
            m = (j * 10 + c) % 13
            DP[i, m] += DP[i-1, j]
    DP[i] %= MOD

print(DP[-1, 5])

### FIXED CODE ###

S = input().strip()

MOD = 10 ** 9 + 7

N = len(S)
DP = [[0] * 13 for i in range(N+1)]
DP[0][0] = 1

for _i, s in enumerate(S):
    i = _i + 1

    if s == '?':
        candidate = range(10)
    else:
        candidate = [int(s)]

    for j in range(13):
        for c in candidate:
            m = (j * 10 + c) % 13
            DP[i][m] += DP[i-1][j]
    for j in range(13):
        DP[i][j] %= MOD

print(int(DP[-1][5]))
S = input()
for i in range(3):
  if S[i]=="9":
    S[i]="1"
  elif S[i]=="1":
    S[i] ="9"
print(S)

### FIXED CODE ###

S = list(input())
for i in range(3):
  if S[i]=="9":
    S[i]="1"
  elif S[i]=="1":
    S[i] ="9"
print("".join(S))
n = int(input())
s = input()
if n%2 != 0.0:
  prtin("No")
elif s[:int(n/2)] == s[int(n/2):]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n = int(input())
s = input()
if n%2 != 0 or n == 1:
  print("No")
elif s[:int(n/2)] == s[int(n/2):]:
  print("Yes")
else:
  print("No")
import math
a, b, n = map(int, input().split())
p = min(b, n)
if p % b == 0:
    print(int(a(p-1)/b))
else:
    print(int((a(p))/b))

### FIXED CODE ###

A,B,N = map(int, input().split())
c = min(N,B)
if c % B == 0:
    print(int(A*(c-1)/B))
else :
    print(int(A*(c)/B))
from heapq import heapify,heappush,heappop
import sys

N, Q = map(int,input().split())

S = []
PQs = [[] for _ in range(200000)]
T = [0]*200000 #幼稚園ごとの最終更新
M = []
for n in range(N):
  a, b = map(int,input().split())
  S.append([a,b-1])#レート、所属
  #print(PQs[0:10])
  PQs[b-1]=PQs[b-1]+[(-a,n)]#-レート、人
  #print(PQs[0:10])

for b in range(200000):
  if len(PQs[b])>0:
    heapify(PQs[b])
    M.append((-PQs[b][0][0],b,0))#レート、人、所属、更新時
heapify(M)
          
for q in range(1,Q+1):#時刻。1からスタート
  c, d = map(int,input().split())
  d = d-1
  d_prv = S[c-1][1]
  S[c-1][1] = d #情報の更新
  #print(S)
 
  #print(d_prv)
  #print(d)
  
  #転園先の幼稚園について
  heappush(PQs[d],(-S[c-1][0],c-1))#-レート、人
  #print(S[P[d][0][1]][1])
  #print(d)
  #print(PQs[0:4]) 
  while d != S[PQs[d][0][1]][1]:#所属が整合していない時（古く間違った情報である時）
    heappop(PQs[d])
  heappush(M,(-PQs[d][0][0],d,q))
  T[d] = q #最終更新時をアップデート
  #print(PQs[0:4])
  
  #転園元の幼稚園について
  if len(PQs[d_prv])>0:
    while d_prv != S[PQs[d_prv][0][1]][1]:#所属が整合していない時（古く間違った情報である時）
      #print(S[PQs[d_prv][0][1]])
      heappop(PQs[d_prv])
      if len(PQs[d_prv]) == 0:
        break
        
    if len(PQs[d_prv]) > 0:  
      heappush(M,(-PQs[d_prv][0][0],d_prv,q))
    T[d_prv] = q #最終更新時をアップデート

  #print(M)   	
  #最強園児の集いを処理
  while M[0][2] != T[M[0][1]]:#更新時が整合していない時（古く間違った情報である時）
    heappop(M)
    #print(M)
  
  #結果の出力
  print(M[0][0]) 
  #print(M)

### FIXED CODE ###

x = list(map(int, input().split()))
ans = 0
for xi in x:
  ans += 1
  if xi == 0:
    print(ans)
    break
n,m = map(int,input().split())
dict1 = {}
for i in range(n):
    a,b = map(int,input().split())
    dict1[a] = b

dict1_sorted = sorted(dict1.items(),key = lambda x:x[0],reverse = False)

money = 0
count = 0

while m > 0:
    if m > dict1_sorted[count][1]:
        money += dict1_sorted[count][0] * dict1_sorted[count][1]
        m -= dict1_sorted[count][1]
        count += 1
    else:
        money += dict1_sorted[count][0] * m
        m = 0
        count += 1

print(money)


### FIXED CODE ###

n,m = map(int,input().split())
li = [list(map(int,input().split())) for _ in range(n)]
li.sort(key = lambda x:x[0])

money = 0
count = 0

while m > 0:
    if m > li[count][1]:
        money += li[count][0] * li[count][1]
        m -= li[count][1]
        count += 1
    else:
        money += li[count][0] * m
        m = 0
        count += 1

print(money)
x = input().split()
n = int(x[0])
m = int(x[1])
a = list()
for i in range(m):
  y = input().split()
  l = int(y[0])
  r = int(y[1])
  for i in range(l,r+1):
    a.append(i)
b = 0
for i in range(n):
  if a.count(i) == m:
    b += 1
print(b)
  

### FIXED CODE ###

x = input().split()
a = int(x[0])
b = int(x[1])
if a >= 13:
  print(b)
elif 6 <= a <= 12:
  print(b//2)
else:
  print(0)
# C - Snack

from math import gcd

A, B = map(int, input().split())
print(int(A * B / gcd(A, B)))


### FIXED CODE ###

# C - Snack

from fractions import gcd

A, B = map(int, input().split())
print(A * B // gcd(A, B))
def next7(s):
    return s * 10 + 7


def submit():
    k = int(input())

    if k % 2 == 0:
        print(-1)
        return
    if k == 5:
        print(-1)
        return

    d = {}
    for t in [1, 3, 7, 9]:
        d[t] = {}
        for i in range(10):
            d[t][t * i % 10] = i
    
    td = k % 10
    curr = 0
    digit = 1
    count = 0
    while count == 0 or curr != 0:
        diff = 7 - (curr % 10)
        if diff != 0:
            if diff < 0:
                diff += 10
            coef = d[td][diff]
            curr += coef * k
        curr //= 10
        count += 1

    print(count)
        


submit()    

### FIXED CODE ###


def submit():
    k = int(input())

    if k % 2 == 0:
        print(-1)
        return
    if k % 5 == 0:
        print(-1)
        return

    d = {}
    for t in [1, 3, 7, 9]:
        d[t] = {}
        for i in range(10):
            d[t][t * i % 10] = i
    
    td = k % 10
    curr = 0
    count = 0
    while count == 0 or curr != 0:
        diff = 7 - (curr % 10)
        if diff != 0:
            if diff < 0:
                diff += 10
            coef = d[td][diff]
            curr += coef * k
        curr //= 10
        count += 1

    print(count)
    
submit()
a,b,c,x=map(int,input().split())
print([500*x+100*y+50*z for z in range(c+1) for y in range(b+1) for x in range(a+1)].count(x))

### FIXED CODE ###

a,b,c,x=[int(input()) for _ in range(4)]
print([500*x+100*y+50*z for z in range(c+1) for y in range(b+1) for x in range(a+1)].count(x))
n = int(input())
a = int(input())

m = n mod 500
if m <= a:
    print('Yes')
else:
    print('No')



### FIXED CODE ###

n = int(input())
a = int(input())

m = n % 500
if m <= a:
    print('Yes')
else:
    print('No')
a = map(int, input())
a.sort()
if a == b:
    print(c)
else:
    print(a)

### FIXED CODE ###

a = input().split()
a.sort()
if a[0] == a[1]:
    print(a[2])
else:
    print(a[0])
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)


a,b,c,d = map(int,input().split())
tn = b-a+1


cn = (b//c)-((a-1)//c)
dn = (b//d)-((a-1)//d)

cd = lcm(c,d)
cdn = (b//cd)-((a-1)//cd)

print(tn-cn-dn+cdn)

### FIXED CODE ###

import fractions

a,b,c,d = map(int,input().split())
tn = b-a+1

cn = (b//c)-(a-1)//c
dn = (b//d)-(a-1)//d
cd = (c*d)//fractions.gcd(c, d)
cdn = (b//cd)-(a-1)//cd

print(tn-cn-dn+cdn)
from collections import deque
from itertools import chain, combinations

n, k = map(int, input().split())
books = [[] for _ in range(10)]

while n:
    c, g = map(int, input().split())
    books[g - 1].append(c)
    n -= 1

for q in books:
    q.sort(reverse=True)

done = set()
max_cost = 0

for book_combi in combinations(chain.from_iterable([[i] * min(k, len(q)) for i, q in enumerate(books) if q]), k):
    if book_combi in done:
        continue
    done.add(book_combi)

    cost = 0
    counts = [0] * 10
    for i in book_combi:
        cost += books[i][counts[i]] + counts[i] * 2
        counts[i] += 1

    if cost > max_cost:
        max_cost = cost

print(max_cost)

### FIXED CODE ###

from itertools import accumulate

n, k = map(int, input().split())
books = [[] for _ in range(10)]

while n:
    c, g = map(int, input().split())
    books[g - 1].append(c)
    n -= 1

books_acc = [[0] + list(accumulate(c + i * 2 for i, c in enumerate(sorted(q, reverse=True)))) for q in books]


def memoize(f):
    memo = [[-1] * (k + 1) for _ in range(10)]

    def main(x, y):
        if x > 9:
            return 0
        result = memo[x][y]
        if result < 0:
            result = memo[x][y] = f(x, y)
        return result

    return main


@memoize
def combi(g, remain):
    book_acc = list(books_acc[g])
    salable = min(remain + 1, len(book_acc))
    return max([book_acc[i] + combi(g + 1, remain - i) for i in range(salable)], default=0)


print(combi(0, k))
N, L, T=map(int, input().split())
XW=[list(map(int, input().split())) for _ in range(N)]
X_=[(XW[i][0]+T)%L if XW[i][1]==1 else (XW[i][0]-T)%L for i in range(N)]
X_.sort()
A0_=(XW[0][0]+T)%L if XW[0][1]==1 else (XW[0][0]-T)%L
P0_=X_.index(A0_)
if P0_>0:
    X_=X_[P0_:]+X_[:P0_]
    
if XW[0][1]==1:
    C0_=round(sum([(T-(XW[i][0]-XW[0][0])/2)//(L/2)+1 if XW[i][1]!=1 and (XW[i][0]-XW[0][0])/2<=T else 0 for i in range(1, N)])%N)
else:
    C0_=round(N-sum([(T-(XW[0][0]+L-XW[i][0])/2)//(L/2)+1 if XW[i][1]!=2 and (XW[0][0]+L-XW[i][0])/2<=T else 0 for i in range(1, N)])%N)
    
if X_[0]==X_[1] and XW[0][1]==1:
  if C0_>0:
    C0_=(C0_-1)%N
  
if C0_>0:
  X_=X_[N-C0_:]+X_[:N-C0_]
print(*X_, sep='\n')

### FIXED CODE ###

N, L, T=map(int, input().split())
XW=[list(map(int, input().split())) for _ in range(N)]
X_=[(XW[i][0]+T)%L if XW[i][1]==1 else (XW[i][0]-T)%L for i in range(N)]
X_.sort()
A0_=(XW[0][0]+T)%L if XW[0][1]==1 else (XW[0][0]-T)%L
P0_=X_.index(A0_)
if P0_>0:
    X_=X_[P0_:]+X_[:P0_]
    
if XW[0][1]==1:
    C0_=round(sum([(T-(XW[i][0]-XW[0][0])/2)//(L/2)+1 if XW[i][1]!=1 and (XW[i][0]-XW[0][0])/2<=T else 0 for i in range(1, N)])%N)
else:
    C0_=round(N-sum([(T-(XW[0][0]+L-XW[i][0])/2)//(L/2)+1 if XW[i][1]!=2 and (XW[0][0]+L-XW[i][0])/2<=T else 0 for i in range(1, N)])%N)
    
if N>1 and X_[0]==X_[1] and XW[0][1]==1:
  C0_=round((C0_-1)%N)

if C0_>0:
  X_=X_[N-C0_:]+X_[:N-C0_]

print(*X_, sep='\n')
s,t = input().split()
ans = map(int,input().split())
m = input()
if m == s:
  ans[0] -= 1
elif m == t:
  ans[1] -= 1
print(ans[0],ans[1])

### FIXED CODE ###

s,t = input().split()
ans = [int(i) for i in input().split()]
m = input()
if m == s:
  ans[0] -= 1
elif m == t:
  ans[1] -= 1
print(ans[0],ans[1])
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0] * n


for i in range(1,n):
    a = []
    if i-k < 0:
        start = 0
    else:
        start = i-k
    
    for j in range(start,i):
        a.append(dp[j] + abs(h[i] - h[j]))    
    
    dp[i] = min(a)
    
print(dp[-1])
                 


### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))

dp = [0] * n

dp[1] = abs(h[0] - h[1])

for i in range(2,n):
    a1 = dp[i-1] + abs(h[i] - h[i-1])
    a2 = dp[i-2] + abs(h[i] - h[i-2])
    dp[i] = min(a1,a2)
    
print(dp[n-1])
a,b=map(input())
a=a+b
if (a)%2==0:
  print(a//2)
else:
  print('IMPOSSIBLE')

### FIXED CODE ###

a,b=map(int,input().split())
a=a+b
if (a)%2==0:
  print(a//2)
else:
  print('IMPOSSIBLE')
N,K = map(int,input().split())
if K%2==0:
    d1=n//(k//2)
    d2=n//k
    ans=d2**3+(d1-d2)**3
else:
    d=n//k
    ans = d**3
print(ans)
    

### FIXED CODE ###

N,K = map(int,input().split())
ans = 0

if K%2==0:
    d1=N//(K//2)
    d2=N//K
    ans=d2**3+(d1-d2)**3
else:
    d=N//K
    ans = d**3

print(ans)
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    X = input()
    XINT = int(X,2)
    ANS = [0]*N
    TEMP = [0]*N
    CHAIND = [0]*N


    cnt = count_ones_by_bitmask(XINT)
    
    if cnt == 0:
        for i in range(N):
            print(1)
            return
    
    bit = 1
    p = XINT % (cnt+1)
    m = 0
    if cnt != 1 :
        m = XINT % (cnt-1)
    pmod = 1
    mmod = 1
    for i in range(N):
        if (cnt !=1):
            ANS[i] = 1
            if (X[N-i-1] == '0'):
                TEMP[i] = (p + pmod) % (cnt+1)
            else:
                TEMP[i] = (m - mmod) % (cnt-1)
        pmod = (pmod*2) % (cnt+1)
        mmod = (mmod*2) % (cnt-1)


    CHA = list(set(TEMP))

    for i in range(len(CHA)):
        an = 0
        cha = CHA[i]
        cnt = count_ones_by_bitmask(CHA[i])
        while cnt>0:
            an += 1
            cha = cha%cnt
            cnt = count_ones_by_bitmask(cha)
        CHAIND[CHA[i]] = an

    for i in reversed(range(N)):
        print(ANS[i]+CHAIND[TEMP[i]])




def count_ones_by_bitmask(num):
    count = 0
    while num:
        count += num & 1
        num >>= 1
    return count

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N = int(input())
    X = input()
    XINT = int(X,2)
    ANS = [0]*N
    TEMP = [0]*N
    CHAIND = [0]*N

    cnt = count_ones_by_bitmask(XINT)
    
    if cnt == 0:
        for i in range(N):
            print(1)
            return
    if cnt ==1:
        for i in  range(N):
            if X[i] == '1':
                print(0) #全てが0になる
            else:
                if i==N-1:
                    print((int(X[N-1])+1)%2+1) # 2の剰余の反転
                else:
                    print((int(X[N-1]))%2+1) # 2の剰余
        return

    p = XINT % (cnt+1)
    m = XINT % (cnt-1)
    pmod = 1
    mmod = 1
    for i in range(N):
        ANS[i] = 1
        if (X[N-i-1] == '0'):
            TEMP[i] = (p + pmod) % (cnt+1)
        else:
            TEMP[i] = (m - mmod) % (cnt-1)
        pmod = (pmod*2) % (cnt+1)
        mmod = (mmod*2) % (cnt-1)


    CHA = list(set(TEMP))

    for i in range(len(CHA)):
        an = 0
        cha = CHA[i]
        cnt = count_ones_by_bitmask(CHA[i])
        while cnt>0:
            an += 1
            cha = cha%cnt
            cnt = count_ones_by_bitmask(cha)
        CHAIND[CHA[i]] = an

    for i in reversed(range(N)):
        print(ANS[i]+CHAIND[TEMP[i]])


def count_ones_by_bitmask(num):
    count = 0
    while num:
        count += num & 1
        num >>= 1
    return count

if __name__ == '__main__':
    main()
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))


index = 0
index2 = 0
stackedTime = 0

while(index<N and stackedTime + A[index] <= K):
  stackedTime += A[index]
  index += 1

while(index2 < M and stackedTime + B[index2] <= K):
  stackedTime += B[index2]
  index2 += 1

maxBook = index + index2
for i in range(N):
  if(index == 0 or index2 == M):
    break
  index -= 1
  stackedTime -= A[index]
  while(index2 < M and stackedTime + B[index2] <= K):
    stackedTime += B[index]
    index2 += 1

  maxBook = max(maxBook, index + index2)

print(maxBook)


### FIXED CODE ###

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))


index = 0
index2 = 0
stackedTime = 0

while(index<N and stackedTime + A[index] <= K):
  stackedTime += A[index]
  index += 1

while(index2 < M and stackedTime + B[index2] <= K):
  stackedTime += B[index2]
  index2 += 1

maxBook = index + index2
for i in range(N):
  if(index == 0 or index2 == M):
    break
  index -= 1
  stackedTime -= A[index]
  while(index2 < M and stackedTime + B[index2] <= K):
    stackedTime += B[index2]
    index2 += 1

  maxBook = max(maxBook, index + index2)

print(maxBook)
N = int(input())
if N == 3：
	print(1, 2, 3)
  	exit()
a = []
i = 2
while len(a) < N-N%2-2 and i + 2 <= 30000:
	a.append(i)
    a.append(i+2)
    i += 6
b = []
i = 3
while len(a) + len(b) < N-N%2 and i + 6 <= 30000:
  	b.append(i)
    b.append(i+6)
    i += 12
c = []
i = 6
while len(a) + len(b) + len(c) < N:
  	c.append(i)
    i += 6
print(' '.join(map(str, a+b+c)))


### FIXED CODE ###

N = int(input())
if N == 3:
    print(2, 5, 63)
    exit()
a = []
i = 2
while len(a) < N-N%2-2 and i + 2 <= 30000:
    a.append(i)
    a.append(i+2)
    i += 6
b = []
i = 3
while len(a) + len(b) < N-N%2 and i + 6 <= 30000:
    b.append(i)
    b.append(i+6)
    i += 12
c = []
i = 6
while len(a) + len(b) + len(c) < N:
    c.append(i)
    i += 6
print(' '.join(map(str, a+b+c)))
x,k,d = map(int,input().split())
cnt = x//d
mod = x%d
mini = 0

if k < cnt:
    print(x-(d*k))
    exit()

if mod > abs(mod-d):
    mini = abs(mod-d)
    cnt += 1
else:
    mini = mod

if k%2 == 1:
    if cnt%2 == 1:
        print(x-(d*cnt))
    else:
        print(min(abs(mini-d),mini+d))
else:
    if cnt%2 == 0:
        print(x-(d*cnt))
    else:
        print(min(abs(mini-d),mini+d))


### FIXED CODE ###

s = input()

if s == "RSS" or s == "SRS" or s == "SSR" or s == "RSR":
    print(1)
elif s == "RRS" or s == "SRR":
    print(2)
elif s == "RRR":
    print(3)
else:
    print(0)