Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, M = list(map(int, input().split(' ')))
    s = M // N
    r = M % N
    while True:
        if r%s == 0:
            print(s)
            break
        if s > r:
            a = (s-r)//N
        else:
            a = 1
        if a == 0:
            a = 1
        s -= a
        r += a*N



if __name__ == '__main__':
    main()

Fixed submission:
import math

def main():
    N, M = list(map(int, input().split(' ')))
    s = min(math.ceil(math.sqrt(M)), M//N)
    ret = []
    while s > 0:
        if M%s == 0:
            a = M//s
            ret.append(a)
            ret.append(s)
        s -= 1
    print(max([s for s in ret if s <= M//N]))



if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, M = list(map(int, input().split(' ')))
    s = M // N
    r = M % N
    while True:
        if r%s == 0:
            print(s)
            break
        s -= 1
        r = M - s * N


if __name__ == '__main__':
    main()

Fixed submission:
import math

def main():
    N, M = list(map(int, input().split(' ')))
    s = min(math.ceil(math.sqrt(M)), M//N)
    ret = []
    while s > 0:
        if M%s == 0:
            a = M//s
            ret.append(a)
            ret.append(s)
        s -= 1
    print(max([s for s in ret if s <= M//N]))



if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from typing import List
from preconditions import preconditions
import heapq


def solve(N: int, M: int, a: List[int], b: List[int]) -> int:
    q = []
    ret = 0
    conditions = sorted([(b[i], a[i]) for i in range(M)], key = lambda x: x[1])
    ci = 0
    for i in range(N+1):
        while ci < len(conditions) and i == conditions[ci][1]:
            heapq.heappush(q, conditions[ci])
            ci += 1
        if len(q) > 0 and i == q[0][0]-1:
            ret += 1
            q = []
    return ret





def main():
    N, M = list(map(int, input().split(' ')))
    a = []
    b = []
    for i in range(M):
        ai, bi = list(map(int, input().split(' ')))
        a.append(ai)
        b.append(bi)

    print(solve(N, M, a, b))



if __name__ == '__main__':
    main()

Fixed submission:
import heapq


def solve(N, M, a, b):
    q = []
    ret = 0
    conditions = sorted([(b[i], a[i]) for i in range(M)], key = lambda x: x[1])
    ci = 0
    for i in range(N+1):
        while ci < len(conditions) and i == conditions[ci][1]:
            heapq.heappush(q, conditions[ci])
            ci += 1
        if len(q) > 0 and i == q[0][0]-1:
            ret += 1
            q = []
    return ret





def main():
    N, M = list(map(int, input().split(' ')))
    a = []
    b = []
    for i in range(M):
        ai, bi = list(map(int, input().split(' ')))
        a.append(ai)
        b.append(bi)

    print(solve(N, M, a, b))



if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def trim(S, N):
    a = 0
    while S[a] == ")":
        a += 1
    b = N-1
    while S[b] == "(":
        b -= 1
    return a, b


def count(S, a, b):
    i = a
    c = 0
    while i <= b:
        if S[i] == "(":
            c += 1
        else:
            c -= 1
        i += 1
    return c


N = int(input())
S = input()

a, b = trim(S, N)
if a > b:
    print("(" * a + S + ")" * (N-b-1))
else:
    c = count(S, a, b)

    if c > 0:
        print("(" * a + S + ")" * (N-b-1-c))
    else:
        print("(" * (a-c) + S + ")" * (N-b-1))

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

i = 0
c = 0
min_c = 0
while i < N:
    if S[i] == "(":
        c += 1
    else:
        c -= 1
    min_c = min(c, min_c)
    i += 1

print("(" * (-min_c) + S + ")" * (c-min_c))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
b = int(input())

# 奇数か偶数の判断
if (a * b)%2 == 0:
    print('Even')
else:
    print('Odd')

Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
a = list(map(int, input().split()))

# 奇数か偶数の判断
if (a[0] * a[1])%2 == 0:
    print('Even')
else:
    print('Odd')

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
b = int(input())

# 奇数か偶数の判断
if (a * b) % 2 == 0:
    print('Even')
else:
    print('Odd')

Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
a = list(map(int, input().split()))

# 奇数か偶数の判断
if (a[0] * a[1])%2 == 0:
    print('Even')
else:
    print('Odd')

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input(3))
b = int(input(4))

# 奇数か偶数の判断
if (a * b)%2 == 0:
    print('Even')
else:
    print('Odd')

Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
a = list(map(int, input().split()))

# 奇数か偶数の判断
if (a[0] * a[1])%2 == 0:
    print('Even')
else:
    print('Odd')

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
b = int(input())

# 奇数か偶数の判断
if (a * b)%2 == 0:
    print('Even')
else:
    print('Odd')

Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
a = list(map(int, input().split()))

# 奇数か偶数の判断
if (a[0] * a[1])%2 == 0:
    print('Even')
else:
    print('Odd')

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
b = int(input())

# 奇数か偶数の判断
if (a * b)%2 == 0:
    print('Even')
else:
    print('Odd')

Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
a = list(map(int, input().split()))

# 奇数か偶数の判断
if (a[0] * a[1])%2 == 0:
    print('Even')
else:
    print('Odd')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = map(int, input().split())

def how_many_times_divisible(n):
    ans = 0
    while n % 2 == 0:
        n /= 2
        ans += 1
    return ans
 

ans = min(map(how_many_times_divisible, a))
 
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
s = int(input())
t = str(s)
print(t.count('1'))
Buggy python submission (verdict: Runtime Error):
A,B,C = map(int,input().split())
i = 0
while i < C or i < int B/A:
    i += 1
print(i)

Fixed submission:
A,B,C = map(int,input().split())
i = 0
while i < C and i < int(B/A):
    i += 1
print(i)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
KA = list(map(int,input(),split()))

items = set(KA[1:])


for i in range(1,N):
    KA = list(map(int,input().split()))
    items = items & set(KA[1:])

ans = len(items)
print(ans)


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

items = set(KA[1:])


for i in range(1,N):
    KA = list(map(int,input().split()))
    items = items & set(KA[1:])

ans = len(items)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
if N == 1:
    print('Hello World')
else N == 2:
    A = int(input())
    B = int(input())
    print(A+B)

Fixed submission:
N = int(input())
if N == 1:
    print('Hello World')
elif N == 2:
    A = int(input())
    B = int(input())
    print(A+B)
Buggy python submission (verdict: Runtime Error):
n = input
ans = ''
for i in range(len(n)):
    if n[i] == '1':
        ans += '9'
    else :
        ans += '1'
print(ans)

Fixed submission:
n = input()
ans = ''
for i in range(3):
    if n[i] == '1':
        ans += '9'
    else :
        ans += '1'
print(ans)

Buggy python submission (verdict: Runtime Error):
n = input
ans - ''
for i in range(len(n)):
    if n[i] == '1':
        ans += '9'
    else :
        ans += '1'
print(ans)

Fixed submission:
n = input()
ans = ''
for i in range(3):
    if n[i] == '1':
        ans += '9'
    else :
        ans += '1'
print(ans)

Buggy python submission (verdict: Runtime Error):
n = input
ans - ''
for i in range(len(n)):
    if n[i] == '1':
        ans += '9'
    else ans += '1'
print(ans)

Fixed submission:
n = input()
ans = ''
for i in range(3):
    if n[i] == '1':
        ans += '9'
    else :
        ans += '1'
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

N,X = map(int,input().split())
x = list(map(int,input().split()))
if N == 1:
    print(abs(x[0] - X))
else:
    xlen = [abs(x[0]-X)]
    for i in range(N-1):
        xlen.append(x[i+1]- x[i])
    ans = xlen[0]
    for i in range(N-2):
        ans = math.gcd(ans,xlen[i+1])
    print(ans)

Fixed submission:
num = list(map(int,input().split()))
num.sort()
ans = num[2]*10 + num[1] + num[0]
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

N,X = map(int,input().split())
x = list(map(int,input().split()))
if N == 1:
    print(abs(x[0] - X))
else:
    xlen = [abs(x[0]-X)]
    for i in range(N-1):
        xlen.append(x[i+1]- x[i])
    ans = xlen[0]
    for i in range(N-2):
        ans = math.gcd(ans,xlen[i+1])
    print(ans)

Fixed submission:
A,B = map(int,input().split())
if A != 2 and B != 2:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
x = list(map(int,input().split()))

ans = sum([abs(i) for i in x])
for i in range(N - K + 1):
    t = min(abs(x[i])+abs(x[i+K-1] - x[i]),abs(x[i+K-1]+abs(x[i+K-1]-x[i]))
    if t < ans:
        ans = t:

print(ans)

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

min_t = 10e9
for i in range(N - K + 1):
    e = i + K - 1
    l = min(x[i], 0)
    r = max(x[e], 0)

    t = min(-l, r) * 2 + max(-l, r)
    min_t = min(min_t, t)

print(min_t)
Buggy python submission (verdict: Runtime Error):
D,G = map(int,input().split(' '))
l = [list(map(int,input().split())) for i in range(D)]

ans = 10**8
for i in range(2**D):
    score = 0
    tmp = 0
    n_list = []
    for j in range(D):
        if (i >> j & 1):
            k = l[j]
            score += (j+1)*100*k[0]+k[1]
            tmp += k[0]
        else:
            n_list.append([j+1]+l[j])
    e_flag = False
    for ii in n_list[::-1]:#[1or2or..,times,bonus]
        for jj in range(ii[1]-1):
            if score<G:
                score += ii[0]*100
                tmp += 1
            else:
                e_flag = True
                break
        if e_flag:
            break
    if score<G:
        continue
    ans = min(ans,tmp)
print(ans)

Fixed submission:
r = int(input())
if r < 1200:
    ans = 'ABC'
elif r<2800:
    ans = 'ARC'
else:
    ans = 'AGC'
print(ans)
Buggy python submission (verdict: Runtime Error):
num = list(map(int,input()
.split()))
if num[2] !=100:
    if num[0] == 0:
        ans = num[1]
    elif num[0] == 1:
        ans = num[1]*100
    elif num[0] == 2:
        ans = num[1]*10000
else:
    if num[0] == 0:
        ans = num[1]+1
    elif num[0] == 1:
        ans = num[1]*100+100
    elif num[0] == 2:
        ans = num[1]*10000+10000

print(ans)

Fixed submission:
num = list(map(int,input()
.split()))
if num[1] !=100:
    if num[0] == 0:
        ans = num[1]
    elif num[0] == 1:
        ans = num[1]*100
    elif num[0] == 2:
        ans = num[1]*10000
else:
    if num[0] == 0:
        ans = num[1]+1
    elif num[0] == 1:
        ans = num[1]*100+100
    elif num[0] == 2:
        ans = num[1]*10000+10000

print(ans)

Buggy python submission (verdict: Runtime Error):
num = list(map(int,input()
.split()))
if num[0] == 0:
    ans = num[1]
elif num[0] == 1:
    ans = num[1]*100
elif num[0] == 2:
    ans = num[1]*10000
else :
    
print(ans)

Fixed submission:
num = list(map(int,input()
.split()))
if num[1] !=100:
    if num[0] == 0:
        ans = num[1]
    elif num[0] == 1:
        ans = num[1]*100
    elif num[0] == 2:
        ans = num[1]*10000
else:
    if num[0] == 0:
        ans = num[1]+1
    elif num[0] == 1:
        ans = num[1]*100+100
    elif num[0] == 2:
        ans = num[1]*10000+10000

print(ans)
Buggy python submission (verdict: Runtime Error):
A,B,K=map(int,input().split())
a=0
for i in range(min(A,B)):
    if A%i==0 and B%i==0:
        a+=1
        if a==K:
            print(i)

Fixed submission:
A,B,K=map(int,input().split())
a=0
C=[]
for i in range(1,min(A,B)+1):
    if A%i==0 and B%i==0:
        C.append(i)
print(C[-K])
Buggy python submission (verdict: Runtime Error):
N=int(input())
if N%2==1:
    A=[]
    for i in range(N):
        a,b=map(int,input().split())
        c=a-b
        A.append([a,-b])
    A.sort()
    ao=0
    t=0
    for j in range(N):
        if j%2==0:
            ao+=A[j][0]
        else:
            t+=A[j][1]
    print(ao+t)

Fixed submission:
N,A,B=map(int,input().split())
print(min(A,B),max(A+B-N,0))

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=[]
for i in range(N):
    a,b=map(int,input().split())
    c=a-b
    A.append([a,-b])
A.sort()
ao=0
t=0
for j in range(N):
    if j%2==0:
        ao+=A[j][0]
    else:
        t+=A[j][1]
print(ao+t)


Fixed submission:
N,A,B=map(int,input().split())
print(min(A,B),max(A+B-N,0))

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=[]
for i in range(N):
    a,b=map(int,input().split())
    c=a-b
    A.append([c,-a,-b])
A.sort()
ao=0
t=0
for j in range(N):
    if j%2==0:
        ao+=-1*A[j][1]
    else:
        t+=-1*A[j][2]
print(ao-t)

Fixed submission:
N,A,B=map(int,input().split())
print(min(A,B),max(A+B-N,0))
Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
A=list(map(int,input().split()))
Ae1=[]
Ao1=[]
for i in range(N):
    if A[i]%2==0:
        Ae1.append(A[i])
    else:
        Ao1.append(A[i])
if Ao1!=[]:
    s=0
    Ao=sorted(Ao1,reverse=True)
    i=0
    while i<=len(Ao)-1:
        a=int(math.log2(Ao[i]))
        if 2**(a+1)-Ao[i] in Ao[i:]:
            s+=1
            Ao.remove(2**(a+1)-Ao[i])
            i+=1
        else:
            i+=1
else:
    s=0
if Ae1!=[]:
    t=0
    Ae=sorted(Ae1,reverse=True)
    j=0
    while j<=len(Ae):
        b=int(math.log2(Ae[j]))
        if 2**(a+1)-Ae[j] in Ae[j:]:
            s+=1
            Ae.remove(2**(a+1)-Ae[j])
            j+=1
        else:
            j+=1
else:
    t=0
print(s+t)
        

Fixed submission:
S=input()
a=0
b=0
for i in range(len(S)):
    if S[-i-1]=="B":
        a+=i-b
        b+=1
print(a)

Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
A=list(map(int,input().split()))
A.sort()
s=0
i=1
while i<=len(A)-1:
    a=int(math.log2(A[-i]))
    if 2**(a+1)-A[-i] in A[:-i]:
        s+=1
        A.remove(2**(a+1)-A[-i])
        i+=1
    else:
        i+=1
print(s)

Fixed submission:
S=input()
a=0
b=0
for i in range(len(S)):
    if S[-i-1]=="B":
        a+=i-b
        b+=1
print(a)
Buggy python submission (verdict: Runtime Error):
s=int(input())
t=[]
for i in range(len(s)-2):
  a=s[i:i+2]
  t.append(abs(a-753))
print(min(t))

Fixed submission:
s = input()
ans = 753
for i in range(len(s)):
    tmp = abs(753 - int(s[i:i+3]))
    if tmp < ans:
        ans = tmp
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=input()
a=0
for i in range(1,int(N)+1,2):
    j=str(i)
    if "3"in j and "5"in j and "7"in j:
        if len(j)==j.count("3")+j.count("5")+j.count("7"):
            a+=1
print(a)

Fixed submission:
N = int(input())
def dfs(s):
    if int(s)>N:
        return 0 
    ret = 1 if all(s.count(c)>0 for c in '753') else 0
    for c in '753':
        ret += dfs(s + c)
    return ret
print(dfs('0'))
Buggy python submission (verdict: Runtime Error):
S,K=input().split()
k=int(K)
for i in range(0,k):
    if S[i]!="1":
        print(S[i])
        break
else:
    print("1")


Fixed submission:
S=input()
k=int(input())
for i in range(0,k):
    if S[i]!="1":
        print(S[i])
        break
else:
    print("1")
Buggy python submission (verdict: Runtime Error):
n,m,d=map(int,input().split())
if n-d-1==0:
    ans=(m-1)*(2/n**2)
elif n-2*d<=0:
    ans=(m-1)/(n*2*(n-d-1))
else:
    ans=(m-1)*(2/(n*(n-2*d))+(1/(2*n*d)))
print(ans)

Fixed submission:
n,m,d=map(int,input().split())
if d==0:
    ans=(m-1)/n
else:
    ans=2*(m-1)*(n-d)/(n**2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N=int(input())
S=input()
w=[0]
e=[0]
a=0
b=0
c=N
de=deque(e)
for i in range(len(S)-1):
    if S[i]=="W":
        a+=1   
    w.append(a)
    if S[-(i+1)]=="E":
        b+=1
    de.appendleft(b)
for i in range(N):
    if w[i]+de[i]<c:
        c=w[i]+de[i]
print(c)

Fixed submission:
from collections import deque
N=int(input())
S=input()
w=[0]
e=[0]
a=0
b=0
c=N
for i in range(len(S)-1):
    if S[i]=="W":
        a+=1   
    w.append(a)
    if S[-(i+1)]=="E":
        b+=1
    e.append(b)
for i in range(N):
    d=w[i]+e[-(i+1)]
    if d<c:
        c=d
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
S=int(input())
N=input()
a=S
for i in range(S):
    if i==0:
        if a>N[1:].count("E"):
            a=N[1:].count("E")
    elif i==len(N)-1:
        if a>N[:len(N)].count("W"):
            a=N[:len(N)].count("W")
    else:
        if a>N[:i].count("W")+N[i+1:].count("E"):
            a=N[:i].count("W")+N[i+1:].count("E")
print(a)

Fixed submission:
from collections import deque
N=int(input())
S=input()
w=[0]
e=[0]
a=0
b=0
c=N
for i in range(len(S)-1):
    if S[i]=="W":
        a+=1   
    w.append(a)
    if S[-(i+1)]=="E":
        b+=1
    e.append(b)
for i in range(N):
    d=w[i]+e[-(i+1)]
    if d<c:
        c=d
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N=int(input())
X=list(map(int,input().split()))
Y=sorted(X)
a=Y[N//2]
b=Y[N//2-1]
for i in range(N):
    for j in range(N):
        if X[i]==Y[j]:
            if j<N//2:
                print(a)
                break
            else:
                print(b)
                break

Fixed submission:
from collections import Counter
N=int(input())
X=list(map(int,input().split()))
Y=sorted(X)
a=Y[N//2]
b=Y[N//2-1]
for i in X:
    if i<=b:
        print(a)
    else:
        print(b)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N=int(input())
X=list(map(int,input().split()))
Y=sorted(X)
for i in range(N):
    for j in range(N):
        if X[i]==Y[j]:
            if j<N//2:
                print(Y[N//2])
                break
            else:
                print(Y[N//2-1])
                break

Fixed submission:
from collections import Counter
N=int(input())
X=list(map(int,input().split()))
Y=sorted(X)
a=Y[N//2]
b=Y[N//2-1]
for i in X:
    if i<=b:
        print(a)
    else:
        print(b)
Buggy python submission (verdict: Runtime Error):
S=input()
flag = False
if S=="zyxwvutsrqponmlkjihgfedcba":
    T="-1"
elif len(S)<=25:
    for i in range(97,123):
        if chr(i) not in S:
            T=S+chr(i)
            break
else:
    for i in range(2,26):
        for j in range(ord(S[-i])+1,123):
            if chr(j) not in S[:-i]:
                T=S[:-i]+chr(j)
                flag=True
                break
        if flag:
            break
print(T)

Fixed submission:
S=input()
flag = False
if S=="zyxwvutsrqponmlkjihgfedcba":
    T="-1"
elif len(S)<=25:
    for i in range(97,123):
        if chr(i) not in S:
            T=S+chr(i)
            break
else:
    for i in range(2,27):
        for j in range(ord(S[-i])+1,123):
            if chr(j) not in S[:-i]:
                T=S[:-i]+chr(j)
                flag=True
                break
        if flag:
            break
print(T)
Buggy python submission (verdict: Runtime Error):
A=int(input())
B=list(map(int,input().split()))
a=0
S=0
for i in range(len(B)):
    S+=abs(B[i]-a)
    a=B[i]
S+=abs(B[-1])
for j in range(len(B)):
    if j=0:
        if 0<=B[0]<=B[1] or 0>=B[0]>=B[1]:
            print(S)
        elif B[0]<=0<=B[1] or B[0]>=0>=B[1]:
            print(S-abs(B[0]))
        else:
            print(S-abs(B[1]-B[0]))
    elif j=len(B)-1:
        if 0<=B[-1]<=B[-2] or 0>=B[-1]>=B[-2]:
            print(S)
        elif B[-1]<=0<=B[-2] or B[-1]>=0>=B[-2]:
            print(S-abs(B[-1]))
        else:
            print(S-abs(B[-1]-B[-2]))
    else:
        if B[j-1]<=B[j]<=B[j+1] or B[j-1]>=B[j]>=B[j+1]:
            print(S)
        elif B[j]<=B[j-1]<=B[j+1] or B[j]>=B[j-1]>=B[j+1]:
            print(S-abs(B[j-1]-B[j]))
        else:
            print(S-abs(B[j+1]-B[j]))

Fixed submission:
A=int(input())
B=list(map(int,input().split()))
a=0
S=0
for i in range(len(B)):
    S+=abs(B[i]-a)
    a=B[i]
S+=abs(B[-1])
for j in range(len(B)):
    if j==0:
        if 0<=B[0]<=B[1] or 0>=B[0]>=B[1]:
            print(S)
        elif B[0]<=0<=B[1] or B[0]>=0>=B[1]:
            print(S-2*abs(B[0]))
        else:
            print(S-2*abs(B[1]-B[0]))
    elif j==len(B)-1:
        if 0<=B[-1]<=B[-2] or 0>=B[-1]>=B[-2]:
            print(S)
        elif B[-1]<=0<=B[-2] or B[-1]>=0>=B[-2]:
            print(S-2*abs(B[-1]))
        else:
            print(S-2*abs(B[-1]-B[-2]))
    else:
        if B[j-1]<=B[j]<=B[j+1] or B[j-1]>=B[j]>=B[j+1]:
            print(S)
        elif B[j]<=B[j-1]<=B[j+1] or B[j]>=B[j-1]>=B[j+1]:
            print(S-2*abs(B[j-1]-B[j]))
        else:
            print(S-2*abs(B[j+1]-B[j]))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=2
b=1
c=0
for i in range(N):
  c=a+b
  a=b
  b=c
print(c)

Fixed submission:
n=int(input())
a=2
b=1
c=0
if n==0:
    c=2
elif n==1:
    c=1
else:
    for i in range(n-1):
        c=a+b
        a=b
        b=c
print(c)
Buggy python submission (verdict: Runtime Error):
S=input()
T=input()
j=0
i=-1
flag = False
while i>=-1*len(S)-1+len(T):
    while j>=-1*len(T):
        if i==-1*len(S)-1+len(T):
            A="UNRESTORABLE"
            flag=True
            break
        elif j==-1*len(T):
            if i!=-1:
                P=S.replace(S[i-len(T)+1:i+1],T,1)
                A=P.replace("?","a")
                i=-1*len(S)-1+len(T)
                flag=True
                break
            else:
                P=S.replace(S[i-len(T)+1:],T,1)
                A=P.replace("?","a")
                flag=True
                break
        elif S[i+j]==T[j-1] or S[i+j]=="?":
            j=j-1
        else:
            j=0
            i=i-1
    if flag:
        break
print(A)

Fixed submission:
R=int(input())
G=int(input())
print(2*G-R)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
a=0
for i in range(len(A)):
    if A.count(A[i])+A.count(A[i]-1)+A.count(A[i]+1)>a:
        a=A.count(A[i])+A.count(A[i]-1)+A.count(A[i]+1)
print(a)

Fixed submission:
import collections
N=int(input())
A=list(map(int,input().split()))
B=dict(collections.Counter(A))
a=0
Bk=B.keys()
for i in Bk:
    if i-1 in Bk:
        if i+1 in Bk:
            if a<B[i]+B[i-1]+B[i+1]:
                a=B[i]+B[i-1]+B[i+1]
        else:
            if a<B[i]+B[i-1]:
                a=B[i]+B[i-1]
    elif i+1 in Bk:
        if a<B[i]+B[i+1]:
            a=B[i]+B[i+1]
    else:
        if a<B[i]:
            a=B[i]
print(a)