Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math
def f(a, n):
    b = sum(a) / n
    b2 = (1+n) / 2 
    
    res = []
    for x in [b, b2, b-b2, b2-b, ceil(b), ceil(b2), floor(b), floor(b2), ceil(b-b2), ceil(b2 - b), floor(b-b2), floor(b2-b)]:
        s = (int(x+i) for i in range(1, n+1))
        sadness = sum(abs(ai - xi) for (ai, xi) in zip(a, s))
        res.append(sadness)
        
    return min(res)
    
n = int(input())
a = [int(i) for i in input().split()]
print(f(a, n))


Fixed submission:
import statistics

def f(a, n):
    a2 = [ai - (i+1) for (i,ai) in enumerate(a)]
    b = int(statistics.median(a2))
    
    sadness = sum(abs(ai - b) for ai in a2)
    
    b += 1
    sadness2 = sum(abs(ai - b) for ai in a2)

    
    return min(sadness, sadness2)
    
n = int(input())
a = [int(i) for i in input().split()]
print(f(a, n))

Buggy python submission (verdict: Runtime Error):
import math
def f(a, n):
    b = sum(a) / n
    b2 = (1+n) / 2 
    
    res = []
    for x in [b, b2, b-b2, b2-b, ceil(b), ceil(b2), floor(b), floor(b2), ceil(b-b2), ceil(b2 - b), floor(b-b2), floor(b2-b)]:
        s = (x+i for i in range(1, n+1))
        sadness = sum(abs(ai - xi) for (ai, xi) in zip(a, s))
        res.append(sadness)
        
    return min(res)
    
n = int(input())
a = [int(i) for i in input().split()]
print(f(a, n))


Fixed submission:
import statistics

def f(a, n):
    a2 = [ai - (i+1) for (i,ai) in enumerate(a)]
    b = int(statistics.median(a2))
    
    sadness = sum(abs(ai - b) for ai in a2)
    
    b += 1
    sadness2 = sum(abs(ai - b) for ai in a2)

    
    return min(sadness, sadness2)
    
n = int(input())
a = [int(i) for i in input().split()]
print(f(a, n))

Buggy python submission (verdict: Runtime Error):
import math

def f(a, n):
    res = math.inf
    for b in range(-n-1, n+1):
        s = (b+i for i in range(1, n+1))
        sadness = sum(abs(ai - xi) for (ai, xi) in zip(a, s))
        res = min(res, sadness)
    
    return res
    
n = int(input())
a = [int(i) for i in input().split()]
print(f(a, n))


Fixed submission:
import statistics

def f(a, n):
    a2 = [ai - (i+1) for (i,ai) in enumerate(a)]
    b = int(statistics.median(a2))
    
    sadness = sum(abs(ai - b) for ai in a2)
    
    b += 1
    sadness2 = sum(abs(ai - b) for ai in a2)

    
    return min(sadness, sadness2)
    
n = int(input())
a = [int(i) for i in input().split()]
print(f(a, n))
Buggy python submission (verdict: Runtime Error):
blue = []
red = []
N = int(input())
for card in range(N):
    blue.append(input())
M = int(input())
for card in range(M):
    red.append(input())

s = input()
prize = blue.count(s) - red.count(s)
print(prize)

Fixed submission:
blue = []
red = []
N = int(input())
for card in range(N):
    blue.append(input())
M = int(input())
for card in range(M):
    red.append(input())

max = 0
for b in blue:
    if max < blue.count(b) - red.count(b):
        max = blue.count(b) - red.count(b)
        
print(max)

Buggy python submission (verdict: Runtime Error):
blue = []
red = []
N = int(input())
for card in range(N):
    blue.append(input())
M = int(input())
for card in range(M):
    red.append(input())

s = input()
prize = blue.count(s) - red.count(s)
print(prize)

Fixed submission:
blue = []
red = []
N = int(input())
for card in range(N):
    blue.append(input())
M = int(input())
for card in range(M):
    red.append(input())

max = 0
for b in blue:
    if max < blue.count(b) - red.count(b):
        max = blue.count(b) - red.count(b)
        
print(max)

Buggy python submission (verdict: Runtime Error):
blue = []
red = []
N = int(input())
for card in range(N):
    blue.append(input())
M = int(input())
for card in range(M):
    red.append(input())

prize = 0
s = input()
for n in blue:
    if s == n:
        prize +=1
for m in red:
    if s == m:
        prize -=1
print(prize)

Fixed submission:
blue = []
red = []
N = int(input())
for card in range(N):
    blue.append(input())
M = int(input())
for card in range(M):
    red.append(input())

max = 0
for b in blue:
    if max < blue.count(b) - red.count(b):
        max = blue.count(b) - red.count(b)
        
print(max)
Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().split())

if N == 1 or M == 1:    
    if N+M == 2:
        print(1)
    else:
        print(max(N,M)-2)

elif N == 2 or M == 2:
    print(0)
    
else:
    print(N*M - ((N-2)*2+(M-2)*2+4))

Fixed submission:
a = list(input())
b = list(input())
c = list(input())
print(a[0]+b[1]+c[2])
Buggy python submission (verdict: Runtime Error):
import numpy as np
N,M = map(int, input().split())
bord = np.zeros((N, M))

if N < 3 or M < 3:
    for n in range(N):
        for m in range(M):
            if n < 1 and m < 1:
                bord[0:n+2,0:m+2] += 1
            elif n < 1:
                bord[0:n+2,m-1:m+2] += 1
            elif m < 1:
                bord[n-1:n+2,0:m+2] += 1
            else:
                bord[n-1:n+2,m-1:m+2] += 1
    bord = bord % 2

#     print(bord)
    print(int(np.sum(bord)))
else:
    print(N*M - ((N-2)*2+(M-2)*2+4))
    


Fixed submission:
N,M = map(int, input().split())

if N == 1 or M == 1:    
    if N+M == 2:
        print(1)
    else:
        print(max(N,M)-2)

elif N == 2 or M == 2:
    print(0)
    
else:
    print(N*M - ((N-2)*2+(M-2)*2+4))

Buggy python submission (verdict: Runtime Error):
import numpy as np
N,M = map(int, input().split())
bord = np.zeros((N, M))

for n in range(N):
    for m in range(M):
#         print(n,m)
        if n < 1 and m < 1:
            bord[0:n+2,0:m+2] += 1
        elif n < 1:
            bord[0:n+2,m-1:m+2] += 1
        elif m < 1:
            bord[n-1:n+2,0:m+2] += 1
        else:
            bord[n-1:n+2,m-1:m+2] += 1
#         print(bord)
#         print('-'*10)

# for n in range(N):
#     for m in range(M):
# #         print(n,m)
#         if n < 1 and m < 1 or n == N-1 and m == M-1 or n < 1 and m == M-1 or m < 1 and n == N-1:
#             bord[n,m] = 4
#         elif n < 1 or n == N-1:
#             bord[n,m] = 6
#         elif m < 1 or m == M-1:
#             bord[n,m] = 6
#         else:
#             bord[n,m] = 1
    
bord = bord % 2

# print(bord)
print(int(np.sum(bord)))

Fixed submission:
N,M = map(int, input().split())

if N == 1 or M == 1:    
    if N+M == 2:
        print(1)
    else:
        print(max(N,M)-2)

elif N == 2 or M == 2:
    print(0)
    
else:
    print(N*M - ((N-2)*2+(M-2)*2+4))
Buggy python submission (verdict: Runtime Error):
    grid = [list(map(int,input().split(' ')))]
    grid.append(list(map(int,input().split(' '))))
    grid.append(list(map(int,input().split(' '))))
     
    flg =False
    for i in range(100):
        b0,b1,b2  = grid[0][0]-i,grid[0][1]-i,grid[0][2]-i
        a1,a2 = grid[1][0]-b0,grid[2][0]-b0
        if grid[1][1] == a1+b1 and grid[1][2] == a1+b2 and grid[2][1] == a2+b1 and grid[2][2] == a2+b2:
            flg =True
            break
        if min([b0,b1,b2]) < 0:
            break
        
    if flg:
        print('Yes')
        

Fixed submission:
grid = [list(map(int,input().split(' ')))]
grid.append(list(map(int,input().split(' '))))
grid.append(list(map(int,input().split(' '))))

flg =False
for i in range(100):
    b0,b1,b2  = grid[0][0]-i,grid[0][1]-i,grid[0][2]-i
    a1,a2 = grid[1][0]-b0,grid[2][0]-b0
    if grid[1][1] == a1+b1 and grid[1][2] == a1+b2 and grid[2][1] == a2+b1 and grid[2][2] == a2+b2:
        if grid[0][0] == i+b0 and grid[0][1] == i+b1 and grid[0][2] == i+b2 and grid[1][0] == a1+b0 and grid[2][0] == a2+b0:
            flg =True
            break
    if min([b0,b1,b2]) < 0:
        break
    
if flg:
    print('Yes')
    
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))

def res(b):
    return np.sum(np.abs(A-(b+np.array(range(1, N+1)))))

tmp = np.sum(A) // N
a = []
for i in range(tmp-100, tmp+100):
    a.append(res(i))
print(min(a))


Fixed submission:
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
A -= np.arange(1,N+1)

def sad(b):
    return int(np.sum(np.abs(A - b)))

l = -1e10
r =  5e10
m = 2e30
tmp = 5e30
tmp2 = 1e30
while tmp2 != sad(m):
    if tmp > sad(m):
        tmp = sad(m)
    tmp2 = sad(m)
    m = (l + r) // 2
    if sad(m) - sad(m+1) >= 0:
        l = m
    else:
        r = m

print(tmp)
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: Time Limit Exceeded):
import itertools
N, M = map(int, input().split())
x = [0]*N
y = [0]*N
z = [0]*N
for i in range(N):
    x[i], y[i], z[i] = map(int, input().split())

a = list(itertools.combinations(range(N), M))

sumabs = []
for i in a:
    sumtmp = [0, 0, 0]
    for j in i:
        sumtmp[0] += x[j]
        sumtmp[1] += y[j]
        sumtmp[2] += z[j]
    sumabs.append(sum(list(map(abs, sumtmp))))

print(max(sumabs))


Fixed submission:
import numpy as np
N, M = map(int, input().split())
x = [0]*N
y = [0]*N
z = [0]*N
for i in range(N):
    x[i], y[i], z[i] = map(int, input().split())
x = np.array(x)
y = np.array(y)
z = np.array(z)


r = np.zeros((N,8))
r[:,0] =  x[:] +y[:] +z[:]
r[:,1] =  x[:] -y[:] +z[:]
r[:,2] =  x[:] +y[:] -z[:]
r[:,3] =  x[:] -y[:] -z[:]
r[:,4] = -x[:] +y[:] +z[:]
r[:,5] = -x[:] -y[:] +z[:]
r[:,6] = -x[:] +y[:] -z[:]
r[:,7] = -x[:] -y[:] -z[:]

print(int(max(np.sum(np.sort(r, axis=0)[::-1][:M,:],axis=0))))
Buggy python submission (verdict: Runtime Error):
s=input()
w=int(input())
a=''
for i in range(0,len(s)//w+1):
    a+=s[w*i]
print(a)


Fixed submission:
s=input()
w=int(input())
a=''
for i in range(0,(len(s)-1)//w+1):
    a+=s[w*i]
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
a=[s[:i].count('W')+s[i+1:].count('E') for i in range(n)]
print(min(a))

Fixed submission:
n=int(input())
s=input()
w,e=0,s.count('E')
for i in s:
    if i =='W':
        n=min(n,w+e)
        w+=1
    else:
        e-=1
        n=min(n,w+e)
print(n)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
a=[]
for i in range(n):
    a.append(s[:i].count('W')+s[i+1:].count('E'))
print(min(a))

Fixed submission:
n=int(input())
s=input()
w,e=0,s.count('E')
for i in s:
    if i =='W':
        n=min(n,w+e)
        w+=1
    else:
        e-=1
        n=min(n,w+e)
print(n)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
prime=[]
tmp = 2
for i in range(2, 55555):
    if prime:
        for j in range(len(prime)):
            if i % prime[j] == 0:
                break
            else:
                if j == len(prime) - 1:
                    prime.append(i)
    else:
        if n > tmp:
            prime.append(i)
print(prime[0:n])


Fixed submission:
n = int(input())
ans=[]
def sosu(x):
    for i in range(2,x):
        if x % i ==0:
            return False
    return True

for i in range(11,55555,5):
    if sosu(i) and i % 5 ==1:
        ans.append(i)
        if len(ans) >= n:
            break

print(' '.join([str(s) for s in ans]))
Buggy python submission (verdict: Runtime Error):
n=int(input())
c=list(map(int, input().split()))
c.sort(reverse=True)
a=0
b=0
for i in range(n):
    if i%2==0:
        a=a+c[i]
    else:
        b=b+c[i]
print(a-b)

Fixed submission:
num=int(input())
a=int(input())

b=num%500
if b>a:
    print("No")
else:
    print("Yes")

Buggy python submission (verdict: Runtime Error):
n=int(input())
c=list(map(int, input().split()))
c.sort(reverse=True)
a=0
b=0
for i in range(n):
    if i%2==0:
        a=a+c[i]
    else:
        b=b+c[i]
print(a-b)

Fixed submission:
num=int(input())
a=int(input())

b=num%500
if b>a:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
  n=int(input())
s=input()
x=ans=0
for i in range(n):
    if s[i]=='I':
        x=x+1
    elif s[i]=='D':
        x=x-1
    ans=max(ans,x)
print(ans)

Fixed submission:
n=int(input())
s=input()
x=ans=0
for i in range(n):
    if s[i]=='I':
        x=x+1
    elif s[i]=='D':
        x=x-1
    ans=max(ans,x)
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
t=list(map(int,input().split()))
m=int(input())
for i in range(m):
    p,x=map(int,input().split())
    print(sum(t)-t[i]+x)

Fixed submission:
n=int(input())
t=list(map(int,input().split()))
m=int(input())
for i in range(m):
    p,x=map(int,input().split())
    print(sum(t)-t[p-1]+x)
Buggy python submission (verdict: Runtime Error):
a=''
for i in input():
    if i=='B':
        a=a[:-1]
    else:
        a+=x
print(a)

Fixed submission:
a=''
for i in input():
    if i=='B':
        a=a[:-1]
    else:
        a+=i
print(a)
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):
d, n = map(int, input().split())

ans = []
if d == 0:
    x = 1
    while True:
        if x % 100 != 0 and x % 10000 != 0:
            ans.append(x)
        x += 1
        if len(ans) == n:
            break
elif d == 1:
    x = 100
    while True:
        if x % 10000 != 0:
            ans.append(x)
        x += 100
        if len(ans) == n:
            break
else:
    x = 10000
    while True:
       if x % 100000000 != 0:
       ans.append(x)
        x += 10000
        if len(ans) == n:
            break

print(ans[-1])

Fixed submission:
d, n = map(int, input().split())

if n == 100:
    print(101 * (100**d))
else:
    print(n * (100**d))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = list(map(int, input().split()))

tmp = 1
m = 0
for ai in a_list:
    if ai % 2 == 0:
        tmp *= ai
        m += 1

ans = 0
while True:
    if tmp % (2**m) == 0:
        tmp //= (2**m)
        ans += m
    else:
        break

for i in range(1, m+1):
    if tmp % 2 == 0:
        tmp //= 2
        ans += 1

print(ans)


Fixed submission:
n = int(input())
a_list = list(map(int, input().split()))

ans = 0
for i in range(1, 100):
    s = len([x for x in a_list if x % (2**i) == 0])
    if s == 0:
        break
    ans += s

print(ans)
Buggy python submission (verdict: Runtime Error):
S = raw_input();
S = S.replace(",", " ");
print(S);

Fixed submission:
S = input();
S = S.replace(",", " ");
print(S);
Buggy python submission (verdict: Time Limit Exceeded):
n, m, d = list(map(int, input().split()))

s = 1 if d == 0 else 2
ans = (n - d) * s * (n)**(m - 2) * (m - 1) / n**m
print(ans)


Fixed submission:
n, m, d = list(map(int, input().split()))

s = 1 if d == 0 else 2
# ans = (n - d) * s * (n)**(m - 2) * (m - 1) / n**m
ans = (n - d) * s * (m - 1) / n**2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

ans1 = max(a)

flag = True
if ans1 % 2 == 1:
    s1 = ans1 // 2
    s2 = ans1 // 2 + 1
else:
    if ans1 // 2 in a:
        flag = False
        ans2 = ans1 // 2
    else:
        s1 = ans1 // 2 - 1
        s2 = ans1 // 2 + 1

while flag:
    if s1 in a:
        ans2 = s1
        break
    elif s2 in a:
        ans2 = s2
        break
    s1 -= 1
    s2 += 1

print(ans1, ans2)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))

ans1 = max(a)
sa = sorted(a)

if n == 2:
    ans1 = a[0]
    ans2 = a[1]
else:
    idx = n // 2
    flag = True
    if sa[idx] == ans1 // 2:
        ans2 = ans1 // 2
    elif sa[idx] < ans1 // 2:
        while True:
            idx += 1
            if ans1 // 2 <= sa[idx]:
                if abs(sa[idx] - ans1 / 2) < abs(sa[idx - 1] - ans1 / 2):
                    ans2 = sa[idx]
                else:
                    ans2 = sa[idx - 1]
                break
    else:
        while True:
            idx -= 1
            if sa[idx] <= ans1 // 2:
                if abs(sa[idx] - ans1 / 2) < abs(sa[idx + 1] - ans1 / 2):
                    ans2 = sa[idx]
                else:
                    ans2 = sa[idx + 1]
                break

print(ans1, ans2)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [0] + list(map(int, input().split())) + [0]
cost = [abs(A[i] - A[i + 1]) for i in range(N + 1)]
result = ""
for n in range(N):
    result += str(sum(cost[:n]) + abs(A[n] - A[n + 2]) + sum(cost[n + 2:]))
    if n != N - 1:
        result += '\n'
print(result)


Fixed submission:
N = int(input())
A = [0] + list(map(int, input().split())) + [0]
cost = [abs(A[i] - A[i + 1]) for i in range(N + 1)]
start = 0
end = sum(cost[2:])
for n in range(N):
    print(start + abs(A[n] - A[n + 2]) + end)
    if n != N - 1:
        start += cost[n]
        end -= cost[n + 2]

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [0] + list(map(int, input().split())) + [0]
cost = [abs(A[i] - A[i + 1]) for i in range(N + 1)]
for n in range(N):
    print(sum(cost[:n]) + abs(A[n] - A[n + 2]) + sum(cost[n + 2:]))


Fixed submission:
N = int(input())
A = [0] + list(map(int, input().split())) + [0]
cost = [abs(A[i] - A[i + 1]) for i in range(N + 1)]
start = 0
end = sum(cost[2:])
for n in range(N):
    print(start + abs(A[n] - A[n + 2]) + end)
    if n != N - 1:
        start += cost[n]
        end -= cost[n + 2]

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [0] + list(map(int, input().split())) + [0]
cost = [abs(A[i] - A[i + 1]) for i in range(N + 1)]
for n in range(N):
    print(sum(cost[:n] + [abs(A[n] - A[n + 2])] + cost[n + 2:]))


Fixed submission:
N = int(input())
A = [0] + list(map(int, input().split())) + [0]
cost = [abs(A[i] - A[i + 1]) for i in range(N + 1)]
start = 0
end = sum(cost[2:])
for n in range(N):
    print(start + abs(A[n] - A[n + 2]) + end)
    if n != N - 1:
        start += cost[n]
        end -= cost[n + 2]
Buggy python submission (verdict: Time Limit Exceeded):
N, H = list(map(int, input().split()))
a = []
b = []
for i in range(N):
    temp0, temp1 = list(map(int, input().split()))
    a.append(temp0)
    b.append(temp1)

b_temp = []
for i in b:
    if max(a) <= i:
        b_temp.append(i)
b = b_temp
if H <= sum(b):
    b.sort()
    for i in range(len(b)):
        H -= b[-1 - i]
        if H <= 0:
            result = i + 1
            break
else:
    if len(b) != 0:
        H -= sum(b)
    dev = int(H / max(a))
    if H % max(a) != 0:
        dev += 1
    result = len(b) + dev

print(result)


Fixed submission:
import numpy as np

N, H = list(map(int, input().split()))
a = []
b = []
for i in range(N):
    temp0, temp1 = list(map(int, input().split()))
    a.append(temp0)
    b.append(temp1)

b = np.array(b)
b = b[max(a) < b]
# b_temp = []
# for i in b:
#     if max(a) <= i:
#         b_temp.append(i)
# b = b_temp
if H <= sum(b):
    # b.sort()
    b = np.sort(b)
    for i in range(len(b)):
        H -= b[-1 - i]
        if H <= 0:
            result = i + 1
            break
else:
    if len(b) != 0:
        H -= sum(b)
    dev = int(H / max(a))
    if H % max(a) != 0:
        dev += 1
    result = len(b) + dev

print(result)

Buggy python submission (verdict: Time Limit Exceeded):
N, H = list(map(int, input().split()))
a = []
b = []
for i in range(N):
    temp0, temp1 = list(map(int, input().split()))
    a.append(temp0)
    b.append(temp1)

b_temp = []
for i in b:
    if max(a) <= i:
        b_temp.append(i)
b = b_temp
if H <= sum(b):
    b.sort()
    b.reverse()
    for i, throw in enumerate(b):
        H -= throw
        if H <= 0:
            result = i + 1
            break
else:
    if len(b) != 0:
        H -= sum(b)
    dev = int(H / max(a))
    if H % max(a) != 0:
        dev += 1
    result = len(b) + dev

print(result)


Fixed submission:
import numpy as np

N, H = list(map(int, input().split()))
a = []
b = []
for i in range(N):
    temp0, temp1 = list(map(int, input().split()))
    a.append(temp0)
    b.append(temp1)

b = np.array(b)
b = b[max(a) < b]
# b_temp = []
# for i in b:
#     if max(a) <= i:
#         b_temp.append(i)
# b = b_temp
if H <= sum(b):
    # b.sort()
    b = np.sort(b)
    for i in range(len(b)):
        H -= b[-1 - i]
        if H <= 0:
            result = i + 1
            break
else:
    if len(b) != 0:
        H -= sum(b)
    dev = int(H / max(a))
    if H % max(a) != 0:
        dev += 1
    result = len(b) + dev

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

list_a = list(set(a))

result = 0
for i in list_a:
    cnt = a.count(i)
    if cnt != i:
        result = result + cnt if cnt < i else result + cnt - i

print(result)


Fixed submission:
N = int(input())
a = list(map(int, input().split()))

count_a = {}
for n in range(N):
    if a[n] in count_a.keys():
        count_a[a[n]] += 1
    else:
        count_a[a[n]] = 1

result = 0
for n in list(count_a.keys()):
    if count_a[n] != n:
        result = result + count_a[n] if count_a[n] < n else result + count_a[n] - n

print(result)

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

list_a = list(set(a))

result = 0
for i in list_a:
    cnt = a.count(i)
    result = result + cnt if cnt < i else result + cnt - i

print(result)


Fixed submission:
N = int(input())
a = list(map(int, input().split()))

count_a = {}
for n in range(N):
    if a[n] in count_a.keys():
        count_a[a[n]] += 1
    else:
        count_a[a[n]] = 1

result = 0
for n in list(count_a.keys()):
    if count_a[n] != n:
        result = result + count_a[n] if count_a[n] < n else result + count_a[n] - n

print(result)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

searched = []
if N < M:
    print('NO')
else:
    flag = True
    for i in range(M):
        if T[i] not in searched:
            if D.count(T[i]) < T.count(T[i]):
                flag = False
                break
        searched.append(T[i])
    if flag:
        print('YES')
    else:
        print('NO')

Fixed submission:
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))


def countNumber(LIST):
    cnt = {}
    for l in LIST:
        try:
            cnt[l] += 1
        except KeyError:
            cnt[l] = 1
    return cnt


countD = countNumber(D)
countT = countNumber(T)

flag = True
for i in countT.keys():
    try:
        if countD[i] < countT[i]:
            flag = False
    except KeyError:
        flag = False
        break

if flag:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
N, M, K = map(int, input().split())

flag = False
for n in range(M + 1):
    for m in range(N + 1):
        if n * N + m * (M - n * 2) == K:
            flag = True

if flag:
    print('Yes')
else:
    print('No')


Fixed submission:
S = input()
if S[:4] == 'YAKI':
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
A.py

Fixed submission:
N = int(input())
A = int(input())

print(N * N - A)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()

index = 0
result = 0
while True:
    num = A.count(A[index])
    index += num
    if (num % 2) == 1:
        result += 1
    if N <= index:
        break
print(result)

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()


def customCount(idx):
    target = A[idx]
    cnt = 1
    idx += 1
    while True:
        if idx == N or A[idx] != target:
            return cnt
        else:
            idx += 1
            cnt += 1


index = 0
result = 0
while True:
    num = customCount(index)
    index += num
    if (num % 2) == 1:
        result += 1
    if N <= index:
        break
print(result)