Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import sys
input = sys.stdin.readline


def main():
    N = int(input())
    A = ["?"]*N

    l, x, r = 0, N//2, N-1
    while True:
        ls = A[l]
        if ls == "?":
            print(l, flush=True)
            ls = input().strip()
            if ls == "Vacant":
                return
            A[l] = ls

        xs = A[x]
        if xs == "?":
            print(x, flush=True)
            xs = input().strip()
            if xs == "Vacant":
                return
            A[x] = xs

        rs = A[r]
        if rs == "?":
            print(r, flush=True)
            rs = input().strip()
            if rs == "Vacant":
                return
            A[r] = rs

        if ls != xs:
            l, x, r = l, (l+x)//2, x
        elif rs != xs:
            l, x, r = x, (x+r)//2, r


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline


def q(i):
    print(i, flush=True)
    s = input().strip()
    if s == "Vacant":
        exit()
    return s


def f(l, r, lc, rc):
    m = (l+r)//2
    mc = q(m)

    if ((m-l) % 2 and lc == mc) or ((m-l) % 2 == 0 and lc != mc):
        f(l, m, lc, mc)
    elif ((r-m) % 2 and mc == rc) or ((r-m) % 2 == 0 and mc != rc):
        f(m, r, mc, rc)


def main():
    N = int(input())
    lc = q(0)
    rc = q(N-1)
    f(0, N-1, lc, rc)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
import bisect
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
#Query = []
#for _ in range(m):
#    b,c = map(int,input().split())
#    Query.append([c,b])
#Query.sort(reverse=True)
Query = [list(map(int,input().split())) for _ in range(m)]
Query = sorted(Query, key=lambda x:(x[1], x[0]), reverse=True)
ans = 0
for b,c in Query:
    #b,c = Query[i][1],Query[i][0]
    #b,c = Query[i][0],Query[i][1]
    if A[0] >= c:
        break
    else:
        #A.sort()
        index = bisect.bisect_left(A,c)
        ans += sum(A[index:])
        if b <= index:
            #for i in range(b):
            #    A[i] = c
            A = A[b:index]
            A.extend([c for i in range(b)])
        else:
            #for i in range(index):
            #    A[i] = c
            A = [ c for i in range(index)]
    #print(A)
print(ans + sum(A))

### FIXED CODE ###

import sys
input = sys.stdin.readline
import bisect
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

minA = A[0]
Query = []
for _ in range(m):
    b,c = map(int,input().split())
    if c > minA:
        Query.append([b,c])
Query = sorted(Query, key=lambda x:(x[1], x[0]), reverse=True)

ans = 0
index = 0
for b,c in Query:
    if index >= n:
        break
    #print("----")
    cnt = 0
    Flag = True
    while Flag:
        #print(A,b,c,index)
        if A[index] < c:
            A[index] = c
            cnt += 1
            index += 1
            if (cnt >= b) or (index >= n):
                Flag = False
        else:
            Flag = False
    '''
    #A.sort()
    if A[0] >= c:
        break
    else:
        index = min(bisect.bisect_left(A,c),b)
        if index > len(A):
            ans += c * len(A)
            break
        else:
            ans += c * index
            A = A[index:]
    print(A)
    '''
print(sum(A))
### BUGGY CODE ###

def gcd(a,b):
    a, b = max([a,b]), min([a,b])
    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)

n = int(input())
ans = 0
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            ans += gcd(gcd(i,j),k)
print(ans)
            


### FIXED CODE ###

from math import gcd

n = int(input())
ans = 0
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      ans += gcd(gcd(i,j),k)
print(ans)
### BUGGY CODE ###

x=int(input())
while(x%i<1 for i in range(2,x)):
  x+=1

print(x)


### FIXED CODE ###

x = int(input())
while any(x % i < 1 for i in range(2, x)): 
    x += 1
print(x)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split(" ")))

ans = 0
den = int(1e9 + 7)
for i in range(len(a) - 1):
    ans = (ans + a[i] * sum(a[i + 1:])) % den

print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split(" ")))

ans = 0
den = int(1e9 + 7)
sum_a = [0 for i in range(len(a))]
sum_a[-1] = a[-1]
for i in range(len(a) - 1, 1, -1):
    sum_a[i - 1] = sum_a[i] + a[i - 1]
for i in range(len(a) - 1):
    ans = (ans + a[i] * sum_a[i + 1]) % den

print(ans)
### BUGGY CODE ###

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

A = 0

for i in range(N):
  if P[i] <= min(P[0:i+1]):
  	A += 1
print(A)

### FIXED CODE ###

N = int(input())
P = list(map(int, input().split()))
 
A = 0
C = P[0]
for i in range(N):
  if P[i] <= C:
    C = P[i]
    A += 1
print(A)
### BUGGY CODE ###

n = int(input())
arr = []
for i in range(n):
    arr.append(int(input()))
visited = []
i = 0
c = 0
while i != 1 and i not in visited:
    visited.append(i)
    i = arr[i]-1
    c += 1
if i == 1:
    print(c)
else:
    print(-1)

### FIXED CODE ###

n = int(input())
arr = []
for i in range(n):
    arr.append(int(input())-1)
now = 0
c = 0
while True:
    if now == 1:
        print(c)
        break
    if c >= n:
        print(-1)
        break
    c += 1
    now = arr[now]
### BUGGY CODE ###

import sys
import math
from collections import Counter
import itertools
import fractions
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################
 

X=II()

for i in range(0, 1000000):
    for j in range(-1000000, 1000000):
        if i**5-j**5==X:
            print(i,j)
            exit()

### FIXED CODE ###

import sys
import math
from collections import Counter
import itertools
import fractions
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################
 

X=II()

for i in range(0, 1000):
    for j in range(-1000, 1000):
        if i**5-j**5==X:
            print(i,j)
            exit()
### BUGGY CODE ###

N, K = map(int,input().split())
A = sorted(map(int,input().split()))
F = sorted(map(int,input().split()),reverse=True)
low,high = -1, max(map(lambda x,y:x*y, A,F))
while high-low>1:
  mid = (high+low)//2
  k = sum(map(lambda x,y: x-min(x,mid//y), A,F))
  if k>K: low = mid
  else: high = mid
print(high)

### FIXED CODE ###

import numpy as np
N, K = map(int,input().split())
A = np.array(sorted(map(int,input().split())))
F = np.array(sorted(map(int,input().split()) ,reverse=True))
low,high = -1, int(1e12)
while high-low>1:
  mid = (high+low)//2
  k = (A-np.minimum(A,mid//F)).sum()
  if k>K: low = mid
  else: high = mid
print(high)
### BUGGY CODE ###

import math

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

if (x+y)%3 != 0:
    ans = 0
else:
    m = (2*x - y) //3
    n = x - 2*m
    if m <0 or n < 0 :
        ans = 0
    else:
        ans = math.factorial(n+m) // (math.factorial(n+m - m) * math.factorial(m))

print(ans%(10**9+7))

### FIXED CODE ###

import math

x, y = map(int,input().split())
mod = 10**9+7 #出力の制限

def cmb(n, k,MOD):
    if k > n - k:
        k = n - k
    ans = 1
    for i in range(1, k + 1):
        ans *= n + 1 - i
        ans *= pow(i, MOD - 2, MOD)
        ans %= MOD
    return ans

if (x+y)%3 != 0:
    ans = 0
else:
    m = (2*x - y) //3
    n = x - 2*m
    # print(m,n)
    if m <0 or n < 0 :
        ans = 0
    else:
        ans = cmb(n+m, m, mod)
print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())
h = list(map(int, input().split()))
h_dict = {}
for i, name in enumerate(h):
    h_dict[i] = name

ab = []
for _ in range(m):
    ab.append(list(map(int, input().split())))
for l in range(len(ab)):
    ab.append([ab[l][1], ab[l][0]])

flg_bad = []
for i in range(len(h_dict)):
    for j in ab:
        if i+1 == j[0]:
            if h[i] <= h[j[1]-1]:
                flg_bad.append(1)
                break

print(len(h) - len(flg_bad))


### FIXED CODE ###

n, m = map(int, input().split())
h = list(map(int, input().split()))
h_dict = {}
for i, name in enumerate(h, 1):
    h_dict[i] = name

ab = []
for _ in range(m):
    ab.append(list(map(int, input().split())))

flg_bad = set()
for j in ab:
    if h_dict[j[0]] < h_dict[j[1]]:
        flg_bad.add(j[0])
    elif h_dict[j[0]] > h_dict[j[1]]:
        flg_bad.add(j[1])
    elif h_dict[j[0]] == h_dict[j[1]]:
        flg_bad.add(j[0])
        flg_bad.add(j[1])

print(len(h) - len(flg_bad))
### BUGGY CODE ###

def popcount(n):
    return bin(n).count('1')


def main():
    N = int(input())
    X = input()

    X_int = int(X, 2)

    pcount_X = popcount(X_int)
    pcount_X_pls1 = pcount_X + 1
    pcount_X_mns1 = pcount_X - 1

    for i,bit in enumerate(X):
        bit = int(bit)
        if bit == 0:
            pcount_Xi = pcount_X_pls1
        else:
            pcount_Xi = pcount_X_mns1
            if pcount_Xi == 0:
                print(0)
                continue

        n = ((X_int % pcount_Xi) + pow(2, N-i-1, pcount_Xi) * (-1)**bit) % pcount_Xi

        ans = 1
        while n > 0:
            ans += 1
            n %= popcount(n)
        print(ans)
        
main()

### FIXED CODE ###

def popcount(n):
    return bin(n).count('1')


def main():
    N = int(input())
    X = input()

    X_int = int(X, 2)

    pcount_X = popcount(X_int)

    pcount_X_pls1 = pcount_X + 1
    pcount_X_mns1 = pcount_X - 1
    
    X_mod_pcount_X_pls1 = X_int % pcount_X_pls1
    if pcount_X_mns1 != 0:
        X_mod_pcount_X_mns1 = X_int % pcount_X_mns1

    for i,bit in enumerate(X):
        bit = int(bit)
        if bit == 0:
            n = (X_mod_pcount_X_pls1 + pow(2, N-i-1, pcount_X_pls1)) % pcount_X_pls1
        else:
            if pcount_X_mns1 == 0:
                print(0)
                continue
            n = (X_mod_pcount_X_mns1 - pow(2, N-i-1, pcount_X_mns1)) % pcount_X_mns1

        ans = 1
        while n > 0:
            ans += 1
            n %= popcount(n)
        print(ans)
        
main()
### BUGGY CODE ###

N, M = map(int, input().split())
X = list(map(int, input().split()))
t = sorted(X, reverse=True)
h = [0] * M
for i in range(1, M):
    h[i] = abs(t[i - 1] - t[i])

for i in range(N - 1):
    tmp = h.index(max(h))
    h[tmp] = 0
print(sum(h))

### FIXED CODE ###

N, M = map(int, input().split())
X = list(map(int, input().split()))
t = sorted(X, reverse=True)
h = [0] * M
for i in range(1, M):
    h[i] = abs(t[i - 1] - t[i])

tmp = sorted(h, reverse=True)
print(sum(tmp[N - 1:]))
### BUGGY CODE ###

import sys
 
 
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
 
 
def get_ints(): return map(int, sys.stdin.readline().strip().split())
 
 
def input(): return sys.stdin.readline().strip()
 
 
def maxim(i, char):
    if i < 0:
        return 0
 
    if li[i][char] != -1:
        ##print('hi')
        ##print(i,char)
        return li[i][char]
    if char == 2:
        li[i][2] = max(c[i] + maxim(i - 1, 1), c[i] + maxim(i - 1, 0))
        return li[i][2]
    if char == 1:
        li[i][1] = max(b[i] + maxim(i - 1, 0), b[i] + maxim(i - 1, 2))
        return li[i][1]
    if char == 0:
        li[i][0] = max(a[i] + maxim(i - 1, 1), a[i] + maxim(i - 1, 2))
        return li[i][0]
    if char == 3:
        li[i][3] = (max(maxim(i - 1, 2), maxim(i - 1, 1), maxim(i - 1, 0)))
        return li[i][3]
 
 
n = int(input())
a, b, c = [], [], []
for _ in range(n):
    x, y, z = get_ints()
    li = [[-1 for i in range(4)] for j in range(n+1)]
    a.append(x)
    b.append(y)
    c.append(z)
li = [[-1 for i in range(4)] for j in range(n+1)]
print(maxim(n , 3))

### FIXED CODE ###

import sys
def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()


n=int(input())
a, b, c = [], [], []
for _ in range(n):
    x,y,z=get_ints()
    
    a.append(x)
    b.append(y)
    c.append(z)
li=[[-1 for i in range(3)]for j in range(n)]
li[0][0],li[0][1],li[0][2]=a[0],b[0],c[0]
for i in range(1,n):


        li[i][0] = max(a[i] + li[i-1][1] ,a[i] + li[i - 1][2])

        li[i][1] = max(b[i] + li[i - 1][0], b[i] +li[i - 1][2])

        li[i][2] = max(c[i] + li[i - 1][1], c[i] + li[i - 1][0])
print(max(li[n-1]))
### BUGGY CODE ###

n = input()
a = map(int, raw_input().split())

res = []
for i in range(n):
  res += [a[i]]
  res.reverse()
print ' '.join(map(str, res))

### FIXED CODE ###

from collections import deque
n = input()
a = map(int, raw_input().split())

res = deque()

for i in range(n):
  if i % 2 == 0:
    res.appendleft(a[i])
  else:
    res.append(a[i])
if n % 2 == 0:
  print ' '.join(map(str, reversed(res)))
else:
  print ' '.join(map(str, res))
### BUGGY CODE ###

n=int(input())
import fractions 
from functools import reduce
arr = list(map(int,input().split()))


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)
    
a = lcm(arr)

ans = 0

for i in arr:
    ans+= (a//i)%1000000007
    if ans >=1000000007:
        ans % 1000000007
print(ans %(1000000000+7))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
 
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
 
a = 1
for i in range(N):
    a = lcm(a, A[i])
 
ans = 0
for i in range(N):
    ans += a * pow(A[i], mod-2, mod)
 
print(ans % mod)
### BUGGY CODE ###


from functools import reduce
from itertools import combinations
from fractions import gcd

def get_gcd(number_list):
    return reduce(gcd, number_list)

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

skipped = list(map(list, combinations(Numbers, N - 1)))

gcd_list = [get_gcd(item) for item in skipped]
    
print(int(max(gcd_list)))

### FIXED CODE ###

from functools import reduce
from itertools import combinations
from fractions import gcd

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


Left = [0] * (N + 1)
Right = [0] * (N + 1)

for i in range(N):
    Left[i + 1] = gcd(Left[i], A[i])
    Right[N - i - 1] = gcd(Right[N - i], A[N - i - 1])
ans = 0
for i in range(N):
    ans = max(ans, gcd(Left[i], Right[i + 1]))
    
print(ans)
### BUGGY CODE ###

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

dictA = {}

for z in A:
    dictA.setdefault(z, 0)
    dictA[z] += 1


BC = [list(map(int, input().split())) for i in range(Q)]
for x in BC:
    if x[0] in dictA:
        if x[1] in dictA:
            dictA[x[1]] += dictA[x[0]]
        else:
            dictA[x[1]] = dictA[x[0]]
        del dictA[x[0]]

    sumA = 0
    for k, v in dictA.items():
        sumA += k * v
    print(sumA)


### FIXED CODE ###

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

dictA = {}

for z in A:
    dictA.setdefault(z, 0)
    dictA[z] += 1

sumA = sum(A)

BC = [list(map(int, input().split())) for i in range(Q)]
for x in BC:
    if x[0] in dictA.keys():
        sumA += (x[1] - x[0]) * dictA[x[0]]
        dictA.setdefault(x[1], 0)
        dictA[x[1]] += dictA[x[0]]
        dictA.pop(x[0])
    print(sumA)
### BUGGY CODE ###

N, X, Y = map(int, input().split())
ans = [0]*(N-1)
for i in range(N-1):
    for j in range(i+1,N):
        dist = min(j-i, min(abs(X-1-i)+1+abs(Y-1-j), abs(Y-1-i)+1+abs(X-1-j)))
        ans[dist-1] += 1
for i in range(N-1):
    print(ans[i])

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)

N, X, Y = map(int, input().split())

ans = [0]*(N-1)
branch1 = X-1
branch2 = N-Y
cycle = Y-X+1
for i in range(cycle//2):   # 輪の1/2まで両側(2通り）で行ける
    ans[i] += cycle
if cycle%2==0:     # 輪は偶数（両方から同じ距離がある）
    ans[cycle//2-1] -= cycle//2
ans[0] -= 1

for i in range(branch1):
    for j in range(cycle//2):
        if cycle%2==0 and j==cycle//2-1:
            ans[i+j+1] += 1
        elif j == 0:    # 直線経路は除外
            ans[i+j+1] += 1
        else:
            ans[i+j+1] += 2
for i in range(branch2):
    for j in range(cycle//2):
        if cycle%2==0 and j==cycle//2-1:
            ans[i+j+1] += 1
        elif j == 0:    # 直線経路は除外
            ans[i+j+1] += 1
        else:
            ans[i+j+1] += 2

for i in range(branch1+branch2+1):   # 直線経路
    ans[i] += branch1+branch2+1 - i

for i in range(N-1):
    print(ans[i])
### BUGGY CODE ###

L,R = map(int,input().split())

if L-R > 2018:
    print(0)
else:
    minMod = 100000000
    for i in range(L,R):

        for j in range(i+1,R+1):
   
            if minMod > (i*j)%2019:
                minMod = (i*j)%2019
    print(minMod)


### FIXED CODE ###

L,R = map(int,input().split())

if R-L > 672:
    print(0)
else:
    minMod = 2019
    for i in range(L,R):
        for j in range(i+1,R+1):
            tmp = (i*j)%2019
            if tmp == 0:
                minMod = 0
                break
            minMod = min(tmp,minMod)
    print(minMod)
### BUGGY CODE ###

N = int(input())
val = 1
for i in range(1, N+1):
    val *= i
print(val%(10**9 + 7))

### FIXED CODE ###

N = int(input())
val = 1
for i in range(1, N+1):
    val *= i
    if val > 10**9 + 7:
        val = val%(10**9 + 7)
print(val)
### BUGGY CODE ###

N=int(input())
S=list(input())

from collections import*
C=Counter(S)
M=min(26,len(C))

from itertools import*

ans=0
i=1
while i<=M:
    L=list(combinations(C.values(),i))
    j=0
    while j<len(L):
        a=1
        for l in L[j]:
            a*=l 
        ans+=a
        ans%=(10**9+7)
        j+=1
    i+=1

print(ans)

### FIXED CODE ###

N=int(input())
S=list(input())

from collections import*
C=Counter(S)

ans=1
for c in C.values():
    ans*=(c+1)%(10**9+7)
ans=(ans-1)%(10**9+7)

print(ans)
### BUGGY CODE ###

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

for i in range(K):
    if A >= 1:
        A = A - 1
    elif B >= 1:
        B = B - 1
print(A, B)

### FIXED CODE ###

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

if (K - A) <= 0:
    print(A - K, B)
elif (K - A) > 0 and (B - K + A) > 0:
    print(0, B - K + A)
else:
    print(0, 0)
### BUGGY CODE ###

n = int(input())
s = list(str(input()))
for i in range(n):
    if i+2 > len(s):
            break
    while s[i] == s[i+1]:
        s.pop(i+1)
        if i+2 > len(s):
            break
print(len(s))

### FIXED CODE ###

n = int(input())
color = input()
old_color = color[0]
ans = 1
for i in range(1, n):
    if old_color != color[i]:
        ans += 1
        old_color = color[i]
print(ans)
### BUGGY CODE ###


n = int(input())
r = ['0']
for i in range(n):
    k = 0
    tmp = input()
    for j in range(len(r)):
        if(tmp == r[j]):
            k += 1
    
    if(k == 0):
        r.append(tmp)
        

print(len(r)-1)

### FIXED CODE ###


n = int(input())
str = [input() for i in range(n)]
str.sort()
k = 1
for i in range(n-1):
    if(str[i] != str[i + 1]):
        k += 1




print(k)
### BUGGY CODE ###

n = int(input())
l = list(map(int,input().split()))
q = 0
a = 0
for i in l:
  a += 1
  if i<=min(l[:a]):
    q += 1
print(q)

### FIXED CODE ###

n = int(input())
l = list(map(int,input().split()))
q = 1
a = l[0]
for i in range(1,n):
  a = min(l[i],a)
  if l[i]<=a:
    q += 1
print(q)
### BUGGY CODE ###

p = int(input())
b_list = [0 for _ in range(p)]
a_list = list(map(int,input().split()))
if a_list[0] == 1:
    a_list[0] = 0
    b_list[0] = 1
    b_list[p-1] = -1
c = 0
for i in a_list:
    if i == 1:
        for j in range(p-1):
            b_list[j+1] -= c**(p-j-2)
    c += 1
for j in b_list:
    print(j % p,end = ' ')


### FIXED CODE ###

p = int(input())
b_list = [0 for _ in range(p-1)]
a_list = list(map(int,input().split()))
def frac(n):
    if a_list[n] == 1:
        t = 1
        for j in range(p-1):
            b_list[j] -= t
            t = (t*n)%p
if a_list[0] == 1:
    b_list[0] -= 1
for i in range(p-1):
    frac(i+1)
b_list.reverse()
print(a_list[0],end = ' ')
for j in b_list:
    print(j % p,end = ' ')
### BUGGY CODE ###

import fractions
a, b, c, d = map(int, input().split())
ans = 0
nc = 1
nc2 = 0
nd = 1
nd2 = 0 
ndc = 1
ndc2 = 0
while b >= c*nc:
  nc2 += 1
  nc += 1
while b >= d*nd:
  nd += 1
  nd2 += 1
cd = c*d//fractions.gcd(c,d)
while b >= cd*ndc:
  ndc += 1
  ndc2 += 1
nc2 -= (a-1)//c
nd2 -= (a-1)//d
ndc2 -= (a-1)//(cd)
ans = b-a+1-nc2-nd2+ndc2
print(ans)

### FIXED CODE ###

import fractions
a, b, c, d = map(int, input().split())
ans = 0
nc = b//c - (a-1)//c
nd = b//d - (a-1)//d
cd = c*d // fractions.gcd(c,d)
ncd = b//cd - (a-1)//cd
ans = b-a+1-nc-nd+ncd
print(ans)
### BUGGY CODE ###

n = int(input())
arr = list(map(int,input().split()))
dic = {}
for i in arr:
    if i not in dic:
        dic[i]=1
    else:
        dic[i]+=1
for i in arr:
    ans=0
    for j in dic.keys():
        if i==j:
            t=dic[j]-1
            
        else:t = dic[j]
        ans+=(t*(t-1))//2
    print(ans)

### FIXED CODE ###

n = int(input())
arr = list(map(int,input().split()))
dic = {}
for i in arr:
    if i not in dic:
        dic[i]=1
    else:
        dic[i]+=1
ans=0
for j in dic.keys():
    t=dic[j]
    ans+=(t*(t-1))//2
for i in arr:
    sm = ans-(dic[i]-1)
    print(sm)
### BUGGY CODE ###

n, k = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(n)]
c = []
for i in range(n):
    for _ in range(l[i][1]):
        #print(l[i][0])
        c.append(l[i][0])
    
c.sort()
print(c[k-1])

### FIXED CODE ###

N,K=map(int,input().split())
li=sorted([list(map(int,input().split())) for _ in range(N)])
for l in li:
    K-=l[1]
    if K<=0:
        print(l[0])
        break
### BUGGY CODE ###

def count_k(chars, previous):
    if chars == previous:
        return 0
    max_k = 1
    for n in range(1, len(chars)):
        block1 = chars[:n]
        if block1 == previous:
            continue
        block2 = chars[n:]
        k = count_k(block2, block1) + 1
        if k == 1:
            continue
        if max_k >= k:
            break
        else:
            max_k = k
    return max_k


s = input()
print(count_k(tuple(s), tuple()))


### FIXED CODE ###

s = input()
maximum = [(0, [()])]

s = tuple(s)
for i in range(1, len(s) + 1):
    j = i - 1
    while j >= 0:
        max_count, previous = maximum[j]
        if max_count < 0:
            j -= 1
            continue
        current = s[j:i]
        if any(p != current for p in previous):
            if len(maximum) == i + 1:
                mc, blocks = maximum[i]
                if mc == max_count + 1:
                    blocks.append(current)
                break
            else:
                maximum.append((max_count + 1, [current]))
        j -= 1
    else:
        if len(maximum) != i + 1:
            maximum.append((-1, []))
    assert len(maximum) == i + 1

print(maximum[-1][0])