ZhenlongDai/ACPR huggingface dataset:
Problem: p02725
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
k,n=map(int,input().split())
dis=list(map(int,input().split()))
ans=[]
for i in range(n):
    if i==0:
        ans.append(dis[0])
    else:
        ans.append(dis[i]-dis[i-1])
print(dis[n-1]-max(ans))


Failing test case input:
20 3
2 11 15

Expected output:
11


Actual output:
6


Fixed submission (verdict: Accepted):
k,n=map(int,input().split())
dis=list(map(int,input().split()))
ans=[]
for i in range(n):
    if i>=1:
        ans.append(dis[i]-dis[i-1])
ans.append(dis[0]+(k-dis[n-1]))
print(k-max(ans))

Problem: p02725
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
K,N = map(int, input().split())
A = list(map(int,input().split()))


l_s = []
check = 0
for i in range(0,N):
    if(A[i] == 0):
        check =1
if(check == 1):
    A.append(K)
    for i in range(1,N+1):
          l_s.append(A[i]-A[i-1])
    num = 0
    ans = 99999999999999999
    for i in range(0,N):
        num = K - l_s[i]
        ans = min(ans,num)
    print(ans)
    
else: 
    A.append(K)
    for i in range(1,N+1):
          l_s.append(A[i]-A[i-1])
    m1 = max(l_s)
    ans = K-1 -m1
    print(ans)

Failing test case input:
3 3
1 8 18

Expected output:
-7


Actual output:
-8


Fixed submission (verdict: Accepted):
K,N = map(int, input().split())
A = list(map(int,input().split()))


l_s = []
check = 0
for i in range(0,N):
    if(A[i] == 0):
        check =1
if(check == 1):
    for i in range(1,N):
          l_s.append(A[i]-A[i-1])
    l_s.append(K-A[N-1])
    num = 0
    ans = 99999999999999999
    for i in range(0,N):
        num = K - l_s[i]
        ans = min(ans,num)
    print(ans)
    
else: 
    for i in range(1,N):
        l_s.append(A[i]-A[i-1])
    l_s.append(K-A[N-1]+A[0])
    m1 = max(l_s)
    ans = K-m1
    print(ans)

Problem: p02725
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
K, N = list(map(int, input().split()))
A = list(map(int, input().split()))
L = []
for i in range(N):
  if(i != N-1):
    L.append(A[i+1] - A[i])
  else:
    L.append(K - A[i])
sumL = sum(L)
maxL = max(L)
print(sumL - maxL)

Failing test case input:
9 3
2 11 15

Expected output:
0


Actual output:
-2


Fixed submission (verdict: Accepted):
K, N = list(map(int, input().split()))
A = list(map(int, input().split()))
L = []
for i in range(N):
  if(i != N-1):
    L.append(A[i+1] - A[i])
  else:
    L.append(K - A[i] + A[0])
maxL = max(L)
print(K - maxL)

Problem: p02725
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
k,n = map(int,input().split())
a = list(map(int,input().split()))
p = k-a[-1]
for i in range(n-1):
    a[i+1] -= a[i]
a[0] = p
a.sort()
ans = sum(a[:n-1])
print(ans)
    

Failing test case input:
8 3
2 3 102

Expected output:
-91


Actual output:
-93


Fixed submission (verdict: Accepted):
k,n = map(int,input().split())
a = list(map(int,input().split()))
b = [0]*(n-1)
p = a[-1]
for i in range(n-1):
    b[i] = a[i+1] - a[i]
b.append(k-p+a[0])
ans = k- max(b)
print(ans)
Problem: p02725
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
  k, N = (int(x) for x in input().split())
  min_LIST = []
  LIST = []
  LIST = list(map(int,input().split()))

  for i in range(len(LIST) - 1):
    min_LIST.append(LIST[i + 1] - LIST[i])
    if(min_LIST[i] <= (LIST[i + 1] - LIST[i])):
      x = (LIST[i + 1] - LIST[i])

  min_LIST.append(LIST[0] + (k - LIST[-1]))
  if(x <= (LIST[0] + (k - LIST[-1]))):
    x = (LIST[0] + (k - LIST[-1]))

  sum_list = sum(min_LIST) - x

  print(sum_list)
if __name__ == "__main__":
  main()






Failing test case input:
11 3
3 11 15

Expected output:
3


Actual output:
7


Fixed submission (verdict: Accepted):
def main():
  k, N = (int(x) for x in input().split())
  min_LIST = []
  LIST = []
  LIST = list(map(int,input().split()))
  x = 0

  for i in range(len(LIST) - 1):
    min_LIST.append(LIST[i + 1] - LIST[i])
    if(x <= min_LIST[i]):
      x = min_LIST[i]

  if(N != 2):
    min_LIST.append(LIST[0] + (k - LIST[-1]))
    if(x <= (LIST[0] + (k - LIST[-1]))):
      x = (LIST[0] + (k - LIST[-1]))

  sum_list = sum(min_LIST) - x

  print(sum_list)
if __name__ == "__main__":
  main()

Problem: p02725
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
K, N=map(int, input().split())
A=list(map(int, input().split()))

A_length_max = K-A[N-1]+A[0]
for i in range (N-2):
    A_length_max=max(A_length_max, A[i+1]-A[i])
print(K-A_length_max)

Failing test case input:
27 3
1 5 29

Expected output:
3


Actual output:
23


Fixed submission (verdict: Accepted):
K, N=map(int, input().split())
A=list(map(int, input().split()))

A_length_max = K-A[N-1]+A[0]
for i in range (N-1): 
    A_length_max=max(A_length_max, A[i+1]-A[i])
print(K-A_length_max)

Problem: p02725
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
k, n = map(int, input().split())
list_a = list(map(int, input().split()))
 
x = 0
longest = 0
for a in list_a:
  if a - x > longest:
    longest = a - x
    x = a
if longest < list_a[0] + (k - list_a[n-1]):
  longest = list_a[0] + (k - list_a[n-1])
print(k-longest)

Failing test case input:
20 3
1 2 15

Expected output:
7


Actual output:
6


Fixed submission (verdict: Accepted):
k, n = map(int, input().split())
list_a = list(map(int, input().split()))
 
x = 0
longest = 0
for a in list_a:
  if a - x > longest:
    longest = a - x
  x = a
if longest < list_a[0] + (k - list_a[n-1]):
  longest = list_a[0] + (k - list_a[n-1])
print(k-longest)

Problem: p02725
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
K, N = map(int, input().split())
A = list(map(int, input().split()))
         
for i in range(N):
  if A[i] >= K/2: A[i] -= K
    
print(max(A) - min(A))

Failing test case input:
6 3
1 1 76

Expected output:
-69


Actual output:
69


Fixed submission (verdict: Accepted):
K, N = map(int, input().split())
A = list(map(int, input().split()))
 
A.append(A[0]+K)
l = 0
for i in range(N):
  l = max(l, A[i+1]-A[i])

print(K-l)
Problem: p02725
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
k,n=map(int,input().split())
l=list(map(int,input().split()))
l=l+[l[0]+k]
ans=k
for i in range(n):
  ans=min(l[i+1]-l[i],k-(l[i+1]-l[i]))
print(ans)

Failing test case input:
27 3
1 6 41

Expected output:
-8


Actual output:
-13


Fixed submission (verdict: Accepted):
k,n=map(int,input().split())
l=list(map(int,input().split()))
l=l+[l[0]+k]
ans=k
for i in range(n):
  ans=min(ans,k-(l[i+1]-l[i]))
print(ans)

Problem: p02725
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
k, n = list(map(int, input().split()))
an = list(map(int, input().split()))
bn = []
for i in range(n-1):
  bn.append(an[i+1]-an[i])
bn.append(k-an[n-1])
print(sum(bn)-max(bn))

Failing test case input:
27 3
2 6 29

Expected output:
4


Actual output:
2


Fixed submission (verdict: Accepted):
k, n = list(map(int, input().split()))
an = list(map(int, input().split()))
bn = []
for i in range(n-1):
  bn.append(an[i+1]-an[i])
bn.append(k-an[n-1]+an[0])
print(sum(bn)-max(bn))

Problem: p02725
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
k, n = map(int, input().split())
a = list(map(int, input().split()))
a = a + [k - a[n - 1]]
for i, d in enumerate(a):
    if i != 0:
        a[i] = d - a[i - 1]

a.sort(reverse=True)
print(k - a[0])

Failing test case input:
20 3
5 11 15

Expected output:
10


Actual output:
11


Fixed submission (verdict: Accepted):
k, n = map(int, input().split())
a = list(map(int, input().split()))
a2 = []
for i, d in enumerate(a):
    if i != 0:
        a2.append(d - a[i - 1])
    else:
        a2.append(d + k - a[n - 1])

a2.sort(reverse=True)

print(k - a2[0])

Problem: p02725
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
K, N =map(int,input().split())
A_n =list(map(int,input().split()))

A_n.sort()

maxd =A_n[N-1]- A_n[0]
for i in range(N-1):
    maxd =max(maxd,A_n[i+1]-A_n[i])
    
print(K-maxd)

Failing test case input:
20 3
0 3 17

Expected output:
6


Actual output:
3


Fixed submission (verdict: Accepted):
K, N =map(int,input().split())
A_n =list(map(int,input().split()))

A_n.sort()

maxd =K -A_n[N-1]+ A_n[0]
for i in range(N-1):
    maxd =max(maxd,A_n[i+1]-A_n[i])
    
print(K-maxd)

Problem: p02725
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    k, n = map(int, readline().rstrip().split())
    A = sorted(list(map(int, readline().rstrip().split())))
    maxA = k + A[0] - A[n-1]
    for i in range(n-1):
    	a = abs(A[i+1] - A[i])
    	maxA = max(maxA,a)
    print(maxA)



if __name__ == '__main__':
    main()


Failing test case input:
8 3
2 3 102

Expected output:
-91


Actual output:
99


Fixed submission (verdict: Accepted):
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    k, n = map(int, readline().rstrip().split())
    A = sorted(list(map(int, readline().rstrip().split())))
    maxA = k + A[0] - A[n-1]
    for i in range(n-1):
        a = abs(A[i+1] - A[i])
        maxA = max(maxA, a)
    print(k - maxA)


if __name__ == '__main__':
    main()
Problem: p02725
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
K,N=map(int, input().split()) 
c=list(map(int, input().split())) 
a = 0
b = 0
for i in range(N):
  print(a)
  if i == 0:
    a = min((c[N-1]-c[0]),K-(c[i+1]-c[0]))
  elif i == N-1:
    a = min(a,K-(c[i-1]-c[i]))
    a = min(a,K-(c[0]-c[i]))
    
  else:
    a = min(a,K-(c[i-1]-c[i]))
    a = min(a,K-(c[i+1]-c[i]))
    
print(a)

Failing test case input:
27 3
1 6 29

Expected output:
4


Actual output:
0
22
4
4


Fixed submission (verdict: Accepted):
K,N=map(int, input().split()) 
c=list(map(int, input().split())) 
a = 0
b = 0
for i in range(N):
  if i == 0:
    a = min((c[N-1]-c[0]),K-(c[i+1]-c[0]))
  elif i == N-1:
    a = min(a,K-(c[i-1]-c[i]))
    a = min(a,K-(c[0]-c[i]))
    
  else:
    a = min(a,K-(c[i-1]-c[i]))
    a = min(a,K-(c[i+1]-c[i]))
    
print(a)

Problem: p02725
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
k,n=map(int,input().split())
a=list(map(int,input().split()))
for i in range(1,n):
    a[i]-=a[i-1]
print(k-max(a))

Failing test case input:
20 3
1 3 14

Expected output:
9


Actual output:
8


Fixed submission (verdict: Accepted):
k,n=map(int,input().split())
a=list(map(int,input().split()))
m=0

for i in range(1,n):
    m=max(m,a[i]-a[i-1])
m=max(m,k+a[0]-a[n-1])

print(k-m)

Problem: p02725
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
K,N = map(int, input().split())
A = list(map(int,input().split()))


l_s = []
check = 0
for i in range(0,N):
    if(A[i] == 0):
        check =1
if(check == 1):
    A.append(K)
    for i in range(1,N+1):
          l_s.append(A[i]-A[i-1])
    num = 0
    ans = 99999999999999999
    for i in range(0,N):
        num = K - l_s[i]
        ans = min(ans,num)
    print(ans)
    
else: 
    
    m1 = 0
    m2 = 0
    m1 = max(A)
    m2 = min(A)
    ans = m1 -m2
    print(ans)

Failing test case input:
0 3
2 6 29

Expected output:
-23


Actual output:
27


Fixed submission (verdict: Accepted):
K,N = map(int, input().split())
A = list(map(int,input().split()))


l_s = []
check = 0
for i in range(0,N):
    if(A[i] == 0):
        check =1
if(check == 1):
    for i in range(1,N):
          l_s.append(A[i]-A[i-1])
    l_s.append(K-A[N-1])
    num = 0
    ans = 99999999999999999
    for i in range(0,N):
        num = K - l_s[i]
        ans = min(ans,num)
    print(ans)
    
else: 
    for i in range(1,N):
        l_s.append(A[i]-A[i-1])
    l_s.append(K-A[N-1]+A[0])
    m1 = max(l_s)
    ans = K-m1
    print(ans)
Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
N, K = map(int, input().split())
A = Counter([int(_) for _ in input().split()])
print(A)
print(sum(A.values()) - sum(dict(A.most_common(K)).values()))


Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
Counter({1: 2, 2: 2, 5: 1})
1


Fixed submission (verdict: Accepted):
from collections import Counter
N, K = map(int, input().split())
A = Counter([int(_) for _ in input().split()])
print(sum(A.values()) - sum(dict(A.most_common(K)).values()))

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections
n,k = map(int,input().split())
a = list(map(int,input().split()))
A = set(a)
l = len(A)
s = list(collections.Counter(A).values())
s = sorted(s)
print(sum(s[l-k:]))

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
2


Fixed submission (verdict: Accepted):
import collections
n,k = map(int,input().split())
a = list(map(int,input().split()))
s = list(collections.Counter(a).values())
s = sorted(s)
print(sum(s[0:len(s)-k]))

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()
count = 1
chk = []
p = 1
if n == 1:
  print(0)
  exit()
else:
  for i in range(n-1):
    if a[i] != a[i+1]:
      count += 1
      chk.append(p)
      p = 1
    else:
      p += 1
  if a[-1] == a[-2]:
    chk.append(p)
  else:
    chk.append(1)
  chk.sort()
  print(chk)
  print(count)
  if count <= k:
    print(0)
    exit()
  else:
    print(sum(chk[:count-k]))
    exit()

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
[1, 2, 2]
3
1


Fixed submission (verdict: Accepted):
n,k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()
count = 1
chk = []
p = 1
if n == 1:
  print(0)
  exit()
else:
  for i in range(n-1):
    if a[i] != a[i+1]:
      count += 1
      chk.append(p)
      p = 1
    else:
      p += 1
  if a[-1] == a[-2]:
    chk.append(p)
  else:
    chk.append(1)
  chk.sort()
  
  
  if count <= k:
    print(0)
    exit()
  else:
    print(sum(chk[:count-k]))
    exit()

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections

result = 0
n,k = map(int,input().split())
input_list = input().split()
counter_list = collections.Counter(input_list)
if k < len(counter_list):
  for i in range(len(counter_list)-k + 1):
    result += sorted(counter_list.values(),reverse=True)[-1]
print(result)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
2


Fixed submission (verdict: Accepted):
import collections

result = 0
n,k = map(int,input().split())
input_list = input().split()
counter_list = collections.Counter(input_list)
if k < len(counter_list):
  length = len(counter_list)-k
  sort_list = sorted(counter_list.values())
  for i in range(length):
    result += sort_list[i]
print(result)
Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(lambda x: int(x), input().split())
a=list(map(lambda x: int(x), input().split()))
dic={}
for i in range(n):
    dic[a[i]]=dic.get(a[i],0)+1
count=list(dic.values())
count.sort(reverse=True)
print(count)
if len(count) <= k:
    print(0)
else:
    print(sum(count[k:]))

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
[2, 2, 1]
1


Fixed submission (verdict: Accepted):
n,k=map(lambda x: int(x), input().split())
a=list(map(lambda x: int(x), input().split()))
dic={}
for i in range(n):
    dic[a[i]]=dic.get(a[i],0)+1
count=list(dic.values())
count.sort(reverse=True)
if len(count) <= k:
    print(0)
else:
    print(sum(count[k:]))

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
set_a = set(a)

count_list = []
if len(set_a) <= k:
    print(0)
else:
    for num in set_a:
        count_list.append(a.count(num))
    count_list = sorted(count_list, reverse = True)

    print(count_list)
    print(sum(count_list[k:]))

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
[2, 2, 1]
1


Fixed submission (verdict: Accepted):
from collections import Counter

n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
set_a = set(a)

count_list = []
if len(set_a) <= k:
    print(0)
else:
    a = Counter(a)
    cost = 0
    for (v, c) in a.most_common()[k:]:
        cost += c
    print(cost)

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k = map(int,input().split())
lst = list(map(int,input().split()))

typ = list(set(lst))
NumList = []
for i in range(len(typ)):
    c = lst.count(lst[i])
    NumList.append([lst[i],c])
NumList.sort(key = lambda x:x[1])
cnt = 0
for i in range(len(typ) - k):
    cnt += NumList[i][1]
print(cnt)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
2


Fixed submission (verdict: Accepted):
from collections import Counter

n,k = map(int,input().split())
lst = list(map(int,input().split()))
typ = list(set(lst))

ans = 0
NumList = Counter(lst)
num = sorted(NumList.items(),key=lambda x:x[1])
for l in range(len(typ)-k):
    ans += num[l][1]
print(ans)
Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
dbflag=0
def debug(*args):
  if dbflag: print(*args)

result = -1


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


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

bag = {}

for x in A:
	if x in bag:
		bag['x'+str(x)]+=1
	else:
		bag['x'+str(x)] = 1

debug(bag)
L = sorted(bag.items(),key= lambda x:x[1])
debug(L)
cnt = len(L) - K

if cnt > 0:
	result = sum(y[1] for y in L[0:K])
	debug([y[1] for y in L[0:K]])
else:
	result = 0


print(result)


Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
2


Fixed submission (verdict: Accepted):
dbflag=0
def debug(*args):
  if dbflag: print(*args)

result = 0


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


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

bag = {}

for x in A:
	if 'x'+str(x) in bag:
		bag['x'+str(x)]+=1
	else:
		bag['x'+str(x)] = 1

debug(bag)
L = sorted(bag.items(),key= lambda x:x[1])
debug(L,len(L),K)
cnt = len(L) - K

if cnt > 0:
	result = sum(y[1] for y in L[0:cnt])
	debug([y[1] for y in L[0:cnt]])
else:
	result = 0


print(result)

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
kind=[]
count=1
for i in range(len(a)-1):
  if(a[i]==a[i+1]):count+=1
  else:
    kind.append(count)
    count=1
kind.append(count)
kind.sort()
change=0
while(len(kind)>k):
  change+=kind.pop()
print(n-change)


Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
3


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
kind=[]
count=1
for i in range(len(a)-1):
  if(a[i]==a[i+1]):count+=1
  else:
    kind.append(count)
    count=1
kind.append(count)
kind.sort()
change=0
for i in range(k):
  if(len(kind)!=0):change+=kind.pop()
print(n-change)

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter

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

print(sum(sorted(c.values())[k:]))

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
2


Fixed submission (verdict: Accepted):
from collections import Counter

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

print(sum(sorted(c.values(), reverse=True)[k:]))

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
a = list(map(int, input().split()))
d = {}
for ai in a:
  if ai in d:
    d[ai] += 1
  else:
    d[ai] = 1
l = [d[key] for key in d]
l.sort()
if len(l) < k:
  print(0)
else:
  print(n - sum(l[:k]))


Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
2


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
a = list(map(int, input().split()))
d = {}
for ai in a:
  if ai in d:
    d[ai] += 1
  else:
    d[ai] = 1
l = [d[key] for key in d]
l.sort(reverse = True)
if len(l) < k:
  print(0)
else:
  print(n - sum(l[:k]))
Problem: p03495
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    n, k = map(int, input().split())
    inlis = list(map(int, input().split()))
    indic = dict()
    cnt = 0
    for i in range(n):
        num = inlis[i]
        if num in indic:
            indic[num] += 1
        else:
            indic[num] = 1
            cnt += 1
    if cnt <= k:
        print(0)
    else:
        indic_sort = sorted(indic.items(), key=lambda x:x[1])
        print(indic_sort)
        sa = cnt - k
        tmp = 0
        ans = 0
        for j in range(n):
            tmp += 1
            ans += indic_sort[j][1]
            if tmp == sa:
                break
        print(ans)



if __name__ == "__main__":
    main()

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
[(5, 1), (1, 2), (2, 2)]
1


Fixed submission (verdict: Accepted):
def main():
    n, k = map(int, input().split())
    inlis = list(map(int, input().split()))
    indic = dict()
    cnt = 0
    for i in range(n):
        num = inlis[i]
        if num in indic:
            indic[num] += 1
        else:
            indic[num] = 1
            cnt += 1
    if cnt <= k:
        print(0)
    else:
        indic_sort = sorted(indic.items(), key=lambda x:x[1])
        
        sa = cnt - k
        tmp = 0
        ans = 0
        for j in range(n):
            tmp += 1
            ans += indic_sort[j][1]
            if tmp == sa:
                break
        print(ans)



if __name__ == "__main__":
    main()

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
n, k = map(int, input().split())
a = list(map(int, input().split()))

B = set(a) 
d = Counter(a)

num = len(B) - k 

c = d.most_common()
print(c)
ans = 0
for i in range(1, num+1):
  ans += c[-i][1]
print(ans)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
[(1, 2), (2, 2), (5, 1)]
1


Fixed submission (verdict: Accepted):
from collections import Counter
n, k = map(int, input().split())
a = list(map(int, input().split()))

B = set(a) 
d = Counter(a)

num = len(B) - k 

c = d.most_common()
ans = 0
for i in range(1, num+1):
  ans += c[-i][1]
print(ans)

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
a = list(map(int, input().split()))

def solve():
  a.sort()
  count = [a.count(i) for i in range(n) if a.count(i)>0]
  count.sort()
  if(len(count)<k):
    print(0)
    return
  print(sum(count[:len(count)-k]))
  return

solve()

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
0


Fixed submission (verdict: Accepted):
import collections

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

def solve():
  c = list(collections.Counter(a).values())
  c.sort()
  if(len(c)<=k):
    print(0)
  else:
    print(sum(c[:len(c)-k]))

solve()
Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int, input().split())
l=sorted(list(map(int, input().split())))
ll=[]
cont=1
for i in range(n-1):
  if l[i]==l[i+1]:
    cont+=1
  else:
    ll.append(cont)
    cont=1
ll.append(l.count(l[-1]))
ll.reverse()

print(sum(ll[k:]))

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
2


Fixed submission (verdict: Accepted):
n,k=map(int, input().split())
l=sorted(list(map(int, input().split())))
ll=[]

cont=1
for i in range(n-1):
  if l[i]==l[i+1]:
    cont+=1
  else:
    ll.append(cont)
    cont=1
ll.append(l.count(l[-1]))
ll.sort()
ll.reverse()

print(sum(ll[k:]))

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):



import sys
from collections import Counter


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))  
def MI(): return map(int, sys.stdin.readline().rstrip().split())        
def II(): return int(sys.stdin.readline().rstrip())                     
def S(): return sys.stdin.readline().rstrip()                           

N, K = MI()
A = (LI())
A = sorted(Counter(A).values(), reverse = True)
sum = A[K:]
print(sum)


Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
[1]


Fixed submission (verdict: Accepted):



import sys
from collections import Counter


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))  
def MI(): return map(int, sys.stdin.readline().rstrip().split())        
def II(): return int(sys.stdin.readline().rstrip())                     
def S(): return sys.stdin.readline().rstrip()                           

N, K = MI()
A = LI()
A = sorted(Counter(A).values(), reverse = True)
sum = sum(A[K:])
print(sum)

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


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

A.sort()
num = len(list(set(A)))
c = [0] * A[-1]
for a in A:
    c[a - 1] += 1
c.sort()
ans = 0
if num > K:
    for i in range(num - K):
        ans += c[i]

print(ans)


Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
0


Fixed submission (verdict: Accepted):


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

A.sort()
num = len(list(set(A)))
c = [0] * A[-1]
for a in A:
    c[a - 1] += 1
c.sort()
ans = 0
if num > K:
    i = 0
    diff = 0
    while diff != num - K:
        if c[i] != 0:
            ans += c[i]
            i += 1
            diff += 1
        else:
            i += 1

print(ans)
Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
def main():
    n, k = map(int, input().split())
    a = tuple(map(int, input().split()))

    col = max(0, len(set(a)) - k)
    ac = Counter(a)
    acl = ac.most_common()[::-1]
    acll = [ace[1] for ace in acl[:col]]
    r = sum(acll)
    print(r)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:

Fixed submission (verdict: Accepted):
import sys
from collections import Counter
def main():
    n, k = map(int, input().split())
    a = tuple(map(int, input().split()))

    col = max(0, len(set(a)) - k)
    if col == 0:
        print(0)
        sys.exit()

    ac = Counter(a)
    acl = ac.most_common()[::-1]
    acll = [ace[1] for ace in acl[:col]]

    r = sum(acll)
    print(r)

if __name__ == '__main__':
    main()

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())
A = list(map(int, input().split()))
dic = {}
B = []
for a in A:
  if a in dic:
    dic[a] += 1
  else:
    dic[a] = 1
for v in dic.values():
  B.append(v)
B.sort()
if len(B) <= K:
  print(0)
else:
  print(sum(B[K:]))

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
2


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
A = list(map(int, input().split()))
dic = {}
B = []
for a in A:
  if a in dic:
    dic[a] += 1
  else:
    dic[a] = 1
for v in dic.values():
  B.append(v)
B.sort()
if len(B) <= K:
  print(0)
else:
  print(sum(B[:-K]))

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K=map(int, input().split())
A=list(map(int, input().split()))
ball={}
result=0
for i in range(N):
  if A[i] in ball.keys():
    ball[A[i]]+=1
  else:
    ball[A[i]]=1
sorted_ball = sorted(list(ball.values()))
if len(sorted_ball) > K:
  for i in range(K):
    result+=sorted_ball[i]
print(result)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
3


Fixed submission (verdict: Accepted):
N,K=map(int, input().split())
A=list(map(int, input().split()))
ball={}
result=0
for i in range(N):
  if A[i] in ball.keys():
    ball[A[i]]+=1
  else:
    ball[A[i]]=1
sorted_ball = sorted(list(ball.values()))
if len(sorted_ball) > K:
  for i in range(len(sorted_ball)-K):
    result+=sorted_ball[i]
print(result)

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
a=list(map(int,input().split()))
count=[0]*n
for i in range(n):
  count[a[i]-1] += 1
count.sort()
sum=0
print(count)
for i in range(k):
  sum += count[n-1-i]
print(max(0,n-sum));

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
[0, 0, 1, 2, 2]
1


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
a=list(map(int,input().split()))
count=[0]*n
for i in range(n):
  count[a[i]-1] += 1
count.sort()
sum=0
for i in range(k):
  sum += count[n-1-i]
print(max(0,n-sum));
Problem: p03495
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,k=map(int,input().split())
a=list(map(int,input().split()))
from collections import defaultdict
d=defaultdict(int)
for i in a:
  d[i]+=1
print(sum(sorted(list(d.values()))[:n-k]))

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
5


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
a=list(map(int,input().split()))
from collections import defaultdict
d=defaultdict(int)
for i in a:
  d[i]+=1
if len(d)<=k:
  print(0)
else:
  print(sum(sorted(list(d.values()))[:len(d)-k]))

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K=map(int,input().split())
A=list(map(int,input().split()))
sa=len(set(A))-K
if sa>0:
    As={}
    for i in range(N):
        if A[i] in As:
            As[A[i]]+=1
        else:
            As[A[i]]=1
    Ass=sorted(As.values())
    print(Ass)
    print(sum(Ass[:sa]))
else:
    print(0)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
[1, 2, 2]
1


Fixed submission (verdict: Accepted):
N,K=map(int,input().split())
A=list(map(int,input().split()))
sa=len(set(A))-K
if sa>0:
    As={}
    for i in range(N):
        if A[i] in As:
            As[A[i]]+=1
        else:
            As[A[i]]=1
    Ass=sorted(As.values())
    print(sum(Ass[:sa]))
else:
    print(0)

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = input().split()
A = [int(n) for n in input().split()]
kind = dict()

for n in A:
    if n not in kind:
        kind[n] = 0
    kind[n] += 1

print(kind)

diff = len(kind) - int(K)
if diff > 0:
    values = sorted(kind.values())
    print(sum(values[:diff]))
else:
    print(0)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
{1: 2, 2: 2, 5: 1}
1


Fixed submission (verdict: Accepted):
N, K = input().split()
A = [int(n) for n in input().split()]
kind = dict()

for n in A:
    if n not in kind:
        kind[n] = 0
    kind[n] += 1
diff = len(kind) - int(K)
if diff > 0:
    values = sorted(kind.values())
    print(sum(values[:diff]))
else:
    print(0)

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
N, K=list(map(int, input().split()))
A=list(map(int, input().split()))

X=Counter(A)
print(len(X))
X2 = sorted(X.items(), key=lambda x:x[1])
ans=0
for i in range(len(X2)-K):
    ans+=X2[i][1]
print(ans)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
3
1


Fixed submission (verdict: Accepted):
from collections import Counter
N, K=list(map(int, input().split()))
A=list(map(int, input().split()))

X=Counter(A)
X2 = sorted(X.items(), key=lambda x:x[1])
ans=0
for i in range(len(X2)-K):
    ans+=X2[i][1]
print(ans)
Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())
a = list(map(int, input().split()))
if N == K:
    print(0)
else:
    d = {str(i):0 for i in a}
    print(d)
    bucket = sorted([a.count(int(i)) for i in d])
    print(sum(bucket[0:len(bucket) - K:]))

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
{'1': 0, '2': 0, '5': 0}
1


Fixed submission (verdict: Accepted):
from collections import Counter
N, K = map(int, input().split())
a = Counter(list(map(int, input().split())))
if N == K:
    print(0)
else:
    num = list(a.values())
    if len(num) <= K:
        print(0)
    else:
        print(sum(sorted(num)[:-K]))

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K=map(int, input().split())
A=list(map(int, input().split()))
ball={}
result=0
for i in range(N):
  if A[i] in ball.keys():
    ball[A[i]]+=1
  else:
    ball[A[i]]=1
sorted_ball = sorted(list(ball.values()))
if len(sorted_ball) > K:
  for i in range(K):
    result+=1
print(result)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
2


Fixed submission (verdict: Accepted):
N,K=map(int, input().split())
A=list(map(int, input().split()))
ball={}
result=0
for i in range(N):
  if A[i] in ball.keys():
    ball[A[i]]+=1
  else:
    ball[A[i]]=1
sorted_ball = sorted(list(ball.values()))
if len(sorted_ball) > K:
  for i in range(len(sorted_ball)-K):
    result+=sorted_ball[i]
print(result)

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
  N, K = map(int, input().split())
  A = list(map(int, input().split()))

  l = [0] * (N+1)
  for i in range(N):
    l[A[i]] += 1
  l.sort(reverse=True)
  print(l)
  ans = N - sum(l[:K])
  print(ans)

if __name__ == '__main__':
  main()


Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
[2, 2, 1, 0, 0, 0]
1


Fixed submission (verdict: Accepted):
def main():
  N, K = map(int, input().split())
  A = list(map(int, input().split()))

  l = [0] * (N+1)
  for i in range(N):
    l[A[i]] += 1
  l.sort(reverse=True)
  ans = N - sum(l[:K])
  print(ans)

if __name__ == '__main__':
  main()

Problem: p03495
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n,k=map(int,input().split())
nm=[0 for i in range(200010)]
a=list(map(int,input().split()))
for i in a:
  nm[i]+=1
a.sort(reverse=True)
for i in range(k):
  n-=a[i]
print(n)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
-2


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
nm=[0 for i in range(200010)]
a=list(map(int,input().split()))
for i in a:
  nm[i]+=1
nm.sort(reverse=True)
for i in range(k):
  n-=nm[i]
print(n)
Problem: p03495
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [0 for i in range(N+1)]

for a in A:
  B[a] += 1

nums = [b for b in B if b > 0]
nums.sort()
n = len(nums)
if n <= K:
  print(0)
else:
  print(sum(nums[:K-n]))

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
3


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [0 for i in range(N+1)]
 
for a in A:
  B[a] += 1
nums = [b for b in B if b > 0]
nums.sort()
n = len(nums)
if n <= K:
  print(0)
else:
  print(sum(nums[:n-K]))

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())
A = list(map(int, input().split()))

dct = {}
for i in A:
    if i in dct:
        dct[i] += 1
    else:
        dct[i] = 1

ls = sorted(dct.values(), reverse=True)
mini = sum(ls)
for i in ls:
    mini -= i
    if mini <= K:
        break

print(0 if mini <= K else mini)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
0


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
A = list(map(int, input().split()))

buckets = {}
for i in A:
    if i in buckets:
        buckets[i] += 1
    else:
        buckets[i] = 1

kinds = sorted(buckets.values())
count = len(kinds)
if K < count:
    mini = 0
    for i in kinds:
        mini += i
        count -= 1
        if count <= K:
            break
    print(mini)
else:
    print(0)

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=len(a)
a=dict(Counter(a))
count=0
a = sorted(a.items(), key=lambda x:x[1], reverse=True)
print(a)
for i,j in a:
  count+=1
  ans-=j
  if count==k:
    break
print(ans)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
[(1, 2), (2, 2), (5, 1)]
1


Fixed submission (verdict: Accepted):
from collections import Counter
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=len(a)
a=dict(Counter(a))
count=0
a = sorted(a.items(), key=lambda x:x[1], reverse=True)
for i,j in a:
  count+=1
  ans-=j
  if count==k:
    break
print(ans)

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
set_a = set(a)

count_list = []
if len(set_a) <= k:
    print(0)
else:
    for num in set_a:
        count_list.append(a.count(num))
    count_list = sorted(count_list)    

    print(sum(count_list[k:]))

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
2


Fixed submission (verdict: Accepted):
from collections import Counter

n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
set_a = set(a)

count_list = []
if len(set_a) <= k:
    print(0)
else:
    a = Counter(a)
    cost = 0
    for (v, c) in a.most_common()[k:]:
        cost += c
    print(cost)
Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
x = len(set(a))
if x <= k:
    print(ans)
else:
    b = Counter(a).most_common(x)
    for i in range(x-1,k-1,-1):
        print(i)
        ans += b[i][1]
    print(ans)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
2
1


Fixed submission (verdict: Accepted):
from collections import Counter
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
x = len(set(a))
if x <= k:
    print(ans)
else:
    b = Counter(a).most_common(x)
    for i in range(x-1,k-1,-1):
        ans += b[i][1]
    print(ans)

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())

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

C = list(set(A))

B = len(C) 
x = B - K

d = {}

for i in A:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1

d = sorted(d.items(), key=lambda x:x[1], reverse=True)

ans = 0
count = 0

for key, value in d:
    ans = ans + value
    count = count + 1
    if count == x:
        print(ans)
        break

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
2


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())

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

C = list(set(A))

B = len(C) 
x = B - K

d = {}

for i in A:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1

d = sorted(d.items(), key=lambda x:x[1])

ans = 0
count = 0

if x<=0:
    print('0')
else:
    for key, value in d:
        ans = ans + value
        count = count + 1
        if count == x:
            print(ans)
            break

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
d={}
for i in a:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
t=[]
for i in d:
    t.append(d[i])
print(sum(t[0:-2]))

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
2


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
d={}
for i in a:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
t=[]
for i in d:
    t.append(d[i])
t.sort()
print(sum(t[0:-k]))

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
a=list(map(int,input().split()))
count=[0]*n
for i in range(n):
  count[a[i]-1] += 1
count.sort()
sum=0
for i in range(k):
  sum += count[i]
print(max(0,n-sum));

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
5


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
a=list(map(int,input().split()))
count=[0]*n
for i in range(n):
  count[a[i]-1] += 1
count.sort()
sum=0
for i in range(k):
  sum += count[n-1-i]
print(max(0,n-sum));
Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter


def solve(string):
    n, k, *a = map(int, string.split())
    count = Counter(a)
    return str(sum(sorted(count.values(), reverse=True)[k:]))


if __name__ == '__main__':
    print(solve(input()))


Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
0


Fixed submission (verdict: Accepted):
from collections import Counter


def solve(string):
    n, k, *a = map(int, string.split())
    count = Counter(a)
    return str(sum(sorted(count.values(), reverse=True)[k:]))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())
A = list(map(int, input().split()))

import collections
A_tuple = collections.Counter(A).most_common()[::-1]
print(len(A_tuple))
if len(A_tuple) < K:
    print(0)
else:
    ans = 0
    for i in range(len(A_tuple)-K):
        ans += A_tuple[i][1]
    print(ans)


Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
3
1


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
A = list(map(int, input().split()))

import collections
A_tuple = collections.Counter(A).most_common()[::-1]

if len(A_tuple) < K:
    print(0)
else:
    ans = 0
    for i in range(len(A_tuple)-K):
        ans += A_tuple[i][1]
    print(ans)

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
A.insert(len(A),0)
L = []
k = 1
for i in range(len(A)-1):
  if (A[i] == A[i+1]):
    k += 1
    i += 1
  else:
    L.append(k)
    k = 1
    i += 1
  
L.sort()
print(L)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
[1, 2, 2]


Fixed submission (verdict: Accepted):
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
A.insert(len(A),0)
L = []
k = 1
for i in range(len(A)-1):
  if (A[i] == A[i+1]):
    k += 1
    i += 1
  else:
    L.append(k)
    k = 1
    i += 1  
L.sort()
if (len(L) <= K):
  print(0)
else:
  print(sum(L[:len(L)-K]))
Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
counter = [] 
x = 0
count = 1
while x < n-1:
	for i in range(n-x-1):
		if a[x] == a[x+1+i]:
			count += 1
		else:
			break
	counter.append(count)
	x = x+1+i
	count = 1
if a[n-2] != a[n-1]:
	counter.append(1)
counter.sort()
print(counter)

y = len(counter)
l = y
answer = 0
for i in range(y): 
	if l > k:
		answer += counter[i]
		l = l - 1
	else:
		break
print(answer)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
[1, 2, 2]
1


Fixed submission (verdict: Accepted):
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
counter = [] 
x = 0
count = 1
while x < n-1:
	for i in range(n-x-1):
		if a[x] == a[x+1+i]:
			count += 1
		else:
			break
	counter.append(count)
	x = x+1+i
	count = 1
if a[n-2] != a[n-1]:
	counter.append(1)
counter.sort()

y = len(counter)
l = y
answer = 0
for i in range(y): 
	if l > k:
		answer += counter[i]
		l = l - 1
	else:
		break
print(answer)

Problem: p03495
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import collections

n,k = map(int,input().split())
a = [int(i) for i in input().split()]
b = collections.Counter(a)
c = sorted(b.items(), key=lambda x:x[1])
ans = 0
d = len(c)
i = 0
while d >= k:
    d -= c[i][1]
    ans += c[i][1]
    i +=1
print(ans)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
3


Fixed submission (verdict: Accepted):
import collections

n,k = map(int,input().split())
a = [int(i) for i in input().split()]
b = collections.Counter(a)
c = sorted(b.items(), key=lambda x:x[1])
ans = 0
d = len(c)
i = 0
while d > k:
    d -= 1
    ans += c[i][1]
    i +=1
print(ans)

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import OrderedDict

N, K =map(int, input().split())
a = list(map(int, input().split()))
p = OrderedDict()
for i in a:
  if i not in p:
    p[i] = 1
  else:
    p[i] +=1

p_rev = OrderedDict(
    sorted(p.items(), key=lambda x: x[1])
)


count = 0
sum = 0
for i in p_rev.values():
  if len(p_rev) - count >= K:
    sum += i
    count += 1
  else:
    break
print(sum)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
3


Fixed submission (verdict: Accepted):
from collections import OrderedDict

N, K =map(int, input().split())
a = list(map(int, input().split()))
p = OrderedDict()
for i in a:
  if i not in p:
    p[i] = 1
  else:
    p[i] +=1

p_rev = OrderedDict(
    sorted(p.items(), key=lambda x: x[1])
)


count = 0
sum = 0
for i in p_rev.values():
  if len(p_rev) - count > K:
    sum += i
    count += 1
  else:
    break
print(sum)
Problem: p03495
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
from collections import Counter
n, k = map(int, input().split())
a = list(map(int, input().split()))
syurui = len(set(a))

c = Counter(a)
ans = 0
c_sort = c.most_common()
print(c_sort)
for i in range(1, syurui-k + 1):
    ans += c_sort[-i][1]
print(ans)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
[(1, 2), (2, 2), (5, 1)]
1


Fixed submission (verdict: Accepted):
from collections import Counter
n, k = map(int, input().split())
a = list(map(int, input().split()))
syurui = len(set(a))

c = Counter(a)
ans = 0
c_sort = c.most_common()

for i in range(1, syurui-k + 1):
    ans += c_sort[-i][1]
print(ans)

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
n,k=map(int,input().split())
a=list(map(int,input().split()))
c=Counter(a).most_common()
ans=0
idx=1
while k>0:
  k-=c[-idx][1]
  ans+=c[-idx][1]
  idx+=1
print(ans)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
3


Fixed submission (verdict: Accepted):
from collections import Counter
n,k=map(int,input().split())
a=list(map(int,input().split()))
c=Counter(a).most_common()
ans=0
idx=1
m=len(c)
while m>k:
  m-=1
  ans+=c[-idx][1]
  idx+=1
print(ans)

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter as ct
N,K=map(int,input().split())
A=[int(i) for i in input().split()]
count=ct(A)
div=len(count)
if div<=K:print(0)
else:print(sum([i[0] for i in sorted(count.items(),key= lambda x:x[1])[:div-K]]))
        

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
5


Fixed submission (verdict: Accepted):
from collections import Counter as ct
N,K=map(int,input().split())
A=[int(i) for i in input().split()]
count=ct(A)
div=len(count)
if div<=K:print(0)
else:print(sum([i[1] for i in sorted(count.items(),key= lambda x:x[1])[:div-K]]))

Problem: p03495
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict
if __name__ == '__main__':
    
    
    
    N = 200000
    K = 1
    A = [0 for i in range(1, N+1)]
    Adict = [0]*N
    for a in A:
        Adict[a-1] += 1
    num = len(set(A))

    
    Adict = sorted(Adict,reverse=True)
    count=0
    for _ in range(num - K):
        while True:
            min_num = Adict.pop()
            count += min_num
            if min_num != 0:
                break
    print(count)

Failing test case input:
5 2
1 1 2 2 5

Expected output:
1

Actual output:
0


Fixed submission (verdict: Accepted):
from collections import defaultdict
if __name__ == '__main__':
    N, K = map(int, input().split())
    A = [None]*N
    A = list(map(int, input().split()))

    Adict = [0]*N
    for a in A:
        Adict[a-1] += 1
    num = len(set(A))

    
    Adict = sorted(Adict,reverse=True)
    count=0
    for _ in range(num - K):
        while True:
            min_num = Adict.pop()
            count += min_num
            if min_num != 0:
                break
    
    print(count)