Harryxun/stf_run huggingface dataset:
n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ai = -1
bi = -1
answer = 0
t_sum = 0
if sum(a) + sum(b) <= k:
    print(n + m)
elif sum(a) <= k:
    t_sum = sum(a)
    ai = n-1
    while True:
        bi += 1
        if t_sum + b[bi] > k:
            break
        t_sum += b[bi] 
    bi -= 1
    answer = ai + bi + 2
    while ai >= 0:
        t_sum -= a[ai]
        ai -= 1
        while bi <= m-1:
            bi += 1
            if t_sum + b[bi] > k:
                break
            t_sum += b[bi]
        bi -= 1
        if ai + bi +2 > answer:
            answer = ai + bi +2
    print(answer)
else:
    while True:
        ai += 1
        if t_sum + a[ai] > k:
            break
        t_sum += a[ai] 
    ai -= 1
    while True:
        bi += 1
        if t_sum + b[bi] > k:
            break
        t_sum += b[bi] 
    bi -= 1
    answer = ai + bi + 2
    while ai >= 0:
        t_sum -= a[ai]
        ai -= 1
        while bi <= m-1:
            bi += 1
            if t_sum + b[bi] > k:
                break
            t_sum += b[bi]
        bi -= 1
        if ai + bi +2 > answer:
            answer = ai + bi +2
    print(answer)

### FIXED CODE ###

n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ai = -1
bi = -1
answer = 0
t_sum = 0
if sum(a) + sum(b) <= k:
    print(n + m)
elif sum(a) <= k:
    t_sum = sum(a)
    ai = n-1
    while True:
        bi += 1
        if bi == m:
            break
        if t_sum + b[bi] > k:
            break
        t_sum += b[bi] 
    bi -= 1
    answer = ai + bi + 2
    while ai >= 0:
        t_sum -= a[ai]
        ai -= 1
        while bi <= m-1:
            bi += 1
            if bi == m:
                break
            if t_sum + b[bi] > k:
                break
            t_sum += b[bi]
        bi -= 1
        if ai + bi +2 > answer:
            answer = ai + bi +2
    print(answer)
else:
    while True:
        ai += 1
        if t_sum + a[ai] > k:
            break
        t_sum += a[ai]
    ai -= 1
    while True:
        bi += 1
        if bi == m:
            break
        if t_sum + b[bi] > k:
            break
        t_sum += b[bi]
    bi -= 1
    answer = ai + bi + 2
    while ai >= 0:
        t_sum -= a[ai]
        ai -= 1
        while bi <= m-1:
            bi += 1
            if bi == m:
                break
            if t_sum + b[bi] > k:
                break
            t_sum += b[bi]
        bi -= 1
        if ai + bi +2 > answer:
            answer = ai + bi +2
    print(answer)
# ３桁の整数の入力
s = input('')
i = 0
# 1から3桁目までの繰り返し
	for j in range(3):
# 1桁目のチェック
		if s[j] == '1':
			i += 1
		else:
			i += 0
print(i)

### FIXED CODE ###

# ３桁の整数の入力
s = input()
i = 0
# 1から3桁目までの繰り返し
for j in range(3):
# 1桁目のチェック
	if s[j] == '1':
		i += 1
	else:
		i += 0

print(i)
N = int(input())
A = []
c=0
f = True
for i in range(N):
  A.append(list(map(int, input().split())))
idx = [0 for i in range(N)]

a = 0

cc = 0

ccc = 0

btlf = [False for i in range(N)]#その周回ですでにバトルしたかどうかのフラグです
m = (N*(N-1))//2
n = 100000
for i in range(min(m,n)):#周回
  btlf = [False for i in range(N)]#リセット
  ccc = 0
  for j in range(N):
    #print(idx)
    if idx[j] != N-1:
      a = A[j][idx[j]]
      if a>j:
        if A[a-1][idx[a-1]]-1==j and btlf[a-1] == False and btlf[j] == False:
          idx[a-1]+=1
          btlf[a-1] = True
          idx[j]+=1
          btlf[j] = True
          cc+=1
          ccc+=1
  if cc == m:#idx == [N-1 for i in range(N)]:
    print(i+1)
    f = False
    break
  if ccc == 0:#対戦が一度もなければ打ち切ります
    break
if f:
  print(-1)

### FIXED CODE ###

S = input()
T = input()
c = 0
if S[0]==T[0]:
  c += 1
if S[1]==T[1]:
  c += 1
if S[2]==T[2]:
  c += 1
print(c)
import math
a, b, x = map(int, input().split())
n = a * b
x /= a
if x / n < 0.5:
    c = (2 * (n - x)) / b - a
    d = a - c
    atan = math.degrees(math.atan(d / b))
else:
    c = 2 * x / a - b
    d = b - c
    atan = math.degrees(math.atan(a / d))

print(90 - atan)

### FIXED CODE ###

import math
a, b, x = map(int, input().split())
n = a * b
x /= a
if x / n < 0.5:
    d = 2 * x / b
    atan = math.degrees(math.atan(d / b))
    ans = 90 - atan
else:
    y = n - x
    d = 2 * y / a
    ans = math.degrees(math.atan(d / a))

print(ans)
a = input()
if a = "Sunny":
  print("Cloudy")
elif a = "Cloudy":
  print("Rainy")
else:
  print("Sunny")

### FIXED CODE ###

a = input()
if a == "Sunny":
  print("Cloudy")
elif a == "Cloudy":
  print("Rainy")
else:
  print("Sunny")
S = input()

if S[0] == S[1]:
  print(Bad)
  break
elif S[1] == S[2]:
  print(Bad)
  break
elif S[2] == S[3]:
  print(Bad)
  break
else:
  print(Good)
  
  

### FIXED CODE ###

s =input()

if s[0] == s[1]:
  print('Bad')
elif s[1] == s[2]:
  print('Bad')
elif s[2] == s[3]:
  print('Bad')
else:
  print('Good')
from sys import stdin
import math



def lcm(x, y):
    return (x * y) // math.gcd(x, y)

a,b = stdin.readline().rstrip().split()


print(lcm(int(a), int(b)))

### FIXED CODE ###

from sys import stdin
import fractions





a,b = [int(x) for x in stdin.readline().rstrip().split()]

f=fractions.gcd(a,b)
f2=a*b//f
print(f2)
n = int(input())
h = input().split(' ')

for i in reversed(range(n)):
    if i < n - 1:
        if int(h[i]) > int(h[i + 1]):
            h[i] -= 1
            if int(h[i]) > int(h[i + 1]):
                print('No')
                exit()

print('Yes')

### FIXED CODE ###

n = int(input())
h = input().split(' ')

for i in reversed(range(n)):
    if i < n - 1:

        h[i] = int(h[i])
        h[i + 1] = int(h[i + 1])

        if h[i] > h[i + 1]:
            h[i] -= 1
            if h[i] > h[i + 1]:
                print('No')
                exit()

print('Yes')
N,M = map(int,input().split())

lis = [[] for _ in range(N+1)]
for i in range(M):
    A,B = map(int,input().split())
    A,B = min(A,B),max(A,B)
    lis[A].append(B)

cnt = 0
seen = [False]*(N+1)
def dfs(v,graph):
    global cnt
    seen[v] = True
    for next_v in graph[v]:
        if seen[next_v] == True:
             continue
        if seen[next_v] == []:
             continue
        cnt += 1
        dfs(next_v,graph)
    return cnt

ma = 0
for j in range(N):
    cnt = 0
    if seen[j] == True:
        continue
    ma = max(ma,dfs(j,lis))
print(ma+1)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

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

lis = [[] for _ in range(N+1)]
for i in range(M):
    A,B = map(int,input().split())
    lis[A].append(B)
    lis[B].append(A)
    
cnt = 0
seen = [False]*(N+1)
def dfs(v,graph):
    global cnt
    seen[v] = True
    for next_v in graph[v]:
        if seen[next_v] == True:
             continue
        if seen[next_v] == []:
             continue
        cnt += 1
        dfs(next_v,graph)
    return cnt

ma = 0
for j in range(N):
    cnt = 0
    if seen[j] == True:
        continue
    ma = max(ma,dfs(j,lis))
print(ma+1)
andb=(raw_input()).split(" ")
a=int(aandb[0])
b=int(aandb[1])
print a,
if a == b:
    print "==",
elif a > b:
    print ">",
else:
    print "<",
print b

### FIXED CODE ###

aandb=(raw_input()).split(" ")
a=int(aandb[0])
b=int(aandb[1])

print "a",

if a > b:
    print ">",
elif a < b:
    print "<",
else:
    print "==",

print "b"
n=int(input())
ans=''
while n>=26:
    s=n%26
    n=n//26
    ans+=(chr(s+96))
ans+=(chr(n+96))
print(ans)

### FIXED CODE ###

a=input()
   
if str.isupper(a):
    print("A")
else:
    print("a")
# 与えられた数値の桁数と桁値の総和を計算する.
def calc_digit_sum(num):
    digits = sums = 0
    while num > 0:
        digits += 1
        sums += num % 10
        num //= 10
    return digits, sums


n = int(input())
arr = map(int, input().split())

MOD = 10 ** 9 + 7

answer = 0
t = itertools.combinations(arr, 2)
for i in t:
    answer = (answer + i[0] * i[1]) % MOD

print(answer)

### FIXED CODE ###

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

mod = 10 ** 9 + 7
sums = sum(arr)

answer = 0
for num in arr:
    sums -= num
    answer = (answer + (sums * num)) % mod

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

for _ in range(min(K, N ** 0.5)):
    lamp = [0 for i in range(N + 1)]
    for i in range(N):
        lamp[max(0, i - A[i])] += 1
        lamp[min(N, i + A[i] + 1)] -= 1

    ans = 0
    for i in range(N):
        ans += lamp[i]
        A[i] = min(ans, N)

[print(A[i], end=' ') if i != N - 1 else print(A[i]) for i in range(N)]


### FIXED CODE ###

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

for i in range(min(K, 50)):
    B = [0 for i in range(N)]
    for j in range(0, N):
        l = max(0, j - A[j])
        r = min(N - 1, j + A[j])
        B[l] += 1
        if r + 1 < N:
            B[r + 1] -= 1

    for j in range(1, N):
        B[j] += B[j - 1]
        
    A = B

[print(i, end=' ') for i in B]
print()
N,M=map(int,input().split())
import heapq
A=list(map(int,input().split()))
heapq.heapify(A)
BC=[]
for i in range(M):
  B,C=map(int,input().split())
  BC.append((B,C))
BC.sort(key=lambda x:x[1],reverse=True)
import bisect
A.sort()
now=0
D=[0]*N
for i in range(M):
  B=BC[i][0]
  C=BC[i][1]
  for j in range(now,min(now+B,N)):
    D[j]=C
  now+=B
  if now>N-1:
    break

for i in range(N):
  a=A[i]
  d=D[i]
  if d>a:
    A[i]=d
  else:
    break
print(sum(A))


### FIXED CODE ###

N,M=map(int,input().split())
import heapq
A=list(map(int,input().split()))
heapq.heapify(A)
BC=[]
for i in range(M):
  B,C=map(int,input().split())
  BC.append((B,C))
BC.sort(key=lambda x:x[1],reverse=True)
import bisect
A.sort()
now=0
D=[0]*N
for i in range(M):
  B=BC[i][0]
  C=BC[i][1]
  for j in range(now,min(now+B,N)):
    D[j]=C
  now+=B
  if now>N-1:
    break

for i in range(N):
  a=A[i]
  d=D[i]
  if d>a:
    A[i]=d
  else:
    break
print(sum(A))
X=int(input())
Y=int(input())
Z=int(input())

A = X // (Y+Z)
print(A)

### FIXED CODE ###

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

b = (a[0]-a[2]) // (a[1]+a[2])
print(b)
import math
n, p = map(int, input().split())
if n == 1:
    print(p)
    exit()

res = 1
v = 2
while v <= p**(1/n)+1:
    if p % v == 0:
        vn = math.pow(v, n)
        while p % vn == 0:
            res *= v
            p /= vn
    v += 1

print(res)

### FIXED CODE ###

import collections

N, p = map(int, input().split())
if N == 1:
    print(p)
    exit()

def prime_decomposition(n):
    # 素因数分解
    if n < 2:
        return []
    prime_factors = []
    while n % 2 == 0:
        prime_factors.append(2)
        n >>= 1

    while n % 3 == 0:
        prime_factors.append(3)
        n //= 3

    a = 5
    b = 7
    while a ** 2 <= n:
        if n % a == 0:
            prime_factors.append(a)
            n //= a
        elif n % b == 0:
            prime_factors.append(b)
            n //= b
        else:
            a += 6
            b += 6
    if n > 1:
        prime_factors.append(n)
    return prime_factors

res = 1
pf = collections.Counter(prime_decomposition(p))
for v, c in pf.items():
    while c >= N:
        res *= v
        c -= N
print(res)
n, k = map(int, input().split(" "))
ls = list(map(int, input().split(" ")))

ls.sort()

print(ls[:k].sum())

### FIXED CODE ###

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

if (a+b)%3 == 0:
    print("Possible")
elif a%3 == 0:
    print("Possible")
elif b%3 == 0:
    print("Possible")
else:
    print("Impossible")
import itertools

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

candidate = list(range(a, b+1, 1))
if n == 1:
    if a == b:
        print(1)
    else:
        print(0)
elif n == 2:
    print(1)
elif n >= 3:
    if a > b:
        print(0)
    else:
        smin = a * n + (b-a)
        smax = b * n - (b-a)
        print(smax-smin+1)

### FIXED CODE ###

import itertools

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

if n == 1:
    if a == b:
        print(1)
    else:
        print(0)
elif n == 2:
    print(1)
elif n >= 3:
    if a > b:
        print(0)
    else:
        smin = a * n + (b-a)
        smax = b * n - (b-a)
        print(smax-smin+1)
import queue

dx = [0, 0, -1, 1]
dy = [1, -1, 0, 0]

h, w = map(int, input().split())
s = []
for i in range(h) :
    s.append(input())

ans = 0

for i in range(h) :
    for j in range(w) :
        #print(i,j)
        if s[i][j] == '#' :
            continue
        dist = [[-1 for i in range(w)] for j in range(h)]
        q = queue.Queue()
        q.put([i,j])
        dist[i][j] = 0
        cnt = 0
        while not q.empty() :
            xy = q.get()
            for k in range(4) :
                y = xy[0] + dx[k]
                x = xy[1] + dy[k]
                if y < 0 or y >= h or x < 0 or x >= w :
                    continue
                if s[y][x] == '#' :
                    continue
                if dist[y][x] != -1 :
                    continue
                q.put([x, y])
                dist[y][x] = dist[xy[0]][xy[1]] + 1
        for k in range(h) :
            for l in range(w) :
                ans = max(ans, dist[k][l])
        #print(dist)


print(ans)


### FIXED CODE ###

import queue

dx = [0, 0, -1, 1]
dy = [1, -1, 0, 0]

h, w = map(int, input().split())
s = []
for i in range(h) :
    s.append(input())

ans = 0

for i in range(h) :
    for j in range(w) :
        if s[i][j] == '#' :
            continue
        dist = [[-1 for i in range(w)] for j in range(h)]
        q = queue.Queue()
        q.put([j,i])
        dist[i][j] = 0
        cnt = 0
        while not q.empty() :
            xy = q.get()
            for k in range(4) :
                x = xy[0] + dx[k]
                y = xy[1] + dy[k]
                if y < 0 or y >= h or x < 0 or x >= w :
                    continue
                if s[y][x] == '#' :
                    continue
                if dist[y][x] != -1 :
                    continue
                q.put([x, y])
                dist[y][x] = dist[xy[1]][xy[0]] + 1
        for k in range(h) :
            for l in range(w) :
                ans = max(ans, dist[k][l])


print(ans)
K, X = map(int, input().split())
 for i in range(X - K + 1, X + K):
     if i < X + K - 1:
        print(i, end=' ')
     else:
        print(i)


### FIXED CODE ###

a, b = map(int, input().split())
print(max([a+b,a-b,a*b]))
# -*- coding: utf-8 -*-
import math

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

ans = 0

CD = (C * D) // math.gcd(C, D) 

def l(a, x):
    if a // x == 0:
        return 1
    if a % x != 0:
        t = a // x + 1
        return t
    t = a // x
    return t

cl = l(A, C)
dl = l(A, D)
cdl = l(A, CD)
cr = B // C
dr = B // D
cdr = B // (CD)

ans = B - A + 1 - (cr - cl + 1) - (dr - dl + 1) + (cdr - cdl + 1)
        
print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-
A, B, C, D = map(int, input().split())

ans = 0
def gcd(a, b):
    while b :
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

CD = (C * D) // gcd(C, D) 

def l(a, x):
    if a // x == 0:
        return 1
    if a % x != 0:
        t = a // x + 1
        return t
    t = a // x
    return t

cl = l(A, C)
dl = l(A, D)
cdl = l(A, CD)
cr = B // C
dr = B // D
cdr = B // (CD)

ans = B - A + 1 - (cr - cl + 1) - (dr - dl + 1) + (cdr - cdl + 1)
        
print(ans)
A=int(input())
B=int(input())
cnt=0
for i in range(A,B+1):
    if  A/10000 == A%10 and  A/1000%10 == A/10%10:
        cnt+=1
print(cnt)

### FIXED CODE ###

A,B=map(int, input().split())
cnt=0
for i in range(A,B+1):
    if  i//10000 == i%10 and  i//1000%10 == i//10%10:
        cnt+=1
print(cnt)
N,K=map(int,input().split())
_=input().split()
S=[]
for s in _:
    S.append((int(_)+1)/2)

maxsum=0

for i in range(len(S)):
    tempsum=sum(S[i:i+K])
    if maxsum<tempsum:
        maxsum=tempsum
    else:
        pass
      
print(maxsum)

### FIXED CODE ###

N,K=map(int,input().split())
_=input().split()
S=[]
for s in _:
    S.append((int(s)+1)/2) #初めから期待値で配列作成

maxsum=sum(S[0:K])
tempsum=maxsum

for i in range(N-K):
    tempsum=tempsum-S[i]+S[i+K]
    if maxsum<tempsum:
        maxsum=tempsum
    else:
        pass

print(maxsum)
# input
N, M = map(int, input().split()) 
X = list(map(int, input().split()))

X.sort()
K = [
    abs(X[i] - X[i - 1])
    for i in range(1, N)
]

print(sum(K[:M - (N - 1)])

### FIXED CODE ###

# input
N, M = map(int, input().split())
X = list(map(int, input().split()))

X.sort()
K = sorted(
    [
        abs(X[i] - X[i - 1])
        for i in range(1, M)
    ],
    reverse=True
)

print(sum(K[N - 1:]))
n, a, b, = map(int,input().split())
ans = 0
for i in range(n+1):
    if a <= sum(list(map(int,list(str)))):
        ans += i
print(ans)
    

### FIXED CODE ###

n, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
    if a <= sum(list(map(int, list(str(i))))) <= b:
        ans += i
print(ans)
import sys
import math
import itertools

rl = sys.stdin.readline
x = int(rl())
while True:
    if x % 2:
      for i in range(3, 7//2, 2):
        if x % i == 0
        break
      else:
        print(x)
        break
    x += 1



### FIXED CODE ###

import sys
import math
import itertools

rl = sys.stdin.readline
x = int(rl())
while True:
    if x == 2:
        print(2)
        break
    if x % 2:
      for i in range(3, x//2, 2):
        if x % i == 0:
            break
      else:
        print(x)
        break
    x += 1
n,x = map(int, input().split())
l = [ abs(i - x) for i in list(map(int, input().split()))]
l.sort(reverse=True)
if len(l) == 1:ans = l[0]
else:
  while len(l) != 1:
    l.sort(reverse=True)
    if 0 not in l: l.append(0)
    l = [ l[i] - l[i+1] for i in range(len(l) - 1)]
    l = list(set(l))
    for i in l:
      if i % min(l) != 0:break
    else:
      l[0] = min(l)
      break
  ans = l[0]
print(ans)

### FIXED CODE ###

n,x = map(int, input().split())
l = [ abs(i - x) for i in list(map(int, input().split()))]
l.sort(reverse=True)
l = list(set(l))
if len(l) == 1:ans = l[0]
else:
  while len(l) != 1:
    l.sort(reverse=True)
    l.append(0)
    l = [ l[i] - l[i+1] for i in range(len(l) - 1)]
    l = list(set(l))
    for i in l:
      if i % min(l) != 0:break
    else:
      l[0] = min(l)
      break
  ans = l[0]
print(ans)
N = int(input())
H = list(map(int,input().split))
count = 0
level = 0
for i in range(0, N):
    if H[i] > level:
        level = H[i]
        count += 1
return count

### FIXED CODE ###

N = int(input())
H = list(map(int,input().split()))
count = 0
level = 0
for i in H:
    if i >= level:
        level = i
        count += 1
print(count)
x,y = map(int, input().spilit())
array = list(map(int, input().spilit()))
su = sum(array)
a = x - su
if a > -1:
  print(a)
else:
  print(-1)

### FIXED CODE ###

x, y = map(int, input().split())
array = list(map(int, input().split()))
su = sum(array)
a = x - su
if a > -1:
    print(a)
else:
    print(-1)
import numpy as np

def count_true(matrix:np.array, s:int):
    return np.count_nonzero(matrix == s)


def unk(k:int, s:int):
    # 条件チェック
    if all([(2 <= k <= 2000), (0 <= s <= 3*k)]):

        x = y = z = np.array([range(0,k+1)])
        c = count_true(np.ravel(x.T+y)+ z.T, s)

        print(c)


if __name__ == '__main__':
    data = input().split(" ")
    data = list(map(int, data))
    unk(data[0], data[1])


### FIXED CODE ###

data = input().split(" ")
data = list(map(int, data))

count=0

for x in range(data[0]+1):
    for y in range(data[0]+1):
        if data[0] >= (data[1]-(x+y)) >= 0:
            z = data[1]-(x+y)
            
            if x + y + z == data[1]:
                count+=1
print(count)
#C
from itertools import accumulate
from collections import deque
import bisect

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

cnt = 0

a_c = list(accumulate(list(a)))
b_c = list(accumulate(list(b)))
result = []

idx_a = bisect.bisect_left(a_c,k)
idx_a_b = bisect.bisect_left(b_c,k-list(a)[idx_a])
result.append(idx_a + idx_a_b)

idx_b = bisect.bisect_left(b_c,k)
idx_b_a = bisect.bisect_left(a_c,k-list(b)[idx_b])
result.append(idx_b + idx_b_a)

for i in range(n+m):
    if len(a) > 0 and len(b) > 0:
        s,t = a.popleft(),b.popleft()
    elif len(a) > 0:
        s = a.popleft()
        t = float('inf')
    elif len(b) > 0:
        s = float('inf')
        t = b.popleft()
    else:
        break
    if s >= t:
        k -= t
        a.appendleft(s)
    else:
        k -= s
        b.appendleft(t)
    if k < 0:
        break
    else:
        cnt += 1
        #print('a:',a)
        #print('b:',b)
    
result.append(cnt)

print(min(result))

### FIXED CODE ###

#C
from itertools import accumulate
from collections import deque
import bisect

n,m,k = map(int,input().split())
a = [0] + list(map(int,input().split()))
b = [0] + list(map(int,input().split()))

cnt = 0

a_c = list(accumulate(list(a)))
b_c = list(accumulate(list(b)))
result = []

for i in range(n+1):
    if a_c[i] > k:
        continue
    b_idx = bisect.bisect_left(b_c,k-a_c[i]+1)
    result.append(i+b_idx-1)
    
print(max(result))
N,K = map(int,input().split()) 
A = list(map(int,input().split()))
A.sort()
temp = 1
V = [] 
for i in range(n-1):
    if A[i] == A[i+1]:
        temp+=1 
    else:
        V.append(temp)
        temp = 1

V.append(temp)
V.sort() 
ans = N- sum(V[-k:])
print(ans)

### FIXED CODE ###

N,K = map(int,input().split()) 
A = list(map(int,input().split()))
A.sort()
temp = 1
V = [] 
for i in range(N-1):
    if A[i] == A[i+1]:
        temp+=1 
    else:
        V.append(temp)
        temp = 1

V.append(temp)
V.sort() 
ans = N- sum(V[-K:])
print(ans)
N = int(input())
Happiness = [sorted([int(i) for i in input().split()]) for j in range(N)]

ans1 = ans2 = 0
for move, choice1, choice2 in zip(Happiness, cycle([1, 2]), cycle([2, 1])):
    ans1 += move[choice1]
    ans2 += move[choice2]

print(max(ans1, ans2))

### FIXED CODE ###

N = int(input())
Happiness = [[int(i) for i in input().split()] for j in range(N)]

dp = [[0] * 3 for _ in range(N)]
dp[0] = Happiness[0][:]
for day in range(1, N):
    dp[day][0] = max(dp[day - 1][1], dp[day - 1][2]) + Happiness[day][0]
    dp[day][1] = max(dp[day - 1][2], dp[day - 1][0]) + Happiness[day][1]
    dp[day][2] = max(dp[day - 1][0], dp[day - 1][1]) + Happiness[day][2]
print(max(dp[N - 1]))
N, M = list(map(int,input().split()))

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

BC = []

for i in range(M):
    BC.append(list(map(int,input().split())))

BC = sorted(BC, key=lambda x: x[1])

BC.reverse()

idx = N-1

for i in range(M):
    B, C = BC[i]

    while idx >= 0:
        if A[idx] < C:
            idx += 1
            break
        idx -= 1
    else:
        break

    if B >= idx:
        A = [C]*idx + A[idx:]
        break
    else:
        A = A[B:idx] + [C]*B + A[idx:]

print(sum(A))

### FIXED CODE ###

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

A = [-1]
A += list(map(int,input().split()))
A.sort()

BC = [[1,-1]]

for i in range(M):
    BC.append(list(map(int,input().split())))

BC = sorted(BC, key=lambda x: x[1])


x = 0

for i in range(N):
    if A[-1] > BC[-1][1]:
        x += A.pop()
        
    else:
        x += BC[-1][1]
        BC[-1][0] -= 1
        if BC[-1][0] == 0:
            BC.pop()

print(x)
S = list(input())
ANS = 0
for i in range(len(S)//2):
    if S[i] != S[len(S)-i]:
        ANS += 1

print(ANS)

### FIXED CODE ###

A, B, C = map(int, input().split())
if A + B + C >= 22:
  print("bust")
else:
  print("win")
n, k = map(int, input())

tree = [int(input()) for i in range(n)]
tree.sort()

res = (tree(i+k-1) - tree(i) for i in range(n-k+1))
print(min(res))

### FIXED CODE ###

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

tree = [int(input()) for i in range(n)]
tree.sort()

res = (tree[i+k-1] - tree[i] for i in range(n-k+1))
print(min(res))