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

#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    s = input()
    cnt = 0
    flag = False
    ok = False
    while True:
        if flag:
            break
        i = 0
        while i < len(s)-1:
            ok = False
            if s[i] != s[i+1]: # 違うものが出た
                cnt += 2
                s = (s[:i] + s[i+2:] if len(s) >= 3 else s[:i])
                ok = True
                break
            i += 1
        if not ok:
            break
        if len(s) == 0:
            break
    print(cnt)


if __name__ == '__main__':
  main()


### FIXED CODE ###

#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    s = input()
    zero = s.count('0')
    one = s.count('1')
    print(min(zero*2,one*2))
if __name__ == '__main__':
  main()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)
def solve(v):
    for u in e[v]:
        if not f[u]:
            f[u]=1
            return[v]+solve(u)
    return[v]
n,m,*t=map(int,open(0).read().split())
e=[[]for _ in range(n+1)]
for a,b in zip(t[::2],t[1::2]):
    e[a].append(b)
    e[b].append(a)
f=[0]*-~n
f[1]=1
a=solve(1)[:0:-1]+solve(1)
print(len(a),*a)

### FIXED CODE ###

n,m,*t=map(int,open(0).read().split())
e=[[]for _ in range(n+1)]
for a,b in zip(t[::2],t[1::2]):
    e[a].append(b)
    e[b].append(a)
f=[0]*-~n
f[1]=1
a=[1]
while 1:
    for v in e[a[-1]]:
        if not f[v]:
            f[v]=1
            a.append(v)
            break
    else:
        break
b=[1]
while 1:
    for v in e[b[-1]]:
        if not f[v]:
            f[v]=1
            b.append(v)
            break
    else:
        break
a=a[:0:-1]+b
print(len(a),*a)
### BUGGY CODE ###

import sys
from collections import defaultdict
from collections import deque
import numpy as np
import heapq
from heapq import heappush, heappop
import itertools


#read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(input())

PATH = []
#COLOR = [[None for _ in range(N+1)] for _ in range(N+1)]
COLOR = defaultdict(int)
PT = [[] for _ in range(N+1)]
cmax = 1
for i in range(N-1):
    a, b = map(int, input().split())
    PATH.append((a, b))
    PT[a].append(b)
    PT[b].append(a)

    la = len(PT[a])
    lb = len(PT[b])

    l = la if la > lb else lb
    if l > cmax:
        cmax = l


q = deque([(1, 0)])

while(q):
    a, ca = q.popleft()
    bs = PT[a]

    c = list(range(1, cmax+1))
    for b in bs:
        if b > a:
            na = a
            nb = b
        else:
            na = b
            nb = a

        if COLOR[(na, nb)] == 0:
            clr = c.pop()
            if clr == ca:
                clr = c.pop()

            COLOR[(na, nb)] = clr
            q.append((b, clr))

print(cmax)

clr = []
for a, b in PATH:
    clr.append(str(COLOR[(a, b)]))

print("\n".join(clr))


### FIXED CODE ###

import sys
from collections import defaultdict
from collections import deque
import numpy as np
import heapq
from heapq import heappush, heappop
import itertools


#read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(input())

PATH = []
#COLOR = [[None for _ in range(N+1)] for _ in range(N+1)]
COLOR = defaultdict(int)
PT = [[] for _ in range(N+1)]
cmax = 1
for i in range(N-1):
    a, b = map(int, input().split())
    PATH.append((a, b))
    PT[a].append(b)
    PT[b].append(a)

    '''
    la = len(PT[a])
    lb = len(PT[b])

    l = la if la > lb else lb
    if l > cmax:
        cmax = l
    '''

q = deque([(1, -1)])
while(q):
    a, ng = q.popleft()
    bs = PT[a]

    c = 1
    for b in bs:
        if b > a:
            na = a
            nb = b
        else:
            na = b
            nb = a

        cab = COLOR[(na, nb)]

        if cab == ng:
            continue

        if cab == 0:
            if c == ng:
                c += 1
            clr = c
            COLOR[(na, nb)] = clr
            q.append((b, clr))
            c += 1

print(max(COLOR.values()))

clr = []
for a, b in PATH:
    clr.append(COLOR[(a, b)])

print("\n".join(map(str, clr)))
### BUGGY CODE ###

import re

def main():
    s = input()
    c = 0

    pat = re.compile(r'A+BC')
    while True:
        m = pat.search(s)
        if not m:
            break
        n = m.end() - m.start() - 2
        s = 'A' * n + s[m.end():]
        c += n

    print(c)
        


main()


### FIXED CODE ###

def main():
    s = input()
    c = 0
    pos = 0
    a = 0

    while pos < len(s):
        if s[pos] == 'A':
            a += 1
            pos += 1
        elif s[pos:pos+2] == 'BC':
            c += a
            pos += 2
        else:
            a = 0
            pos += 1

    print(c)
        


main()
### BUGGY CODE ###

n = int(input())
p = [int(input()) for _ in range(n)]

q = [0] * n
for i in range(n):
    q[p[i]-1] = i
k = 1
for i in range(n-1):
    tmp = 1
    j = i
    while j < n-1 and q[j] < q[j+1]:
        j += 1
        tmp += 1
    k = max(k, tmp)
print(n-k)


### FIXED CODE ###

n = int(input())
p = [int(input()) for _ in range(n)]

q = [0] * n
for i in range(n):
    q[p[i]-1] = i
mxk = 1
k = 1
for i in range(n-1):
    if q[i] < q[i+1]:
        k += 1
        if k > mxk:
            mxk = k
    else:
        k = 1
print(n-mxk)
### BUGGY CODE ###

n = int(input())
L = tuple(map(int, input().split()))
L = sorted(L, reverse=True)

counts = 0
for i in range(n-2):
    a = L[i]
    for j in range(i+1, n-1):
        b = L[j]
        for k in range(j+1, n):
            if a - b < L[k]:
                counts += 1
            else:
                break
print(counts)

### FIXED CODE ###

n = int(input())
L = tuple(map(int, input().split()))
L = sorted(L, reverse=True)

counts = 0
for i in range(n-2):
    a = L[i]
    for j in range(i+1, n-1):
        cc = a - L[j]
        left = j
        right = n
        while right - left > 1:
            mid = (right+left)//2
            if L[mid] > cc:
                left = mid
            else:
                right = mid
        counts += left - j
print(counts)
### BUGGY CODE ###


import sys


def solv(n):
    r = 0
    m = n / 2
    ps = filter(lambda x: x <= m, primes)
    for p in ps:
        q = n - p
        if q in primes:
            r += 1
    return r


def prime_list(n):
    limit = int(n ** 0.5) + 1
    lis = range(1, n + 1, 2)
    lis[0] = 2
    while True:
        if len(lis) == 0:
            break
        p = lis.pop(0)
        yield p
        if p <= limit:
            lis = [x for x in lis if x % p != 0]


primes = []
for p in prime_list(50000):
    primes.append(p)

while True:
    n = int(sys.stdin.readline())
    if n == 0:
        exit()
    print solv(n)

### FIXED CODE ###


import sys
import itertools


def prime_list(n):
    limit = int(n ** 0.5) + 1
    lis = range(1, n + 1, 2)
    lis[0] = 2
    while True:
        if len(lis) == 0:
            break
        p = lis.pop(0)
        yield p
        if p <= limit:
            lis = [x for x in lis if x % p != 0]


primes = []
for p in prime_list(50000):
    primes.append(p)
c = [0] * 50001 * 2
for i, j in itertools.combinations(primes, 2):
    c[i+j] += 1
for i in primes:
    c[i+i] += 1
while True:
    n = int(sys.stdin.readline())
    if n == 0:
        exit()
    print c[n]
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    l, r = [int(x) for x in input().split()]
    # if r - l + 1 >= 5000:
    #     print(0)
    # else:
    M = 2019
    mn = []
    for i in range(l, r + 1):
        for j in range(i+1, r + 1):
            mn.append((i*j)%M)

    mn.sort()
    print(mn[0])
        



t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""



"""


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    l, r = [int(x) for x in input().split()]
    if r - l + 1 >= 5000:
        print(0)
    else:
        M = 2019
        mn = []
        for i in range(l, r + 1):
            for j in range(i+1, r + 1):
                mn.append((i*j)%M)

        mn.sort()
        print(mn[0])
        



t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""



"""
### BUGGY CODE ###

n, m = map(int, input().split())
*x, = sorted(map(int, input().split()))

diff = []
for i in range(m-1):
    diff.append(abs(x[i]-x[i+1]))
partition = sorted(diff, reverse=True)[:(n-1)]

ans = 0
for _d in diff:
    if _d in partition:
        partition.remove(_d)
        continue

    ans += _d

print(ans)


### FIXED CODE ###

n, m = map(int, input().split())
*x, = sorted(map(int, input().split()))

diff = []
for i in range(m-1):
    diff.append(abs(x[i]-x[i+1]))
p = 0 if len(diff) < n else len(diff)-n+1
sec = sorted(diff)[:p]

print(sum(sec))
### BUGGY CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

def conb(n,r): 
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n = inp()
a = inpl()
c = Counter(a)
res = 0
d = dict()
for key in list(c):
    # print(c[key])
    if c[key] > 1:
        tmp = conb(c[key], 2)
        res += tmp
        d[key] = tmp
    else:
        d[key] = 0
for i,t in enumerate(a):
    if d[t] == 0:
        print(res)
        continue
    if c[t]-1 > 1:
        tmp = conb(c[t]-1,2)
    else:
        tmp = 0
    print(tmp + res - d[t])


### FIXED CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

def conb(n,r): 
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n = inp()
a = inpl()
c = Counter(a)
res = 0
d = dict()
for key in list(c):
    # print(c[key])
    if c[key] > 1:
        tmp = conb(c[key], 2)
        res += tmp
        d[key] = tmp
    else:
        d[key] = 0
for i,t in enumerate(a):
    if d[t] == 0:
        print(res)
        continue
    now = d[t] * max(0,c[t]-2) // c[t]
    # print(now)
    print(res - d[t] + now)
### BUGGY CODE ###

def solve(G,start):
	for i in range(n):
		if G[start][i]:
			cost[i] = max(cost[i],cost[start] + G[start][i])
			solve(G,i)
n,m = map(int,raw_input().split())
G = [[0]*n for i in range(n)]
for i in range(m):
	a,b,c = map(int,raw_input().split())
	G[a][b] = c
cost = [0]*n
solve(G,0)
print cost[n-1]

### FIXED CODE ###

inf = 1e9
n,m = map(int,raw_input().split())
edge = [map(int,raw_input().split()) for i in range(m)]
d = [inf]*n
d[0] = 0
while 1:
	update = 0
	for i in range(m):
		a,b,c = edge[i]
		if d[a] != inf and d[b] > d[a] - c:
			d[b] = d[a] - c
			update = 1
	if update == 0: break
print abs(d[n-1])
### BUGGY CODE ###

import sys
from random import randint
input = sys.stdin.readline
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = [randint(0, 25) for i in range(D)]
last = [0] * 26
def score(day, score):
  for i in range(26): score -= (day - last[i]) * c[i]
  return score
def run(day):
  global last
  last = [0] * 26
  res = 0
  for d in range(day):
    contest = t[d]
    last[contest] = d + 1
    res = score(d + 1, res) + s[d][contest]
  return res


for d in range(1, D + 1):
  mx = -float("inf")
  mxx = randint(0, 25)
  for x in range(26):
    t[d - 1] = x
    res = run(d)
    if mx < res:
      mx = res
      mxx = x
  t[d - 1] = mxx

for _ in range(100):
  l = randint(1, 365)
  last = [0] * 26
  run(l)
  #print(last)
  zmx = -float("inf")
  zmxz = 0
  for z in range(26):
    t[l - 1] = z

    for d in range(l + 1, D + 1):
      mx = -float("inf")
      mxx = t[d - 1]
      for x in range(26):
        t[d - 1] = x
        res = score(d, 0) + s[d - 1][x]
        if mx < res:
          mx = res
          mxx = x
      t[d - 1] = mxx
      last[mxx] = d
    zres = run(D)
    if zres > zmx:
      zmx = zres
      zmxz = z
  t[l - 1] = zmxz

for x in t: print(x + 1)

### FIXED CODE ###

import sys
from random import randint
input = sys.stdin.readline
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

t = [0] * D
last = [0] * 26
def score(day, score):
  for i in range(26): score -= (day - last[i]) * c[i]
  return score
def run(day):
  global last
  res = 0
  for d in range(day):
    contest = t[d] - 1
    last[contest] = d + 1
    res = score(d + 1, res) + s[d][contest]
  return res


for d in range(1, D + 1):
  mx = 0
  mxx = randint(1, 27)
  for x in range(26):
    t[d - 1] = x
    res = run(d)
    if mx < res:
      mx = res
      mxx = x
  t[d - 1] = mxx
for d in range(1, D + 1):
  mx = 0
  mxx = t[d - 1]
  for x in range(26):
    t[d - 1] = x
    res = run(d)
    if mx < res:
      mx = res
      mxx = x
  t[d - 1] = mxx

for x in t: print(x + 1)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)
n,q = map(int,input().split())
tree = [[] for _ in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)
ans = [0]*n
for i in range(q):
    p,x = map(int,input().split())
    ans[p-1] += x
done = [0]*n
def dfs(now,m):
    done[now] = 1
    ans[now] += m
    for i in tree[now]:
        if not done[i]:
            dfs(i,ans[now])
dfs(0,0)
print(*ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n,q = map(int,input().split())
t = [[] for _ in range(n+1)]
for _ in range(n-1):
  a,b = map(int,input().split())
  t[a].append(b)
  t[b].append(a)
cnt = [0]*(n+1)
for _ in range(q):
  p,x = map(int,input().split())
  cnt[p] += x
def csum(now,bef):
  for i in t[now]:
    if i != bef:
      cnt[i] += cnt[now]
      csum(i,now)
csum(1,0)
print(*cnt[1:])
### BUGGY CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
b = list(set(a))
aSum = 0
for i in b:
    if a.count(i) % 2 == 1:
        aSum += 1
print(aSum)


### FIXED CODE ###

import sys
import collections
import bisect


def main():
    n = int(input())
    A = [int(input()) for _ in range(n)]
    c = collections.Counter(A)
    sumA = 0
    cKeys = c.keys()
    for cKey in cKeys:
        sumA += c[cKey] % 2
    print(sumA)


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

# coding: utf-8
from heapq import heappush,heappop

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

for k in range(K):
    tmp1=[0 for i in range(N)]
    tmp2=[0 for i in range(N)]
    
    h1=[]
    h2=[]
    num1=0
    num2=0
    for i in range(N):
        heappush(h1,A[i]+i)
        num1+=1
        tmp1[i]+=num1
        # print("h1",h1[0],i,)
        while h1[0]==i:
            # print("!")
            heappop(h1)
            num1-=1
            if len(h1)==0:
                break
        
        heappush(h2,Ar[i]+i)
        tmp2[i]=num2
        num2+=1
        # print("h2",h2[0],i)
        while h2[0]==i:
            # print("?")
            l=heappop(h2)
            num2-=1
            if len(h2)==0:
                break
    
    for i in range(N):
        A[i]=tmp1[i]+tmp2[-(1+i)]
    Ar=list(reversed(A))
    
    if set(A)==set([N]):
        break
# print(tmp1,tmp2)
# print(h1,h2)
print(*A)

### FIXED CODE ###

# coding: utf-8
import copy
N,K=map(int,input().split())
A=list(map(int,input().split()))
for k in range(K):
    imos=[0 for i in range(N+1)]
    
    for i in range(N):
        imos[max(i-A[i],0)]+=1
        imos[min(i+A[i]+1,N)]-=1
    tmp=[imos[0]]
    for i in range(N-1):
        tmp.append(tmp[i]+imos[i+1])
    A=copy.deepcopy(tmp)
    if set(A)==set([N]):
        break
    
print(*A)
### BUGGY CODE ###

import fractions

N = int(input())

total = 0

for i in range(1, N + 1):
  total += i

for i in range(1, N):
  for j in range(i + 1, N + 1):
    total += (fractions.gcd(i, j) * 6)

for i in range(1, N - 1):
  for j in range(i + 1, N):
    for k in range(j + 1, N + 1):
      total += (fractions.gcd(fractions.gcd(i, j), k) * 6)

print(total)

### FIXED CODE ###

import fractions

N = int(input())

total = 0

for i in range(1, N + 1):
  total += i

for i in range(1, N + 1):
  for j in range(i + 1, N + 1):
    tmp = fractions.gcd(i, j)
    total += (tmp * 6)
    for k in range(j + 1, N + 1):
      total += (fractions.gcd(tmp, k) * 6)

print(total)
### BUGGY CODE ###

s = input()

dp_prev = [1, 0, 0, 0]

for c in s:
    dp_new = [dp_prev[i] for i in range(0, 4)]
    for i in range(0, 4):
        if c == "A":
            dp_new[1] = dp_prev[0] + dp_prev[1]

        elif c == "B":
            dp_new[2] = dp_prev[1] + dp_prev[2]

        elif c == "C":
            dp_new[3] = dp_prev[2] + dp_prev[3]

        else:
            dp_new[0] = dp_prev[0] * 3
            dp_new[1] = dp_prev[0] + dp_prev[1] * 3
            dp_new[2] = dp_prev[1] + dp_prev[2] * 3
            dp_new[3] = dp_prev[2] + dp_prev[3] * 3

    dp_prev = dp_new

ans = dp_prev[3] % 1000000007
print(ans)


### FIXED CODE ###

s = input()

dp_prev = [1, 0, 0, 0]

MODE_BASE = 1000000007

for c in s:
    dp_new = [dp_prev[i] for i in range(0, 4)]
    for i in range(0, 4):
        if c == "A":
            dp_new[1] = (dp_prev[0] + dp_prev[1]) % MODE_BASE

        elif c == "B":
            dp_new[2] = (dp_prev[1] + dp_prev[2]) % MODE_BASE

        elif c == "C":
            dp_new[3] = (dp_prev[2] + dp_prev[3]) % MODE_BASE

        else:
            dp_new[0] = (dp_prev[0] * 3) % MODE_BASE
            dp_new[1] = (dp_prev[0] + dp_prev[1] * 3) % MODE_BASE
            dp_new[2] = (dp_prev[1] + dp_prev[2] * 3) % MODE_BASE
            dp_new[3] = (dp_prev[2] + dp_prev[3] * 3) % MODE_BASE

    dp_prev = dp_new

ans = dp_prev[3]
print(ans)
### BUGGY CODE ###

n, k = map(int, input().split())
a = [int(i) for i in input().split()]

ans = [1] * (n-k+1)

for i in range(k):
    ans[0] *= a[i]

for i in range(1, n-k+1):
    ans[i] = (ans[i-1] / a[i-1]) * a[k+i-1]
    if ans[i-1] < ans[i]:
        print('Yes')
    else:
        print('No')


### FIXED CODE ###

n, k = map(int, input().split())
a = [int(i) for i in input().split()]

for i in range(n-k):
    if a[i] < a[k+i]:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

while True:
	n = int(input())
	if n == 0:
	    break
	s = []
	u = 0
	v = 0
	s = list(input().split())
	while True:
		t = []
		for i in range(n):
			for j in range(n):
				if s[i] == s[j]:
					u += 1
			t.append(u)
			t_str = list(map(str, t))
			u = 0
		if s == t_str:
			print(str(v))
			print(" ".join(t_str))
			break
		else:
			s = t
			v += 1

### FIXED CODE ###

while True:
	n = int(input())
	if n == 0:
	    break
	s = []
	u = 0
	v = 0
	s = list(map(int, input().split()))
	while True:
		t = []
		for i in range(n):
			for j in range(n):
				if s[i] == s[j]:
					u += 1
			t.append(u)
			t_str = list(map(str, t))
			u = 0
		if s == t:
			print(str(v))
			print(" ".join(t_str))
			break
		else:
			s = t
			v += 1
### BUGGY CODE ###

N, K = map(int, input().split())
numbers = list(map(int, input().split()))

max_num = max(sum(numbers[i:i+K]) for i in range(N+1-K))
    
answer = (max_num + K) / 2
print(answer)


### FIXED CODE ###

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

mx = sum(p[:K])
cur = mx
for i in range(N-K):
  cur = cur-p[i]+p[i+K]
  mx = max(mx, cur)
  
ans = (mx+K) / 2
print(ans)
### BUGGY CODE ###

n = int(input())
a=[int(i) for i in input().split()]

ans=0
for i in set(a):
  if a.count(i)-i<0:
    ans+=a.count(i)
  else:
    ans+=a.count(i)-i
  
print(ans)


### FIXED CODE ###

import collections

n = int(input())
a=[int(i) for i in input().split()]
#a.sort()

c = collections.Counter(a)

#print(c)
ans=0
for i in set(a):
  tmp=c[i]
  if tmp-i<0:
    ans+=tmp
  else:
    ans+=tmp-i
  
print(ans)
### BUGGY CODE ###

n , k = map(int, input().strip().split(' '))

w = [0] * n
d = [0] * n
p = None
for i in range(n):
    w[i], d[i] = map(int, input().strip().split(' '))
    p1 = w[i] + (k - 1) * d[i]
    if p == None or p1 < p:
        p = p1


p1 = 1
p2 = p

def getk(p):
    kk = 0
    for i in range(n):
        if p <w[i]:
            kk += 0
        else:
            kk += (p - w[i]) // d[i] + 1
    return kk

def search(pmin, pmax):
    if pmin == pmax:
        return pmin
    else:
        mid = (pmin + pmax) // 2
        findk = getk(mid)        
        if (findk >= k):
            return search(pmin, mid)
        else:
            return search(mid+1, pmax)


print(search(p1, p2))


### FIXED CODE ###

n , k = map(int, input().strip().split(' '))

w = [0] * n
d = [0] * n
p = None
for i in range(n):
    w[i], d[i] = map(int, input().strip().split(' '))
    p1 = w[i] + (k - 1) * d[i]
    if p == None or p1 < p:
        p = p1


p1 = 1
p2 = p

def getk(p):
    kk = 0
    for i in range(n):
        if p <w[i]:
            kk += 0
        else:
            kk += (p - w[i]) // d[i] + 1
        if kk > k:
            return kk
    return kk

def search(pmin, pmax):
    if pmin == pmax:
        return pmin
    else:
        mid = (pmin + pmax) // 2
        findk = getk(mid)
        if (findk >= k):
            return search(pmin, mid)
        else:
            return search(mid+1, pmax)


print(search(p1, p2))
### BUGGY CODE ###

n = int(input())
wordlist = [input() for i in range(n)]
wordset = set(wordlist)
wordlist2 = list(wordset)
checklist = []
ans = []
for j in range(len(wordlist2)) :
    checklist.append(wordlist.count(wordlist2[j]))
position = [i for i, x in enumerate(checklist) if x == max(checklist)]
for k in position :
    ans.append(wordlist2[k])
ans.sort()
for l in range(len(ans)) :
    print(ans[l])

### FIXED CODE ###

n = int(input())
d = {}
for i in range(n) :
    s = input()
    if s not in d :
        d[s] = 1
    else :
        d[s] += 1
m = max(d.values())
ans = []
for i in d :
    if d[i] == m :
        ans.append(i)
ans.sort()
for i in ans:
    print(i)