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

#from collections import Counter

import numpy as np

n = int(input())
nums = np.zeros(2001, dtype=int)

ls = map(int, input().split(" "))
#ls = Counter(map(int, ls))
#vals = ls.keys()
ls = sorted(ls)
for l in ls:
    nums[l] += 1

vals = [val for val in range(2001) if nums[val] >= 1]
#print(vals)

cumsum = np.cumsum(nums)

#print(cumsum)
##ls = list(ls)
#ls = np.asarray(ls)
#out = 0
#for i in range(n-1):
#    a = ls[i]
#    for j in range(i+1, n-1):
#        b = ls[j]
#        cur_ls = ls[j+1:]
#        #print(cur_ls, a+b)
#        cur_num = (cur_ls < a+b).sum()
#        out += cur_num

out = 0

a_counts = np.zeros(2001, dtype=int)
for i in range(n-1):
    a = ls[i]
    b_counts = np.zeros(2001, dtype=int)
    a_counts[a] += 1
    for j in range(i+1, n-1):
        b = ls[j]
        b_counts[b] += 1
        if a < b:
            b_count = b_counts[b]
            #print("flag1")
        else:
            assert a == b
            b_count = a_counts[a] + b_counts[b]
            #print("flag2")

        # c > b
        cur_num = max(cumsum[a+b-1] - cumsum[b], 0)
        # c = b
        #print(a, b, nums[b], b_count)
        cur_num += (nums[b] - b_count)

        #print(ls[i], ls[j], cur_num)
        out += cur_num


print(out)        

### FIXED CODE ###

#from collections import Counter

#import numpy as np

input = raw_input
n = int(input())
#nums = np.zeros(2001, dtype=int)
nums = [0] * 2001
#nums = np.zeros(2001, dtype=int)

ls = map(int, input().split(" "))
#ls = Counter(map(int, ls))
#vals = ls.keys()
ls = sorted(ls)
for l in ls:
    #print(l)
    nums[l] += 1

set_vals = [val for val in range(2001) if nums[val] >= 1]
#print(vals)

#cumsum = np.cumsum(nums)

#print(set_vals)
len_set = len(set_vals)
out = 0
for i in range(len_set):
    val1 = set_vals[i]
    num_i = nums[val1]
    if num_i >= 3:
        out += (num_i * (num_i-1) * (num_i-2) // 6)
    
    if num_i >= 2:
        val2 = set_vals[i]
        for j in range(i+1, len_set):
            val3 = set_vals[j]
            num_h = nums[val3]
            if 2 * val1 <= val3:
                break

            out += ((num_i * (num_i-1)) // 2) * num_h

    for j in range(i+1, len_set):
        val2 = set_vals[j]
        num_j = nums[val2]

        if num_j >= 2:
            out += (num_i *  num_j * (num_j - 1) // 2 )

        for h in range(j+1, len_set):
            val3 = set_vals[h]
            #print(val1, val2, val3)
            num_h = nums[val3]
            if val1 + val2 <= val3:
                break

            #print("num", num_i, num_j, num_h)
            out += (num_i * num_j * num_h)

print(out)
### BUGGY CODE ###

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

len_s =  len(s)
L = []

for i in range(1, len_s+1):
    for j in range(len_s-i+1):
        if s[j:j+i] not in L:
            L.append(s[j:j+i])

L.sort()
print(L[k-1])


### FIXED CODE ###

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

len_s =  len(s)
L = []
m = 0
for i in range(1, k+1):
    for j in range(len_s-i+1):
        if s[j:j+i] not in L:
            L.append(s[j:j+i])


L.sort()
print(L[k-1])
### BUGGY CODE ###

from collections import deque
n,k,*h=map(int,open(0).read().split())
h=deque(h)
INF=float("inf")
dp=deque([0,abs(h[0]-h[1])])
for i in range(2,n):
	width = k
	tmp=INF
	if i<k:
		width=i
	for j in range(1,width+1):
		tmp = min( tmp , dp[i-j]+abs(h[i-j]-h[i]) )
	dp.append(tmp)
print(dp[-1])

### FIXED CODE ###

n,k,*h=map(int,open(0).read().split())
INF=float("inf")
dp=[INF]*n
dp[0]=0
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
	width = k
	if i<k:
		width=i
	for j in range(1,width+1):
		dp[i] = min( dp[i] , dp[i-j]+abs(h[i-j]-h[i]) )
print(dp[-1])
### BUGGY CODE ###

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

for _ in range(Q):
    qt, q1, q2 = input().split()
    if qt == '1':
        S[int(q1)-1] = q2
    else:
        print(len(set(S[int(q1)-1:int(q2)])))


### FIXED CODE ###

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

'''
'init(a)': 配列aで初期化。O(N)
'update(k,x)': a[k]をxに変更 O(logN)
'query(p,q)': [p,q)について "segfunc" したものを返す O(logN)
'ide_ele' : 単位元。
'''

#####segfunc######


def segfunc(x, y):
    return x | y


def init(init_val):
    # set_val
    for i in range(N):
        seg[i+num-1] = init_val[i]
    # built
    for i in range(num-2, -1, -1):
        seg[i] = segfunc(seg[2*i+1], seg[2*i+2])


def update(k, x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1], seg[k*2+2])


def query(p, q):
    if q <= p:
        return ide_ele
    p += num-1
    q += num-2
    res = ide_ele
    while q-p > 1:
        if p & 1 == 0:
            res = segfunc(res, seg[p])
        if q & 1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(segfunc(res, seg[p]), seg[q])
    return res


#####単位元######
ide_ele = 0

# num:n以上の最小の2のべき乗
num = 2**(N-1).bit_length()
seg = [ide_ele]*2*num


init_val = []
for s in S:
    init_val.append(1 << (ord(s)-ord('a')))
init(init_val)

for _ in range(Q):
    t, s, u = input().split()
    if t == '1':
        update(int(s)-1, 1 << (ord(u)-ord('a')))
    else:
        print(bin(query(int(s)-1, int(u))).count('1'))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
    b.append(a[i])
    b.reverse()

for i in b:
    print('{} '.format(i), end='')
print()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import collections

n = int(input())
a = list(map(int, input().split()))
b = collections.deque()

for i in range(n):
    if i % 2 == 0:
        b.appendleft(a[i])
    else:
        b.append(a[i])

if n % 2 == 0:
    b.reverse()

for i in b:
    print('{} '.format(i), end='')
print()
### BUGGY CODE ###

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

newLi = sorted(t, reverse=True)
li = []

for i in range(N):
  k = []

  k.append(newLi.pop(0))
  k.append(newLi.pop(0))
  k.append(newLi.pop(-1))

  li.append(k)

ans = 0

for s in li:
  ans += s[1]

print(ans)

### FIXED CODE ###

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

newLi = sorted(t, reverse=True)
ans = 0

for i in range(N):
  ans += newLi[i * 2 + 1]

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

from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))
def inpl_str():
    '''
    一行に複数の文字
    '''
    return list(input().split())

n=inp()
a = inpl()
sorted_a = sorted(a,reverse=True)
place=defaultdict(lambda: [])
for i in range(n):
    place[a[i]].append(i+1)
ans = 0
dp=[[-INF]*(n+1) for i in range(n+1)]
dp[0][0] = 0
for i in range(n):
    if i!=0 and sorted_a[i] == sorted_a[i - 1]:
        index += 1
    else:
        index = 0
    for j in range(n):
        _place = place[sorted_a[i]][index]
        #右
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + sorted_a[i] * abs(n - (i - j) - _place))
        #左
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + sorted_a[i] *  abs(_place - j - 1))

print(max(dp[n]))

### FIXED CODE ###

INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))
def inpl_str():
    '''
    一行に複数の文字
    '''
    return list(input().split())

n=inp()
a = inpl()
sorted_a = sorted(a,reverse=True)
place=dict()
for i in range(n):
    if a[i] not in place:
        place[a[i]]=[i+1]
    else:
        place[a[i]].append(i+1)
ans = 0
dp=[[-INF]*(n+1) for i in range(n+1)]
dp[0][0] = 0
for i in range(n):
    if i!=0 and sorted_a[i] == sorted_a[i - 1]:
        index += 1
    else:
        index = 0
    for j in range(n):
        _place = place[sorted_a[i]][index]
        #右
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + sorted_a[i] * abs(n - (i - j) - _place))
        #左
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + sorted_a[i] *  abs(_place - j - 1))

print(max(dp[n]))
### BUGGY CODE ###

from operator import mul
from functools import reduce

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

ans = reduce(mul, A)
if ans > 10**18: ans = -1

print(ans)

### FIXED CODE ###

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

ans = 1
if 0 in A:
    ans = 0
else:
    for i in A:
        ans *= i
        if ans > 10**18:
            ans = -1
            break
print(ans)
### BUGGY CODE ###

# dp[n][i][j]=(頂点iから頂点jへ行く長さnのパスの個数)
# dp[n][i][j]=sum(dp[n-1][i][k]*a[k][j])⇒DP[n]=DP[n-1]*A DP[0]=Eより DP[n]=A^n
n,k=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
dp=[[0]*n for i in range(n)]
mod=10**9+7
for i in range(n):
    for j in range(n):
        dp[i][i]=1
def dot(A,B):
    C=[[0]*n for i in range(n)]
    for i in range(n):
        for j in range(n):
            for k in range(n):
                C[i][j]+=A[i][k]*B[k][j]
            C[i][j]%=mod
    return C
while k:
    if k&1:
        dp=dot(dp,a)
    a=dot(a,a)
    k>>=1
ans=0
for i in dp:
    ans+=sum(i)
print(ans%mod)


### FIXED CODE ###

# dp[n][i][j]=(頂点iから頂点jへ行く長さnのパスの個数)
# dp[n][i][j]=sum(dp[n-1][i][k]*a[k][j])⇒DP[n]=DP[n-1]*A DP[0]=Eより DP[n]=A^n
n,k=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
dp=[[0]*n for i in range(n)]
mod=10**9+7
for i in range(n):
    for j in range(n):
        dp[i][i]=1
def dot(A,B):
    C=[[0]*n for i in range(n)]
    for i in range(n):
        for j in range(n):
            for k in range(n):
                C[i][j]+=A[i][k]*B[k][j]
            C[i][j]%=mod
    return C
while k:
    if k&1:
        dp=dot(dp,a)
    a=dot(a,a)
    k>>=1
ans=0
for i in dp:
    ans+=sum(i)
print(ans%mod)
### BUGGY CODE ###

def main():
    import sys
    input = sys.stdin.readline

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

    import itertools

    indices = [i for i in range(N)]
    for i in range(N):
        for v in itertools.combinations(indices, i):
            v = list(v)
            # print(v)
            tmp_l = get_l(A, v)
            # print(tmp_l)
            if judge(tmp_l):
                print(i)
                exit()
    print(-1)


def get_l(l, rm_ind):
    ans = []
    for i, a in enumerate(l):
        if i in rm_ind:
            continue
        ans.append(a)
    return ans


def judge(l):
    for i, a in enumerate(l):
        if i+1 != a:
            return False
    return True


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline

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

    import itertools

    ind = 1
    brick = 0
    for a in A:
        if a == ind:
            ind += 1
        else:
            brick += 1
    if brick == N:
        print(-1)
    else:
        print(brick)


#     indices = [i for i in range(N)]
#     for i in range(N):
#         for v in itertools.combinations(indices, i):
#             v = list(v)
#             # print(v)
#             tmp_l = get_l(A, v)
#             # print(tmp_l)
#             if judge(tmp_l):
#                 print(i)
#                 exit()
#     print(-1)


# def get_l(l, rm_ind):
#     ans = []
#     for i, a in enumerate(l):
#         if i in rm_ind:
#             continue
#         ans.append(a)
#     return ans


# def judge(l):
#     for i, a in enumerate(l):
#         if i+1 != a:
#             return False
#     return True


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

N, M = list(map(int, input().split()))
S = [0] * M
E = [0] * M
for i in range(M):
    S[i], E[i] = list(map(int, input().split()))
X = []
Y = []
for i in range(M):
    if S[i] == 1:
        X.append(E[i])
    if E[i] == N:
        Y.append(S[i])
for i in range(len(X)):
    for j in range(len(Y)):
        if X[i] == Y[j]:
            print("POSSIBLE")
            break
    else:
        continue
    break
else:
    print("IMPOSSIBLE")


### FIXED CODE ###

N, M = list(map(int, input().split()))
X = [0] * N
Y = [0] * N
for i in range(M):
    S, E = list(map(int, input().split()))
    if S == 1:
        X[E-1] = 1
    if E == N:
        Y[S-1] = 1
for i in range(N):
    if X[i] == 1 and Y[i] == 1:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")
### BUGGY CODE ###

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

li = [0] * (N + 1)
for i in A:
  li[i] += 1

for i in A:
  li[i] -= 1
  count = 0
  for j in li[1:]:
    if j >= 2: count += j * (j - 1) // 2
  li[i] += 1
  print(count)

### FIXED CODE ###

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

li = [0] * (N + 1)
total = 0

for i in A:
  li[i] += 1
for i in li[1:]:
  total += i * (i - 1) // 2

for i in A:
  j = li[i]
  print(total - (j * (j - 1) // 2) + ((j - 1) * (j - 2) // 2))
### BUGGY CODE ###

s = input()
q_num = int(input())
for i in range(q_num):
    q = list(input().split())
    if q[0] == '1':
        s = s[::-1]
    else:
        if q[1] == '1':
            s = q[2] + s 
        else:
            s += q[2]
print(s)

### FIXED CODE ###

s = input()
q_num = int(input())
head = []
tail = []
flip = 0
for i in range(q_num):
    q = tuple(input().split())
    if q[0] == '1':
        flip ^= 1
    else:
        f = int(q[1]) - 1
        c = q[2]
        if f ^ flip == 0:
            head.append(c)
        else:
            tail.append(c)
if flip:
    head, tail = tail, head
    s = s[::-1]
head = ''.join(head)
tail = ''.join(tail)
print(head[::-1] + s + tail)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
import heapq

def main():
    s = input().strip()
    n = len(s)
    stq = set()
    k = int(input().strip())
    for i in range(n):
        for j in range(i+1, max(i+1+k+1, n+1)):
            stq.add(s[i:j]) 
    stq = list(stq)
    heapq.heapify(stq)
    for i in range(k):
        ans = heapq.heappop(stq)
        if i == k-1:
            print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
import heapq

def main():
    s = input().strip()
    n = len(s)
    stq = set()
    k = int(input().strip())
    for i in range(n):
        for j in range(i+1, min(i+1+k+1, n+1)):
            stq.add(s[i:j])
    stq = list(stq)
    heapq.heapify(stq)
    for i in range(k):
        ans = heapq.heappop(stq)
        if i == k-1:
            print(ans)

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

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

H_t = input()

H = [0]*N
ma = []*N

good_count = 0

for i in range(N):
    
    H[i]= int(H_t.split()[i])
    ma.append(0)

#print(H_M)

for j in range(M):
    a, b = map(int, input().split())
    
    ma[a-1] = max(ma[a-1], H[b-1]) # つながった展望台の中で一番高い展望台を保持する
    ma[b-1] = max(ma[b-1], H[a-1]) 
    
    
for i in range(N):
    if H[i] > ma[i]:
        good_count +=1
print(good_count)

### FIXED CODE ###

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

H_t = input().split()
H = [int(s) for s in H_t]
#print(H)

ma = [0]*N

good_count = 0

#print(H_M)

for j in range(M):
    a, b = map(int, input().split())
    
    ma[a-1] = max(ma[a-1], H[b-1]) # つながった展望台の中で一番高い展望台を保持する
    ma[b-1] = max(ma[b-1], H[a-1]) 
    
    
for i in range(N):
    if H[i] > ma[i]:
        good_count +=1
print(good_count)
### BUGGY CODE ###

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

if len(h) == 1:
    print('Yes')
else:
    count = 0
    for i in range(1, len(h)-1):
        if max(h[0:i]) <= h[i+1]+1:
            count += 0
        else:
            count += 1
    
    if count == 0:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

# 減らせるときは減らす
N = int(input())
h = list(map(int, input().split()))

stop_flg = 0
h[0] = h[0]-1
for i in range(N-1):
    if stop_flg == 0:
        if h[i] <= h[i+1]-1:
            h[i+1] = h[i+1]-1
        elif h[i] == h[i+1]:
            continue
        else:
            stop_flg = 1

if stop_flg == 1:
    print('No')
else:
    print('Yes')
### BUGGY CODE ###

N,K=map(int,input().split())
A=list(map(int,input().split()))
A=[0]+A
R=[0]
for i in range(1,N+1):
    R.append(R[-1]+A[i])
I=[i for i in range(N+1)]

ans=0
for i in range(N):
    for j in range(i+1,N+1):
        if (R[j]-R[i])%K==(j-i):
            ans+=1
print(ans)

### FIXED CODE ###

N,K=map(int,input().split())
a=list(map(int,input().split()))
A=[0]
for i in range(N):
    A.append((A[-1]+a[i]-1))
for i in range(len(A)):
    A[i]%=K
#print(A)

D={}
D[0]=1
ans=0

for i in range(1,N+1):
    if A[i] in D:
        ans+=D[A[i]]
        D[A[i]]+=1
    else:
        D[A[i]]=1
    if i-K+1>=0:
        D[A[i-K+1]]-=1
#print(D)
if K==1:
    print(0)
else:
    print(ans)
### BUGGY CODE ###

import itertools

x,y,z,k=(int(i) for i in input().split())
#print(x,y,z,k)
a=list(int(i) for i in input().split())
a.sort(reverse=True)
b=list(int(i) for i in input().split())
b.sort(reverse=True)
c=list(int(i) for i in input().split())
c.sort(reverse=True)
#print(a,b,c)

ab=list(itertools.product(a,b))
sumab=[0 for i in range(len(ab))]
#print(ab)

for i in range(len(ab)):
  sumab[i]=ab[i][0]+ab[i][1]
  
abc=list(itertools.product(sumab,c))
abc.sort(reverse=True)
sumabc=[0 for i in range(len(abc))]
for i in range(len(abc)):
  sumabc[i]=abc[i][0]+abc[i][1]
  
sumabc.sort(reverse=True)

for i in range(k):
  print(sumabc[i])
  

### FIXED CODE ###

#import itertools

x,y,z,k=(int(i) for i in input().split())
#print(x,y,z,k)
a=list(int(i) for i in input().split())
a.sort(reverse=True)
b=list(int(i) for i in input().split())
b.sort(reverse=True)
c=list(int(i) for i in input().split())
c.sort(reverse=True)
#print(a,b,c)

#k=3000
#a=[int(i) for i in range(1000)]
#b=[int(i) for i in range(1000)]
#c=[int(i) for i in range(1000)]
x=[]
for h in range(len(a)):
    for i in range(len(b)):
        if (h+1)*(i+1) <=k:
            for j in range(len(c)):
                if (h+1)*(i+1)*(j+1) <=k:
                    x.append(a[h]+b[i]+c[j])

x.sort(reverse=True)
for i in range(k):
  print(x[i])
### BUGGY CODE ###

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

mod = 10**9 + 7
ans = 0

for x in range(m):
  for y in range(m-x-1):
    ans += (a[x] * a[y+x+1])
print(ans % mod)

### FIXED CODE ###

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

mod = 10**9 + 7
ans = 0

tmp_sum = sum(a[1:m]) % mod

for x in range(m-1):
  if a[x] % mod != 0:
    ans += (a[x] * tmp_sum) % mod
  
  tmp_sum -= a[x+1] % mod

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

import bisect


n, k = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
end = bisect.bisect_right(a, k)
a = a[0:end]
n = len(a)

def subset_sum(mid):
    if a[mid] >= k:
        return True
    dp = [False]*k
    dp[0] = True    
    for i in range(n):
        if i == mid:
            continue
        for j in range(k)[::-1]:
            if j - a[i] < 0:
                break
            else:
                dp[j] |= dp[j - a[i]]
 
    return sum(dp[k-a[mid]:])
  
ok = -1
ng = n
while abs(ng - ok) > 1:
    mid = (ok + ng) // 2
    if subset_sum(mid):
        ng = mid
    else:
        ok = mid
print(ng)

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline


def solve(mid):
    """のぞいてもいいカードならTrueを返す"""
    dp = 1
    mask = (1 << k) - 1
    if k <= a[mid]:
        return False
    for i, weight in enumerate(a):
        if i == mid:
            continue
        dp |= dp << min(weight, k + 10)
        dp &= mask
    return dp >> (k - a[mid]) == 0
     

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

a.sort()
ok = 0
ng = n
if not solve(ok):
    print(0)
    exit()

while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if solve(mid):
        ok = mid
    else:
        ng = mid

print(ok + 1)
### BUGGY CODE ###

def main():
    N = int(input())
    A = [int(input()) for i in range(N)]

    temp = 0
    minimum = -1
    for i in range(N):
        temp = A[i]
        A[i] = minimum
        print(max(A))
        A[i] = temp


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    A_sorted = sorted(A)

    for i in range(N):
        if A_sorted[-1] == A[i]:
            print(A_sorted[-2])
        else:
            print(A_sorted[-1])


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

s = input()
K = int(input())
len_s = len(s)
already = set()
for start in range(len_s):
    for end in range(start+1, len_s+1):
        already.add(s[start:end])
candidate = sorted(list(already))
print(candidate[K-1])

### FIXED CODE ###

s = input()
K = int(input())
len_s = len(s)
already = set()
for start in range(len_s):
    for end in range(start+1, min(start + 6, len_s+1)):
        already.add(s[start:end])
candidate = sorted(list(already))
print(candidate[K-1])
### BUGGY CODE ###

H, W, M = map(int, input().split())
h = [0 for i in range(H)]
w = [0 for i in range(W)]
dp = [[0 for i in range(W)] for j in range(H)]

for i in range(M):
    hh, ww = map(int, input().split())
    w[ww - 1] += 1
    dp[hh - 1][ww - 1] += 1

for i in range(H):
    h[i] = sum(dp[i])

hhh = max(h)
www = max(w)
hhhh = [i for i, x in enumerate(h) if x == hhh]
wwww = [i for i, x in enumerate(w) if x == www]
check = 0


for i in hhhh:
    for j in wwww:
        if dp[i][j] == 0:
            check = 1
            break
print(hhh + www - (1 - check))


### FIXED CODE ###

H, W, M = map(int, input().split())
h = [0 for i in range(H)]
w = [0 for i in range(W)]
DP = set()
for i in range(M):
    hh, ww = map(int, input().split())
    h[hh - 1] += 1
    w[ww - 1] += 1
    DP.add((hh - 1, ww - 1))

hhh = max(h)
www = max(w)
hhhh = [i for i, x in enumerate(h) if x == hhh]
wwww = [i for i, x in enumerate(w) if x == www]
check = 0

for i in hhhh:
    for j in wwww:
        if (i, j) not in DP:
            print(hhh + www)
            exit()
print(hhh + www - 1)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
amin = min(a)
amax = max(a)
ans = 0
for x in range(amin,amax+1):
	    p = 0
	    p += a.count(x)
	    p += a.count(x+2)
	    p += a.count(x+1)
	    ans = max(ans,p)
print(ans)

### FIXED CODE ###

import collections
n = int(input())
a = list(map(int,input().split()))
c = dict(collections.Counter(a))
c = dict(sorted(c.items(),key = lambda x:x[0]))

ans = 0
for i in range(1,10**5):
  cnt = 0
  try:
    cnt += c[i-1]
  except KeyError:
    pass
  
  try:
    cnt += c[i]
  except KeyError:
    pass
    
  try:
    cnt += c[i+1]
  except KeyError:
    pass
    
  ans = max(ans,cnt)  
  
print(ans)
### BUGGY CODE ###

n,m=map(int, input().split())
prefecture=[[] for j in range(n)]
p=[]
y=[]
for i in range(m):
    a,b=map(int, input().split())
    p.append(a)
    y.append(b)
    prefecture[p[i]-1].append(y[i])

for j in range(n):
    prefecture[j].sort()

for i in range(m):
    print('{0:06d}{1:06d}'.format(p[i],prefecture[p[i]-1].index(y[i])+1))

### FIXED CODE ###

n,m=map(int, input().split())
prefecture=[]
for i in range(m):
    pk,yk=map(int, input().split())
    prefecture.append([pk,yk,i])

prefecture.sort(key=lambda x:(x[0],x[1])) # x[0]:pで整理したうえでx[1]:yで整理
p_num=prefecture[0][0]
city_num=1
for i in range(m):
    if(prefecture[i][0]!=p_num):
        p_num=prefecture[i][0]
        city_num=1

    prefecture[i].append(city_num)
    city_num+=1

prefecture.sort(key=lambda x:x[2])

for i in range(m):
    print('{0:06d}{1:06d}'.format(prefecture[i][0], prefecture[i][3]))
### BUGGY CODE ###

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

count = 1
while B > count:
  if A * count % B == C:
    print("YES")
    exit(0)
print("NO")

### FIXED CODE ###

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

count = 1
while B > count:
  if A * count % B == C:
    print("YES")
    exit(0)
  count += 1
print("NO")