Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
L = list(set(a))
res = 0

for i in L:
    X = a.count(i)
    if X < i:
        res += X
    
    else:
        res += X - i

print(res)

Fixed submission:
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
L = list(set(a))
res = 0
d = Counter()
d.update(a)
for i in L:
    X = d[i]
    if X < i:
        res += X
    
    else:
        res += X - i

print(res)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
L = list(set(a))
res = 0

for i in L:
    if a.count(i) < i:
        res += a.count(i)
    
    else:
        res += a.count(i) - i

print(res)
    
  

Fixed submission:
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
L = list(set(a))
res = 0
d = Counter()
d.update(a)
for i in L:
    X = d[i]
    if X < i:
        res += X
    
    else:
        res += X - i

print(res)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
res = 0
a.sort()
k = 0
for i in range(N-1):
    if a[i] != a[i+1]:
        count = i + 1 - k
        k = count 
        
        if count < a[i]:
            res += count
        else:
            res += count - a[i]
        
for i in range(a[-1]):
    if a[-1] != a[-i]:
        res += 1
        break
        
        
print(res)
  

Fixed submission:
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
L = list(set(a))
res = 0
d = Counter()
d.update(a)
for i in L:
    X = d[i]
    if X < i:
        res += X
    
    else:
        res += X - i

print(res)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
res = 0
a.sort()

for i in range(N-1):
    if a[i] != a[i+1]:
        count = i + 1 - count 
        if count < a[i]:
            res += count
        else:
            res += count - a[i]
        
        
print(res)

Fixed submission:
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
L = list(set(a))
res = 0
d = Counter()
d.update(a)
for i in L:
    X = d[i]
    if X < i:
        res += X
    
    else:
        res += X - i

print(res)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
res = 0
a.sort()

for i in range(N-1):
    if a[i] != a[i+1]:
        count = i + 1 - count 
        if count < a[i]:
            res += count
        else:
            res += count - a[i]
        
        
print(res)

Fixed submission:
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
L = list(set(a))
res = 0
d = Counter()
d.update(a)
for i in L:
    X = d[i]
    if X < i:
        res += X
    
    else:
        res += X - i

print(res)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
res = 0
a.sort()

for i in range(N):
    X = a.count(i+1)
    if a[i] > N:
        res += 1
        
    elif X < i+1:
        res += X
        i = i  + X
        
    else:
        res += X - (i+1)
        i = i  + X
        
print(res)

Fixed submission:
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
L = list(set(a))
res = 0
d = Counter()
d.update(a)
for i in L:
    X = d[i]
    if X < i:
        res += X
    
    else:
        res += X - i

print(res)