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

N, *S = open(0).read().split()
dict = {i : 0 for i in S}
for i in S:
  dict[i] += 1
print("\n".join(sorted([i for i, j in dict.items() if j == max(dict.values())])))

### FIXED CODE ###

from collections import Counter

N, *S = open(0).read().split()
count = Counter(S)
max_value = max(count.values())
ans_list = [i for i, j in count.items() if j == max_value]
ans_list.sort()
print("\n".join(ans_list))
### BUGGY CODE ###

N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]

h.sort()

ans = float('inf')
for i in range(N - K + 1):
    s = h[i: i + K]
    ans = min(ans, max(s) - min(s))

print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]

h.sort()

ans = min([h[i + K - 1] - h[i] for i in range(N - K + 1)])
print(ans)
### BUGGY CODE ###

import math
N,K=map(int,input().split())
import heapq
A=list(map(int,input().split()))
h=[]
for i in range(len(A)):
  heapq.heappush(h,(-A[i],1))
for i in range(K):
  a=heapq.heappop(h)
  b=a[0]
  c=a[1]
  heapq.heappush(h,(c*b/(c+1),c+1))


ans=heapq.heappop(h)
print(math.ceil(-ans[0]))

### FIXED CODE ###

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

def isok(x):
  c=0
  for i in range(N):
    c+=math.ceil(A[i]/x)-1
  if c<=K:
    return True
  else:
    return False
start=0
end=max(A)
mid=(start+end)//2
while end-start>1:
  mid=(start+end)//2
  if isok(mid)==True:
    end=mid
  else:
    start=mid
print(end)
### BUGGY CODE ###

import sys,random
try: sys.stdin = open('in.in','r')
except: pass

ans = 0
allboth = 1
l = r = 0

n = int(input())
for i in range(n):
	s = input().strip()
	ans += s.count('AB')
	if s[0] == 'B' or s[-1] == 'A':
		l += s[0] == 'B'
		r += s[-1] == 'A'
		if s[0] != 'B' or s[-1] != 'A':
			allboth = 0

ans += min(l,r)
if allboth and ans:
	while True:
		pass
	ans -= 1
print(ans)


### FIXED CODE ###

import sys,random
try: sys.stdin = open('in.in','r')
except: pass

ans = 0
allboth = 1
l = r = 0

n = int(input())
for i in range(n):
	s = input().strip()
	ans += s.count('AB')
	if s[0] == 'B' or s[-1] == 'A':
		l += s[0] == 'B'
		r += s[-1] == 'A'
		if s[0] != 'B' or s[-1] != 'A':
			allboth = 0

ans += min(l,r)
if allboth and l:
	ans -= 1
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
def f():
    h,w=[int(j) for j in input().split()]
    a=[]
    b=[]
    for i in range(h):
        a.append([int(j) for j in input().split()])
    for i in range(h):
        b.append([int(j) for j in input().split()])
    l=[[] for i in range(h)]
    for i in range(h):
        for j in range(w):
            l[i].append(abs(a[i][j]-b[i][j]))
    ans=[[set() for j in range(w)] for i in range(h)]
    ans[0][0].add(l[0][0])
    for i in range(h):
        for j in range(w):
            for k in ans[i][j]:
                if i+1<h:
                    ans[i+1][j].add(k+l[i+1][j])
                    ans[i+1][j].add(k-l[i+1][j])
                if j+1<w:
                    ans[i][j+1].add(k+l[i][j+1])
                    ans[i][j+1].add(k-l[i][j+1])
    a=10**18
    for i in ans[h-1][w-1]:
        a=min(abs(i),a)
    print(a)

f()


### FIXED CODE ###

import sys
import numpy as np
input = sys.stdin.readline
h,w=[int(j) for j in input().split()]
a=[]
b=[]
a=[[int(j) for j in input().split()] for i in range(h)]
b=[[int(j) for j in input().split()] for i in range(h)]
x=(h+w)*80
l=2*x+1
dp=[[0]*w for i in range(h)]
dp[0][0]=np.zeros(l,np.bool)
d=abs(a[0][0]-b[0][0])
dp[0][0][x+d]=1
for i in range(h):
    for j,(s,t) in enumerate(zip(a[i],b[i])):
        if i==j==0:
            continue
        d=abs(s-t)
        p=np.zeros(l,np.bool)
        if i!=0:
            p[d:]|=dp[i-1][j][:l-d]
            p[:l-d]|=dp[i-1][j][d:]
        if j!=0:
            p[d:]|=dp[i][j-1][:l-d]
            p[:l-d]|=dp[i][j-1][d:]
        dp[i][j]=p

ans=np.abs(np.where(dp[-1][-1])[0]-x).min()
print(ans)
### BUGGY CODE ###

n, k = map(int, input().split())
H = list(map(int, input().split()))
inf = float('inf')
dp = [inf] * n
dp[0] = 0
for i in range(n - 1):
    for j in range(1, k + 1):
        if i + j < n:
            dp[i + j] = min(dp[i + j], dp[i] + abs(H[i + j] - H[i]))
print(dp[-1])

### FIXED CODE ###

import sys


def input():
    return sys.stdin.readline().strip()


n, k = map(int, input().split())
H = list(map(int, input().split()))

INF = 10 ** 9
dp = [INF] * n
dp[0] = 0
for i in range(n - 1):
    for j in range(1, k + 1):
        if j >= n - i:
            break
        dp[i + j] = min(dp[i + j], dp[i] + abs(H[i + j] - H[i]))
print(dp[-1])
### BUGGY CODE ###

R, G, B, N = map(int, input().split())
ans = 0
tmp = [R, G, B]
tmp.sort()

rmax = N // tmp[2]
gmax = N // tmp[1]

for i in range(rmax + 1):
  for j in range(gmax + 1):
    if (N - i * tmp[2] - j * tmp[1]) < 0:
      break
    if (N - i * tmp[2] - j * tmp[1]) % tmp[0] == 0:
      ans += 1
#      print(ans, i, j)
print(ans)

### FIXED CODE ###

R, G, B, N = map(int, input().split())
ans = 0
r, g = 0, 0
rmax = N // R
gmax = N // G

if R * G * B == 1:
  for i in range(N + 1):
    ans += N + 1 - i
  print(ans)
  exit()

for i in range(rmax + 1):
  for j in range(gmax + 1):
    if (N - i * R - j * G) < 0:
      break
    if (N - i * R - j * G) % B == 0:
      ans += 1
#      print(ans, i, j)
print(ans)
### BUGGY CODE ###

import itertools

d,g = map(int,input().split())
    
arr = []
    
for i in range(d):
    arr.append(list(map(int,input().split())))
    
ans = 10**10

for i in itertools.product((0,1),repeat=d**2):
    score=0
    num=0
    index=0
    
    for j in range(d):
        if i[j]==1:
            score += (j+1)*100*arr[j][0] + arr[j][1]
            num +=arr[j][0]
        else:
            index = max(j,index)
    
    if g - score <=0:
        ans = min(ans,num)
    
    elif g - score <= (index+1) *100*(arr[index][0]-1):
        num+= -(-(g-score)//(100*(index+1)))
        ans =min(ans,num)

print(ans)

### FIXED CODE ###

d,g = map(int,input().split())
    
arr = []
    
for i in range(d):
    arr.append(list(map(int,input().split())))
    
from itertools import product
from math import ceil
    
ans = 1e09
#各問題を選択するしないを01表記
for c in product([0,1],repeat=d):
    #print(c)
    #スコア
    score = 0
    #解く問題数
    num = 0
    
    ind = 0
    #まず01表記を全て
    for i in range(d):
        #もし01表記で1の場合，完答した場合の点数，問題数を加算
        if c[i] == 1:
            score += arr[i][0]*100*(i+1) + arr[i][1]
            num += arr[i][0]
        #0だった場合，
        else:
            ind = max(i,ind)
    #目標よりも点数が大きかった場合，小さい方を答えにする
    if g - score <= 0:
        ans = min(ans,num)
        #print(0,ans,num,score,ind)
    #もし目標が，点数とind番目の問題を完答してない場合との和より小さい時
    elif g - score <= (arr[ind][0]-1)*100*(ind+1):
        num += ceil((g-score)/(100*(ind+1)))
        ans = min(ans,num)
        #print(1,ans,num,score,ind)
    else:
        pass
#print(2,num,score,ind)
print(ans)
### BUGGY CODE ###

# coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)
#from heapq import heappop, heappush
#from collections import defaultdict
# import math
# from itertools import product, accumulate, combinations, product
# import bisect# lower_bound etc
#import numpy as np
# from copy import deepcopy
#from collections import deque
#import numba

def run():
    H, N = map(int, sysread().split())
    AB = list(map(int, read().split()))
    A = [0] + AB[0::2]
    B = [0] + AB[1::2]

    INF = float('inf')
    dp = [[INF] * (H+1) for _ in range(N+1)]
    dp[0][0] = 0
    for i in range(0, N):
        for v in range(H+1):
            dp[i+1][v] = min(dp[i][v], dp[i+1][v])
            do = True
            pre_v = v
            while do:
                next_v = pre_v + A[i+1]
                if next_v >= H:
                    next_v = H
                    do = False
                dp[i+1][next_v] = min(dp[i+1][next_v], dp[i+1][pre_v] + B[i+1])
                pre_v = next_v
    print(dp[N][H])

if __name__ == "__main__":
    run()

### FIXED CODE ###

# coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)
from heapq import heappop, heappush
#from collections import defaultdict
# import math
# from itertools import product, accumulate, combinations, product
# import bisect# lower_bound etc
#import numpy as np
# from copy import deepcopy
#from collections import deque
#import numba

def run():
    H, N = map(int, sysread().split())
    AB = list(map(int, read().split()))
    A = AB[::2]
    B = AB[1::2]
    Amax = max(A)

    INF = float('inf')
    dp = [[INF] * (H+Amax+1) for _ in range(N+1)]
    dp[0][0] = 0
    for i in range(N):
        for j in range(H+Amax+1):
            tmp = j - A[i]
            if tmp >= 0:
                dp[i+1][j] = min([dp[i][j], dp[i+1][tmp] + B[i]])
            elif j == H and tmp < 0:
                dp[i + 1][H] = min(dp[i][H], dp[i + 1][0] + B[i])
            else:
                dp[i+1][j] = dp[i][j]
    ret = min(dp[N][H:])
    print(ret)



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

A, B = map(int, input().split())

ans = A
for i in range(A+1, B+1):
    ans ^= i

print(ans)

### FIXED CODE ###

A, B = map(int, input().split())
def func(x):
  a = (x+1) // 2
  b = a % 2
  c = x if (x+1) % 2 == 1 else 0
  return b^c
print(func(A-1)^func(B))
### BUGGY CODE ###

# /usr/bin/python
# -*- coding: utf-8 -*-
import sys


n,k = map(int, sys.stdin.readline().rstrip().split())
hn = list(map(int, sys.stdin.readline().rstrip().split())) + [0]*k
dp = [-1] * (n+k)

dp[0] = 0
for i in range(n):
  for j in range(1,k+1):
    if dp[i+j] < 0:
      dp[i+j] = dp[i] + abs(hn[i+j]-hn[i])
    else:
      dp[i+j] = min(dp[i+j], dp[i] + abs(hn[i+j]-hn[i]))

print(dp[n-1])

### FIXED CODE ###

# -*- coding: utf-8 -*-
import math
import sys
import numpy as np

n,k = map(int, sys.stdin.readline().rstrip().split())
h = np.array(list(map(int, sys.stdin.readline().rstrip().split())))

dp = np.zeros(n, dtype=np.int)

for i in range(1,n):
  if i < k:
    dp[i] = np.min(dp[:i] + np.abs(h[i]-h[:i]))
  else:
    dp[i] = np.min(dp[i-k:i] + np.abs(h[i]-h[i-k:i]))

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

n,k=map(int,input().split())
d=input().split()
while 1:
    t=0
    p=list(str(n))
    q=len(p)
    for c in range(q):
        if t==1:
            break
        for b in range(k):
            if p[c]==d[b]:
                n=n+10**c
                t=1
                break
    if t==0:
        break
print(n)

### FIXED CODE ###

n,k=map(int,input().split())
d=input().split()
while 1:
    t=0
    p=list(str(n))
    q=len(p)
    for c in range(q):
        if t==1:
            break
        for b in range(k):
            if p[c]==d[b]:
                n=n+1
                t=1
                break
    if t==0:
        break
print(n)
### BUGGY CODE ###

def f(k, A):
    n = len(A)

    prev = [0] * (k + 1)
    cur = [0] * (k + 1)

    # init for last column
    for j in range(min(A[n - 1], k) + 1):
        prev[j] = 1

    for i in range(n - 2, -1, -1):
        kount = 0
        for j in range(k + 1):
            # dp[i][j] = SUM dp[i - 1][ ...A[i] items before j...]
            kount += prev[j]
            if j > A[i]:
                kount -= prev[j - A[i] - 1]
            cur[j] = kount
        prev, cur = cur, prev

    return prev[-1] % 1000000007

assert f(4, [2, 3]) == 2
assert f(4, [1, 2, 3]) == 5
assert f(10, [9]) == 0
assert f(0, [0, 0]) == 1
#assert f(100000, [100000, 100000, 100000, 100000]) == 665683269

n, k = map(int, input().split())
A = list(map(int, input().split()))
ans = f(k, A)
print(ans)


### FIXED CODE ###

from itertools import accumulate

def f(k, A):
    n = len(A)

    mod = int(1e9 + 7)
    dp = [0] * (k + 1)

    # init for last column
    for j in range(min(A[n - 1], k) + 1):
        dp[j] = 1

    for i in range(n - 2, -1, -1):
        dp = list(accumulate(dp))
        a = A[i]
        dp[a+1:] = [x - y for x, y in zip(dp[a + 1:], dp)]
        dp = [x % mod for x in dp]

    return dp[-1] % mod

assert f(4, [2, 3]) == 2
assert f(4, [1, 2, 3]) == 5
assert f(10, [9]) == 0
assert f(0, [0, 0]) == 1
assert f(100000, [100000, 100000, 100000, 100000]) == 665683269

n, k = map(int, input().split())
A = list(map(int, input().split()))
ans = f(k, A)
print(ans)
### BUGGY CODE ###

N = int(input())
p = 1
for i in range(1,N+1):
    p = p * i
print(p%(10**9+7))
    

### FIXED CODE ###

x = int(raw_input())
a = 1L
for i in range(1, x+1):
 a = a * i
 a = a % 1000000007
print(a)
### BUGGY CODE ###

N = int(input())
S = list(input())
pairs = []
for i, c1 in enumerate(S):
    for j, c2 in enumerate(S[i + 1:], start=i + 1):
        if c1 != c2:
            pairs.append((i, j))
res = 0
for i, j in pairs:
    for k, c3 in enumerate(S[j + 1:], start=j + 1):
        if j - i == k - j:
            continue
        elif S[j] == c3 or S[i] == c3:
            continue
        else:
            res += 1
print(res)

### FIXED CODE ###

N = int(input())
S = list(input())
n = len(S)
pairs = []
for i, c1 in enumerate(S):
    for j, c2 in enumerate(S[i + 1:], start=i + 1):
        if c1 != c2:
            pairs.append((i, j))
prefix = [[0] * 3 for _ in range(len(S) + 1)]
for i, c in enumerate(S, start=1):
    if c == 'R':
        prefix[i][0] += prefix[i - 1][0] + 1
        prefix[i][1] += prefix[i - 1][1]
        prefix[i][2] += prefix[i - 1][2]
    elif c == 'G':
        prefix[i][1] += prefix[i - 1][1] + 1
        prefix[i][0] += prefix[i - 1][0]
        prefix[i][2] += prefix[i - 1][2]
    else:
        prefix[i][2] += prefix[i - 1][2] + 1
        prefix[i][0] += prefix[i - 1][0]
        prefix[i][1] += prefix[i - 1][1]
res = 0
for i, j in pairs:
    if {S[i], S[j]} == {'R', 'G'}:
        res += prefix[-1][2] - prefix[j + 1][2]
        if 2 * j - i < n and S[2 * j - i] == 'B':
            res -= 1
    elif {S[i], S[j]} == {'R', 'B'}:
        res += prefix[-1][1] - prefix[j + 1][1]
        if 2 * j - i < n and S[2 * j - i] == 'G':
            res -= 1
    elif {S[i], S[j]} == {'B', 'G'}:
        res += prefix[-1][0] - prefix[j + 1][0]
        if 2 * j - i < n and S[2 * j - i] == 'R':
            res -= 1
print(res)
### BUGGY CODE ###

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

L.sort()

s = 0
for j in range(N-2):
    for k in range(j+1,N-1):
        Ld = [0] + L[k+1::] + [3000]
        # L[i] < L[j]+L[k] となる L[i]の数を求める
        key = L[j]+L[k]
        l = 0
        r = N - k + 2
        while r - l > 1:
            m = (r + l) // 2
            if Ld[m] < key:
                l = m
            else:
                r = m
        s += l

print(s)

### FIXED CODE ###

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

L.sort()

s = 0

ma = L[N-1]
for j in range(N-2):
    ja = L[j]
    for k in range(j+1,N-1):
        ka = L[k]
        # L[i] < L[j]+L[k] となる L[i]の数を求める
        key = ja + ka
        l = k + 1
        r = N - 1
        while r - l > 1:
            m = l + (r - l) // 2
            if L[m] < key:
                l = m
            else:
                r = m
        kka = L[k+1]
        if kka < key <= ma:
            s += l-k
        elif key <= kka:
            s += 0
        else:
            s += N-k-1

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

X,K,D = map(int,input().split())

A = abs(X)
while A > D:
    A -= D
    K -= 1
    if K == 0:
        break

if K > 0:
    if K%2 == 1:
        A = A - D

print(abs(A))

### FIXED CODE ###

X,K,D = map(int,input().split())
A = abs(X)
ans = 0
if A >= D*K:
    print( A - (D * K))
else :
    e = A//D
    K -= e
    A %= D
    if K%2 == 0:
        print(A)
    else:
        print(D-A)
### BUGGY CODE ###

T = int(input())
ABCD = [list(map(int,input().split())) for _ in range(T)]

for a,b,c,d in ABCD:
    if a < b:
        print('No')
        continue
    if d < b:
        print('No')
        continue
    tmp = a % b
    if tmp > c:
        print('No')
        continue
    if d % b == 0:
        print('Yes')
        continue
    if c >= b:
        print('Yes')
        continue

    dp = [a]
    now = a
    for _ in range(c+2):
        if now < b:
            print('No')
            break
        now %= b
        if now in dp:
            print('Yes')
            break
        if now > c:
            print('No')
            break
        dp.append(now)
        now += d




    

### FIXED CODE ###

#from math import gcd
from fractions import gcd
T = int(input())
ABCD = [list(map(int,input().split())) for _ in range(T)]

for a,b,c,d in ABCD:
    if a < b:
        print('No')
        continue
    if d < b:
        print('No')
        continue
    tmp = a % b
    if tmp > c:
        print('No')
        continue
    if d % b == 0:
        print('Yes')
        continue
    if c >= b-1:
        print('Yes')
        continue
    if a%2 == 0 and b%2 == 0 and d %2 == 0 and b-c == 2:
        print('Yes')
        continue
    GCD = gcd(b,d)
    if b-GCD +(a%GCD) > c:
        print('No')
    else:
        print('Yes')
### BUGGY CODE ###

s = list(input())
ans = 0
while True:
    n = len(s)
    if n <= 1:
        print(ans)
        exit()
    for i in range(n-1):
        if s[i] != s[i+1]:
            del s[i:i+2]
            ans += 2
            break
        if i == n-2:
            print(ans)
            exit()


### FIXED CODE ###

from collections import Counter
s = list(input())
s = Counter(s)
print(min(s['0'], s['1']) * 2)
### BUGGY CODE ###

import bisect

n = int(input())
L = sorted(list(map(int, input().split())))

ans = 0
for i in range(n-1, 1, -1):
    for j in range(i-1, 0, -1):
        ans += j - bisect.bisect_right(L[:j], L[i]-L[j])

print(ans)


### FIXED CODE ###

import bisect

n = int(input())
L = sorted(list(map(int, input().split())))

ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        ans += bisect.bisect_left(L, L[i]+L[j]) - (j+1)

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

N = int(input())
A = list(map(int, input().split()))
B = [0 for i in range(max(A)+1)]
C = [0 for i in range(max(A)+1)]
 
for i in range(2, len(B)):
  if B[i] != 0:
    continue
  for j in range(i, len(B), i):
    B[j] = i
flag1 = False
flag2 = False
 
def func(X):
  global flag1, flag2
  while X>1:
    x = B[X]
    if C[x]==1:
      flag1 = True
    if C[x]==N-1:
      flag2 = True
    C[x] += 1
    while X%x==0:
      X = X//x
    #print(C)
for a in A:
  func(a)
#print(flag1, flag2)
if flag2:
  print("not coprime")
elif flag1:
  print("setwise coprime")
else:
  print("pairwise coprime")


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
 
B = [0 for i in range(max(A)+1)]
 
for i in range(2, len(B)):
  if B[i] != 0:
    continue
  for j in range(i, len(B), i):
    B[j] = i

def func(X):
  buf = set()
  while X>1:
    x = B[X]
    buf.add(x)
    while X%x==0:
      X = X//x
  #print(buf)
  return buf
 
set1 = func(A[0])
set2 = func(A[0])
totallen = len(set1)
for a in A[1:]:
  set3 = func(a)
  totallen += len(set3)
  #print(a, set1, set2)
  set1 |= set3
  set2 &= set3
  #print(set1, set2, set3)
#print(totallen, set1, set2)
if len(set2)!=0:
  print("not coprime")
elif len(set1)==totallen:
  print("pairwise coprime")
else:
  print("setwise coprime")
### BUGGY CODE ###

def main():
    n, q = map(int, input().split())
    s = input()
    q_list = []
    for _ in range(q):
        q_list.append(list(map(int,input().split())))


    for i in range(q):
        ans = 0
        if q_list[i][1] - q_list[i][0] < 2:
            print(0)
            continue
        tmp = s[q_list[i][0]-1:q_list[i][1]]
        ans = tmp.count('AC')
        print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n, q = map(int, input().split())
    s = input()

    tmp = [0] * (n + 1)

    for i in range(1,n):
        tmp[i] = tmp[i-1] + ( 1 if s[i-1] ==  'A' and s[i] ==  'C' else 0 )
    
    for _ in range(q):
        l, r = map(int, input().split())
        print(tmp[r-1] - tmp[l-1])

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

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

DIGIT = 61
MOD = (10**9) +7
count = 0
for i in range(DIGIT):
    one_count = 0
    for num in a_list:
        if (num >> i) % 2 == 1:
            one_count += 1
    comb_1_1 = one_count * (n - one_count)
    count += comb_1_1 * (2**i)
    count = count % MOD
    
print(count)

### FIXED CODE ###

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

DIGIT = 61
MOD = (10**9) +7
count = 0
for i in range(DIGIT):
    one_count = 0
    for num in a_list:
        if (num >> i) % 2 == 1:
            one_count += 1
    comb_1_1 = one_count * (n - one_count)
    count += comb_1_1 * (2**i)
    count = count % MOD
    
print(count)
### BUGGY CODE ###

n, k = map(int, input().split())
a_list = list(map(int, input().split()))

a_set = set(a_list)
a_set_len = len(a_set)
a_count = sorted([a_list.count(i) for i in a_set])

count = 0
i = 0
while(a_set_len > k):
    count += a_count[i] 
    a_set_len -= 1
    i += 1

print(count)


### FIXED CODE ###

from collections import Counter
n, k = map(int, input().split())
a_list = list(map(int, input().split()))

counter = Counter(a_list).most_common()[::-1]

count = 0
for i in range(max((len(counter) - k), 0)):
    count += counter[i][1]

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

import math
def num_divisors_trial_division(n):
    num = 0
    for i in range(1, int(math.sqrt(n) + 1e-9) + 1):
        if n % i == 0:
            num += 1
            if n != i**2:
                num += 1

    return num

N=int(input())
if N==1:
    print(1)
else:
    sum=0
    for i in range(2,N+1):
        sum+=i*num_divisors_trial_division(i)
        #print(temp)
    print(1+sum)

### FIXED CODE ###

N=int(input())
sum=0
for j in range(1,N+1):
    sum+=((N//j)*(N//j+1)//2)*j
print(sum)
### BUGGY CODE ###

N, W = map(int, input().split())
vs = [[] for _ in range(4)]
w1, v1 = map(int, input().split())
vs[0].append(v1)
for i in range(N - 1):
    w, v = map(int, input().split())
    vs[w - w1].append(v)
#print(vs)
for i in range(4):
    vs[i].sort()
#print(vs)
ans = 0
for i in range(N + 1):
    if i * w1 > W:
        break
    if i == 0:
        si = 0
    else:
        si = sum(vs[0][-i:])
    for j in range(N + 1 - i):
        if i * w1 + j * (w1 + 1) > W:
            break
        sj = si
        if j > 0:
            sj += sum(vs[1][-j:])
        for k in range(N + 1 - i - j):
            if i * w1 + j * (w1 + 1) + k * (w1 + 2) > W:
                break
            sk = sj
            if k > 0:
                sk += sum(vs[2][-k:])
            for l in range(N + 1 - i - j - k):
                if i * w1 + j * (w1 + 1) + k * (w1 + 2) + l * (w1 + 3) > W:
                    break
                sl = sk               
                if l > 0:
                    sl += sum(vs[3][-l:])
                ans = max(ans, sl)
print(ans)

### FIXED CODE ###

N, W = map(int, input().split())
vs = [[] for _ in range(4)]
w1, v1 = map(int, input().split())
vs[0].append(v1)
for i in range(N - 1):
    w, v = map(int, input().split())
    vs[w - w1].append(v)
#print(vs)
for i in range(4):
    vs[i].sort()
#print(vs)
ans = 0
for i in range(N + 1):
    if i * w1 > W:
        break
    if i == 0:
        si = 0
    else:
        si = sum(vs[0][-i:])
    for j in range(N + 1 - i):
        if i * w1 + j * (w1 + 1) > W:
            break
        sj = si
        if j > 0:
            sj += sum(vs[1][-j:])
        for k in range(N + 1 - i - j):
            if i * w1 + j * (w1 + 1) + k * (w1 + 2) > W:
                break
            sk = sj
            if k > 0:
                sk += sum(vs[2][-k:])
            for l in range(N + 1 - i - j - k):
                if i * w1 + j * (w1 + 1) + k * (w1 + 2) + l * (w1 + 3) > W:
                    break
                sl = sk               
                if l > 0:
                    sl += sum(vs[3][-l:])
                ans = max(ans, sl)
print(ans)
### BUGGY CODE ###

s = list(input())
n = len(s)

temp = [0]*2019
num = 0
for i in range(n):
    num += int(s.pop())*10**(i)
    temp[num % 2019] += 1

ans = temp[0]
for t in temp:
    if t > 1:
        ans += t*(t-1)/2

print(int(ans))

### FIXED CODE ###

S=input()
N=len(S)
M=2019

remainder=[0]*M
val=0
for i in range(N):
  val=(int(S[N-1-i])*pow(10,i,M)+val)%M
  remainder[val]+=1

ans=remainder[0]
for i in range(2019):
  ans+=remainder[i]*(remainder[i]-1)//2
print(ans)