Buggy python submission (verdict: Time Limit Exceeded):
Input = map(int,raw_input().split(' '))
N = Input[0]
K = Input[1]
A = map(int,raw_input().split(' '))
A = sorted(A)
count = []
i = 0
while i < len(A):
	count.append(A.count(A[i]))
	i += A.count(A[i])
count = sorted(count)
dim = len(count)
rslt = 0
if dim <= K:
	print rslt
else:
	rslt += sum(count[:dim-K])
	print rslt

Fixed submission:
import bisect
Input = map(int,raw_input().split(' '))
N = Input[0]
K = Input[1]
A = map(int,raw_input().split(' '))
A = sorted(A)
count = []
i = 0
while i < len(A):
	count.append(bisect.bisect_right(A,A[i]) - bisect.bisect_left(A,A[i]))
	i = bisect.bisect_right(A,A[i])
count = sorted(count)
dim = len(count)
rslt = 0
if dim <= K:
	print rslt
else:
	rslt += sum(count[:dim-K])
	print rslt

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

Input = map(int,raw_input().split(' '))
N = Input[0]
K = Input[1]
A = map(int,raw_input().split(' '))
A = sorted(A)
count = []
i = 0
while i < len(A):
	count.append(A.count(A[i]))
	i += A.count(A[i])
count = sorted(count)
count = np.array(count)
dim = count.shape[0]
rslt = 0
if dim <= K:
	print rslt
else:
	rslt += count[:dim-K].sum()
	print rslt

Fixed submission:
import bisect
Input = map(int,raw_input().split(' '))
N = Input[0]
K = Input[1]
A = map(int,raw_input().split(' '))
A = sorted(A)
count = []
i = 0
while i < len(A):
	count.append(bisect.bisect_right(A,A[i]) - bisect.bisect_left(A,A[i]))
	i = bisect.bisect_right(A,A[i])
count = sorted(count)
dim = len(count)
rslt = 0
if dim <= K:
	print rslt
else:
	rslt += sum(count[:dim-K])
	print rslt

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

Input = map(int,raw_input().split(' '))
N = Input[0]
K = Input[1]
A = map(int,raw_input().split(' '))
#A = sorted(A)

count = []
for n in range(1,N+1):
	count.append(A.count(n))
count = sorted(count)
zeroCount = count.count(0)
count = np.array(count)
rslt = 0
if zeroCount > N - K :
	print rslt
else:
	rslt += count[zeroCount:N-K].sum()
	print rslt

Fixed submission:
import bisect
Input = map(int,raw_input().split(' '))
N = Input[0]
K = Input[1]
A = map(int,raw_input().split(' '))
A = sorted(A)
count = []
i = 0
while i < len(A):
	count.append(bisect.bisect_right(A,A[i]) - bisect.bisect_left(A,A[i]))
	i = bisect.bisect_right(A,A[i])
count = sorted(count)
dim = len(count)
rslt = 0
if dim <= K:
	print rslt
else:
	rslt += sum(count[:dim-K])
	print rslt

Buggy python submission (verdict: Time Limit Exceeded):
Input = map(int,raw_input().split(' '))
N = Input[0]
K = Input[1]
A = map(int,raw_input().split(' '))
#A = sorted(A)

count = []
for n in range(1,N+1):
	count.append(A.count(n))

count = sorted(count)
zeroCount = count.count(0)
rslt = 0
if zeroCount > N - K :
	print rslt
else:
	while count.count(0) != N - K:
		rslt += count[zeroCount]
		count[zeroCount] = 0
		zeroCount += 1

	print rslt

Fixed submission:
import bisect
Input = map(int,raw_input().split(' '))
N = Input[0]
K = Input[1]
A = map(int,raw_input().split(' '))
A = sorted(A)
count = []
i = 0
while i < len(A):
	count.append(bisect.bisect_right(A,A[i]) - bisect.bisect_left(A,A[i]))
	i = bisect.bisect_right(A,A[i])
count = sorted(count)
dim = len(count)
rslt = 0
if dim <= K:
	print rslt
else:
	rslt += sum(count[:dim-K])
	print rslt