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

import sys
import heapq

v,e,r=map(int, input().split());

e_1=[0]*e;
e_2=[0]*e;
e_w=[0]*e;

for i in range(e):
    e_1[i], e_2[i], e_w[i] = map(int, input().split());

v_q=[];

INF = 9999999999999999999
d = [INF for i in range(v)]
d[r] = 0
heapq.heappush(v_q,(0,r))
while(len(v_q) != 0):
    cost,u = heapq.heappop(v_q)
    if(cost > d[u]):
        continue
    for j in range(e):
        if(u == e_1[j]):
            alt = cost+e_w[j]
            if(d[e_2[j]] > alt):
                d[e_2[j]] = alt
                heapq.heappush(v_q,(alt,e_2[j]))

for i in range(v):
    if(d[i] != INF):
        print(d[i])
    else:
        print("INF")


### FIXED CODE ###

import sys
from collections import deque

v,e,r=map(int, input().split());

edge_info=[0]*v;
for i in range(v):
    edge_info[i] = []

for i in range(e):
    e1, e2, w = map(int, input().split());
    edge_info[e1].append((e2,w))

v_q=deque();

INF = 9999999999999999999
d = [INF for i in range(v)]
d[r] = 0
v_q.append((0,r))
while(len(v_q) != 0):
    cost,u = v_q.popleft()
    if(cost > d[u]):
        continue
    for j in range(len(edge_info[u])):
        e2,w = edge_info[u][j]
        alt = cost+w
        if(d[e2] > alt):
            d[e2] = alt
            v_q.append((alt,e2))

for i in range(v):
    if(d[i] != INF):
        print(d[i])
    else:
        print("INF")
### BUGGY CODE ###

def main():
    import sys
    input = sys.stdin.buffer.readline
    from collections import deque
    N, Q = (int(i) for i in input().split())
    G = [[] for _ in range(N)]
    cost = [0]*N
    for _ in range(N-1):
        a, b = (int(i) for i in input().split())
        G[a-1].append(b-1)
        G[b-1].append(a-1)
    G_color = ['WHITE' for _ in range(len(G))]
    G_parent = ['NIL' for _ in range(len(G))]

    def bfs(s):
        G_color[s] = 'GRAY'
        Q = deque()
        Q.append(s)
        while Q:
            u = Q.popleft()
            for v in G[u]:
                if G_color[v] == 'WHITE':
                    G_color[v] = 'GRAY'
                    G_parent[v] = u
                    Q.append(v)
            G_color[u] = 'BLACK'

    def dfs(v, x):
        seen = [False] * N
        todo = []
        seen[v] = True
        todo.append(v)
        while todo:
            u = todo[-1]
            for next_v in G[u]:
                if seen[next_v] or next_v == G_parent[u]:
                    continue
                seen[next_v] = True
                todo.append(next_v)
                break
            else:
                w = todo.pop()
                cost[w] += x

    bfs(0)
    for _ in range(Q):
        p, x = (int(i) for i in input().split())
        dfs(p-1, x)
    print(*cost)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.buffer.readline
    from collections import deque
    N, Q = (int(i) for i in input().split())
    G = [[] for _ in range(N)]
    cost = [0]*N
    for _ in range(N-1):
        a, b = (int(i) for i in input().split())
        G[a-1].append(b-1)
        G[b-1].append(a-1)
    for _ in range(Q):
        p, x = (int(i) for i in input().split())
        cost[p-1] += x

    def bfs(s):
        G_color = ['WHITE' for _ in range(len(G))]
        G_color[s] = 'GRAY'
        Q = deque()
        Q.append(s)
        while Q:
            u = Q.popleft()
            for v in G[u]:
                if G_color[v] == 'WHITE':
                    G_color[v] = 'GRAY'
                    cost[v] += cost[u]
                    Q.append(v)
            G_color[u] = 'BLACK'

    bfs(0)
    print(*cost)


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

# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy
import bisect


def dfs(s, prev, pre):
  val[s] += Ope[s] + prev
  for i in G[s]:
    if(i == pre):
      continue
    dfs(i, val[s], s)

def bfs(sx, sy, n):
  que = deque([[sy,sx]])
  while que:
    y,x = que.popleft()
    for i,j in D:
      if(x+i<0 or y+j<0 or x+i>W-1 or y+j>H-1):
        continue
      dist = G[y+j][x+i]
      if(G[y+j][x+i] != "X"):
        if(type(G[y+j][x+i]) is str):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        elif(dist>G[y][x]+1):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        

#X = str(input()).split()
#a = [int(x) for x in input().split()]
#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]

S = str(input())
Q = int(input())
flag = 0


for i in range(Q):
  Que = str(input()).split()
  if(int(Que[0])==1):
    flag = 1 - flag
  else:
    if(flag == 1):
      if(int(Que[1])==1):
        S = S + Que[2]
      else:
        S = Que[2] + S
    else:
      if(int(Que[1])==1):
        S = Que[2] + S
      else:
        S = S + Que[2]

if(flag == 1):
  S = S[::-1]

print(S)


### FIXED CODE ###

# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy
import bisect


def dfs(s, prev, pre):
  val[s] += Ope[s] + prev
  for i in G[s]:
    if(i == pre):
      continue
    dfs(i, val[s], s)

def bfs(sx, sy, n):
  que = deque([[sy,sx]])
  while que:
    y,x = que.popleft()
    for i,j in D:
      if(x+i<0 or y+j<0 or x+i>W-1 or y+j>H-1):
        continue
      dist = G[y+j][x+i]
      if(G[y+j][x+i] != "X"):
        if(type(G[y+j][x+i]) is str):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        elif(dist>G[y][x]+1):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        

#X = str(input()).split()
#a = [int(x) for x in input().split()]
#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]

S = str(input())
Q = int(input())
flag = 0

S2 = deque(S)

#print(S2)

for i in range(Q):
  Que = str(input()).split()
  if(int(Que[0])==1):
    flag = 1 - flag
  else:
    if(flag == 1):
      if(int(Que[1])==1):
        S2.append(Que[2])
      else:
        S2.appendleft(Que[2])
    else:
      if(int(Que[1])==1):
        S2.appendleft(Que[2])
      else:
        S2.append(Que[2])

S = "".join(list(S2))

if(flag == 1):
  S = S[::-1]

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

#!/usr/bin/python3

import sys
from bisect import bisect_left
from collections import defaultdict

sys.setrecursionlimit(1000000)

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

nbs = defaultdict(list)

for i in range(n - 1):
    (u, v) = map(int, input().split())
    nbs[u - 1].append(v - 1)
    nbs[v - 1].append(u - 1)


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

def getmlen(cur, p, ctail):
    oidx = 0
    ov = 0
    
    idx = bisect_left(dp, a[cur])
    ov = dp[idx]

    ntail = ctail
    if ctail < idx:
        ntail = idx

    dp[idx] = a[cur]
    mlen[cur] = ntail + 1
    
    for ch in nbs[cur]:
        if ch == p:
            continue

        getmlen(ch, cur, ntail)
    dp[idx] = ov



getmlen(0, -1, 0)

for i in range(n):
    print(mlen[i])


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
from bisect import bisect_left
 
N = int(input())
a = [int(i) for i in input().split()]
vec = [[] for _ in range(N)]
for _ in range(N - 1) :
  u, v = map(int, input().split())
  vec[u - 1].append(v - 1)
  vec[v - 1].append(u - 1)
 
lis = [a[0]]
ret = [0] * N
def dfs(cur, pre) :
  for nex in vec[cur] :
    if nex == pre : continue
    if a[nex] > lis[-1] :
      lis.append(a[nex])
      ret[nex] = len(lis)
      dfs(nex, cur)
      lis.pop()
    else :
      pos = bisect_left(lis, a[nex])
      v = lis[pos]
      lis[pos] = a[nex]
      ret[nex] = len(lis)
      dfs(nex, cur)
      lis[pos] = v
 
dfs(0, -1)
 
ret[0] = 1
for i in range(N) :
  print(ret[i])
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()
l, r = [0] * Q, [0] * Q
for i in range(Q):
    l[i], r[i] = map(int, input().split())
for i in range(Q):
    print(S[l[i] - 1:r[i]].count("AC"))


### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
l, r = [0] * Q, [0] * Q
cnt = [0] * len(S)
for i in range(Q):
    l[i], r[i] = map(int, input().split())
    l[i] -= 1
    r[i] -= 1
for i in range(1, len(S)):
    if(i == 0): pass
    cnt[i] = cnt[i - 1]
    if (S[i] == 'C' and S[i - 1] == 'A'):
        cnt[i] += 1
for i in range(Q):
    print(cnt[r[i]] - cnt[l[i]])
### BUGGY CODE ###

N,A=int(input()),list(map(int,input().split()))
b=[]
for i in A:
    if i in b:
        print("NO")
        exit()
    b.append(i)
print("YES")

### FIXED CODE ###

N,A=int(input()),list(map(int,input().split()))
A=sorted(A,key=int)
l=set([])
for i in A:
    if i in l:
        print("NO")
        exit()
    else:
        l.add(i)
print("YES")
### BUGGY CODE ###

import bisect

n = int(input())
p = list(map(int, input().split()))
pi = sorted(zip(p, range(n)))

index = [-1, -1, pi[n - 1][1], n, n]
ret = 0
for pos in range(n - 2, -1, -1):
    p, i = pi[pos]
    ii = bisect.bisect_left(index, i)
    ret += p * (index[ii - 1] - index[ii - 2]) * (index[ii] - i)
    ret += p * (i - index[ii - 1]) * (index[ii + 1] - index[ii])
    index.insert(ii, i)
print(ret)


### FIXED CODE ###

n = int(input())
p = list(map(int, input().split()))
pi = sorted(zip(p, range(n)))
left  = {i: i - 1 for i in range(n)}
right = {i: i + 1 for i in range(n)}
left[-1] = -1
right[n] = n

ret = 0
for p, i in pi:
    ret += p * (left[i] - left[left[i]]) * (right[i] - i)
    ret += p * (i - left[i]) * (right[right[i]] - right[i])
    l, r = left[i], right[i]
    right[l] = r
    left[r] = l
print(ret)
### BUGGY CODE ###

k = int(input())

if k%2 ==0:
    print(-1)
    exit(0)

for i in range(1, 10**12):
    n = int(('7'*i))
    if n%k == 0:
        print(i)
        exit(0)

print(-1)

### FIXED CODE ###

k = int(input())

m = 0

for i in range(1, 10**7):
    n = m *10 +7
    m = n % k
    if m == 0:
        print(i)
        exit(0)

print(-1)
### BUGGY CODE ###

n = int(input())
a = []
for i in range(n):
    tmp = int(input())
    if tmp in a:
        a.remove(tmp)
    else:
        a.append(tmp)

print(len(a))

### FIXED CODE ###

n = int(input())
a = {}
cnt = 0
for i in range(n):
    tmp = int(input())
    if tmp not in a:
        a[tmp] = 1
    else:
        a[tmp] += 1

for v in a.values():
    if v % 2 != 0:
        cnt += 1

print(cnt)
### BUGGY CODE ###

x, y, z, k = map(int, input().split())
a_s = list(map(int, input().split()))
bs = list(map(int, input().split()))
cs = list(map(int, input().split()))

list = [a_s[l] + bs[m] + cs[n] for l in range(x) for m in range(y) for n in range(z)]
list.sort(reverse=True)
for i in range(k):
    print(list[i])

### FIXED CODE ###

x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ab = []
for ai in a:
  for bi in b:
    ab.append(ai + bi)
ab.sort(reverse = True)

abc = []

for abi in ab[:k]:
  for ci in c:
    abc.append(abi + ci)
abc.sort(reverse = True)

for abci in abc[:k]:
  print(abci)
### BUGGY CODE ###

import sys
inputs = sys.stdin.readlines()
n = int(inputs[0])
L = list(map(int, inputs[1].split()))

sort_L = sorted(L)
ans = 0
for i in range(n-2):
    a = sort_L[i]
    for j in range(i+1, n-1):
        b = sort_L[j]
        d, e = b-a, a+b
        for k in range(j+1, n):
            c = sort_L[k]
            if d < c:
                if c < e:
                    ans += 1
                else:
                    break
print(ans)

### FIXED CODE ###

import sys
inputs = sys.stdin.readlines()
n = int(inputs[0])
L = list(map(int, inputs[1].split()))
A = sorted(L)
 
ans = 0
for i in range(n-1, 0, -1):
    l, r = 0, i-1
    while l < r:
        if A[i] < A[l] + A[r]:
            ans += r-l
            r -= 1
        else:
            l += 1

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

n, m = map(int, input().split())
a = list(map(int, input().split()))
while m != 0:
    maxa = max(a)
    for i in range(n):
        if a[i] == maxa:
            a[i] /= 2
            m -= 1

ans = 0
#print(a)
for i in range(n):
    ans += int(a[i])
print(ans)

### FIXED CODE ###

from heapq import heapify, heappop, heappush

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

for i in range(n):
    a[i] *= -1
heapify(a)
#print(a)
for i in range(m):
    maxa = heappop(a)
    heappush(a, -(-maxa//2))
#print(a)
print(-(sum(a)))
### BUGGY CODE ###

x,k,d = map(int,input().split())

x = abs(x)

if x > k*d:
    print(x-k*d)
elif x == 0:
    if k%2 ==0:
        print(0)
    else:
        print(d)
else:
    x_r = x%d
    x_l = x%d - d
    t = 0
    while x >= 0:
        x -= d
        t += 1
    if (k - t)%2 == 0:
        print(abs(x_l))
    else:
        print(x_r)

### FIXED CODE ###

x,k,d = map(int,input().split())

x = abs(x)

if x > k*d:
    print(x-k*d)
elif x == 0:
    if k%2 ==0:
        print(0)
    else:
        print(d)
else:
    x_r = x%d
    x_l = x%d - d
    t = 0
    while x >= 0:
        x -= d
        t += 1
    if (k - t)%2 == 0:
        print(abs(x_l))
    else:
        print(x_r)
### BUGGY CODE ###

n, k = map(int, input().split())
arr = [int(_) for _ in input().split()]
max = 0
max_p = 0

for i in range(0, n-k+1):
  t = sum(arr[i:i+k])
  if max < t:
    max = t
    max_p = sum([_*(_+1)/(_*2.0) for _ in arr[i:i+k]])

print(max_p)

### FIXED CODE ###

import numpy as np
n, k = map(int, input().split())
arr = np.array([int(_)*(int(_)+1)/(int(_)*2.0) for _ in input().split()])

max = t = sum(arr[0:k])

for i in range(1, n-k+1):
  t += arr[i+k-1]
  t -= arr[i-1]
  if max < t:
    max = t

print(max)
### BUGGY CODE ###

K,S=map(int,input().split())

z = list(range(0,K+1))
answer = []

for i in z:
  s_z = S - i
  if K < s_z:
    for x in list(range(s_z - K,K+1)):
      y = s_z - x
      answer.append([x, y, z])

  else:
    for x in list(range(0,s_z+1)):
      y = s_z - x
      answer.append([x, y, z])

print(len(answer))

### FIXED CODE ###

K,S=map(int,input().split())

z = list(range(0,K+1))
answer = []

for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      answer.append(K + 1 - (s_z - K))
  else:
    answer.append(s_z + 1)

print(sum(answer))
### BUGGY CODE ###

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

ans = 0
for i in range(N):
    ans += A[i] * sum(A[i + 1:])
    ans %= 1000000007
print(ans)


### FIXED CODE ###

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

ans = 0
sum_list = sum(A)
for i in range(N):
    ans += A[i] * (sum_list - A[i])
    ans %= 1000000007
    sum_list -= A[i]
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

INF = 10 ** 10

d = [[INF] * n for _ in range(n)]
for i in range(n):
    d[i][i] = 0

for i in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    d[a][b] = c
    d[b][a] = c

for k in range(n):
    for i in range(n):
        for j in range(n):
            if d[i][j] > d[i][k] + d[k][j]:
                d[i][j] = d[i][k] + d[k][j]

# print()
# print(*d, sep='\n')

for i in range(n):
    for j in range(n):
        if i == j:
            continue

        if d[i][j] <= l:
            d[i][j] = 1
        else:
            d[i][j] = INF

for k in range(n):
    for i in range(n):
        for j in range(n):
            if d[i][j] > d[i][k] + d[k][j]:
                d[i][j] = d[i][k] + d[k][j]

# print()
# print(*d, sep='\n')

q = int(input())
for i in range(q):
    s, t = map(int, input().split())
    s -= 1
    t -= 1

    if d[s][t] == INF:
        print(-1)
    else:
        print(d[s][t]-1)


### FIXED CODE ###

import sys
input = sys.stdin.readline

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

INF = float("INF")

d = [[INF] * n for _ in range(n)]
for i in range(n):
    d[i][i] = 0

for i in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    d[a][b] = c
    d[b][a] = c

for k in range(n):
    for i in range(n):
        for j in range(n):
            if d[i][j] > d[i][k] + d[k][j]:
                d[i][j] = d[i][k] + d[k][j]

# print()
# print(*d, sep='\n')

for i in range(n):
    for j in range(n):
        if i == j:
            continue

        if d[i][j] <= l:
            d[i][j] = 1
        else:
            d[i][j] = INF

for k in range(n):
    for i in range(n):
        for j in range(n):
            if d[i][j] > d[i][k] + d[k][j]:
                d[i][j] = d[i][k] + d[k][j]

# print()
# print(*d, sep='\n')

q = int(input())
for i in range(q):
    s, t = map(int, input().split())
    s -= 1
    t -= 1

    if d[s][t] == INF:
        print(-1)
    else:
        print(d[s][t]-1)
### BUGGY CODE ###

n = int(input())
ls = list(map(int,input().split()))
for i in range(1,n+1):
    print(ls.count(i))

### FIXED CODE ###

n = int(input())
ls = list(map(int,input().split()))
a = [0]*(n)
p = 0
for i in range(n-1):
    p = ls[i] 
    a[p-1] +=1
for j in range(n):
    print(a[j])
### BUGGY CODE ###

from math import ceil
n, k = map(int, input().split())
A = sorted(map(int, input().split()))
F = sorted(map(int, input().split()))
A.reverse()
ok = max(a * f for a, f in zip(A, F))
ng = -1
while ok - ng != 1:
    x = (ok + ng) // 2
    cnt = 0
    for a, f in zip(A, F):
        if a * f > x:
            cnt += ceil(a - x / f)
        if cnt > k:
            ng = x
            break
    else:
        ok = x

print(ok)


### FIXED CODE ###

def main():
    from math import ceil
    n, k = map(int, input().split())
    A = sorted(map(int, input().split()))
    F = sorted(map(int, input().split()))
    A.reverse()
    ok = max(a * f for a, f in zip(A, F))
    ng = -1
    while ok - ng != 1:
        x = (ok + ng) // 2
        cnt = 0
        for a, f in zip(A, F):
            if a * f > x:
                cnt += ceil(a - x / f)
            if cnt > k:
                ng = x
                break
        else:
            ok = x

    print(ok)

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

a, b = map(int, input().split())

i = max(a, b)
while True:
    if i%a == 0 and i%b == 0:
        print(i)
        break
    else: i += 1


### FIXED CODE ###

a, b = map(int, input().split())

def gcd(a, b):
    while b != 0:
        a, b = b, a%b
    return a
    
def lcm(a, b):
    return int(a*b/gcd(a, b))

print(lcm(a, b))
### BUGGY CODE ###

from itertools import combinations as f
l,r=map(int,input().split())
print(min([i*j%2019 for i,j in f(set(map(lambda x:x%2019,range(l,r+1))),2)]))

### FIXED CODE ###

from itertools import combinations as f
l,r=map(int,input().split())
s=set(map(lambda x:x%2019,range(l,r+1)[:2019]))
print(min([i*j%2019 for i,j in f(s,2)]))
### BUGGY CODE ###

def main():
    N, K = list(map(int, input().split()))
    P = list(map(int, input().split()))

    expect = [((p + 1) / 2.0) for p in P]
    sum_exp = [sum(expect[i:i + K]) for i in range(N - K + 1)]
    print(max(sum_exp))


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N, K = list(map(int, input().split()))
    P = list(map(int, input().split()))

    E = [((p + 1) / 2.0) for p in P]

    total = 0
    m = 0
    for i in range(N):
        if i < K:
            total += E[i]
        else:
            total += E[i] - E[i - K]

        if total > m:
            m = total

    print(m)


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

# For taking integer inputs.
import math
from decimal import Decimal
from itertools import permutations


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


n = inp()
a = inlist()
D = 10000000000000000
mid = 0
for i in range(1, n):

    s1 = sum(a[:i])
    s2 = sum(a[i:])

    d = abs(s1 - s2)

    if d < D:
        mid = i
        D = d
s1 = sum(a[:mid])
s2 = sum(a[mid:])
res = abs(s1-s2)
print(res)


### FIXED CODE ###

# For taking integer inputs.
import math
from decimal import Decimal
from itertools import permutations


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


n = inp()
a = inlist()
pref = [0] * (n)
suf = [0] * n
pref[0] = a[0]
suf[n-1] = a[n-1]
j = n - 2
for i in range(1, n):
    pref[i] = a[i] + pref[i-1]
    suf[j] = a[j] + suf[j+1]
    j -= 1

D = 10000000000000000
for i in range(0, n-1):

    s1 = pref[i]
    s2 = suf[i+1]
    d = abs(s1 - s2)
    if d < D:

        D = d

print(D)
### BUGGY CODE ###

n = int(input())
for i in range(n):
    if i == 0:
        s = input()
        S = {s: 1}
    else:
        s = input()
        if s in S:
            S[s] += 1
        else:
            S[s] = 1
max_k_list = [kv[0] for kv in S.items() if kv[1] == max(S.values())]
ans = sorted(max_k_list)
for a in ans:
    print(a, sep="\n")

### FIXED CODE ###

n = int(input())
ans = []
for i in range(n):
    if i == 0:
        s = input()
        S = {s: 1}
        ans.append(s)
        mx = 1
    else:
        s = input()
        if s in S:
            S[s] += 1
            if S[s] > mx:
                ans = [s]
                mx = S[s]
            elif S[s] == mx:
                ans.append(s)
        else:
            S[s] = 1
            if S[s] == mx:
                ans.append(s)
ans = sorted(ans)
for a in ans:
    print(a, sep="\n")