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

n = int(input())
s = str(input())
r = []
g = []
b = []
for i in range(n):
    if s[i] == "R":
        r.append(i)
    if s[i] == "G":
        g.append(i)
    if s[i] == "B":
        b.append(i)
ans = len(r)*len(g)*len(b)
for i in range(len(r)):
    for j in range(len(g)):
        if max(r[i],g[j])+(abs(r[i]-g[j])) < n:
            if s[max(r[i],g[j])+(abs(r[i]-g[j]))] == "B":
                ans -= 1
        if 0 <= min(r[i],g[j])-(abs(r[i]-g[j])):
            if s[min(r[i],g[j])-(abs(r[i]-g[j]))] == "B":
                ans -= 1
        if abs(r[i]-g[j])%2 == 0:
            if s[(r[i]+g[j])//2] == "B":
                ans -= 1
print(ans)

### FIXED CODE ###

n = int(input())
s = str(input())
r = []
g = []
def right(r,g):
    return (max(r,g)+(abs(r-g)))
def left(r,g):
    return (min(r,g)-(abs(r-g)))
def half(r,g):
    return ((r+g)//2)
for i in range(n):
    if s[i] == "R":
        r.append(i)
    elif s[i] == "G":
        g.append(i)
ans = len(r)*len(g)*(n-(len(r)+len(g)))
for i in range(len(r)):
    for j in range(len(g)):
        t = left(r[i],g[j])
        f = right(r[i],g[j])
        h = half(r[i],g[j])
        if f < n:
            if s[f] == "B":
                ans -= 1
        if 0 <= t:
            if s[t] == "B":
                ans -= 1
        if abs(r[i]-g[j])%2 == 0:
            if s[h] == "B":
                ans -= 1
print(ans)
### BUGGY CODE ###

n,x,m=map(int,input().split())
i=int(2)
a=[x]
q=int(0)
while (i <= n) and (q == 0):
	x=(x**2)%m
	if x in a:
		q=1
	else:
		a.append(x)

if len(a) == n:
	print(sum(a))	
else:
	j=a.index(x)
	b=a[0:j]
	c=a[j:]
	lb=len(b)
	lc=len(c)
	k=(n-lb)%lc
	l=(n-lb)//lc
	d=c[0:k]
	print(sum(b)+sum(c)*l+sum(d))

### FIXED CODE ###

n,x,m=map(int,input().split())
i=int(2)
a=[x]
q=int(0)
while (i <= n) and (q == 0):
	x=(x**2)%m
	if x in a:
		q=1
	else:
		a.append(x)
	i=i+1

if len(a) == n:
	print(sum(a))	
else:
	j=a.index(x)
	b=a[0:j]
	c=a[j:]
	lb=len(b)
	lc=len(c)
	k=(n-lb)%lc
	l=(n-lb)//lc
	d=c[0:k]
	print(sum(b)+sum(c)*l+sum(d))
### BUGGY CODE ###

S = input()
N = len(S)
A = [0] * N

for i in range(N):
    if S[i] == 'R':
        step = S[i:].find('L')
        if step % 2 == 0:
            A[i+step]   += 1
        else:
            A[i+step-1] += 1
    else:
        step = S[:i+1][::-1].find('R')
        if step % 2 == 0:
            A[i-step]   += 1
        else:
            A[i-step+1] += 1

print(' '.join([str(a) for a in A]))


### FIXED CODE ###

S = input()
N = len(S)
A = [0] * N

step_R  = [0] * N
count_R = 1
step_L  = [0] * N
count_L = 1

for i in range(1, N):
    if S[i-1] == 'R':
        if S[i] == 'L':
            for j in range(count_R):
                step_R[i-1-j] = j+1
            count_R  = 1
        else:
            count_R += 1

for i in range(1, N)[::-1]:
    if S[i] == 'L':
        if S[i-1] == 'R':
            for j in range(count_L):
                step_L[i+j] = j+1
            count_L  = 1
        else:
            count_L += 1

steps = [max(step_R[i], step_L[i]) for i in range(N)]

for i in range(N):
    step = steps[i]
    if S[i] == 'R':
        if step % 2 == 0:
            A[i+step]   += 1
        else:
            A[i+step-1] += 1
    else:
        if step % 2 == 0:
            A[i-step]   += 1
        else:
            A[i-step+1] += 1

print(' '.join([str(a) for a in A]))
### BUGGY CODE ###

while 1:
    s = [0 for i in xrange(7)]
    n = input()
    if n==0: break
    for i in xrange(n):
        age = input()
        s[min(6, age/10)] += 1
    for i in xrange(7):
        print s[i]

### FIXED CODE ###

while 1:
    n = input()
    if n==0: break
    s = [0 for i in range(13)]
    for i in range(n):
        s[int(raw_input())/10] += 1
    for i in range(6):
        print s[i]
    print sum(s[6:])
### BUGGY CODE ###

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

dp = [[0] * (n+1) for _ in range(n+1)]

for l in range(1, n+1):
    for i in range(n - l + 1):
        j = i + l
        if (n - l) % 2 == 0:
            dp[i][j] = max(dp[i+1][j] + a[i], dp[i][j-1] + a[j-1])
        else:
            dp[i][j] = min(dp[i+1][j] - a[i], dp[i][j-1] - a[j-1])

print(dp[0][n])


### FIXED CODE ###

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

dp = [[0] * (n+1) for _ in range(n+1)]

for l in range(1, n+1):
    for i in range(n - l + 1):
        j = i + l
        if (n - l) % 2 == 0:
            dp[i][j] = max(dp[i+1][j] + a[i], dp[i][j-1] + a[j-1])
        else:
            dp[i][j] = min(dp[i+1][j] - a[i], dp[i][j-1] - a[j-1])

print(dp[0][n])
### BUGGY CODE ###

S = input()

ans = 0
while S:
    now = S.find("ABC")
    if now == -1:
        break

    num_A = 1
    num_BC = 1
    S1 = S[:now]
    while len(S1) > 0 and S1[-1] == "A":
        num_A += 1
        S1 = S1[:-1]

    S2 = S[now+3:]
    while len(S2) > 0 and S2[0:2] == "BC":
        num_BC += 1
        S2 = S2[2:]

    ans += num_A*num_BC
    S = "A" + S[(now + 2 * num_BC + 1):]

print(ans)

### FIXED CODE ###

S = input()
T = S.replace("BC", "D")
a = 0
ans = 0
for i in T:
    if i == "A":
        a += 1
    elif i == "D":
        ans += a
    else:
        a = 0

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

h, w, k = map(int, input().split())
ori = [list(map(int, list(input()))) for _ in range(h)]
ori.reverse()
ans = 0
for y in range(h - 1):
    for x in range(w):
        data = [[ori[i][j] for j in range(w)] for i in range(h)]
        for i in range(y, h - 1):
            data[i][x] = data[i+1][x]
        data[h-1][x] = 0
        score = 0
        lc = 1
        nxt = True
        while nxt:
            nxt = False
            for i in range(h):
                c = 1
                for j in range(1, w):
                    if data[i][j] != 0 and data[i][j] == data[i][j-1]:
                        c += 1
                    else:
                        if c >= k:
                            nxt = True
                            score += data[i][j-1] * c * lc
                            for l in range(j - c, j):
                                data[i][l] = 0
                        c = 1
                if c >= k:
                    nxt = True
                    score += data[i][w-1] * c * lc
                    for l in range(w - c, w):
                        data[i][l] = 0
            for j in range(w):
                z = 0
                for i in range(h):
                    if data[i][j] == 0:
                        z += 1
                    elif z > 0:
                        data[i-z][j] = data[i][j]
                        data[i][j] = 0
            lc *= 2
        ans = max(ans, score)
print(ans)

### FIXED CODE ###

from sys import setrecursionlimit, exit
setrecursionlimit(1000000000)

from heapq import heapify, heappush, heappop, heappushpop, heapreplace
from bisect import bisect_left, bisect_right

from math import atan, degrees

h, w, k = map(int, input().split())
ori = [list(map(int, list(input()))) for _ in range(h)]
ori.reverse()
ans = 0
for x in range(w):
    for y in range(h - 1):
        data = [[ori[i][j] for j in range(w)] for i in range(h)]
        for i in range(y, h - 1):
            data[i][x] = data[i+1][x]
        data[h-1][x] = 0
        score = 0
        lc = 1
        nxt = True
        while nxt:
            nxt = False
            for i in range(h):
                c = 1
                for j in range(1, w):
                    if data[i][j] != 0 and data[i][j] == data[i][j-1]:
                        c += 1
                    else:
                        if c >= k:
                            nxt = True
                            score += data[i][j-1] * c * lc
                            for l in range(j - c, j):
                                data[i][l] = 0
                        c = 1
                if c >= k:
                    nxt = True
                    score += data[i][w-1] * c * lc
                    for l in range(w - c, w):
                        data[i][l] = 0
            for j in range(w):
                z = 0
                for i in range(h):
                    if data[i][j] == 0:
                        z += 1
                    elif z > 0:
                        data[i-z][j] = data[i][j]
                        data[i][j] = 0
            lc *= 2
        ans = max(ans, score)
        if score == 0:
            break
print(ans)
### BUGGY CODE ###

n=int(input())
s=[list(map(int,input().split()))for i in range(3)]
c=0
for i in range(n):
    p=s[2][i]
    q=[j for j in s[1] if j<p]
    f=[j for j in s[0] if j<p]
    for a in range(len(q)):
        r=q[a]
        t=[j for j in f if j<r]
        c+=len(t)
print(c)

### FIXED CODE ###

n=int(input())
s=[list(map(int,input().split()))for i in range(3)]
s[0].sort()
s[1].sort()
s[2].sort()
c,d,e=0,0,0
for i in range(n):
    while d<n and s[0][d]<s[1][i]:
        d+=1
    while e<n and s[2][e]<=s[1][i]:
        e+=1
    c+=d*(n-e)
print(c)
### BUGGY CODE ###

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

b = []

i = 1
max = 10**9
while True:
    t = 2**i
    if t < max:
        b.append(t)
    else:
        break
    i = i+1

a.sort(reverse=True)
#print(a)

sum = 0
i = 0
while True:

    t = 0
    for bb in b :
        if bb > a[i]:
            t = bb - a[i]
            break
    
    if a[i+1:].count(t) > 0:
        sum += 1
        a.remove(t)

    i = i + 1
    if i >= len(a):
        break

print(sum)

### FIXED CODE ###

from bisect  import bisect_left

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

sum = 0
for i in range (len(a)-1,-1,-1):

    b = 1
    while b <= a[i]:
        b = b<<1
    t = b - a[i]
    #print("2^",t)

    k = bisect_left(a,t)
    if a[k] == t and k < i:
        sum += 1
        a[k] -= 0.1
        a[i] += 0.1
print(sum)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = 1
lim = 10**18
for i in range(n):
	ans = ans * a[i]

if ans > lim:
	print(-1)
else:
	print(ans)

### FIXED CODE ###

import sys
n = int(input())
a = list(map(int,input().split()))
ans = 1

if 0 in a:
	print(0)
	sys.exit()

for i in range(n):
	ans = ans * a[i]
	if ans > 1000000000000000000:
		print(-1)
		sys.exit()

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

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
L = [tuple(map(int, input().split())) for _ in range(M)]

L.sort(key=lambda x: x[1], reverse=True)

flag = True
num = 0
while flag:
    if num >= M:
        break

    for i in range(L[num][0]):
        if L[num][1] > A[0]:
            A[0] = L[num][1]
            A.sort()
        else:
            flag = False
            break
    num += 1

print(sum(A))



### FIXED CODE ###

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
L = [tuple(map(int, input().split())) for _ in range(M)]

L.sort(key=lambda x: x[1], reverse=True)

flag = True
num = 0
now = 0
while flag:
    if num >= M:
        break
    for i in range(L[num][0]):
        if now < N and L[num][1] > A[now]:
            A[now] = L[num][1]
            now += 1
        else:
            flag = False
            break
    num += 1
print(sum(A))
### BUGGY CODE ###

from  collections import deque

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

#Que = [list(map(str, input().split())) for _ in range(Q)]

deque_S = deque(S)
re_flag = 1
for i in range(Q):
    que = str(input())

    if len(que) == 1:
        #S = S[::-1]
        re_flag *= -1

    else:
        if que[2] == '1':
            if re_flag == 1:
                #S = que[4:] + S
                deque_S.appendleft(que[4:])
            else:
                #S =  S + que[-1:3:-1]
                deque_S.append(que[-1:3:-1])
        if que[2] == '2':
            if re_flag == 1:
                #S = S + que[4:]
                deque_S.append(que[4:])
            else:
                #S = que[-1:3:-1] + S
                deque_S.appendleft(que[-1:3:-1])

ans = ''
if re_flag == 1:
    for i in range(len(deque_S)):
        ans += deque_S[i]
else:
    for i in reversed(range(len(deque_S))):
        ans += deque_S[i][::-1]
#print(deque_S)

print(ans)

### FIXED CODE ###

from  collections import deque

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

#Que = [list(map(str, input().split())) for _ in range(Q)]

deque_S = deque(S)
re_flag = 1
for i in range(Q):
    que = str(input())

    if len(que) == 1:
        #S = S[::-1]
        re_flag *= -1

    else:
        if que[2] == '1':
            if re_flag == 1:
                #S = que[4:] + S
                deque_S.appendleft(que[4:])
            else:
                #S =  S + que[-1:3:-1]
                deque_S.append(que[-1:3:-1])
        if que[2] == '2':
            if re_flag == 1:
                #S = S + que[4:]
                deque_S.append(que[4:])
            else:
                #S = que[-1:3:-1] + S
                deque_S.appendleft(que[-1:3:-1])

ans = ''
if re_flag == 1:
    ans = ''.join(deque_S)
else:
    ans = ''.join(deque_S)[::-1]
#print(deque_S)

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

from math import gcd

k = int(input())
l = [[[0] * (k + 1) for i in range(k + 1)] for j in range(k + 1)]
ans = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        for c in range(1, k + 1):
            mn, mx = min(a, b, c), max(a, b, c)
            mi = a + b + c - mn - mx
            if l[a][b][c]:
                ans += l[a][b][c]
                continue
            else:
                ans += gcd(gcd(a, b), c)
print(ans)

### FIXED CODE ###

from math import gcd

k = int(input())
l = [[[0] * (k + 1) for i in range(k + 1)] for j in range(k + 1)]
ans = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        for c in range(1, k + 1):
            mn, mx = min(a, b, c), max(a, b, c)
            mi = a + b + c - mn - mx
            if l[a][b][c]:
                ans += l[a][b][c]
                continue
            else:
                ans += gcd(gcd(a, b), c)
print(ans)
### BUGGY CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, T = MAP()
A = LIST()
B = [max(A[i+1:N])-A[i] for i in range(N-1)]
# print(B)
print(B.count(max(B)))

### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, T = MAP()
A = LIST()
# B = [max(A[i+1:N])-A[i] for i in range(N-1)] # O(N^2)時間かかる
# print(B)
min_ = INF
B = []
for i in A:
	B.append(i-min_)
	# print(min_)
	if min_ > i:
		min_ = i
# print(B)
print(B.count(max(B)))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 6)

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

edges = [[] for _ in range(N)]

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

counter = [0] * N
checked = [False] * N

for i in range(Q):
    p, x = map(int, input().split())
    counter[p - 1] += x

def process(root):
    checked[root] = True
    for e in edges[root]:
        if checked[e] == False:
            counter[e] += counter[root]
            process(e)

process(0)

print(" ".join(map(str, counter)))

### FIXED CODE ###

from collections import deque

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

edges = [[] for _ in range(N)]

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

counter = [0] * N
checked = [False] * N

for i in range(Q):
    p, x = map(int, input().split())
    counter[p - 1] += x

queue = deque()
queue.append(0)

while queue:
    root = queue.pop()
    checked[root] = True
    for e in edges[root]:
        if checked[e] == False:
            queue.append(e)
            counter[e] += counter[root]

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

from operator import mul
from functools import reduce

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

MOD = 10 ** 9 + 7
N, K = map(int, input().split())
if K == 1:
    print(0)
    exit()

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

N = len(A)
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    factinv.append((factinv[-1] * inv[-1]) % MOD)

ans = 0
sum_num = 0
for i in range(N - (K - 1)):
    for j in range(i+K-1, N):
        ans += (A[j] - A[i]) * cmb(j-i-1, K-2, MOD) % MOD
print(ans % MOD)


### FIXED CODE ###

MOD = 10 ** 9 + 7

def ncr(n, r, mod=MOD):
    return (fct[n] * invf[r] * invf[n - r]) % mod


def make_tables(n, mod=MOD):
    fct = [1 for _ in range(n + 1)]
    invf = [1 for _ in range(n + 1)]

    for i in range(2, n + 1):
        fct[i] = (fct[i - 1] * i) % mod
        invf[i] = divmod(fct[i])
    return fct, invf


def divmod(a, mod=MOD):
    return pow(a, mod - 2, mod)


N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))
for i in range(N):
    A[i] %= MOD

fct, invf = make_tables(N, mod=MOD)

ans = 0
for i in range(N - K + 1):
    ans += ((A[-1-i] - A[i]) % MOD * ncr(N - i - 1, K - 1)) % MOD
print(ans % MOD)
### BUGGY CODE ###

import sys
def input(): return sys.stdin.readline().strip()
n=int(input())
aa=[]
for i in range(n):
    aa.append(int(input()))
bb=[]
for i in range(n):
    if not bb:
        bb.append(aa[i])
    else:
        if bb[0] > aa[i]:
            bb.append(aa[i])
            bb = sorted(bb)
        else:
            for j in range(len(bb)):
                if bb[-(j+1)] < aa[i]:
                    bb[-(j+1)] = aa[i]
                    bb = sorted(bb)
                    break
            else:
                bb = [aa[i]] + bb
print(len(bb))

### FIXED CODE ###

import sys
aa=list(map(int,sys.stdin.read().split()))
aa=aa[1:aa[0]+1]
n=len(aa)
import bisect
bb=[]
for i in range(n):
    if not bb:
        bb.append(aa[-i-1])
    else:
        if bb[-1] <= aa[-i-1]:
            bb.append(aa[-i-1])
        else:
            j = bisect.bisect_right(bb,aa[-i-1])
            bb[j] = aa[-i-1]
print(len(bb))
### BUGGY CODE ###

import numpy as np

H, W = map(int, input().split())
S_arr = []
for _ in range(H):
    S_arr.append(list(input()))

point_arr = np.zeros((H, W))

x = 0
start = 0
stop = W
for y in range(H):
    start = 0
    stop = W
    for x in range(W):
        if S_arr[y][x] == "#":
            stop = x
            point_arr[y, start:stop] += stop - start
            start = stop + 1
    point_arr[y, start:W] += W - start
    

for x in range(W):
    start = 0
    stop = H
    for y in range(H):
        if S_arr[y][x] == "#":
            stop = y
            point_arr[start:stop, x] += stop - start
            start = stop + 1
    point_arr[start:H, x] += H - start

print(int(np.max(point_arr))-1)

### FIXED CODE ###

#   ABC129　D問題
H, W = map(int, input().split())    #   1 <= H, W <= 2000
S_arr = []
for _ in range(H):
    S_arr.append(list(input()))

point_arr = [[0]*W for _ in range(H)]

start = 0
stop = W
for y in range(H):
    start = 0
    stop = W
    for x in range(W):
        if S_arr[y][x] == "#":
            stop = x
            for i in range(start, stop):
                point_arr[y][i] += stop - start
            start = stop + 1
    for i in range(start, W):
        point_arr[y][i] += W - start


for x in range(W):  #   コードのコピペ禁止の原則に違反してるけど、改善方法が思いつかない問題
    start = 0
    stop = H
    for y in range(H):
        if S_arr[y][x] == "#":
            stop = y
            for i in range(start, stop):
                point_arr[i][x] += stop - start
            start = stop + 1
    for i in range(start, H):
        point_arr[i][x] += H - start

ans = 0
for i in range(H):
    for j in range(W):
        if ans < point_arr[i][j]:
            ans = point_arr[i][j]
ans -= 1
print(ans)
#   O(H*W)程度の計算量で十分高速だと思ってたのに、そうでもない問題
#   2019/06/10 現在未解決　PyPy使ったらどうなるのかやってみた。Numpy含まれてるからランタイムエラーになるのだろうか？
### BUGGY CODE ###

def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

n = inp()
m = int(n)

ans = 0

for i in range(len(n)):
    ans += (m % 10)
    m //= 10

ans %= 9

if ans == 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

n = inp()
m = int(n)

ans = 0

for i in range(len(n)):
    ans += int(n[i])

ans %= 9

if ans == 0:
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

N,M=map(int, input().split())
a=[int(i) for i in input().split()]
a.sort()

for i in range(M):
    B,C=map(int, input().split())
    for j in range(B):
        if a[j]<C:
            a[j]=C   
    a.sort()
#    print(a)

print(sum(a))

### FIXED CODE ###

N,M = map(int, input().split())
a = [int(i) for i in input().split()]
c = [[int(i) for i in input().split()] for j in range(M)]

a.sort()
c2=sorted(c,key=lambda x:(-int(x[1])))

d = []
for i in range(M):
    for j in range(c2[i][0]):
        d.append(c2[i][1])
        if len(d) == N:
            break
    else:
        continue
    break

i = 0
while a[i] < d[i]:
    a[i] = d[i]
    i += 1
    if i == N or i == len(d):
        break

print(sum(a))
### BUGGY CODE ###

from operator import itemgetter
import datetime

n = int(input())
sn = []
cntlist = []

for i in range(n):
    s = input()
    for j in sn:
        if(j[0] == s):
            j[1] += 1
            break
    else:
        sn.append([s,1])
        continue

sn.sort(key=itemgetter(1))
#sn.sort(key=cntlist)
sn.reverse()
#print(sn)

cnt = sn[0][1]
for i in sn:
    if(int(i[1]) == cnt):
        print(i[0])
        continue
    else:
        break


### FIXED CODE ###

from operator import itemgetter
import datetime

n = int(input())
sn = dict()

for i in range(n):
    s = input()
    if(s in sn):
        sn[s] += 1
    else:
        sn[s] = 1

sn = sorted(sn.items(), key=lambda x:(-x[1],x[0]))
#print(sn)

max_val = max(dict(sn).values())

for si in sn:
    if(int(si[1]) == max_val):
        print(si[0])
    else:
        break