Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
for i in range(N):
  t[i], x[i], y[i] = map(int, input().split())

is_able = True

for i in range(N-1):
  dt = t[i+1] - t[i]
  dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
  if dt < dist:
    is_able = False
  if dt % 2 != dist % 2:
    is_able = False
  
if is_able:
  print("YES")
else:
  print("NO")


Fixed submission:
N = int(input())
t = [0] * (N+1)
x = [0] * (N+1)
y = [0] * (N+1)
for i in range(N):
  t[i+1], x[i+1], y[i+1] = map(int, input().split())
is_able = True
 
for i in range(N):
  dt = t[i+1] - t[i]
  dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
  if dt < dist:
    is_able = False
  if dt % 2 != dist % 2:
    is_able = False
  
if is_able:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
y, m, d = input()
y = '2018'
print(y + '/' + m + '/' + d)

Fixed submission:
y, m, d = input().split('/')
y = '2018'
print(y + '/' + m + '/' + d)

Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())
sum = 0
is_exist = False
for i in range(N+1):
  for j in range(N+1):
    k = N - i - j
    sum = i * 10000 + j * 5000 + k * 1000
    if sum == Y and i + j + k == N:
      printf("{} {} {}".format(i, j, k))
      is_exist = True
      break
  if is_exist:
    break
if is_exist == False:
  print("-1 -1 -1")

Fixed submission:
y, m, d = input().split('/')
y = '2018'
print(y + '/' + m + '/' + d)
Buggy python submission (verdict: Runtime Error):
def main():
  a, b = map(int, input().split())
  s = input()
  for i in range(1, len(s)+1):
    if i == a+1:
      if s[i] != '-':
       	return False
    else:
      if s[i] == '-':
        return False
  return True

if __name__ == '__main__':
  if main():
    print('Yes')
  else:
    print('No')

Fixed submission:
def main():
  a, b = map(int, input().split())
  s = input()
  for i in range(len(s)):
    if i == a:
      if s[i] != '-':
       	return False
    else:
      if s[i] == '-':
        return False
  return True
 
if __name__ == '__main__':
  if main():
    print('Yes')
  else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N, A, B = input().split()
A = int(A)
B = int(B)
k_sum = 0
ans = 0
for j in range(1, int(N)+1):
  j = str(j)
  for i in range(len(j)):
  	k_sum += int(j[i])
  if k_sum >= A and k_sum <= B:
    ans += int[j]

print(j)
  

Fixed submission:
N, A, B = input().split()
A = int(A)
B = int(B)
k_sum = 0
ans = 0
for j in range(1, int(N)+1):
  j = str(j)
  k_sum = 0
  for i in range(len(j)):
  	k_sum += int(j[i])
  if k_sum >= A and k_sum <= B:
    ans += int(j)
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0:
  print("Possible")
else:
  Print("Impossible")

Fixed submission:
a, b = map(int, input().split())
if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0:
  print("Possible")
else:
  print("Impossible")
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
li = sorted(list(map(int, input().split())), reverse=True)

print(li[0]+li[1]+li[2])

Fixed submission:
n, k = map(int, input().split())
li = sorted(list(map(int, input().split())), reverse=True)
ans = 0

for i in range(k):
  ans += li[i]
  
print(ans)
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())

for i in range(h+2):
  if i == 0 or i == h+1:
    print("#"*(w+2))
  else:
    print("#"+input()"#")
	

Fixed submission:
h, w = map(int, input().split())
 
for i in range(h+2):
  if i == 0 or i == h+1:
    print("#"*(w+2))
  else:
    print("#"+input()+"#")
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a > b:
  print("GREATER")
elif a == b:
  print("EQUAL")
else:
  print("LESS")


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

if a > b:
  print("GREATER")
elif a == b:
  print("EQUAL")
else:
  print("LESS")
Buggy python submission (verdict: Runtime Error):
w, a, b = map(int, input().split())
ans = 0
if a < b:
  if a+w > b:
    ans = 0
  else:
    ans = b - a+w
else if a == b:
  ans = 0

else:
  if b+w > a:
    ans = 0
  else:
    ans = a - b+w

print(ans)


Fixed submission:
w, a, b = map(int, input().split())
ans = 0
if a < b:
  if a+w > b:
    ans = 0
  else:
    ans = b - (a+w)
elif a == b:
  ans = 0
 
else:
  if b+w > a:
    ans = 0
  else:
    ans = a - (b+w)
 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 1

for i in range(1, n+1):
  ans *= i
  
print(ans % 1000000007)


Fixed submission:
n = int(input())
ans = 1
 
for i in range(1, n+1):
  ans = (ans * i) % 1000000007
  
print(ans)
Buggy python submission (verdict: Runtime Error):
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input() for _ in range(n))]

flag = False
for i in range(3):
    if a[i][0] in b and a[i][1] in b and a[i][2] in b:
        flag = True
        break
    if a[0][i] in b and a[1][i] in b and a[2][i] in b:
        flag = True
        break
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
    flag = True
if a[2][0] in b and a[1][1] in b and a[0][2] in b:
    flag = True
    
print("Yes" if flag else "No")

Fixed submission:
import numpy as np

a = [list(map(int, input().split())) for _ in range(3)]
a = np.array(a)
n = int(input())

for _ in range(n):
    b = int(input())
    
    for j in range(3):
        for i in range(3):
            if a[j][i] == b:
                a[j][i] = 0

at = a.transpose()
flag = False
for i in range(3):
    if sum(a[:][i]) == 0 or sum(at[:][i]) == 0:
        flag = True
        break
diag = a[0][0] + a[1][1] + a[2][2]
diag2 = a[2][0] + a[1][1] + a[0][2]
if diag == 0 or diag2 == 0:
    flag = True

print("Yes" if flag else "No")
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd

A,B = map(int,input().split())
x = gcd(A,B)

def prime_factrization(n):
    exponent = 0
    while n%2 == 0:
        exponent += 1
        n //= 2
    if exponent == 0:
        a = []
    else:
        a = [[2,exponent]]
    
    q = 3
    while q*q <= n:
        if n%q != 0:
            continue
        exponent = 0
        while n%q == 0:
            exponent += 1
            n //= q
        a.append([q,exponent])
        q += 2
        
    if n != 1:
        a.append([n,1])
    return a
    
a = prime_factrization(x)

print(len(a)+1)

Fixed submission:

from fractions import gcd

A,B = map(int,input().split())
x = gcd(A,B)

def prime_factrization(n):
    exponent = 0
    while n%2 == 0:
        exponent += 1
        n //= 2
    if exponent == 0:
        a = []
    else:
        a = [[2,exponent]]
    
    q = 1
    while q*q <= n:
        q += 2
        if n%q != 0:
            continue
        exponent = 0
        while n%q == 0:
            exponent += 1
            n //= q
        a.append([q,exponent])
        
    if n != 1:
        a.append([n,1])
    return a

if x == 1:
    print(1)
else:
    a = prime_factrization(x)
    print(len(a)+1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

dic = []
cnt = [0 for _ in range(N)]

for i in range(N):
    s = input()
    test = {}
    for ss in s:
        if not ss in test:
            test[ss] = 1
        else:
            test[ss] += 1
    for j, prev in enumerate(dic):
        if prev == test:
            cnt[j] += 1
            break
    dic.append(test)

ans = 0
for i in cnt:
    for j in range(1, i+1):
        ans += j
print(ans)

Fixed submission:
N = int(input())
s = [input() for _ in range(N)]

dic = {}
ans = 0

for ss in s:
    temp = [ch for ch in ss]
    temp.sort()
    sss = "".join(temp)
    
    if sss in dic:
        ans += dic[sss]
        dic[sss] += 1
    else:
        dic[sss] = 1

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

a_max = max(A)

for i,a in enumerate(A):
    if a == a_max:
        A[i] -= a
        print(max(A))
        A[i] += a
    else:
        print(a_max)

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

for x in A:
    if x == ref[-1]:
        print(ref[-2])
    else:
        print(ref[-1])
Buggy python submission (verdict: Runtime Error):
N, M = map(int,input().split())
a = [int(input) for _ in range(M)]

dev = 100000007
dp = [0 for _ in range(N+1)]
dp[0] = 1
dp[1] = 1

fall = [1 for _ in range(N+1)]

for i in range(M):
    fall[a[i]] = 0

for i in range(1,N):
    dp[i+1] = dp[i]*fall[i] + dp[i-1]*fall[i-1]
    dp[i+1] %= dev

print(dp[N])

Fixed submission:
N, M = map(int,input().split())
a = [int(input()) for _ in range(M)]

dev = 1000000007
dp = [0 for _ in range(N+1)]
dp[0] = 1
dp[1] = 1

fall = [1 for _ in range(N+1)]

for i in range(M):
    fall[a[i]] = 0

for i in range(1,N):
    dp[i+1] = dp[i]*fall[i] + dp[i-1]*fall[i-1]
    dp[i+1] %= dev

print(dp[N])

Buggy python submission (verdict: Runtime Error):

N, M = map(int,input().split())
a = []
dev = 100000007

for _ in range(M):
    aa = int(input())
    a.append(aa)

ans = 0
flag = True
a.append(N+1)

for i in range(M-1):
    if a[i+1] == a[i]+1:
        flag = False
        break

def fadd(n):
    if n == 1:
        return 1
    elif n == 2:
        return 2
    elif n == 0:
        return 0
    else:
        return fadd(n-1)%dev + fadd(n-2)%dev
    
if flag:
    
    pa = 0 
    for i,na in enumerate(a):
        print(i,na)
        ans += fadd(na - 1 - pa)%dev
        pa = na + 1

print(ans)

Fixed submission:
N, M = map(int,input().split())
a = [int(input()) for _ in range(M)]

dev = 1000000007
dp = [0 for _ in range(N+1)]
dp[0] = 1
dp[1] = 1

fall = [1 for _ in range(N+1)]

for i in range(M):
    fall[a[i]] = 0

for i in range(1,N):
    dp[i+1] = dp[i]*fall[i] + dp[i-1]*fall[i-1]
    dp[i+1] %= dev

print(dp[N])

Buggy python submission (verdict: Runtime Error):
N, M = map(int,input().split())
a = []
dev = 100000007

for _ in range(M):
    aa = int(input())
    a.append(aa)

ans = 0

def dfs(step):
    global ans
    if step == N:
        ans = (ans+1)%dev
        return
    elif step > N:
        return
    
    for ds in (1,2):
        ns = step + ds
        if ns in a:
            continue
        else:
            dfs(ns)

dfs(0)
print(ans)

Fixed submission:
N, M = map(int,input().split())
a = [int(input()) for _ in range(M)]

dev = 1000000007
dp = [0 for _ in range(N+1)]
dp[0] = 1
dp[1] = 1

fall = [1 for _ in range(N+1)]

for i in range(M):
    fall[a[i]] = 0

for i in range(1,N):
    dp[i+1] = dp[i]*fall[i] + dp[i-1]*fall[i-1]
    dp[i+1] %= dev

print(dp[N])
Buggy python submission (verdict: Runtime Error):

N, M = map(int,input().split())
A = [0 for _ in range(N)]

abc = [(A[i],1) for i in range(N)]

for j in range(M):
    B, C = map(int, input().split())
    abc.append((C,B))
    
abc.sort()
abc.reverse()

ans = 0
cnt = N

for (c,b) in abc:
    num_c = min(b,cnt)
    ans += num_c * c
    cnt -= num_c

print(ans)

Fixed submission:
N, M = map(int,input().split())
A = [int(a) for a in input().split()]
BC = [[0,0] for _ in range(M)]

for i in range(M):
    B,C = map(int,input().split())
    BC[i] = [B,C]

a_use = sorted(A)
bc_use = sorted(BC, reverse=True, key=lambda x: x[1])

low_index = 0
for i in range(M):
    if low_index > N-1:
        break
    if a_use[low_index] > bc_use[i][1]:
        break
    else:
        for j in range(bc_use[i][0]):
            if j + low_index > N-1:
                break
            if a_use[j+low_index] < bc_use[i][1]:
                a_use[j+low_index] = bc_use[i][1]
        low_index += bc_use[i][0]

print(int(sum(a_use)))
Buggy python submission (verdict: Runtime Error):
S = input()

S1 = 10*int(S[0]) + int(S[1])
S2 = 10*int(S[2]) + int(S[3])
SepS = [S1, S2]
MM = [True,True]

for i in range(2):
  if SepS[i] < 1 or SepS[i] > 12:
    MM[i] = False

if MM[0] and MM[1]:
  print("AMBIGUOUS")
elif MM[0]:
  print("MMYY")
elif MM[1]:
  print("YYMM")
else:
  print("NA")

Fixed submission:
N, K = map(int, input().split())
S = input()
 
dummy = ""
 
for i in range(N):
  if i == K-1:
    dummy += S[i].lower()
  else:
    dummy += S[i]
    
print(dummy)

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

dummy = ""

for i in range(N):
  if i == K-1:
    dummy += S[i].lower
  else:
    dummy += S[i]
    
print(dummy)

Fixed submission:
N, K = map(int, input().split())
S = input()
 
dummy = ""
 
for i in range(N):
  if i == K-1:
    dummy += S[i].lower()
  else:
    dummy += S[i]
    
print(dummy)
Buggy python submission (verdict: Runtime Error):
a = [0 for _ in range*6]

for i in range(6):
    a[i]= int(input())
k = int(input())

dist = a[5]-a[0]

if dist > k:
    print(":(")
else:
    print("Yay!")

Fixed submission:
a = [0 for _ in range(5)]

for i in range(5):
    a[i]= int(input())
k = int(input())

dist = a[4]-a[0]

if dist > k:
    print(":(")
else:
    print("Yay!")
Buggy python submission (verdict: Runtime Error):
Time = []
Time_Zero = []

for i in range(5):
    A = int(input())
    ra = A%10
    qa = A//10
    if ra == 0:
      Time_Zero.append([ra,qa,A])
    else:
      Time.append([ra,qa,A])

Time.sort(reverse=True)

ans = 0
for r,q,A in Time_Zero:
  ans += 10*q

for r,q,A in Time:
  ans += 10*(q+1)

ans += Time[-1][2] - 10*(Time[-1][1]+1)

print(ans)

Fixed submission:
Time = []
Time_Zero = []

for i in range(5):
    A = int(input())
    ra = A%10
    qa = A//10
    if ra == 0:
      Time_Zero.append([ra,qa,A])
    else:
      Time.append([ra,qa,A])

Time.sort(reverse=True)

ans = 0
for r,q,A in Time_Zero:
  ans += 10*q

for r,q,A in Time:
  ans += 10*(q+1)

if len(Time) > 0:
  ans += Time[-1][2] - 10*(Time[-1][1]+1)

print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()

cnt = 0
ans = 0

for ss in S:
    if ss in 'ACGT':
        len += 1
    else:
        len = 0
    ans = max(ans,len)
    
print(ans)

Fixed submission:
S = input()

acgt =['A','C','G','T']

count = 0
ans = 0

for i in range(len(S)):
    if acgt.count(S[i]):
        count += 1
    else:
        count = 0
    ans = max(ans,count)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

ans = 0
for i in range(1,N+1):
    s = set(str(i))
    if s == {'7','5','3'}:
        ans += 1

print(ans)

Fixed submission:
N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    cnt = 1 if all(s.count(c) for c in '753') else 0
    
    for ss in '753':
        cnt += dfs(s+ss)
    #print(s,cnt)
    
    return cnt
    
print(dfs('0'))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
v = list(map(int,input().split()))
b = []
c = []

for i, vv in enumerate(v):
    if i%2 == 0:
        b.append(vv)
    else:
        c.append(vv)

b_set = []
c_set = []

for bb in set(b):
    b_set.append((b.count(bb), bb))
for cc in set(c):
    c_set.append((c.count(cc), cc))

b_set.sort(reverse=True)
b_set.append((0,0))
c_set.sort(reverse=True)
c_set.append((0,0))

if b_set[0][1] != c_set[0][1]:
    ans = n - b_set[0][0] - c_set[0][0]
else:
    try1 = n - b_set[1][0] - c_set[0][0]
    try2 = n - b_set[0][0] - c_set[1][0]
    ans = min(try1,try2)

print(ans)

Fixed submission:
n = int(input())
v = list(map(int,input().split()))
b = []
c = []

for i, vv in enumerate(v):
    if i%2 == 0:
        b.append(vv)
    else:
        c.append(vv)

b_set = {}
c_set = {}

for bb in b:
    if not bb in b_set.keys():
        b_set[bb] = 1
    else:
        b_set[bb] += 1

for cc in c:
    if not cc in c_set.keys():
        c_set[cc] = 1
    else:
        c_set[cc] += 1

b_sorted = []
c_sorted = []

for key, value in b_set.items():
    b_sorted.append([value,key])
for key, value in c_set.items():
    c_sorted.append([value,key])

b_sorted = sorted(b_sorted, reverse=True)
b_sorted += [[0,0]]
c_sorted = sorted(c_sorted, reverse=True)
c_sorted += [[0,0]]


if b_sorted[0][1] != c_sorted[0][1]:
    ans = n - b_sorted[0][0] - c_sorted[0][0]
else:
    try1 = n - b_sorted[1][0] - c_sorted[0][0]
    try2 = n - b_sorted[0][0] - c_sorted[1][0]
    ans = min(try1,try2)

print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())

k = min(K,len(S))

for i in range(k):
    if S[i] != '1':
        ans = S[i]
        break
print(ans)

Fixed submission:
S = input()
K = int(input())
 
k = min(K,len(S))

ans = 1

for i in range(k):
    if S[i] != '1':
        ans = S[i]
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())

for i in range(K):
    if S[i] != '1':
        ans = S[i]
        break
print(ans)

Fixed submission:
S = input()
K = int(input())
 
k = min(K,len(S))

ans = 1

for i in range(k):
    if S[i] != '1':
        ans = S[i]
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
D,G = map(int,input().split())
G = G//100
pc = []

for i in range(D):
    p,c = maap(int,input().split())
    pc.append((p,c//100))

ans = 1e9

for i in range(1<<D):
    points = 0
    cost = 0
    for j in range(D):
        jbit = ((i>>j)&1)
        
        points += jbit*( (j+1)*pc[j][0] + pc[j][1])
        cost += jbit * pc[j][0]
        
    if points >= G:
        ans = min(ans,cost)
        continue
    res = G - points
    for k in range(D-1,-1,-1):
        kbit = ((i>>k)&1)
        if not kbit:
            test = res // (k+1)
            #print(test)
            if test <= pc[k][0]-1:
                res = 0
                cost += test
                ans = min(ans, cost)
            else:
                res -= (k+1)*(pc[k][0]-1)
                cost += pc[k][0]-1
    
print(ans)

Fixed submission:
D,G = map(int,input().split())
G = G//100
pc = []

for i in range(D):
    p,c = map(int,input().split())
    pc.append((p,c//100))

ans = 1e9

for i in range(1<<D):
    points = 0
    cost = 0
    for j in range(D):
        jbit = ((i>>j)&1)
        
        points += jbit*( (j+1)*pc[j][0] + pc[j][1])
        cost += jbit * pc[j][0]
        
    if points >= G:
        ans = min(ans,cost)
        continue
    res = G - points
    for k in range(D-1,-1,-1):
        kbit = ((i>>k)&1)
        if not kbit:
            test = (res+k) // (k+1)
            #print(test)
            if test <= pc[k][0]-1:
                res = 0
                cost += test
                ans = min(ans, cost)
            else:
                res -= (k+1)*(pc[k][0]-1)
                cost += pc[k][0]-1
    
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, c, k = map(int, input().split())

if abs(a - b) >=th:
    print("Unfair")
elif k == 0:
    print(a - b)
else:
    print(b - a)

Fixed submission:
a, b, c, k = map(int, input().split())

if abs(a - b) >= 10e18:
    print("Unfair")
elif k%2 == 0:
    print(a - b)
else:
    print(b - a)

Buggy python submission (verdict: Runtime Error):
a, b, c, k = map(int, input().split())

if result >=th:
    print("Unfair")
elif k == 0:
    print(a - b)
else:
    print(b - a)

Fixed submission:
a, b, c, k = map(int, input().split())

if abs(a - b) >= 10e18:
    print("Unfair")
elif k%2 == 0:
    print(a - b)
else:
    print(b - a)
Buggy python submission (verdict: Runtime Error):
H, W = map(int,input().split())

s = []
for i in range(H):
    ss = input()
    s.append(ss)

shift = [[1,0],[-1,0],[0,1],[0,-1]]

for j in range(H):
    for i in range(W):
        if s[j][i] == "#":
            flag = False
            for dx, dy in shift:
                nx = i + dx
                ny = j + dy
                if nx >= 0 and nx < W and ny >= 0 and ny < H:
                    if s[ny][nx] == "#":
                        flag = True
            if not flag:
                exit(0)

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


Fixed submission:
H,W = map(int,input().split())
s = []
for _ in range(H):
    s.append(input())

shift = [[1,0],[-1,0],[0,-1],[0,1]]

flag = True
for j in range(H):
    for i in range(W):
        if s[j][i] == ".":
            continue
        else:
            flag = False
            for dx,dy in shift:
                nx = i + dx
                ny = j + dy
                
                if nx >= 0 and nx < W and ny >= 0 and ny < H:
                    if s[ny][nx] == "#":
                        flag = True
            if not flag:
                print("No")
                exit(0)

print("Yes")

Buggy python submission (verdict: Runtime Error):
H, W = map(int,input().split())

s = []
for i in range(H):
    ss = input()
    s.append(ss)

shift = [[1,0],[-1,0],[0,1],[0,-1]]

for j in range(H):
    for i in range(W):
        if s[j][i] == "#":
            flag = False
            for dx, dy in shift:
                nx = i + dx
                ny = j + dy
                if nx >= 0 and nx < W and ny >= 0 and ny < H:
                    if s[ny][nx] == "#":
                        flag = True
            if not flag:
                break

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

Fixed submission:
H,W = map(int,input().split())
s = []
for _ in range(H):
    s.append(input())

shift = [[1,0],[-1,0],[0,-1],[0,1]]

flag = True
for j in range(H):
    for i in range(W):
        if s[j][i] == ".":
            continue
        else:
            flag = False
            for dx,dy in shift:
                nx = i + dx
                ny = j + dy
                
                if nx >= 0 and nx < W and ny >= 0 and ny < H:
                    if s[ny][nx] == "#":
                        flag = True
            if not flag:
                print("No")
                exit(0)

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

ans = 0
a_as = [0 for _ in range(max(a))]

for x in a:
    a_as[x-1] += 1

for i,cnt in enumerate(a_as):
    if cnt == 0 or cnt == i+1:
        continue
    elif cnt > i+1:
        ans += cnt - (i+1)
    else:
        ans += cnt
    
print(ans)

Fixed submission:

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

ans = 0
a_as = {}

for x in a:
    if x in a_as:
        a_as[x] += 1
    else:
        a_as[x] = 1

for x in a_as:
    if x > a_as[x]:
        ans += a_as[x]
    else:
        ans += abs(a_as[x]-x)
    
print(ans)

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

a.sort()
i = 0
ans = 0

seen = []

while i < N:
    x = a[i]
    if x in seen:
        ans += 1
        i += 1
        continue
    else:
        seen.append(x)

    cnt = 1
    j = 1
    flag = True
    while j < x and i+j < N and flag:
        if a[i+j] != x:
            flag = False
        else:
            cnt += 1
        j += 1
            
    if not flag or cnt != x:
        ans += cnt
    i += cnt

print(ans)

Fixed submission:

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

ans = 0
a_as = {}

for x in a:
    if x in a_as:
        a_as[x] += 1
    else:
        a_as[x] = 1

for x in a_as:
    if x > a_as[x]:
        ans += a_as[x]
    else:
        ans += abs(a_as[x]-x)
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

ans = []

for i,x in enumerate(a):
    if i%2 == (n-1)%2:
        ans.insert(0,x)
    else:
        ans.append(x)

print(*ans)

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

farm=[]
latt=[]

for i,x in enumerate(a):
    if i%2 == (n-1)%2:
        farm.append(x)
    else:
        latt.append(x)
farm.reverse()
ans = farm + latt

print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int,input().split())
t = []

for _ in range(N):
    a,b = map(int,input().split())
    for j in range(b):
        t.append(a)
t.sort()

print(t[K-1])

Fixed submission:
N, K = map(int,input().split())
a_max = 100000
t = [0 for _ in range(a_max)]

for _ in range(N):
    a, b = map(int,input().split())
    t[a-1] += b

cnt = 0
for i in range(a_max):
    cnt += t[i]
    if cnt >= K:
        ans = i+1
        break

print(ans)