Buggy python submission (verdict: Runtime Error):
import numpy as np
def solve(N, K, A):
    numbers = {}
    for a in A:
        numbers[a] = numbers.get(a, 0) + 1
    M = len(numbers)
    if M <= K:
        return 0
    dp = np.full((M+1, M+1), N, dtype=int)
    dp[0,:] = 0 
    for i, n in enumerate(numbers.values()):
        for j in range(M+1):
            if j > 0:           
                dp[i+1,j] = min(dp[i+1,j], dp[i,j-1], dp[i,j] + n)
            else:                           
                dp[i+1,j] = min(dp[i+1,j], dp[i,j] + n)
    return min(dp[M,:K+1])                          
                                                        
N, K = map(int, raw_input().split())                            
A = map(int, raw_input().split())                                           
print solve(N, K, A)  

Fixed submission:
def solve(N, K, A):
    numbers = {}
    for a in A:
        numbers[a] = numbers.get(a, 0) + 1
    if len(numbers) <= K:
        return 0
    return N - sum(sorted(numbers.values(), key=lambda x: -x)[:K])
N, K = map(int, raw_input().split())
A = map(int, raw_input().split())
print solve(N, K, A)

Buggy python submission (verdict: Runtime Error):
import numpy as np
def solve(N, K, A):
    numbers = {}
    for a in A:
        numbers[a] = numbers.get(a, 0) + 1
    M = len(numbers)
    if M <= K:
        return 0
    dp = np.full((M+1, M+1), N, dtype=in
    dp[0,:] = 0 
    for i, n in enumerate(numbers.values()):
        for j in range(M+1):
            if j > 0:           
                dp[i+1,j] = min(dp[i+1,j], dp[i,j-1], dp[i,j] + n)
            else:                           
                dp[i+1,j] = min(dp[i+1,j], dp[i,j] + n)
    return min(dp[M,:K+1])                          
                                                        
N, K = map(int, raw_input().split())                            
A = map(int, raw_input().split())                                           
print solve(N, K, A)  

Fixed submission:
def solve(N, K, A):
    numbers = {}
    for a in A:
        numbers[a] = numbers.get(a, 0) + 1
    if len(numbers) <= K:
        return 0
    return N - sum(sorted(numbers.values(), key=lambda x: -x)[:K])
N, K = map(int, raw_input().split())
A = map(int, raw_input().split())
print solve(N, K, A)

Buggy python submission (verdict: Runtime Error):
import numpy as np
def solve(N, K, A):
    numbers = {}
    for a in A:
        numbers[a] = numbers.get(a, 0) + 1
    M = len(numbers)
    if M <= K:
        return 0
    dp = np.full((M+1, M+1), N)
    dp[0,:] = 0
    for i, n in enumerate(numbers.values()):
        for j in range(M+1):
            if j > 0:
                dp[i+1,j] = min(dp[i+1,j], dp[i,j-1], dp[i,j] + n)
            else:
                dp[i+1,j] = min(dp[i+1,j], dp[i,j] + n)
    return min(dp[M,:K+1])

if __name__ == "__main__":
    N, K = map(int, raw_input().split())
    A = map(int, raw_input().split())
    print solve(N, K, A)

Fixed submission:
def solve(N, K, A):
    numbers = {}
    for a in A:
        numbers[a] = numbers.get(a, 0) + 1
    if len(numbers) <= K:
        return 0
    return N - sum(sorted(numbers.values(), key=lambda x: -x)[:K])
N, K = map(int, raw_input().split())
A = map(int, raw_input().split())
print solve(N, K, A)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N, K = map(int, raw_input().split())
A = map(int, raw_input().split())
numbers = {}
for a in A:
    numbers[a] = numbers.get(a, 0) + 1
M = len(numbers)
dp = np.full((M+1, M+1), N)
dp[0,:] = 0
for i, n in enumerate(numbers.values()):
    for j in range(M+1):
        if j > 0:
            dp[i+1,j] = min(dp[i+1,j], dp[i,j-1], dp[i,j] + n)
        else:
            dp[i+1,j] = min(dp[i+1,j], dp[i,j] + n)
print min(dp[M,:K+1])

Fixed submission:
def solve(N, K, A):
    numbers = {}
    for a in A:
        numbers[a] = numbers.get(a, 0) + 1
    if len(numbers) <= K:
        return 0
    return N - sum(sorted(numbers.values(), key=lambda x: -x)[:K])
N, K = map(int, raw_input().split())
A = map(int, raw_input().split())
print solve(N, K, A)