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

N = int(input())
l = [-1] * N

def get(v1, v2):
    print(v1)
    s = input()
    if s=="Male":
        l[v1] = 0
    elif s=="Female":
        l[v1] = 1
    else:
        print(v1)
        return -1

    print(v2)
    s = input()
    if s=="Male":
        l[v2] = 0
    elif s=="Female":
        l[v2] = 1
    else:
        print(v2)
        return -1
    
    return l[v2]==l[v1]


left, right = 0, N-1
while right-left>1:
    mid = (left+right)//2
    v = get(left, mid)
    if v==-1:
        break
        exit()
    elif v==True and (mid-left)%2:
        right = m
    else:
        left = m


### FIXED CODE ###

N = int(input())
l = [-1] * N

print(0)
s = input()
if s=="Male":
    l[0] = 0
elif s=="Female":
    l[0] = 1
else:
    exit(0)

print(N-1)
s = input()
if s=="Male":
    l[N-1] = 0
elif s=="Female":
    l[N-1] = 1
else:
    exit(0)

left, right = 0, N-1
while right-left>1:
    mid = (left+right)//2

    print(mid)
    s = input()
    if s=="Male":
        l[mid] = 0
    elif s=="Female":
        l[mid] = 1
    else:
        exit(0)

    if (l[mid]==l[left] and (mid-left)%2) or (l[mid]!=l[left] and (mid-left)%2==0):
        left, right = left, mid
    else:
        left, right = mid, right
### BUGGY CODE ###

n, m = map(int, input().split(" "))
max = 1
for i in range((int)(m/n), 1, -1):
  if m % i == 0:
    max = i
    break
print(max)

### FIXED CODE ###

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

n, m = map(int, input().split(" "))
max = 1
#print(make_divisors(m))
for i in make_divisors(m):
  if i > m/n:
    break
  else:
    max = i
print(max)
### BUGGY CODE ###

N = int(input())
As = list(map(int, input().split(' ')))
 
not_divisible = 0
for num_i, Ai in enumerate(As):
    for num_j, Aj in enumerate(As):
        if num_i==num_j:
            continue
        if Ai%Aj==0:
            break
    else:
        not_divisible += 1
print(not_divisible)


### FIXED CODE ###

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

max_a = max(a)
dp = [0] * (max_a + 1)

for i in a:
    for j in range(i, max_a+1, i):
        dp[j] += 1
        
print([dp[i] for i in a].count(1))
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
# input = sys.stdin.r/eadline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    A,B,C = MAP()
    if not(A%2==0 and B%2==0 and C%2==0):
        print(0)
        return
        
    if A==B==C:
        print(-1)
        return
    answer = 0
    
    while A%2==0 and B%2==0 and C%2==0:
        x = A//2
        y = B//2
        z = C//2
        A = y+z
        B = x+y
        C = y+z
        answer += 1
    print(answer)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
# input = sys.stdin.r/eadline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    A,B,C = MAP()
    if A==B==C:
        if A%2==1 or B%2==1 or C%2==1:
            print(0)
        else:
            print(-1)
        return
    answer = 0
    
    while A%2==0 and B%2==0 and C%2==0:
        x = A//2
        y = B//2
        z = C//2
        A = y+z
        B = x+z
        C = y+x
        answer += 1
    print(answer)

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

n,a,b,c,d,e=[int(input()) for i in range(6)]

city1 = [n]
city2 = [0]
city3 = [0]
city4 = [0]
city5 = [0]
city6 = [0]

t = 0

while city6[t-1]<n:
    
    if city1[t]==0:
        city1.append(0)
        city2.append(city2[t])
    elif city1[t]>=a:
        city1.append(city1[t]-a)
        city2.append(city2[t]+a)
    else:
        city1.append(0)
        city2.append(city2[t]+city1[t])
    
    if city2[t]==0:
        city3.append(city3[t])
    elif city2[t]>=b:
        city2[t+1] -= b
        city3.append(city3[t]+b)
    else:
        city2[t+1] -= city2[t]
        city3.append(city3[t]+city2[t])
    
    if city3[t]==0:
        city4.append(city4[t])
    elif city3[t]>=c:
        city3[t+1] -= c
        city4.append(city4[t]+c)
    else:
        city3[t+1] -= city3[t]
        city4.append(city4[t]+city3[t])
    
    if city4[t]==0:
        city5.append(city5[t])
    elif city4[t]>=d:
        city4[t+1] -= d
        city5.append(city5[t]+d)
    else:
        city4[t+1] -= city4[t]
        city5.append(city5[t]+city4[t])
        
    if city5[t]==0:
        city6.append(city6[t])
    elif city5[t]>=e:
        city5[t+1] -= e
        city6.append(city6[t]+e)
    else:
        city5[t+1] -= city5[t]
        city6.append(city6[t]+city5[t])
        
    t += 1

print(t-1)


### FIXED CODE ###

n,a,b,c,d,e=[int(input()) for i in range(6)]

lis = [a,b,c,d,e]
neck = min(lis)

if(n%neck==0):
  print(( (n//neck))+4)
else:
  print(( (n//neck) +1)+4)
### BUGGY CODE ###

def main():
    n = int(input())
    hoge = []
    res = 0
    for _ in range(n):
        s = input()
        if s not in hoge:
            res += 1
            hoge.append(s)
    print(res)

if __name__ == '__main__':
    main()



### FIXED CODE ###

def main():
    n = int(input())
    hoge = {}
    for _ in range(n):
        s = input()
        hoge[s] = 1
    print(len(hoge.keys()))

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

n = int(input())
def sqe(a, b, c):
    D = (b**2 - 4*a*c) ** (1/2)
    x_1 = (-b + D) / (2 * a)

    return x_1
  
for i in range(1,n+1):
  cnt = 0
  for x in range(1,70):
    if n-x**2<=0:
      break
    for y in range(1,int((n-x*2)**0.5)+1):
      if x**2+y**2+x*y>i:
        break
      x_1 = sqe(1,x+y,x**2+y**2+x*y-i)
      if x_1.is_integer() and x_1>0:
        cnt += 1
  print(cnt)

### FIXED CODE ###

n = int(input())
def solve(n):
  l = [0]*(n**3)
  for x in range(1,n+1):
    for y in range(1,n+1):
      for z in range(1,n+1):
        l[x**2+y**2+z**2+x*y+y*z+z*x] += 1
  return l
l = solve(100)
print(*l[1:n+1])
### BUGGY CODE ###

from collections import deque

def main():
  n, m = map(int, input().split())
  ab = (map(int, input().split()) for i in range(m))
  
  ggg = [[0] * (n+1) for i in range(n+1)]
  ff = [0] * (n+1)
  
  for a, b in ab:
    ggg[a][b] = 1
    ggg[b][a] = 1
    
  qq = deque()
  qq.append((1, 1))
  
  while qq:
    a, f = qq.popleft()
    if ff[a]:
      continue
    ff[a] = f
    for b in range(1, n+1):
      if ggg[a][b] and not ff[b]:
        qq.append((b, a))
  
  rr = ff[2:]
  y = all(rr)
  
  print('Yes' if y else 'No')
  if y:
    for r in rr:
      print(r)

if __name__ == '__main__':
  main()


### FIXED CODE ###

from collections import deque

def main():
  n, m = map(int, input().split())
  ab = (map(int, input().split()) for i in range(m))
  
  ggg = [[] for i in range(n+1)]
  ff = [0] * (n+1)
  
  for a, b in ab:
    ggg[a].append(b)
    ggg[b].append(a)
    
  qq = deque()
  qq.append(1)
  ff[1] = 1
  
  while qq:
    a = qq.popleft()
    for b in ggg[a]:
      if not ff[b]:
        ff[b] = a
        qq.append(b)
  
  rr = ff[2:]
  y = all(rr)
  
  print('Yes' if y else 'No')
  if y:
    for r in rr:
      print(r)

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

nk = list(map(int, input().split()))
p = list(map(int, input().split()))
n = nk[0]
k = nk[1]
s = [sum(p[:i]) for i in range(n+1)]
maxim = 0
for i in range(n-k+1):
    if (s[i+k]-s[i]) > maxim:
        maxim = s[i+k]-s[i]
ans = (maxim+k)/2
print(ans)

### FIXED CODE ###

def main():    
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    s = sum(p[:k])
    maxs = s
    for i in range(n-k):
        s = s - p[i] + p[i+k]
        if s > maxs:
            maxs = s
    ans = (maxs+k)/2
    print(ans)
main()
### BUGGY CODE ###

N, M = [int(x) for x in input().split()]

f = [[0 for _ in range(N)] for _ in range(N)]

for _ in range(M):
    i, j = [int(x) for x in input().split()]
    f[j - 1][i - 1] = 1

ans = 0
for x in range(1, N):
    if sum(f[x][:x]) == 0:
        ans += 1

print(ans)

### FIXED CODE ###

from typing import Dict, List

N, M = [int(x) for x in input().split()]

class UnionFind:
    def __init__(self, num_node: int):
        self.__parent_index = [x for x in range(num_node)]
        self.__tree_rank = [1] * num_node

    def __is_root(self, index: int) -> bool:
        return self.__parent_index[index] == index

    def root(self, index: int) -> int:
        """Find root index."""
        while not self.__is_root(index):
            index = self.__parent_index[index] = self.root(self.__parent_index[index])
        return index

    def unite(self, x: int, y: int) -> bool:
        """Unite two trees."""
        x = self.root(x)
        y = self.root(y)

        if x == y:
            return False

        if self.__tree_rank[x] < self.__tree_rank[y]:
            x, y = y, x

        self.__tree_rank[x] += self.__tree_rank[y]
        self.__parent_index[y] = x

        return True

    def groups(self) -> Dict[int, List[int]]:
        __groups: Dict[int, List[int]] = {}
        for node, parent in enumerate(self.__parent_index):
            __root = self.root(parent)
            if __groups.get(__root) is None:
                __groups[__root] = [node]
            else:
                __groups[__root].append(node)

        return __groups

uni = UnionFind(N)
for i in range(M):
    a, b = [int(x) - 1 for x in input().split()]
    uni.unite(a, b)

print(len(uni.groups()) - 1)
### BUGGY CODE ###

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

### FIXED CODE ###

from collections import Counter
# これは, u749194f さんの改造です。
# オリジナルではございません。
# https://atcoder.jp/contests/abc162/submissions/11825963
n = int(input())
s = input()
flag = True
if len(set(s))<=2:
    print(0)
    flag = False
if flag:
    r = [i+1 for i in range(n) if s[i]=='R']
    b = [i+1 for i in range(n) if s[i]=='B']
    g = [i+1 for i in range(n) if s[i]=='G']
    minus = 0
    def cnt_cmb(a, b, c):
        cnt = 0
        set_c = set(c)
        for i in a:
            for j in b:
                if (i+j)/2 in set_c:
                    cnt += 1
        return cnt
    minus += cnt_cmb(r, b, g)
    minus += cnt_cmb(b, g, r)
    minus += cnt_cmb(g, r, b)
    a = Counter(s)
    rslt = 1
    for value in a.values():
        rslt *= value
    print(len(r)*len(b)*len(g)-minus)
### BUGGY CODE ###

#入力。参加者数N, 初期得点K ,正解数Q
N, K, Q = list(map(int,input().split()))
#入力。正解した人の番号A[i]
A = [None for _ in range(Q)]
for i in range(Q):
  A[i] = int(input())
#初期得点(hp)をリスト化。
hp = [K for _ in range(N)]
#まず他の人への攻撃力at(各人の正解数)を記録。
at = [0 for _ in range(N)]
#正解した人の攻撃力+1。
for i in range(Q):
  j = A[i]
  at[j-1] += 1
#攻撃力分の数を一度全員のhpからマイナスする。
for i in range(N):
  hp[i] -= sum(at)
#各々自分の攻撃力分は本来受けないはずのダメージなのでhpに戻す(足す)。
for i in range(N):
  hp[i] += at[i]
#結果(生き残り判定)
for i in range(N):
  if hp[i] > 0:
    print('Yes')
  else:
    print('No')

### FIXED CODE ###

#入力。参加者数N, 初期得点K ,正解数Q
N, K, Q = list(map(int,input().split()))
#入力。正解した人の番号A[i]
A = [None for _ in range(Q)]
for i in range(Q):
  A[i] = int(input())
#初期得点(hp)をリスト化。
hp = [K for _ in range(N)]
#まず他の人への攻撃力at(各人の正解数)を記録。
at = [0 for _ in range(N)]
#正解した人の攻撃力+1。
for i in range(Q):
  j = A[i]
  at[j-1] += 1
#攻撃力分の数を一度全員のhpからマイナスする。
s = sum(at)
for i in range(N):
  hp[i] -= s
#各々自分の攻撃力分は本来受けないはずのダメージなのでhpに戻す(足す)。
for i in range(N):
  hp[i] += at[i]
#結果(生き残り判定)
for i in range(N):
  if hp[i] > 0:
    print('Yes')
  else:
    print('No')
### BUGGY CODE ###

class BIT:
  def __init__(self, n):
    self.n = n
    self.data = [0]*(n+1)
  def sum(self, i):
    s = 0
    while i > 0:
      s += self.data[i]
      i -= i & -i
    return s
  def add(self, i, x):
    # assert i > 0
    while i <= self.n:
      self.data[i] += x
      i += i & -i

N, Q = map(int, input().split())
Cs = [0] + list(map(int, input().split()))

Qs = []
for i in range(Q):
  l,r = map(int, input().split())
  Qs.append((i,l,r))
  
Qs.sort(key=lambda x:x[2])

ans = [-1]*Q
dic = {}
b = 1
bt = BIT(N)

for i,l,r in Qs:
  st = set()
  for j in range(b,r+1):
    if not Cs[j] in st and Cs[j] in dic:
      bt.add(dic[Cs[j]],-1)
    st.add(Cs[j])
    dic[Cs[j]] = j
  for s in st:
    bt.add(dic[s], 1)
  ans[i] = bt.sum(r) - bt.sum(l-1)
  b = r + 1
  
for i in range(Q):
  print(ans[i])

### FIXED CODE ###

from sys import stdin
input = stdin.readline
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
 
n, q = map(int, input().split())
tmp = list(map(int, input().split()))
color = [-1]
for v in tmp:
    color.append(v)
qry = [None]*q
ans = [0]*q
p = 0
for _ in ans:
    l, r = map(int, input().split())
    qry[p] = [l-1, r, p]
    p += 1
qry.sort(key=lambda x: x[1])
dic = {}
last_update_idx = 1
bit = Bit(n)
for l, r, i in qry:
    if last_update_idx < r+1:
        st = set()
        for j in range(last_update_idx, r+1):
            if not color[j] in st and color[j] in dic:
                bit.add(dic[color[j]], -1)
            dic[color[j]] = j
            st.add(color[j])
        for v in st:
            bit.add(dic[v], 1)
        last_update_idx = r+1
    ans[i] = bit.sum(r) - bit.sum(l)
for v in ans:
    print(v)
### BUGGY CODE ###

import collections
import itertools

N = int(input())
s_list = []
for i in range(N):
    s_list.append(input())

d = {}
for s in s_list:
    l2 = []
    for i in range(len(s)):
        l2.append(s[i])
    l2.sort()
    a = ""
    for i in l2:
        a += i
    if a in d:
        d[a]+=1
    else:
        d[a] = 1
ans = 0
for i in d:
    ans += len(list(itertools.combinations(range(d[i]), 2)))
print(ans)

### FIXED CODE ###

import collections
import itertools
ans = 0

N = int(input())
s_list = []
for i in range(N):
    s_list.append(input())

d = {}
for s in s_list:
    l2 = []
    for i in range(len(s)):
        l2.append(s[i])
    l2.sort()
    a = ""
    for i in l2:
        a += i
    if a in d:
        ans+=d[a]
        d[a]+=1
    else:
        d[a] = 1

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


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


dp = [10 ** 10] * N
dp = dp + [10 ** 10] * 1000
dp[0] = 0

footing = footing + [0] * 1000
# give
for i in range(N-1):
    for k in range(1, K+1):
        if dp[i+k] > dp[i] + abs(footing[i+k] - footing[i]):
            dp[i+k] = dp[i] + abs(footing[i+k] - footing[i])

print(dp[N-1])

# get
'''
for i in range(1,N):
    if dp[i] > dp[i-1] + abs(footing[i]-footing[i-1]):
        dp[i] = dp[i-1] + abs(footing[i]-footing[i-1]) 

    for j in range(2,K+1): 
        if i >= j:
            if dp[i] > dp[i-j] + abs(footing[i]-footing[i-j]):
                dp[i] = dp[i-j] + abs(footing[i]-footing[i-j]) 

print(dp[N-1])
'''

### FIXED CODE ###

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


dp = [10 ** 10] * N
dp = dp + [10 ** 10] * 1000
dp[0] = 0

footing = footing + [0] * 1000
# give
'''
for i in range(N-1):
    for k in range(1, K+1):
        if dp[i+k] > dp[i] + abs(footing[i+k] - footing[i]):
            dp[i+k] = dp[i] + abs(footing[i+k] - footing[i])

print(dp[N-1])
'''
# get
for i in range(1,N):
    for j in range(1,min(K+1, i+1)): 
        dp[i] = min(dp[i],dp[i-j] + abs(footing[i]-footing[i-j])) 

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

N,M = map(int, input().split())
a = [int(input()) for _ in range(M)]
dp = [0]*(N+1)
dp[0] = 1
dp[1] =0 if 1 in a else 1
for i in range(2, N+1):
  dp[i] = (dp[i-1] + dp[i-2])%(10**9+7) if i not in a else 0
print(dp[N])

### FIXED CODE ###

N,M = map(int, input().split())
a = set([int(input()) for _ in range(M)])
dp = [0]*(N+1)
dp[0] = 1
dp[1] =0 if 1 in a else 1
for i in range(2, N+1):
  dp[i] = (dp[i-1] + dp[i-2])%(10**9+7) if i not in a else 0
print(dp[N])
### BUGGY CODE ###

import numpy as np
n=int(input())
a=np.array(sorted(list(map(int,input().split()))))
b=sorted(list(map(int,input().split())))
c=np.array(sorted(list(map(int,input().split()))))
#cnt=0
#for i in range(n):
 # B=b[i]
  #A=[a[i] for i in range(n) if a[i]<B]
  #C=[c[i] for i in range(n) if c[i]>B]
  #cnt+=len(A)*len(C)
#print(cnt)

cnt=0
for i in range(n):
  B=b[i]
  AA=np.searchsorted(a, B-0.1, side='right')
  CC=n-np.searchsorted(c, B+0.1)
  cnt+=AA*CC
print(cnt)

### FIXED CODE ###

n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
#cnt=0
#for i in range(n):
 # B=b[i]
  #A=[a[i] for i in range(n) if a[i]<B]
  #C=[c[i] for i in range(n) if c[i]>B]
  #cnt+=len(A)*len(C)
#print(cnt)
cnt=0
#真ん中のパーツをまず考える
for i in range(n):
  B=b[i]
  if B<=a[0] or B>=c[-1]:
    continue
  #Bより小さいAの最大値のインデックスを探す
  i_small=0
  i_large=n-1
  while i_large-i_small>1:
    if a[(i_small+i_large)//2] <B:
      i_small=(i_small+i_large)//2
    else:
      i_large=(i_small+i_large)//2
 
  A=i_large
  if a[-1]<B:
    A+=1

  #Bより大きいCの最小値のインデックスを探す
  i_small=0
  i_large=n-1
  while i_large-i_small>1:
    if c[(i_small+i_large)//2] >B:
      i_large=(i_small+i_large)//2
    else:
      i_small=(i_small+i_large)//2
  C=n-i_large
  if c[0]>B:
    C+=1

  cnt+=A*C
if n>1:
  print(cnt)
else:
  if a[0]<b[0]<c[0]:
    print(1)
  else:
    print(0)
### BUGGY CODE ###

import sys
from fractions import gcd

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]



n, m = na()
a = na()
a.sort()

for i in range(m):
    b, c = na()
    for j in range(b):
        if a[j] < c:
            a[j] = c
        else:
            break
    a.sort()

print(sum(a))

### FIXED CODE ###

import sys
import math
import numpy as np
import bisect
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n, m = na()
a = na()
bc = []

for _ in range(m):
    bci = na()
    bc.append(bci)

bc.sort(key=lambda x:x[1], reverse=True)
#print(bc)

bi, ci = bc[0][0], bc[0][1]
i = 0
for _ in range(n):
    if bi != 0:
        bi -= 1
        a.append(ci)
    else:
        i += 1
        if i > (m - 1):
            break
        else:
            bi, ci = bc[i][0], bc[i][1]
            bi -= 1
            a.append(ci)

a.sort(reverse=True)
print(sum(a[:n]))
### BUGGY CODE ###

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

balls = {}

for a in A:
  if a in balls:
    balls[a] += 1
  else:
    balls[a] = 1

for a in A:
  balls[a] -= 1
  res = 0
  for b in balls:
    count = balls[b]
    res += count * (count-1) // 2
  balls[a] += 1
  print(res)

### FIXED CODE ###

from copy import deepcopy
dp = {0: 0}

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

balls = {}
fact = 1
for (i, a) in enumerate(A):
  count = i+1
  dp[count] = count * (count-1) // 2
  if a in balls:
    balls[a] += 1
  else:
    balls[a] = 1

res = 0
for count in balls.values():
  res += dp[count]

for a in A:
  print(res - dp[balls[a]] + dp[balls[a]-1])
### BUGGY CODE ###

import itertools

def primes(n):
    l = []
    i = 2
    while i <= n**(1/2):
        while n % i == 0:
            n //= i
            l.append(i)
        i += 1
    if n > 1:
        l.append(n)
    return l

def mul(l):
    result = 1
    for i in l:
        result *= i
    return result

n = int(input())

prime_list = primes(n)

i,j = 1,n
for m in range(len(prime_list)//2 + 1):
    cmb = set(itertools.combinations(prime_list, m))
    for c in cmb:
        s = mul(c)
        t = n//s
        if abs(s-t) < abs(i-j):
            i,j = s,t

print(i+j-2)


### FIXED CODE ###

import math

N = int(input())

ans = 10**15
for k in range(1, int(math.sqrt(N))+1):
    if N % k > 0:
        continue
    ans = min(ans, k + N//k - 2)
print(ans)
### BUGGY CODE ###

def b():
    N, K = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [10 ** 9] * (N + 1)
    dp[0] = 0
    for i in range(1, N):
        for j in range(1, K + 1):
            if i >= j:
                dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]))
    return dp[i]


if __name__ == '__main__':
    ans = b()
    print(ans)

### FIXED CODE ###

def b():
    N, K = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [10 ** 9] * (N + 1)
    dp[0] = 0
    for i in range(1, N):
        for j in range(1, K + 1):
            if i >= j:
                dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]))
    return dp[i]


if __name__ == '__main__':
    ans = b()
    print(ans)
### BUGGY CODE ###

def solve():

    N,M=map(int,input().split())
    A_list=[]#正解問題番号を入れる
    W_list=[0]*N
    WA=0
    PS=[list(map(str,input().split())) for i in range(M) ]
    ans=0
    pena=0
    for x in range(M):
        #if PS[x][0] not in A_list:
            if PS[x][0] in A_list:
                continue
            if PS[x][1]=='AC':
                A_list.append(PS[x][0])
                ans+=1
                WA+=W_list[int(PS[x][0])-1]
            else:
                #pena+=1
                W_list[int(PS[x][0])-1]+=1
    
    #print(ans,pena)
    print(ans,WA)
solve()


### FIXED CODE ###

n, m = map(int, input().split())
AC = [0] * (n+1) #その問題で既に AC が出たか
b = [0] * (n+1) #その問題で WA が出た回数

WA = 0

for i in [0]*(m):

    s = input().split()

    if AC[int(s[0])] == 0:
        if s[1] == "AC":
            AC[int(s[0])] = 1
            WA += b[int(s[0])]
        else:
            b[int(s[0])] += 1

print(sum(AC), WA)
### BUGGY CODE ###

from fractions import Fraction
n = int(input())
nums = [list(map(int,input().split())) for _ in range(n)]
a, b = nums[0][0], nums[0][1]
for i in range(1, n):
    if a / nums[i][0] != b / nums[i][1]:
        p, q = nums[i][0], nums[i][1]
        if a > p or b > q:
            j = 2
            while p < a or q < b:
                p = nums[i][0] * j
                q = nums[i][1] * j
                j += 1
        a, b = p, q
        
print(a + b)

### FIXED CODE ###

from math import ceil
from fractions import Fraction
n = int(input())
nums = [list(map(int,input().split())) for _ in range(n)]
a, b = 1, 1
p = 1
for i in range(n):
    x, y = nums[i][0], nums[i][1]
    p = ceil(max(Fraction(a, x), Fraction(b, y)))
    a, b = p * x, p * y
        
print(a + b)
### BUGGY CODE ###

N = int(input())
S = [''] * N
for i in range(N) :
    S[i] = input()
S_set = sorted(list(set(S)))
#print(S_set)
cnt = [0 for i in range(len(S_set))]
word_buf = []
mmax = -1

for i in range(len(S_set)) :
    cnt[i] = S.count(S_set[i])

    if i == 0 :
        word_buf.append(S_set[i])
    else :
        if cnt[i] < mmax :
            pass
        elif cnt[i] == mmax :
            word_buf.append(S_set[i])
        elif cnt[i] > mmax :
            word_buf.clear()
            word_buf.append(S_set[i])
    mmax = max(mmax,cnt[i]) # 現時点での最大値

word_buf = sorted(word_buf)
for i in range(len(word_buf)) :
    print(word_buf[i])

### FIXED CODE ###

from collections import Counter
N = int(input())
S = [''] * N
for i in range(N) :
    S[i] = input()
S = Counter(S).most_common()
c = S[0][1]

print(*sorted([a for a,s in S if s==c]),sep="\n")