Harryxun/stf_run huggingface dataset:
import copy
import numpy as np
from scipy.sparse import csr_matrix

def openinput():
    n, m = map(int, input().split())
    s ,t = [], []
    for _ in range(m):
        si, ti = map(int, input().split())
        s.append(si - 1)
        t.append(ti - 1)
    return n, m, s, t

def make_adjacency_matrix(weights, edges, num_of_nodes):
    return csr_matrix((weights, edges), shape=(num_of_nodes, num_of_nodes)).toarray()

def edit_mat(mat, weight, edge_from, edge_to):
    copied = copy.deepcopy(mat)
    copied[edge_from, edge_to] = weight
    return copied

def depth_first_search(mat, start_node):
    to_visit = [(start_node, 0, 1.0)]    # (node, depth, expected_value)
    depth_expecteds = []  # expected value of path length from 0 to n-1
    while to_visit:
        visit, depth, expected = to_visit.pop()
        if visit == n-1:
            depth_expecteds.append(depth * expected)
        else:
            nexts = [v for v, c in enumerate(mat[visit]) if c > 0]
            if nexts:
                for next in nexts:
                    to_visit.append((next, depth+1, expected/len(nexts)))
            else:   # leaf node but not n
                depth_expecteds.append(np.inf)
    return sum(depth_expecteds)





if __name__ == "__main__":
    n, m, s, t = openinput()
    adjacency_matrix = make_adjacency_matrix([1]*m, (s,t), n)

    rawcols = np.where(adjacency_matrix == 1)
    expecteds = []
    for r, c in zip(rawcols[0], rawcols[1]):
        mat = edit_mat(adjacency_matrix, 0, r, c)
        expecteds.append(depth_first_search(mat, 0))

    min_expected = np.min(expecteds)
    if np.isinf(min_expected):
        print(depth_first_search(adjacency_matrix, 0))
    else:
        print(min_expected)

### FIXED CODE ###

# reference: https://www.onakasuitacity.com/abc144-f/

import numpy as np

n, m = map(int, input().split())
outgoing = [[] for _ in range(n)]
incoming = [[] for _ in range(n)]
for _ in range(m):
    si, ti = map(int, input().split())
    outgoing[si-1].append(ti-1)
    incoming[ti-1].append(si-1)


ex_dp = np.zeros(n)
for v in reversed(range(n-1)):   # O(m)
    outgoing_degree = len(outgoing[v])
    ex_dp[v] = 1 + sum(ex_dp[post] for post in outgoing[v])/outgoing_degree if outgoing_degree!=0 else np.inf

p_dp = np.ones(n)
for v in range(1,n):      # O(m)
    p_dp[v] = sum(p_dp[prev]/len(outgoing[prev]) for prev in incoming[v])

min_ex = ex_dp[0]
for v, posts in enumerate(outgoing):      # O(m)
    outgoing_degree = len(outgoing[v])
    if outgoing_degree <= 1:
        continue

    max_post = max(posts, key= lambda pos: ex_dp[pos])
    diff_v_ex = 0
    for w in posts:
        if w == max_post:
            diff_v_ex -= 1/outgoing_degree * ex_dp[w]
        else:
            diff_v_ex += 1/(outgoing_degree*(outgoing_degree-1)) * ex_dp[w]
    min_ex = min(ex_dp[0] + p_dp[v] * diff_v_ex, min_ex)

print(min_ex)
n = int(input())
a = list(map(int, input().split()))
s = 0
for i in range(n):
    s += 1 / a[i]
print(1 / s)

### FIXED CODE ###

a = int(input())
s = input()
if a >= 3200:
    print(s)
else:
    print('red')
n = int(input())
ab = []
g = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)
    ab.append([a,b])

k = max([len(i) for i in g])
print(k)

c = [[-1]*n for i in range(n)]
from collections import deque
q = deque([(0,-1)])

while q:
    cur,col = q.popleft()
    for next_i in g[cur]:
        if c[cur][next_i]<0:
            col = (col+1)%k
            c[cur][next_i] = col
            c[next_i][cur] = col
            q.append((next_i,col))


for a,b in ab:
    print(c[a][b]+1)


### FIXED CODE ###

n = int(input())
ab = []
g = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)
    ab.append([a,b])

k = max([len(i) for i in g])
print(k)

reach = [False]*n
c = dict()
from collections import deque
q = deque([[0,-1]])

while q:
    cur,col = q.popleft()
    reach[cur] = True
    for next_i in g[cur]:
        if not reach[next_i]:
            col = (col+1)%k
            a,b = sorted([cur,next_i])
            c[(a,b)] = col
            q.append([next_i,col])

for a,b in ab:
    print(c[(a,b)]+1)
H,W=map(int,input().split())
if (H*W)%2==0:
    B=int((H*W)/2)
    print (B)
else:
    if (H+W)%2==0:
        C=int((H*W+1)/2)
        print (C)
    else:
        D=int((H*W-1)/2)
        print(D)



### FIXED CODE ###

K=int(input())
A=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(A[K-1])
s=str(input())
ans=0
for i in range(len(s)-1):
  if not s[i]-1<=s[i+1]:
    print("No")
    exit()
print("Yes")


### FIXED CODE ###

N=int(input())
H=list(map(int,input().split()))
base=0
for h in H:
    if base>h:
        print("No")
        break
    base=max(base,h-1)
else:
    print("Yes")
""" abc055_a """

import sys

H = pow(10, 9) + 7

def _main():
    n_s, n_c = map(int, sys.stdin.readline().split(' '))

    if 2 * n_s <= n_c:
        result = n_s + int((n_c - n_s * 2) / 4)
    else:
        result = int(n_c / 2)

    print(result)

if __name__ == '__main__':
    _main()


### FIXED CODE ###

""" abc055_a """

import sys

H = pow(10, 9) + 7

def _main():
    _n = int(sys.stdin.readline())
    answers = list(map(lambda a: a == 'o', sys.stdin.readline()))

    # ooxoox
    # S-----
    # a[0] = o: SS---S
    # a[1] = o: SSS--S
    # a[2] = x: SSSW-S
    # a[3] = o: SSSWWS
    # a[4] = o: SSSWWS OK
    # a[5] = x: SSSWWS OK

    def _evaluate(zoo_first, zoo_last):

        zoo = [None] * _n

        zoo[0] = zoo_first == 'S'
        zoo[_n-1] = zoo_last == 'S'

        for i in range(0, _n):
            same = answers[i] if zoo[i] else not answers[i]
            next_z = zoo[(i-1)%_n] if same else not zoo[(i-1)%_n]
            if zoo[(i+1)%_n] is None:
                zoo[(i+1)%_n] = next_z
            else:
                if zoo[(i+1)%_n] != next_z:
                    return -1

        return zoo

    for _f, _l in [['S', 'S'], ['W', 'W'], ['S', 'W'], ['W', 'S'],]:
        result = _evaluate(_f, _l)
        if -1 != result:
            print(_format(result))
            return

    print(-1)

def _format(result):
    return ''.join(map(lambda e: 'S' if e else 'W', result))

if __name__ == '__main__':
    _main()
a =map(int,input())
s=0
for i in range(a[0]+1):
    s+=i
print(s)

### FIXED CODE ###

a =int(input())
s=0
for i in range(a+1):
    s+=i
print(s)
a,*b,c=input()
print(a+len(b)+C)

### FIXED CODE ###

a,*b,c=input()
print(a+str(len(b))+c)
I = [input() for i in range(2)]
sn = int(I[0])
ss = str(I[1])
if sn%2 == 1 :
    A = 'No' 
else:
    sl = int(sn/2) 
    # print(sl)
    if sl >= 2 : 
        H1 = ss[:sl]
        H2 = ss[sl:]
    #     print(H1)
    #     print(H2)
    elif sl == 1 :
        H1 = ss[0]
        H2 = ss[1]
    if  H1 == H2 :
        A = 'Yes'
    else:
        A = 'No'
print(A)

### FIXED CODE ###

rad = int(input())
S = round(rad*rad,0)
print(S)
count = 1
while True:
x = input().strip()
if x == '0':
   break
print('Case %s: %s' % (count, x))
count = count + 1

### FIXED CODE ###

import sys
count = 1
while True:
    x = input().strip()
    if x == '0':
         break
    print('Case %s: %s' % (count, x))
    count = count + 1
#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/C-RemainderMinimization.py
#
import math
a, b, c, d = map(int, input().split())
cd_lcm = (c * d) // math.gcd(c, d)
ab_c = b//c - (a-1)//c
ab_d = b//d - (a-1)//d
ab_cd_both = b//cd_lcm - (a-1)//cd_lcm
ab_cd_either = ab_c + ab_d - ab_cd_both
ab_cd_neither = b-a+1 - ab_cd_either

print(ab_cd_neither)


### FIXED CODE ###

#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/C-RemainderMinimization.py
#
# import math
from fractions import gcd
a, b, c, d = map(int, input().split())
# cd_lcm = (c * d) // math.gcd(c, d)
cd_lcm = (c * d) // gcd(c, d)
ab_c = b//c - (a-1)//c
ab_d = b//d - (a-1)//d
ab_cd_both = b//cd_lcm - (a-1)//cd_lcm
ab_cd_either = ab_c + ab_d - ab_cd_both
ab_cd_neither = b-a+1 - ab_cd_either

print(ab_cd_neither)
import numpy as np
a, b, c = map(int, input().split())
if np.sqrt(a) + np.sqrt(b) < np.sqrt(c):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

a, b, c = map(int, input().split())
if a * b * 4 < (c - (a + b))**2 and c - (a + b) > 0:
    print("Yes")
else:
    print("No")
a, b = map(int, input())
print((a-1)*(b-1))

### FIXED CODE ###

a, b = map(int, input().split())
print((a-1)*(b-1))
def fibonacci(n):
    if n == 0:
        return 0
    elif n == 1:
        return 1
    n+=2
    return fibonacci_sub2(n-2, 1, 0)

def fibonacci_sub2(n, fibo_minus1, fibo_minus2):
    return fibo_minus1 if n==0 else fibonacci_sub2(n-1, fibo_minus1+fibo_minus2, fibo_minus1)


N,M = map(int, input().split()) #1 2
if M != 0:
    a = [int(input()) for i in range(M)]
else:
    if N == 1:
        print(1)
        exit()
    else:
        print(fibonacci(N)%1000000007)
        exit()
ans = []
nstep = range(N)
preidx = 0

for idx,i in enumerate(a):
    if i - preidx == 1 and idx != 0:
        print(0)
        exit()
    if idx == 0 and i-preidx-1 != 0:
        ans.append([idx,i-preidx-1])
    elif idx > 0:
        ans.append([idx,i-preidx-2])
    preidx = i
else:
    if preidx != N:
        ans.append([idx,N-preidx-1])

fibsum = 1
for idx,val in enumerate(ans):
    fibsum *= max(1,fibonacci(val[1]))
    fibsum %= 1000000007 
print(fibsum)







### FIXED CODE ###

import sys
sys.setrecursionlimit(10000001)
def fibonacci(n):
    if n == 0:
        return 0
    elif n == 1:
        return 1
    n+=2
    return fibonacci_sub2(n-2, 1, 0)%1000000007

def fibonacci_sub2(n, fibo_minus1, fibo_minus2):
    return fibo_minus1%1000000007 if n==0 else fibonacci_sub2(n-1, (fibo_minus1+fibo_minus2)%1000000007, fibo_minus1%1000000007)%1000000007


N,M = map(int, input().split()) #1 2
if M != 0:
    a = [int(input()) for i in range(M)]
else:
    if N == 1:
        print(1)
        exit()
    else:
        print(fibonacci(N)%1000000007)
        exit()
ans = []
nstep = range(N)
preidx = 0

for idx,i in enumerate(a):
    if i - preidx == 1 and idx != 0:
        print(0)
        exit()
    if idx == 0 and i-preidx-1 != 0:
        ans.append([idx,max(0,i-preidx-1)])
    elif idx > 0:
        ans.append([idx,max(0,i-preidx-2)])
    preidx = i
else:
    if preidx != N:
        ans.append([idx,max(0,N-preidx-1)])

fibsum = 1
for idx,val in enumerate(ans):
    fibsum *= max(1,fibonacci(val[1]))
    fibsum %= 1000000007 
print(fibsum)
N = str(input())
if N[0]==N[1] or N[1]==N[2] or N[2]==N[3] or N[3]==N[4]:
    print("Bad")
else:
    print("Good)

### FIXED CODE ###

N = str(input())
if N[0]==N[1] or N[1]==N[2] or N[2]==N[3]:
    print("Bad")
else:
    print("Good")
a,b=input().split(" ")
a=int(a)
b=int(b)
print(a*b,2*(a+b))

### FIXED CODE ###

a,b = input().split(" ")
a=int(a)
b=int(b)
print(a*b,2*(a+b))
A, B, K = map(int, input().split())
ans=[1]
for i in range(2,int(max([A,B]))):
        if A%i== 0 and B%i == 0:
            ans.append(i)
print(ans[K-1])

### FIXED CODE ###

A, B, K = map(int, input().split())
ans=[1]
for i in range(2,int(max([A,B])+1)):
        if A%i== 0 and B%i == 0:
            ans.append(i)
ans.sort(reverse=True)
print(ans[K-1])
a = list(map(int,input().split()))
S = input()

b = list(S.split("-"))

a.sort()
b.sort()

if a[0] == len(b[0]) and a[1] == len(b[1]):
    print("Yes")
elif sum(a) == len(b[1]):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

import re
A,B = list(map(int,input().split()))
S = input()

d = re.compile("\d+")

if (d.match(S[:A])) and S[A] == "-" and d.match(S[A+1:]):
    print("Yes")

else:print("No")
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
m = n//2
ca = Counter(a)

if n % 2 == 0 and all(ca[i*2 + 1] == 2 for i in range(m)):
    ans = 2 ** m % (1e9 + 7)
    print(int(ans))
elif n % 2 == 1 and all(ca[(i+1)*2] == 2 for i in range(m)):
    ans = 2 ** m % (1e9 + 7)
    print(int(ans))
else:
    print(0)


### FIXED CODE ###


from collections import Counter

n = int(input())
a = list(map(int, input().split()))
m = n // 2
ca = Counter(a)

if n % 2 == 1 and ca[0] == 1 and all(ca[(i+1)*2] == 2 for i in range(m)):
    ans = (2 ** m) % (10 ** 9 + 7)
    print(ans)
elif n % 2 == 0 and all(ca[i*2 + 1] == 2 for i in range(m)):
    ans = (2 ** m) % (10 ** 9 + 7)
    print(ans)
else:
    print(0)
N = int(input())
a = list(map(int, input().split()))


def gcd(m, n):
    if n == 0:
        return m
    else:
        return gcd(n, m % n)


def lcm(m, n):
    return (m / gcd(m, n)) * n


lc = a[0]
for i in range(N):
    lc = lcm(lc, a[i])
ans = 0
lc %= int(1e9+7)
for i in range(N):
    ans += (lc / a[i])
print(int(ans % (1e9+7)))


### FIXED CODE ###

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


def lcm(m, n):
    return (m // fractions.gcd(m, n)) * n


mod = 10**9+7
lc = a[0]
for i in range(N):
    lc = lcm(lc, a[i])
ans = 0
for i in range(N):
    ans += (lc // a[i])
print(ans % mod)
A = Input()
A = A.split()

B = []
for x in A:
    y = int(x)
    B.append(y)

c = [1, 2, 3, 4, 5]
for x in range(len(B)):
    if B[x] != c[x]:
        z = x+1
        print(z)

### FIXED CODE ###

A = input()
A = A.split()
B = []
for x in A:
    y = int(x)
    B.append(y)

c = [1, 2, 3, 4, 5]
for x in range(len(B)):
    if B[x] != c[x]:
        z = x+1
        print(z)
n = int(input())
h = [int(i) for i in input().split()]
for j in range(n):
  if h[j] - h[j+1] < -1:
    print("No")
    exit()
  else:
    continue
for k in range(n-1):
  if h[k] < h[k+1] and h[k+1] < h[k+2]:
    print("No")
    exit()
  else:
    continue
print("Yes")


### FIXED CODE ###

n = int(input())
h = [int(i) for i in input().split()]
for j in range(n-1):
  if h[j] - h[j+1] > 1:
    print("No")
    exit()
  elif h[j] == h[j+1] + 1:
    h[j+1] += 1
print("Yes")
a, b = map(int, raw_input().split())
if a > 9 or b > 9:
  print(-1)
else:
  print(a*b)

### FIXED CODE ###

a, b = map(int, input().split())
if a > 9 or b > 9:
  print(-1)
else:
  print(a*b)
num = input()
if num % 9 == 0:
  print("yes")
else:
  print("no")

### FIXED CODE ###

from sys import stdin, stdout
t = int(stdin.readline())
if t % 9 == 0:
  print("Yes")
else:
  print("No")
from collections import deque, defaultdict, Counter
from math import floor, ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
a = N % 1000

if a == 0:
    print(0)
else:
    print(1000 -  a)


### FIXED CODE ###

from collections import deque, defaultdict, Counter
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
a = N % 1000
# if 0 <= N < 1000:
#     print(N)
if N % 1000 == 0:
    print(0)
else:
    print(1000 - a)


# for i in range(1, 10+1):
#     have = 1000 * i

#     if 0 <= have - N < 1000:
#         print(have - N)
#         exit()
N = int(input())

def factorial(n, p):
    if n == 0: return 1
    return n/p + factorial(n/p, p)

def duble_factorial(n, p):
    if n%2 == 1:
        return factorial(n,p) - duble_factorial(n-1, p) # n!! = n!/(n-1)!!だからpで割ると引き算で表せるよね
    else:
        res = factorial(n/2, p)
        if p == 2: 
            res += n/2
        return res

ans = min(duble_factorial(N,2), duble_factorial(N,5))
print(ans)

### FIXED CODE ###

N = int(input())

def factorial(n, p):
    if n == 0: return 0
    return n//p + factorial(n//p, p)

def duble_factorial(n, p):
    if n%2 == 1:
        return factorial(n,p) - duble_factorial(n-1, p) # n!! = n!/(n-1)!!だからpで割ると引き算で表せるよね
    else:
        res = factorial(n//2, p)
        if p == 2: 
            res += n//2
        return res

ans = min(duble_factorial(N,2), duble_factorial(N,5))
print(ans)
import bisect

def dfs(v):
  for u in g[v]:
    if checked[u]==0:
      checked[u]=1
      pos=bisect.bisect_left(dp,arr[u])
      changes.append((pos,dp[pos]))
      dp[pos]=arr[u]
      ans[u]=bisect.bisect_left(dp,10**18)
      dfs(u)
  pos,val=changes.pop()
  dp[pos]=val

n=int(input())
arr=[0]+list(map(int,input().split()))
g=[[] for _ in range(n+1)]
for _ in range(n-1):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
ans=[0]*(n+1)
ans[1]=1
checked=[0]*(n+1)
checked[1]=1
dp=[10**18 for _ in range(n+1)]
dp[0]=1
changes=[(0,1)]
dfs(1)
for i in range(1,n+1):
  print(ans[i])

### FIXED CODE ###

import bisect
import sys
sys.setrecursionlimit(10**7)

def dfs(v):
  pos=bisect.bisect_left(dp,arr[v])
  changes.append((pos,dp[pos]))
  dp[pos]=arr[v]
  ans[v]=bisect.bisect_left(dp,10**18)
  for u in g[v]:
    if checked[u]==0:
      checked[u]=1
      dfs(u)
  pos,val=changes.pop()
  dp[pos]=val

n=int(input())
arr=[0]+list(map(int,input().split()))
g=[[] for _ in range(n+1)]
for _ in range(n-1):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
ans=[0]*(n+1)
checked=[0]*(n+1)
checked[1]=1
dp=[10**18 for _ in range(n+1)]
changes=[]
dfs(1)
for i in range(1,n+1):
  print(ans[i])
N, X = map(int, input().split())
city_lst = list(map(int, input().split()))
city_lst.sort()

if X < city_lst[0]:
	maximum_D = city_lst[0] - X
else:
	for i in range(N - 1):
		if city_lst[i] < X:
			maximum_D = min(abs(X - city_lst[i]), abs(city_lst[i + 1] - X))
			break

# print(maximum_D)
for D in reversed(range(1, maximum_D + 1)):
	fail = 0
	for i in range(1, N + 1):
		if not city_lst[i] - city_lst[i - 1] == D:
			break
	if not fail:
		print(D)
		break

### FIXED CODE ###

from fractions import gcd

N, X = (int(i) for i in input().split())

x = [abs(int(i) - X) for i in input().split()]  
for i in range(1,N):
	x[i] = gcd(x[i-1], x[i])

print(x[-1])
a,b,c=map(int,input().split())

if a+b+c => 22:
  print(bust)
else:
  print(win)


### FIXED CODE ###

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

if sum(a) >= 22:
    print("bust")
else:
    print("win")
import numpy as np

N, W = [int(x) for x in input().split()]
weight = np.zeros((N,2))
for x in range(N):
    weight[x] = [int(y) for y in input().split()]
#topdown
memo = np.zeros((N+1,W+1))
for x in range(N+1):
    memo[x] = [-1]*(W+1)

def dp(n,w):
    if w < 0:
        return -float('inf')
    elif n == 0 or w == 0:
        return 0
    elif memo[n][w] != -1:
        return memo[n][w]
    else:
        memo[n][w] = max(dp(n-1,w), dp(n-1,w - int(weight[n-1][0])) + weight[n-1][1])
        return memo[n][w]

print(int(dp(N,W)))

### FIXED CODE ###

import numpy as np

N, W = [int(x) for x in input().split()]
items = [tuple(map(int, input().split())) for _ in range(N)]

#topdown
memo = np.zeros(shape = W+1, dtype = np.int64)

for w,v in items:
    memo[w:] = np.maximum( memo[w:], memo[:-w] + v)

print(memo[-1])
#N個のボールを持ち，K個以下の整数にする
#順当に考えるならば，種類が少ないやつから変更していけばいい
#番号の列をリストで表現
#押し付けきれるとは限らない

counter = 0

condition = list(map(int, input().split()))
A_list = list(map(int, input().split()))

zero_line = [0 for _ in range(condition[0])]

for i in A_list:
    if zero_line[i] == 0:
        counter += 1
    zero_line[i] += 1

zero_line.sort()
zero_line.reverse()

if counter <= condition[1]:
    print(0)
else:
    print(sum(zero_line[counter-condition[1]+1 :counter]))

### FIXED CODE ###

#N個のボールを持ち，K個以下の整数にする
#順当に考えるならば，種類が少ないやつから変更していけばいい
#番号の列をリストで表現
#押し付けきれるとは限らない

counter = 0

condition = list(map(int, input().split()))
A_list = list(map(int, input().split()))

zero_line = [0 for _ in range(200001)]

for i in A_list:
    if zero_line[i] == 0:
        counter += 1
    zero_line[i] += 1

zero_line.sort()
zero_line.reverse()

if counter <= condition[1]:
    print(0)
else:
    print(sum(zero_line[condition[1] :counter]))
# -*- coding: utf-8 -*-
"""
Created on Tue May 12 00:13:44 2020

@author: shinba
"""
import sys

w,h,x,y = map(int,input().split())

if (x==0 and y==0) or (x==w and y==0) or (x==0 and y==h) or (x==w and y==h):
    print((w*h)/2,0)
    sys.exit()
if w != x:
    if y/x == h/w or y/(w-x) == h/w:
        #print(y/x,h/w,y/(w-x))
        if y/x == h/w and y/(w-x) == h/w:
            print((w*h)/2,1)
        else:
            print((w*h)/2,0)
        sys.exit()
    
a1 = h*min(w-x,x)
a2 = w*min(h-y,y)

if a1 == a2:
    print(a1,1)
else:
    print(max(a1,a2),0)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Tue May 12 00:13:44 2020

@author: shinba
"""
import sys

w,h,x,y = map(int,input().split())

if w%2 == 0 and h%2 == 0:
    if w//2 == x and h//2 == y:
        print((h*w)/2,1)
        sys.exit()
        
print(h*w/2,0)
10 5
10 -80 21
23 8 38
-94 28 11
-26 -2 18
-69 72 79
-26 -86 -54
-72 -50 59
21 65 -32
40 -94 87
-62 18 82

### FIXED CODE ###

a, b = map(int, input().split())
sum0 = []
sum1 = []
sum2 = []
sum3 = []
sum4 = []
sum5 = []
sum6 = []
sum7 = []

for i in range(a):
  x, y, z = map(int, input().split())
  sum0.append((x + y + z))
  sum1.append((x + y - z))
  sum2.append((x - y + z))
  sum3.append((x - y - z))
  sum4.append((- x + y + z))
  sum5.append((- x + y - z))
  sum6.append((- x - y + z))
  sum7.append((- x - y - z))

sum0 = sum(sorted(sum0, reverse=True)[:b])
sum1 = sum(sorted(sum1, reverse=True)[:b])
sum2 = sum(sorted(sum2, reverse=True)[:b])
sum3 = sum(sorted(sum3, reverse=True)[:b])
sum4 = sum(sorted(sum4, reverse=True)[:b])
sum5 = sum(sorted(sum5, reverse=True)[:b])
sum6 = sum(sorted(sum6, reverse=True)[:b])
sum7 = sum(sorted(sum7, reverse=True)[:b])


print(max([sum0,sum1,sum2,sum3,sum4,sum5,sum6,sum7]))
def value_and_count(x):
    d = {}
    for xi in x:
        if xi in d.keys():
            d[xi] += 1
        else:
            d[xi] = 1
    return d

def comb(n, k):
    k = min(n - k, k)
    denominator = 1 # 分母
    numerator = 1 # 分子
    for i in range(k):
        denominator *= i + 1
        numerator *= n - i
    return numerator // denominator

n, a, b = map(int, input().split())
v = list(map(int, input().split()))
d_v = value_and_count(v)
v.sort(reverse=True)
sum_v = sum(v[:a])
print(sum_v / a)

ans = 0
d_vk = None
for k in range(a, b + 1):
    vk = v[:k]
    sum_vk = sum(vk)
    if sum_vk < sum_v:
        break

    if d_vk is None:
        d_vk = value_and_count(vk)
    else:
        d_vk[vk[-1]] += 1

    ans_k = 1
    for vi, ci in d_vk.items():
        ans_k *= comb(d_v[vi], ci)
    ans += ans_k

print(ans)


### FIXED CODE ###

def value_and_count(x):
    d = {}
    for xi in x:
        if xi in d.keys():
            d[xi] += 1
        else:
            d[xi] = 1
    return d

def comb(n, k):
    k = min(n - k, k)
    denominator = 1 # 分母
    numerator = 1 # 分子
    for i in range(k):
        denominator *= i + 1
        numerator *= n - i
    return numerator // denominator

n, a, b = map(int, input().split())
v = list(map(int, input().split()))
d_v = value_and_count(v)
v.sort(reverse=True)
sum_v = sum(v[:a])
mean_v = sum_v / a
print(mean_v)

ans = 0
d_vk = None
for k in range(a, b + 1):
    vk = v[:k]
    sum_vk = sum(vk)
    if sum_vk / k < mean_v:
        break

    if d_vk is None:
        d_vk = value_and_count(vk)
    else:
        d_vk[vk[-1]] += 1

    ans_k = 1
    for vi, ci in d_vk.items():
        ans_k *= comb(d_v[vi], ci)
    ans += ans_k

print(ans)