Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())
a = [[] for _ in range(m)]

count = 1
for i in range(m):
    p,y = map(int, input().split())
    a[p-1].append([y, count])
    count += 1
b = []
for i,j in enumerate(a):
    j_sort = sorted(j)
    for k,l in enumerate(j_sort):
        b.append([l[1],str(i+1).zfill(6)+str(k+1).zfill(6)])
        
for i in sorted(b):
    print(i[1])

Fixed submission:
n, m = map(int, input().split())
D = [[] for _ in range(n)]
for i in range(m):
    p,y = map(int, input().split())
    D[p-1].append((y,i))
ans = [None] * m
for i,d in enumerate(D):
    d.sort()
    for j, (k,l) in enumerate(d):
        ans[l] = str(i+1).zfill(6) + str(j+1).zfill(6)
for i in ans:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
py = []
for i in range(m):
    py.append(list(map(int, input().split())))
check = [[] for i in range(n)]
for i in py:
    check[i[0]-1].append(i[1])
for i in range(len(check)):
    check[i] = sorted(check[i])
for i in py:
    x = (check[i[0]-1].index(i[1]) + 1)
    ans = str(i[0]).zfill(6) + str(x).zfill(6)
    print(ans)

Fixed submission:
n, m = map(int, input().split())
D = [[] for _ in range(n)]
for i in range(m):
    p,y = map(int, input().split())
    D[p-1].append((y,i))
ans = [None] * m
for i,d in enumerate(D):
    d.sort()
    for j, (k,l) in enumerate(d):
        ans[l] = str(i+1).zfill(6) + str(j+1).zfill(6)
for i in ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = []
y = []
h = []
for i in range(n):
    a,b,c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)
kk = h.index(max(h))
for i in range(101):
    for j in range(101):
        H = h[kk] + abs(x[k] - i) + abs(y[k] - j)
        for k in range(n):
            if h[k] > 0:
                if H != abs(x[k]-i)+abs(y[k]-j)+h[k]:
                    H = -1
            if h[k] == 0:
                if H > abs(x[k] - i) + abs(y[k] - j):
                    H = -1
        if H != -1:
            print(i, j, H)

Fixed submission:
n = int(input())
x = []
y = []
h = []
for i in range(n):
    a,b,c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)
kk = h.index(max(h))
for i in range(101):
    for j in range(101):
        H = h[kk] + abs(x[kk] - i) + abs(y[kk] - j)
        for k in range(n):
            if h[k] > 0:
                if H != abs(x[k]-i)+abs(y[k]-j)+h[k]:
                    H = -1
            if h[k] == 0:
                if H > abs(x[k] - i) + abs(y[k] - j):
                    H = -1
        if H != -1:
            print(i, j, H)
Buggy python submission (verdict: Runtime Error):
n = int(input())
v = [int(i) for i in input().split()] 

from statistics import mode
if len(set(v))  == 1:
    print(int(len(v) / 2))
else:
    print(len(v[0::2]) - collections.Counter(v[0::2]).most_common()[0][1] + len(v[1::2]) - collections.Counter(v[1::2]).most_common()[0][1])

Fixed submission:
n = int(input())
v = [int(i) for i in input().split()] 
import collections
if len(set(v))  == 1:
    print(int(len(v) / 2))
else:
    a = collections.Counter(v[0::2]).most_common()
    b = collections.Counter(v[1::2]).most_common() 
    if a[0][0] == b[0][0]:
        print(min((len(v[0::2]) - a[1][1] + len(v[1::2]) - b[0][1]),(len(v[0::2]) - a[0][1] + len(v[1::2]) - b[1][1])))
    else:
        print(len(v[0::2]) - a[0][1] + len(v[1::2]) - b[0][1])

Buggy python submission (verdict: Runtime Error):
n = int(input())
v = [int(i) for i in input().split()] 

from statistics import mode
if len(set(v))  == 1:
    print(int(len(v) / 2))
else:
    print(len(v[0::2]) - collections.Counter(v[0::2]).most_common()[0][1] + len(v[1::2]) - collections.Counter(v[1::2]).most_common()[0][1])

Fixed submission:
n = int(input())
v = [int(i) for i in input().split()] 
import collections
if len(set(v))  == 1:
    print(int(len(v) / 2))
else:
    a = collections.Counter(v[0::2]).most_common()
    b = collections.Counter(v[1::2]).most_common() 
    if a[0][0] == b[0][0]:
        print(min((len(v[0::2]) - a[1][1] + len(v[1::2]) - b[0][1]),(len(v[0::2]) - a[0][1] + len(v[1::2]) - b[1][1])))
    else:
        print(len(v[0::2]) - a[0][1] + len(v[1::2]) - b[0][1])
Buggy python submission (verdict: Time Limit Exceeded):
s = list(str(input()))
t = list(str(input()))
for i in range(len(s)):
    if s[i] != t[i]:
        c1 = s[i]
        c2 = t[i]
        for j in range(len(s)):
            if s[j] == c1:
                s[j] = c2
            else:
                if s[j] == c2:
                    s[j] = c1
if s == t:
    print('Yes')
else:
    print('No')

Fixed submission:
s = str(input())
t = str(input())

import collections
s_count = collections.Counter(s)
t_count = collections.Counter(t)

if sorted(s_count.values()) == sorted(t_count.values()):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n,x = map(int,input().split())
x_list = list(map(int,input().split()))
x_list.append(x)
x_list = sorted(x_list)
a = []
for i in range(n):
    b = x_list[i+1]-x_list[i]
    a.append(b)
import math
from functools import reduce
ans = reduce(math.gcd, a)
print(int(ans))

Fixed submission:
n,x = map(int,input().split())
x_list = list(map(int,input().split()))
x_list.append(x)
x_list = sorted(x_list)
a = []
for i in range(n):
    b = x_list[i+1]-x_list[i]
    a.append(b)
import math
from functools import reduce
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
ans = reduce(gcd, a)
print(int(ans))

Buggy python submission (verdict: Runtime Error):
n,x = map(int,input().split())
x_list = list(map(int,input().split()))
x_list.append(x)
x_list = sorted(x_list)
a = []
for i in range(n):
    b = x_list[i+1]-x_list[i]
    a.append(b)
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
ans = gcd(*a)
print(int(ans))

Fixed submission:
n,x = map(int,input().split())
x_list = list(map(int,input().split()))
x_list.append(x)
x_list = sorted(x_list)
a = []
for i in range(n):
    b = x_list[i+1]-x_list[i]
    a.append(b)
import math
from functools import reduce
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
ans = reduce(gcd, a)
print(int(ans))

Buggy python submission (verdict: Runtime Error):
n,x = map(int,input().split())
x_list = list(map(int,input().split()))
import math
import functools
x_list.append(x)
x_list = sorted(x_list)
a = []
for i in range(n):
    b = x_list[i+1]-x_list[i]
    a.append(b)
gcd = functools.reduce(math.gcd,a)
print(gcd)

Fixed submission:
n,x = map(int,input().split())
x_list = list(map(int,input().split()))
x_list.append(x)
x_list = sorted(x_list)
a = []
for i in range(n):
    b = x_list[i+1]-x_list[i]
    a.append(b)
import math
from functools import reduce
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
ans = reduce(gcd, a)
print(int(ans))

Buggy python submission (verdict: Runtime Error):
n,x = map(int,input().split())
x_list = list(map(int,input().split()))
x_list.append(x)
x_list = sorted(x_list)
a = []
for i in range(n):
    a.append(x_list[i+1]-x_list[i])
import math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
print(gcd_list(a))

Fixed submission:
n,x = map(int,input().split())
x_list = list(map(int,input().split()))
x_list.append(x)
x_list = sorted(x_list)
a = []
for i in range(n):
    b = x_list[i+1]-x_list[i]
    a.append(b)
import math
from functools import reduce
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
ans = reduce(gcd, a)
print(int(ans))
Buggy python submission (verdict: Runtime Error):
s = str(input())
s_list = list(s)
ans_1 = 'no'
ans_2 = 'no'
s_list_len = len(s_list)
if s_list[0] == 'A':
    ans_1 = 'ok'
count = 0
for i,j in enumerate(s_list[2:s_list_len-1]):
    if j == 'C':
        s_list.pop(2+i)
        count += 1
if count == 1:
    ans_2 = 'ok'
ans_3 = 'ok'
for i in s_list[1:]:
    if not i.islower():
        ans_3 = 'no'
if (ans_1 == 'ok') and (ans_2 == 'ok') and (ans_3 == 'ok'):
    print('AC')
else:
    print('WA')

Fixed submission:
s = str(input())
s_list = list(s)
ans_1 = 'no'
ans_2 = 'no'
ans_3 = 'ok'
check = 'no'
s_list_len = len(s_list)
if s_list[0] == 'A':
    ans_1 = 'ok'
count = 0
for i,j in enumerate(s_list[2:s_list_len-1]):
    if j == 'C':
        count += 1
        if check == 'no':
            s_list.pop(2+i)
        check = 'yes'
if count == 1:
    ans_2 = 'ok'
for i in s_list[1:]:
    if not i.islower():
        ans_3 = 'no'
if (ans_1 == 'ok') and (ans_2 == 'ok') and (ans_3 == 'ok'):
    print('AC')
else:
    print('WA')
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a <= 8 and b <= 8:
    print('Yay!')
else:
    print(':(')

Fixed submission:
a,b = map(int,input().split())
if a <= 8 and b <= 8:
    print('Yay!')
else:
    print(':(')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]

count = 0
check = True
while check:
    a = sorted(list(filter(lambda x : (x % 2) == 0, a)), reverse=True)
    if a == []:
        check = False
    else:
        a[0] = int(a[0] / 2)
        for i in range(1,len(a)):
            a[i] *= 3
        count += 1
print(count)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
count = 0
for i in a:
    while i % 2 == 0:
        i /= 2
        count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())

max_range = 10 ** 5
dp = [int(i) for i in range(max_range + 1)]

for i in [6,9]:
    check = i
    while check < max_range:
        for j in range(max_range + 1):
            if j - check >= 0:
                dp[j] = min(dp[j],dp[j-check] + 1)

        check =  check *
        
print(dp[n])

Fixed submission:
n = int(input())
max_n = 10 ** 5

dp = [int(i) for i in range(max_n + 1)]

for i in (6,9):
    v = i
    while v < max_n:
        for j in range(len(dp)):
            if j + v < max_n+1:
                dp[j+v] = min(dp[j+v],dp[j]+1)
        v *= i
        
print(dp[n])
Buggy python submission (verdict: Runtime Error):
h,w = map(int, input().split())
s = []
for i in range(w):
    s.append(str(input()))
    
flag = True
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            check = False
            if i+1 < h:
                if s[i+1][j] == '#':
                    check = True
            if j+1 < w:
                if s[i][j+1] == '#':
                    check = True
            if i-1 >= 0:
                if s[i-1][j] == '#':
                    check = True
            if j-1 >= 0:
                if s[i][j-1] == '#':
                    check = True
            if check == False:
                flag = False
if flag:
    print('Yes')
else:
    print('No')

Fixed submission:
H, W = map(int, input().split())
Sij = []
for _ in range(H):
    Sij.append(input())
result = []
for a in range(H):
    for b in range(W):
        check = []    
        if Sij[a][b] == '#':
            if a-1 >= 0:
                H_up = a - 1
                S_H_up = Sij[H_up][b]
                check.append(S_H_up)
            if a+1 <= H-1:
                H_down = a + 1
                S_H_down = Sij[H_down][b]
                check.append(S_H_down)
            if b-1 >= 0:
                W_right = b - 1
                S_W_right = Sij[a][W_right]
                check.append(S_W_right)
            if b+1 <= W-1: 
                W_left = b + 1
                S_W_left = Sij[a][W_left]
                check.append(S_W_left)
            if '#' in check:
                result.append('good')
            else:
                result.append('bad')
                
if 'bad' in result:
    print('No')
else:
    print('Yes')
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = [int(i) for i in input().split()]



a = statistics.median(sorted(x)[0:len(x)-1])
b = statistics.median(sorted(x)[1:len(x)])
for i in x:
    if i > a:
        print(a)
    else:
        print(b)

Fixed submission:
n = int(input())
xm = list(map(int, input().split()))
xm_sort = sorted(xm)
a = n//2-1
for i in range(n):
    if xm[i]<=xm_sort[a]:
        print(xm_sort[a+1])
    else:
        print(xm_sort[a])

Buggy python submission (verdict: Runtime Error):
n = int(input())
x = [int(i) for i in input().split()]

for i in x:
    if i > statistics.median(sorted(x)[0:len(x)-1]):
        print(statistics.median(sorted(x)[0:len(x)-1]))
    else:
        print(statistics.median(sorted(x)[1:len(x)]))

Fixed submission:
n = int(input())
xm = list(map(int, input().split()))
xm_sort = sorted(xm)
a = n//2-1
for i in range(n):
    if xm[i]<=xm_sort[a]:
        print(xm_sort[a+1])
    else:
        print(xm_sort[a])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = [int(i) for i in input().split()]

import statistics
for i in range(len(x)):
    print(statistics.median(x[0:i] + x[i+1:len(x)]))

Fixed submission:
n = int(input())
xm = list(map(int, input().split()))
xm_sort = sorted(xm)
a = n//2-1
for i in range(n):
    if xm[i]<=xm_sort[a]:
        print(xm_sort[a+1])
    else:
        print(xm_sort[a])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
Xn = list(map(int,input().split()))
import numpy as np

for i in range(N):
    Xn_numpy = np.array(Xn)
    Xn_deleted = np.delete(Xn_numpy, i)
    Xn_sort = np.sort(Xn_deleted)[::-1]
    a = (len(Xn_sort)+1)//2-1
    print(Xn_sort[a])

Fixed submission:
n = int(input())
xm = list(map(int, input().split()))
xm_sort = sorted(xm)
a = n//2-1
for i in range(n):
    if xm[i]<=xm_sort[a]:
        print(xm_sort[a+1])
    else:
        print(xm_sort[a])
Buggy python submission (verdict: Runtime Error):
a,b,k = map(int, input().split())
x = list(range(a,b+1))
y = x[0:k]
z = x[len(x)-k:len(x)]
a = []
for i in range(len(y)):
    a.append(y[i])
for i in range(len(z)):
    a.append(z[i])
a_uniq = []
for i in a:
    if i not in a_uniq:
        a_uniq.append(i)
for i in range(len(a_uniq)):
    print(a_uniq[i])

Fixed submission:
a, b, k = map(int, input().split())
if b - a + 1 <= 2 * k:
    result = ([i for i in range(a, b + 1)])
else:
    result = ([i for i in range(a, a + k)] + [i for i in range(b - k + 1, b + 1)])
for i in result:
    print(i)

Buggy python submission (verdict: Runtime Error):
a,b,k = map(int, input().split())
x = list(range(a,b+1))
y = x[0:k]
z = x[len(x)-k:len(x)]
a = []
for i in range(len(y)):
    a.append(y[i])
for i in range(len(z)):
    a.append(z[i])
a_uniq = []
for i in a:
    if i not in a_uniq:
        a_uniq.append(i)
for i in range(len(a_uniq)):
    print(a_uniq[i])

Fixed submission:
a, b, k = map(int, input().split())
if b - a + 1 <= 2 * k:
    result = ([i for i in range(a, b + 1)])
else:
    result = ([i for i in range(a, a + k)] + [i for i in range(b - k + 1, b + 1)])
for i in result:
    print(i)

Buggy python submission (verdict: Runtime Error):
a,b,k = map(int, input().split())
x = list(range(a,b+1))
y = x[0:k]
z = x[len(x)-k:len(x)]
a = []
for i in range(len(y)):
    a.append(y[i])
for i in range(len(z)):
    a.append(z[i])
a_uniq = []
for i in a:
    if i not in a_uniq:
        a_uniq.append(i)
for i in range(len(a_uniq)):
    print(a_uniq[i])

Fixed submission:
a, b, k = map(int, input().split())
if b - a + 1 <= 2 * k:
    result = ([i for i in range(a, b + 1)])
else:
    result = ([i for i in range(a, a + k)] + [i for i in range(b - k + 1, b + 1)])
for i in result:
    print(i)
Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
e = min([a,b])
f = min([c,d])
print(e+f)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = min([a,b]) + min([c,d])
print(e)

Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
e = min([a,b])
f = min([c,d])
print(e+f)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = min([a,b]) + min([c,d])
print(e)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]

for i in range(len(a)):
    a_pop = [0] + a[0:i] + a[i+1:len(a)] + [0]
    ans = 0
    for i in range(len(a_pop)-1):
        ans += abs(a_pop[i+1] - a_pop[i])
    print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
total = abs(a[0]) + abs(a[n-1])
for i in range(n-1):
    total += abs(a[i+1] - a[i])
a.insert(0,0)
a.insert(n+1,0)
ans=[]
for i in range(1,n+1):
    if a[i-1]<=a[i]<=a[i+1] or a[i-1]>=a[i]>=a[i+1]:
        ans.append(total)
    else:
        change = total + abs(a[i+1]-a[i-1]) -(abs(a[i]-a[i-1])+abs(a[i+1]-a[i]))
        ans.append(change)
for i in range(n):
    print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
result_1 = []
result_1.append(abs(a[0]))
for i in range(n-1):
    result_1.append(abs(a[i+1]-a[i]))
result_1.append(abs(a[n-1]))
a.insert(0,0)
a.insert(n+1,0)
for i in range(n):
    if a[i+2] >= a[i+1] >= a[i]:
        print(sum(result_1))
    elif a[i+2] <= a[i+1] <= a[i]:
        print(sum(result_1))
    else:
        b = abs(a[i+2]-a[i+1])
        c = abs(a[i+1]-a[i])
        d = abs(a[i+2]-a[i])
        result = sum(result_1) - (b + c - d)
        print(result)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
total = abs(a[0]) + abs(a[n-1])
for i in range(n-1):
    total += abs(a[i+1] - a[i])
a.insert(0,0)
a.insert(n+1,0)
ans=[]
for i in range(1,n+1):
    if a[i-1]<=a[i]<=a[i+1] or a[i-1]>=a[i]>=a[i+1]:
        ans.append(total)
    else:
        change = total + abs(a[i+1]-a[i-1]) -(abs(a[i]-a[i-1])+abs(a[i+1]-a[i]))
        ans.append(change)
for i in range(n):
    print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
result_1 = []
result_1.append(abs(a[0]))
for i in range(n-1):
    result_1.append(abs(a[i+1]-a[i]))
result_1.append(abs(a[n-1]))
a.insert(0,0)
a.insert(n+1,0)
for i in range(n):
    b = abs(a[i+2]-a[i+1])
    c = abs(a[i+1]-a[i])
    d = abs(a[i+2]-a[i])
    result = sum(result_1) - (b + c - d)
    print(result)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
total = abs(a[0]) + abs(a[n-1])
for i in range(n-1):
    total += abs(a[i+1] - a[i])
a.insert(0,0)
a.insert(n+1,0)
ans=[]
for i in range(1,n+1):
    if a[i-1]<=a[i]<=a[i+1] or a[i-1]>=a[i]>=a[i+1]:
        ans.append(total)
    else:
        change = total + abs(a[i+1]-a[i-1]) -(abs(a[i]-a[i-1])+abs(a[i+1]-a[i]))
        ans.append(change)
for i in range(n):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for i in range(n):
    s.append(str(input()))
for i,j in enumerate(s):
    if j[0] != 'M' and j[0] != 'A' and j[0] != 'R' and j[0] != 'C' and j[0] != 'H':
        s.pop(i)
import itertools
count = 0
for i in itertools.combinations(s, 3):
    check = []
    for j in i:
        check.append(j[0])
    if len(list(set(check))) == 3:
        count += 1
print(count)

Fixed submission:
n = int(input())
s = []
for i in range(n):
    s.append(str(input()))
count = [0] * 5
for i,j in enumerate(s):
    if j[0] == 'M':
        count[0] += 1
    if j[0] == 'A':
        count[1] += 1
    if j[0] == 'R':
        count[2] += 1
    if j[0] == 'C':
        count[3] += 1
    if j[0] == 'H':
        count[4] += 1
import itertools
ans = 0
for i in itertools.combinations(count, 3):
    ans += i[0] * i[1] * i[2]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]
ans = 0
for i in set(a):
    if a.count(i) - i < 0:
        ans += a.count(i)
    else:
        ans += a.count(i) - i
print(ans)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()] 
count = {}
ans = 0
for i in a:
    if i not in count:
        count[i] = 1
    else:
        count[i] += 1
for i,c in count.items():
    if i > c:
        ans += c
    elif i < c:
        ans += c - i
print(ans)

Buggy python submission (verdict: Runtime Error):
    n = int(input())
    a = [int(i) for i in input().split()] 
    count = {}
    ans = 0
    for i in a:
        if i not in count:
            count[i] = 1
        else:
            count[i] += 1
    for i,c in count.items():
        if i > c:
            ans += c
        elif i < c:
            ans += c - i
    print(ans)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()] 
count = {}
ans = 0
for i in a:
    if i not in count:
        count[i] = 1
    else:
        count[i] += 1
for i,c in count.items():
    if i > c:
        ans += c
    elif i < c:
        ans += c - i
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()] 
a_unique = list(set(a))
count = 0
for i in a_unique:
    check = i - a.count(i)
    if check < 0:
        count += abs(check)
    elif check > 0:
        count += i - check
print(count)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()] 
count = {}
ans = 0
for i in a:
    if i not in count:
        count[i] = 1
    else:
        count[i] += 1
for i,c in count.items():
    if i > c:
        ans += c
    elif i < c:
        ans += c - i
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()] 
count = 0
for i in range(100000):
    if a.count(i) > 0:
        check = i - a.count(i)
        if check < 0:
            count += abs(check)
        elif check > 0:
            count += i - check
for i in a:
    if i > 100000:
        count += 1
print(count)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()] 
count = {}
ans = 0
for i in a:
    if i not in count:
        count[i] = 1
    else:
        count[i] += 1
for i,c in count.items():
    if i > c:
        ans += c
    elif i < c:
        ans += c - i
print(ans)