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

def A():
    w = ['Sunny', 'Cloudy', 'Rainy']
    today = input()
    index = w.index(today)
    if index == 2:
        index = -1
    print(w[index+1])

def B():
    odd = 'RUD'
    even = 'LUD'

    s = input()
    for i in range(len(s)):
        if (i+1)%2 == 0:
            if s[i] not in even:
                print('No')
                return
        else:
            if s[i] not in odd:
                print('No')
                return
        
    print('Yes')

def C():
    temp = [int(i) for i in input().split()]
    N = temp[0]
    K = temp[1]
    Q = temp[2]
    points = [0]*N
    # for i in range(N):
    #     points[i] = K

    for i in range(Q):
        num = int(input())
        points[num-1] += 1

    for i, p in enumerate(points):
        if K-sum([x for j,x in enumerate(points) if j!=i]) > 0:
            print('Yes')
        else:
            print('No')
    
C()


### FIXED CODE ###

def A():
    w = ['Sunny', 'Cloudy', 'Rainy']
    today = input()
    index = w.index(today)
    if index == 2:
        index = -1
    print(w[index+1])

def B():
    odd = 'RUD'
    even = 'LUD'

    s = input()
    for i in range(len(s)):
        if (i+1)%2 == 0:
            if s[i] not in even:
                print('No')
                return
        else:
            if s[i] not in odd:
                print('No')
                return
        
    print('Yes')

def C():
    temp = [int(i) for i in input().split()]
    N = temp[0]
    K = temp[1]
    Q = temp[2]
    points = {}

    for i in range(N):
        points[i] = 0

    for i in range(Q):
        num = int(input())
        points[num-1] += 1

    for i in points.keys():
        if K - (Q - points[i]) > 0:
            print('Yes')
        else:
            print('No')
    
C()
### BUGGY CODE ###

import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return float(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()



def main():
	nn=II()
	A=LI()
	ans="pairwise coprime"

	n = 1000000
	primes = set(range(2, n+1))
	for i in range(2, int(n**0.5+1)):
		primes.difference_update(range(i*2, n+1, i))
	primes=list(primes)

	#print(primes)


	B=set(range(1,10**6+1))
	C=set()
	for i in A:
		a=set()
		for j in primes:
			if j>i:
				break
			elif i%j==0:
				a.add(j)




		B&=a
		if C&a:
			ans="setwise coprime"
		C|=a

	if B:
		ans="not coprime"

	print(ans)





















if __name__ == "__main__":
	main()


### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return float(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()



def main():
	nn=II()
	A=LI()
	ans="pairwise coprime"

	n = 500005
	primes = set(range(2, n+1))
	for i in range(2, int(n**0.5+1)):
		primes.difference_update(range(i*2, n+1, i))
	primes=set(primes)

	#print(primes)


	B=set(range(1,5*10**5+5))
	C=set()
	for i in A:
		a=set()
		while i%2==0:
			a.add(2)
			i//=2
		f=3
		while f*f<=i:
			if i in primes:
				break
			elif i%f==0:
				a.add(f)
				i//=f
			else:
				f+=2
		if i!=1:
			a.add(i)
		B&=a
		if C&a:
			ans="setwise coprime"
		C|=a

	if B:
		ans="not coprime"

	print(ans)





















if __name__ == "__main__":
	main()
### 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
    else:
        break
    
print("{} {}".format(A, B))

### FIXED CODE ###

A,B,K =  map(int,input().split())
if K==0:
    print("{} {}".format(A, B))
elif A==0&B==0:
    A=0
    B=0
    print("{} {}".format(A, B))
elif A<K:
    B=B-(K-A)
    if B<0:
        B=0
    A=0
    print("{} {}".format(A, B))
elif A==K:
    A=0
    print("{} {}".format(A, B))
else :
    A = A-K
    print("{} {}".format(A, B))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def main():
  n, m = map(int, input().split())
  dp = [ [float("inf")]*(2**n) for _ in range(m) ]
  dp[0][0] = 0
  for i in range(1, m):
    a, b = map(int, input().split())
    k = map(int, input().split())
    c = 0
    for l in k:
      c += 2**(l-1)
    for j in range(2**n):
      dp[i][j] = min(dp[i-1][j&(~c)]+a, dp[i-1][j])

  if dp[m-1][2**n-1] == float("inf"):
    print(-1)
  else:
    print(dp[m-1][2**n-1])
    
if __name__ == "__main__":
  main()

### FIXED CODE ###

n, m = map(int, input().split())
dp = [ [float("inf")]*(2**n) for _ in range(m) ]
dp[0][0] = 0
for i in range(1, m):
  a, b = map(int, input().split())
  k = set(map(int, input().split()))
  c = 0
  for l in k:
    c += 2**(l-1)
  for j in range(2**n):
    dp[i][j] = min(dp[i-1][j&(~c)]+a, dp[i-1][j])

if dp[m-1][2**n-1] == float("inf"):
  print(-1)
else:
  print(dp[m-1][2**n-1])
### BUGGY CODE ###

import sys
from itertools import combinations 
input = sys.stdin.readline

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

l.sort()
cnt = 0

for n,i in enumerate(l[:]):
    for m,j in enumerate(l[n+1:],n+1):

        cnt +=len(list([c for c in set(l[m+1:]) if c<=i+j-1]))

        
print(cnt)


### FIXED CODE ###

import sys
from bisect import bisect_left
from itertools import combinations 

input = sys.stdin.readline
 
N = int(input())
l= list(map(int, input().split()))
 
l.sort()
cnt = 0
 
for n,i in enumerate(l[:N-2]):
    for m,j in enumerate(l[n+1:N-1],n+1):
        cnt += max(0,bisect_left(l,i+j)-(m+1)) 
        
print(cnt)
### BUGGY CODE ###

N = int(input())

A = [int(x) for x in input().split()]
A.sort()
for j in range(N):
    b = A.count(j+1)
    print(b)
    if b != 0:
        del A[0:(b-1)]


### FIXED CODE ###

N = int(input())
A = [int(x) for x in input().split()]
B = [0] * N
for i in range(N-1):
    B[(A[i]-1)] += 1

for j in range(N):
    print(B[j])
### BUGGY CODE ###

h,w,d=map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]

dx = [0 for _ in range(h*w+5)]
dy = [0 for _ in range(h*w+5)]

for i in range(h):
    for j in range(w):
        dx[a[i][j]] = i
        dy[a[i][j]] = j

dfromd = [0 for _ in range(h*w+5)]

for i in range(h*w-d+3):
    dfromd[i] = abs(dx[i+d]-dx[i])+abs(dy[i+d]-dy[i])

q = int(input())
for _ in range(q):
    l,r=map(int,input().split())
    res = 0
    while l < r:
        res += dfromd[l]
        l += d
    print(res)

### FIXED CODE ###

h,w,d=map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]

dx = [0 for _ in range(h*w+5)]
dy = [0 for _ in range(h*w+5)]

for i in range(h):
    for j in range(w):
        dx[a[i][j]] = i
        dy[a[i][j]] = j

dfromd = [0 for _ in range(h*w+1)]

for i in range(d+1,h*w+1):
        dfromd[i] = dfromd[i-d]+abs(dx[i-d]-dx[i])+abs(dy[i-d]-dy[i])

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

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

cnt = 0
for i in range(n):
    memo = 0
    while(a[i]%2==0):
        a[i]%=2
        memo += 1
    cnt = max(memo,cnt)
print(cnt)


### FIXED CODE ###

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

cnt = 10**10
for i in range(n):
    memo = 0
    while(a[i]%2==0):
        a[i]/=2
        memo += 1
    cnt = min(memo,cnt)
print(cnt)
### BUGGY CODE ###

from math import gcd
from functools import reduce
#K = int(input())
K = 200
def gcd_List(List):
  return reduce(gcd,List)
sum = 0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      sum += gcd_List([i,j,k])
print(sum)

### FIXED CODE ###

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

#!/usr/bin/env python3
# -*- coding:utf-8 -*-

def main():
  N_a, N_b, N_q = map(int, input().strip().split(' '))
  As = list(map(int, [input().strip() for _ in range(N_a)]))
  Bs = list(map(int, [input().strip() for _ in range(N_b)]))
  Qs = list(map(int, [input().strip() for _ in range(N_q)]))

  for q in Qs:
    min_a_l = -(2*(10**10)+1)
    min_b_l = -(2*(10**10)+1)
    min_a_r = 2*(10**10)+1
    min_b_r = 2*(10**10)+1
    for a in As:
      da = a - q
      if 0 <= da < min_a_r:
          min_a_r = da
      if 0 > da >= min_a_l:
          min_a_l = da

    for b in Bs:
      db = b - q
      if 0<= db < min_b_r:
          min_b_r = db
      if 0 > db >= min_b_l:
          min_b_l = db
    score = min([
      min_a_r if min_a_r > min_b_r else min_b_r,
      abs(min_a_l) if min_a_l < min_b_l else abs(min_b_l),
      2*min_a_r + abs(min_b_l) if min_a_r < abs(min_b_l) else min_a_r + 2*abs(min_b_l),
      2*abs(min_a_l) + abs(min_b_r) if abs(min_a_l) < abs(min_b_r) else abs(min_a_l) + 2*abs(min_b_r)])
    print(score)

  pass

if __name__=='__main__':
  main()

### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding:utf-8 -*-

from bisect import bisect_left

def main():
  N_a, N_b, N_q = map(int, input().strip().split(' '))
  As = list(map(int, [input().strip() for _ in range(N_a)]))
  Bs = list(map(int, [input().strip() for _ in range(N_b)]))
  Qs = list(map(int, [input().strip() for _ in range(N_q)]))

  for q in Qs:
    min_a_l = -(2*(10**10)+1)
    min_b_l = -(2*(10**10)+1)
    min_a_r = 2*(10**10)+1
    min_b_r = 2*(10**10)+1
    a_index = bisect_left(As, q)
    if len(As) > a_index-1 >= 0:
      min_a_l = As[a_index-1] - q
    if a_index < len(As):
      min_a_r = As[a_index] - q

    b_index = bisect_left(Bs, q)
    if len(Bs) > b_index-1 >= 0:
      min_b_l = Bs[b_index-1] - q
    if b_index < len(Bs):
      min_b_r = Bs[b_index] - q

    score = min([
      min_a_r if min_a_r > min_b_r else min_b_r,
      abs(min_a_l) if min_a_l < min_b_l else abs(min_b_l),
      2*min_a_r + abs(min_b_l) if min_a_r < abs(min_b_l) else min_a_r + 2*abs(min_b_l),
      2*abs(min_a_l) + abs(min_b_r) if abs(min_a_l) < abs(min_b_r) else abs(min_a_l) + 2*abs(min_b_r)])
    print(score)

  pass

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

import sys
import math
from collections import deque
import copy

N = int(input())
p = list(map(float, input().split()))

if N == 1:
    print(p[0])
    sys.exit()
dp = [[0 for _ in range(N + 10)] for _ in range(N + 10)]
dp[2][0] = (1 - p[0]) * (1 - p[1])
dp[2][2] = p[0] * p[1]
dp[2][1] = 1 - dp[2][0] - dp[2][2]
for i in range(3, N + 1):
    dp[i][0] = dp[i - 1][0] * p[i - 1]
for i in range(3, N + 1):
    for l in range(1, N + 1):
        dp[i][l] = dp[i - 1][l] * (1 - p[i - 1]) + dp[i - 1][l - 1] * p[i - 1]
ans = 0
for i in range(N//2+1, N+1):
    ans += dp[N][i]
print(ans)


### FIXED CODE ###

import sys
import math
from collections import deque
import copy

N = int(input())
p = list(map(float, input().split()))
if N == 1:
    print(p[0])
    sys.exit()
dp = [[0 for _ in range(N + 10)] for _ in range(N + 10)]
dp[2][0] = (1.0 - p[0]) * (1.0 - p[1])
dp[2][2] = p[0] * p[1]
dp[2][1] = 1.0 - dp[2][0] - dp[2][2]
for i in range(2, N):
    for l in range(0, N + 1):
        dp[i + 1][l + 1] += dp[i][l] * p[i]
        dp[i + 1][l] += dp[i][l] * (1.0 - p[i])
ans = 0.0
for i in range(N // 2 + 1, N + 1):
    ans += dp[N][i]
print(ans)
### BUGGY CODE ###

N,K=(int(i) for i in input().split())
while N>0:
    N=N-K
M=N+K
print(min(abs(N),M))
    

### FIXED CODE ###

N,K=(int(i) for i in input().split())
N=N-N//K*K
M=N-K
print(min(N,abs(M)))
### BUGGY CODE ###

import copy
from itertools import product, combinations

N = int(input())

dp = []
for _ in range(N):
    dp.append(list(map(int, input().split(' '))))

original = copy.deepcopy(dp)


for k, i, j in product(range(N), repeat=3):
    dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])

if dp == original:
    route_set = set()
    costs = []
    for i in range(N):
        for j in range(i + 1, N):
            route_set.add(dp[i][j])
            costs.append(dp[i][j])

    route_set = route_set - set(map(sum, combinations(costs, r=2)))
    print(sum([cost for cost in costs if cost in route_set]))
else:
    print(-1)


### FIXED CODE ###

import copy
from itertools import product, combinations

N = int(input())

dp = []
for _ in range(N):
    dp.append(list(map(int, input().split(' '))))

original = copy.deepcopy(dp)

for k, i, j in product(range(N), repeat=3):
    dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])

if dp == original:
    cost = 0
    for i in range(N):
        for j in range(i + 1, N):
            for k in range(N):
                if k == i or k == j:
                    continue
                if dp[i][j] == dp[i][k] + dp[k][j]:
                    break
            else:
                cost += dp[i][j]
    print(cost)
else:
    print(-1)
### BUGGY CODE ###

H,W=map(int,input().split())
S = []
for _ in range(H):
  S.append(list(input()))
  
Left = [[0] * W for i in range(H)]
for i in range(H):
  cur=0
  for j in range(W):
    #cur=0
    if S[i][j]=='#':
      cur=0
    else:
      cur=cur+1
    Left[i][j]=cur
    
Right=[[0] * W for i in range(H)]
for i in range(H):
  cur=0
  for j in range(W-1,-1,-1):
    if S[i][j]=='#':
      cur=0
    else:
      cur+=1
      Right[i][j]=cur
      
Up=[[0] * W for i in range(H)]
for j in range(W):
  cur=0
  for i in range(H):
    if S[i][j]=='#':
      cur=0
    else:
      cur+=1
      Up[i][j]=cur
      
Down=[[0] * W for i in range(H)]
for j in range(W):
  cur=0
  for i in range(H-1,-1,-1):
    if S[i][j]=='#':
      cur=0
    else:
      cur+=1
      Down[i][j]=cur
      
res=0
for i in range(H):
  for j in range(W):
    if S[i][j]=='#':
      continue
    res=max(res,Left[i][j]+Right[i][j]+Up[i][j]+Down[i][j]-3)
print(res)

### FIXED CODE ###

import numpy as np
H,W = map(int,input().split())
S=np.array([list(input().rstrip("\n")) for _ in range(H)]) == '.'
D = np.zeros((H,W),dtype=int)
U = np.zeros((H,W),dtype=int)
L = np.zeros((H,W),dtype=int)
R = np.zeros((H,W),dtype=int)
for i in range(H):# 上下
  U[i] = (U[i-1] + 1) * S[i]
  D[-i-1] = (D[-i] + 1) * S[-i-1]
for i in range(W):# 左右
  L[:,i] = (L[:,i-1] + 1) * S[:,i]
  R[:,-i-1] = (R[:,-i] + 1) * S[:,-i-1]
print(np.max(U+D+L+R)-3)
### BUGGY CODE ###

# coding: utf-8
# Your code here!
import copy
N,K=map(int,input().split())
R,S,P=map(int,input().split())
point=score={'r':R,'s':S,'p':P}
T=input()
l=[[]for i in range(K)]
for i in range(N):
  l[i%K].append(T[i])
def get_point(s1,s2):
    num={'r':0,'s':1,'p':2}
    if num[s1]==(num[s2]+1)%3:
        return point[s2]
    else:return 0
def rest(hand):
    if hand=='r':return['s','p']
    elif hand=='s':return['r','p']
    elif hand=='p':return['r','s']
def cal(mini_l):
    size=len(mini_l)
    kind=['r','s','p']
    order={'r':[],'s':[],'p':[]}
    score={'r':[],'s':[],'p':[]}
    for hand in kind:
        order[hand].append(hand)
        score[hand].append(get_point(mini_l[0],hand))
    for i in range(1,size):
        new_order={'r':0,'s':0,'p':0}
        for hand in kind:
            choice=''
            tmp_score=-1
            for pre_hand in rest(hand):
                if score[pre_hand][i-1]+get_point(mini_l[i],hand)>tmp_score:
                    choice=pre_hand
                    tmp_score=score[pre_hand][i-1]+get_point(mini_l[i],hand)
            new_order[hand]=copy.copy(order[choice])
            new_order[hand].append(hand)
            score[hand].append(tmp_score)
        order=new_order
    tmp_score=-1
    for hand in kind:
        if score[hand][-1]>tmp_score:
            ans=hand
            tmp_score=score[hand][-1]
    return tmp_score
ans=0
for ll in l:
    ans+=cal(ll)
print(ans)        

### FIXED CODE ###

# coding: utf-8
# Your code here!
import copy
N,K=map(int,input().split())
R,S,P=map(int,input().split())
point=score={'r':R,'s':S,'p':P}
T=input()
l=[[]for i in range(K)]
for i in range(N):
  l[i%K].append(T[i])
def get_point(s1,s2):
    num={'r':0,'s':1,'p':2}
    if num[s1]==(num[s2]+1)%3:
        return point[s2]
    else:return 0
def rest(hand):
    if hand=='r':return['s','p']
    elif hand=='s':return['r','p']
    elif hand=='p':return['r','s']
def cal(mini_l):
    size=len(mini_l)
    kind=['r','s','p']
    score={'r':[],'s':[],'p':[]}
    for hand in kind:
        score[hand].append(get_point(mini_l[0],hand))
    for i in range(1,size):
        for hand in kind:
            choice=''
            tmp_score=-1
            for pre_hand in rest(hand):
                if score[pre_hand][i-1]+get_point(mini_l[i],hand)>tmp_score:
                    choice=pre_hand
                    tmp_score=score[pre_hand][i-1]+get_point(mini_l[i],hand)
            score[hand].append(tmp_score)
    tmp_score=-1
    for hand in kind:
        if score[hand][-1]>tmp_score:
            ans=hand
            tmp_score=score[hand][-1]
    return tmp_score
ans=0
for ll in l:
    ans+=cal(ll)
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
#import numpy as np
n,m = map(int, input().split())
i=0
lst = []
while i < m: 
    l = map(int, input().split())
    lst.append(list(l))
    i+=1

sort_lst = sorted(lst)
i=1
res=[]
for i in range(1,n+1):
    j=1
    for k in sort_lst:
        if i == k[0]:
            res.append([str(k[0])+str(k[1]),str(k[0]).rjust(6,'0') + str(j).rjust(6,'0')])
            j+=1

#ans
for ans in lst:
    for r in res:
        if str(ans[0])+str(ans[1]) == r[0]:
            print(r[1])


### FIXED CODE ###

# -*- coding: utf-8 -*-
n,m = map(int, input().split())
i=0
lst = []
while i < m: 
    lst.append(list(map(int, input().split())) + [i])
    i+=1
lst = sorted(lst)
j=0
i=1
for k in lst:
    if i != k[0]:
        i=k[0]
        j=1
        k[1]=i*1000000+j
    else:
        j+=1
        k[1]=i*1000000+j

#ans
for ans in sorted(lst, key=lambda x:x[2]):
    print('{0:012d}'.format(ans[1]))
### BUGGY CODE ###

def chmin(min,cur):
	if min > cur:
		min = cur
	return min

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

dp = [float('inf') for i in range(n)]
dp[0] = 0

for i in range(n):
	for j in range(k):
		try:
			dp[i+j+1] = chmin(dp[i+j+1],dp[i]+abs(h[i]-h[i+j+1]))
		except:
			break

print(dp[n-1])

### FIXED CODE ###

import sys
input = sys.stdin.readline

def chmin(min,cur):
	if min > cur:
		min = cur
	return min

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

dp = [float('inf')]*n
dp[0] = 0

for i in range(n):
	for j in range(k):
		try:
			dp[i+j+1] = chmin(dp[i+j+1],dp[i]+abs(h[i]-h[i+j+1]))
		except:
			break

print(dp[n-1])
### BUGGY CODE ###

# coding: utf-8
N = int(input())
A = input().split()
for k in range(N):
  A_ = A.copy()
  del A_[k]
  dict = {}
  for i in range(N-1):
    if A_[i] in dict.keys():
      dict[A_[i]] += 1
    else:
      dict[A_[i]] = 1

  ans = 0
  for key in dict.keys():
    ans += int(dict[key] * (dict[key] - 1) / 2)
  print('{}'.format(ans))

### FIXED CODE ###

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

dict = {}
for i in range(N):
  if A[i] in dict.keys():
    dict[A[i]] += 1
  else:
    dict[A[i]] = 1

def comb(n):
  if n<2:
    return 0
  return int(n * (n - 1) / 2)

# all
ret = 0
for key in dict.keys():
  val = dict[key]
  ret += comb(val)

# i >= 0
for i in range(N):
  val_n = dict[A[i]]
  next_ret = ret - comb(val_n) + comb(val_n - 1)
  print(next_ret)
### BUGGY CODE ###

import math
import copy
import numpy as np

MOD = 998244353

n = int(input())
xxs = []
total = 0
for _ in range(n):
    t = int(input())
    xxs.append(t)
    total += t

xs = np.array(xxs)
dp = np.array([[0] * (total+1) for _ in range(n)])

dp[0][0] = 2
dp[0][xs[0]] = 1

curtotal = xs[0]
for i in range(1,n): # length of
    s = xs[i]
    curtotal += s
    dp[i] = (dp[i-1] * 2)
    for j in range (s,curtotal+1):
        if j - s >= 0:
            dp[i][j] = (dp[i][j] + dp[i-1][j-s])
    dp[i] %= MOD

plus = 0
if total % 2 == 0:
    dp2 = np.array([0] * (total // 2 + 1))
    dp2[0] = 1
    curtotal = 0
    for i in range(n):
        s = xs[i]
        curtotal += s
        prev = copy.copy(dp2)
        for j in range(s,min(len(dp2), curtotal+1)):
            if j-s >= 0:
                dp2[j] =  (dp2[j] + prev[j-s]) % MOD
                #print(i,j,s,dp2)
    plus = dp2[total//2]

#print(dp2)
minus = 0
for i in range(math.ceil(total/2), total+1):
    minus = (minus + dp[n-1][i]) % MOD


#print(3**n, minus, plus)
print(((3**n)%MOD - minus*3 + plus*3) % MOD)


### FIXED CODE ###

import math
import copy
import numpy as np

MOD = 998244353

n = int(input())
xxs = []
total = 0
for _ in range(n):
    t = int(input())
    xxs.append(t)
    total += t

xs = np.array(xxs)
dp = np.array([[0] * (total+1) for _ in range(n)])

dp[0][0] = 2
dp[0][xs[0]] = 1

curtotal = xs[0]
for i in range(1,n): # length of
    s = xs[i]
    curtotal += s
    dp[i] = (dp[i-1] * 2)
    dp[i][s:] += dp[i-1][:-s]
    dp[i] %= MOD

#print(dp)

plus = 0
if total % 2 == 0:
    dp2 = np.array([0] * (total // 2 + 1))
    dp2[0] = 1
    curtotal = 0
    for i in range(n):
        s = xs[i]
        curtotal += s
        prev = copy.copy(dp2)
        dp2[s:] += prev[:-s]
        dp2 %= MOD
    plus = dp2[total//2]

#print(dp2)
minus = 0
for i in range(math.ceil(total/2), total+1):
    minus = (minus + dp[n-1][i]) % MOD


#print(3**n, minus, plus)
print(((3**n)%MOD - minus*3 + plus*3) % MOD)
### BUGGY CODE ###

#!/usr/bin/env python3

def main():
    N, K = map(int, input().split())
    h = list(map(int, input().split()))
    INF = 10**12
    dp = [INF] * (N+1)
    dp[1] = 0
    for i in range(2,N+1):
        dp[i] = min(dp[i-j]+abs(h[i-1]-h[i-j-1]) for j in range(1,min(K,i)+1))
    print(dp[N])

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    N, K = map(int, input().split())
    h = list(map(int, input().split()))
    INF = 10**12
    dp = [INF] * (N+1)
    dp[1] = 0
    for i in range(1,N):
        for j in range(1,K+1):
            if i+j > N:
                break
            else:
                dp[i+j] = min(dp[i+j],dp[i]+abs(h[i-1]-h[i+j-1]))
    print(dp[N])

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

n = int(input())
s = [0] * n
li = []
ans = []
for i in range(n):
    s[i] = input()
    if s[i] in ans:
        li[ans.index(s[i])][1] += 1
    else:
        li.append([s[i], 1])
        ans.append(s[i])
              
li.sort(key = lambda x: x[0])
li.sort(key = lambda x: x[1] , reverse = True)

a = li[0][1]
for j in range(len(li)):
    if a == li[j][1]:
        print(li[j][0])
    else:
        break

### FIXED CODE ###

n = int(input())
s = [input() for i in range(n)]

dic = {}
for i in range(n):
    if s[i] in dic:
        dic[s[i]] += 1
    else:
        dic[s[i]] = 1

max_dic = max(dic.values())
ans = [i for i, j in dic.items() if j == max_dic]
ans.sort()

for i in range(len(ans)):
    print(ans[i])