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

import sys
from itertools import count, accumulate
from operator import mul
from functools import reduce
lines = sys.stdin.readlines()

positions = [int(i) for i in lines[1].split(' ')]

distances = [ j - i for i, j in zip(positions, positions[1:])]

n = len(distances)
factorials = [1] + list(accumulate(range(1,n + 1), mul))

combinations = dict()
def combination(i, j):
    j = min(j, i - j)
    if (i, j) in combinations:
        return combinations((i, j))
    else:
        return factorials[i] // (factorials [j] * factorials[i - j])

permutations = dict()
def permutation(i, j):
    if (i, j) in permutations:
        return permutations((i, j))
    else:
        return reduce(mul, range(j, i+1))

s = 0
result = 0
for d, i in zip(distances, count(1)):
    lt = i - 1
    gt = n - i
    t = factorials[n] // i
    s += t
    result += d * s

print(int(result % (pow(10,9) + 7)))

### FIXED CODE ###

import sys
from itertools import count, accumulate
from operator import mul
from functools import reduce
lines = sys.stdin.readlines()

positions = [int(i) for i in lines[1].split(' ')]

distances = [ j - i for i, j in zip(positions, positions[1:])]

n = len(distances)
p = pow(10,9) + 7

factorials = [1] + list(accumulate(range(1,n + 1), lambda x, y: (x * y) % p))

combinations = dict()
def combination(i, j):
    j = min(j, i - j)
    if (i, j) in combinations:
        return combinations((i, j))
    else:
        return factorials[i] // (factorials [j] * factorials[i - j])

permutations = dict()
def permutation(i, j):
    if (i, j) in permutations:
        return permutations((i, j))
    else:
        return reduce(mul, range(j, i+1))

def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n = n >> 1
    return res

s = 0
result = 0
for d, i in zip(distances, count(1)):
    lt = i - 1
    gt = n - i
    i_inv = modpow(i, p-2, p)
    t = factorials[n] * i_inv
    s += t
    result += d * s

print(int(result % (pow(10,9) + 7)))
### BUGGY CODE ###

s=input()
n=int(input())
k= [input().split() for i in range(n)]
for i in range(len(k)):
    if len(k[i])==1:
        s=s[::-1]
    else:
        if k[i][1]=="2":
            s=s+k[i][2]
        else:
            s=k[i][2]+s
print(s)

### FIXED CODE ###

S = input()
Q = int(input())
reverseCount = 0
pre = ""
pro = ""
for _ in range(Q):
    query = input()
    if len(query) == 1:
        reverseCount += 1
    else:
        _, F, C = query.split(" ")
        if (int(F) + reverseCount) % 2 == 1:
            pre = C + pre
        else:
            pro = pro + C
S = pre + S + pro
if reverseCount % 2 == 0:
    print(S)
else:
    print(S[::-1])
### BUGGY CODE ###

N,M = list(map(int, input().split()))
A = [0] * N
B = [0] * N

for i in range(N):
	A[i],B[i]=list(map(int, input().split()))

sum = 0
ans = 0
for i in range(N):
	idx = A.index(min(A))
	
	if(sum+B[idx] >= M):
		for i in range(B[idx]):
			ans += A[idx]
			sum += 1
			if(sum >= M):
				break
		break
	ans += A[idx]*B[idx]
	sum += B[idx]
	A[idx] = 10000000
print(ans)


### FIXED CODE ###

import numpy as np

N,M = list(map(int, input().split()))
A = [0] * N
B = [0] * N

for i in range(N):
	A[i],B[i]=list(map(int, input().split()))

sum = 0
ans = 0

idx = np.argsort(A)

for i in range(N):
	if(sum+B[idx[i]] >= M):
		for j in range(B[idx[i]]):
			ans += A[idx[i]]
			sum += 1
			if(sum >= M):
				break
		break
	ans += A[idx[i]]*B[idx[i]]
	sum += B[idx[i]]
print(ans)
### BUGGY CODE ###

from bisect import bisect_left,bisect_right
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
ans=0
for A in a:
    indexB=bisect_left(b,A+1)
    for B in b[indexB:]:
        indexC=bisect_left(c,B+1)
        for C in c[indexC:]:
            ans+=1
print(ans)


### FIXED CODE ###

from bisect import bisect_left,bisect_right
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
ans=0
for i in range(n):
    A=bisect_left(a,b[i])
    C=n-bisect_right(c,b[i])
    ans+=A*C
print(ans)
### BUGGY CODE ###

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

count = 0
for val in range(n):
    for i in range(b[val]):
        if a[val] > 0 and b[val] > 0:
            a[val] -= 1
            b[val] -= 1
            count +=1
            
        elif a[val+1] >0 and b[val] > 0:
            a[val + 1] -= 1
            b[val] -= 1
            count += 1

print(count)

### FIXED CODE ###

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

count = 0
for val in range(n):
    
    if a[val] >=  b[val]:
        count += b[val]
        a[val] = a[val] - b[val]
        b[val] = 0
        
    elif a[val] < b[val]:
        count += a[val]
        b[val] = b[val] - a[val]
        
        if a[val+1] >=  b[val]:
            count += b[val]
            a[val+1] = a[val+1] - b[val]
            b[val] = 0
            
        
        elif a[val+1] < b[val]:
            count += a[val + 1]
            a[val+1] = 0
        #print(count)
print(count)
### BUGGY CODE ###

#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
  return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

n,m,s,t = II()
u,v,a,b = Line(m)

from heapq import heappop, heappush
def dijkstra(E,s,n):
  inf=float('inf')
  visited=[False]*n
  d=[inf for _ in range(n)]
  d[s]=0
  q=[]
  heappush(q,(0,s))
  while q:
    du, u1 = heappop(q)
    if d[u1]<du: continue
    if not visited[u1]:
      visited[u1]=True
      for v1,weight in E.get(u1,[]):
        if not visited[v1]:
          alt=du+weight
          if d[v1]>alt:
            d[v1]=alt
            heappush(q, (alt,v1))
  return d

p = dict()
p2 = dict()
for i in range(m):
  p[u[i]-1]=p.get(u[i]-1,[])+[(v[i]-1,a[i])]
  p[v[i]-1]=p.get(v[i]-1,[])+[(u[i]-1,a[i])]
  p2[u[i]-1]=p2.get(u[i]-1,[])+[(v[i]-1,b[i])]
  p2[v[i]-1]=p2.get(v[i]-1,[])+[(u[i]-1,b[i])]

d = dijkstra(p,s-1,n)
d2 = dijkstra(p2,t-1,n)

ans = [d[n-1]+d2[n-1]]
for i in range(1,n):
  ans.append(min(ans[i-1],d[n-1-i]+d2[n-1-i]))

for i in range(n):
  print(10**15-ans[n-1-i])

### FIXED CODE ###

#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
  return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

n,m,s,t = II()
u,v,a,b = Line(m)

from heapq import heappop, heappush
def dijkstra(E,s,n):
  inf=float('inf')
  d=[inf for _ in range(n)]
  d[s]=0
  q=[]
  heappush(q,(0,s))
  while q:
    du, u1 = heappop(q)
    if d[u1]<du: continue
    for v1,weight in E[u1].items():
      alt=du+weight
      if d[v1]>alt:
        d[v1]=alt
        heappush(q, (alt,v1))
  return d

p = [dict() for _ in range(n)]
p2 = [dict() for _ in range(n)]
for i in range(m):
  p[u[i]-1][v[i]-1] = a[i]
  p[v[i]-1][u[i]-1] = a[i]
  p2[u[i]-1][v[i]-1] = b[i]
  p2[v[i]-1][u[i]-1] = b[i]

d = dijkstra(p,s-1,n)
d2 = dijkstra(p2,t-1,n)

ans = [0]*n
ans[0] = d[n-1]+d2[n-1]
for i in range(1,n):
  ans[i] = min(ans[i-1],d[n-1-i]+d2[n-1-i])

for i in ans[::-1]:
  print(10**15-i)
### BUGGY CODE ###

from collections import deque

N,M,K = map(int,input().split())
friend = [list(map(int,input().split())) for _ in range(M)]
block = [list(map(int,input().split())) for _ in range(K)]

g = [[False]*(N+1) for _ in range(N+1)]
for i in friend:
    g[i[0]][i[1]] = True
    g[i[1]][i[0]] = True


b = [[False]*(N+1) for _ in range(N+1)]
for i in block:
    b[i[0]][i[1]] = True
    b[i[1]][i[0]] = True
    

stack=deque()

ans = []
for i in range(1,N+1):
    cnt = 0
    visited = [0] * (N+1)
    visited[i] = 1 
    stack.append(i)
    while stack:
        n = stack.pop()
        for j in range(1,N+1):
            if g[n][j] and visited[j]==0:
                stack.append(j)
                visited[j] = 1
                if g[i][j] == False and b[i][j]==False:
                    cnt+=1
    ans.append(cnt)
print(*ans)
    

### FIXED CODE ###

from collections import deque

N,M,K = map(int,input().split())
friend = [list(map(int,input().split())) for _ in range(M)]
block = [list(map(int,input().split())) for _ in range(K)]

f = [set() for _ in range(N+1)]
b = [set() for _ in range(N+1)]

for i,j in friend:
    f[i].add(j)
    f[j].add(i)
for i,j in block:
    b[i].add(j)
    b[j].add(i)

stack=deque()
linkList = []
ans = [0] *(N+1)
visited = [0] * (N+1)

for i in range(1,N+1):
    if visited[i]:
        continue
    link = {i}
    visited[i] = 1 
    stack.append(i)
    while stack:
        n = stack.pop()
        for j in f[n]:
            if j in f[n] and visited[j]==0:
                stack.append(j)
                visited[j] = 1
                link.add(j)
    linkList.append(link)
    for i in link:
        ans[i] = len(link) - len(link & f[i]) - len(link & b[i]) - 1
print(*ans[1:])
### BUGGY CODE ###

N,K,Q = map(int, input().split())
A = []
for a in range(Q):
	A.append(int(input()))


for i in range(1,N+1):
    judge = ((K-Q) + (A.count(i)))
    if judge > 0 :
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

N,K,Q = map(int, input().split())
A = []
for a in range(Q):
	A.append(int(input()))


P = [K-Q] * N
for i in range(Q):
    P[A[i]-1] += 1
for i in range(N):
    if P[i] <= 0:
        print("No")
    else:
        print("Yes")
### BUGGY CODE ###

import sys
sys.setrecursionlimit(100000)
from collections import defaultdict
edges = []
to = defaultdict(list) # 1から到達できるか
ot = defaultdict(list) # Nから到達できるか
N, M, P = map(int, input().split())
visited_toN = [False]*(N+1)
visited_fm1 = [False]*(N+1)    
for i in range(M):
    a,b,c = map(int, input().split())
    a -= 1
    b -= 1
    edges.append((a,b,-c+P))
    to[a].append(b)
    ot[b].append(a)

def dfs(v):
    global visited_fm1
    if visited_fm1[v]:return
    visited_fm1[v] = True
    for nxt in to[v]:
        dfs(nxt)
    
def dfs_r(v):
    global visited_toN
    if visited_toN[v]:return
    visited_toN[v] = True
    for nxt in ot[v]:
        dfs_r(nxt)
        
dfs(0)
dfs_r(N-1)
is_ok = []

for s, t in zip(visited_fm1,visited_toN):
    is_ok.append(s and t)


# BellmanFord    
INF = 10 ** 18
def bellmanFord(n, edges, s, g):
    """
    input
        n : 頂点の数
        edges : (始点, 終点, コスト)のリスト
        s : 探索の始点
        g : 探索の終点
    output
        sから各点への最短距離
    """    
    d = [INF] * n
    d[s] = 0
    cnt = 0
    while True:
        update = False
        for a, b, c in edges:
            if not is_ok[a]:continue
            if not is_ok[b]:continue
            if d[a] != INF and d[b] > d[a] + c:
                d[b] = d[a] + c
                update = True
        if not update:
            break
        cnt += 1
        # 負閉路の存在をチェック
        if cnt > n:
            print(-1)
            exit()
        # print(d,cnt)
    return d[g]



ans = bellmanFord(N,edges,0,N-1)
print(max(0,-ans))


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)
from collections import defaultdict
edges = []
to = defaultdict(list) # 1から到達できるか
ot = defaultdict(list) # Nから到達できるか
N, M, P = map(int, input().split())
visited_toN = [False]*(N+1)
visited_fm1 = [False]*(N+1)    
for i in range(M):
    a,b,c = map(int, input().split())
    a -= 1
    b -= 1
    edges.append((a,b,-c+P))
    to[a].append(b)
    ot[b].append(a)

def dfs(v):
    global visited_fm1
    if visited_fm1[v]:return
    visited_fm1[v] = True
    for nxt in to[v]:
        dfs(nxt)
    
def dfs_r(v):
    global visited_toN
    if visited_toN[v]:return
    visited_toN[v] = True
    for nxt in ot[v]:
        dfs_r(nxt)
        
dfs(0)
dfs_r(N-1)
is_ok = []

for s, t in zip(visited_fm1,visited_toN):
    is_ok.append(s and t)


# BellmanFord    
INF = 10 ** 18
def bellmanFord(n, edges, s, g):
    """
    input
        n : 頂点の数
        edges : (始点, 終点, コスト)のリスト
        s : 探索の始点
        g : 探索の終点
    output
        sから各点への最短距離
    """    
    d = [INF] * n
    d[s] = 0
    cnt = 0
    while True:
        update = False
        for a, b, c in edges:
            if not is_ok[a]:continue
            if not is_ok[b]:continue
            if d[a] != INF and d[b] > d[a] + c:
                d[b] = d[a] + c
                update = True
        if not update:
            break
        cnt += 1
        # 負閉路の存在をチェック
        if cnt > n:
            print(-1)
            exit()
        # print(d,cnt)
    return d[g]



ans = bellmanFord(N,edges,0,N-1)
print(max(0,-ans))
### BUGGY CODE ###

#-*-coding:utf-8-*-

def main():
    k,s = map(int,input().split())
    counter=0

    for x in range(k+1):
        for y in range(k+1):
            for z in range(k+1):
                if x+y+z==s:
                    counter+=1
    print(counter)


if __name__=="__main__":
    main()

### FIXED CODE ###

#-*-coding:utf-8-*-

def main2():
    k,s = map(int,input().split())
    counter=0
    for x in range(k+1):
        for y in range(k+1):
            if 0<=s-x-y <=k:
                counter+=1
    print(counter)

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

import itertools
N, K = map(int, input().split())
x = list(map(int, input().split()))
ans = 10 ** 8 * K
for v in itertools.combinations(x, K):
  a = abs(v[0]) + abs(v[-1] - v[0])
  b = abs(v[-1]) + abs(v[-1] - v[0])
  if min(a, b) < ans:
    ans = min(a, b)
print(ans)

### FIXED CODE ###

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

ans = float('inf')
for i in range(n-k+1):
    l, r = X[i], X[i+k-1]
    if r <= 0:
        ans = min(abs(l), ans)
    elif 0 <= l:
        ans = min(abs(r), ans)
    else:
        dist = min(abs(l), abs(r))*2+max(abs(l), abs(r))
        ans = min(dist, ans)
print(ans)
### BUGGY CODE ###

n = int(input())
xy = [[i] + list(map(int,input().split())) for i in range(n)]

xy.sort(key=lambda x:x[1])
edge  = []
for i in range(n-1):
    i1,x1,y1 = xy[i]
    i2,x2,y2 = xy[i+1]
    edge.append((x2-x1,i1,i2))

xy.sort(key=lambda x:x[2])
for i in range(n-1):
    i1,x1,y1 = xy[i]
    i2,x2,y2 = xy[i+1]
    edge.append((y2-y1,i1,i2))
class UnionFind():
    def __init__(self, N):
        self.rank = [0] * N
        self.par = [i for i in range(N)]
        self.counter = [1] * N

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            z = self.counter[x] + self.counter[y]
            self.counter[x], self.counter[y] = z, z
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def size(self, x):
        x = self.find(x)
        return self.counter[x]

    def same(self, x, y):
        return self.find(x) == self.find(y)

#クラスカル法
uf = UnionFind(n)
edge.sort()
ans = 0
edge_cnt = 0
i = 0
while edge_cnt < n-1:
    cost,i1,i2 = edge[i]
    if not uf.same(i1,i2):
        ans += cost
        uf.unite(i1,i2)
        edge_cnt += 1
    i += 1
print(ans)


### FIXED CODE ###

n = int(input())
xy = [[i] + list(map(int,input().split())) for i in range(n)]

xy.sort(key=lambda x:x[1])
edge  = []
for i in range(n-1):
    i1,x1,y1 = xy[i]
    i2,x2,y2 = xy[i+1]
    edge.append((x2-x1,i1,i2))

xy.sort(key=lambda x:x[2])
for i in range(n-1):
    i1,x1,y1 = xy[i]
    i2,x2,y2 = xy[i+1]
    edge.append((y2-y1,i1,i2))
class UnionFind():
    def __init__(self, N):
        self.rank = [0] * N
        self.par = [i for i in range(N)]
        self.counter = [1] * N

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            z = self.counter[x] + self.counter[y]
            self.counter[x], self.counter[y] = z, z
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def size(self, x):
        x = self.find(x)
        return self.counter[x]

    def same(self, x, y):
        return self.find(x) == self.find(y)

#クラスカル法
uf = UnionFind(n)
edge.sort()
ans = 0
edge_cnt = 0
i = 0
while edge_cnt < n-1:
    cost,i1,i2 = edge[i]
    if not uf.same(i1,i2):
        ans += cost
        uf.unite(i1,i2)
        edge_cnt += 1
    i += 1
print(ans)
### BUGGY CODE ###

n=int(input())
l=list(map(int, input().split()))
ans=[l[0]]
for i in range(1, n):
  if i%2==1:
    ans.append(l[i])
  else:
    ans.insert(0, l[i])
if n%2==0:
  ans.reverse()
  print(*ans)
else:
  print(*ans)

### FIXED CODE ###

n=int(input())
l=list(map(int, input().split()))
if n%2==0:
  for i in range(n-1, 0, -2):
    print(str(l[i]), end=' ')
  for i in range(0, n, 2):
    print(str(l[i]), end=' ')
else:
  for i in range(n-1, -1, -2):
    print(str(l[i]), end=' ')
  for i in range(1, n, 2):
    print(str(l[i]), end=' ')
### BUGGY CODE ###

import fractions
import itertools
from functools import reduce

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

def dv(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
    
A,B = map(int,input().split())
Cd = list(set(dv(A))&set(dv(B)))
N = len(Cd)
ans = 0
for bit in range(1<<N):
    d = []
    for i in range(N):
        if (bit>>i)&1 == 1:
            d.append(Cd[i])
    if not d:
        continue
    Flag = 1
    for i in itertools.combinations(d, 2):
        if gcd_list(i) != 1:
            Flag = 0
            break
    if Flag == 1:
        ans = max(ans,len(d))
print(ans)

### FIXED CODE ###

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
import fractions
A,B = map(int,input().split())
ans = factorization(fractions.gcd(A,B))
if ans[0][0] == 1:
    print(len(ans))
else:
    print(len(ans)+1)
### BUGGY CODE ###

def main():
    mod = 998244353
    a, b, c, d = map(int, input().split())
    dp = [[0]*(d+1) for _ in [0]*(c+1)]
    dp[a][b] = 1
    for i in range(a+b+1, c+d+1):
        for p in range(c, a-1, -1):
            q = i-p
            if q > d:
                break
            if q < 0:
                continue
            dp[p][q] = (q*dp[p-1][q]+p*dp[p][q-1] -
                        (p-1)*(q-1)*dp[p-1][q-1]) % mod
    print(dp[c][d])


main()


### FIXED CODE ###

def main():
    mod = 998244353
    a, b, c, d = map(int, input().split())
    dp = [[0]*(d+1) for _ in [0]*(c+1)]
    dp[a][b] = 1
    for i in range(a+b+1, c+d+1):
        for p in range(c, a-1, -1):
            q = i-p
            if q > d:
                break
            if q < 0:
                continue
            dp[p][q] = (q*dp[p-1][q]+p*dp[p][q-1] -
                        (p-1)*(q-1)*dp[p-1][q-1]) % mod
    print(dp[c][d])


main()
### BUGGY CODE ###

import math
h, n = input().split()
h = int(h)
n = int(n)
attack = list(map(int, input().split()))
while  n > 0:
    m_attack = max(attack)
    if h - m_attack <= 0:
        h = h-m_attack
        print("Yes")
        break
    else:   
        h = h - m_attack
        attack.remove(m_attack)
        n = n-1
if h > 0:
    print("No")

### FIXED CODE ###

h, n = input().split()
h = int(h)
n = int(n)
attack = sorted(list(map(int, input().split())), reverse=True)
while  n > 0:
    m_attack = attack[0]
    if h - m_attack <= 0:
        h = h - m_attack
        print("Yes")
        break
    else:   
        h = h - m_attack
        attack.remove(m_attack)
        n = n-1
if h > 0:
    print("No")
### BUGGY CODE ###

# - coding : utf-8 -*-

def digit2bin(num1, num2):
    bin1 = bin(num1).split('0b')[1]
    bin2 = bin(num2).split('0b')[1]
    if len(bin1) > len(bin2):
        bin2 = bin2.zfill(len(bin1))
    else:
        bin1 = bin1.zfill(len(bin2))
    return bin1, bin2

def xor(num1, num2):
    bin1, bin2 = digit2bin(num1, num2)
    res_bin = ""
    for b1, b2 in zip(bin1, bin2):
        tmp = abs(int(b1) - int(b2))
        res_bin += str(tmp)
    return int(res_bin, 2)

def func_f(x, an):
    res = 0
    for a in an:
        res += xor(x, int(a))
    return res

if __name__ == "__main__":
    n, k = input().split()
    an = input().split()

    results = []
    for x in range(0, int(k)+1):
        results.append(func_f(x, an))
    print(max(results))
    

    




### FIXED CODE ###

# - coding : utf-8 -*-

if __name__ == "__main__":

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

    p = [1] * 41
    for i in range(40):
        p[i+1] = p[i] * 2
        
    ans = 0
    x = 0
    for i in range(41):
        t = p[40-i]
        if x + t > k:
            cnt = 0
            for j in range(n):
                if an[j] & t == t:
                    cnt += 1
            ans += cnt * t
        else:
            cnt = 0
            for j in range(n):
                if an[j] & t == t:
                    cnt += 1
            if cnt <= n/2:
                x += t
            ans += max(cnt, n-cnt) * t
    print(ans)
### BUGGY CODE ###

L,R=map(int,input().split())
ans=2019
for i in range(L,R):
	if i==2019:
		print(0)
		exit()
	for j in range(i+1, R+1):
		if j==2019:
			print(0)
			exit()
		ans=min(ans,(i*j)%2019)
print(ans)

### FIXED CODE ###

L,R=map(int,input().split())
ans=2019
for i in range(L,R):
	for j in range(i+1, R+1):
		if j%2019==0:
			print(0)
			exit()
		ans=min(ans,(i*j)%2019)
print(ans)
### BUGGY CODE ###

#!usr/bin/env python3


import sys


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


def solve():
    n = I()
    sli = [input() for i in range(n)]
    setli = set(sli)
    rank = {}
    for i in setli:
        j = sli.count(i)
        rank[i] = j
    ans = [k for k, v in rank.items() if v == max(rank.values())]
    ans.sort()
    for i in ans:
        print(i)


# Solve
if __name__ == "__main__":
    solve()


### FIXED CODE ###

#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


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


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n = I()
    sli = [input() for i in range(n)]
    rank = defaultdict(lambda: 0)
    for i in sli:
        rank[i] += 1
    rank = list(rank.items())
    rank.sort(key=lambda x: (-x[1], x[0]))
    for i, j in rank:
        if j == rank[0][1]:
            print(i)


# Solve
if __name__ == "__main__":
    solve()