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

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

def cmd(n,r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
 
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
 
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
 
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
 
    return result
n,k = inpl()
a = inpl()
a.sort()
res = 0
for i in range(1,n-k+2):
    c = cmd(n-i,k-1)
    res += c*(-a[i-1] + a[n-i])
    res %= mod
print(res)

### FIXED CODE ###

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

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv
comb = Combination(100010)
n,k = inpl()
a = inpl()
a.sort()
res = 0
for i in range(n-k+1):
    cc = comb(n-i-1,k-1)
    res += cc*(-a[i]+a[n-i-1])
    res %= mod
print(res)
### BUGGY CODE ###

input()
ls = list(map(int,input().split()))
n = 0
for i in set(ls):
    count = ls.count(i)
    if count == 0 or count == i:
        pass
    elif count > i:
        n += count - i
    else:
        n += count
print(n)


### FIXED CODE ###

from collections import Counter
input()
a = map(int,input().split())

result = 0
for k, v in Counter(a).items():
    if k > v:
        result += v
    elif k < v:
        result += v-k
print(result)
### BUGGY CODE ###

#!/usr/bin/env python3.4

# abc127_d

import itertools
import functools

def find_index(iterable, func, from_i):
    i = from_i
    l = len(iterable)
    while i<l and not func(iterable[i]):
        i += 1
    return i

def main():
    # Input
    n, m = [int(s) for s in input().split()]
    cards = [int(s) for s in input().split()]
    acts = [[int(s) for s in input().split()] for _ in range(m)]
    # Get ans
    cards.sort()
    acts.sort(key=lambda a: a[1])
    i = 0
    for b, c in acts:
        i = find_index(cards, lambda card: card>=c, i)
        #print(i, cards[:i], cards[i:])
        change_num = min(b, i)
        cards = cards[:i][change_num:] + [c]*change_num + cards[i:]
        #print(cards)
    ans = sum(cards)
    # Output
    print(ans)

if __name__ == '__main__':
    main()



### FIXED CODE ###

#!/usr/bin/env python3.4

# abc127_d

import collections
import itertools
import functools

def main():
    # Input
    _, m = [int(s) for s in input().split()]
    cards = [int(s) for s in input().split()]
    acts = [[int(s) for s in input().split()] for _ in range(m)]
    # Get ans
    cards = collections.deque(sorted(cards))
    acts.sort(key=lambda a: a[1], reverse=True)
    for b, c in acts:
        for _ in range(b):
            if cards[0] >= c:
                break
            cards.popleft()
            cards.append(c)
    ans = sum(cards)
    # Output
    print(ans)

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

# import numpy as np

def main():
    s = input()
    # s = '<>>><<><<<<<>>><'
    n_list = [0] * (len(s)+1)
    # n_list = np.zeros(len(s)+1)

    for i in range(0, len(s)):
        if s[i] == '<':
            n_list[i+1] = n_list[i]+1
        else: # i = >
            j = i # jは左側の                           文字のインデックス
            k = 1                          
            for j in range(i, 0, -1):
                if s[j] == '<':
                    n_list[j+1] = max(n_list[j], n_list[j+2])+1
                    break
                n_list[j] = k                
                j-=1
                k+=1
        if s[0] == '>':
            n_list[0] = n_list[1]+1
        # print('i={} {}'.format(i, n_list))    

    # print(n_list)
    print(int(sum(n_list)))


if __name__ == "__main__":
    main()





### FIXED CODE ###

# import numpy as np
# import time

def main():
    s = input()
    # s = '<>>><<><<<<<>>><' # test
    # s = '>>>>>>>'
    n_list = [0] * (len(s)+1)
    # n_list = np.zeros(len(s)+1)

    for i in range(1, len(s)):
        if s[i-1] == '<':
            n_list[i] = n_list[i-1]+1
        else: # i = >
            if s[i] == '>':
                continue
            # j = i # jは左側の                           文字のインデックス
            k = 1                          
            for j in range(i, 1, -1):
                if s[j-1] == '<':
                    n_list[j] = max(n_list[j-1], n_list[j+1])+1
                    break
                n_list[j-1] = k
                k+=1
    
    if s[-1] == '<':
        n_list[-1] = n_list[-2]+1
    elif s[-1] == '>':
        # j = i # jは左側の                           文字のインデックス
        k = 1                     
        for j in range(len(s), 1, -1):
            if s[j-1] == '<':
                n_list[j] = max(n_list[j-1], n_list[j+1])+1
                break
            n_list[j-1] = k
            k+=1
    if s[0] == '>':
        n_list[0] = n_list[1]+1
            
        # print('i={} {}'.format(i, n_list))    
 
    # print(n_list)
    print(int(sum(n_list)))


if __name__ == "__main__":
    # start = time.time()
    main()    
    # elapsed_time = time.time() - start
    # print ("elapsed_time:{0}".format(elapsed_time) + "[sec]")
### BUGGY CODE ###

"""
dp[i][j] -> i人目までみる。j人が座布団を積むときの、最小の座布団の枚数
"""
N = int(input())
men = []
for _ in range(N):
    h,p=map(int,input().split())
    men.append((h,p))

men.sort(key=lambda x: sum(x))
ceil = max(men,key=lambda x: x[0])[0]+1
dp = [[float("INF")for _ in range(N+1)] for _ in range(N+1)]
for i in range(N+1):
    dp[i][0] = 0

for i in range(1,N+1):
    h,p = men[i-1][0],men[i-1][1]
    for j in range(1,i+1):
        if dp[i-1][j-1] <= h:
            dp[i][j] = min(dp[i-1][j],dp[i-1][j-1]+p)
        else:
            dp[i][j] = dp[i-1][j]
        
for j in range(N,-1,-1):
    if dp[-1][j] != float("INF"):
        print(j)
        break



### FIXED CODE ###

N = int(input())
men = []
for _ in range(N):
    H,P = map(int,input().split())
    men.append((H,P,H+P))
men.sort(key=lambda x: x[2])

maxH = max(men)[0]
inf = maxH+1
#dp[i][j] -> i人目までみたとき、j人が座布団を積む場合の最小枚数
dp = [[-1]*(N+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    h,p,a = men[i-1]
    for j in range(1,N+1):
        if 0 <= dp[i-1][j-1] <= h:
            if dp[i-1][j] == -1:
                dp[i][j] = dp[i-1][j-1]+p
            else:
                dp[i][j] = min(dp[i-1][j],dp[i-1][j-1]+p)
        else:
            dp[i][j] = dp[i-1][j]

for j in range(N,-1,-1):
    if dp[-1][j] != -1:
        print(j)
        break
### BUGGY CODE ###

import fractions
from functools import reduce

mod = 10**9 + 7

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

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

num_lcm = lcm(*a)
ans = 0
for i in range(n):
    ans = (ans + num_lcm // a[i]) % mod

print(ans)

### FIXED CODE ###

import fractions
from functools import reduce

mod = 10**9 + 7

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
a = list(map(int, input().split()))
a_ = []
for i in range(n):
    a_.append(pow(a[i], mod - 2, mod))

num_lcm = lcm(*a) % mod
ans = 0
for i in range(n):
    ans = (ans + num_lcm * a_[i] % mod) % mod

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

N=int(input())
L=list(map(int,input().split()))
L.sort(reverse=True)
t=0
for i in range(N-2):
    for j in range(i+1,N-1):
        if L[i]<L[j]+L[N-1]:
            t+=N-1-j
        elif L[i]>=L[j]+L[j+1]:
            t+=0
        else:
            c=int((2*N-2-j)/2)
            while L[i]>L[j]+L[c] or L[i]<L[j]+L[c+1]:
                if L[i]<=L[j]+L[c]:
                    c=int((c+N-1-j)/2)
                elif L[i]>=L[j]+L[c+1]:
                    c=int((N-1+c)/2)
                print('c')
            t+=N-1-c

print(t)


### FIXED CODE ###

from bisect import bisect_left

N=int(input())
L=list(map(int,input().split()))
L.sort()
ans=0
for i in range(N-2):
    for j in range(i+1,N-1):
        l=L[i]+L[j]
        c=bisect_left(L,l)
        ans+=max(0,c-j-1)
print(ans)
### BUGGY CODE ###

N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

dp = [[0] * (W + 1) for _ in range(N + 1)]
for i in range(N):
	for j in range(W + 1):
		if j - w[i] >= 0:
			dp[i + 1][j] = dp[i][j - w[i]] + v[i]
		dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
print(dp[N][W])


### FIXED CODE ###

N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

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

for i in range(N):
	for j in range(W + 1):
		if j - w[i] >= 0:
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i])
		dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
print(dp[N][W])
### BUGGY CODE ###

S = input()
b = set([2019*x for x in range(1, 200000//2019 + 1)])

ans = 0
for i in range(len(S)):
    for j in range(i+1, len(S)+1):
        if int(S[i:j]) in b:
            ans += 1
print(ans)

### FIXED CODE ###

S = input()

n_i_to_j_mod = [0] * (2019+1) # 2019で割った余りがiになるようなSの部分連続文字列の個数
i_to_end_mod = [0] * (len(S)+1) # S[-i:](Sの後方i文字)を2019で割ったときの余り

for i in range(1, len(S)+1):
    if i == 1:
        i_to_end_mod[1] = int(S[-1]) % 2019
    else:
        i_to_end_mod[i] = (i_to_end_mod[i-1] + int(S[-i]) * pow(10, i-1, 2019)) % 2019
    n_i_to_j_mod[i_to_end_mod[i]] += 1

ans = n_i_to_j_mod[0] + (n_i_to_j_mod[0] * (n_i_to_j_mod[0]-1))//2
for i in range(1, 2019):
    if n_i_to_j_mod[i] >= 2:
        ans += (n_i_to_j_mod[i] * (n_i_to_j_mod[i]-1)) // 2
print(ans)
### BUGGY CODE ###

n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
#print(n,m,l)
s=[]
g=[]
for i in l:
    if i[0]==1:
        s.append(i[1])
    if i[1]==n:
        g.append(i[0])
#print(s,g)
for i in s:
    if i in g:
        print('POSSIBLE')
        break
else:
    print('IMPOSSIBLE')

### FIXED CODE ###

n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
#print(n,m,l)
def bin_search(a,li):
    max_len=len(li)-1
    min_len=0
    while max_len>=min_len:
        mid=(max_len+min_len)//2
        if li[mid]==a:
            return True
        elif li[mid]<a:
            min_len=mid+1
        else:
            max_len=mid-1
s=[]
g=[]
for i in l:
    if i[0]==1:
        s.append(i[1])
    if i[1]==n:
        g.append(i[0])
g.sort()
for i in s:
    if bin_search(i,g):
        print('POSSIBLE')
        break
else:
    print('IMPOSSIBLE')
### BUGGY CODE ###

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

A.sort()
for _ in range(M):
  a = A.pop(-1) // 2
  bisect.insort_left(A, a)

print(sum(A))

### FIXED CODE ###

import heapq

def minus_int(s):
  return -1 * int(s)

N, M = map(int, input().split())
A = list(map(minus_int, input().split()))
heapq.heapify(A)
for _ in range(M):
  tmp = int(heapq.heappop(A) / 2)
  heapq.heappush(A, tmp)

print(sum(A) * (-1))
### BUGGY CODE ###

N = int(input())
S = input()
S = [(a, p) for p, a in enumerate(S)]
count = 0
for i in range(N):
    for j in range(i+1,N):
        if S[i][0] != S[j][0]:
            for k in range(j+1,N):
                if S[i][0] != S[k][0] and S[j][0] != S[k][0] and j-i != k-j:
                    count+=1
print(count)

### FIXED CODE ###

N = int(input())
S = list(input())
count = S.count("R")*S.count("B")*S.count("G")
for i in range(N):
    for j in range(i+1,N):
        if 2*j-i < N:
            if S[i]!=S[j] and S[2*j-i]!=S[i] and S[2*j-i]!=S[j]:
                count-=1
print(count)
### BUGGY CODE ###

a,b = map(int,input().split())
c = list(map(int,input().split()))
cnt = 0
for i in range(a):
    j = i + 1
    while j < a+1:
        c[i:j]
        if sum(c[i:j])%b == 0:
            cnt += 1
        j += 1
print(cnt)

### FIXED CODE ###

n, m = map(int, input().split())
d = {0: 1}
asum = 0
ans = 0
for a in map(int, input().split()):
    asum = (asum + a) % m
    if asum in d:
        ans += d[asum]
        d[asum] += 1
    else:
        d[asum] = 1
print(ans)
### BUGGY CODE ###

N = int(input())
array = [i for i in range(1, N+1)]
num = 0

for i in range(N-1):
    num += i + 1

print(num)

### FIXED CODE ###

N = int(input())
print(N * (N-1) // 2)
### BUGGY CODE ###

n = int(input())
power = 1
for i in range(n):
    power *= i+1
print(power%(10**9+7))

### FIXED CODE ###

import math
n = int(input())
print(math.factorial(n)%(10**9+7))
### BUGGY CODE ###

import math
N = int(input())
for i in range(1, N+1):
    if i < 6:
        print(0)
        continue
    cnt = 0
    for x in range(1, int(math.pow(i, 1.0/2.6)+1)):
        for y in range(1, int(math.pow(i, 1.0/2.6)+1)):
            for z in range(1, int(math.pow(i, 1.0/2.6)+1)):
                if ((x+y+z)**2)-x*y-y*z-z*x == i:
                    cnt += 1
    print(cnt)

### FIXED CODE ###

N = int(input())
lis = [0]*N
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            ans = x**2 + y**2 + z**2 + x*y + y*z + z*x -1
            if ans >= N:
                pass
            else:
                lis[ans] += 1
for i in range(N):
    print(lis[i])
### BUGGY CODE ###

x,k,d = (int(x) for x in input().split())
if x < 0:
    x *= -1

if x - d * k >= 0:
    print(x - d * k)
else:
    for i in range(k):
        x -= d
        if x <= 0:
            if (k-i) % 2 == 0:
                print(x + d)
                break
            else:
                print(x * (-1))
                break

### FIXED CODE ###

import math
x,k,d = (int(x) for x in input().split())
if x < 0:
    x *= -1

if x/d >= k:
    print(x-d*k)
else:
    if (k-math.ceil(x/d)) % 2 == 0:
        a = x - math.ceil(x/d)*d
        print(a * -1)
    else:
        a = x - math.ceil(x/d)*d
        print(a + d)
### BUGGY CODE ###

#!/usr/bin/env python3

import numpy as np

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

a_sum = np.cumsum(a)

ans = 0
diff = 0
for i in range(len(a)):
    ans += np.sum(((a_sum[i:]-diff) % m) == 0)
    diff += a[i]

print(ans)


### FIXED CODE ###

#!/usr/bin/env python3

import numpy as np
from scipy.special import comb

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

a_sum = np.cumsum(a)


re_list = {}
re_list[0] = 1
for i in a_sum:
    re = i % m
    if re in re_list:
        re_list[re] += 1
    else:
        re_list[re] = 1

# print(re_list)
ans = 0
for value in re_list.values():
    ans += comb(value, 2, exact=True)

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

n,q = [int(i) for i in input().split()]
s = input()
l = [[int(i) for i in input().split()] for _ in range(q)]
for i in l:
    ss = s[i[0]-1:i[1]]
    ss2 = ss.replace('AC','')
    print((len(ss)-len(ss2))//2)

### FIXED CODE ###

n,q = [int(i) for i in input().split()]
string = input()
l = [[int(i) for i in input().split()] for _ in range(q)]

ans = [0 for _ in range(n)]

for i in range(n-1):
    if string[i] == 'A' and string[i+1] == 'C':
        ans[i+1] = ans[i] +1
    else:
        ans[i+1] = ans[i]
        
for x,y in l:
    print(ans[y-1] - ans[x-1])
### BUGGY CODE ###

n = int(input())
v = list(range(n))
for x in range(n):
  v[x] = input()

import collections
c = collections.Counter(v)
values, counts = zip(*c.most_common())
num = 0

for y in list(counts):
  if y == max(counts):
    num += 1
answers = list(values[:num])
answers.sort()
for z in range(num):
  print(answers[z])

### FIXED CODE ###

n = int(input())
v = list(range(n))
for x in range(n):
  v[x] = input()

import collections
c = collections.Counter(v)
values, counts = zip(*c.most_common())
num = list(counts).count(max(counts))
answers = list(values[:num])
answers.sort()
for z in range(num):
  print(answers[z])
### BUGGY CODE ###

def main():
    import sys
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    finish = [False] * N
    for i in range(K):
        start = [0] * N
        end = [0] * N
        for j in range(N):
            if j - A[j] < 0:
                start[0] += 1
            else:
                start[j-A[j]] += 1
            if j + A[j] >= N:
                pass
            else:
                end[j+A[j]] += 1
        tmp = start[0]
        A[0] = tmp
        for j in range(1, N):
            tmp += start[j]
            tmp -= end[j-1]
            A[j] = tmp
            if tmp >= N:
                finish[j] = True
        if False not in finish:
            break
    print(" ".join(map(str, A)))

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    for i in range(K):
        start = [0] * N
        end = [0] * N
        for j in range(N):
            if j - A[j] < 0:
                start[0] += 1
            else:
                start[j-A[j]] += 1
            if j + A[j] >= N:
                pass
            else:
                end[j+A[j]] += 1
        tmp = start[0]
        A[0] = tmp
        tmp_min = tmp
        for j in range(1, N):
            tmp += start[j]
            tmp -= end[j-1]
            A[j] = tmp
            tmp_min = min(tmp_min, tmp)
        if tmp_min >= N:
            break
    print(" ".join(map(str, A)))

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

from itertools import accumulate

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

A=[int(x) for x in input().split()]

m=A.index(min(A))
A=A[m:]+A[:m]
dp=[[int(x) for x in A] for i in range(2)]

#dp[i]:k回魔法を唱えた時にA[i]を手に入れる最小の時間。
#dp=Aで初期化。その後、１〜Nまでのdp[i]はmin(dp[i-1],A[i])で順に更新されていく。
#更新前後のdpを保持するため蟻本P60に記載のある「配列の再利用」を行う。
#各回におけるsum(dp)+k*xを算出して最小値が答え。

#ans初期値は魔法を唱えず、全てを入手した数字（sum(A))
ans=sum(A)
for k in range(1,N):
  cnt=dp[0][0]
  for i in range(1,N):
    dp[(k+1)&1][i]=min(dp[k&1][i-1],A[i])
    cnt+=dp[(k+1)&1][i]
  ans=min(ans,cnt+k*x)
  
print(ans)


### FIXED CODE ###

N,x=map(int,input().split())
A=[int(x) for x in input().split()]
dp=A[:]

#dp[i]:k回魔法を唱えた時にA[i]を手に入れる最小の時間。
#dp=Aで初期化。その後、１〜Nまでの各ステップでdp[i]はmin(dp[i],A[i-k])で順に更新されていく。
#各回におけるsum(dp)+k*xを算出して最小値が答え。

#ans初期値は魔法を唱えず、全てを入手した数字（sum(A))
ans=sum(A)
for k in range(1,N):
  for i in range(N):
    if dp[i]>A[i-k]:
      dp[i]=A[i-k]
  ans=min(ans,sum(dp)+x*k)

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

N = int(input())

for n in range(1, N+1):
    s = n//5
    cnt = 0
    flag = 0
    for x in range(1, s+1):
        for y in range(1, s+1):
            for z in range(1, s+1):
                siki = x**2 + y**2 + z**2 + x*y + y*z + z*x

                if siki == n:
                    # print('ans = ', siki)
                    if (x==y)and(y==z):
                        cnt += 1
                    elif (x!=y)and(y!=z):
                        cnt += 6
                    else:
                        cnt += 3
                # elif siki > n:
                    flag = 1
                    break
            if flag:
                break
        if flag:
            break
    print(cnt)

### FIXED CODE ###

n=int(input())

ans=[0]*(n+1)

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            f= x**2 + y**2 + z**2 + x*y + y*z + z*x
            if f<=n:
                ans[f]+=1

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

q, k = list(map(int, input().split()))
list = [int(i) for i in input()]

# 0 ,1 のまとまりを作る
sum01 = []
pre = 1
cnt = 0
# 111010
# 001010
for i, e in enumerate(list):
    if e != pre:
        sum01.append(cnt)
        cnt = 1
        pre = e
    else:
        cnt += 1
if cnt != 0:
    sum01.append(cnt)

if len(sum01) % 2 == 1:
    sum01.append(0)

#print(sum01)
Add = 2 * k + 1
answer = 0
for i in range(0, len(sum01), 2):
    temp = 0
    left = i
    right = min(i + Add, len(sum01))
    for j in range(left, right, 1):
        temp += sum01[j]
    answer = max(temp, answer)

print(answer)

### FIXED CODE ###

q, k = list(map(int, input().split()))
list = [int(i) for i in input()]

# 0 ,1 のまとまりを作る
sum01 = []
pre = 1
cnt = 0
# 111010
# 001010
for i, e in enumerate(list):
    if e != pre:
        sum01.append(cnt)
        cnt = 1
        pre = e
    else:
        cnt += 1
if cnt != 0:
    sum01.append(cnt)

if len(sum01) % 2 == 1:
    sum01.append(0)

# print(sum01)
Add = 2 * k + 1
ruiseki = [0]
for i, e in enumerate(sum01):
    ruiseki.append(ruiseki[i] + sum01[i])

# print(ruiseki)
answer = 0
for i in range(0, len(sum01), 2):
    left = i
    right = min(i + Add, len(sum01))
    temp = ruiseki[right] - ruiseki[left]
    answer = max(temp, answer)

print(answer)
### BUGGY CODE ###

x = int(input())
from collections import deque
q = deque([[0, 0]])
while q:
    xi, i = q.popleft()
    if xi == x:
        print(i-1)
        exit()
    q.append([xi, i+1])
    q.append([xi+i, i+1])
    q.append([xi-i, i+1])

### FIXED CODE ###

x = int(input())
ans = 0
cnt = 0
i = 0
while cnt < x:
    i+=1
    cnt += i
    ans += 1
print(ans)
### BUGGY CODE ###

N = int(input())
l = [input() for _ in range(N)]
m = set(l)
d = dict()

for name in m:
  d[name] = l.count(name)
  
  
max_kv_list = sorted([kv[0] for kv in d.items() if kv[1] == max(d.values())])
for name in max_kv_list:
  print(name)

### FIXED CODE ###

#!/usr/bin/env python3
from collections import Counter

def solve(l):
    d = Counter(l)
    d_max = max(d.values())
    max_d_list = sorted([k[0] for k in d.items() if k[1] == d_max])
    return max_d_list



def main():
    N = int(input())
    l = [input() for _ in range(N)]
    d = solve(l)
    for a in d:
        print(a)
    return

if __name__ == '__main__':
    main()