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

S = input(); K = int(input())
subs = []
for i in range(1, max(len(S), 5) + 1):
  for j in range(len(S) - i + 1):
    subs.append(S[j: j + i])
subsset = set(subs)
subs = sorted(list(subsset))
print(subs[K - 1])

### FIXED CODE ###

S = input(); K = int(input())
subs = []
for i in range(1, min(len(S), 5) + 1):
  for j in range(len(S) - i + 1):
    subs.append(S[j: j + i])
subsset = set(subs)
subs = sorted(list(subsset))
print(subs[K - 1])
### BUGGY CODE ###

import numpy as np
from collections import deque

S = input()
Q = int(input())
reverse_cnt = 0
index = []
s = deque([])

for i in range(Q):
    query = input().split()
    if query[0] == "1":
        reverse_cnt += 1
        index = list(np.array(index) * -1)
    else:
        s.append(query[2])
        if query[1] == "1":
            index.append(-1)
        else:
            index.append(1)

if reverse_cnt % 2 != 0:
    S = S[::-1]

insert = ""
add = ""

for i in index:
    if i == 1:
        add += s.popleft()
    elif i == -1:
        insert += s.popleft()

print(insert[::-1] + S + add)

### FIXED CODE ###

from collections import deque

S = input()
Q = int(input())
reverse_cnt = 0
s = deque([i for i in S])

for i in range(Q):
    query = input().split()
    if query[0] == "1":
        reverse_cnt += 1
    else:
        if query[1] == "1":
            if reverse_cnt % 2 == 0:
                s.appendleft(query[2])
            else:
                s.append(query[2])
        else:
            if reverse_cnt % 2 == 0:
                s.append(query[2])
            else:
                s.appendleft(query[2])

if reverse_cnt % 2 == 0:
    while s:
        print(s.popleft(), end="")
else:
     while s:
        print(s.pop(), end="")
### BUGGY CODE ###

N = int(input())
A = []
B = []
for i in range(N):
    a,b = map(int, input().split())
    A.append(a)
    B.append(b)
c = 0
for i in range(N-1,-1,-1):
    if A[i] % B[i] == 0:
        continue
    if A[i] < B[i]:
        push = B[i] - A[i]
    elif A[i] > B[i]:
        push = B[i] - A[i] % B[i]
    c += push
    for j in range(i+1):
        A[j] += push
print(c)

### FIXED CODE ###

N = int(input())
A = []
B = []
for i in range(N):
    a,b = map(int, input().split())
    A.append(a)
    B.append(b)
c = 0
for i in range(N-1,-1,-1):
    if (A[i]+c) % B[i] == 0:
        continue
    if A[i]+c < B[i]:
        push = B[i] - (A[i]+c)
    elif A[i]+c > B[i]:
        push = B[i] - (A[i]+c) % B[i]
    c += push
print(c)
### BUGGY CODE ###

def main(s,x,q):
    res = s
    rev = 1 #-1なら反転中
    for op in q:
        if int(op[0]) == 1:
            rev = rev * -1
        elif int(op[1])*rev == 1 or int(op[1])*rev == -2:
                res = op[2] + res
        elif int(op[1])*rev == -1 or int(op[1])*rev == 2:
            res = res + op[2]
    return res if rev == 1 else res[::-1]

s = input()
x = int(input())
q = [input().split() for _ in range(x)]
print(main(s,x,q))

### FIXED CODE ###

def main2(s,x,q):
    res = s
    rev = 1 #-1なら反転中
    lstA = []
    lstB = []
    for op in q:
        if int(op[0]) == 1:
            rev = rev * -1
        elif int(op[1])*rev == 1 or int(op[1])*rev == -2:
            lstA.append(op[2])
        elif int(op[1])*rev == -1 or int(op[1])*rev == 2:
            lstB.append(op[2])
    if rev == 1:
        res = "".join(lstA[::-1])+res+"".join(lstB)
    else :
        res = "".join(lstB[::-1])+res[::-1]+"".join(lstA)
    return res

s = input()
x = int(input())
q = [input().split() for _ in range(x)]
print(main2(s,x,q))
### BUGGY CODE ###

N, K = map(int, input().split())
H = list(map(int, input().split()))

DP = [10**8] * (N+1)
DP[0] = 0
DP[1] = abs(H[0] - H[1])

for i in range(2, N):
    DP[i] = min(DP[i-x] + abs(H[i-x]-H[i]) for x in range(1, min(i+1, K+1)))
print(DP[N-1])


### FIXED CODE ###

N, K = map(int, input().split())
H = list(map(int, input().split()))

DP = [10**8] * (N+1)
DP[0] = 0
DP[1] = abs(H[0] - H[1])

for i in range(2, N):
    DP[i] = min(DP[i-x] + abs(H[i-x]-H[i]) for x in range(1, min(i+1, K+1)))
print(DP[N-1])
### BUGGY CODE ###

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

list_ans = 0

for i in range(n-k+1):
    list_sum = sum(list_score[i:i+k])
    if list_sum >= list_ans:
        list_ans = list_sum




ans = list_ans*0.5 + 0.5*k

print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
list_P = list(map(int, input().split()))
cnt = 0

for i in range(k):
    p = list_P[i]
    cnt += (1+p)/2

ans = cnt
for i in range(k, n):
    p, q = list_P[i-k], list_P[i]
    cnt -= (1+p)/2
    cnt += (1+q)/2
    ans = max(ans, cnt)

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

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

r = []
result = ""

for i in range(1, N + 1):
    a = li.index(i)
    result = result + str(a + 1) + " "

print(result)

### FIXED CODE ###

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

r = [0]*N

for index in range(N):
    l = li[index]
    r[l-1] = str(index+1)

print(" ".join(r))
### BUGGY CODE ###

H, W = map(int, input().split())
S = [input() for _ in range(H)]

def solve(i,j):
	if S[i][j] == "#":
		return 0
	cnt = 1
	tmp = j
	while True:
		tmp -= 1
		if tmp < 0:
			break
		if S[i][tmp] == "#":
			break
		cnt += 1
	tmp = j
	while True:
		tmp += 1
		if tmp >= W:
			break
		if S[i][tmp] == "#":
			break
		cnt += 1
	tmp = i
	while True:
		tmp -= 1
		if tmp < 0:
			break
		if S[tmp][j] == "#":
			break
		cnt += 1
	tmp = i
	while True:
		tmp += 1
		if tmp >= H:
			break
		if S[tmp][j] == "#":
			break
		cnt += 1

	return cnt
		
ans = 0
for i in range(H):
	for j in range(W):
		ans = max(ans, solve(i,j))

print(ans)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

H,W = map(int, readline().split())
grid = np.frombuffer(read(), 'S1').reshape(H,-1)[:,:W]

X,Y = np.where(grid == b'#')

A = np.ones((H,W), np.int32)
B = np.ones((H,W), np.int32)

A[X,Y] = 0
B[X,Y] = 0

for w in range(W-1):
	A[:,w+1] += A[:,w] * (A[:,w+1] != 0)
for w in range(W-2,-1,-1):
	A[:,w] = np.maximum(A[:,w], A[:,w+1]) * (A[:,w] != 0)


for h in range(H-1):
	B[h+1,:] += B[h,:] * (B[h+1,:] != 0)
for h in range(H-2,-1,-1):
	B[h,:] = np.maximum(B[h,:], B[h+1,:]) * (B[h,:] != 0)

C = A+B

print(np.max(C)-1)
### BUGGY CODE ###

N = int(input())
S = input()
ans = 0
T = {'R', 'G', 'B'}
sum_R, sum_G, sum_B = [0], [0], [0]

for i in S:
    sum_R.append(i=='R')
    sum_G.append(i=='G')
    sum_B.append(i=='B')
    
for i in range(1, N+1):
    sum_R[i] = sum_R[i-1] + sum_R[i]
    sum_G[i] = sum_G[i-1] + sum_G[i]
    sum_B[i] = sum_B[i-1] + sum_B[i]
    
dict_RGB = {'R':sum_R, 'G':sum_G, 'B':sum_B}

for i in range(N-2):
    s_i = S[i]
    for j in range(i+1, N-1):
        s_j = S[j]
        if s_i == s_j:
            continue
        
        s_k = list(T - set((s_i, s_j)))[0]
        
        sum_s_k = dict_RGB[s_k]
        ans = ans + sum_s_k[-1] - sum_s_k[j]
        if (2 * j - i < N) and (S[2*j - i]==s_k):
            ans -= 1
        
    
print(ans)

### FIXED CODE ###

N = int(input())
S = input()
ans = 0
T = {'R', 'G', 'B'}
sum_R, sum_G, sum_B = [0], [0], [0]
 
for i in S:
    sum_R.append(i=='R')
    sum_G.append(i=='G')
    sum_B.append(i=='B')
    
for i in range(1, N+1):
    sum_R[i] = sum_R[i-1] + sum_R[i]
    sum_G[i] = sum_G[i-1] + sum_G[i]
    sum_B[i] = sum_B[i-1] + sum_B[i]
    
dict_RGB = {'R':sum_R, 'G':sum_G, 'B':sum_B}
 
for i in range(N-2):
    s_i = S[i]
    for j in range(i+1, N-1):
        s_j = S[j]
        if s_i == s_j:
            continue
        
        s_k = list(T - set((s_i, s_j)))[0]
        
        sum_s_k = dict_RGB[s_k]
        ans = ans + sum_s_k[-1] - sum_s_k[j]
        if (2 * j - i < N) and (S[2*j - i]==s_k):
            ans -= 1
        
    
print(ans)
### BUGGY CODE ###

n = input()
n = int(n)
y = input()
list = y.split(' ')

for i in range(n):
    i = i + 1
    i = str(i)
    print(list.count(i))


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
nums = [0] * n

for i in a:
    nums[i-1] += 1

print("\n".join(map(str, nums)))
### BUGGY CODE ###

N, M = list(map(int, input().split()))
sigma = list(map(int, input().split()))
gokans = []

for i in range(M):
    pair = list(map(int, input().split()))
    gokans.append(pair)

def connected(i, j, paths):
    if [pair for pair in paths if i in pair] and [pair for pair in paths if j in pair]:
        i_start = [pair for pair in paths if i in pair]
        chain = i_start
        old_chain = []
        for pair in chain:
            paths.remove(pair)

        while chain != old_chain:
            old_chain = chain
            for pair in chain:
                new_chain = [couple for couple in paths if set(couple) & set(pair) != set()]
                chain += new_chain
                for pair in new_chain:
                    paths.remove(pair)
            narabi = [couple[0] for couple in chain] + [couple[1] for couple in chain]
            if j in narabi:
                return True
        return False
    else:
        return False

count = 0
for i in range(1, N+1):
    if i != sigma[i-1]:
        gokans1 = gokans.copy()
        if connected(i, sigma[i-1], gokans1):
            count += 1
    else:
        count += 1

print(count)

### FIXED CODE ###

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

par = [i for i in range(n)]
#rootの計算量は、parが最初の状態に近いほど値は小さくて、高々O(n)
def root(x):
	tmp = par[x]
	if tmp == x:
		return x
	else:
		a = root(tmp)
		par[x] = a
		return a

def merge(x, y):
	x = root(x)
	y = root(y)
	if x != y:
		par[x] = y
		return

for i in range(m):
	x, y = map(int, input().split())
	merge(x-1, y-1)
	#print(par)

ans = 0

for i in range(n):
	if p[i]-1 == i:
		ans += 1
	elif root(p[i]-1) == root(i):
		ans += 1
print(ans)
### BUGGY CODE ###

import sys, os 
sys.setrecursionlimit(10**8)
#resource.setrlimit(resource.RLIMIT_STACK, (2**29,-1))

read = lambda : sys.stdin.readline().rstrip('\n')
tint = lambda x: [int(x) for x in x.split()]
inf = float('inf')

def main():
    n, k = tint(read())
    stones = tint(read())
    dp = [inf]*n
    dp[0] = 0
    for i in range(n):
        for t in range(1, k+1):
            if i+t < n:
                dp[i+t] = min(dp[i+t], dp[i]+abs(stones[i]-stones[i+t]))
    print(dp[-1])

if __name__ == '__main__':    
    main()


### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    h = tuple(map(int, input().split()))
    INF = 10 ** 9
    dp = [INF] * n
    dp[0] = 0
    for i in range(n):
        for j in range(1, k + 1):
            i_j = i + j
            if i_j < n:
                x = dp[i] + abs(h[i] - h[i_j])
                if dp[i_j] > x:
                    dp[i_j] = x
    print(dp[-1])


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

a,b,k=map(int,input().split())
l=[i for i in range(a,b+1) if i<a+k or i>b-k]
print(*l ,sep='\n')


### FIXED CODE ###

a,b,k=map(int,input().split())
r=range(a,b+1)
for i in sorted(set(r[:k])|set(r[-k:])):print(i)
### BUGGY CODE ###

N=int(input())
Data=list(map(int,input().split()))
mindata=min(Data)-1
maxdata=max(Data)+1
ans=0
for i in range(mindata,maxdata+1):
    cnt=0
    for j in range(N):
        if abs(Data[j]-i)<=1:cnt+=1
    if ans<cnt:
        ans=cnt
    if ans==N:break
print(ans)


### FIXED CODE ###

from collections import Counter

N=int(input())

counter=Counter(list(map(int,input().split())))
res=0

for i in counter:
    cnt=counter[i-1]+counter[i]+counter[i+1]
    if res<cnt:res=cnt
print(res)
### BUGGY CODE ###

import sys,os,io
input = sys.stdin.readline
# input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

N, M = map(int, input().split())
edge = [[] for _ in range(N)]
for i in range(N-1):
  a,b = list(map(int, input().split()))
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)

def dfs(start):
  stack = [start]
  parent = [N]*N
  parent[start] = -1
  while stack:
    v = stack[-1]
    marker = 0
    for u in edge[v]:
      if u==parent[v]:
        continue
      if parent[u]==N: #子へ降ろす
        marker = 1
        parent[u]=v
        stack.append(u)
      else: #子から吸い上げる
        ans[v] *= ans[u]+1
    if marker==0:
      stack.pop()
    ans[v]%=M
  return

def dfs2(start):
  stack = [start]
  parent = [N]*N
  parent[start] = -1
  p_value = [0]*N
  while stack:
    v = stack.pop()
    cum1 = [1]*(len(edge[v])+1)
    cum2 = [1]*(len(edge[v])+1)
    for i,u in enumerate(edge[v]):
      if u==parent[v]:
        cum1[i+1] = cum1[i]*(p_value[v]+1)
      else:
        cum1[i+1] = cum1[i]*(ans[u]+1)
      cum1[i+1] %= M
    for i,u in enumerate(edge[v][::-1]):
      if u==parent[v]:
        cum2[-i-2] = cum2[-i-1]*(p_value[v]+1)
      else:
        cum2[-i-2] = cum2[-i-1]*(ans[u]+1)
      cum2[i+1]%=M
    for i,u in enumerate(edge[v]):
      if u==parent[v]:
        continue
      parent[u]=v
      p_value[u] = cum1[i]*cum2[i+1]%M
      ans[u] *= (p_value[u]+1)
      ans[u] %= M
      stack.append(u)
    ans[v] %= M
  return

ans = [1]*N
dfs(0)
dfs2(0)
print(*ans, sep='\n')

### FIXED CODE ###

import sys,os,io
input = sys.stdin.readline
# input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

N, M = map(int, input().split())
edge = [[] for _ in range(N)]
for i in range(N-1):
  a,b = list(map(int, input().split()))
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)

def dfs(start):
  stack = [start]
  parent = [N]*N
  parent[start] = -1
  while stack:
    v = stack[-1]
    marker = 0
    for u in edge[v]:
      if u==parent[v]:
        continue
      if parent[u]==N: #子へ降ろす
        marker = 1
        parent[u]=v
        stack.append(u)
      else: #子から吸い上げる
        ans[v] *= ans[u]+1
        ans[v] %=M
    if marker==0:
      stack.pop()
  return

def dfs2(start):
  stack = [start]
  parent = [N]*N
  parent[start] = -1
  p_value = [0]*N
  while stack:
    v = stack.pop()
    cum1 = [1]*(len(edge[v])+1)
    cum2 = [1]*(len(edge[v])+1)
    for i,u in enumerate(edge[v]):
      if u==parent[v]:
        cum1[i+1] = cum1[i]*(p_value[v]+1)%M
      else:
        cum1[i+1] = cum1[i]*(ans[u]+1)%M
    for i,u in enumerate(edge[v][::-1]):
      if u==parent[v]:
        cum2[-i-2] = cum2[-i-1]*(p_value[v]+1)%M
      else:
        cum2[-i-2] = cum2[-i-1]*(ans[u]+1)%M
    for i,u in enumerate(edge[v]):
      if u==parent[v]:
        continue
      parent[u]=v
      p_value[u] = cum1[i]*cum2[i+1]%M
      ans[u] *= (p_value[u]+1)
      ans[u] %= M
      stack.append(u)
    ans[v] %= M
  return

ans = [1]*N
dfs(0)
dfs2(0)
print(*ans, sep='\n')
### BUGGY CODE ###

N,C = map(int,input().split())
D = [list(map(int,input().split())) for _ in range(C)]
c = [list(map(lambda x:int(x)-1,input().split())) for _ in range(N)]

ans = 10000*N*N
for i in range(C):
    cur_score = 0
    for x in range(N):
        for y in range((-x)%3,N,3):
            cur_score += D[c[x][y]][i]
    if cur_score>ans:
        continue
    for j in range(C):
        cur_score2 = 0
        if j == i:
            continue
        for x in range(N):
            for y in range((1-x)%3,N,3):
                cur_score2 += D[c[x][y]][j]
        if cur_score+cur_score2>ans:
            continue
        
        for k in range(C):
            cur_score3 = 0
            if k == j or k == i:
                continue
            for x in range(N):
                for y in range((2-x)%3,N,3):
                    cur_score3 += D[c[x][y]][k]
            ans = min(ans,cur_score+cur_score2+cur_score3)
print(ans)

### FIXED CODE ###

N,C = map(int,input().split())
D = [list(map(int,input().split())) for _ in range(C)]
c = [list(map(lambda x:int(x)-1,input().split())) for _ in range(N)]

n = [[0]*C for _ in range(3)]
for i in range(N):
    for j in range(N):
        n[(i+j)%3][c[i][j]] += 1

ans = 500*500*1000
for c0 in range(C):
    for c1 in range(C):
        if c1 == c0:
            continue
        for c2 in range(C):
            if c2 in (c0,c1):
                continue
            score = 0
            for a in range(C):
                score += n[0][a] * D[a][c0] + n[1][a] * D[a][c1] + n[2][a] * D[a][c2]
            ans = min(ans,score)
print(ans)
### BUGGY CODE ###

N, K=map(int, input().split())
A=list(map(int, input().split()))
sa=set(A)
if len(sa)<=K:
  print(0)
else:
  # 書き換える要素の種類数
  sub=len(sa)-K
  # 少ないやつを書き換えたい
  a=list(sa)
  
  numl=[]
  for i in a:
    numl.append(A.count(i))
  
  numl.sort()
  print(sum(numl[:sub]))
  
  

### FIXED CODE ###

N, K=map(int, input().split())
A=list(map(int, input().split()))
sa=set(A)
if len(sa)<=K:
  print(0)
else:
  # 書き換える要素の種類数
  sub=len(sa)-K
  # 少ないやつを書き換えたい
  A.sort()
  A.append(A[-1])
  a=[0]*len(sa)
  j=0
  for i in range(N):
    a[j]+=1
    if A[i]!=A[i+1]:
      j+=1
  
  a.sort()
  print(sum(a[:sub]))
### BUGGY CODE ###

import sys
readline = sys.stdin.readline

H,W = map(int,readline().split())
grid = [readline().rstrip() for i in range(H)]

# 各マスについて、上下左右にそれぞれ照射できるマスがいくつあるか
L = [[0] * W for i in range(H)]
R = [[0] * W for i in range(H)]
U = [[0] * W for i in range(H)]
D = [[0] * W for i in range(H)]

for i in range(H):
  cur = 0
  for j in range(W):
    if grid[i][j] == "#":
      cur = 0
    else:
      cur += 1
    L[i][j] = cur
  cur = 0
  for j in range(W - 1,-1,-1):
    if grid[i][j] == "#":
      cur = 0
    else:
      cur += 1
    R[i][j] = cur
    
for j in range(W):
  cur = 0
  for i in range(H):
    if grid[i][j] == "#":
      cur = 0
    else:
      cur += 1
    U[i][j] = cur
  cur = 0
  for i in range(H - 1,-1,-1):
    if grid[i][j] == "#":
      cur = 0
    else:
      cur += 1
    D[i][j] = cur
    
ans = 0
for i in range(H):
  for j in range(W):
    if ans < L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3:
      ans = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
      
print(ans)

### FIXED CODE ###

h,w=map(int,input().split())
grid=[None]*h

for i in range(h):
  grid[i]=input()

yoko=[[0 for i in range(w)] for j in range(h)]
tate=[[0 for i in range(w)] for j in range(h)]

for i in range(h):
  s=grid[i]
  left=0
  right=0
  while left<len(s):
    if s[left]=="#":
      left+=1
      right=left
      continue
    while right+1<w and s[right+1]==".":
      right+=1
  
    for j in range(left,right+1):
      yoko[i][j]=right-left
      
    left=right+1
    right=left
    
for i in range(w):
  up=0
  down=0
  while up<h:
    if grid[down][i]=="#":
      up+=1
      down=up
      continue
    while down+1<h and grid[down+1][i]==".":
      down+=1
    for j in range(up,down+1):
      tate[j][i]=down-up
    up=down+1
    down=up
    
ans=0
for i in range(h):
  for j in range(w):
    if grid[i][j]==".":
      ans=max(ans,tate[i][j]+yoko[i][j])
      
print(ans+1)
### BUGGY CODE ###

import fractions
from collections import defaultdict
A, B = map(int, input().split())
C = fractions.gcd(A, B)
D = set([1])
c = C
for i in range(2, C+1):
    while c % i == 0:
        D.add(i)
        c //= i

print(len(D))


### FIXED CODE ###

import fractions
from collections import defaultdict
A, B = map(int, input().split())
C = fractions.gcd(A, B)
c = C

if c == 1:
    print(1)
    exit()


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


print(len(factorization(c))+1)
### BUGGY CODE ###

n,p = map(int,input().split())
if n == 1:
  print(p)
  exit()
a = 1
for i in range(1,1000001):
  if p%(i ** n) == 0:
    a = i
print(a)

### FIXED CODE ###

n,p = map(int,input().split())
if n == 1:
  print(p)
  exit()
a = 1
for k in range(2,1000001):
  c = 0
  while p%k == 0:
    p = p//k
    c += 1
  a *= k**(c//n)
  if p == 1:
    break
print(a)
### BUGGY CODE ###

# encoding: utf-8


import sys

__input = sys.stdin.readlines()
length_1 = int(__input[0])
array_1 = list(map(int, __input[1].split()))
length_2 = int(__input[2])
array_2 = list(map(int, __input[3].split()))
upperbound = 2000
assert length_1 == len(array_1) and length_2 == len(array_2)


def solution_1():
    record = [False] * upperbound

    for i in array_1:
        # record combinations of sums of each in array_1
        for j in range(upperbound - i, 0, -1):
            if record[j]:
                record[int(i + j)] = True
        record[i] = True

    for each in array_2:
        if record[each]:
            print("yes")
        else:
            print("no")


def solution_2():
    for each in array_2:
        # print('e', each)
        ans = solve(0, each)
        if ans:
            print("yes")
        else:
            print("no")


def solve(i, m):
    if m == 0:
        # print('c')
        return True
    if i >= length_1:
        # print('a', i, m)
        return False

    # print('b', i, m)
    ans = solve(i + 1, m) or solve(i + 1, m - array_1[i])
    return ans


if __name__ == '__main__':
    # solution_1()
    solution_2()

### FIXED CODE ###

# encoding: utf-8


import sys

__input = sys.stdin.readlines()
length_1 = int(__input[0])
array_1 = list(map(int, __input[1].split()))
length_2 = int(__input[2])
array_2 = list(map(int, __input[3].split()))

record = [False] * 2000


def solution():
    # print(length_1, array_1, length_2, array_2)
    assert length_1 == len(array_1) and length_2 == len(array_2)

    for i in array_1:
        # record[i] = True
        for j in range(2000 - i, 0, -1):
            if record[j]:
                # print(j, i + j)
                record[i + j] = True
        record[i] = True

    for index in array_2:
        if record[index]:
            print("yes")
        else:
            print("no")


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

n, m = map(int, input().split())

h = {}
for k, v in zip(range(1,n+1),[k for k in map(int, input().split())]):
    h[k] = v 

miti = []
for i in range(m):
    temp = [k for k in map(int, input().split())]
    miti.append(temp)


non = []

for i in range(n):
    i = i +1
    flag = 0
    for j in range(m):
        if i in miti[j]:
            flag = flag+1
    
    if flag ==0:
        non.append(i)


high = []
for i in range(n):
    i = i + 1
    flag = 0
    for j in range(m):
        if i in miti[j]:
            if i ==miti[j][0]:
                if h[i] <= h[miti[j][1]]:
                    flag = flag +1
            else:
                if h[i] <= h[miti[j][0]]:
                    flag = flag + 1
    if flag == 0:
        high.append(i)

print(len(set(non + high)))


### FIXED CODE ###

import numpy as np

n, m = map(int, input().split())

h = {}
for k, v in zip(range(1,n+1),[k for k in map(int, input().split())]):
    h[k] = v 

miti = []
for i in range(m):
    temp = [k for k in map(int, input().split())]
    miti.append(temp)

x = np.zeros(n)

for i in range(m):
    if h[miti[i][0]] < h[miti[i][1]]:
        x[miti[i][0]-1] =+1
    elif h[miti[i][0]] > h[miti[i][1]]:
        x[miti[i][1]-1] =+1
    elif h[miti[i][0]] == h[miti[i][1]]:
        x[miti[i][0]-1] =+1
        x[miti[i][1]-1] =+1

print(sum(x == 0))
### BUGGY CODE ###

N = int(input())

A=[]
B=[]
C=[]
saidai = 0
for i in range(N):
    A.append(input())
C=sorted(set(A))

for i in C:
    y = A.count(i)
    B.append([i, y])
    saidai = max(y, saidai)

for i in range(len(B)):
    if B[i][1] == saidai:
        print(B[i][0])

### FIXED CODE ###

from collections import Counter
N = int(input())
 
A=[]
for i in range(N):
    A.append(input())

B = Counter(A)

saidai = max(B.values())

C=[]
for i, j in B.items():
    if j == saidai:
        C.append(i)
C.sort()
for i in C:
    print(i)