Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split(' '))
A = input().split(' ')

num = []
count = []
for a in range(len(A)):
    tmp = A[a]
    if not tmp in num:
        num.append(tmp)
        count.append(1)
    else:
        index = num.index(tmp)
        count[index] += 1

count = sorted(count)
ans = 0
if len(count)<=K:
    pass
else:
    tmp = len(count)-K
    count = count[:tmp]
    ans = sum(count)

print(ans)

Fixed submission:
#辞書型でリトライ
N,K = map(int, input().split(' '))
A = input().split(' ')

dic = {}
for a in range(len(A)):
    tmp = A[a]
    if not tmp in dic:
        dic[tmp] = 1
    else:
        dic[tmp] += 1

values = sorted(dic.values())
ans = 0
if len(values)<=K:
    pass
else:
    tmp = len(values)-K
    values = values[:tmp]
    ans = sum(values)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split(' '))
A = [int(i) for i in input().split(' ')]

num = []
count = []
for a in range(len(A)):
    tmp = A[a]
    if not tmp in num:
        num.append(tmp)
        count.append(1)
    else:
        index = num.index(tmp)
        count[index] += 1

count = sorted(count)
ans = 0
if len(count)<=K:
    pass
else:
    tmp = len(count)-K
    count = count[:tmp]
    ans = sum(count)

print(ans)

Fixed submission:
#辞書型でリトライ
N,K = map(int, input().split(' '))
A = input().split(' ')

dic = {}
for a in range(len(A)):
    tmp = A[a]
    if not tmp in dic:
        dic[tmp] = 1
    else:
        dic[tmp] += 1

values = sorted(dic.values())
ans = 0
if len(values)<=K:
    pass
else:
    tmp = len(values)-K
    values = values[:tmp]
    ans = sum(values)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split(' '))
A = [int(i) for i in input().split(' ')]

num = []
count = []
for a in range(len(A)):
    tmp = A[a]
    if not tmp in num:
        num.append(tmp)
        count.append(1)
    else:
        index = num.index(tmp)
        count[index] += 1

count = sorted(count)
ans = 0
if len(count)<=K:
    pass
else:
    for i in range(len(count)-K):
        ans += count[i]

print(ans)

Fixed submission:
#辞書型でリトライ
N,K = map(int, input().split(' '))
A = input().split(' ')

dic = {}
for a in range(len(A)):
    tmp = A[a]
    if not tmp in dic:
        dic[tmp] = 1
    else:
        dic[tmp] += 1

values = sorted(dic.values())
ans = 0
if len(values)<=K:
    pass
else:
    tmp = len(values)-K
    values = values[:tmp]
    ans = sum(values)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split(' '))
A = [int(i) for i in input().split(' ')]

num = []
count = []
for a in range(len(A)):
    tmp = A[a]
    if not tmp in num:
        num.append(tmp)
        count.append(1)
    else:
        index = num.index(tmp)
        count[index] += 1

count = sorted(count)
ans = 0
if len(count)<=K:
    pass
else:
    for i in range(len(count)-K):
        ans += count[i]

print(ans)

Fixed submission:
#辞書型でリトライ
N,K = map(int, input().split(' '))
A = input().split(' ')

dic = {}
for a in range(len(A)):
    tmp = A[a]
    if not tmp in dic:
        dic[tmp] = 1
    else:
        dic[tmp] += 1

values = sorted(dic.values())
ans = 0
if len(values)<=K:
    pass
else:
    tmp = len(values)-K
    values = values[:tmp]
    ans = sum(values)

print(ans)