Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
num_lists = list(map(int, input().split()))

num_counts = dict()
if len(set(num_lists)) <= k:
  ans = 0
else:
  for i in set(num_lists):
    num_counts[i] = num_lists.count(i)
    numbers = list(num_counts.values())
    numbers.sort()
    ans = 0
  for i in range(len(set(num_lists)) - k):
    ans += numbers[i]

print(ans)


Fixed submission:
from collections import Counter

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

num_counts = dict()
length = len(set(num_lists))
ans = 0

if length > k:
  d = Counter()
  d.update(num_lists)
  count_sorted = list(d.values())
  count_sorted.sort()
  for i in range(length - k):
    ans += count_sorted[i]

print(ans)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
num_lists = list(map(int, input().split()))

num_counts = dict()
if len(set(num_lists)) <= k:
  ans = 0
else:
  for i in set(num_lists):
    num_counts[i] = num_lists.count(i)
    numbers = [num_counts.values()]
    numbers.sort()
    ans = 0
  for i in range(len(set(num_lists)) - k):
    ans += numbers[i]

print(ans)


Fixed submission:
from collections import Counter

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

num_counts = dict()
length = len(set(num_lists))
ans = 0

if length > k:
  d = Counter()
  d.update(num_lists)
  count_sorted = list(d.values())
  count_sorted.sort()
  for i in range(length - k):
    ans += count_sorted[i]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
num_lists = list(map(int, input().split()))

if len(set(num_lists)) <= k:
  ans = 0
else:
  num_counts = {}
  for i in set(num_lists):
    num_counts[i] = num_lists.count(i)
  
  numbers = list(num_counts.values())
  numbers.sort()
  ans = 0
  for i in range(len(set(num_lists))-k):
    ans += numbers[i]
print(ans)


Fixed submission:
from collections import Counter

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

num_counts = dict()
length = len(set(num_lists))
ans = 0

if length > k:
  d = Counter()
  d.update(num_lists)
  count_sorted = list(d.values())
  count_sorted.sort()
  for i in range(length - k):
    ans += count_sorted[i]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
num_lists = list(map(int, input().split()))

if len(set(num_lists)) <= k:
  ans = 0
else:
  num_counts = {}
  for i in set(num_lists):
    num_counts[i] = num_lists.count(i)
  
  numbers = list(num_counts.values())
  numbers.sort()
  ans = 0
  for i in range(len(set(num_lists))-k):
    ans += numbers[i]
print(ans)


Fixed submission:
from collections import Counter

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

num_counts = dict()
length = len(set(num_lists))
ans = 0

if length > k:
  d = Counter()
  d.update(num_lists)
  count_sorted = list(d.values())
  count_sorted.sort()
  for i in range(length - k):
    ans += count_sorted[i]

print(ans)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
num_lists = list(map(int, input().split()))

if len(set(num_lists)) <= k:
  ans = 0
else:
  num_counts = {}
  for i in set(num_lists):
    num_counts[i] = num_lists.count(i)
  
  numbers = list(num_counts.values())
  numbers.sort()
  ans = 0
  for i in range(k - len(set(num_lists)):
    ans += numbers[i]
print(ans)


Fixed submission:
from collections import Counter

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

num_counts = dict()
length = len(set(num_lists))
ans = 0

if length > k:
  d = Counter()
  d.update(num_lists)
  count_sorted = list(d.values())
  count_sorted.sort()
  for i in range(length - k):
    ans += count_sorted[i]

print(ans)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
num_lists = list(map(int, input().split()))

if len(set(num_lists)) <= k:
  ans = 0
else:
  num_counts = {}
  for i in set(num_lists):
    num_counts[i] = num_lists.count(i)
  
  numbers = list(num_counts.values)
  numbers.sort()
  ans = 0
  for i in range(k - len(set(num_lists)):
    ans += numbers[i]
print(ans)

Fixed submission:
from collections import Counter

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

num_counts = dict()
length = len(set(num_lists))
ans = 0

if length > k:
  d = Counter()
  d.update(num_lists)
  count_sorted = list(d.values())
  count_sorted.sort()
  for i in range(length - k):
    ans += count_sorted[i]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
num_lists = list(map(int, input().split()))

num_counts = {}
if len(set(num_lists)) <= k:
  ans = 0
else:
  for i in set(num_lists):
    num_counts[i] = num_lists.count(i)
  numbers = list(num_counts.values())
  numbers.sort()
  ans = 0
  for i in range(len(set(num_lists)) - k):
    ans += numbers[i]

print(ans)

Fixed submission:
from collections import Counter

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

num_counts = dict()
length = len(set(num_lists))
ans = 0

if length > k:
  d = Counter()
  d.update(num_lists)
  count_sorted = list(d.values())
  count_sorted.sort()
  for i in range(length - k):
    ans += count_sorted[i]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
num_lists = list(map(int, input().split()))

num_counts = {}
if len(set(num_lists)) <= k:
  ans = 0
else:
  for i in set(num_lists):
    num_counts[i] = num_lists.count(i)
    numbers = list(num_counts.values())
    numbers.sort()
    ans = 0
  for i in range(len(set(num_lists)) - k):
    ans += numbers[i]

print(ans)

Fixed submission:
from collections import Counter

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

num_counts = dict()
length = len(set(num_lists))
ans = 0

if length > k:
  d = Counter()
  d.update(num_lists)
  count_sorted = list(d.values())
  count_sorted.sort()
  for i in range(length - k):
    ans += count_sorted[i]

print(ans)