Harryxun/stf_run huggingface dataset:
import sys
sys.setrecursionlimit(10**7)

def input(): return sys.stdin.readline()[:-1]
mod = 10**9 + 7
def readInt():return int(input())
def readIntList():return list(map(int,input().split()))
def readStringList():return list(input())
def readStringListWithSpace():return list(input().split())
def readString():return input()

target = readInt()
nums = [i for i in range(3,target+1)]

dp = [0] * (1+target)
for num in nums:
    if num <= target:
        dp[num] = 1
for i in range(target+1):
    for num in nums:
        if i - num > 0:
            dp[i] += dp[i-num]
print(dp[-1]%mod

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

def input(): return sys.stdin.readline()[:-1]
mod = 10**9 + 7
def readInt():return int(input())
def readIntList():return list(map(int,input().split()))
def readStringList():return list(input())
def readStringListWithSpace():return list(input().split())
def readString():return input()

target = readInt()
nums = [i for i in range(3,target+1)]

dp = [0] * (1+target)
for num in nums:
    if num <= target:
        dp[num] = 1
for i in range(target+1):
    for num in nums:
        if i - num > 0:
            dp[i] += dp[i-num]
print(dp[-1]%mod)
N=int(input())
A=[int(x) for x in input().split()]

A=sorted(A)

if N%2==0:
    if all(A[i]==A[i+1] and A[0]==1 and A[i]+2==A[i+2] for i in range(0,N-2,2)):
        print(2**(N//2))
    else:
        print(0)
else:
    if all(A[0]==0 and A[i]==A[i+1] and A[i]-2==A[i-1] for i in range(2,N,2)):
        print(2**(N//2))
    else:
        print(0)


### FIXED CODE ###

N=int(input())
A=[int(x) for x in input().split()]
mod=10**9+7
A=sorted(A)

if N%2==0:
    if all(A[i]==A[i+1] and A[0]==1 and A[1]==1 and A[i]-2==A[i-2] for i in range(2,N,2)):
        print((2**(N//2))%mod)
    else:
        print(0)
else:
    if all(A[0]==0 and A[i]==A[i-1] and A[i]-2==A[i-2] and A[-1]==N-1 for i in range(2,N,2)):
        print((2**(N//2))%mod)
    else:
        print(0)
A, op, B = map(int, input().split())
if op == '+':
    print(A+B)
elif op == '-':
    print(A-B)

### FIXED CODE ###

# ABC50_A

a, op, b = map(str,input().split())
if op == '+':
    print(int(a)+int(b))
else:
    print(int(a)-int(b))
import numpy as np
import math
import scipy

def hoge():
  dp = [0] * (n + 5)
  for i in range(1, n):
    if i <= k:
      p = i
    else:
      p = k
    dp[i] = min(dp[i] + abs(h_list[i] - h_list[j]) for j in range(p, i))
  return dp[n]

def solve():
  global n, k, h_list
  n, k = map(int, input().split())
  h_list = list(map(int, input().split()))
  ans = hoge()
  print(ans)
  return 0

if __name__ == "__main__":
  solve()

### FIXED CODE ###

def hoge():
  dp = [0] * (n + 5)
  for i in range(1, n):
    p = [dp[j] + abs(h_list[i] - h_list[j]) for j in range(max(0, i - k), i)]
    dp[i] = min(p)
  return dp[n - 1]

def solve():
  global n, k, h_list
  n, k = map(int, input().split())
  h_list = list(map(int, input().split()))
  ans = hoge()
  print(ans)
  return 0

if __name__ == "__main__":
  solve()
N=int(input())
actlist=list(map(int,input().split()))
As = sorted([(A, i) for i, A in enumerate(actlist)])[::-1]

left=1
right=N
sumnum=0

for i in As:
    move=0
    moveleft=abs(i[1]+1-left)
    moveright=abs(i[1]+1-right)
    if moveleft>moveright:
        move=moveleft
        left+=1
    else:
        move=moveright
        right=right-1
    sumnum+=move*i[0]
    
print(sumnum+1)

### FIXED CODE ###

import numpy as np
print(float(input())*2*np.pi)
a,b,h,m = list(map(int, input().split()))

hh=360*(60*h+m)/(60*12)
mm=360*(m/60)
rad=hh-mm
if rad > 180:
    rad=360-rad
print(rad)
print(math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(rad))))

### FIXED CODE ###

import math
a,b,h,m = list(map(int, input().split()))

hh=360*(60*h+m)/(60*12)
mm=360*(m/60)
rad=hh-mm
if rad > 180:
    rad=360-rad
print(math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(rad))))
K = int(input())
S = input()
if len(S) =< K:
 print(S)
else:
 print(S[:K+1]+'...')


### FIXED CODE ###

K = int(input())
S = input()
if len(S) <= K:
 print(S)
else:
 print(S[:K] + '...')
import bisect as bs
l=int(input())
lst=sorted(list(map(int,input().split())))
n=lst[l-1]
m=bs.bisect_left(lst,n/2)
print(m)

if n/2 - lst[m] <= lst[m+1] -n/2:
  print(n,lst[m])
else:
  print(n,lst[m+1])


### FIXED CODE ###

import bisect as bs
l=int(input())
lst=sorted(list(map(int,input().split())))
n=lst[l-1]
lst[l-1]=float("inf")
m=bs.bisect_right(lst,n/2)
if n/2 - lst[m-1] <= lst[m] -n/2:
  print(n,lst[m-1])
else:
  print(n,lst[m])
n,m=map(int,input().split())
mod=10**9+7
a = [int(input()) for i in range(m)]
block=[0,1]
x=[True for i in n]
for j in a:
  x[j-1]=False

for i in range(1,n+1):
  if x[i-1]==True:
    block=block[1:]+[0]
  else:
    block=block[1:]+[sum(block)%mod]
print(block[-1])


### FIXED CODE ###

n,m=map(int,input().split())
mod=10**9+7
a = [int(input()) for i in range(m)]
block=[0,1]
x=[True for i in range(n)]
for j in a:
  x[j-1]=False

for i in range(1,n+1):
  if x[i-1]==False:
    block=block[1:]+[0]
  else:
    block=block[1:]+[sum(block)%mod]
print(block[-1])
Row = int(input())
List = []
for i in range (Row):
  List.append(list(map(int, input().split())))
x = 0
y = 0
flag = True
for i in range(Row):
  reqT = List[i][1]-x+List[i][2]-y
  chck= reqT - T
  if chck < 0 or chck % 2 == 1:
    flag = False
    break
  x = List[i][1]
  y = List[i][2]
if flag:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

Row = int(input())
List = []
for i in range (Row):
  List.append(list(map(int, input().split())))
x = 0
y = 0
T = 0
flag = True
for i in range(Row):
  reqT = abs(List[i][1]-x)+abs(List[i][2]-y)
  chck= List[i][0] - T - reqT
  if chck < 0 or chck % 2 == 1:
    flag = False
    break
  x = List[i][1]
  y = List[i][2]
  T = List[i][0]
if flag:
  print("Yes")
else:
  print("No")
A, B, K = map(int, input().split())
n = max(A, B)
k = 0
if n == 1:
    print("1")
else:
    while k < K:
        n = n - 1
        if A % n == 0 and B % n == 0:
            k = k + 1
    print(n)


### FIXED CODE ###

A, B, K = map(int, input().split())
n = max(A, B)
k = 0
while True:
    if A % n == 0 and B % n == 0:
        k = k + 1
    if k >= K:
        break
    n = n - 1
print(n)
from math import ceil,sqrt,log,gcd,pi
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())

# for _ in range(ii()):
a,b=mi()
if((b+a)%2):
    print("IMPOSSIBLE")
else:
    x=abs(b+a)//2
    print(x)

### FIXED CODE ###

# from math import ceil,sqrt,log,gcd,pi
# def ii():return int(input())
# def si():return input()
# def mi():return map(int,input().split())
# def li():return list(mi())

# for _ in range(ii()):
a,b=map(int,input().split())
s=(a+b)
if(s==0 or s%2):
    print("IMPOSSIBLE")
else:
    x=0
    if(s!=0):
        x=abs(s)//2
    print(x)
n = int(input())
for i in range(n):
    if int(i*1.08) = n:
        print(i)
        exit()
print(":(")


### FIXED CODE ###

n = int(input())
for i in range(n+1):
    if int(i*1.08) == n:
        print(i)
        exit()
print(":(")
import math
a, b = map(int, input().split())
(a + b) / 2 = x
print(ceil(x))

### FIXED CODE ###

import math
a,b = map(int, input().split())
x = (a + b) / 2
print(math.ceil(x))
from functools import reduce


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

a = reduce(lambda a, b: a * b, A)
total = 0
for i in range(n):
    total += reduce(lambda a, b: a * b, A[:i] + A[i+1:])
print(1.0 * a / total)

### FIXED CODE ###

from functools import reduce


n = int(input())
A = list(map(int, input().split()))
if n == 1:
    print(A[0])
else:
    numerator = reduce(lambda a, b: a * b, A)
    denominator = 0
    for i in range(n):
        denominator += reduce(lambda a, b: a * b, A[:i] + A[i+1:])
    print(1.0 * numerator / denominator)
R = int(input())
G = int(input())
print(2*G-R)

### FIXED CODE ###

C = str(input())
D = str(input())
if C[0] == D[2] and C[1] == D[1] and C[2] == D[0]:
    print("YES")
else:
    print("NO")
l = input().split(" ")
j = input().split(" ")
k = int(l[0])
n = int(l[1])
for i in range(j):
  d1 = j[i+1] - j[i]
  d2 = j[i+2] - j[i+1]
  max = max(d1,d2)
  dt = k - int(max)
print(dt)


### FIXED CODE ###

KN = input().split(' ')
K = int(KN[0])
N = int(KN[1])
M = K/2
Al = input().split(' ')
A = []

for home in Al:
  A.append(int(home))

m = A[0]+(K-A[-1])
 
for i in range(N-1):
  m = max(m,abs(A[i]-A[i+1]))

print(K-m)
a = int(input())
b = int(input())

if (a == 1 or b == 2) and (a == 1 or b == 2):
    print(3)
elif (a == 2 or b == 3) and (a == 2 or b == 3):
    print(1)
else
    print(2)


### FIXED CODE ###

a = int(input())
b = int(input())
print(6 - a - b)
import itertools

N, M = map(int, input().split())
S = []
for i in range(M):
    tmp = list(map(int, input().split()))
    S.append([tmp[1:]])
P = list(map(int, input().split()))


origin_list = [0, 1]
all_way = []
for i in itertools.product(origin_list, repeat=N):
    all_way.append(i)
print(all_way)

ans = 0
for way in all_way:
    light = 0
    for i, s in enumerate(S):
        small_sum = 0
        for ss in s:
            if way[ss - 1] == 1:
                small_sum += 1
        if small_sum % 2 == P[i]:
            light += 1
    if light == M:
        ans += 1

print(ans)

### FIXED CODE ###

import itertools

N, M = map(int, input().split())
S = []
for i in range(M):
    tmp = list(map(int, input().split()))
    S.append([tmp[1:]])
P = list(map(int, input().split()))


origin_list = [0, 1]
all_way = []
for i in itertools.product(origin_list, repeat=N):
    all_way.append(i)

ans = 0
for way in all_way:
    light = 0
    for i, s in enumerate(S):
        small_sum = 0
        for ss in s:
            for sss in ss:
                if way[sss - 1] == 1:
                    small_sum += 1
            if small_sum % 2 == P[i]:
                light += 1
        if light == M:
            ans += 1

print(ans)
N=int(input())
a=list(map(int,input().split()))

l=sorted(a)

# N=10
# l=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
if N>=10**3:
    math.


ans=1

for i in range(N):
    if i>=1 and l[i]==l[i-1]:
        continue
    else:
        t=l[i]
        for j in range(N-i):
            c=l[i+j]
            if abs(c-t)<=2:
                continue
            else:
                _ans=j
                if _ans>ans:
                    ans=_ans
                else:
                    pass
                break
print(ans)

### FIXED CODE ###

N=int(input())
a=list(map(int,input().split()))

l=[0]*((10**5)+2)

for v in a:
    l[v]+=1
    l[v+1]+=1
    l[v+2]+=1

print(max(l))
a = input()
A = a[0]
B = a[2]
if A == B:
 print(Yes)
else:
 print(No)

### FIXED CODE ###

N = input()
A = int(N[0])
B = int(N[1])
C = int(N[2])
if A==C:
 print("Yes")
else:
 print("No")
A, B, K = map(int, input().split())
num = [i for i in range(A, B+1)]
num_set = []

if B < K:
    K = len(num)

for i in range(K):
    num_set.append(num[i])

num.sort(reverse=True)
for i in range(K):
    if num[i] not in num_set:
        num_set.append(num[i])

num_set.sort()
for i in range(len(num_set)):
    print(num_set[i])


### FIXED CODE ###

A, B, K = map(int, input().split())
a = A
b = B

ans = []
for i in range(K):
    if A not in ans:
        ans.append(A)

    if B not in ans:
        ans.append(B)

    if A + 1 <= b:
        A += 1
    if B - 1 >= a:
        B -= 1

ans.sort()
for i in ans:
    print(i)
from collections import defaultdict

N, K = [int(x) for x in input().split()]
S = input()

dict = defaultdict(list)

L_num = S.count('L')
R_num = S.count('R')

ans = S
skip = -1
for i in range(N):
    if i <= skip:
        continue
    if S[i] == 'R':
        count = 0
        for j in range(i + 1, N):
            if S[j] == 'R':
                count += 1
            else:
                break
        dict[count].append(i)
        skip = count + i
count = 0
for i in range(K + 10):
    max_key = max(dict.keys())
    if len(dict[max_key]) == 0:
        dict.pop(max_key)
        max_key = max(dict.keys())
    target_index = dict[max_key].pop()
    if target_index == 0 or target_index == N - 1:
        continue
    ans = ans[0:target_index] + "L" * (max_key + 1) + ans[target_index + max_key + 1:]
    count += 1
    if count == K:
        break

score = 0
for i in range(N):
    if i != 0 and ans[i] == 'L' and ans[i - 1] == 'L':
        score += 1
    if i != N - 1 and ans[i] == 'R' and ans[i + 1] == 'R':
        score += 1

print(score)




### FIXED CODE ###

from collections import defaultdict

N, K = [int(x) for x in input().split()]
S = input()

ans = S
target_char = S[0]
replacing = False
for i in range(N):
    if S[i] != target_char:
        ans = ans[0:i] + target_char + ans[i + 1:]
        replacing = True
    else:
        if replacing:
            K -= 1
            replacing = False
    if K == 0:
        break

score = 0
for i in range(N):
    if i != 0 and ans[i] == 'L' and ans[i - 1] == 'L':
        score += 1
    if i != N - 1 and ans[i] == 'R' and ans[i + 1] == 'R':
        score += 1

print(score)
import collections

def solve():
    n = int(input())
    v = [int(i) for i in input().split()]
    v_odd = [j for i,j in enumerate(v) if i%2==1]
    v_even = [j for i,j in enumerate(v) if i%2==0]

    v_count = collections.Counter(v)
    #すべて同じ数字
    if(len(v_count)==1):
        return print(int(n/2))
    #異なる数字の時
    elif(len(v_count)!=1):
        
        
        v_odd_max = collections.Counter(v_odd).most_common()[0]
        v_even_max = collections.Counter(v_even).most_common()[0]
        if(v_odd_max[0] != v_even_max[0]):
            return print(int(n/2-v_odd_max[1])+int(n/2-v_even_max[1]))
        else:
            a = v_even.most_common()[1]
            return print(int(n/2-v_odd_max[1])+int(n/2-a[1]))
solve()

### FIXED CODE ###

import collections
n = int(input())
v = [int(i) for i in input().split()]
v_even = [v[2*i] for i in range(int(n/2))]
v_odd = [v[2*i-1] for i in range(int(n/2))]
c_even = collections.Counter(v_even)
c_odd = collections.Counter(v_odd)
if(c_even.most_common()[0][0]!=c_odd.most_common()[0][0]):
    print(n - c_even.most_common()[0][1] - c_odd.most_common()[0][1])
elif(len(collections.Counter(v))==1):
    print(int(n/2))
else:
    if(c_even.most_common()[0][1]>c_odd.most_common()[0][1]):
        print(n-c_even.most_common()[0][1] - c_odd.most_common()[1][1])
    elif(c_even.most_common()[0][1]<c_odd.most_common()[0][1]):
        print(n - c_odd.most_common()[0][1] - c_even.most_common()[1][1])
    else:
        print(n - c_odd.most_common()[0][1] - max(c_odd.most_common()[1][1],c_even.most_common()[1][1]))
A, B = map(int, input().split())

n = 1
c = 0

if B==1 :
  print("0")
else :
	while n < B:
		n = n + A -1
		c = c+1
    print(c)

### FIXED CODE ###

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

n = 1
c = 0

while n < B:
	n = n + A -1
#	print(n)
	c = c+1

print(c)
A=[]
for I in range(n):
  moji=list(input())
  moji.sort()
  moji=''.join(moji)
  A.append(moji)
A.sort()
print(A)
N=0
for i in range(n):
  a=A[i]
  for s in range(i+1,n):
    b=A[s]
    if a==b:
      N+=1
print(N)

### FIXED CODE ###

n =int(input())
A=[]
for I in range(n):
  moji=list(input())
  moji.sort()
  moji=''.join(moji)
  A.append(moji)
A.sort()
N=0
SUM=0
i=0
while True:
  if i==n-1:
    SUM=SUM+int(0.5*N*(N+1))
    break
  a=A[i]
  for s in range(i+1,n,1):
    b=A[s]
    if a==b:
      N+=1
      i+=1
    else:
      SUM=SUM+int(0.5*N*(N+1))
      N=0
      i=s
      break
print(SUM)
S = input()

c = []
f = []

for i, si in enumerate(S):
    if si == 'C':
        c.append(i)
    elif si == 'F':
        f.append(i)

if min(c) < max(f):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

S = input()

C = False
# F = False
ans = False
for si in S:
    if si == 'C':
        C = True
    if C and si == 'F':
        ans = True

if ans:
    print('Yes')
else:
    print('No')
N = input()
lists = list(map(int, input().split()))

high_sum = 0

for x in range(int(N)):
    if x < int(N ) - 1:
        if lists[x] < lists[x + 1]:
            a = lists[x + 1] - lists[x]
            high_sum += a
        else:
            continue
    else:
        b = lists[x] - lists[x - 1]
        if b < 0:
            high_sum += a
        else:
            break
        
print(high_sum)

### FIXED CODE ###

N = int(input())
lists = [int(x) for x in input().split()]
step_sum = 0

for y in range(1, N):
    if lists[y - 1] <=  lists[y]:
        continue
    else:
        s = abs(lists[y] - lists[y -1])
        lists[y] += s
        step_sum += s
        continue
        
print(step_sum)
# %%
W, H = [int(i) for i in input().split()]
maze = [[] for _ in range(H)]

num_black = 0
for i in range(H):
    temp = input()
    for j in temp:
        maze[i].append(j)
        if j == "#":
            num_black += 1

# %%
import copy, collections

maze_copy = copy.deepcopy(maze)
maze_copy[-1][-1] = -1
color = [["W"] * W for _ in range(H)]


def BFS(Y, X):
    vec = [[1, 0], [-1, 0], [0, 1], [0, -1]]
    color[Y][X] = "G"
    que = collections.deque()
    maze_copy[Y][X] = 1
    que.append([Y, X])

    while len(que) != 0:
        u = que.popleft()
        for y, x in vec:
            temp_x = u[1] + x
            temp_y = u[0] + y
            if (0 <= temp_x < W and 0 <= temp_y < H
                    and maze_copy[temp_y][temp_x] == "." and color[temp_y][temp_x] == "W"):
                color[temp_y][temp_x] = "G"
                maze_copy[temp_y][temp_x] = maze_copy[u[0]][u[1]] + 1
                que.append([temp_y, temp_x])


BFS(0, 0)
if maze_copy[-1][-1] == -1:
    print(-1)
else:
    print(W * H - num_black - maze_copy[-1][-1])



### FIXED CODE ###

#%%
H, W = [int(i) for i in input().split()]
maze = [[] for _ in range(H)]

num_black = 0
for i in range(H):
    temp = input()
    for j in temp:
        maze[i].append(j)
        if j == "#":
            num_black += 1
            
#%%
import copy, collections

maze_copy = copy.deepcopy(maze)
color = [["W"] * W for _ in range(H)]


X, Y = 0, 0
vec = [[1, 0], [-1, 0], [0, 1], [0, -1]]
color[Y][X] = "G"
que = collections.deque()
maze_copy[Y][X] = 1
que.append([Y, X])

while len(que) != 0:
    u = que.popleft()
    for y, x in vec:
        temp_x = u[1] + x
        temp_y = u[0] + y
        if (0 <= temp_x < W and 0 <= temp_y < H
                and maze_copy[temp_y][temp_x] == "." and color[temp_y][temp_x] == "W"):
            color[temp_y][temp_x] = "G"
            maze_copy[temp_y][temp_x] = maze_copy[u[0]][u[1]] + 1
            que.append([temp_y, temp_x])
    
if maze_copy[-1][-1] == ".":
    print(-1)
else:
    print(W * H - num_black - maze_copy[-1][-1])
n=input()
a=input()
b=input()
c=input()
tim = 0
for i in range(int(n)):
    if a[i] == b[i] and b[i] != c[i]:
        tim+=1
    elif b[i] == c[i] and c[i] != a[i]:
        tim+=1
    elif c[i] == a[i] and a[i] != b[i]:
        tim+=1
    elif c[i] == a[i] and a[i] == b[i]:
        tim+=0
    else:
        tim+=2
print(tim)

### FIXED CODE ###

n,a,b = (int(i) for i in input().split())
x=min(a,b)
y=a+b-n
if y < 0:
    y=0
print(x,y)
MOD=10**9+7
n,k=map(int,input().split())
a=list(map(int,input().split()))

a.sort(reverse=True)

#前計算
fact = [1]
fact_inv = [1]
mod=10**9+7
for i in range(n+1):
    new_fact = fact[-1]*(i+1)%mod
    fact.append(new_fact)
    fact_inv.append(pow(new_fact,mod-2,mod))

def mod_comb_k(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod
#前計算終わり

lc=len(c)
sum=0
for i in range(lc):
  sum+=c[i]*(a[i]-a[-i-1])%MOD
  
print(sum%MOD)


### FIXED CODE ###

MOD=10**9+7
n,k=map(int,input().split())
a=list(map(int,input().split()))

a.sort(reverse=True)


fact = [1]
fact_inv = [1]
mod=10**9+7
for i in range(10**5+1):
    new_fact = fact[-1]*(i+1)%mod
    fact.append(new_fact)
    fact_inv.append(pow(new_fact,mod-2,mod))


def mod_comb_k(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod

  
c=[]
for i in range(1,n-k+1+1):
  c.append(mod_comb_k(n-i,k-1,MOD))
lc=len(c)
#print(c,a)
sum=0
for i in range(lc):
  sum+=c[i]*(a[i]-a[-i-1])%MOD
  
print(sum%MOD)
import sys
import time

class Node:
    def __init__(self, key):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None

def insert(key, z):
    global root
    y = None
    x = root
    while x:
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    if y is None:
        root = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z

def inorderTreeWalk(node):
    global In
    if node:
        inorderTreeWalk(node.left)
        In.append(str(node.key))
        inorderTreeWalk(node.right)

def preorderTreeWalk(node):
    global Pre
    if node:
        Pre.append(str(node.key))
        preorderTreeWalk(node.left)
        preorderTreeWalk(node.right)

if __name__ == "__main__":
    lines = sys.stdin.readlines()
    del lines[0]

    root = None
    for line in lines:
        if line[0] == "i":
            insert(Node(int(line.split()[1])))
        else:
            In = []
            Pre = []
            inorderTreeWalk(root)
            print " " + " ".join(map(str, In))
            preorderTreeWalk(root)
            print " " + " ".join(map(str, Pre))

### FIXED CODE ###

import sys

class Node:
    def __init__(self, key):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None

def insert(z):
    global root
    y = None
    x = root
    while x is not None:
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    if y is None:
        root = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z

def inorderTreeWalk(node):
    global In
    if node:
        inorderTreeWalk(node.left)
        In.append(str(node.key))
        inorderTreeWalk(node.right)

def preorderTreeWalk(node):
    global Pre
    if node:
        Pre.append(str(node.key))
        preorderTreeWalk(node.left)
        preorderTreeWalk(node.right)

if __name__ == "__main__":
    lines = sys.stdin.readlines()
    del lines[0]

    root = None
    for line in lines:
        if line[0] == "i":
            insert(Node(int(line.split()[1])))
        else:
            In = []
            Pre = []
            inorderTreeWalk(root)
            print " " + " ".join(map(str, In))
            preorderTreeWalk(root)
            print " " + " ".join(map(str, Pre))
A = map(int, input().split())
for i in range(5):
	if (A[i] == 0):
		print(i+1)
        break


### FIXED CODE ###

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

for i in range(5):
    if A[i] == 0:
        print(i + 1)
        break
k = int(i) for i in input().split()
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[k])

### FIXED CODE ###

k = int(input())
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[k-1])
a,b=[int(x) for x in input().split()]
print(a*b,(a+b)*2)


### FIXED CODE ###

a,b = input().split()
a = int( a )
b = int( b )
print(  a * b, 2 * ( a + b ) )
n = input()

for i in range(n):
    a = sqrt(n - i)
    if type(a) is int:
        print(a)
    else:
        pass


### FIXED CODE ###

import numpy

n = int(input())

for i in range(n):
    a = int(numpy.sqrt(n - i))
    b = n - i
    if a**2 == b:
        print(b)
        break
    else:
        pass
s = input()
print("3" if "RRR" in s else "2" if "RR" in s else "1" "R" in s else "0" )

### FIXED CODE ###

s = input()
print("3" if "RRR" in s else "2" if "RR" in s else "1" if "R" in s else "0" )
a,b,c=input().split()
print((a[0],b[0],c[0],sep='').upper)

### FIXED CODE ###

a,b,c=input().split()
print((a[0]+b[0]+c[0]).upper())