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

X = int(input())
if X < 100:
    print(0)
else:
    item = [100, 101, 102, 103, 104, 105]
    dp = [[False for _ in range(X//100+10)] for _ in range(X+10)]
    dp[0][0] = True
    dp[100][1] = True
    dp[101][1] = True
    dp[103][1] = True
    dp[102][1] = True
    dp[105][1] = True
    for x in range(200, X+1):
        for n in range(2, x//100+1):
            for i in item:
                if dp[x-i][n-1]:
                    dp[x][n] = True
                    if x == X:
                        break
    if True in dp[X]:
        print(1)
    else:
        print(0)

### FIXED CODE ###

X = int(input())
dp = [False for _ in range(X+1)]
dp[0] = True
for x in range(X+1):
    if x > 99:
        item = [100, 101, 102, 103, 104, 105]
        for i in item:
            if dp[x-i]:
                dp[x] = True
if dp[X]:
    print(1)
else:
    print(0)
### BUGGY CODE ###

N, M = map(int,input().split())
A_list = [int(input()) for _ in range(M)]
Dp_list = [0] * (N+1)
Dp_list[0] = 1
inf = 1000000007

if 1 in A_list:
    Dp_list[1] = 0
else:
    Dp_list[1] = 1

if N != 1:
    for i in range(2, N + 1):
        if i in A_list:
            continue

        Dp_list[i] = Dp_list[i-2] + Dp_list[i-1]
        Dp_list[i] %= inf
    print(Dp_list[N])
else:
    print(1)

### FIXED CODE ###

N, M = map(int,input().split())
A_list = set([int(input()) for _ in range(M)])
Dp_list = [0] * (N+1)
Dp_list[0] = 1

if 1 in A_list:
    Dp_list[1] = 0
else:
    Dp_list[1] = 1

if N != 1:
    for i in range(2, N + 1):
        if i in A_list:
            continue

        Dp_list[i] = Dp_list[i-2] + Dp_list[i-1]
        Dp_list[i] %= 1000000007
    print(Dp_list[N])
else:
    print(1)
### BUGGY CODE ###

n,q =map(int,input().split())
s = input()

d= {}

for k in range(n-1):
    d[k]=0

for j in range(n-1):
    if s[j:j+2]=='AC':
        d[j]+=1

# print(d)

ans = []
for _ in range(q):
    l,r = map(int,input().split())

    tmp = 0
    for p in range(l-1 , r-1):
        tmp+=d[p]

    ans.append(tmp)



for i in ans:
    print(i)

### FIXED CODE ###

n,q =map(int,input().split())
s = input()

d= {}

for k in range(n):
    d[k]=0

total = 0
for j in range(n-1):
    if s[j]=='A' and s[j+1]=='C':
        total+=1
        d[j+1]+=total
    else:
        d[j+1]=total
        
# print(d)

ans = []
for _ in range(q):
    l,r = map(int,input().split())

    ans.append(d[r-1] -d[l-1])


for i in ans:
    print(i)
### BUGGY CODE ###

from fractions import gcd
from functools import reduce
 
N=int(input())
a_list = list(map(int, input().split()))
lst = []
for i, a in enumerate(a_list):
    tmp = a_list[:i] + a_list[i+1:]
    lst.append(reduce(gcd, tmp))
print(max(lst))

### FIXED CODE ###

from fractions import gcd
N=int(input())
a_list = list(map(int, input().split()))
gcd_l = [0] * (N+1) 
gcd_r = [0] * (N+1) 
for i, a in enumerate(a_list):
    gcd_l[i+1] = gcd(gcd_l[i], a)
for i in range(N, 0, -1):
    a = a_list[i-1]
    gcd_r[i-1] = gcd(gcd_r[i], a)
ans = 1
# print(gcd_l, gcd_r)
for i in range(N):
    tmp = gcd(gcd_l[i], gcd_r[i+1])
    if (ans < tmp):
        ans = tmp
print(ans)
### BUGGY CODE ###

import sys

H, N = list(map(int, input().split()))
AB = [list(map(int, input().split())) for n in range(N)]

dp = [sys.maxsize for i in range(H+1)]
dp[0] = 0

# 各ダメージ段階の最小値を求める
for i in range(H):
    if dp[i] == sys.maxsize:
        continue
    # 各魔法を使って最小値なら更新
    for j in range(N):
        a = min(i + AB[j][0], H)
        b = dp[i] + AB[j][1]
        if dp[a] > b:
            dp[a] = b

print(dp[H])


### FIXED CODE ###

import sys

H, N = list(map(int, input().split()))
AB = [list(map(int, input().split())) for n in range(N)]

dp = [sys.maxsize for i in range(H+1)]
dp[0] = 0

# 各ダメージ段階の最小値を求める
for i in range(H):
    if dp[i] == sys.maxsize:
        continue
    # 各魔法を使って最小値なら更新
    for j in range(N):
        a = min(i + AB[j][0], H)
        b = dp[i] + AB[j][1]
        if dp[a] > b:
            dp[a] = b

print(dp[H])
### BUGGY CODE ###

import math
              
K = int(input())
total = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            total += math.gcd(c,math.gcd(a,b))
print(total)

### FIXED CODE ###

import math 
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
    
 
a = int(input())
 
ans = 0
 
for i in range(1,a+1):
    for j in range(1,i+1):
        for k in range(1,j+1):
            if i == j and i == k:
                ans += gcd(i,j,k)
            elif i == j or i == k or j == k:
                ans += gcd(i,j,k)*3
            else:
                ans += gcd(i,j,k)*6
print(ans)
### BUGGY CODE ###

#from fractions import gcd
#from math import gcd
import numpy as np
#import sys
#input = sys.stdin.readline
mod = 10**9+7

def obtain_ps(n):
    ps={}
    while(n>1):
        if int(n**0.5)+1<=2:
            ps[n]=1
            n=1
        for i in range(2, int(n**0.5)+1):
            if not n%i==0:
                continue
            i_primary=True
            for j in range(2, int(i**0.5)+1):
                if j %i:
                    i_primary=False
                    break
            if not i_primary:
                continue
            count=1
            r=i
            while(not n%r):
                count +=1
                r*=i
                if count > 10:
                    return -1
            count-=1
            ps[i]=count
            n=n/(i**count)

    return ps

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

ps={}
ps_s=[]
for s in A:
    ps_tmp=obtain_ps(s)
    ps_s.append(ps_tmp)
    for k,v in ps_tmp.items():
        if k in ps.keys():
            ps[k]=max(v, ps_tmp[k])
        else:
            ps[k]=v

ans=0
for ps_tmp in ps_s:
    plus=1
    for k,v in ps.items():
        if k in ps_tmp.keys():
            plus*=k**(v-ps_tmp[k])
        else:
            plus*=k**v

    ans+=plus%mod
#lcm=np.product([k**v for k,v in ps.items()])

#ans = np.sum([lcm // s %mod for s in A]) % mod

print(int(ans%mod))

### FIXED CODE ###

from fractions import gcd
#from math import gcd
import numpy as np
import sys
input = sys.stdin.readline
mod = 10**9+7

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

lcm = 1
for s in A:
    lcm = s*lcm//gcd(lcm, s)

ans = lcm*sum([pow(s, mod-2, mod) for s in A]) % mod
#ans = sum([lcm//s % mod for s in A]) % mod

print(int(ans%mod))
### BUGGY CODE ###

import sys

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

if k==0:
    print(max(a))
    sys.exit()

def rf(mm):
    if mm==0:
        mm=1
    icnt=0
    for i in range(n):
        icnt+=(a[i]-1)//mm+1
    return icnt

asum=sum(a)
m=asum//(n+k)
um=asum
lm=1
for ii in range(60):
    if m==1:
        break
    rfm=rf(m)
    if rfm<=(n+k) and rf(m-1)>(n+k):
        break
    if um-lm<5:
        break
    if rfm>(n+k):
        lm=m
        m=(um+lm)//2-1
    elif rfm<(n+k):
        um=m
        m=(um+lm)//2-1
    else:
        um=m-1
        m=(um+lm)//2-1

if um<1:
    print(1)
    sys.exit()
    
for mi in range(um,max(0,lm-1),-1):
    if rf(mi)<=(n+k) and rf(mi-1)>(n+k):
        break

print(mi)



### FIXED CODE ###

import sys

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

if k==0:
    print(max(a))
    sys.exit()

def rf(mm):
    if mm==0:
        mm=1
    icnt=0
    for i in range(n):
        icnt+=(a[i]-1)//mm+1
    return icnt

asum=sum(a)
m=asum//(n+k)
um=asum
lm=1
for ii in range(60):
    if m==1:
        break
    if rf(m)<=(n+k) and rf(m-1)>(n+k):
        break
    if um-lm<5:
        break
    if rf(m)>(n+k):
        lm=m
        m=(um+lm)//2-1
    elif rf(m)<(n+k):
        um=m
        m=(um+lm)//2-1
    else:
        um=m-1
        m=(um+lm)//2-1
#    if rf(m)==(n+k) and um-lm<5:

if um<1:
    print(1)
    sys.exit()
    
for mi in range(um,max(0,lm-1),-1):
    if rf(mi)<=(n+k) and rf(mi-1)>(n+k):
        break

print(mi)
### BUGGY CODE ###

n = int(input())

word_list = []

for i in range(n):
    word = input()
    if(word in word_list):
        continue
    word_list.append(word)
    
        

print(len(word_list))

### FIXED CODE ###

n = int(input())

word_list = [input() for i in range(n)]
l = len(set(word_list))
        
print(l)
### BUGGY CODE ###

N = int(input())
a = list(map(int,input().split()))
li = list(set(a))
a.sort()
li.sort()
count = 0
for i in range(len(li)):
    tmp1= a.count(li[i])
    tmp2 = li[i]
    if tmp1 > tmp2:
        count += tmp1-tmp2
    elif tmp2 > tmp1:
        count += tmp1
print(count)

### FIXED CODE ###

from collections import Counter

N = int(input())
A = list(map(int,input().split()))
A = Counter(A)
keys = list(A.keys())
count = 0
for i in range(len(A)):
    if keys[i]!=A[keys[i]]:
        if keys[i]>A[keys[i]]:
            count += A[keys[i]]
        else:
            count += A[keys[i]]-keys[i]
print(count)
### BUGGY CODE ###

#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict(list)
#import bisect
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    V = readInts()
    C = readInts()
    ans = -1
    for bit in range(1 << n):
        # bit 全探索
        cost = 0
        value = 0
        for i in range(n):
            if bit & (1 << i):
                # もしフラグが立っていたら、
                cost += C[i]
                value += V[i]
        ans = max(ans,value - cost)
    print(ans)
if __name__ == '__main__':
  main()


### FIXED CODE ###

#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
def main():
  n=int(input())
  v=list(map(int,input().split()))
  c=list(map(int,input().split()))
  x=[0]*n
  for i in range(n):
    x[i]=max(0,v[i]-c[i])
  print(sum(x))
if __name__ == '__main__':
  main()
### BUGGY CODE ###

H,N,*AB = map(int, open(0).read().split())
dp = [0]+[10**8]*H
for n in range(N):
  A,B = AB[2*n:2*(n+1)]
  for h in range(1,H+1): dp[h] = min(dp[h],dp[max(0,h-A)]+B)
print(dp[-1])

### FIXED CODE ###

H,N,*AB = map(int, open(0).read().split())
dp = [0]+[10**8]*H
for n in range(N):
  A,B = AB[2*n:2*(n+1)]
  for h in range(1,H+1): dp[h] = min(dp[h],dp[max(0,h-A)]+B)
print(dp[-1])
### BUGGY CODE ###

n, k = map(int, input().split())
p_n = list(map(int, input().split()))
v_n = []

s = 0
max_s = 0
max_i = 0

for i in range(n - k + 1):
    s = sum(p_n[i:i + k])

    if s > max_s:
        max_s = s

print((max_s + k) / 2)

### FIXED CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))

s = sum(p[:k])
max_s = s

for i in range(n - k):
    s = s - p[i] + p[i + k]

    if max_s < s:
        max_s = s

print((max_s + k) / 2)
### BUGGY CODE ###

N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]

A.sort()

for i,j in BC:

    for k in range(i):
        if A[k] < j:
            A[k] = j
        else:
            break

    A.sort()

print(sum(A))


### FIXED CODE ###

N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]

A.sort()
S_BC = sorted(BC,key=lambda x:x[1],reverse=True)

index = 0
flag = 0
for Bj,Cj in S_BC:
    for k in range(Bj):
        if len(A) >= index+1:
            if A[index] < Cj:
                A[index] = Cj
                index += 1
            else:
                flag = 1
                break
        else:
            flag = 1
            break
        
    if flag == 1:
        break

print(sum(A))
### BUGGY CODE ###

import itertools
import operator

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

for i in range(len(list(itertools.combinations(A, 2)))):
    n = list(itertools.combinations(A, 2))
    if n[i][0]*n[i][1] >= (10**9+7):
        num = n[i][0]*n[i][1]%(10**9 +7)

    AA.append(n[i][0]*n[i][1])


if sum(AA) >= (10**9 +7):
    print(sum(AA)%(10**9 +7))
else:
    print(sum(AA))


### FIXED CODE ###

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

mod = 10**9 + 7
S = sum(A)%mod
ans = 0

for x in A:
    S -= x
    S %= mod
    ans += S * x
    ans %= mod

ans %= mod
print(ans)
### BUGGY CODE ###

from functools import reduce
import math

def main():
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    S = list(_ for _ in input())
    S = S[::-1]    
    S_num = 0
    temp_ans_0 = ''
    temp_ans_1 = ''
    num_temp_ans_0 = 0
    num_temp_ans_1 = 0
    # for i in range(len(S)):
    #     if(i%2 ==0):
    #         temp_ans_0 += '0'
    #         temp_ans_1 += '1'
    #     else:
    #         temp_ans_0 += '1'
    #         temp_ans_1 += '0'
    for i in range(len(S)):
        S_num += int(S[i]) * 2**i
        if(i%2 ==0):
            num_temp_ans_0 += 0 * 2**i
            num_temp_ans_1 += 1 * 2**i
        else:
            num_temp_ans_0 += 1 * 2**i
            num_temp_ans_1 += 0 * 2**i
            
    c0 = bin(S_num ^ num_temp_ans_0).count('1')
    c1 = bin(S_num ^ num_temp_ans_1).count('1')
    
    print(min(c0,c1))
    
if __name__ == '__main__':
    main()


### FIXED CODE ###

from functools import reduce
import math

def main():
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    S = list(_ for _ in input())
    S = S[::-1]    
    S_num = 0
    temp_ans_0 = '0b'
    temp_ans_1 = '0b'
    num_temp_ans_0 = 0
    num_temp_ans_1 = 0
    for i in range(len(S)):
        if(i%2 ==0):
            temp_ans_0 += '0'
            temp_ans_1 += '1'
        else:
            temp_ans_0 += '1'
            temp_ans_1 += '0'
    # i = 0
    # for s in S:
    #     S_num += int(s) * 2**i
    #     if(i%2 ==0):
    #         num_temp_ans_0 += 0 * 2**i
    #         num_temp_ans_1 += 1 * 2**i
    #     else:
    #         num_temp_ans_0 += 1 * 2**i
    #         num_temp_ans_1 += 0 * 2**i
    #     i +=1
    S_str ='0b'+''.join(S)
    S_num = int(S_str,0)
    num_temp_ans_0 = int(temp_ans_0,0)
    num_temp_ans_1 = int(temp_ans_1,0) 
    c0 = bin(S_num ^ num_temp_ans_0).count('1')
    c1 = bin(S_num ^ num_temp_ans_1).count('1')
    
    print(min(c0,c1))
    
if __name__ == '__main__':
    main()
### BUGGY CODE ###

from math import floor
a,b,n = map(int,input().split())
ans = 0
for i in range(max(0,int(n/max(a,b))-1),n+1):
    ans = max(ans,floor(a*i/b) - a*floor(i/b))
print(ans)

### FIXED CODE ###

from math import floor
a,b,n = map(int,input().split())
ans = 0
if n <= b:
    for i in range(max(0,n-9),n+1):
        ans = max(ans,floor(a*i/b) - a*floor(i/b))
else:
    for i in range(max(0,b-10),min(n,b+10)):
        ans = max(ans,floor(a*i/b) - a*floor(i/b))
print(ans)
### BUGGY CODE ###

from sys import stdin

S = input()
Q = int(input())

T_list = []
for q in range(Q):
    T = stdin.readline()[:-1]

    if T == '1':
        S = S[::-1]

    else:
        t, f, c = T.split()

        if f == '1':
            tmp_s = [c, S]
            S = ''.join(tmp_s)
        else:
            tmp_s = [S, c]
            S = ''.join(tmp_s)

print(S) 


### FIXED CODE ###

from sys import stdin

S = input()
Q = int(input())

reverse_flg = False

former_list = []
latter_list = []

for q in range(Q):
    T = stdin.readline()[:-1]

    if T == '1':
        if reverse_flg:
            reverse_flg = False
        else:
            reverse_flg = True
    
    else:
        t, f, c = T.split()
        if (f == '1' and reverse_flg == False) or (f == '2' and reverse_flg == True):
            former_list.append(c)
        else:
            latter_list.append(c)


if reverse_flg:
    latter_list = ''.join(reversed(latter_list))
    former_list = ''.join(former_list)
    S = ''.join(list(reversed(S)))
    S = ''.join([latter_list, S, former_list])

else:
    former_list = ''.join(reversed(former_list))
    latter_list = ''.join(latter_list)
    S = ''.join([former_list, S, latter_list])

print(S)
### BUGGY CODE ###

import itertools
N,M=map(int,input().split())
kslist=[]
for i in range(M):
    kslist.append(list(map(int,input().split()))) 
plist=list(map(int,input().split()))
seq=[0]*N+[1]*N
ls=list(set(list(itertools.permutations(seq,N))))
n=0
for tup in ls:
    ln=[]
    for j in range(M):
        sum1=0
        for k in range(1,kslist[j][0]+1):
            sum1+=tup[kslist[j][k]-1]
        ln.append(sum1%2)
    if ln==plist:
        n+=1
        
print(n)            
    

### FIXED CODE ###

import itertools
N,M=map(int,input().split())
kslist=[(list(map(int,input().split()))) for i in range(M)]
plist=list(map(int,input().split()))
ls=list((itertools.product(range(2),repeat=N)))
n=0
for tup in ls:
    n+=1
    for j in range(M):
        sum1=0
        for k in range(1,kslist[j][0]+1):
            sum1+=tup[kslist[j][k]-1]
        if sum1%2!=plist[j]:
            n=n-1
            break
print(n)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000)
from collections import deque

def bfs(sx,sy,gx,gy):
    d = [[float("inf")] * w for i in range(h)]
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    que = deque([])
    que.append((sx, sy))
    d[sx][sy] = 0

    while que:
        p = que.popleft()
        if p[0] == gx and p[1] == gy:
            break
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            if 0 <= nx < h and 0 <= ny < w and s[nx][ny] != "#" and d[nx][ny] == float("inf"):
                que.append((nx, ny))
                d[nx][ny] = d[p[0]][p[1]] + 1

    return d[gx][gy]

h,w=map(int,input().split())
s = [list(input()) for i in range(h)]
ans=0
memo=[[0] * w for i in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j]=='.':
            for k in range(i,h):
                if i != k:
                    for l in range(w):
                        if s[k][l]=='.':
                            ans = max(ans,bfs(i,j,k,l))
                else:
                    for l in range(j,w):
                        if s[k][l]=='.':
                            ans = max(ans,bfs(i,j,k,l))
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
from collections import deque


h,w=map(int,input().split())
s = [list(input()) for i in range(h)]

def bfs(sx,sy):
    dx = [0,1,0,-1]
    dy = [1,0,-1,0]
    d = [[-1]*w for i in range(h)]
    q = deque()
    q.append((sx,sy))
    d[sx][sy] = 0
    while q:
        x,y = q.popleft()
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if  0<= nx < h and 0 <= ny < w and d[nx][ny]==-1 and s[nx][ny]=='.':
                q.append((nx,ny))
                d[nx][ny] = d[x][y]+1
    return max([max(i) for i in d])

count = 0
for i in range(h):
    for j in range(w):
        if s[i][j] != '#':
            count  = max(count, bfs(i,j))
print(count)
### BUGGY CODE ###

s=[input()]
q=int(input())
turn=True
dic={'1':True,'2':False}

for i in range(q):
    qq=input().split()
    if qq[0]=='1':
        turn=not turn
    else:
        if turn==dic[qq[1]]:
            s.insert(0,qq[2])
        else:
            s.append(qq[2])
text="".join(s)
print(text if turn else text[::-1])

### FIXED CODE ###

s=[input()]
q=int(input())
turn=True
l=""
for i in range(q):
    qq=input().split()
    if qq[0]=='1':
        turn=not turn
    else:
        if turn==bool(int(qq[1])-2):
            l+=qq[2]
        else:
            s.append(qq[2])

text=l[::-1]+"".join(s)
print(text if turn else text[::-1])
### BUGGY CODE ###

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

s = set()
for i in range(N-2):
  for j in range(i+1, N-1):
    for k in range(j+1, N):
      s.add(S[i]+S[j]+S[k])
print(len(s))

### FIXED CODE ###

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

ans = 0
for i in range(10):
  a = S.find(str(i))
  if a != -1:
    for j in range(10):
      b = S.find(str(j), a+1)
      if b != -1:
        for k in range(10):
          c = S.find(str(k), b+1)
          if c != -1:
            ans += 1
print(ans)
### BUGGY CODE ###

# encoding: utf-8
N, M = list(map(int, input().split()))

# TLE
# Amod = [A for A in map(lambda x: int(x) % M , input().split())]
# ans = 0
# for l in range(len(Amod)):
#     acm = 0
#     for r in range(l, len(Amod)):
#         acm = (acm + Amod[r]) % M
#         if acm == 0: ans += 1

Asym = [0 for i in range(N)]
sym = 0
for i, A in enumerate(map(int, input().split())):
    sym = (sym + A) % M
    Asym[i] += sym
    
ans = Asym.count(0)
for sym in set(Asym):
    cnt = Asym.count(sym)
    ans +=  int(cnt * (cnt -  1) / 2)

print(ans)

# Acnt = [0 for i in range(M)]
# sym = 0
# for A in map(int, input().split()):
#     sym = (sym + A) % M
#     Acnt[sym] += 1

# print(int(Acnt[0] + sum([cnt * (cnt - 1) for cnt in Acnt]) / 2))

### FIXED CODE ###

# encoding: utf-8
N, M = list(map(int, input().split()))

d_sym = {}
sym = 0

# refresh

ans = 0
for A in map(int, input().split()):
    sym = (sym + A) % M
    #
    if sym == 0: ans += 1
    # 
    if str(sym) in d_sym.keys(): d_sym[str(sym)] += 1
    else: d_sym[str(sym)] = 1

print(int(ans + sum([val * (val - 1) / 2 for val in d_sym.values()])))
### BUGGY CODE ###

n,q = map(int, input().split())
s = input()

for i in range(q):
    l,r = map(int, input().split())
    print(s[l-1:r].count("AC"))


### FIXED CODE ###

n,q = map(int, input().split())
s = input()

cum_sum = [0]
sum = 0
for i in range(n-1):
    if s[i] == "A" and s[i+1] == "C":
        sum += 1
    cum_sum.append(sum)

for i in range(q):
    l, r = map(int, input().split())
    print(cum_sum[r-1] - cum_sum[l-1])
### BUGGY CODE ###

import fractions
def main():
  _=input()
  a=tuple(map(int,input().split()))
  a1=a[0]
  fgcd=fractions.gcd
  for i in a:
    if a1%i:
        a1=(i*a1)//fgcd(i,a1)
  x=[a1//i for i in a]
  print(sum(x)%(10**9+7))
  
if __name__ == '__main__':
    main()

### FIXED CODE ###

import fractions
from functools import reduce
def main():
  _=input()
  a=tuple(map(int,input().split()))
  fgcd=fractions.gcd
  def lcm_base(x, y):
    return (x * y) // fgcd(x, y)
  def lcm(numbers):
    return reduce(lcm_base, numbers, 1)
  q=lcm(a)
  x=[q//i for i in a]
  print(sum(x)%(10**9+7))
  
if __name__ == '__main__':
    main()
### BUGGY CODE ###

def n_gram(s, n):
	return [s[i:i+n] for i in range(len(s)-n+1)]

s = input()
k = int(input())

n_gram_set = set()
for i in range(1, len(s)+1):
	n_gram_set = n_gram_set | set(n_gram(s, i))

print(sorted(list(n_gram_set))[k-1])

### FIXED CODE ###

def n_gram(s, n):
	return [s[i:i+n] for i in range(len(s)-n+1)]

s = input()
k = int(input())

subs = set()
for k_i in range(1, k+1):
	subs = subs | set(n_gram(s, k_i))
print(sorted(subs)[k-1])