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

from collections import deque
H, W, M = map(int, input().split())
bomb = []
counth = deque([0 for k in range(H)])
countw = deque([0 for k in range(W)])
for k in range(M):
  h, w = map(int, input().split())
  h -= 1
  w -= 1
  bomb.append([h, w])
  counth[h] += 1 
  countw[w] += 1

maxh = max(counth)
maxw = max(countw)
index_h = deque([])
index_w = []
k = 0
while k < H:
  h = counth.popleft()
  if h == maxh:
    index_h.append(k)
  k += 1
k = 0
while k < W:
  w = countw.popleft()
  if w == maxw:
    index_w.append(k)
  k += 1
ans = maxh + maxw - 1
lenh = len(index_h)
lenw = len(index_w)

if lenh*lenw > M:
  ans += 1
else:  
  for i in range(lenh):
    h = index_h.pop()
    for j in range(lenw):
      w = index_w[j]
      if [h, w] not in bomb:
        ans += 1
        break
    else:
      continue
    break
print(ans)

### FIXED CODE ###

from collections import deque
H, W, M = map(int, input().split())
bomb = []
counth = [0 for k in range(H)]
countw = [0 for k in range(W)]
for k in range(M):
  h, w = map(int, input().split())
  h -= 1
  w -= 1
  bomb.append(h+ w*H)
  counth[h] += 1 
  countw[w] += 1
counth = deque(counth)
countw = deque(countw)

def binary_search(list, item):
    low = 0
    high = len(list) - 1

    while low <= high:
        mid = (low + high) //2
        guess = list[mid]
        if guess == item:
            #return mid
            return True
        if guess > item:
            high = mid -1
        else:
            low = mid + 1

    #return None
    return False


maxh = max(counth)
maxw = max(countw)
index_h = deque([])
index_w = []
for k in range(H):
  h = counth.popleft()
  if h == maxh:
    index_h.append(k)

for k in range(W):
  w = countw.popleft()
  if w == maxw:
    index_w.append(k)

ans = maxh + maxw - 1
lenh = len(index_h)
lenw = len(index_w)


if lenh*lenw > M:
  ans += 1
else:
  bomb.sort()
  kouho = []
  for i in range(lenh):
    h = index_h.pop()
    for j in range(lenw):
      w = index_w[j]
      kouho.append(h+ H*w)
  for K in kouho:
    if binary_search(bomb, K):
      continue
    else:
      ans += 1
      break
    
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N, K = map(int, input().split())
h = list(map(int, input().split()))
init = 10**9
dp = [init] * N
dp[0] = 0

for i in range(1, N):
    if i - K < 0:
        dp[i] = min(dpk + abs(h[i]-hk) for dpk, hk in zip(dp[:i], h[:i]))
    else:
        dp[i] = min(dpk + abs(h[i]-hk) for dpk, hk in zip(dp[i-K:i], h[i-K:i]))

print(dp[-1])

### FIXED CODE ###

import sys
input = sys.stdin.readline

N, K = map(int, input().split())
h = [int(x) for x in input().split()]
dp = [0] * N

for i, hi in enumerate(h):
    if i == 0:
        continue
    if i - K < 0:
        dp[i] = min(dpk + abs(hi-hk) for dpk, hk in zip(dp[:i], h[:i]))
    else:
        dp[i] = min(dpk + abs(hi-hk) for dpk, hk in zip(dp[i-K:i], h[i-K:i]))

print(dp[-1])
### BUGGY CODE ###

import collections
S = input()
N = len(S)
M = [0]
mod = 0
ten = 1
for s in S[::-1]:
  mod += (int(s) * ten) % 2019
  mod %= 2019
  M.append(mod)
  ten *= 10
count = collections.Counter(M)
print(sum([c*(c-1)//2 for c in count.values()]))

### FIXED CODE ###

import collections
S = input()
N = len(S)
M = [0]
mod = 0
ten = 1
for s in S[::-1]:
  mod += (int(s) * ten) % 2019
  mod %= 2019
  M.append(mod)
  ten *= 10
  ten %= 2019 
count = collections.Counter(M)
print(sum([c*(c-1)//2 for c in count.values()]))
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
D={}
ans=""
M=0
for i in range(N):
    if N//(N-i)==1:
        a=A[N-i-1]
        D[N-i]=a
        if a==1:
            M+=1
            ans=ans+str(N-i)+" "
    else:
        a=N//(N-i)
        memo=0
        for j in range(1,a):
            memo+=D[(N-i)*(j+1)]
        if memo%2==A[N-i-1]:
            D[N-i]=0
        else:
            D[N-i]=1
            M+=1
            ans=ans+str(N-i)+" "
ans=ans[:-1]
print(M)
print(ans)

### FIXED CODE ###

from collections import deque
N=int(input())
A=deque(list(map(int,input().split())))
D={}
ans=[]
M=0
for i in range(N):
    a=A.pop()
    if N//(N-i)==1:
        D[N-i]=a
        if a==1:
            M+=1
            ans.append(str(N-i))
    else:
        p=N//(N-i)
        memo=0
        for j in range(1,p):
            memo+=D[(N-i)*(j+1)]
        if memo%2==a:
            D[N-i]=0
        else:
            D[N-i]=1
            M+=1
            ans.append(str(N-i))
print(M)
print(" ".join(ans))
### BUGGY CODE ###

N, strings, answers = int(input()), [], []
for x in range(N):
    string = input()
    strings.append(string)
max_char = strings.count(max(strings, key=strings.count))
for x in strings:
    if strings.count(x) == max_char:
        answers.append(x)
for x in sorted(set(answers), key=str.lower):
    print(x)

### FIXED CODE ###

from collections import defaultdict
from collections import OrderedDict
N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k]+=1
    else:
        ans.update({k:1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)
### BUGGY CODE ###

import fractions


k = int(input())
cache = dict()

def gcd(l):
    if tuple(sorted(l)) in cache:
        return cache[tuple(sorted(l))]
    ans = l[0]
    for i in range(1, len(l)):
        ans = fractions.gcd(ans, l[i])
    cache[tuple(sorted(l))] = ans
    return ans

res = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            res += gcd([a, b, c])
print(res)



### FIXED CODE ###

import fractions


k = int(input())

def gcd(p, q):
    if p % q == 0: return q
    return gcd(q, p % q)

res = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            res += gcd(gcd(a, b), c)
print(res)
### BUGGY CODE ###

N, D, A = map(int, input().split())
monster = []
for k in range(N):
  monster.append(list(map(int, input().split())))
monster.sort(key = lambda x: x[0])
ans = 0
while len(monster) > 0:
  if monster[0][1] > 0:
    nowx = monster[0][0]
    damage = ((monster[0][1]-0.1)//A)*A + A
    ans += int((monster[0][1]-0.1)//A + 1)
    j = 0
    while(j<len(monster)):
      if monster[j][0] <= nowx + 2*D:
        monster[j][1] -= damage
        if monster[j][1] > 0:
          j += 1
        else:
          del monster[j]
        continue
      else:
        break

print(ans)

### FIXED CODE ###

N, D, A = map(int, input().split())
monster = []
for k in range(N):
  monster.append(list(map(int, input().split())))
monster.sort(key = lambda x: x[0])
for k in range(N):
  monster[k][1] = int((monster[k][1]-0.1)//A + 1)
ans = 0
"""
k = 0
while k < len(monster):
  if monster[k][1] > 0:
    nowx = monster[k][0]
    damage = monster[k][1]
    ans += monster[k][1]
    j = 0 + k
    nextk = N
    while(j +1 < len(monster)):
      j += 1
      if monster[j][0] <= nowx + 2*D:
        monster[j][1] -= damage
        if monster[j][1] > 0:
          nextk = min(j, nextk)
          continue
      else:
        nextk = min(nextk, j)
        break
    k = nextk
"""
final = monster[-1][0]
ruiseki = 0
minuslist = []
j = 0
for k in range(N):
  while (j < len(minuslist)):
    if monster[k][0] >= minuslist[j][0]:
      ruiseki -= minuslist[j][1]
      j += 1
    else:
      break
  if ruiseki < monster[k][1]:
    ans += monster[k][1] - ruiseki
    if monster[k][0] + 2*D +1 <= final:
      minuslist.append([monster[k][0]+2*D+1, monster[k][1] - ruiseki])
    ruiseki = monster[k][1]


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

import itertools
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

H, W, N = list(map(int, sys.stdin.readline().split()))
AB = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]

hist = set()


def count(h, w):
    ret = 0
    for dh, dw in itertools.product([-1, 0, 1], repeat=2):
        ret += (h + dh, w + dw) in hist
    return ret


def ok(a=1, b=1):
    return 1 < a < H and 1 < b < W


ans = [0] * 10
ans[0] = (H - 2) * (W - 2)
for a, b in AB:
    hist.add((a, b))
    for dh, dw in itertools.product([-1, 0, 1], repeat=2):
        if not ok(a + dh, b + dw):
            continue
        c = count(a + dh, b + dw)
        ans[c] += 1
        ans[c - 1] -= 1
print('\n'.join(map(str, ans)))


### FIXED CODE ###

import itertools
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

H, W, N = list(map(int, sys.stdin.readline().split()))
AB = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]

hist = set()


def count(h, w):
    ret = 0
    for dh, dw in itertools.product([-1, 0, 1], repeat=2):
        ret += (h + dh, w + dw) in hist
    return ret


def ok(a=1, b=1):
    return 1 < a < H and 1 < b < W


ans = [0] * 10
ans[0] = (H - 2) * (W - 2)
for a, b in AB:
    hist.add((a, b))
    for dh, dw in itertools.product([-1, 0, 1], repeat=2):
        if not ok(a + dh, b + dw):
            continue
        c = count(a + dh, b + dw)
        ans[c] += 1
        ans[c - 1] -= 1
print('\n'.join(map(str, ans)))
### BUGGY CODE ###

#### import ####
import sys
sys.setrecursionlimit(10**7)
import math
from collections import defaultdict

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

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

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

N = I()
A = [0]*N
for i in range(N):
  A[i] = I()
  
A.sort()
A2 = A[:]

temp = A.pop(0)
B = [temp]
for i in range(math.ceil((N-1)/2)):
  if i%2==0:
    temp = A.pop(len(A)-1)
    B.insert(0,temp)
    if len(A)>0:
      temp = A.pop(0)
      B.insert(0,temp)
  else:
    temp = A.pop(len(A)-1)
    B.append(temp)
    if len(A)>0:
      temp = A.pop(0)
      B.append(temp)

temp = A2.pop(N-1)
B2 = [temp]
for i in range(math.ceil((N-1)/2)):
  if i%2==0:
    temp = A2.pop(0)
    B2.insert(0,temp)
    if len(A2)>0:
      temp = A2.pop(len(A2)-1)
      B2.insert(0,temp)
  else:
    temp = A2.pop(0)
    B2.append(temp)
    if len(A2)>0:
      temp = A2.pop(len(A2)-1)
      B2.append(temp)

val1 = 0
val2 = 0
for i in range(N-1):
  val1 += abs(B[i]-B[i+1])
  val2 += abs(B2[i]-B2[i+1])
  
print(max(val1,val2))

### FIXED CODE ###

#### import ####
import sys
sys.setrecursionlimit(10**7)
import math
from collections import defaultdict

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

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

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

from collections import deque

N = I()
tempA = [0]*N
for i in range(N):
  tempA[i] = I()
  
tempA.sort()
A = deque(maxlen=N)
for i in range(N):
  A.append(tempA[i])
A2 = tempA[:]


temp = A.popleft()
B = deque(maxlen=N)
B.append(temp)
for i in range(math.ceil((N-1)/2)):
  if i%2==0:
    temp = A.pop()
    B.appendleft(temp)
    if len(A)>0:
      temp = A.popleft()
      B.appendleft(temp)
  else:
    temp = A.pop()
    B.append(temp)
    if len(A)>0:
      temp = A.popleft()
      B.append(temp)

val1 = 0
val2 = val1
for i in range(N-1):
  val1 += abs(B[i]-B[i+1])

if N%2==1:
  val2 = val1-abs(A2[(N-1)//2]-A2[(N-1)//2+1])+abs(A2[(N-1)//2]-A2[(N-1)//2-1])
print(max(val1,val2))
### BUGGY CODE ###

a,b,q = list(map(int,input().split()))
s = [int(input()) for i in range(0,a)]
t = [int(input()) for i in range(0,b)]
x = [int(input()) for i in range(0,q)]

s.sort()
t.sort()

def bifind(r,z):
    low = 0
    high = len(r)-1
    y = (low + high)//2
    if z < r[0]:
        return [r[0],r[0]]
    elif z > r[-1]:
        return [r[-1],r[-1]]
    while True:
        if r[y] <= z:
            low = y
            y = (y+high)//2
        else:
            high = y
            y = (low + y)//2
        if r[y] < z < r[y+1]:
            break
    return [r[y],r[y+1]]

for i in range(0,q):
    ls = bifind(s,x[i])
    lt = bifind(t,x[i])
    ans = list()
    for j in range(0,2):
        for k in range(0,2):
            ans.append(abs(ls[j]-x[i])+abs(lt[k]-ls[j]))
            ans.append(abs(lt[k]-x[i])+abs(lt[k]-ls[j]))
    print(min(ans))

### FIXED CODE ###

a,b,q = list(map(int,input().split()))
s = [int(input()) for i in range(0,a)]
t = [int(input()) for i in range(0,b)]
x = [int(input()) for i in range(0,q)]
import bisect

def bifind(r,z):
    if z < r[0]:
        return [r[0],r[0]]
    elif z > r[-1]:
        return [r[-1],r[-1]]
    y = bisect.bisect_left(r,z)-1
    return [r[y],r[y+1]]

for i in range(0,q):
    ls = bifind(s,x[i])
    lt = bifind(t,x[i])
    ans = list()
    for j in range(0,2):
        for k in range(0,2):
            ans.append(abs(ls[j]-x[i])+abs(lt[k]-ls[j]))
            ans.append(abs(lt[k]-x[i])+abs(lt[k]-ls[j]))
    print(min(ans))
### BUGGY CODE ###

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

A = [int(input()) for _ in range(Q)]

P = [K for _ in range(N)]

for i in range(Q):
    ans = A[i]
    for k in range(N):
        P[k] -= 1
    P[ans-1] += 1

for i in range(N):
    if P[i] > 0:
        print('Yes')

    else:
        print('No')

### FIXED CODE ###

N,K,Q = map(int, input().split())
P = [0 for _ in range(N)]
for q in range(Q):
    num = int(input())
    P[num - 1] += 1

val = K - Q
if val > 0:
    for i in range(N):
        print('Yes')
else:
    standard = abs(val) + 1
    for i in range(N):
        if P[i] >= standard:
            print('Yes')

        else:
            print('No')
### BUGGY CODE ###

import sys

N = int(sys.stdin.readline().rstrip())
S = sys.stdin.readline().rstrip()

if len(set(S)) == 1 or N < 3:
    print(0)
    sys.exit()

ans = 0
for i in range(N - 2):
    a = S[i]
    for j in range(i + 1, N - 1):
        b = S[j]
        if a == b:
            continue
        jtoi = j - i
        for k in range(j + 1, N):
            c = S[k]
            if a == c or b == c:
                continue
            ktoj = k - j
            if jtoi != ktoj:
                ans += 1

print(ans)

### FIXED CODE ###

import sys

N = int(sys.stdin.readline().rstrip())
S = sys.stdin.readline().rstrip()

if len(set(S)) == 1 or N < 3:
    print(0)
    sys.exit()

Rs = S.count("R")
Gs = S.count("G")
Bs = S.count("B")
ans = Rs * Gs * Bs


for i in range(N - 1):
    for j in range(i + 1, N):
        k = j + (j - i)
        if k >= N: break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ans -= 1
print(ans)
### BUGGY CODE ###

INF = 10 ** 9

def main():
    H, N = map(int, input().split())
    dp = [INF] * (H+1)
    dp[0] = 0
    for _ in range(N):
        a, b = map(int, input().split())
        for j in range(H):
            nj = min(j+a, H)
            dp[nj] = min(dp[nj], dp[j]+b)

    print(dp[H])

    
if __name__ == "__main__":
    main()

### FIXED CODE ###

INF = 10 ** 9

def main():
    H, N = map(int, input().split())
    dp = [INF] * (H+1)
    dp[0] = 0
    for _ in range(N):
        a, b = map(int, input().split())
        for j in range(H):
            nj = min(j+a, H)
            dp[nj] = min(dp[nj], dp[j]+b)

    print(dp[H])

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

S = input()
n = len(S)
while S.find('01') >= 0 or S.find('10') >= 0:
    S = S.replace('01', '').replace('10', '')
    S = S.replace('10', '').replace('01', '')
print(n - len(S))

### FIXED CODE ###

S = input()
lst1 = sum([1 for x in S if x == '1'])
lst2 = sum([1 for x in S if x == '0'])
print(min(lst1, lst2) * 2)
### BUGGY CODE ###

N = int(input())

def cal(i):
    count = 0
    x=1
    y=1
    z=1
    tmpx=1
    tmpy=1
    tmpz=1
    while(True):
        ycount=0
        while(True):
            zcount=0
            while(True):
                ans = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if (ans == i):
                    if ((100*x +10*y + z) % 111 == 0):
                        count+=1
                    else:
                        count+=3
                elif (ans > i):
                    break
                z += 1
                zcount+=1

            tmpz+=1
            z=tmpz
            if (zcount == 0):
                break
            y += 1
            ycount+=1

        tmpy+=1
        y = tmpy
        tmpz = tmpy
        z = tmpz
        if (ycount == 0):
            break
        x += 1

    return count

def main():
    for i in range(1, N+1):
        print(cal(i))

if __name__ == '__main__':
    main()

### FIXED CODE ###

n = int(input())

def main():
    ans = [0]*(n+1)
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                fn = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if fn > n:
                    break
                else:
                    ans[fn] += 1

    for i in range(1, n+1):
        print(ans[i])

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

import numpy as np
import sys

input = sys.stdin.readline

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

direction = [[0,1],[0,-1],[1,0],[-1,0]]
black = np.zeros((H,W))
que = []
for i in range(H):
  for j in range(W):
    if G[i][j] == '#':
      que.append([i,j])
      black[i][j] = 0
def main():
  while que:
    nh, nw = que.pop(0)
    for dh, dw in direction:
      if nh+dh<0 or nh+dh>H-1 or nw+dw<0 or nw+dw>W-1:
        continue
      if black[nh+dh][nw+dw] > 0:
        continue
      que.append([nh+dh,nw+dw])
      black[nh+dh][nw+dw] = black[nh][nw]+1
  print(int(np.max(black)))

if __name__ == "__main__":
  main()

### FIXED CODE ###

import copy
from collections import deque
def main():
  H, W = map(int, input().split())
  G = [['#' == x for x in input()] for _ in range(H)]
 
  black = deque([(i, j) for i in range(H) for j in range(W) if G[i][j]])
 
  ans = 0
  while True:
    ans += 1
    next_black = deque()
    while black:
      bi, bj = black.popleft()
      if bi > 0 and not G[bi - 1][bj]:
        G[bi - 1][bj] = True
        next_black.append((bi - 1, bj))
      if bj > 0 and not G[bi][bj - 1]:
        G[bi][bj - 1] = True
        next_black.append((bi, bj - 1))
      if bi < H - 1 and not G[bi + 1][bj]:
        G[bi + 1][bj] = True
        next_black.append((bi + 1, bj))
      if bj < W - 1 and not G[bi][bj + 1]:
        G[bi][bj + 1] = True
        next_black.append((bi, bj + 1))
    if next_black:
       black = copy.copy(next_black)
    else:
       break
  print(ans - 1)
  
if __name__ == "__main__":
  main()
### BUGGY CODE ###

import bisect

N = int(input())
A = [int(i) for i in input().split(' ')]
B = [int(i) for i in input().split(' ')]
C = [int(i) for i in input().split(' ')]

A.sort()
B.sort()
C.sort()

count = 0
for a in A:
    i = bisect.bisect_right(B,a)
    for b in B[i::]:
        j = bisect.bisect_right(C,b)
        count += len(C[j::])
        
print(count)

### FIXED CODE ###

import bisect

N = int(input())
A = [int(i) for i in input().split(' ')]
B = [int(i) for i in input().split(' ')]
C = [int(i) for i in input().split(' ')]

A.sort()
B.sort()
C.sort()

count = 0
for b in B:
    i = bisect.bisect_left(A,b)
    j = bisect.bisect_right(C,b)
    count += i * (N - j)

print(count)
### BUGGY CODE ###

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

ans = 1
cnt = 1
for i in range(max(D)+1):
    if D[0] != 0 or i not in D:
        ans = 0
        break
    else:
        ans = ans * (cnt ** D.count(i)) % 998244353
        cnt = D.count(i)

print(ans)


### FIXED CODE ###

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


if D[0] != 0 or 0 in D[1:]:
    ans = 0
else:
    num = [0 for i in range(max(D)+1)]
    ans = 1
    cnt = 1
    for i in range(n):
        num[D[i]] += 1
    for i in range(len(num)):
        ans = ans * (cnt ** num[i]) % 998244353
        cnt = num[i]

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

import sys

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
B = []
ans = 0
for i in A:
    B.append(list(bin(i)[2:]))
C = [0 for i in range(60)]
for i in B:
    for l in range(len(i)):
        if i[-(l+1)] == '1':
            C[l] += 1
for i in range(60):
    ans = (ans + C[i]*(N-C[i])*(2**i))%(10**9+7)
print(ans)

### FIXED CODE ###

import sys
mod = 10**9+7
N = int(sys.stdin.readline())
A = tuple(map(int, sys.stdin.readline().split()))
B = []
ans = 0
C = [0 for i in range(60)]
for i in A:
    for l in range(60):
        if ((i >> l) & 1) == 1:
            C[l] += 1
for i in range(60):
    t = C[i]
    ans = (ans + t*(N-t)*(2**i)) % mod
print(ans)
### BUGGY CODE ###

from collections import Counter
n=int(input())
a=[list(input()) for _ in range(n)]
count=0
for i in range(n):
  for j in range(i+1,n):
    if Counter(a[i])==Counter(a[j]):
      count+=1
print(count)

### FIXED CODE ###

from collections import Counter
n=int(input())
s=[]
for _ in range(n):
    temp=sorted(list(input()))
    s.append("".join(temp))
s_count=Counter(s)
ans=0
for i in s_count:
    ans+=((s_count[i])*(s_count[i]-1))//2
print(ans)
### BUGGY CODE ###

N=int(input())
a=[0]+list(map(int,input().split()))+[0]
cost=[]
for i in range(N+1):
        cost.append(abs(a[i+1]-a[i]))
for i in range(N):
    print(sum(cost)-cost[i]-cost[i+1]+abs(a[i+2]-a[i]))

### FIXED CODE ###

N=int(input())
a=[0]+list(map(int,input().split()))+[0]
cost=[]
for i in range(N+1):
    cost.append(abs(a[i+1]-a[i]))
S = sum(cost)
for i in range(N):
    print(S-cost[i]-cost[i+1]+abs(a[i+2]-a[i]))
### BUGGY CODE ###

while True:
    n = int(input())
    if n==0 : break

    a = []
    for i in range(n):
        a.append(int(input()))

    maxi = 0
    for i in range(1,1+n):
        for j in range(n-i+1):
            if maxi < sum(a[j:j+i]):
                maxi = sum(a[j:j+i])

    print(maxi)

### FIXED CODE ###

while True:
    n = int(input())
    if n==0 : break

    a = []
    for i in range(n):
        a.append(int(input()))

    maxp = -100001
    maxcont = -100001
    for i in range(n):
        maxcont = max(a[i], maxcont + a[i])
        maxp = max(maxp, maxcont)

    print(maxp)
### BUGGY CODE ###

n=int(input())
s = []
max = 0

for i in range(n):
    s.append(input())

s.sort()

for i in range(n):
    if max < s.count(str(s[i])):
        max = s.count(str(s[i]))

for i in range(n):
    if i == 0 and max == s.count(str(s[i])):
        print(s[i])
    elif max == s.count(str(s[i])) and s[i] != s[i-1]:
        print(s[i])

### FIXED CODE ###

import collections

n=int(input())
s = []
max = 0

for i in range(n):
    s.append(input())

c = collections.Counter(s)

for i in c.items():
    if i[1] > max:
        max = i[1]

s2 = [i[0] for i in c.items() if i[1] == max]

s2.sort()

for j in range(len(s2)):
    print(s2[j])