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

import bisect

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

YZ = Y*Z
BC = []
for b in B:
  for c in C:
    BC.append(b+c)

BC.sort()
# 2つのリストから1つずつ要素を取り出したときに和がx以上となる組合せ
def count_large_2(L1, L2, x):
  L1.sort()
  L2.sort(reverse=True)
  N1, N2 = len(L1), len(L2)
  i = j = 0
  c = 0
  while i<N1 and j<N2:
    if L1[i]+L2[j] >= x:
      c += 1
      j += 1
      if j >= N2:
        c += (N1-i-1) * N2
    else:
      i += 1
      if i>=N1:
        continue
      c += j
  return c


def check(S):
  c = count_large_2(BC, A, S)  
  return c >= K



Sl = 0
Sr = A[0]+B[0]+C[0]+1

while Sr - Sl > 1:
  mid = (Sl + Sr) // 2
  if check(mid):
    Sl = mid
  else:
    Sr = mid


Ans = []
for a in A:
  for b in B:
    if a + b + C[0] < Sr:
      break
    for c in C:
      if a + b + c >= Sr:
        Ans.append(a+b+c)
      else:
        break

Ans.sort(reverse=True)
Ans = Ans + [Sl]*(K-len(Ans))
for ans in Ans:
  print(ans)

### FIXED CODE ###

import bisect

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

YZ = Y*Z
BC = []
for b in B:
  for c in C:
    BC.append(b+c)

BC.sort()
def check(S):
  count = 0
  left = X*Y*Z
  for a in A:
    count += YZ - bisect.bisect_left(BC, S-a)
    left -= YZ
    if count >= K or count+left < K:
      break
  
  return count >= K



Sl = 0
Sr = A[0]+B[0]+C[0]+1

while Sr - Sl > 1:
  mid = (Sl + Sr) // 2
  if check(mid):
    Sl = mid
  else:
    Sr = mid

Ans = []
for a in A:
  for b in B:
    if a + b + C[0] < Sr:
      break
    for c in C:
      if a + b + c >= Sr:
        Ans.append(a+b+c)
      else:
        break

Ans.sort(reverse=True)
Ans = Ans + [Sl]*(K-len(Ans))
for ans in Ans:
  print(ans)
### BUGGY CODE ###

N = int(input())
A = input().split()
flag = 1

for j in range(N):
	for i in range(N):
		if i+j+1<N:
			if A[j] == A[i+j+1]:
				flag = 0
				break
if flag==0:
	print('NO')
elif flag==1:
	print('YES')



### FIXED CODE ###

N = int(input())
A = input().split()
flag = 1
A.sort()

for i in range(N-1):
	if A[i] == A[i+1]:
		flag = 0
		break
if flag==0:
	print('NO')
elif flag==1:
	print('YES')
### BUGGY CODE ###

def f(n, hs, a_s):
    sum_a = [0] * n
    sum_a[0] = a_s[0]
    for ai, a in enumerate(a_s[1:]):
        mx = 0
        h = hs[ai + 1]
        for i in range(ai + 1):
            if h > hs[i]:
                if sum_a[i] > mx:
                    mx = sum_a[i]
        sum_a[ai + 1] = a + mx
    return sum_a[-1]


n = int(input())
hs = list(map(int, input().split()))
a_s = list(map(int, input().split()))
print(f(n, hs, a_s))


### FIXED CODE ###

def get(i):
    mx = 0
    while i > 0:
        if bit[i] > mx:
            mx = bit[i]
        i -= i & -i
    return mx


def update(i, x):
    while i < n + 1:
        if x > bit[i]:
            bit[i] = x
        i += i & -i


n = int(input())
hs = list(map(int, input().split()))
a_s = list(map(int, input().split()))

bit = [0] * (n + 1)
for h, a in zip(hs, a_s):
    update(h, get(h - 1) + a)
print(max(bit))
### BUGGY CODE ###

import sys
from collections import deque
readline = sys.stdin.readline
n, m = map(int, readline().split())
P = list(map(lambda x:int(x)-1, readline().split()))
G = [set() for _ in range(n)]
for i in range(m):
    x, y = map(lambda x:int(x)-1, readline().split())
    G[x].add(y)
    G[y].add(x)

D = {}
cnt = 0
V = [-1]*n
while -1 in V:
    st = V.index(-1)
    que = deque([st])
    V[st] = cnt
    D[cnt] = set([P[st]])
    while que:
        nw = que.popleft()
        for nx in G[nw]:
            if V[nx] != -1: continue
            D[cnt].add(P[nx])
            V[nx] = cnt
            que.append(nx)
    cnt += 1
print(sum([int(i in D[V[i]]) for i in range(n)]))

### FIXED CODE ###

import sys
readline = sys.stdin.readline

class UnionFind(object):
    def __init__(self, n):
        self._par = list(range(n))
        self.size = [1]*n

    def root(self, v):
        if self._par[v] == v:
            return v
        self._par[v] = self.root(self._par[v])
        return self._par[v]
    
    def unite(self, u, v):
        u, v = self.root(u), self.root(v)
        if u==v:
            return False
        if self.size[u] > self.size[v]:
            u, v = v, u
        self.size[v] += self.size[u]
        self._par[u] = v

    def is_connected(self, u, v):
        return self.root(u)==self.root(v)

n, m = map(int, readline().split())
P = list(map(lambda x:int(x)-1, readline().split()))
uf = UnionFind(n)
for _ in range(m):
    x, y = map(lambda x:int(x)-1, readline().split())
    uf.unite(x,y)

ans = 0
for i in range(n):
    if uf.is_connected(i, P[i]):
        ans += 1
print(ans)
### BUGGY CODE ###

n=int(input())
p=[int(x) for x in input().split()]
a=1
for i in range(1,n):
  if p[i]<=min(p[:i]):
    a+=1
print(a)    

### FIXED CODE ###

n=int(input())
p=[int(x) for x in input().split()]
a=1
b=p[0]
for i in range(1,n):
  if p[i-1]<b:
    b=p[i-1]
  if p[i]<=b:
    a+=1
print(a)
### BUGGY CODE ###

# https://atcoder.jp/contests/abc151/tasks/abc151_e

def calc(x,y):
    a = fac[x]
    b = fac[y]
    c = fac[x-y]
    ret = ( (a%p)*pow(b,p-2,p)*pow(c,p-2,p))%p
    return ret

N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
p=10**9+7

fac=[1]
for i in range(1,N+1):
    fac.append( (fac[-1]*i)%p )
#print(fac)

ans=0
for L in range(N-K+1):
    for R in range(L+K-1,N):
        if L==R:
            tmp=0
            diff=0
            #print(L,R,diff)
        elif L+(K-1)==R:
            diff= A[R]-A[L]
            ans += diff
            #print(L,R,diff)
        else:
            tmp = calc(R-L-1,K-2)
            diff= tmp*(A[R]-A[L])
            ans += diff            
            #print(L,R,diff)
        ans %=p
            
print(ans)

### FIXED CODE ###

# https://atcoder.jp/contests/abc151/tasks/abc151_e

def calc(x,y):
    a = fac[x]
    b = fac[y]
    c = fac[x-y]
    ret = ( (a%p)*pow(b,p-2,p)*pow(c,p-2,p))%p
    return ret

N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
p=10**9+7

fac=[1]
for i in range(1,N+1):
    fac.append( (fac[-1]*i)%p )
#print(fac)

ans=0

for i in range(N):
    if i<=N-K:
        nokori = N-1-i
        kumi = calc(nokori,K-1)
        ans -= (A[i]*kumi)%p
    if i>=K-1:
        nokori = i
        kumi = calc(nokori,K-1)
        ans += (A[i]*kumi)%p
        
print(ans%p)

#for L in range(N-K+1):
#    for R in range(L+K-1,N):
#        if L==R:
#            tmp=0
#            diff=0
#            #print(L,R,diff)
#        elif L+(K-1)==R:
#            diff= A[R]-A[L]
#            ans += diff
#            #print(L,R,diff)
#        else:
#            tmp = calc(R-L-1,K-2)
#            diff= tmp*(A[R]-A[L])
#            ans += diff            
#            #print(L,R,diff)
#        ans %=p
### BUGGY CODE ###

n,k=map(int,input().split())
*a,= map(int,input().split())
*f,= map(int,input().split())
a=sorted(a)
f=sorted(f, reverse=True)

def is_ok(arg):
    cnt=0
    for i in range(n):
        cnt+=max(a[i]-arg//f[i], 0)
    return cnt<=k

def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

print(meguru_bisect(-1, 10**12))


### FIXED CODE ###

import numpy as np
N, K= map(int, input().split())
A=[int(i) for i in input().split()]
F=[int(i) for i in input().split()]

A=np.array(sorted(A, reverse=True))
F=np.array(sorted(F))

lower_bound=0
upper_bound=np.max(A*F)
K_tmp=0

while upper_bound>=lower_bound:
    mid=(lower_bound+upper_bound)//2
    K_tmp=np.sum(np.maximum(A-mid//F, 0))
    if K_tmp<=K:
        upper_bound=mid-1
    else:
        lower_bound=mid+1

print(lower_bound)
### BUGGY CODE ###

import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
a = na()
q = ni()
c = [na() for _ in range(q)]

for i in c:
  a = [i[1] if i[0] == l else l for l in a]
  print(sum(a))

### FIXED CODE ###

import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
a = na()
q = ni()
l = [na() for _ in range(q)]

import collections

c = collections.Counter(a)
ans = sum(a)
for i in l:
  if c[i[0]] >0:
    ans = ans - c[i[0]]*i[0] + i[1]*(c[i[0]])
    c[i[1]] = c[i[1]] + c[i[0]]
    c[i[0]] = 0
    print(ans)
  else:
    print(ans)
### BUGGY CODE ###

x = int(input())
for i in range(x):
    for j in range(-int((x)**(1/5))-1,int((x)**(1/5))+1):
        if i**5 - j**5 == x:
            print(i,j)
            break
    else:
        continue
    break

### FIXED CODE ###

x = int(input())

for i in range(-200,200):
    for j in range(-200,200):
        if i**5 - j**5 == x:
            print(i,j)
            exit()
### BUGGY CODE ###

def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]
n = I()
li = LI()
ans = 1
for k in li:
  ans = ans*k
if ans > 10**18:
  print(-1)
else:
  print(ans)

### FIXED CODE ###

def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]
n = I()
li = LI()
ans = 1
if 0 in li:
  print(0)
else:
  for k in li:
    ans *= k
    if ans > 10**18:
      print(-1)
      break
  else:
    print(ans)
### BUGGY CODE ###

def main():
 
  import sys
  input = sys.stdin.readline
  
  import collections
 
  N = int(input())
  S = list(input())
 
  CNT_S = collections.Counter(S)
 
  cnt_r = CNT_S['R']
  cnt_b = CNT_S['B']
  cnt_g = CNT_S['G']
 
  total = cnt_r * cnt_g * cnt_b
  subdu = 0
 
 
  for pos in range(N):
      for i in range(1, N):
 
          index_r = pos
          index_m = pos + i
          index_l = pos + 2 * i
 
          if (index_l < N and index_m < N and index_r < N):
              if (S[index_l] != S[index_m] and S[index_l] != S[index_r] and S[index_m] != S[index_r]):
                  subdu += 1
 
 
  ans = total - subdu
 
  print(ans)
  
if __name__ == '__main__':
    main()
 

### FIXED CODE ###

import collections

N = int(input())
S = list(input())

CNT_S = collections.Counter(S)

cnt_r = CNT_S['R']
cnt_b = CNT_S['B']
cnt_g = CNT_S['G']

total = cnt_r * cnt_g * cnt_b
subdu = 0


for pos in range(N):
    for i in range(1, N):
    
        index_r = pos
        index_m = pos + i
        index_l = pos + 2 * i
        
        if (index_l < N and index_m < N and index_r < N):
            if (S[index_l] != S[index_m] and S[index_l] != S[index_r] and S[index_m] != S[index_r]):
                subdu += 1


ans = total - subdu

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

import sys
sys.setrecursionlimit(1000000000)
N = int(input())

def recursive(n):
    if n==0:
        return 2
    elif n==1:
        return 1
    else:
        return recursive(n-1)+recursive(n-2)

print(recursive(N))

### FIXED CODE ###

import sys
from functools import lru_cache
sys.setrecursionlimit(1000000000)

N = int(input())

@lru_cache(maxsize=1000)
def recursive(n):
    if n==0:
        return 2
    elif n==1:
        return 1
    else:
        return recursive(n-1)+recursive(n-2)

print(recursive(N))
### BUGGY CODE ###

from collections import deque
N,M,K=map(int,input().split())
F,B=[[] for _ in range(N)],[[] for _ in range(N)]
for _ in range(M):
  a,b = map(int,input().split())
  a,b = a-1,b-1
  F[a].append(b)
  F[b].append(a)
for _ in range(K):
  c,d = map(int,input().split())
  c,d=c-1,d-1
  B[c].append(d)
  B[d].append(c)
#print(F,B)
C=[[] for _ in range(N)]
for i,f in enumerate(F):
  store = deque([i])
  c = []
  while len(store)>0:
    s = store.popleft()
    if s in c:continue
    c.append(s)
    store.extend(F[s])
  c = [v for v in c if v != i and v not in f and v not in B[i]]
  C[i]=c
#print(F,B,C)
print(' '.join([str(len(v)) for v in C]))

### FIXED CODE ###

from sys import setrecursionlimit 
setrecursionlimit(10**6)

n, m, k = map(int, input().split())

fr = [set() for _ in range(n)]
bl = [set() for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    fr[a-1].add(b-1)
    fr[b-1].add(a-1)
    
for i in range(k):
    c ,d = map(int, input().split())
    bl[c-1].add(d-1)
    bl[d-1].add(c-1)
    
def dfs(v, temp):
    visited[v] = True
    temp.add(v)
    for i in fr[v]:
        if visited[i] == False:
            temp = dfs(i, temp)
    return temp
visited = [False]*n

cc = [0]*n
for v in range(n):
    if visited[v] == False:
        c = dfs(v,set())
        for i in c:
            cc[i] = c


ans = []
for i in range(n):
    aa = len(cc[i]) - len(cc[i] & fr[i]) - len(cc[i] & bl[i]) - 1
    ans.append(aa)
print(*ans)
### BUGGY CODE ###

n = int(input())
s = set()

for i in range(n):
    s = {input()} ^ s

print(len(s))


### FIXED CODE ###

import sys
input = sys.stdin.readline

import bisect

def main():
    n = int(input())
    s = []

    for i in range(n):
        a = int(input())
        i = bisect.bisect_left(s, a)
        if len(s) > i and s[i] == a:
            s.remove(a)
        else:
            s.insert(i, a)


    print(len(s))


main()
### BUGGY CODE ###

n, x0, y0 = list(map(int, input().split()))

cards = [y0] + list(map(int, input().split()))

xs = [[-1] * (n+1) for i in range(n+1)]
ys = [[-1] * (n+1) for i in range(n+1)] 
#xs[i][j] = xの手番で、xがcards[i]を持ちyがcards[j]を持っているとき(i<j)の最善スコア
#ys[i][j] = yの手番で、xがcards[j]を持ちyがcards[i]を持っているとき(i<j)の最善スコア

########ys[i][j] = yの手番で、xがcards[i]を持ちyがcards[j]を持っているとき(i>j)の最善スコア

for i in range(n+1):
	xs[i][-1] = abs(cards[-1] - cards[i])
	ys[i][-1] = abs(cards[-1] - cards[i])

for i in range(n-1, -1, -1):

	# x[i][j] = max (y[j][j+1] , y[j][j+2] , ……, y[j][n-1] )
	for j in range(n-1, i, -1):
		# temp_max = max(ys[j][j+1:n-1])
		# xs[i][j] = max(temp_max, ys[j][n-1])
		xs[i][j] = max(ys[j][j+1:n+1])

	for j in range(n-1, i, -1):
		# temp_min = min(xs[j][j+1:n-1])
		# ys[i][j] = min(temp_min, xs[j][n-1])
		ys[i][j] = min(xs[j][j+1:n+1])

# print(max(xs[0][0], abs(cards[-1] - x0)) )

# print(xs)
# print(ys)
print(max(ys[0][1:]))	


### FIXED CODE ###

n, x0, y0 = list(map(int, input().split()))

cards = [y0] + list(map(int, input().split()))
# yの手持ちはゲームに関与するため、リストに加えてしまう

xs = [[-1] * (n+1) for i in range(n+1)]
ys = [[-1] * (n+1) for i in range(n+1)] 
#xs[i][j] = xの手番で、xがcards[i]を持ちyがcards[j]を持っているとき(i<j)の最善スコア
#ys[i][j] = yの手番で、xがcards[j]を持ちyがcards[i]を持っているとき(i<j)の最善スコア

for i in range(n+1):
	xs[i][-1] = abs(cards[-1] - cards[i])
	ys[i][-1] = abs(cards[-1] - cards[i])

for j in range(n-1, -1, -1):

	# x[i][j] = max (y[j][j+1] , y[j][j+2] , ……, y[j][n] )
	xs_temp = max(ys[j][j+1:n+1])
	ys_temp = min(xs[j][j+1:n+1])
	for i in range(0, j):
		xs[i][j] = xs_temp
		ys[i][j] = ys_temp

# print(xs)
# print(ys)
print(max(ys[0][1:]))
### BUGGY CODE ###

from itertools import product, permutations
n, c = map(int, input().split())
d = [list(map(int, input().split())) for _ in range(c)]
grid = [list(map(int, input().split())) for _ in range(n)]
cost = [[0] * c for _ in range(3)]

for i, j, k in product(range(n), range(n), range(c)):
    # cost[0][k] -> 余りが0になる場所の色をkに変えるときのコスト
    cost[(i + j + 2) % 3][k] += d[grid[i][j] - 1][k]

ans = []
for s, t, u in permutations(range(c), r=3):
    ans.append(cost[0][s] + cost[1][t] + cost[2][u])
print(min(ans))

### FIXED CODE ###

#%% D
from itertools import product, permutations
n, c = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(c)]
C = [list(map(int, input().split())) for _ in range(n)]


X = [[0] * c for i in range(3)]

for i in range(n):
    for j in range(n):
        X[(i + j + 2) % 3][C[i][j] - 1] += 1

cost = [[0] * c for i in range(3)]

for i in range(c):
    for j in range(c):
        cost[0][j] += X[0][i] * D[i][j]
        cost[1][j] += X[1][i] * D[i][j]
        cost[2][j] += X[2][i] * D[i][j]

ans = []
for s, t, u in permutations(range(c), r=3):
    ans.append(cost[0][s] + cost[1][t] + cost[2][u])
print(min(ans))
### BUGGY CODE ###

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

ans = 0
use_list = []
for i in range(2**N):
    use_list.append(list(map(int, list(bin(i)[2::].zfill(N)))))
for u in use_list:
    s = 0
    
    for i in range(N):
        if u[i] == 1:
            s += a[i]
    if s < x:
        ans = max(ans, sum(u)-1)
    elif s == x:
        ans = max(ans, sum(u))
print(ans)

### FIXED CODE ###

N, x = map(int, input().split())
a = list(map(int, input().split()))
dp = [[]]
a.sort()
ans = 0
f = False
for b in a:
    if b <= x:
        ans += 1
        x -= b
        f = True
    else:
        f = False
if x > 0 and f:
    ans -= 1
print(ans)
### BUGGY CODE ###

import collections
S = []
ans = []
N = int(input())
for i in range(N):
    s = input()
    S.append(s)
c = collections.Counter(S)
j = 0
while c.most_common()[j][1]==c.most_common()[0][1] and j<len(collections.Counter(S)):
    if j==len(collections.Counter(S))-1:
        ans.append(c.most_common()[j][0])
        break
    ans.append(c.most_common()[j][0])
    j+=1
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i])

### FIXED CODE ###

from collections import Counter
S = []
N = int(input())
for i in range(N):
    s = input()
    S.append(s)

c = Counter(S)
max_num = max(c.values())
max_list = [i for i,j in c.items() if j==max_num]
max_list.sort()
print('\n'.join(max_list))
### BUGGY CODE ###

a, b, x = map(int, input().split())
ans = 0
for i in range(a,b+1):
  if i%x == 0:
    ans += 1
print(ans)

### FIXED CODE ###

def hoge(a,x):
  if a == 0:
    return 0
  else:
    return a//x

a, b, x = map(int, input().split())

ans = hoge(b,x) - hoge(a-1,x)
print(ans)
### BUGGY CODE ###

from sys import stdin

[K, S] =  [int(x) for x in (stdin.readline().rstrip().split())]

# combination of given X, Y, Z, that satisfy
# 0<= X, Y, Z <= K
# 0<= S <=3K
# X+Y+Z = S
# 2<= K<=2500

count = 0

for i in range(K+1):
    if i>S:
        break
    for j in range(K+1):
        if i+j>S:
            break
        if i+j<=S and K+i+j>=S:
            count+=1

print(count)






### FIXED CODE ###

from sys import stdin

[K, S] =  [int(x) for x in (stdin.readline().rstrip().split())]

# combination of given X, Y, Z, that satisfy
# 0<= X, Y, Z <= K
# 0<= S <=3K
# X+Y+Z = S
# 2<= K<=2500

count = 0

for i in range(K+1):
    for j in range(K+1):
        if i+j<=S and K+i+j>=S:
            count+=1

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

s=input()
K=int(input())

_set=set()

for i in range(len(s)):
  for j in range(i+1, len(s)+1):
    #print(i,j)
    _set.add(s[i:j])

#print(sorted(list(_set)))
print(sorted(list(_set))[K-1])

### FIXED CODE ###

s=input()
K=int(input())

memo=set()
for i in range(len(s)):
  for j in range(1,min(len(s)-i+1,K+1)):
    memo.add(s[i:i+j])
    
memo=list(memo)
memo.sort()
#print(memo)
print(memo[K-1])
### BUGGY CODE ###

import bisect
import sys
import math


def get_iv():
    args = sys.stdin.readline()
    argv = args.split()
    iargv = [int(arg) for arg in argv]
    return iargv


def min_mod_prod(L, R):
    min_rem = 2019
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            tst = (i * j) % 2019
            if tst < min_rem:
                minij = [i, j]
                min_rem = tst
    minij.append(min_rem)
    return minij


def main():
    specs = get_iv()
    L = specs[0]
    R = specs[1]
    rv = min_mod_prod(L, R)
    #print(rv)
    print(rv[2])


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
import math


def get_iv():
    args = sys.stdin.readline()
    argv = args.split()
    iargv = [int(arg) for arg in argv]
    return iargv


def min_mod_prod(L, R):
    min_rem = 2019
    for i in range(L, R + 1):
        if min_rem == 0:
            break
        for j in range(i + 1, R + 1):
            if min_rem == 0:
                break
            tst = (i * j) % 2019
            if tst < min_rem:
                minij = [i, j]
                min_rem = tst

    minij.append(min_rem)
    return minij


def main():
    specs = get_iv()
    L = specs[0]
    R = specs[1]
    rv = min_mod_prod(L, R)
    # print(rv)
    print(rv[2])


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

N,K=map(int,input().split())
A=list(map(int,input().split()))
B=set(A)
C=[]
ans=0
for i in B:
  C.append(A.count(i))
C.sort()
for i in range(len(C)-K):
  ans+=C[i]
print(ans)  

### FIXED CODE ###

import numpy as np
N,K=map(int,input().split())
A=list(map(int,input().split()))
B=np.zeros(N)
for i in A:
  B[i-1]+=1
C=sorted([i for i in B if i != 0])
ans=0
for i in range(len(C)-K):
  ans+=C[i]
print(int(ans))
### BUGGY CODE ###

import sys
import numpy as np
input = sys.stdin.buffer.readline
a,b=map(int,input().split())
L=[i for i in range(a,b+1)]
L1=np.array(L)
L2=np.prod(L1)
print("Positive" if L2>0 else "Zero" if L2==0 else "Negative")

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
a,b=map(int,input().split())
if a>0:
    print("Positive")
    exit(0)
elif a<=0 and 0<=b:
    print("Zero")
    exit(0)
elif a<0 and b<0:
    num=b-a+1
    if num%2==0:
        print("Positive")
        exit(0)
    else:
        print("Negative")
        exit(0)
### BUGGY CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort()
F.sort(reverse=True)

l = 0
r = 10**12 + 1

while l < r:
    m = (l + r) // 2
    if sum(max(a - m // f, 0) for a, f in zip(A, F)) <= K:
        r = m
    else:
        l = m + 1

print(r)


### FIXED CODE ###

import numpy as np

N, K = map(int, input().split())
A = np.array(input().split(), np.int64)
F = np.array(input().split(), np.int64)
A.sort()
F.sort()
F = F[::-1]

l = 0
r = (A * F).max()

while l < r:
    m = (l + r) // 2
    if np.maximum(A - m // F, 0).sum() <= K:
        r = m
    else:
        l = m + 1

print(r)
### BUGGY CODE ###

N = int(input())
M = 1

while M < N:
    M <<= 1

mask = []
K = M
while K // 2 > 0:
    s = (1 << (K // 2)) - 1
    m = 0
    for _ in range(M // K):
        m <<= K
        m += s
    mask.append(m)
    K >>= 1
mask = mask[::-1]

def popcnt(n):
    for i, m in enumerate(mask):
        n = (n & m) + ((n >> (1 << i)) & m)
    return n

def f(n):
    ret = 0
    while n > 0:
        ret += 1
        n %= popcnt(n)
    return ret

X = 0
for s in input():
    X <<= 1
    if s == '1':
        X += 1

ans = [f(X ^ (1 << i)) for i in range(N)]
print(*ans[::-1], sep='\n')


### FIXED CODE ###

N = int(input())
X = input()

cnt = X.count('1')
if cnt == 1:
    for x in X[:-1]:
        if x == '0':
            print(1)
        else:
            print(0)
    if X[-1] == '1':
        print(0)
    else:
        print(2)
    exit()

M = 0
for x in X:
    M <<= 1
    if x == '1':
        M += 1

def solve(n):
    ret = 1
    while n > 0:
        ret += 1
        n %= bin(n).count('1')
    return ret

ans = []
p = M % (cnt + 1)
m = M % (cnt - 1)

for i in range(N):
    if X[i] == '0':
        ans.append(solve((p + pow(2, N - i - 1, cnt + 1)) % (cnt + 1)))
    else:
        ans.append(solve((m - pow(2, N - i - 1, cnt - 1)) % (cnt - 1)))
print(*ans, sep='\n')