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

import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
a.reverse()
mod = 7 + 10**9
leng = 60
data = [[0 for i in range(leng+1)] for j in range(n)]
#pre
for i in range(n):
    k = list(bin(a[i]))
    k.reverse()
    ll = len(k)
    for j in range(1, leng+1):
        temp = data[i - 1][j]
        if j - 1 >= ll:
            data[i][j] = temp
            continue
        if k[j - 1] == "1":
            data[i][j] = temp + 1
        else:
            data[i][j] = temp
ans = 0
a.reverse()
data.reverse()
for i in range(n-1):
    k = format(a[i], 'b')
    k = list(k)
    k.reverse()
    for s in range(leng - len(k)):
        k.append(0)
    for j in range(leng):
        if k[j] == "1":
            ans += ((n - i - 1) - data[i+1][j+1]) * (2**j)
            ans %= mod
        else:
            ans += data[i+1][j+1] * (2**j)
            ans %= mod
print(ans)


### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline
    n = int(input())
    a = list(map(int, input().split()))
    a.reverse()
    mod = 7 + 10**9
    leng = len(format(max(a), 'b'))
    bit_acc = [0 for i in range(leng)]
    for i in range(n):
        #先頭から二進数を0埋めした
        bit_data = format(a[i], 'b').zfill(leng)
        for j in range(leng):
            if bit_data[j] == '1':
                bit_acc[j] += 1
    ans = 0
    p = [pow(2,leng - 1 - j, mod) for j in range(leng)]
    for i in range(n):
        bit_data = format(a[i], 'b').zfill(leng)
        for j in range(leng):
            if bit_data[j] == '1':
                ans += (n - bit_acc[j]) * p[j]
            else:
                ans += bit_acc[j] * p[j]
            ans %= mod
    print((ans * 500000004) % mod)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
dp = [0] * (n + 1)
mod = 10 ** 9 + 7

dp[0] = 1
if not 1 in a:
    dp[1] = 1
for i in range(1, n):
    if i + 1 in a:
        dp[i + 1] = 0
    else:
        dp[i + 1] = (dp[i] + dp[i - 1]) % mod
print(dp[n])

### FIXED CODE ###

n, m = map(int, input().split())
dp = [0] * (n + 1)
a = []
for i in range(m):
    aa = int(input())
    dp[aa] = -1
    a.append(aa)
for i in range(m - 1):
    if a[i] + 1 == a[i + 1]:
        print(0)
        exit()
mod = 10 ** 9 + 7

dp[0] = 1
if 1 in a:
    dp[1] = 0
else:
    dp[1] = 1
for i in range(1, n):
    if dp[i + 1] == -1:
        dp[i + 1] = 0
    else:
        dp[i + 1] = (dp[i] + dp[i - 1]) % mod
print(dp[n])
### BUGGY CODE ###

import copy
from statistics import median

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

y = copy.deepcopy(x)
for a in x:
    y.remove(a)
    print(median(y))
    y.append(a)

### FIXED CODE ###

import copy

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

if n == 2:
    print(x[1])
    print(x[0])
    exit()

y = copy.deepcopy(x)
y.sort()
mid_s = y[n // 2 - 1]
mid_l = y[n // 2]
for a in x:
    if a < mid_l:
        print(mid_l)
    else:
        print(mid_s)
### BUGGY CODE ###

n=int(input())
arr=[0]+[list(map(int,input().split())) for _ in range(n)]
pos=[0]*(n+1)
ans=0
while 1:
  flag=False
  cnt=0
  check=[0]*(n+1)
  for i in range(1,n+1):
    if check[i]==1:
      continue
    if pos[i]==n-1:
      cnt+=1
      continue
    pair=arr[i][pos[i]]
    if check[pair]==1:
      continue
    if arr[pair][pos[pair]]==i:
      flag=True
      pos[i]+=1
      pos[pair]+=1
      check[i]=1
      check[pair]=1
  if cnt==n:
    print(ans)
    break
  if flag==False:
    print(-1)
    break
  ans+=1

### FIXED CODE ###

import collections

n=int(input())
arr=[list(map(int,input().split())) for _ in range(n)]
arr=[0]+[collections.deque(arr[i]) for i in range(n)]
ans=0
cand=set(range(1,n+1))
while 1:
  check=set()
  for i in cand:
    if not arr[i]:
      continue
    pair=arr[i][0]
    if arr[pair][0]==i:
      check.add(i)
      check.add(pair)
  if not check:
    break
  cand=set()
  for i in check:
    cand.add(i)
    arr[i].popleft()
    if arr[i]:
      cand.add(arr[i][0])
  ans+=1
for i in range(1,n+1):
  if arr[i]:
    print(-1)
    break
else:
  print(ans)
### BUGGY CODE ###

import numpy as np
N = int(input())
A = np.array([int(input()) for i in range(N)])
ans = np.zeros(N, dtype=int)

ans[0] = A[1:].max()
ans[N-1] = A[:-1].max()

for i in range(1, N-1):
    left = A[:i].max()
    right = A[i+1:].max()
    ans[i] = max(left, right)

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

### FIXED CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
ans = [0]*N

first = sorted(A)[-1]
second = sorted(A)[-2]

for i in range(N):
    if A[i]==first:
        ans[i] = second
    else:
        ans[i] = first

print(*ans, sep="\n")
### BUGGY CODE ###

from collections import deque
import sys
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())
    L = [[0] for _ in range(n)]
    for _ in [0] * m:
        a, b = map(int, input().split())
        L[a-1].append(b-1)
        L[b-1].append(a-1)
    L[0][0] = 1
    d = [0] * n
    ans = [0] * n
    dq = deque([0])
    while len(dq) > 0:
        t = dq.popleft()
        for i in range(1, len(L[t])):
            dti = d[L[t][i]]
            if dti == 0 or dti > d[t] + 1:
                d[L[t][i]] = d[t] + 1
                ans[L[t][i]] = t + 1
            if L[L[t][i]][0] == 0:
                dq.append(L[t][i])
        else:
            L[t][0] = 1
    print('Yes')
    print(*ans[1:], sep='\n')

main()


### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())
    L = [[0] for _ in range(n)]
    for _ in [0] * m:
        a, b = map(int, input().split())
        L[a-1].append(b-1)
        L[b-1].append(a-1)
    L[0][0] = 1
    ans = [0] * n
    dq = deque([0])
    while dq:
        t = dq.popleft()
        for i in range(1, len(L[t])):
            next = L[t][i]
            if ans[next] != 0:
                continue
            ans[next] = t + 1
            dq.append(next)
        else:
            L[t][0] = 1
    print('Yes')
    print(*ans[1:], sep='\n')

main()
### BUGGY CODE ###

n = int(input())
A = list(map(int, input().split()))
from collections import Counter
C = Counter(A)
for i in range(n):
	count = 0
	for k, v in C.items():
		if k == A[i]:
			v -= 1
		count += v * (v - 1) // 2
	print(count)

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
from collections import Counter
C = Counter(A)
count = 0
for v in C.values():
	count += v * (v - 1) // 2
for a in A:
	x = C[a]
	print(count - (x * (x - 1) // 2) + ((x - 1) * (x - 2) // 2))
### BUGGY CODE ###

N = int(input())
g = {i: [] for i in range(1, N+1)}    

l = [0] * (N + 1)

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

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

stack = [K]
visited = []
while len(stack):
    v = stack.pop()
    visited.append(v)
    for c,ln in g[v]:
        if c in visited:
            continue
        l[c] = l[v] + ln
        stack.append(c)

for q in range(Q):
    x, y = map(int,input().split())
    print(l[x] + l[y])

### FIXED CODE ###

N = int(input())
g = {i: [] for i in range(1, N+1)}    

l = [0] * (N + 1)

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

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

stack = [K]

while len(stack):
    v = stack.pop()
    for c,ln in g[v]:
        if l[c] != 0:
            continue
        l[c] = l[v] + ln
        stack.append(c)

for q in range(Q):
    x, y = map(int,input().split())
    print(l[x] + l[y])
### BUGGY CODE ###

l = [0] * ( 10 ** 5 + 1 )
N = int(input())
A = list(map(int, input().split()))
for i in range(len(A)):
  l[A[i]] += 1
Q = int(input())
for i in range(Q):
  B, C = map(int, input().split())
  l[C] += l[B]
  l[B] = 0
  sum=0
  for i in range(len(l)):
    sum += i * l[i]
  print(sum)

### FIXED CODE ###

s=set()
l = [0] * ( 10 ** 5 + 1 )
sum=0
N = int(input())
A = list(map(int, input().split()))
for i in range(len(A)):
    l[A[i]] += 1
    s.add(A[i])
    sum += A[i]
Q = int(input())
for i in range(Q):
    B, C = map(int, input().split())
    if l[B] > 0:
        s.add(C)
        sum = sum + l[B] * ( C - B )
        l[C] += l[B]
        l[B] = 0
        s.discard(B)
    print(sum)
### BUGGY CODE ###

import heapq
 
N, M = [int(s) for s in input().split()]
A = [int(s) for s in input().split()]
 
hpq = list(map(lambda x: -1 * x, A))
for i in range(M):
    heapq.heapify(hpq)
    x = heapq.heappop(hpq)
    heapq.heappush(hpq, x / 2)

print(sum(map(lambda x: int(-1 * x), hpq)))

### FIXED CODE ###

import heapq
 
N, M = [int(s) for s in input().split()]
A = [int(s) for s in input().split()]
 
hpq = list(map(lambda x: -1 * x, A))
heapq.heapify(hpq)
for i in range(M):
    x = heapq.heappop(hpq)
    heapq.heappush(hpq, x / 2)

print(sum(map(lambda x: int(-1 * x), hpq)))
### BUGGY CODE ###

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
aa = [0]
for i in a:
    aa.append(aa[-1]+i)
bb = [0]
for i in b:
    bb.append(bb[-1]+i)
ans = 0
for i in range(n+1):
    if aa[i] > k:
        break
    for j in range(m+1):
        if aa[i]+bb[j] <= k:
            tmp = i+j
        else:
            break
    ans = max(ans, tmp)
print(ans)

### FIXED CODE ###

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
aa = [0]
for i in a:
    aa.append(aa[-1]+i)
bb = [0]
for i in b:
    bb.append(bb[-1]+i)
ans = 0
j = m
for i in range(n+1):
    if aa[i] > k:
        break
    while aa[i] + bb[j] > k and j > 0:
        j -= 1
    ans = max(ans, i+j)
print(ans)
### BUGGY CODE ###

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

M = 10**9 + 7

for n in range(N):
    A[n] = A[n] % M

ans = 0

for i in range(N-1):
    for n in range(i + 1, N):
        ans += A[i] * A[n]
        ans = ans % M

print(ans)

### FIXED CODE ###

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

M = 10**9 + 7

Total = sum(A) -A[0]

ans = 0

for i in range(N-1):
    ans += A[i] * Total
    ans = ans % M
    Total -= A[i+1]

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

S = input()
Q = int(input())

reverse = False
cnt = 0
for i in range(Q):
    inp = input().split()
    if inp[0] == "1":
        cnt += 1
        reverse = (cnt % 2 != 0)
        #S = S[::-1]
    else:
        f, c = inp[1:]
        if int(f) == 1:
            if reverse:
                S = S + c
            else:
                S = c + S
        else:
            if reverse:
                S = c + S
            else:
                S = S + c
print(S[::-1] if reverse else S)

### FIXED CODE ###

from collections import deque

S = deque(input())
Q = int(input())

reverse = False
cnt = 0
for i in range(Q):
    inp = input().split()
    if inp[0] == "1":
        cnt += 1
        reverse = (cnt % 2 != 0)
        #S = S[::-1]
    else:
        f, c = inp[1:]
        if int(f) == 1:
            if reverse:
                S.append(c)
            else:
                S.appendleft(c)
        else:
            if reverse:
                S.appendleft(c)
            else:
                S.append(c)
S = "".join(S)
print(S[::-1] if reverse else S)
### BUGGY CODE ###

n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
bc = [list(map(int, input().split())) for _ in range(m)]

for i in range(m):
    listnum=bc[i][0]
    tplist=[bc[i][1]]
    templist=tplist*listnum
    a.extend(templist)
a=sorted(a,reverse=True)
print(sum(a[:n]))


### FIXED CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
bc=[list(map(int, input().split())) for _ in range(m)]

sorted_ab=sorted(bc, reverse=True, key=lambda x: x[1])
new_ab=[]
ans=[]

for i in range(m):
    if len(new_ab)<=n:
        tmp_l=[sorted_ab[i][1]]*sorted_ab[i][0]
        new_ab+=tmp_l
    else:
        break

final_list=a+new_ab
final_list.sort(reverse=True)

print(sum(final_list[:n]))
### BUGGY CODE ###

import sys
input = sys.stdin.buffer.readline

H, W, M = map(int, input().split())

bomb_h = [0] * H
bomb_w = [0] * W
grid = [[False] * W for _ in range(H)]

max_h = 0
max_w = 0
h_indices = []
w_indices = []

for i in range(M):
    h, w = map(int, input().split())
    bomb_h[h-1] += 1
    bomb_w[w-1] += 1
    if bomb_h[h-1] == max_h:
        h_indices.append(h-1)
    elif bomb_h[h-1] > max_h:
        h_indices = [h-1]
        max_h = bomb_h[h-1]

    if bomb_w[w-1] == max_w:
        w_indices.append(w-1)
    elif bomb_w[w-1] > max_w:
        w_indices = [w-1]
        max_w = bomb_w[w-1]

    grid[h-1][w-1] = True

ans = max_w + max_h - 1
for h in h_indices:
    for w in w_indices:
        if not grid[h][w]:
            ans += 1
            print(ans)
            exit()

if ans == -1:
    ans = 0

print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

H, W, M = map(int, input().split())

bomb_h = [0] * H
bomb_w = [0] * W
bomb = set()
for i in range(M):
    h, w = map(int, input().split())
    bomb_h[h-1] += 1
    bomb_w[w-1] += 1
    bomb.add((h-1, w-1))

max_h = max(bomb_h)
max_w = max(bomb_w)

h_indices = []
for i in range(H):
    if bomb_h[i] == max_h:
        h_indices.append(i)

w_indices = []
for i in range(W):
    if bomb_w[i] == max_w:
        w_indices.append(i)

ans = max_w + max_h - 1
for h in h_indices:
    for w in w_indices:
        if (h, w) not in bomb:
            ans += 1
            print(ans)
            exit()

if ans == -1:
    ans = 0

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

import sys

M = 1046527
def h1(key):
    return key % M

def h2(key):
    return 1 + (key %(M-1))

def h3(key, i):
    return (h1(key) + i*h2(key)) % M

word_dic = {'A': 1, 'T': 2, 'G': 3, 'C': 4}
def getkey(text):
    sum = 0
    p = 1
    for c in text:
        sum += p*word_dic[c]
        p *= 5
    return sum

dict = {}
def find(text):
    global dict
    key = getkey(text)
    i = 0
    while i < M:
        h = h3(key, i)
        if dict.get(h) == None:
            break
        elif dict[h] == text:
            return True
        i += 1
    return False

def insert(text):
    global dict
    key = getkey(text)
    i = 0
    while i < M:
        j = h3(key, i)
        if dict.get(j) == None:
            dict[j] = text
            break
        else:
            i += 1

n = int(input())
operations = sys.stdin.readlines()
for ope in operations:
    op, text = ope.rstrip().split(' ')
    if op == 'insert':
        insert(text)
    elif op == 'find':
        rst = find(text)
        if rst:
            print('yes')
        else:
            print('no')


### FIXED CODE ###

import sys

M = 1046527
def h1(key):
    return key % M

def h2(key):
    return 1 + (key %(M-1))

def h3(key, i):
    return (h1(key) + i*h2(key)) % M

word_dic = {'A': 1, 'T': 2, 'G': 3, 'C': 4}
def getkey(text):
    sum = 0
    p = 1
    for c in text:
        sum += p*word_dic[c]
        p *= 5
    return sum

dict = [None for i in range(M)]
def find(text):
    key = getkey(text)
    i = 0
    while i < M:
        h = h3(key, i)
        if dict[h] == None:
            break
        elif dict[h] == text:
            return True
        i += 1
    return False

def insert(text):

    key = getkey(text)
    i = 0
    while i < M:
        j = h3(key, i)
        if dict[j] == None:
            dict[j] = text
            break
        else:
            i += 1

n = int(input())
operations = sys.stdin.readlines()
for ope in operations:
    op, text = ope.rstrip().split(' ')
    if op == 'insert':
        insert(text)
    elif op == 'find':
        rst = find(text)
        if rst:
            print('yes')
        else:
            print('no')
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)
n,x,y = map(int,input().split())
g = [[]for i in range(n)]
g[0].append(1)
g[n-1].append(n-2)
g[x-1].append(y-1)
g[y-1].append(x-1)
for i in range(1,n-1):
  g[i].append(i-1)
  g[i].append(i+1)
ans = [0]*(n-1)
def dfs(b,c):
  for i in g[b]:
    if a[i] > c+1:
      a[i] = c+1
      dfs(i,c+1)
    
for i in range(n):
  a = [999999999]*n
  a[i] = 0
  dfs(i,0)
  for j in a:
    if j == 0:
      continue
    ans[j-1] += 1
for i in ans:
  print(i//2)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
from collections import deque
n,x,y = map(int,input().split())
g = [[]for i in range(n)]
g[0].append(1)
g[n-1].append(n-2)
g[x-1].append(y-1)
g[y-1].append(x-1)
for i in range(1,n-1):
  g[i].append(i-1)
  g[i].append(i+1)
ans = [0]*(n-1)
def dfs(b,c):
  for i in g[b]:
    if a[i] > c+1:
      a[i] = c+1
      que.append([i,c+1])
    
for i in range(n):
  a = [999999999]*n
  a[i] = 0
  que = deque()
  que.append([i,0])
  while que:
    x,y = que.popleft()
    dfs(x,y)
  for j in a:
    if j == 0:
      continue
    ans[j-1] += 1
for i in ans:
  print(i//2)
### BUGGY CODE ###

N,M=map(int,input().split())
box=[[] for i in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    box[a-1].append(b-1)
    box[b-1].append(a-1)
ans=[None]*(N)
ans[0]=0
que=[0]
while len(que)>0:
    index=que.pop(0)
    for x in box[index]:
        if ans[x]==None:
            ans[x]=index+1
            que.append(x)
print("Yes")
for i in range(1,N):
    print(ans[i])


### FIXED CODE ###

N,M=map(int,input().split())
box=[[] for i in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    box[a-1].append(b-1)
    box[b-1].append(a-1)
ans=[None]*(N)
ans[0]=0
que=[0]
while len(que)>0:
    index=que.pop(0)
    for x in box[index]:
        if ans[x]==None:
            ans[x]=index+1
            que.append(x)
print("Yes")
for i in range(1,N):
    print(ans[i])
### BUGGY CODE ###

from collections import deque

def pr(A,n):
    for i in range(n):
        if i!=n-1:
            print(A[i],end=" ")
        else:
            print(A[i])

n=int(input())
que_r=deque()

for i in range(n):
    s=input().split()

    if s[0]=="insert":
        que_r.appendleft(int(s[1]))
    elif s[0]=="delete":
        try:
            que_r.remove(int(s[1]))
        except ValueError: pass
    elif s[0]=="deleteFirst":
        gav=que_r.popleft()
    elif s[0]=="deleteLast":
        gav=que_r.pop()

pr(que_r,len(que_r))


### FIXED CODE ###

from collections import deque


n=int(input())
que_r=deque()

for i in range(n):
    s=input()
    l=len(s)
    if s[0]=="i":
        que_r.appendleft(s[7:])
    elif s[6]==" ":
        try:
            que_r.remove(s[7:])
        except: pass
    elif l>10:
        que_r.popleft()
    elif l>6:
        que_r.pop()

print(*que_r)
### BUGGY CODE ###

n = int(input())
l = 0
s = []
for i in range(20):
	print(l)
	stemp = str(input())
	s.append(stemp)
	if stemp[i] == 'Vacant':
		break
	elif i!=0:
		if s[i] == s[i-1]:
			if ((n-l)//2)%2 == 0:
				l = (n-l)//2
			else:
				l = (n-l)//2+1
		else:
			if l%2 == 0:
				l = l//2
				n = l
				s[i] = s[i-1]
			else:
				l = l//2+1
				n = l
				s[i] = s[i-1]
	elif i==0:
		if (n//2)%2==0:
			l = l+n//2
		else:
			l = l+(n//2)+1

### FIXED CODE ###

n = int(input())
l = 0
s = []
start = [0]
end = [n]
check = 1

for i in range(20):
	print(l)
	stemp = str(input())
	s.append(stemp)
	if stemp == 'Vacant':
		break
	elif i!=0:
		if check == 1:
			if s[i-1] == s[i]:
				start[0] = l
				if ((end[0]-start[0])//2)%2==0:
					l = start[0]+(end[0]-start[0])//2
				else:
					l = start[0]+(end[0]-start[0])//2+1
				
			else:
				end[0] = l
				if ((end[0]-start[0])//2)%2==0:
					l = start[0]+(end[0]-start[0])//2
				else:
					l = start[0]+(end[0]-start[0])//2+1
				check = check*-1

		elif check == -1:
			if s[i-1] == s[i]:
				end[0] = l
				if ((end[0]-start[0])//2)%2==0:
					l = start[0]+(end[0]-start[0])//2
				else:
					if abs((end[0]-start[0])) == 2:
						l = start[0]+(end[0]-start[0])//2
					else:
						l = start[0]+(end[0]-start[0])//2-1
				
			else:
				start[0] = l
				if ((end[0]-start[0])//2)%2==0:
					l = start[0]+(end[0]-start[0])//2
				else:
					l = start[0]+(end[0]-start[0])//2+1
				check = check*-1
	else:
		if (n//2)%2==0:
			l = l+n//2
		else:
			l = l+(n//2)+1
### BUGGY CODE ###

n = int(input())
seq = input()
ans = 0
for i, val in enumerate(seq[:-2]):
    for j, val in enumerate(seq[i+1:-1], i+1):
        if seq[i] == seq[j]:
            continue
        for k, val in enumerate(seq[j+1:], j+1):
            if seq[i] != seq[k] and seq[j] != seq[k] and j-i != k-j:
                ans +=1
print(ans)

### FIXED CODE ###

n = int(input())
seq = input().strip()
ans = 0
r = set()
g = set()
b = set()
for i in range(len(seq)):
    if seq[i] == 'R':
        r.add(i)
    elif seq[i] == 'G':
        g.add(i)
    else:
        b.add(i)

ans = len(r)*len(g)*len(b)
for i in r:
    for j in g:
        if (i+j) % 2 == 0 and ((i + j) //2) in b:
            ans -= 1
        if max(i,j) + (max(i,j) - min(i,j)) in b:
            ans -= 1
        if min(i,j) - (max(i,j) - min(i,j)) in b:
            ans -= 1
        
print(ans)
### BUGGY CODE ###

X = int(input())
def f(i):
    return i*(i+1)/2

for i in range(1,10**1000000000000000):
    if  f(i) >= X:
        print(i)
        break


### FIXED CODE ###

X = int(input())
def f(i):
    return i*(i+1)/2

for i in range(1,10**1000000):
    if  f(i) >= X:
        print(i)
        break
### BUGGY CODE ###

N=int(input())
S= [input() for i in range(N)]
A=list(set(S))
M=len(A)
c=[0]*M

for i in range(M):
  #print(A[i],S.count(A[i]))
  c[i]=S.count(A[i])
#print(A)
#print(c)
max=0
for i in range(M):
  if max<=c[i]:
    max=c[i]
maxS=[]
for i in range(M):
  if max==c[i]:
    maxS.append(A[i])
print(*sorted(maxS),sep='\n')

### FIXED CODE ###

N=int(input())
S= [input() for i in range(N)]
from collections import Counter
c = Counter(S)
d = c.most_common()

max=d[0][1]

A=[]
for i in d:
  if i[1]==max:
    A.append(i[0])
print(*sorted(A),sep='\n')