Buggy python submission (verdict: Runtime Error):
n, k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
d=sorted([a.count(i) for i in set(a)])[::-1]
ans=0
for i in range(k):
  ans+=d[i]
print(n-ans)


Fixed submission:
n, k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
d={i:0 for i in set(a)}
for i in a: d[i]+=1
print(n-sum([t[1] for t in sorted(d.items(), key=lambda x:-x[1])][:k]))

Buggy python submission (verdict: Time Limit Exceeded):
n, k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
d=sorted([a.count(i) for i in range(n)])[::-1]
print(n-sum(d[:k]))


Fixed submission:
n, k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
d={i:0 for i in set(a)}
for i in a: d[i]+=1
print(n-sum([t[1] for t in sorted(d.items(), key=lambda x:-x[1])][:k]))

Buggy python submission (verdict: Time Limit Exceeded):
n, k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
d=sorted([a.count(i) for i in set(a)])[::-1]
print(n-sum(d[:k]))


Fixed submission:
n, k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
d={i:0 for i in set(a)}
for i in a: d[i]+=1
print(n-sum([t[1] for t in sorted(d.items(), key=lambda x:-x[1])][:k]))

Buggy python submission (verdict: Time Limit Exceeded):
n, k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
d=sorted([a.count(i) for i in set(a)])[::-1]
if len(d)-k>0: print(len(a)-sum(d[:k]))
else: print("0")


Fixed submission:
n, k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
d={i:0 for i in set(a)}
for i in a: d[i]+=1
print(n-sum([t[1] for t in sorted(d.items(), key=lambda x:-x[1])][:k]))

Buggy python submission (verdict: Time Limit Exceeded):
n, k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
d={i:a.count(i) for i in set(a)}
p=len(d)-k
l=[]
for i in range(p):
  t=list(d.items())[0]
  for j in d.items():
    if t[1]>j[1]:
      t=j
  l.append(t[1])
  d.pop(t[0], None)
if p>0: print(sum(l))
else: print("0")


Fixed submission:
n, k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
d={i:0 for i in set(a)}
for i in a: d[i]+=1
print(n-sum([t[1] for t in sorted(d.items(), key=lambda x:-x[1])][:k]))

Buggy python submission (verdict: Time Limit Exceeded):
n, k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
d={i:a.count(i) for i in set(a)}
p=len(d)-k
if p>0: print(sum((t[1] for t in sorted(d.items(), key=lambda x:x[1])[:p])))
else: print("0")


Fixed submission:
n, k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
d={i:0 for i in set(a)}
for i in a: d[i]+=1
print(n-sum([t[1] for t in sorted(d.items(), key=lambda x:-x[1])][:k]))

Buggy python submission (verdict: Time Limit Exceeded):
n, k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
s=set(a)
d=[a.count(i) for i in s]
p=len(s)-k
d=sorted(d)
if p>0: print(sum(d[:p]))
else: print("0")


Fixed submission:
n, k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
d={i:0 for i in set(a)}
for i in a: d[i]+=1
print(n-sum([t[1] for t in sorted(d.items(), key=lambda x:-x[1])][:k]))

Buggy python submission (verdict: Time Limit Exceeded):
n, k=[int(x) for x in input().split()]
a=input().split()
s=set(a)
d=[]
for i in s:
  d.append(a.count(i))
p=len(s)-k
if p<=0:
  print("0")
  exit()
d=sorted(d)
print(sum(d[:p]))


Fixed submission:
n, k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
d={i:0 for i in set(a)}
for i in a: d[i]+=1
print(n-sum([t[1] for t in sorted(d.items(), key=lambda x:-x[1])][:k]))

Buggy python submission (verdict: Time Limit Exceeded):
n, k=[int(x) for x in input().split()]
a=input().split()
s=set(a)
d=[]
for i in s:
  d.append(a.count(i))
p=len(s)-k
if p<=0:
  print("0")
  exit()
d=sorted(d, key=lambda x:x)
r=0
for i in range(p):
  r+=d[i]
print(r)


Fixed submission:
n, k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
d={i:0 for i in set(a)}
for i in a: d[i]+=1
print(n-sum([t[1] for t in sorted(d.items(), key=lambda x:-x[1])][:k]))

Buggy python submission (verdict: Time Limit Exceeded):
n, k=[int(x) for x in input().split()]
a=input().split()
s=set(a)
d={}
for i in s:
  d[i]=a.count(i)
p=len(s)-k
if p<=0:
  print("0")
  exit()
d=sorted(d.items(), key=lambda x:x[1])
r=0
for i in range(p):
  r+=d[i][1]
print(r)

Fixed submission:
n, k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
d={i:0 for i in set(a)}
for i in a: d[i]+=1
print(n-sum([t[1] for t in sorted(d.items(), key=lambda x:-x[1])][:k]))