Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list( map(int, input().split()) ) #ここでN個受け取る

flags = [0] * 21000
nums = [0] * 21000

for i in range(N):
    flags[A[i]] = 1
    nums[A[i]] += 1
    
s_nums = sorted(nums)
count = 0
ans = 0

if sum(flags) - K > 0:
    for j in range(len(s_nums)):
        if count < sum(flags)-K:
            ans += s_nums[j]
            count += 1
            
    print(ans)
    
else :
    print(0)


Fixed submission:
N, K = map(int, input().split())
A = list( map(int, input().split()) ) #ここでN個受け取る

var = [0] * (N+1)


for i in A:
    var[i] += 1
    
var = sorted(var,  reverse = True )


count = 0
for j in range( K, N+1 ):
    if var[j] == 0:
        break
    
    if var[j] != 0:
        count += var[j]
        
print(count)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list( map(int, input().split()) ) #ここでN個受け取る

var = [0] * N+1


for i in A:
    var[i] += 1
    
var = sorted(var,  reverse = True )


count = 0
for j in range( K, N+1 ):
    if var[j] == 0:
        break
    
    if var[j] != 0:
        count += var[j]
        
print(count)

Fixed submission:
N, K = map(int, input().split())
A = list( map(int, input().split()) ) #ここでN個受け取る

var = [0] * (N+1)


for i in A:
    var[i] += 1
    
var = sorted(var,  reverse = True )


count = 0
for j in range( K, N+1 ):
    if var[j] == 0:
        break
    
    if var[j] != 0:
        count += var[j]
        
print(count)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list( map(int, input().split()) ) #ここでN個受け取る

var = [0] * N+1


for i in A:
    var[i] += 1
    
var.sort( reverse = True )


count = 0
for j in range( K, N+1 ):
    if var[j] == 0:
        break
    
    if var[j] != 0:
        count += var[j]
        
print(count)

Fixed submission:
N, K = map(int, input().split())
A = list( map(int, input().split()) ) #ここでN個受け取る

var = [0] * (N+1)


for i in A:
    var[i] += 1
    
var = sorted(var,  reverse = True )


count = 0
for j in range( K, N+1 ):
    if var[j] == 0:
        break
    
    if var[j] != 0:
        count += var[j]
        
print(count)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list( map(int, input().split()) ) #ここでN個受け取る

var = [0] * 21000


for i in range(N):
    var[A[i]] += 1
    
var.sort( reverse = True )


count = 0
for j in range( K, N ):
    if var[j] == 0:
        break
    
    if var[j] != 0:
        count += var[j]
        
print(count)

Fixed submission:
N, K = map(int, input().split())
A = list( map(int, input().split()) ) #ここでN個受け取る

var = [0] * (N+1)


for i in A:
    var[i] += 1
    
var = sorted(var,  reverse = True )


count = 0
for j in range( K, N+1 ):
    if var[j] == 0:
        break
    
    if var[j] != 0:
        count += var[j]
        
print(count)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list( map(int, input().split() ) )

nums=[0] * 21000
var = [0] * 21000

for i in range(N):
    nums[A[i]] += 1
    var[A[i]] = 1
    
VAR = sum(var)
s_nums = sorted(nums, reverse = True)
ans = 0
# flag = 0
# for j in range(N):
if VAR <= K:
    print(0)
        
        
if VAR > K:
    for k in range(K):
        ans += s_nums[k]
    print(N - ans)
            

Fixed submission:
N, K = map(int, input().split())
A = list( map(int, input().split()) ) #ここでN個受け取る

var = [0] * (N+1)


for i in A:
    var[i] += 1
    
var = sorted(var,  reverse = True )


count = 0
for j in range( K, N+1 ):
    if var[j] == 0:
        break
    
    if var[j] != 0:
        count += var[j]
        
print(count)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list( map(int, input().split()) ) #ここでN個受け取る

flags = [0] * 21000
nums = [0] * 21000

for i in range(N):
    flags[A[i]] = 1
    nums[A[i]] += 1
    
s_nums = sorted(nums)
count = 0
ans = 0

if sum(flags) - K > 0:
    for j in range(len(s_nums)):
        if s_nums[j] != 0 and count < sum(flags)-K:
            ans += s_nums[j]
            count += 1
            
    print(ans)
    
else :
    print("0")

Fixed submission:
N, K = map(int, input().split())
A = list( map(int, input().split()) ) #ここでN個受け取る

var = [0] * (N+1)


for i in A:
    var[i] += 1
    
var = sorted(var,  reverse = True )


count = 0
for j in range( K, N+1 ):
    if var[j] == 0:
        break
    
    if var[j] != 0:
        count += var[j]
        
print(count)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list( map(int, input().split()) ) #ここでN個受け取る

flags = [0] * 21000
nums = [0] * 21000

for i in range(N):
    flags[A[i]] = 1
    nums[A[i]] += 1
    
s_nums = sorted(nums)
count = 0
ans = 0

if sum(flags) - K > 0:
    for j in range(len(s_nums)):
        if s_nums[j] != 0 and count < sum(flags)-K:
            ans += s_nums[j]
            count += 1
            
    print(ans)
    
else :
    print(0)

Fixed submission:
N, K = map(int, input().split())
A = list( map(int, input().split()) ) #ここでN個受け取る

var = [0] * (N+1)


for i in A:
    var[i] += 1
    
var = sorted(var,  reverse = True )


count = 0
for j in range( K, N+1 ):
    if var[j] == 0:
        break
    
    if var[j] != 0:
        count += var[j]
        
print(count)