Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = list(map(int,input().split()))
keisuu = [[0]*n for _ in range(n)]
for i in range(n):
    a[i]*=2
    
    if i+1 <=n-1:
        keisuu[i][i+1] = 1
        keisuu[i][i] = 1
    else:
        keisuu[i][i] = 1
        keisuu[i][0] = 1
keisuu = np.array(keisuu)
avec = np.array(a)
inv_keisuu = np.linalg.inv(keisuu)
x = np.dot(inv_keisuu,avec)
for i in range(n):
    print(int(x[i]))


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
x = s-2*sum([a[i] for i in range(1,n-1,2)])
print(x)
for i in range(n-1):
    x = 2*a[i]-x
    print(x)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
a = list(map(int,input().split()))
keisuu = [[0]*n for _ in range(n)]
for i in range(n):
    a[i]*=2
    
    if i+1 <=n-1:
        keisuu[i][i+1] = 1
        keisuu[i][i] = 1
    else:
        keisuu[i][i] = 1
        keisuu[i][0] = 1
keisuu = np.array(keisuu)
avec = np.array(a)
inv_keisuu = np.linalg.inv(keisuu)
x = np.dot(inv_keisuu,avec)
for i in range(n):
    print(int(x[i]))


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
x = s-2*sum([a[i] for i in range(1,n-1,2)])
print(x)
for i in range(n-1):
    x = 2*a[i]-x
    print(x)
Buggy python submission (verdict: Runtime Error):
import math
A,B,C,D = map(int,input().split())
W = C*D//math.gcd(C,D)
X = B//C -((A-1)//C)
Y = B//D -((A-1)//D)
Z = B//W -((A-1)//W)
ans = (B-A+1)-(X+Y-Z)
print(ans)

Fixed submission:
import fractions
A,B,C,D = map(int,input().split())
all = B-A+1
X = fractions.gcd(C,D)
gC = B//C - ((A-1)//C)
gD = B//D - ((A-1)//D)
gcdcd = C*D//X
gCD = B//gcdcd - ((A-1)//gcdcd)
ans = all - (gC+gD -gCD)
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
A,B,C,D = map(int,input().split())
W = C*D//math.gcd(C,D)
X = B//C -((A-1)//C)
Y = B//D -((A-1)//D)
Z = B//W -((A-1)//W)
ans = (B-A+1)-(X+Y-Z)
print(ans)

Fixed submission:
import fractions
A,B,C,D = map(int,input().split())
all = B-A+1
X = fractions.gcd(C,D)
gC = B//C - ((A-1)//C)
gD = B//D - ((A-1)//D)
gcdcd = C*D//X
gCD = B//gcdcd - ((A-1)//gcdcd)
ans = all - (gC+gD -gCD)
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
A,B,C,D = map(int,input().split())
W = C*D//math.gcd(C,D)
X = B//C -((A-1)//C)
Y = B//D -((A-1)//D)
Z = B//W -((A-1)//W)
ans = (B-A+1)-(X+Y-Z)
print(ans)

Fixed submission:
import fractions
A,B,C,D = map(int,input().split())
all = B-A+1
X = fractions.gcd(C,D)
gC = B//C - ((A-1)//C)
gD = B//D - ((A-1)//D)
gcdcd = C*D//X
gCD = B//gcdcd - ((A-1)//gcdcd)
ans = all - (gC+gD -gCD)
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
A,B,C,D = map(int,input().split())
W = C*D//math.gcd(C,D)
X = B//C -((A-1)//C)
Y = B//D -((A-1)//D)
Z = B//W -((A-1)//W)
ans = (B-A+1)-(X+Y-Z)
print(ans)

Fixed submission:
import fractions
A,B,C,D = map(int,input().split())
all = B-A+1
X = fractions.gcd(C,D)
gC = B//C - ((A-1)//C)
gD = B//D - ((A-1)//D)
gcdcd = C*D//X
gCD = B//gcdcd - ((A-1)//gcdcd)
ans = all - (gC+gD -gCD)
print(ans)
Buggy python submission (verdict: Runtime Error):
W,H,x,y = map(int,input().split())
print(W*H/2)
if W//2 == x && H//2 == y:
    print(1)
else:
    print(0)

Fixed submission:
W,H,x,y = map(int,input().split())

if W/2 == x and H/2 == y:
    ans = 1
else:
    ans = 0
print(W*H/2,ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
a = list(int(input()) for i in range(M))
dp = [0]*(N+1)
dp[0] = 1
dp[1] = 1
if 1 in a:
    dp[1] = 0
for i in range(2,N+1):
    if i in a:
        continue
    
    dp[i] = (dp[i-2]+dp[i-1])%1000000007
ans = dp[N]
print(ans)



Fixed submission:
N,M = map(int,input().split())
a = set([int(input()) for i in range(M)])
dp = [0]*(N+1)
dp[0] = 1
dp[1] = 1
if 1 in a:
    dp[1] = 0
for i in range(2,N+1):
    if i in a:
        continue
    
    dp[i] = (dp[i-2]+dp[i-1])%1000000007
ans = dp[N]
print(ans)

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = set([int(input()) for i in range(M)])
dp = [0]*(N+1)
dp[1] = 1

if 1 in a:
    dp[2] = 1
    dp[1] = 0
else:
    dp[2] = 2
for i in range(3,N+1):
    if i-1 in a:
        continue
    
    dp[i] = (dp[i-2]+dp[i-1])%1000000007
ans = dp[N]
print(ans)



Fixed submission:
N,M = map(int,input().split())
a = set([int(input()) for i in range(M)])
dp = [0]*(N+1)
dp[0] = 1
dp[1] = 1
if 1 in a:
    dp[1] = 0
for i in range(2,N+1):
    if i in a:
        continue
    
    dp[i] = (dp[i-2]+dp[i-1])%1000000007
ans = dp[N]
print(ans)

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = []
for i in range(M):
    a.append(int(input()))
dp = [0]*(N+1)
dp[1] = 1
if 1 in a:
    dp[2] = 1
    dp[1] = 0
else:
    dp[2] = 2
for i in range(3,N+1):
    if i-1 in a:
        continue
    
    dp[i] = (dp[i-2]+dp[i-1])%1000000007
ans = dp[N]
print(ans)


Fixed submission:
N,M = map(int,input().split())
a = set([int(input()) for i in range(M)])
dp = [0]*(N+1)
dp[0] = 1
dp[1] = 1
if 1 in a:
    dp[1] = 0
for i in range(2,N+1):
    if i in a:
        continue
    
    dp[i] = (dp[i-2]+dp[i-1])%1000000007
ans = dp[N]
print(ans)

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = []
for i in range(M):
    a.append(int(input()))
dp = [0]*(N+1)
dp[1] = 1
if 1 in a:
    dp[2] = 1
    dp[1] = 0
else:
    dp[2] = 2
for i in range(3,N+1):
    if i-1 in a:
        dp[i] = dp[i-2]%1000000007
        dp[i-1] = 0
    else:
        dp[i] = (dp[i-2]+dp[i-1])%1000000007
ans = dp[N]%1000000007
print(ans)


Fixed submission:
N,M = map(int,input().split())
a = set([int(input()) for i in range(M)])
dp = [0]*(N+1)
dp[0] = 1
dp[1] = 1
if 1 in a:
    dp[1] = 0
for i in range(2,N+1):
    if i in a:
        continue
    
    dp[i] = (dp[i-2]+dp[i-1])%1000000007
ans = dp[N]
print(ans)

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = []
for i in range(M):
    a.append(int(input()))
dp = [0]*(N+1)
dp[1] = 1
if 1 in a:
    dp[2] = 1
    dp[1] = 0
else:
    dp[2] = 2
for i in range(3,N+1):
    if i-1 in a:
        dp[i] = dp[i-2]
        dp[i-1] = 0
    else:
        dp[i] = dp[i-2]+dp[i-1]
ans = dp[N]%1000000007
print(ans)


Fixed submission:
N,M = map(int,input().split())
a = set([int(input()) for i in range(M)])
dp = [0]*(N+1)
dp[0] = 1
dp[1] = 1
if 1 in a:
    dp[1] = 0
for i in range(2,N+1):
    if i in a:
        continue
    
    dp[i] = (dp[i-2]+dp[i-1])%1000000007
ans = dp[N]
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = [list(map(int,input().split()))for i in range(m)]
p =[]
d = []
a.sort()
for i in range(m):
    b = bc[i][0]
    c = bc[i][1]
    p.append([c,b])
p.sort(reverse = True)
look = 0
for i in range(n):
    if look > m-1:break
    if p[look][1] >0:
        d.append(p[look][0])
        p[look][1]-=1
    else:
        look+=1
        d.append(p[look][0])
        p[look][1]-=1
sm = sum(a)
updatefrom = 0
updateto = 0
ans = 0
for x in range(n):
    updatefrom +=a[x]
    updateto +=d[x]
    ans = max(ans,sm-updatefrom +updateto)
print(ans)
    

    
    

Fixed submission:
n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = [list(map(int,input().split()))for i in range(m)]
p =[]
d = []
a.sort()
for i in range(m):
    b = bc[i][0]
    c = bc[i][1]
    p.append([c,b])
p.sort(reverse = True)
look = 0
for i in range(n):
    if look > m-1:break
    if p[look][1] >0:
        d.append(p[look][0])
        p[look][1]-=1
    
    else:
        if look ==m-1:break
        look+=1
        d.append(p[look][0])
        p[look][1]-=1
sm = sum(a)
updatefrom = 0
updateto = 0
ans = sm
for x in range(n):
    if x >= len(d):break
    updatefrom +=a[x]
    updateto +=d[x]
    ans = max(ans,sm-updatefrom +updateto)
print(ans)
Buggy python submission (verdict: Runtime Error):
S = int(input())
x = 0
a = S//100
b = S%100
if a>=1 and a<=12:
    x+=1
if b>=1 and a<=12:
    x+=1
if x = 0:
    print("NA")
elif x = 2:
    print("AMBIGUOUS")
if x = 1:
    if a>=1 and a<=12:
        print("MMYY")
    else:
        print("YYMM")

Fixed submission:
S = int(input())
x = 0
a = S//100
b = S%100
if a>=1 and a<=12:
    x+=1
if b>=1 and b<=12:
    x+=1
if x == 0:
    print("NA")
elif x == 2:
    print("AMBIGUOUS")
if x == 1:
    if a>=1 and a<=12:
        print("MMYY")
    else:
        print("YYMM")
Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n = map(int,input().split())
rgb = [r,g,b]
rgb.sort()
x = rgb[2]
y = rgb[1]
z = rgb[0]
ans = 0

for i in range(n//x+30):
    for j in range(n//y+30):
        if (n-x*i-y*j)%z ==0:
            if (n-x*i-y*j)//z >=0:
                ans += 1
          
print(ans)

Fixed submission:
r,g,b,n = map(int,input().split())
rgb = [r,g,b]
rgb.sort()
x = rgb[2]
y = rgb[1]
z = rgb[0]
ans = 0

for i in range(n//x+30):
    for j in range(n//y+30):
        if (n-x*i-y*j)%z ==0:
            if (n-x*i-y*j)//z >=0:
                ans += 1
          
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n = map(int,input().split())
rgb = [r,g,b]
rgb.sort()
x = rgb[2]
y = rgb[1]
z = rgb[0]
ans = 0

for i in range(2200):
    for j in range(2200):
        if (n-x*i-y*j)%z ==0:
            if (n-x*i-y*j)//z >=0:
                ans += 1
          
print(ans)

Fixed submission:
r,g,b,n = map(int,input().split())
rgb = [r,g,b]
rgb.sort()
x = rgb[2]
y = rgb[1]
z = rgb[0]
ans = 0

for i in range(n//x+30):
    for j in range(n//y+30):
        if (n-x*i-y*j)%z ==0:
            if (n-x*i-y*j)//z >=0:
                ans += 1
          
print(ans)
Buggy python submission (verdict: Runtime Error):
 N, Q = map(int, input().split())
2 S = input()
3 t = [0] * (N + 1)
4 for i in range(N):
5 t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
6 for i in range(Q):
7 l, r = map(int, input().split())
8 print(t[r-1] - t[l-1])


Fixed submission:
N,Q = map(int,input().split())
S = str(input())
t = [0]*(N+1)
for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == "AC" else 0)
for i in range(Q):
    l,r = map(int,input().split())
    print(t[r-1]-t[l-1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
res = []
x = 0
for i in range(n):
    a,b = map(int,input().split())
    res.append(a+b)
res.sort(reverse = True)
for i in range(n//2+1):
    ans+=res[i]
print(ans)
    

Fixed submission:
n = int(input())
res = []

ans = 0
for i in range(n):
    a,b = map(int,input().split())
    res.append(a+b)
    ans-=b

res.sort(reverse = True)
for i in range(0,n,2):
    ans+=res[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
dp = [[0]*(len(t)+1) for i in range(len(s)+1)]
#dp[i+1][j+1]sのi文字目までとtのj文字目までを比較したときのLCS
for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j]+1
        else:
            dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j])

i = len(s)
j = len(t)
ans = ''
while (i>=0 and j >= 0):
    if(dp[i+1][j] > dp[i][j+1] ):i-=1
    elif (dp[i+1][j] < dp[i][j+1]):j -= 1
    else:ans = s[i]+ ans
print(ans)


Fixed submission:
s = input()
t = input()
dp = [[0]*(len(t)+1) for i in range(len(s)+1)]
#dp[i+1][j+1]sのi文字目までとtのj文字目までを比較したときのLCS
for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j]+1
        else:
            dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j])

i = len(s)-1
j = len(t)-1
ans = ''
while j>= 0 and i >= 0:
    if dp[i][j+1] == dp[i+1][j+1]:i-= 1
    elif dp[i+1][j] == dp[i+1][j+1] :j-= 1
    else:
        ans = s[i] + ans
        i -= 1
        j -= 1
        
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
n  =len(s)
res = 0
ans = 0
for i in range(n):
    if s[i] == 'B':
        res+=1AC
    else:
        ans+=res


print(ans)

Fixed submission:
s = input()
n  =len(s)
res = 0
ans = 0
for i in range(n):
    if s[i] == 'B':
        res+=1
    else:
        ans+=res


print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
v = list(map(int,input().split()))
a = []
b = []
for i in range(0,n,2):
    a.append(v[i])
    b.append(v[i+1])
a = Counter(a)
b = Counter(b)
p = a.most_common()[0][1]
q = b.most_common()[0][1]

if a.most_common()[0][0] == b.most_common()[0][0]:
    if p == n//2:
        if q == n//2:
            print(n-p-q+n//2)
        else:
            print(n-p-q+(n//2-b.most_common[1][1]))
    else:
        if q != n//2:
            print(n-p-q+n-a.most_common[1][1]-b.most_common[1][1])
        else:
            print(n-p-q+(n//2-a.most_common[1][1]))
            
    
        
            
        

else:
    print(n-p-q)



Fixed submission:
from collections import Counter
n = int(input())
v = list(map(int,input().split()))
a = []
b = []
for i in range(0,n,2):
    a.append(v[i])
    b.append(v[i+1])
a = Counter(a)
b = Counter(b)
p = a.most_common()[0][1]
q = b.most_common()[0][1]

if a.most_common()[0][0] == b.most_common()[0][0]:
    if p == n//2:
        if q == n//2:
            print(n-p-q+n//2)
        else:
            print(n-q-b.most_common()[1][1])
    else:
        if q != n//2:
            
            print(min(n-p-b.most_common()[1][1],n-q-a.most_common()[1][1]))
        else:
            print(n-q-a.most_common()[1][1])
            
    
        
            
        

else:
    print(n-p-q)
Buggy python submission (verdict: Runtime Error):
print(2*(m-1)*(n-d)/n/n if m > 0 else (m-1)/n)

Fixed submission:
n,m,d = map(int,input().split())
print(2*(m-1)*(n-d)/n/n if d > 0 else (m-1)/n)
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = 10**9
def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)
for a in range(1,n//2+3):
    b = n-a
    
    ans = min(digitSum(a)+digitSum(b),ans)
print(ans)

Fixed submission:
n = int(input())
ans = 10**9
def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)
for a in range(1,n//2+3):
    b = n-a
    if a>=1 and b>=1:
        
        ans = min(digitSum(a)+digitSum(b),ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
    a,b,k = map(int,input().split())
    ans = []
    for i in range(k):
        if a+i not in ans and a+i <=b:ans.append(a+i)
        if b-i not in ans and b-i >=a:ans.append(b-i)
    ans.sort()
    print(*ans)

Fixed submission:
a,b,k = map(int,input().split())
ans = []
for i in range(k):
    if a+i not in ans and a+i <=b:ans.append(a+i)
    if b-i not in ans and b-i >=a:ans.append(b-i)
ans.sort()
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,k = map(int,input().split())
ans = []
for i in range(a,b+1):
    
    if i <= a+k-1 or i >= b-k+1:ans.append(i)
print(*ans)

Fixed submission:
a,b,k = map(int,input().split())
ans = []
for i in range(k):
    if a+i not in ans and a+i <=b:ans.append(a+i)
    if b-i not in ans and b-i >=a:ans.append(b-i)
ans.sort()
print(*ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
if n < m:
    print('NO')
    exit(0)
dcnt = {}
for x in d:dcnt[x] = 0
ok = True
for x in d:dcnt[x]+=1
for i in range(m):
    if t[i] not in dcnt:ok = False
    if dcnt[t[i]] == 0:ok = False
    dcnt[t[i]] -= 1
if ok: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()))
if n < m:
    print('NO')
    exit(0)
dcnt = {}
for x in d:dcnt[x] = 0
ok = True
for x in d:dcnt[x]+=1
for i in range(m):
    if t[i] not in dcnt:
        ok = False
        break
    if dcnt[t[i]] == 0:
        ok = False
        break
    dcnt[t[i]] -= 1
if ok:print('YES')
else:print('NO')

Buggy python submission (verdict: Runtime Error):
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
if n < m:
    print('NO')
    exit(0)
dcnt = {}
for x in d:dcnt[x] = 0
ok = True
for x in d:dcnt[x]+=1
for i in range(m):
    if dcnt[t[i]] == 0:ok = False
    dcnt[t[i]] -= 1
if ok: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()))
if n < m:
    print('NO')
    exit(0)
dcnt = {}
for x in d:dcnt[x] = 0
ok = True
for x in d:dcnt[x]+=1
for i in range(m):
    if t[i] not in dcnt:
        ok = False
        break
    if dcnt[t[i]] == 0:
        ok = False
        break
    dcnt[t[i]] -= 1
if ok:print('YES')
else:print('NO')
Buggy python submission (verdict: Runtime Error):
a,b,c,d,e,f = map(int,input().split())
X = []
Y = []
res = 0
for i in range(f+1):
    for j in range(f+1):
        x = 100*a*i+100*b*j
        y = c*i+d*j
        if x > f and y > f:break
        X.append(x)
        Y.append(y)
def ok(x,y):
    return (x//100)*e >= y and x+y <=f
cnt = 0
X.sort()
Y.sort()
for x in X:
    for y in Y:
        if x+y > f:break
        
        if ok(x,y):
          
            if x+y == 0:continue
            if res < 100*y/(x+y):
                res = 100*y/(x+y)
                ansx = x
                ansy = y
        cnt +=1
print(ansx+ansy,ansy)


Fixed submission:
a,b,c,d,e,f = map(int,input().split())
X = []
Y = []
res = 0
for i in range(f+1):
    for j in range(f+1):
        x = 100*a*i+100*b*j
        y = c*i+d*j
        if x > f and y > f:break
        X.append(x)
        Y.append(y)
def ok(x,y):
    return (x//100)*e >= y and x+y <=f
cnt = 0
X.sort()
Y.sort()
ansx = 0
ansy = 0
for x in X:
    for y in Y:
        if x+y > f:break
        
        if ok(x,y):
          
            if x+y == 0:continue
            if res <= 100*y/(x+y):
                res = 100*y/(x+y)
                ansx = x
                ansy = y
        cnt +=1
print(ansx+ansy,ansy)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
amin = min(a)
amax = max(a)
ans = 0
for x in range(amin,amax+1):
	    p = 0
	    p += a.count(x)
	    p += a.count(x+2)
	    p += a.count(x+1)
	    ans = max(ans,p)
print(ans)


Fixed submission:
import collections
n = int(input())
a = list(map(int,input().split()))
c = dict(collections.Counter(a))
c = dict(sorted(c.items(),key = lambda x:x[0]))

ans = 0
for i in range(1,10**5):
  cnt = 0
  try:
    cnt += c[i-1]
  except KeyError:
    pass
  
  try:
    cnt += c[i]
  except KeyError:
    pass
    
  try:
    cnt += c[i+1]
  except KeyError:
    pass
    
  ans = max(ans,cnt)  
  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
amin = min(a)
amax = max(a)
ans = 0
for x in range(amin,amax+1):
	    p = 0
	    p += a.count(x)
	    p += a.count(x+2)
	    p += a.count(x+1)
	    ans = max(ans,p)
print(ans)

Fixed submission:
import collections
n = int(input())
a = list(map(int,input().split()))
c = dict(collections.Counter(a))
c = dict(sorted(c.items(),key = lambda x:x[0]))

ans = 0
for i in range(1,10**5):
  cnt = 0
  try:
    cnt += c[i-1]
  except KeyError:
    pass
  
  try:
    cnt += c[i]
  except KeyError:
    pass
    
  try:
    cnt += c[i+1]
  except KeyError:
    pass
    
  ans = max(ans,cnt)  
  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
amin = min(a)
amax = max(a)
ans = 0
for x in range(amin,amax+1):
	    p = 0
	    p += a.count(x)
	    p += a.count(x+2)
	    p += a.count(x+1)
	    ans = max(ans,p)
print(ans)

Fixed submission:
import collections
n = int(input())
a = list(map(int,input().split()))
c = dict(collections.Counter(a))
c = dict(sorted(c.items(),key = lambda x:x[0]))

ans = 0
for i in range(1,10**5):
  cnt = 0
  try:
    cnt += c[i-1]
  except KeyError:
    pass
  
  try:
    cnt += c[i]
  except KeyError:
    pass
    
  try:
    cnt += c[i+1]
  except KeyError:
    pass
    
  ans = max(ans,cnt)  
  
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ki = [[] for _ in range(n)]
dlist = [[0]*n for _ in range(n)]
dist = [0]*n
for i in range(n-1):
    a,b,c  = map(int,input().split())
    a -= 1
    b -= 1
    ki[a].append(b)
    ki[b].append(a)
    dlist[a][b] = dlist[b][a] = c
q,k = map(int,input().split())
k -= 1
def dfs(now,last = -1):
    for next in ki[now]:
        if next == last:continue
        dist[next] = dist[now] + dlist[now][next]
        dfs(next,now)
dfs(k)
for i in range(q):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    print(dist[x]+dist[y])

Fixed submission:
# solution

data=int(input())

abc=[list(map(int,input().split())) for _ in [0]*(data-1)]

q,k=map(int,input().split())

array1=[list(map(int,input().split())) for _ in [0]*q]

k-=1

tree=[[] for _ in [0]*data]

dist=[-1]*data

dist[k]=0

[tree[a-1].append([b-1,c]) for a,b,c in abc]

[tree[b-1].append([a-1,c]) for a,b,c in abc]

q=[k]

while(q):
	qq=[]
	for i in q:
		for j,k in tree[i]:
			if dist[j]<0:
				dist[j]=dist[i]+k
				qq.append(j)
	q=qq

for x,y in array1:
	print(dist[x-1]+dist[y-1])
Buggy python submission (verdict: Runtime Error):
    n = int(input())
    a = list(map(int,input().split()))
    red = 0
    ans = 0
    cnt = [0]*10
    for x in a:
        if x < 3200:
            cnt[x//400] +=1
        else:
            red+=1
    for x in cnt:
        if x >0:ans+=1

    if red == n:ans = 1
    print(ans)
    ans+=red
    print(ans)



Fixed submission:
n = int(input())
a = list(map(int,input().split()))
red = 0
ans = 0
cnt = [0]*10
for x in a:
    if x < 3200:
        cnt[x//400] +=1
    else:
        red+=1
for x in cnt:
    if x >0:ans+=1

if red == n:print(1)
else:print(ans)
ans+=red
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
t = list(map(int,input().split()))
m = int(input())
res = sum(t)
px = [list(map(int,input().split()))for _ in range(m)]
for i in range(m):
    p = px[i][0]-1
    x = px[i][1]
    ans = res -t[i]+x
    print(ans)
    

Fixed submission:
n = int(input())
t = list(map(int,input().split()))
m = int(input())
res = sum(t)
px = [list(map(int,input().split()))for _ in range(m)]
for i in range(m):
    p = px[i][0]-1
    x = px[i][1]
    ans = res -t[p]+x
    print(ans)