Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math
import heapq
def dijkstra(s,m,n):
    visited=[0]*n
    d=[float("inf")]*n
    d[s]=0
    while True:
        mincost=float("inf")
        for i in xrange(n):
            if visited[i]!=2 and d[i]<mincost:
                mincost=d[i]
                u=i
        if mincost==float("inf"):
            break
        visited[u]=2
        for v in xrange(n):
            if visited[v]!=2:
                if d[u]+m[u][v]<d[v]:
                    d[v]=d[u]+m[u][v]
                    visited[v]=1
    return d

def main():
    xs,ys,xt,yt=map(int,raw_input().split())
    n=int(raw_input())
    c=[[xs,ys,0]]+[map(int,raw_input().split()) for _ in xrange(n)]+[[xt,yt,0]]
    dist=[[float("inf")]*(n+2) for _ in xrange(n+2)]
    for i in xrange(n+2):
        for j in xrange(n+2):
            if i==j:continue
            dist[i][j]=min(dist[i][j],dist[j][i],max(math.sqrt(abs(c[i][0]-c[j][0])**2+abs(c[i][1]-c[j][1])**2)-c[i][2]-c[j][2],0))
            dist[j][i]=dist[i][j]
    ans=dijkstra(0,dist,n+2)
    print(ans[n+1])
main()


Fixed submission:
n,x=map(int,raw_input().split())
a=map(int,raw_input().split())
ans=0
if a[0]+a[1]>x:
    ans+=a[0]+a[1]-x
    a[1]=max(a[1]-ans,0)
for i in xrange(1,n-1):
    if a[i]+a[i+1]>x:
        ans+=a[i]+a[i+1]-x
        tmp=a[i]+a[i+1]-x
        a[i+1]=max(a[i+1]-tmp,0)

print(ans)

Buggy python submission (verdict: Runtime Error):
import math
def dis(x1,y1,r1,x2,y2,r2):
    if math.sqrt(abs(x1-x2)**2+abs(y1-y2)**2)>r1+r2:
        return  math.sqrt(abs(x1-x2)**2+abs(y1-y2)**2)-r1-r2
    else:
        return 0
import heapq

def dijkstra(s,g,c,n):
    d=[float('inf')]*n
    d[s]=0
    pq=[]
    heapq.heappush(pq,[0,s])
    while len(pq)!=0:
        t,u=heapq.heappop(pq)
        if d[u]<t:
            continue
        for v in g[u]:
            if d[u]+c[u][v]<d[v]:
                d[v]=d[u]+c[u][v]
                heapq.heappush(pq,[d[v],v])
    return d
def main():
    xs,ys,xt,yt=map(int,raw_input().split())
    n=int(raw_input())
    c=[[xs,ys,0]]+[map(int,raw_input().split()) for _ in xrange(n)]+[[xt,yt,0]]
    g=[[] for _ in xrange(n+2)]
    dist=[[float("inf")]*(n+2) for _ in xrange(n+2)]
    for i in xrange(n+2):
        for j in xrange(n+2):
            if i==j:continue
            g[i].append(j)
            dist[i][j]=min(dist[i][j],dis(c[i][0],c[i][1],c[i][2],c[j][0],c[j][1],c[j][2]))
    ans=dijkstra(0,g,dist,n+2)
    print(ans[n+1])
main()

Fixed submission:
n,x=map(int,raw_input().split())
a=map(int,raw_input().split())
ans=0
if a[0]+a[1]>x:
    ans+=a[0]+a[1]-x
    a[1]=max(a[1]-ans,0)
for i in xrange(1,n-1):
    if a[i]+a[i+1]>x:
        ans+=a[i]+a[i+1]-x
        tmp=a[i]+a[i+1]-x
        a[i+1]=max(a[i+1]-tmp,0)

print(ans)
Buggy python submission (verdict: Runtime Error):
 n,q=map(int,raw_input().split())
exist=set([1])
cup=range(n+2)
now=1
exist.add(cup[now-1])
exist.add(cup[now+1])
for i in xrange(q):
    a,b=map(int,raw_input().split())
    if now==a:now=b
    elif now==b:now=a
    tmp=cup[a]
    cup[a]=cup[b]
    cup[b]=tmp
    exist.add(cup[now-1])
    exist.add(cup[now+1])
exist.add(now-1)
exist.add(now+1)
exist=list(exist)
ans=0
for i in xrange(len(exist)):
    if exist[i]!=0 and exist[i]!=n+1:ans+=1
print ans

Fixed submission:
n,q=map(int,raw_input().split())
exist=set([1])
cup=range(n+2)
now=1
exist.add(cup[now-1])
exist.add(cup[now+1])
for i in xrange(q):
    a,b=map(int,raw_input().split())
    if now==a:now=b
    elif now==b:now=a
    tmp=cup[a]
    cup[a]=cup[b]
    cup[b]=tmp
    exist.add(cup[now-1])
    exist.add(cup[now+1])
exist=list(exist)
ans=0
for i in xrange(len(exist)):
    if exist[i]!=0 and exist[i]!=n+1:ans+=1
print ans
Buggy python submission (verdict: Runtime Error):
mod=10**9+7
n,k=map(int,raw_input().split())
a=map(int,raw_input().split())
dp=[[[0]*(1<<8) for _ in xrange(n+1)] for _ in xrange(n+1)]
for i in xrange(n):
    dp[i+1][1][a[i]]=1
for i in xrange(n):
    for j in xrange(n):
        for l in xrange(1<<8):
            dp[i+1][j+1][a[i]^l]+=(j+1)*dp[i][j][l]%mod
            dp[i+1][j][l]+=dp[i][j][l]%mod
ans=0
for j in xrange(1,n+1):
    ans=(ans+dp[n][j][k])%mod
print(ans)

Fixed submission:
mod=11
n,k=map(int,raw_input().split())
k=(k-8)%mod
last=7*n-7*2-2
idx=-1
for i in xrange(1,last+1):
    if 3*(i+i+1+i+2)%mod==k:
        idx=i
        break
r2idx=r1idx=-1
for i in xrange(1,n+1):
    if (7*i-1-idx)%11==0:
        r2idx=7*i-1
        break
for i in xrange(1,n+1):
    if (7*i-idx)%11==0:
        r1idx=7*i
        break
if idx==-1:
    print(0)
    exit()
if r1idx==-1:
    if r2idx==-1:
        print((last-idx)/11+1)
    else:
        print((last-idx)/11+1-(last-r2idx)/(7*11)-1)
else:
    if r2idx==-1:
        print((last-idx)/11+1-(last-r1idx)/(7*11)-1)
    else:
        print((last-idx)/11+1-(last-r2idx)/(7*11)-1-(last-r1idx)/(7*11)-1)

#print r1idx,r2idx,idx
#print((last-idx)/11+1-(last-r2idx)/(n*11)-1-(last-r1idx)/(n*11)-1)
Buggy python submission (verdict: Time Limit Exceeded):
mod=10**9+7
n,k=map(int,raw_input().split())
a=map(int,raw_input().split())
dp=[[[0]*(1<<8) for _ in xrange(n+1)] for _ in xrange(n+1)]
for i in xrange(n):
    dp[i+1][1][a[i]]=1
for i in xrange(n):
    for j in xrange(n):
        for l in xrange(1<<8):
            dp[i+1][j+1][a[i]^l]+=(j+1)*dp[i][j][l]%mod
            dp[i+1][j][l]+=dp[i][j][l]%mod
ans=0
for j in xrange(1,n+1):
    ans=(ans+dp[n][j][k])%mod
print(ans)

Fixed submission:
mod=10**9+7
n,k=map(int,raw_input().split())
a=map(int,raw_input().split())
dp=[[[0]*(1<<8) for _ in xrange(n+1)] for _ in xrange(n+1)]
for i in xrange(n):
    dp[i+1][1][a[i]]=1
for i in xrange(n):
    for j in xrange(n):
        for l in xrange(1<<8):
            dp[i+1][j+1][a[i]^l]+=(j+1)*dp[i][j][l]%mod
            dp[i+1][j][l]+=dp[i][j][l]%mod
ans=0
for j in xrange(1,n+1):
    ans=(ans+dp[n][j][k])%mod
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(raw_input())
p=map(lambda x:int(x)-1,raw_input().split())
a=range(1,n+1)
b=range(n,0,-1)
for i in xrange(1,n):
    if p[i]>p[i-1]:
        diff=abs(a[p[i]]+b[p[i]]-(a[p[i-1]]+b[p[i-1]]))
        for j in xrange(p[i],n):
            a[j]=a[j]+diff+1
    else:
        diff=abs(a[p[i]]+b[p[i]]-(a[p[i-1]]+b[p[i-1]]))
        for j in xrange(p[i],-1,-1):
            b[j]=b[j]+diff+1
print(" ".join(map(str,a)))
print(" ".join(map(str,b)))

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

def check(y,x):
    if 0<=y<=h-1 and 0<=x<=w-1:
        if g[y][x]=="#":
            return True
    return False

def dfs(y,x):
    dx=(0,1)
    dy=(1,0)
    if y==h-1 and x==w-1:
        return True
    for i in xrange(2):
        nxy=y+dy[i]
        nxx=x+dx[i]
        if check(nxy,nxx) and not visited[nxy][nxx]:
            visited[nxy][nxx]=True
            if dfs(nxy,nxx):
                return True
            visited[nxy][nxx]=False
    return False

h,w=map(int,raw_input().split())
g=[raw_input() for _ in xrange(h)]
visited=[[False]*w for _ in xrange(h)]
visited[0][0]=True
if not dfs(0,0):
    print("Impossible")
    exit()
for i in xrange(h):
    for j in xrange(w):
        if g[i][j]=="#" and not visited[i][j]:
            print("Impossible")
            exit()
print("Possible")
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**8)


class Segtree():
    INT_MIN=-10**9

    def __init__(self,size):
        self.size=1
        while self.size<size:
            self.size=self.size*2
        self.node=[self.INT_MIN]*(2*self.size-1)


    def update(self,k,a):
        k+=self.size-1
        self.node[k]=a
        while k>0:
            k=(k-1)/2
            self.node[k]=max(self.node[k*2+1],self.node[k*2+2])

    def get_max(self,queryL,queryR,k=0,nodeL=0,nodeR=-1):
        if nodeR==-1:nodeR=self.size
        if (nodeR<=queryL or queryR<=nodeL):return self.INT_MIN
        if (queryL<=nodeL and nodeR<=queryR):return self.node[k]
        else:
            nodeM=(nodeL+nodeR)/2
            vl=self.get_max(queryL,queryR,k*2+1,nodeL,nodeM)
            vr=self.get_max(queryL,queryR,k*2+2,nodeM,nodeR)
            return max(vl,vr)

n,t=map(int,raw_input().split())
a=map(int,raw_input().split())
seg=Segtree(n)
for i in xrange(n):
    seg.update(i,a[i])
ans=0
mx=0
for i in xrange(n):
    tmp=seg.get_max(i,n)-a[i]
    if mx<tmp:
        ans=1
        mx=tmp
    elif mx==tmp:
        ans+=1
print ans


Fixed submission:
s=raw_input()
l=0
r=len(s)-1

news=""
i=0
while i<len(s):
    if s[i]=="W":
        while i<len(s) and s[i]=="W":
            i+=1
        news+=s[i-1]
    else:
        while i<len(s) and s[i]=="B":
            i+=1
        news+=s[i-1]
print(len(news)-1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**8)


class Segtree():
    INT_MIN=-10**9

    def __init__(self,size):
        self.size=1
        while self.size<size:
            self.size=self.size*2
        self.node=[self.INT_MIN]*(2*self.size-1)


    def update(self,k,a):
        k+=self.size-1
        self.node[k]=a
        while k>0:
            k=(k-1)/2
            self.node[k]=max(self.node[k*2+1],self.node[k*2+2])

    def get_max(self,queryL,queryR,k=0,nodeL=0,nodeR=-1):
        if nodeR==-1:nodeR=self.size
        if (nodeR<=queryL or queryR<=nodeL):return self.INT_MIN
        if (queryL<=nodeL and nodeR<=queryR):return self.node[k]
        else:
            nodeM=(nodeL+nodeR)/2
            vl=self.get_max(queryL,queryR,k*2+1,nodeL,nodeM)
            vr=self.get_max(queryL,queryR,k*2+2,nodeM,nodeR)
            return max(vl,vr)
            
n,t=map(int,raw_input().split())
a=map(int,raw_input().split())
seg=Segtree(n)
for i in xrange(n):
    seg.update(i,a[i])
ans=0
mx=0
for i in xrange(n):
    tmp=seg.get_max(i,n)-a[i]
    if mx<tmp:
        ans=1
        mx=tmp
    elif mx==tmp:
        ans+=1
print ans


Fixed submission:
n,t=map(int,raw_input().split())
a=map(int,raw_input().split())
now=a[0]
cnt=[]
for i in xrange(1,n):
    if now<a[i]:
        cnt.append(a[i]-now)
    else:
        now=a[i]
print(cnt.count(max(cnt)))
Buggy python submission (verdict: Runtime Error):
mod=10**9+7
n=int(raw_input())
t=map(int,raw_input().split())
a=map(int,raw_input().split())

if t[n-1]!=a[0]:
    print(0)
    exit()

ans=1
for i in xrange(n):
    if i==0 or i==n-1 or t[i]>t[i-1]:
        if a[i]<t[i] and a[i]==a[i+1]:
            print(0)
            exit()
        elif a[i]!=t[i] and a[i]!=a[i+1]:
            print(0)
            exit()
        continue
    else:
        if t[i]==a[i]:
            if a[i]==a[i+1]:
                ans=(ans*t[i])%mod
        elif t[i]>a[i]:
            if a[i]==a[i+1]:
                ans=(ans*a[i])%mod
        elif a[i]>t[i]:
            if a[i]==a[i+1]:
                ans=(ans*t[i])%mod
            else:
                print(0)
                exit()
print(ans%mod)

Fixed submission:
mod=10**9+7
n=int(raw_input())
t=map(int,raw_input().split())
a=map(int,raw_input().split())

if t[n-1]!=a[0]:
    print(0)
    exit()

ans=1
for i in xrange(n):
    if i==0 or i==n-1:
        continue
    elif t[i]>t[i-1]:
        if a[i]<t[i] and a[i]==a[i+1]:
            print(0)
            exit()
        elif a[i]!=t[i] and a[i]!=a[i+1]:
            print(0)
            exit()
    else:
        if t[i]==a[i]:
            if a[i]==a[i+1]:
                ans=(ans*t[i])%mod
        elif t[i]>a[i]:
            if a[i]==a[i+1]:
                ans=(ans*a[i])%mod
        elif a[i]>t[i]:
            if a[i]==a[i+1]:
                ans=(ans*t[i])%mod
            else:
                print(0)
                exit()
print(ans%mod)
Buggy python submission (verdict: Time Limit Exceeded):
s=raw_input()
while True:
    f=0
    for i in xrange(len(s)-1):
        if s[i]=="S" and s[i+1]=="T":
            s=s[0:i]+s[i+2:len(s)]
            f=1
            break
    if f==0:
        break
print(len(s))

Fixed submission:
s=raw_input()
stack=[]
for i in xrange(len(s)):
    if len(stack)==0 or s[i]=="S":
        stack.append(s[i])
        continue
    if s[i]=="T":
        if stack[-1]=="S":
            stack.pop()
        else:
            stack.append(s[i])
print(len(stack))
Buggy python submission (verdict: Time Limit Exceeded):
n,x=map(int,raw_input().split())
a=map(int,raw_input().split())
s=[[10**12]*n for _ in xrange(n)]
for i in xrange(n):
    for j in xrange(n):
        if j==0:s[i][j]=a[i]
        else:s[i][j]=min(s[i][j-1],a[(i-j)%n])
ans=10**12
for j in xrange(n):
    tmp=x*j
    for i in xrange(n):
        tmp+=s[i][j]
    ans=min(ans,tmp)
print ans


Fixed submission:
n,x=map(int,raw_input().split())
a=map(int,raw_input().split())
s=[[10**12]*n for _ in xrange(n)]
for i in xrange(n):
    for j in xrange(n):
        if j==0:s[i][j]=a[i]
        else:s[i][j]=min(s[i][j-1],a[(i-j)%n])
ans=float("inf")
for j in xrange(n):
    tmp=x*j
    for i in xrange(n):
        tmp+=s[i][j]
    ans=min(ans,tmp)
print ans
Buggy python submission (verdict: Runtime Error):
    s=raw_input()
    n=False
    e=False
    w=False
    ss=False
    for i in xrange(len(s)):
        if s[i]=="N":n=True
        elif s[i]=="E":e=True
        elif s[i]=="W":w=True
        else:ss=True
    if (n and ss) or (e and w):
        print("Yes")
    else:
        if not n and not ss and not e and not w:
            print("Yes")
        else:
            print("No")


Fixed submission:
s=raw_input()
n=False
e=False
w=False
ss=False
for i in xrange(len(s)):
    if s[i]=="N":n=True
    elif s[i]=="E":e=True
    elif s[i]=="W":w=True
    else:ss=True
if (n+ss)%2==0 and (e+w)%2==0:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
s=raw_input()
n=False
e=False
w=False
ss=False
for i in xrange(n):
    if s[i]=="N":n=True
    elif s[i]=="E":e=True
    elif s[i]=="W":w=True
    else:ss=True
if (n and ss) or (e and w):
    print("Yes")
else:
    if not n and not ss and not e and not w:
        print("Yes")
    else:
        print("No")

else:
    if not n and not ss and not e and not w:
        print("YES")
    else:
        print("NO")

Fixed submission:
s=raw_input()
n=False
e=False
w=False
ss=False
for i in xrange(len(s)):
    if s[i]=="N":n=True
    elif s[i]=="E":e=True
    elif s[i]=="W":w=True
    else:ss=True
if (n+ss)%2==0 and (e+w)%2==0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())

if N == 1:
    print("Hello World")

elif 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 = int(input())
A = int(input())
B = int(input())

if N == 1:
    print("Hello World")

elif N == 2:
    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 = int(input())

n_letters = str(n)

for i in n_letters:
    if n_letters[i] == "1":
        n_letters[i] = "9"
    elif n_letters[i] == "9":
        n_letters[i] = "1"


Fixed submission:
n = input()
ans = []
for i in range(len(n)):
    if n[i] == '1':
        ans.append('9')
    elif n[i] == '9':
        ans.append('1')

print(''.join(ans))
Buggy python submission (verdict: Runtime Error):
r, D, x = map(int, ainput().split())
for i in range(1, 11):
    x = r * x - D
    print(x)


Fixed submission:
r, D, x = map(int, input().split())
for i in range(1, 11):
    x = r * x - D
    print(x)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))
CB = [0]*(M)
for i in range(M):
    b, c = map(int, input().split())
    CB[i] = (c, b)

A.sort()
CB = list(reversed(sorted(CB)))

ind = 0
for i in range(M):
    (c, b) = CB[i]
    for _ in range(b):
        if ind >= N:
            break
        if A[ind] < c:
            A[ind] = c
            ind += 1
    if ind >= N:
        break

print(sum(A))


Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
CB = [0]*(M)
for i in range(M):
    b, c = map(int, input().split())
    CB[i] = (c, b)

A.sort()
CB = list(reversed(sorted(CB)))

ind = 0
for i in range(M):
    (c, b) = CB[i]
    for _ in range(b):
        if ind >= N:
            break
        if A[ind] < c:
            A[ind] = c
            ind += 1
        else:
            break
    if ind >= N:
        break

print(sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))
CB = [0]*(M)
for i in range(M):
    b, c = map(int, input().split())
    CB[i] = (c, b)

A.sort()
CB = list(reversed(sorted(CB)))

ind = 0
for i in range(M):
    (c, b) = CB[i]
    for _ in range(b):
        if ind >= N:
            break
        if A[ind] < c:
            A[ind] = c
            ind += 1
print(sum(A))


Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
CB = [0]*(M)
for i in range(M):
    b, c = map(int, input().split())
    CB[i] = (c, b)

A.sort()
CB = list(reversed(sorted(CB)))

ind = 0
for i in range(M):
    (c, b) = CB[i]
    for _ in range(b):
        if ind >= N:
            break
        if A[ind] < c:
            A[ind] = c
            ind += 1
        else:
            break
    if ind >= N:
        break

print(sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))
CB = [0]*(M)
for i in range(M):
    b, c = map(int, input().split())
    CB[i] = (c, b)

A.sort()
CB = list(reversed(sorted(CB)))

ind = 0
for i in range(M):
    (c, b) = CB[i]
    for _ in range(b):
        if ind >= N:
            break
        if A[ind] < c:
            A[ind] = c
            ind += 1
print(sum(A))


Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
CB = [0]*(M)
for i in range(M):
    b, c = map(int, input().split())
    CB[i] = (c, b)

A.sort()
CB = list(reversed(sorted(CB)))

ind = 0
for i in range(M):
    (c, b) = CB[i]
    for _ in range(b):
        if ind >= N:
            break
        if A[ind] < c:
            A[ind] = c
            ind += 1
        else:
            break
    if ind >= N:
        break

print(sum(A))
Buggy python submission (verdict: Runtime Error):
from math import gcd

def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]

N = int(input())
A = [0] + list(map(int, input().split()))

toRight = [0]*(N+1)
toRight[1] = A[1]
for i in range(2, N+1):
    toRight[i] = gcd(toRight[i-1], A[i])

toLeft = [0]*(N+1)
toLeft[N] = A[N]
for i in reversed(range(1, N)):
    toLeft[i] = gcd(toLeft[i+1], A[i])
    
ans = max(toRight[-2], toLeft[2])
for i in range(3, N-3 + 1):
    now = gcd(toRight[i-1], toLeft[-i-1])
    ans = max(ans, now)

print(ans)


Fixed submission:
def gcd(a, b):  # a >= b
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]

N = int(input())
A = [0] + list(map(int, input().split()))

toRight = [0]*(N+1)
toRight[1] = A[1]
for i in range(2, N+1):
    toRight[i] = gcd(toRight[i-1], A[i])

toLeft = [0]*(N+1)
toLeft[N] = A[N]
for i in reversed(range(1, N)):
    toLeft[i] = gcd(toLeft[i+1], A[i])

# print(toRight)
# print(toLeft)
    
ans = max(toRight[-2], toLeft[2])
for i in range(2, N-1 + 1):
    now = gcd(toRight[i-1], toLeft[i+1])
    ans = max(ans, now)

print(ans)

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

def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]

N = int(input())
A = [0] + list(map(int, input().split()))

toRight = [0]*(N+1)
toRight[1] = A[1]
for i in range(2, N+1):
    toRight[i] = gcd(toRight[i-1], A[i])

toLeft = [0]*(N+1)
toLeft[N] = A[N]
for i in reversed(range(1, N)):
    toLeft[i] = gcd(toLeft[i+1], A[i])
    
ans = max(toRight[-2], toLeft[2])
for i in range(3, N-3 + 1):
    now = gcd(toRight[i-1], toLeft[-i-1])
    ans = max(ans, now)

print(ans)


Fixed submission:
def gcd(a, b):  # a >= b
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]

N = int(input())
A = [0] + list(map(int, input().split()))

toRight = [0]*(N+1)
toRight[1] = A[1]
for i in range(2, N+1):
    toRight[i] = gcd(toRight[i-1], A[i])

toLeft = [0]*(N+1)
toLeft[N] = A[N]
for i in reversed(range(1, N)):
    toLeft[i] = gcd(toLeft[i+1], A[i])

# print(toRight)
# print(toLeft)
    
ans = max(toRight[-2], toLeft[2])
for i in range(2, N-1 + 1):
    now = gcd(toRight[i-1], toLeft[i+1])
    ans = max(ans, now)

print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=(int(e)*2-1 for e in input()[::2])
print(max(a,b,(a+b)//2+1))

Fixed submission:
a, b = map(int, input().split())
c = max(a,b)
print(c + max(c-1, min(a,b)))
Buggy python submission (verdict: Runtime Error):
def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]

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

def checker(n): # int => int list
    s = format(n, 'b')
    l = len(s)
    res = [0]*l
    for i in range(l):
        if i == l - 1:
            hoge = n // 4
            if n == hoge + 1 or n == hoge + 2:
                res[i] = 1
        else:
            if s[i] == "1":
                res[i] = (int(s[i+1:], 2) + 1) % 2
    return res

a = checker(A-1) if A > 0 else "0"
b = checker(B)

if len(a) < len(b):
    tmp = a
    a = b
    b = tmp

b = [0 for _ in range(len(a) - len(b))] + b

ans = ""
for i in range(len(a)):
    ans += str(a[i] ^ b[i])
ans = int(ans, 2)
print(ans)


Fixed submission:
def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]

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

def checker(n): # int => int list
    s = format(n, 'b')
    l = len(s)
    res = [0]*l
    for i in range(l):
        if i == l - 1:
            hoge = n // 4
            if n == hoge * 4 + 1 or n == hoge * 4 + 2:
                res[i] = 1
        else:
            if s[i] == "1":
                res[i] = (int(s[i+1:], 2) + 1) % 2
    return res

a = checker(A-1) if A > 0 else [0]
b = checker(B)

if len(a) < len(b):
    tmp = a
    a = b
    b = tmp

b = [0 for _ in range(len(a) - len(b))] + b

ans = ""
for i in range(len(a)):
    ans += str(a[i] ^ b[i])
ans = int(ans, 2)
print(ans)

Buggy python submission (verdict: Runtime Error):
def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]

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

def checker(n): # int => int list
    s = format(n, 'b')
    l = len(s)
    res = [0]*l
    for i in range(l):
        if i == l - 1:
            hoge = n // 4
            if n == hoge + 1 or n == hoge + 2:
                res[i] = 1
        else:
            if s[i] == "1":
                res[i] = (int(s[i+1:], 2) + 1) % 2
    return res

a = checker(A-1) if A > 0 else "0"
b = checker(B)

if len(a) < len(b):
    tmp = a
    a = b
    b = tmp

b = [0 for _ in range(len(a) - len(b))] + b

ans = ""
for i in range(len(a)):
    ans += str(a[i] | b[i])
ans = int(ans, 2)
print(ans)


Fixed submission:
def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]

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

def checker(n): # int => int list
    s = format(n, 'b')
    l = len(s)
    res = [0]*l
    for i in range(l):
        if i == l - 1:
            hoge = n // 4
            if n == hoge * 4 + 1 or n == hoge * 4 + 2:
                res[i] = 1
        else:
            if s[i] == "1":
                res[i] = (int(s[i+1:], 2) + 1) % 2
    return res

a = checker(A-1) if A > 0 else [0]
b = checker(B)

if len(a) < len(b):
    tmp = a
    a = b
    b = tmp

b = [0 for _ in range(len(a) - len(b))] + b

ans = ""
for i in range(len(a)):
    ans += str(a[i] ^ b[i])
ans = int(ans, 2)
print(ans)
Buggy python submission (verdict: Runtime Error):
btc = 380000
N = int(input())
ans = 0
for i in range(N):
    x, u = map(int, input().split())
    if u == "BTC":
        x *= btc
    ans += x
print(ans)

Fixed submission:
btc = 380000
N = int(input())
ans = 0
for i in range(N):
    x, u = input().split()
    x = float(x)
    if u == "BTC":
        x *= btc
    ans += x
print(ans)