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

n, a, b = list(map(int, input().split()))
MAX = 510000
MOD = 1000000007

fac = [0 for i in range(MAX)]
finv = [0 for i in range(MAX)]
inv = [0 for i in range(MAX)]
com = [0 for i in range(MAX)]

def cominit() :
  fac[0] = fac[1] = 1
  finv[0] = finv[1] = 1
  inv[1] = 1
  com[1] = n
  for i in range(2, MAX) :
    fac[i] = fac[i-1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * int(MOD / i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD
    com[i] = com[i-1] * (n-(i-1)) * inv[i] % MOD
    
  return fac, finv, inv, com
 
"""
def combination(n, r, inv) :
  ans = 1
  if(n < r) : 
    return 0
  if((n < 0) or (r < 0)) :
    return 0
  for i in range(0, r) :
    return (fac[n] * (finv[r] * finv[n-r] % MOD) % MOD) 
 """

def two_n_mod(n) :
  ans = 1
  while(n > 32) :
    ans = ans * 2**32 % MOD
    n -= 32
  return ans * 2**n % MOD

temp = cominit()
##print(two_n_mod(1000000000))
print((two_n_mod(n) - 1 - com[a] - com[b]) % MOD)



### FIXED CODE ###

n, a, b = list(map(int, input().split()))
MAX = 510000
MOD = 1000000007


fac = [0 for i in range(MAX)]
finv = [0 for i in range(MAX)]
inv = [0 for i in range(MAX)]
com = [0 for i in range(MAX)]
power = [2 for i in range(32)]

for i in range(1, 32) :
  power[i] = power[i-1] * power[i-1] % MOD

def cominit() :
  fac[0] = fac[1] = 1
  finv[0] = finv[1] = 1
  inv[1] = 1
  com[1] = n
  for i in range(2, MAX) :
    fac[i] = fac[i-1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * int(MOD / i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD
    com[i] = com[i-1] * (n-(i-1)) * inv[i] % MOD
    
  return fac, finv, inv, com


def two_n_mod(n) :
  ans = 1
  temp_i = 0
  temp = [0 for i in range(32)]
    
  for i in range(32) :
    temp[i] += n%2
    n = int(n/2)
  ans = (2**n) % MOD
  for i in range(32) :
    ans = ans * (power[i] ** temp[i]) % MOD
  return ans

temp = cominit()
##print(two_n_mod(1000000000))
##print(2**n % MOD)
print((two_n_mod(n) - 1 - com[a] - com[b]) % MOD)
### BUGGY CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
for i in range(0,M):
    A[0]=int(A[0]/2)
    A.sort(reverse=True)

print(sum(A))

### FIXED CODE ###

import heapq
N, M = map(int, input().split())
A = list(map(lambda x:int(x)*(-1), input().split()))
heapq.heapify(A)
for i in range(0,M):
    a=heapq.heappop(A)
    heapq.heappush(A,(-1)*(-a//2))
print(-sum(A))

#　優先度付きキューが難しい
### BUGGY CODE ###

from collections import deque

h,w,K = map(int,input().split())

maze = [[x for x in input()] for _ in range(h)]

sx = 0
sy = 0

for i in range(h):
    for j in range(w):
        if maze[i][j] == 'S':
            sx = j
            sy = i

d = [[float('inf')]*w for _ in range(h)]
d[sy][sx] = 0

q = deque([[sy,sx]])
c = 0

visited = [[False]*w for _ in range(h)]
visited[sy][sx] = True

while q:
    y,x = q.popleft()
    for j,k in [[1,0],[-1,0],[0,1],[0,-1]]:
        ny,nx = y+j,x+k
        if maze[ny][nx] == '.' and not visited[ny][nx]:
            d[ny][nx] = d[y][x] + 1
            if ny in {0,h-1} or nx in {0,w-1}:
                if d[ny][nx] <= k:
                    print(1)
                    exit()
                else:
                    continue
            else:
                visited[ny][nx] = True
                q.append([ny,nx])
                c += 1
    if c >= 4*K**2:
        break
    

def BFS(sy,sx):
    visited = [[-1]*w for _ in range(h)]
    q = deque([[sy,sx]])
    visited[sy][sx] = 0
    while q:
        y,x = q.popleft()
        if y == 0 or y == h-1 or x == 0 or x == w-1:
            return visited[y][x]
        for l,k in [[1,0],[-1,0],[0,1],[0,-1]]:
            new_y,new_x = y+l,x+k
            if visited[new_y][new_x] == -1:
                visited[new_y][new_x] = visited[y][x] + 1
                q.append([new_y,new_x])

ans = float('inf')

for i in range(h):
    for j in range(w):
        if d[i][j] <= K:
            ans = min(ans,BFS(i,j))

print((ans-1) // K +2)

### FIXED CODE ###

from collections import deque

h,w,K = map(int,input().split())

maze = [[x for x in input()] for _ in range(h)]

sx = 0
sy = 0

for i in range(h):
    for j in range(w):
        if maze[i][j] == 'S':
            sx = j
            sy = i

d = [[float('inf')]*w for _ in range(h)]
d[sy][sx] = 0

q = deque([[sy,sx]])
c = 0

visited = [[False]*w for _ in range(h)]
visited[sy][sx] = True

while q:
    y,x = q.popleft()
    for j,k in [[1,0],[-1,0],[0,1],[0,-1]]:
        ny,nx = y+j,x+k
        if maze[ny][nx] == '.' and not visited[ny][nx]:
            d[ny][nx] = d[y][x] + 1
            if ny in {0,h-1} or nx in {0,w-1}:
                if d[ny][nx] <= K:
                    print(1)
                    exit()
                else:
                    continue
            else:
                visited[ny][nx] = True
                if d[ny][nx] == K:
                    continue
                else:
                    q.append([ny,nx])
    

def BFS(sy,sx):
    visited = [[-1]*w for _ in range(h)]
    q = deque([[sy,sx]])
    visited[sy][sx] = 0
    while q:
        y,x = q.popleft()
        if y == 0 or y == h-1 or x == 0 or x == w-1:
            return visited[y][x]
        for l,k in [[1,0],[-1,0],[0,1],[0,-1]]:
            new_y,new_x = y+l,x+k
            if visited[new_y][new_x] == -1:
                visited[new_y][new_x] = visited[y][x] + 1
                q.append([new_y,new_x])

ans = float('inf')

for i in range(h):
    for j in range(w):
        if d[i][j] <= K:
            ans = min(ans,min(i,h-1-i,j,w-1-j))

print((ans-1) // K +2)
### BUGGY CODE ###

N,K=(int(x) for x in input().split())
A=list(map(int, input().split()))
s=1
for i in range(K):
    s=A[s-1]
print(s)


### FIXED CODE ###

N,K=(int(x) for x in input().split())
A=list(map(int, input().split()))
if K<=N:
    s=1
    for i in range(K):
        s=A[s-1]
    print(s)
else:
    s=1
    S={1}
    iloop=1
    while A[s-1] not in S:
        S.add(A[s-1])
        s=A[s-1]
        iloop=iloop+1
    p=s
    loop=1
    while A[s-1] != p:
        loop=loop+1
        s=A[s-1]
    g=(K-iloop)%loop+iloop
    s=1
    for i in range(g):
        s=A[s-1]
    print(s)
### BUGGY CODE ###

import itertools
n,k = map(int,input().split())
x = []
a = []
b = []
for i in range(n):
    x1,y1=[int(i) for i in input().split()]
    x.append([x1,y1])
    a.append(x1)
    b.append(y1)
ue = list(itertools.combinations(a,2))
mi = list(itertools.combinations(b,2))
ans = float("inf")
for u,d in ue:
  for m,h in mi:
    kazu = 0
    if u > d:
      UP = u
      DO = d
    else:
      UP = d
      DO = u
    if m > h:
      RI = m
      LE = h
    else:
      RI = h
      LE = m
    for i in  x:
      if (UP >= i[0] and i[0]>= DO and RI >= i[1] and i[1] >= LE):
        kazu += 1
    if kazu >= k:
      ans = min(ans,(UP-DO)*(RI-LE))
print(ans)

### FIXED CODE ###

import itertools
n,k = map(int,input().split())
x = []
a = []
b = []
for i in range(n):
    x1,y1=[int(i) for i in input().split()]
    x.append([x1,y1])
    a.append(x1)
    b.append(y1)
ue = list(itertools.combinations(a,2))
mi = list(itertools.combinations(b,2))
e = len(ue)
ue.extend(mi)
ans = float("inf")
for i in range(e):
  u = ue[i]
  if u[0] > u[1]:
    UP = u[0]
    DO = u[1]
  else:
    UP = u[1]
    DO = u[0]
  for j in range(e):
    kazu = 0
    m = ue[j+e]
    if m[0] > m[1]:
      RI = m[0]
      LE = m[1]
    else:
      RI = m[1]
      LE = m[0]
    for i in  x:
      c = i[0]
      d = i[1]
      if (UP >= c and c>= DO and RI >= d and d >= LE):
        kazu += 1
    if kazu >= k:
      ans = min(ans,(UP-DO)*(RI-LE))
print(ans)
### BUGGY CODE ###

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

    count = 1
    for i in range(1,N):
        for p in range(i):
            if P[p] < P[i]:
                break
        else:
            count += 1
    print(count)
if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N = int(input())
    P = list(map(int,input().split()))
    min_val = 2*10e5
    count = 1
    for i in range(1,N):
        if min_val > P[i-1]:
            min_val = P[i-1]
        if P[i] <= min_val:
            count += 1
    print(count)
if __name__ == '__main__':
    main()
### BUGGY CODE ###

from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
from fractions import gcd

sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7


def inp(): return int(sys.stdin.readline())


def inp_list(): return list(map(int, sys.stdin.readline().split()))


def lcm(x, y): return (x * y) // gcd(x, y)

N, K = inp_list()
h = inp_list()

dp = [INF] * N
dp[0] = 0 # initial condition
# 計算量: O(NK)
for i in range(N - 1):
    for j in range(i + 1, i + K + 1):
        if j > N - 1: break
        dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j])) # recurrence formula
    
print(dp[N - 1])


### FIXED CODE ###

from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
from fractions import gcd

sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7


def inp(): return int(sys.stdin.readline())


def inp_list(): return list(map(int, sys.stdin.readline().split()))


def lcm(x, y): return (x * y) // gcd(x, y)

N, K = inp_list()
h = inp_list()

dp = [INF] * N
dp[0] = 0 # initial condition
# 計算量: O(NK)
for i in range(N - 1):
    for j in range(i + 1, i + K + 1):
        if j > N - 1: break
        dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j])) # recurrence formula
    
print(dp[N - 1])
### BUGGY CODE ###

import sys
from heapq import heappush, heappop


I = sys.stdin.readlines()
N, Q = map(int, I[0].split())
P = []
for i in range(1, N + 1):
    s, t, x = map(int, I[i].split())
    P.append((s - x, t - 1 - x, x))
P.sort()


q = []
cur = 0
ans = [-1] * Q
for i in range(N + 1, N + Q + 1):
    d = int(I[i])
    while cur < N and P[cur][0] <= d:
        s, t, x = P[cur]
        heappush(q, (x, s, t))
        cur += 1
    while q and q[0][2] < d:
        heappop(q)
    if q:
        ans[i - N - 1] = q[0][0]

print(*ans, sep='\n')


### FIXED CODE ###

import sys
from heapq import heappush, heappop


I = sys.stdin.readlines()
N, Q = map(int, I[0].split())
P = []
for i in range(1, N + 1):
    s, t, x = map(int, I[i].split())
    P.append((s - x, t - 1 - x, x))
P.sort()


q = []
cur = 0
for i in range(N + 1, N + Q + 1):
    d = int(I[i])
    while cur < N and P[cur][0] <= d:
        s, t, x = P[cur]
        heappush(q, (x, t))
        cur += 1
    ans = -1
    while len(q) > 0:
        x, t = q[0]
        if d <= t:
            ans = x
            break
        else:
            heappop(q)
    print(ans)
### BUGGY CODE ###

#coding: UTF-8
N=int(input())
out=1
for i in range(1,N+1):
    out=out*i
print(out%(10**9+7))

### FIXED CODE ###

#coding: UTF-8
import math
N=int(input())
out=math.factorial(N)
print(out%(10**9+7))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)

def main():
    input = sys.stdin.readline
    N, Q = map(int, input().split())
    G = [set() for _ in range(N)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        G[a-1].add(b-1)
        G[b-1].add(a-1)

    weights = [0] * N
    for _ in range(Q):
        p, x = map(int, input().split())
        weights[p-1] += x

    ans = [0] * N
    ans[0] = weights[0]
    visited = [False] * N
    def f(a, node):
        visited[node] = True
        for nt in G[node]:
            if visited[nt]:
                continue
            b = a + weights[nt]
            ans[nt] = b
            f(b, nt)
        return  0

    f(weights[0], 0)
    return ' '.join(map(str, ans))


if __name__ == '__main__':
    print(main())


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

def main():
    input = sys.stdin.readline
    N, Q = map(int, input().split())
    G = [set() for _ in range(N)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        G[a-1].add(b-1)
        G[b-1].add(a-1)

    weights = [0] * N
    for _ in range(Q):
        p, x = map(int, input().split())
        weights[p-1] += x

    ans = [0] * N
    ans[0] = weights[0]
    visited = [False] * N
    def f(a, node):
        visited[node] = True
        for nt in G[node]:
            if visited[nt]:
                continue
            b = a + weights[nt]
            ans[nt] = b
            f(b, nt)
        return  0

    f(weights[0], 0)
    return ' '.join(map(str, ans))


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

from sys import stdin
from itertools import accumulate


def main():
    N = int(stdin.readline().rstrip())
    S = stdin.readline().rstrip()
    r_sum, g_sum, b_sum = [list(accumulate(1 if c == x else 0 for c in S)) for x in 'RGB']

    ans = 0
    sums = {'R': r_sum, 'G': g_sum, 'B': b_sum}
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            if S[i] == S[j]:
                continue
            other = 'RGB'.replace(S[i], '').replace(S[j], '')
            ans += sums[other][-1] - sums[other][j]
            k = j + (j - i)
            if k < N and S[k] == other:
                ans -= 1
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

from sys import stdin
from itertools import accumulate


def main():
    N = int(stdin.readline().rstrip())
    S = stdin.readline().rstrip()
    r_sum, g_sum, b_sum = [list(accumulate(1 if c == x else 0 for c in S)) for x in 'RGB']

    ans = 0
    sums = {'R': r_sum, 'G': g_sum, 'B': b_sum}
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            if S[i] == S[j]:
                continue
            other = 'RGB'.replace(S[i], '').replace(S[j], '')
            ans += sums[other][-1] - sums[other][j]
            k = j + (j - i)
            if k < N and S[k] == other:
                ans -= 1
    print(ans)


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

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())
num = 0

for a in range(K):
    for b in range(K):
        for c in range(K):
            num += gcd(a+1, b+1, c+1)

print(num)

### FIXED CODE ###

import math

K = int(input())
num = 0

for a in range(K):
    for b in range(K):
        ab = math.gcd(a+1, b+1)
        for c in range(K):
            num += math.gcd(ab, c+1)

print(num)
### BUGGY CODE ###

import math
import itertools
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

k = int(input())
l = list(itertools.product(range(k+1)[1:], repeat=3))
s = 0

for i in l:
    s += gcd(i[0], i[1], i[2])

print(s)

### FIXED CODE ###

import math
import itertools
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

k = int(input())
l = list(itertools.combinations_with_replacement(range(k+1)[1:], 3))
s = 0
n = 0

for i in l:
    x = len(set(i))
    if x == 3:
        n = 6
    elif x == 2:
        n = 3
    elif x == 1:
        n = 1

    s += gcd_list(list(i)) * n


print(s)
### BUGGY CODE ###

n = int(input())
a = []
for i in range(n):
    num = int(input())
    try:
        a.remove(num)
    except:
        a.append(num)
print(len(a))


### FIXED CODE ###

import collections
n = int(input())
a = [int(input()) for _ in range(n)]
result = 0
cnt = collections.Counter(a)
for i in cnt.values():
    if i % 2 == 1:
        result += 1

print(result)
### BUGGY CODE ###

N=int(input())
uvw=list(list(map(int,input().split())) for _ in range(N-1))

graph=[[0]*N for _ in range(N)]
for u,v,w in uvw:
    graph[u - 1][v - 1] = w
    graph[v - 1][u - 1] = w
colors=[2]*N
queue=[0]
colors[0]=0
while len(queue)>0:
    x=queue.pop(0)
    for j in range(N):
        if graph[x][j]!=0 and colors[j]==2:
            queue.append(j)
            if graph[x][j]%2==0:
                colors[j]=colors[x]
            else:
                colors[j]=0 if colors[x]==1 else 1
for p in colors:
    print(p)


### FIXED CODE ###

from collections import deque
N=int(input())
uvw=list(list(map(int,input().split())) for _ in range(N-1))

graph_list=[[] for _ in range(N)]
for u,v,w in uvw:
    graph_list[u - 1].append([v,w])
    graph_list[v - 1].append([u,w])

colors=[-1]*N
colors[0]=0
queue=deque([1])

while len(queue)>0:
    x=queue.popleft()
    if all(colors[i]!=-1 for i in range(N)):
        break
    for j in graph_list[x-1]:
        if colors[j[0]-1]==-1:
            queue.append(j[0])
            colors[j[0]-1]=(2+colors[x-1]+j[1])%2
for p in colors:
    print(p)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(1, n+1):
    ans.append(a.index(i)+1)
print(*ans)


### FIXED CODE ###

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

n = int(input())
dam = list(map(int,input().split()))
yama =[0]*n
sum_dam = sum(dam)
dam2 = dam[0]*2 +2
for kari in range(0,dam2,2):
  yama[0] = kari
  for i in range(1,n):
    yama[i] = (dam[i-1] - (yama[i-1] // 2))*2
    if yama[i] < 0:
      break
  if sum(yama) == sum_dam:
    joined = " ".join(map(str, yama))
    print(joined)
    break

### FIXED CODE ###

n = int(input())
dam = list(map(int,input().split()))
mountain =[0]*n
all_water = sum(dam)
def dam_water(num):
  sum_dam = 0
  for i in range(num,n,2):
    sum_dam += dam[i]
  return sum_dam

mountain[0] = all_water - 2 * (dam_water(1))

for i in range(1,n):
  mountain[i] = 2*dam[i-1] - mountain[i-1]

print(" ".join(map(str,mountain)))
### BUGGY CODE ###

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

answer = 0
mod = 1000000007
for i in range(N-1):
  for j in range(i+1, N):
    answer += A[i] * A[j]
    answer %= mod
print(int(answer))

### FIXED CODE ###

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

answer = 0
a_sum = sum(A)
mod = 10**9+7

for i in range(N-1):
  a_sum -= A[i]
  answer += a_sum * A[i]
print(str(answer % mod))
### BUGGY CODE ###

import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
M = 998244353


def main():
    N, K = map(int, readline().split())
    LR = list(list(map(int, readline().split())) for _ in range(K))
    LR.sort()
    dp = [0] *(N+1)
    dp[1] = 1
    for i in range(1, N + 1):
        for l,r in LR:
            for s in range(l,r+1):
                if i - s > 0:
                    dp[i] += dp[i - s]
                    dp[i] %= M
                else:
                    break
    print(dp[N])


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
M = 998244353


class SegTree:
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        res = self.ide_ele
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res


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


def main():
    N, K = map(int, readline().split())
    LR = list(list(map(int, readline().split())) for _ in range(K))
    LR.sort()

    A = [0] * (N + 1)
    A[1] = 1
    seg = SegTree(A, segfunc=segfunc, ide_ele=0)
    for i in range(2, N + 1):
        for l, r in LR:
            if i - l > 0:
                total = (seg.tree[i + seg.num] + seg.query(max(1, i - r), min(N, i - l + 1)) % M)
                seg.update(i, total)
            else:
                break
    print(seg.tree[seg.num + N] % M)


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

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

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

candidate = []
candidate.extend(A)

for j in range(M):
    b, c = map(int, input().split())
    
    if b > N:
        b = N

    if c >= min(candidate):
        candidate.extend([c] * b)
        
sorted_candidate = sorted(candidate, reverse=True)

print(sum(sorted_candidate[:N]))

### FIXED CODE ###

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

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

BC = []

for j in range(M):
    b, c = map(int, input().split())
    BC.append((b, c))
    
sorted_BC = sorted(BC, reverse=True, key=lambda item: item[1])

candidate = []
count = N
for bc in sorted_BC:
    b = bc[0]
    c = bc[1]
    if count >= 0:
        candidate.extend([c] * b)
        count = count - b
    else:
        break
    
candidate.extend(A)

print(sum(sorted(candidate, reverse=True)[:N]))
### BUGGY CODE ###

N,Q = map(int, input().split())
d = {}
score = [0 for _ in range(N)]

# 辞書の初期化
for i in range(1,N+1):
  d[i] = {i}

# 連結情報を取得する
for i in range(1,N):
  a,b = map(int,input().split())
  d[a].add(b)
  for i in range(1,N+1):
    if a in d[i]:
      d[i].add(b)
  
# スコア加算処理
for i in range(1,Q+1):
  p,x = map(int,input().split())
  for elm in d[p]:
    score[elm-1] += x
  
print(*score)

### FIXED CODE ###

from collections import deque
n,q=map(int, input().split())
l=[[] for i in range(n+1)]
ans=[0]*(n+1)

for i in range(n-1):
    a,b=[int(j) for j in input().split()]
    l[a].append(b)
    l[b].append(a)
for i in range(q):
    p,x=[int(j) for j in input().split()]
    ans[p]+=x

que=deque()
que.append(1)
ll=[0]*(n+1)
while que:
    y=que.popleft()
    ll[y]=1
    for i in l[y]:
        if ll[i]==1:
            continue
        ans[i]+=ans[y]
        que.append(i)
print(*ans[1:])
### BUGGY CODE ###

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

#y seppen wo motomeru

I=[A[i]-i-1 for i in range(N)]

m=min(I)
M=max(I)

opp=10**100
for i in range(m, M+1):
    #print(i)
    temp=sum([abs(val-i) for val in I])
    if temp<opp:
        opp=temp
print(opp)

### FIXED CODE ###

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

def func(b):
    return sum([abs(val - b) for val in I])

#y seppen wo motomeru

I=[A[i]-i-1 for i in range(N)]
I.sort()

if N % 2 ==1:
    print(func(I[N//2]))
else:
    print(func(I[N//2]))
### BUGGY CODE ###

import sys
from operator import itemgetter
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())
    ab_list = [tuple(map(int, input().split())) for _ in range(m)]
    deleted = [False for _ in range(n-1)]
    for ab in sorted(ab_list, key = itemgetter(1)):
        if True in deleted[ab[0]-1:ab[1]-1]:
            continue
        else:
            deleted[ab[1]-2] = True
    print(len([b for b in deleted if b is True]))

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
from operator import itemgetter
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())
    ab_list = [tuple(map(int, input().split())) for _ in range(m)]
    ab_list.sort(key = itemgetter(1))
    del_max = -10
    ans = 0
    for ab in ab_list:
        if ab[0] - 1 > del_max:
            ans += 1
            del_max = ab[1] - 2
    print(ans)

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

from collections import defaultdict
d = defaultdict(int)


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

for i in polls:
    d[i] += 1

max_k_list = sorted([kv[0] for kv in d.items() if kv[1] == max(d.values())])
# max_k_list.sort()

for ans in max_k_list:
    print(ans)

### FIXED CODE ###

import collections

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

c = collections.Counter(polls)
maxval = c.most_common()[0][1]

values, counts = zip(*c.most_common())

ans = []

for i in c.most_common():
    if i[1] == maxval:
        ans.append(i[0])
    else:
        break

ans.sort()

for i in ans:
    print(i)