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

def main():
    import bisect
    import array
    B=bisect.bisect_left
    I=10**9+1
    n,q,*t=map(int,open(0).read().split())
    d=t[-q:]
    t=t[:-q]
    N0=2**(q-1).bit_length()
    data=array.array('I',[I]*2*N0)
    for x,l,r in sorted([(x,B(d,s-x)+N0,B(d,t-x)+N0)for s,t,x in zip(t[::3],t[1::3],t[2::3])],reverse=1):
        while l<r:
            if r&1:
                r-=1
                data[r-1]=x
            if l&1:
                data[l-1]=x
                l+=1
            l>>=1
            r>>=1
    for k in range(N0-1,q+N0-1):
        s=I
        while~k:
            if data[k]<s:s=data[k]
            k=(k-1)//2
        print(-(s==I)or s)
if __name__=='__main__':
    main()

### FIXED CODE ###

def main():
    from bisect import bisect_left
    def update(l,r,v):
        L,R=l+N0,r+N0
        while L<R:
            if R&1:
                R-=1
                data[R-1]=v
            if L&1:
                data[L-1]=v
                L+=1
            L>>=1
            R>>=1
    def query(k):
        k+=N0-1
        s=10**18
        while k+1:
            if data[k]<s:s=data[k]
            k=~-k//2
        return s
    n,*t=open(0)
    n,q=map(int,n.split())
    d=[-10**18]+list(map(int,t[n:]))+[10**18]
    N0=2**(q+1).bit_length()
    data=[10**18]*2*N0
    for x,t,s in sorted(list(map(int,t.split()))[::-1]for t in t[:n])[::-1]:
        l=bisect_left(d,s-x)
        r=bisect_left(d,t-x)
        update(l,r,x)
    for i in range(q):
        a=query(i+1)
        print(-(a==10**18)or a)
if __name__=='__main__':
    main()
### BUGGY CODE ###

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

A = A + [0]
for k in range(K):
    t = [0]*(N+1)
    for i in range(N):
        l = max(i-A[i], 0)
        r = min(i+A[i], N-1)
        t[l] += 1
        t[r+1] -= 1

    A = [0]*N
    A[0] = t[0]
    for i in range(1, N):
        A[i] = A[i-1] + t[i]
    
    if all(a == N for a in A):
        print(*A)
        exit()

print(*A)

### FIXED CODE ###

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

A = A + [0]
K = min(K, 50)
for k in range(K):
    t = [0]*(N+1)
    for i in range(N):
        l = max(i-A[i], 0)
        r = min(i+A[i], N-1)
        t[l] += 1
        t[r+1] -= 1

    S = [0]*N
    S[0] = t[0]
    for i in range(1, N):
        S[i] = S[i-1] + t[i]

    A = S.copy()
print(*S)
### BUGGY CODE ###

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

ans = 1
for i in A:
    ans *= i

print(ans if ans <= 10 ** 18 else -1)

### FIXED CODE ###

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

ans = 1
if A.count(0) >= 1:
    print(0)
    exit()
for i in A:
    ans *= i
    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)
### BUGGY CODE ###

n,y = map(int,input().split())

for i in range(y//10000+1):
    if i > n:
        break
    for j in range((y-i*10000)//5000+1):
        if i + j > n:
            break
        for k in range((y-i*10000-j*5000)//1000+1):
            if i + j + k > n:
                break
            if i+j+k == n and i * 10000 + j * 5000 + k * 1000 == y:
                print(i,j,k)
                exit()

print(-1,-1,-1)


### FIXED CODE ###

n,y = map(int,input().split())

for i in range(y//10000+1):
    if i > n:
        break
    for j in range((y-i*10000)//5000+1):
        if i + j > n:
            break
        if i * 10000 + j * 5000 + (n-i-j) * 1000 == y:
            print(i,j,n-i-j)
            exit()

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

n=int(input())
a=list(map(int,input().split()))
a1 = sorted(a)
a1 = list(set(a1))
total = 0

for i in range(len(a1)):
  to = a.count(a1[i])
  total += (to*(to-1)//2)
  
for i in range(n):
  to = a.count(a[i])-1
  print(total-(to*(to+1)//2)+(to*(to-1)//2))
  
  
 

### FIXED CODE ###

import collections
n=int(input())
a=list(map(int,input().split()))
b = collections.Counter(a)
total = 0

for i in b.values():
  total += i*(i-1)//2
  
for i in a:
  c = b[i]
  print(total-(c*(c-1)//2)+((c-1)*(c-2)//2))
### BUGGY CODE ###

from collections import defaultdict
from bisect import bisect_right

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

b = []
c = []
for i in range(n):
	b.append(i + 1 - a[i])
	c.append(i + 1 + a[i])

cnt = defaultdict(list)
for i in range(n):
	cnt[b[i]].append(i)

ans = 0
for i in range(n):
	k = bisect_right(cnt[c[i]], i)
	ans += len(cnt[c[i]][k:])

print(ans)


### FIXED CODE ###

from collections import defaultdict

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

memo = defaultdict(int)
ans = 0
for i, a in enumerate(A, 1):
    ans += memo[i - a]
    memo[a + i] += 1

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

import math
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
M = [0] * N
for i in range(N):
    op = 1
    for j in range(N):
        jj = (i + j) % N
        M[i] = M[i] + A[jj] if op == 1 else M[i] - A[jj]
        op = 1 - op
print(*M)


### FIXED CODE ###

import math
import sys

input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
X = [sum(A)] * N
for i in range(2, N, 2):
    X[0] -= 2 * A[i - 1]
for i in range(1, N):
    X[i] = 2 * A[i - 1] - X[i - 1]
print(*X)
### BUGGY CODE ###

from collections import OrderedDict


if __name__ == "__main__":
    N, X, Y = map(int, input().split())
    k_dict = OrderedDict()

    for i in range(1, N):
        k_dict[i] = 0

    for i in range(1, N):
        for j in range(i+1, N+1):
            if i <= X and j <= X:
                d = j - i
                k_dict[d] += 1
                # print('{} {} {} debug 1'.format(i, j, d))
                continue

            if i <= X and X < j and j < Y:
                d = min(j-i, X-i + 1 + Y-j)
                k_dict[d] += 1
                # print('{} {} {} debug 2'.format(i, j, d))
                continue

            if i <= X and Y <= j:
                d = X-i + 1 + j-Y
                k_dict[d] += 1
                # print('{} {} {} debug 3'.format(i, j, d))
                continue

            if X < i and i < Y and X < j and j < Y:
                d = min(j-i, i-X + 1 + Y-j)
                k_dict[d] += 1
                # print('{} {} {} debug 4'.format(i, j, d))
                continue

            if X < i and i < Y and Y <= j:
                d = min(j-i, i-X + 1 + j - Y)
                k_dict[d] += 1
                # print('{} {} {} debug 5'.format(i, j, d))
                continue

            if Y <= i and Y <= j:
                d = j-i
                k_dict[d] += 1
                # print('{} {} {} debug 6'.format(i, j, d))
                continue

    for k, v in k_dict.items():
        # print('{} {}'.format(k, v))
        print(v)


### FIXED CODE ###

from collections import OrderedDict


if __name__ == "__main__":
    N, X, Y = map(int, input().split())
    k_dict = OrderedDict()

    for i in range(1, N):
        k_dict[i] = 0

    for i in range(1, N):
        for j in range(i+1, N+1):
            if i <= X and j <= X:
                d = j - i
                k_dict[d] += 1
                # print('{} {} {} debug 1'.format(i, j, d))
                continue

            if i <= X and X < j and j < Y:
                d = min(j-i, X-i + 1 + Y-j)
                k_dict[d] += 1
                # print('{} {} {} debug 2'.format(i, j, d))
                continue

            if i <= X and Y <= j:
                d = X-i + 1 + j-Y
                k_dict[d] += 1
                # print('{} {} {} debug 3'.format(i, j, d))
                continue

            if X < i and i < Y and X < j and j < Y:
                d = min(j-i, i-X + 1 + Y-j)
                k_dict[d] += 1
                # print('{} {} {} debug 4'.format(i, j, d))
                continue

            if X < i and i < Y and Y <= j:
                d = min(j-i, i-X + 1 + j - Y)
                k_dict[d] += 1
                # print('{} {} {} debug 5'.format(i, j, d))
                continue

            if Y <= i and Y <= j:
                d = j-i
                k_dict[d] += 1
                # print('{} {} {} debug 6'.format(i, j, d))
                continue

    for k, v in k_dict.items():
        # print('{} {}'.format(k, v))
        print(v)
### BUGGY CODE ###

# 出現した数のフラグを立てればよいだけでは
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
count = Counter(A)
happend = set()
A.sort()
ans = 0

for val in A:
    tmp = set()
    for i in range(1, int(val**(1/2))+2):
        if val % i == 0:
            tmp.add(i)
            tmp.add(val//i)

    if len(tmp & happend) >= 1 or count[val] >= 2:
        ans += 1
    happend.add(val)

print(N-ans)


### FIXED CODE ###

from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)
A.sort()
ans = 0
max_A = max(A)
dp = [True]*(max_A+1)  # 0~max(A)の数についてのリスト
happend = set()
for a in A:
    if C[a] >= 2:
        if a in happend:
            continue
        else:
            # aが存在したという証拠だけは残しておく
            x = a * 2
            while x <= max_A:
                dp[x] = False
                x += a
            happend.add(a)
    else:
        if dp[a]:
            ans += 1
        x = a * 2
        while x <= max_A:
            dp[x] = False
            x += a
print(ans)
### BUGGY CODE ###

import math
K = int(input())
s = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            s = s + math.gcd(math.gcd(a, b), c)

print(s)


### FIXED CODE ###

import math
K = int(input())
s = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            s = s + math.gcd(math.gcd(a, b), c)

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

S = str(input())
s = int(S)
n = len(S)
count = 0
for i in range(1,n+1):
    for j in range(i+4,n+1):
        si = s%10**(n-i+1)
        sij = si//10**(n-j)
        if sij % 2019 == 0:
            count+=1
            i+=3
            j+=3

print(count)

### FIXED CODE ###

from collections import Counter

s = input()
a = [0]
mod = 2019

for i,j in enumerate(s[::-1]):
    a.append(a[-1] + int(j)*pow(10,i,mod))
    a[-1] %= mod
b = Counter(a)

ans = 0
for i in b.values():
    ans += i*(i-1)//2
print(ans)
### BUGGY CODE ###

def rem():
  X = input()
  N = len(X)
  
  st = "ST"
  con = X.count(st)
  
  while con > 0:
    X = X.replace(st,"")
    con = X.count(st)
    
  print(len(X))
  
rem()

### FIXED CODE ###

from collections import deque

X = input()
N = len(X)
S = "S"
T = "T"
stack = deque("")

for i,str in enumerate(X):
  if str == S:
    stack.append(str)
  elif str == T:
    if len(stack) == 0:
      stack.append(str)
    elif stack[-1] == T:
      stack.append(str)
    elif stack[-1] == S:
      stack.pop()
      
print(len(stack))
### BUGGY CODE ###

N, T = map(int, input().split())
A = [0]*N
B = [0]*N
AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[0])
dp = [[0]*(T) for _ in range(N+1)]
ans = 0
for i in range(N):
    for j in range(T):
        dp[i+1][j] = dp[i][j]
        ans = max(ans, dp[i][j] + AB[i][1])
        if j - AB[i][0] >= 0:
            dp[i+1][j] = max(dp[i][j], dp[i][j-AB[i][0]] + AB[i][1])
print(ans)


### FIXED CODE ###

N, T = map(int, input().split())
A = [0]*N
B = [0]*N
AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[0])
dp = [[0]*(T) for _ in range(N+1)]
ans = 0
for i in range(N):
    for j in range(T):
        dp[i+1][j] = dp[i][j]
        ans = max(ans, dp[i][j] + AB[i][1])
        # 上は この時刻jまでで商品i-1個を入れた後に時間制約の無いi個目の商品を追加している
        if j - AB[i][0] >= 0:
            dp[i+1][j] = max(dp[i][j], dp[i][j-AB[i][0]] + AB[i][1])
print(ans)
### BUGGY CODE ###

n=int(input())
s=[]
ans=0
for i in range(n):
  S=str(sorted(input()))
  s.append(S)

for i in range(len(set(s))):
  tmp = s.count(list(set(s))[i])
  if tmp==1:
    ans+=0
  else:
    ans+=tmp*(tmp-1)/2
  
print(int(ans))


### FIXED CODE ###

n = int(input())
s = {}
ans = 0
for i in range(n):
    tmp = str(sorted(input()))
    if tmp in s:
        ans += s[tmp]
        s[tmp] += 1
    else:
        s[tmp] = 1
print(ans)
### BUGGY CODE ###

def main():
    r,g,b,n = map(int, input().split())
    tmp = [r,g,b]
    r,g,b = sorted(tmp, reverse=True)
    res = 0
    for i in range(n//r + 1):
        for j in range(n//g + 1):
            if r*i + g*j <= n:
                if (n-(r*i + g*j)) % b==0:
                    res += 1           
    print(res)

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    r,g,b,n = map(int, input().split())
    tmp = [r,g,b]
    r,g,b = sorted(tmp, reverse=True)
    res = 0
    for i in range(n//r + 1):
        if i*r > n:
            break
        for j in range(n//g + 1):
            if r*i + g*j > n:
                break
            if (n-(r*i + g*j)) % b==0:
                res += 1           
    print(res)

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

S = input()
N = len(S)
MOD = 10 ** 9 + 7
dp = [[0] * 13 for i in range(N + 1)]
dp[0][0] = 1

p10 = 1
for i, s in enumerate(S[::-1], start=1):
    if s != '?':
        for k in range(13):
            dp[i][(int(s) * p10 + k) % 13] += dp[i - 1][k]
            dp[i][(int(s) * p10 + k) % 13] %= MOD
    else:
        for j in range(10):
            for k in range(13):
                dp[i][(j * p10 + k) % 13] += dp[i - 1][k]
                dp[i][(j * p10 + k) % 13] %= MOD
    p10 *= 10
print(dp[N][5] % MOD)


### FIXED CODE ###

S = input()
N = len(S)
MOD = 10 ** 9 + 7
dp = [[0] * 13 for i in range(N + 1)]
dp[0][0] = 1

for i, s in enumerate(S[::-1], start=1):
    p10 = pow(10, i - 1, 13)
    if s != '?':
        for k in range(13):
            dp[i][(int(s) * p10 + k) % 13] += dp[i - 1][k]
            dp[i][(int(s) * p10 + k) % 13] %= MOD
    else:
        for j in range(10):
            for k in range(13):
                dp[i][(j * p10 + k) % 13] += dp[i - 1][k]
                dp[i][(j * p10 + k) % 13] %= MOD

print(dp[N][5] % MOD)
### BUGGY CODE ###

N = int(input())
S = input()

r= S.count("R")
g = S.count("G")
b= S.count("B")
ans=r*g*b

for j in range(N):
  for k in range(N):
    i=2*j-k
    if 0<=i<j<k<=N-1 and S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k]:
      ans-=1
print(ans)

### FIXED CODE ###

N = int(input())
S = input()

r= S.count("R")
g = S.count("G")
b= S.count("B")
ans=r*g*b

for j in range(N):
  for k in range(N):
    i=2*j-k
    if 0<=i<j<k<=N-1 and S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k]:
      ans-=1
print(ans)
### BUGGY CODE ###

n = int(input())
S = ['']*n
T = []
for i in range(n):
    S[i] = input()
mxcnt = 0
for s in S:
    mxcnt = max(mxcnt,S.count(s))
for s in S:
    if S.count(s) == mxcnt and s not in T:
        T.append(s)
T.sort()
for t in T:
    print(t)

### FIXED CODE ###

n = int(input())
S = ['']*n
T = []
for i in range(n):
    S[i] = input()
S.sort()
if n == 1:
    print(S[0])
    exit()
cnt = 1
mxcnt = 1
for i in range(n-1):
    if S[i] == S[i+1]:
        cnt += 1
    else:
        cnt = 1
    mxcnt = max(mxcnt,cnt)
cnt = 1
for i in range(n-1):
    if S[i] == S[i+1]:
        cnt += 1
    else:
        cnt = 1
    if cnt == mxcnt:
        T.append(S[i])
if mxcnt == 1:
    T.append(S[-1])
for t in T:
    print(t)
### BUGGY CODE ###

def main():
    from bisect import bisect_left
    from array import array
    I=10**9+1
    n,*t=open(0)
    n,q=map(int,n.split())
    d=array('i',[-I]+list(map(int,t[n:]))+[I])
    N0=2**(q+1).bit_length()
    data=array('i',[I]*2*N0)
    for x,t,s in sorted(list(map(int,t.split()))[::-1]for t in t[:n])[::-1]:
        l=bisect_left(d,s-x)
        r=bisect_left(d,t-x)
        L,R=l+N0,r+N0
        while L<R:
            if R&1:
                R-=1
                data[R-1]=x
            if L&1:
                data[L-1]=x
                L+=1
            L>>=1
            R>>=1
    for k in range(q):
        k+=N0
        s=I
        while k+1:
            if data[k]<s:s=data[k]
            k=~-k//2
        print(-(s==I)or s)
if __name__=='__main__':
    main()

### FIXED CODE ###

def main():
    from bisect import bisect_left
    def update(l,r,v):
        L,R=l+N0,r+N0
        while L<R:
            if R&1:
                R-=1
                data[R-1]=v
            if L&1:
                data[L-1]=v
                L+=1
            L>>=1
            R>>=1
    def query(k):
        k+=N0-1
        s=10**18
        while k+1:
            if data[k]<s:s=data[k]
            k=~-k//2
        return s
    n,*t=open(0)
    n,q=map(int,n.split())
    d=[-10**18]+list(map(int,t[n:]))+[10**18]
    N0=2**(q+1).bit_length()
    data=[10**18]*2*N0
    for x,t,s in sorted(list(map(int,t.split()))[::-1]for t in t[:n])[::-1]:
        l=bisect_left(d,s-x)
        r=bisect_left(d,t-x)
        update(l,r,x)
    for i in range(q):
        a=query(i+1)
        print(-(a==10**18)or a)
if __name__=='__main__':
    main()
### BUGGY CODE ###

n=int(input())
a = list(map(int, input().split()))
ans=1
b=10**18
for i in a:
    ans*=i
    if ans == 0:
        break
    if ans > b:
        ans=-1
print(ans)

### FIXED CODE ###

n=int(input())
a = list(map(int, input().split()))
a.sort()
ans=1
b=10**18
for i in a:
    ans*=i
    if ans > b:
        ans=-1
        break
print(ans)
### BUGGY CODE ###

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

a=sorted(a)
if n==1:
  for i in range(m):
    a[0]=a[0]//2
else:
  for i in range(m):
    if a[n-2]>a[n-1]:
      a=sorted(a)
    a[n-1]=a[n-1]//2

ans=sum(a)
  
print(ans)

### FIXED CODE ###

import heapq	

n,m=map(int,input().split())
a=list(map(int,input().split()))
hq=[]
for i in range(len(a)):
  heapq.heappush(hq,-a[i])

if n==1:
  for i in range(m):
    hq[0]=(((-1)*hq[0])//2)*(-1)
else:
  for i in range(m):
    v=heapq.heappop(hq)
    heapq.heappush(hq,((v*-1)//2)*(-1))

ans=0
for i in range(len(hq)):
  ans=ans+(-1)*heapq.heappop(hq)

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

import bisect
S=list(input())
T=list(input())
N=len(S)
TI={}
for i in range(N):
  s=S[i]
  if s in set(T):
    if s in TI:
      TI[s].append(i)
    else:
      TI[s]=[i]

i=-1
for t in T:
  if t not in TI:
    print(-1)
    exit()
  else:
    ni=TI[t][(bisect.bisect_right(TI[t],i%N))%len(TI[t])]
    if ni>i%N:
      i+=ni-i%N
    else:
      i+=N-i%N+ni
print(i+1)

### FIXED CODE ###

import bisect
S=list(input())
T=list(input())
sT=set(T)
N=len(S)
TI={}
for i in range(N):
  s=S[i]
  if s in sT:
    if s in TI:
      TI[s].append(i)
    else:
      TI[s]=[i]

i=-1
for t in T:
  if t not in TI:
    print(-1)
    exit()
  else:
    ni=TI[t][(bisect.bisect_right(TI[t],i%N))%len(TI[t])]
    if ni>i%N:
      i+=ni-i%N
    else:
      i+=N-i%N+ni
print(i+1)
### BUGGY CODE ###

#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin


def main(init=int(2**31-1)):
    n, q = (int(s) for s in stdin.readline().split())

    a = [init] * n

    for _ in range(q):
        com, x, y = (int(s) for s in stdin.readline().split())
        if com:
            print(min(a[x:y+1]))
        else:
            a[x] = y


main()

### FIXED CODE ###

#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin


def main(init=int(2**31-1), readline=stdin.readline):
    n, q = (int(s) for s in readline().split())

    a = [init] * n
    b = [init] * ((n // 100) + 1)

    for _ in range(q):
        com, x, y = (int(s) for s in readline().split())
        if com:
            bx = x - (x % 100) + 100
            by = y - (y % 100)
            if bx < by:
                m = min(min(a[x:bx]), min(b[bx//100:by//100]),
                        min(a[by:y+1]))
            else:
                m = min(a[x:y+1])
            print(m)
        else:
            a[x] = y
            bx = x - (x % 100)
            b[x//100] = min(a[bx:bx+100])


main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline

class Factorization:	
	def __init__(self):
		# privateなインスタンス変数を作成
		self.__factors = dict()
		self.__n = 0
	
	
	def get_factors(self, n):
		# [summary] 素因数分解した結果を、辞書([素因数, 指数]...)で返す
		self.__factors.clear()
		self.__n = n
		
		if n < 2:
			# 2より小さい数の場合、素因数分解できない
			return { n:1 }
		else:
			self.__factorization()
			
			return self.__factors
	
	
	def get_divisors(self, n):
		# [summary] 約数をリストに列挙
		self.__factors.clear()
		self.__n = n
		
		if n < 2:
			return [1]
		else:
			self.__factorization()
			divisors = [1]
			
			for k, v in self.__factors.items():
				import copy
				copy_ = copy.deepcopy(divisors)
								
				for i in range(1, v + 1):
					for c in copy_:
						divisors.append(c * (k ** i))
			
			return divisors

				
	def count_divisors(self, n):
		# [summary] 約数の個数を返す
		self.__factors.clear()
		self.__n = n
		
		if n < 2:
			return 1
		else:
			self.__factorization()
			count = 1
			
			for v in self.__factors.values():
				count *= v + 1
			
			return count
	

	def	__factorization(self):
		# [summary]素因数分解した結果を、インスタンス変数に格納
		
		# 2,3,5で、割れなくなるまで割り続ける
		# (末尾に2,3,5のつく数は素数でないことが明白なので
		# 後続の処理で素数のリストに入れないように、先に処理する)
		self.__divide_with(2)
		self.__divide_with(3)
		self.__divide_with(5)
			
		# 平方根以下の素数で総当たりで試し割りする
		# (実際は、素数らしき数)
		import math
		sqrt_ = math.floor(math.sqrt(self.__n))
			
		primes = [7, 11, 13, 17, 19, 23, 29, 31]
		i = 0
		is_break = False
			
		while self.__n > 1:
			for p in primes:
				if p + i <= sqrt_:
					self.__divide_with(p + i)
				else:
					# 試し割りする数が平方根を超えたら、ループを抜ける
					is_break = True
						
					# 1が素因数に追加されることを防止
					if self.__n > 1:
						self.__factors.setdefault(self.__n, 1)
				
			if is_break:
				break
			else:
				i += 30
	
	
	def __divide_with(self, d):
		count = 0
		
		while self.__n % d == 0:
			self.__n //= d
			count += 1
		
		if count > 0:
			self.__factors.setdefault(d, count)


# D - Not Divisible
n = int(input())
a = list(map(int, input().split()))
dic = dict()

for ai in a:
	dic.setdefault(ai, 0)
	dic[ai] += 1

ans = 0
appeared = set()
lib = Factorization()

for k, v in sorted(dic.items(), key=lambda x:x[0]):
	is_exist = False

	if v == 1:
		divisors = lib.get_divisors(k)
		
		for d in divisors:
			if d in appeared:
				is_exist = True
				break

		if is_exist == False:
			ans += 1

	if is_exist == False:
		appeared.add(k)

print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline

# D - Not Divisible
n = int(input())
a = list(map(int, input().split()))
dic = dict()

for ai in a:
	dic.setdefault(ai, 0)
	dic[ai] += 1

multiples = set()
upper = 10 ** 6

for k in dic.keys():
  i = 2
  
  while True:
    if k * i <= upper:
      multiples.add(k * i)
      i += 1
    else:
      break

ans = 0

for k, v in dic.items():
  if v == 1:
    if not k in multiples:
      ans += 1

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

import itertools
import numpy as np

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

a=[]
b=[]
c=[]
d=[]

for i in range(q):
    ai, bi, ci, di = list(map(int, input().split()))
    a.append(ai)
    b.append(bi)
    c.append(ci)
    d.append(di)

h = 0
it = itertools.combinations_with_replacement(range(1, m+1), n)
A_list = np.array(list(it))


for A in A_list:
    s = 0
    for i in range(q):
        if A[b[i]-1] - A[a[i]-1] == c[i]:
            s += d[i]
    h = max(h, s)

print(h)
 



### FIXED CODE ###

import itertools

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

a=[]
b=[]
c=[]
d=[]

for i in range(q):
    x = list(map(int, input().split()))
    a.append(x[0])
    b.append(x[1])
    c.append(x[2])
    d.append(x[3])

h = []
A_list = list(itertools.combinations_with_replacement(range(1, m+1), n))


for A in A_list:
    s = 0
    for i in range(q):
        if A[b[i]-1] - A[a[i]-1] == c[i]:
            s += d[i]
    h.append(s)

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

from collections import Counter
a=open(0)
n=int(a.readline())
l=a.read().split()
c=Counter(l)
max_list=[kv[0] for kv in c.items() if kv[1]==max(c.values())]
max_list.sort()
for j in max_list:
  print(j)

### FIXED CODE ###

n = int(input())
s = [input() for _ in range(n)]
d = {}
for w in s:
    if w not in d:
        d[w] = 0
    d[w] += 1
d2 = sorted(d.items(), key=lambda x:x[1], reverse=True)
maxcnts = [w[0] for w in d2 if w[1] == d2[0][1]]
maxcnts.sort()
for ans in maxcnts:
    print(ans)