Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03661 (python)

Fixed submission:
n = int(raw_input())
a = map(int, raw_input().split())
s = [0] * n
s[0] = a[0]
for i in xrange(1, n):
    s[i] += s[i - 1] + a[i]
ans = 10**12
for i in xrange(n - 1):
    ans = min(ans, abs(s[i] - (s[n - 1] - s[i])))
print ans

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**8)

def find_path(now, par):
    if now == n - 1:
        path.append(n - 1)
        return True
    for to in g[now]:
        if to == par: continue
        if find_path(to, now):
            path.append(now)
            return True
    return False

def dfs(now, par, color):
    color[now] = "b"
    for to in g[now]:
        if to == par: continue
        if color[to] == "w": continue
        dfs(to, now, color)

n = int(raw_input())
g = [[] for _ in xrange(n)]
for i in xrange(n - 1):
    a, b = map(int, raw_input().split())
    a -= 1; b -=1
    g[a].append(b)
    g[b].append(a)
path = []
find_path(0, -1)
path.reverse()
color = ["bl"] * n
color[0] = "b"
color[n - 1] = "w"
for i in xrange(1, len(path) - 1):
    v = path[i]
    if i % 2 == 1:
        color[v] = "b"
    else:
        color[v] = "w"
dfs(0, -1, color)
cnt = 0
for i in xrange(n):
    if color[i] == "b":
        cnt += 1
if cnt > n - cnt:
    print "Fennec"
else:
    print "Snuke"
Problem p03733 (python)

Fixed submission:
n,T=map(int,raw_input().split())
t=map(int,raw_input().split())
i=1
now=T
ans=T
while i<n:
    if t[i]+T<now:
        while t[i]+T<now:
            i+=1
    if t[i]>=now:
        now=t[i]+T
        ans+=T
        i+=1
    elif t[i]+T>=now:
        ans+=t[i]+T-now
        now=t[i]+T
        i+=1
print ans

Buggy submission (verdict: Runtime Error):
n=int(raw_input())
xy=[]
for i in xrange(n):
    x,y=map(int,raw_input().split())
    if x>y:x,y=y,x
    xy.append((x,y))
xy.sort()
rmn=10**12;rmx=0;bmn=10**12;bmx=0
for i in xrange(n):
    x,y=xy[i]
    rmn=min(rmn,y)
    rmx=max(rmx,y)
    bmn=min(bmn,x)
    bmx=max(bmx,x)
ans1=(rmx-rmn)*(bmx-bmn)
cntmx=0;cntmn=0
for i in xrange(n):
    x,y=xy[i]
    if rmx==y:cntmx+=1
    if bmn==x:cntmx+=1
if cntmx==1 and cntmn==1 and xy[0][0]==bmn and xy[0][1]==rmx:
    print ans1
    exit()
xy[0]=(xy[0][1],xy[0][0])
xy.sort()
ymn=[10**12]*n
rmn=bmn;bmn=xy[0][0];bmx=xy[n-1][0]
for i in xrange(n):
    x,y=xy[i]
    ymn[i]=min(ymn[max(0,i-1)],y)
ans2=(rmx-rmn)*(bmx-bmn)
for i in xrange(1,n):
    x,y=xy[i]
    if ymn[i]<x:
        break
    bmn=x
    bmx=max(bmx,xy[i-1][1])
    ans2=min(ans2,(rmx-rmn)*(bmx-bmn))
print min(ans1,ans2)
Problem p03746 (python)

Fixed submission:
from collections import deque
from sys import setrecursionlimit
setrecursionlimit(10**6)

def dfs1(now,visited,ans):
    visited[now]=True
    for nx in g[now]:
        if not visited[nx]:
            ans.appendleft(nx)
            dfs1(nx,visited,ans)
            break

def dfs2(now,visited,ans):
    visited[now]=True
    for nx in g[now]:
        if not visited[nx]:
            ans.append(nx)
            dfs2(nx,visited,ans)
            break

n,m=map(int,raw_input().split())
g=[[] for _ in xrange(n)]
for i in xrange(m):
    a,b=map(int,raw_input().split())
    a-=1;b-=1
    g[a].append(b)
    g[b].append(a)
ans=deque([a,b])
visited=[False]*n
visited[a]=True
visited[b]=True
dfs1(a,visited,ans)
dfs2(b,visited,ans)
print len(ans)
for i in xrange(len(ans)):
    print ans[i]+1,
print

Buggy submission (verdict: Runtime Error):
from collections import deque

def dfs1(now,visited,ans):
    visited[now]=True
    for nx in g[now]:
        if not visited[nx]:
            ans.appendleft(nx)
            dfs1(nx,visited,ans)
            break

def dfs2(now,visited,ans):
    visited[now]=True
    for nx in g[now]:
        if not visited[nx]:
            ans.append(nx)
            dfs2(nx,visited,ans)
            break

n,m=map(int,raw_input().split())
g=[[] for _ in xrange(n)]
for i in xrange(m):
    a,b=map(int,raw_input().split())
    a-=1;b-=1
    g[a].append(b)
    g[b].append(a)
ans=deque([a,b])
visited=[False]*n
visited[a]=True
visited[b]=True
dfs1(a,visited,ans)
dfs2(b,visited,ans)
print len(ans)
for i in xrange(len(ans)):
    print ans[i]+1,
print
Problem p03763 (python)

Fixed submission:
n=int(raw_input())
s=[raw_input() for _ in xrange(n)]
cnt=[[0]*26 for _ in xrange(n)]
for i in xrange(n):
    for j in xrange(len(s[i])):
        cnt[i][ord(s[i][j])-ord("a")]+=1
ans=""
for j in xrange(26):
    tmp=10**9
    for i in xrange(n):
        tmp=min(tmp,cnt[i][j])
    ans+=chr(j+ord("a"))*tmp
print ans

Buggy submission (verdict: Runtime Error):
s=raw_input()
t=raw_input()
sb=[0]*(len(s)+1)
tb=[0]*(len(t)+1)
for i in xrange(len(s)):
    if s[i]=="B":
        sb[i+1]+=1
for i in xrange(len(s)):
    sb[i+1]+=sb[i]
for i in xrange(len(t)):
    if t[i]=="B":
        tb[i+1]+=1
for i in xrange(len(t)):
    tb[i+1]+=tb[i]
q=int(raw_input())
for i in xrange(q):
    a,b,c,d=map(int,raw_input().split())
    a-=1;c-=1;
    cnt1=b-a;cnt2=d-c
    cnt1+=sb[b]-sb[a]
    cnt2+=tb[d]-tb[c]
    if abs(cnt1-cnt2)%3==0:
        print("YES")
    else:
        print("NO")
Problem p03777 (python)

Fixed submission:
a,b=raw_input().split()
if (a=='H' and b=='H') or (a=='D' and b=='D'):
    print 'H'
else:
    print 'D'

Buggy submission (verdict: Runtime Error):
a,b=raw_input().split()
if (a=='H' and b='H') or (a=='D' and b=='D'):
    print 'H'
else:
    print 'D'
Problem p03781 (python)

Fixed submission:
x=int(raw_input())
ans=0
su=0
while su<x:
    ans+=1
    su+=ans
print ans

Buggy submission (verdict: Runtime Error):
n,k=map(int,raw_input().split())
a=map(int,raw_input().split())
a.sort()
used=[False]*n
idx=n-1
cnt=0
while True:
    if idx-cnt<0:
        break
    tmp=sum(a[idx-cnt:idx+1])
    if tmp<k:
        cnt+=1
        continue
    for i in xrange(idx-cnt,idx+1):
        used[i]=True
    tmp-=a[idx-cnt]
    for i in xrange(idx-cnt-1,-1,-1):
        if tmp+a[i]>=k:
            used[i]=True
        else:
            break
    idx-=1
    cnt=0
ans=0
for i in xrange(n):
    if not used[i]:
        ans+=1
print ans
Problem p03813 (python)

Fixed submission:
x=input()
if x<1200:
    print("ABC")
else:
    print("ARC")

Buggy submission (verdict: Runtime Error):
s=raw_input()
n=len(s)
for i in xrange(n):
    if s[i]=="a":
        idx1=i
        break    
for i in xrange(n-1,0,-1):
    if s[i]=="z":
        idx2=i
        break
print idx2-idx1+1
Problem p03827 (python)

Fixed submission:
n=int(raw_input())
s=raw_input()
ans=0;cnt=0
for i in xrange(n):
    if s[i]=="I":
        cnt+=1
        ans=max(ans,cnt)
    elif s[i]=="D":
        cnt-=1
        ans=max(ans,cnt)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(raw_input())
s=raw_input()
ans=0
for i in xrange(n):
    if s[i]=="I":
        cnt+=1
        ans=max(ans,cnt)
    elif s[i]=="D":
        cnt-=1
        ans=max(ans,cnt)
print(ans)
Problem p03840 (python)

Fixed submission:
I,O,T,J,L,S,Z=map(int,raw_input().split())
ans=0
ans1=0
ans+=2*O
ans1+=2*O
ans+=4*(I/2)
ans+=4*(J/2)
ans+=4*(L/2)
JL=min(J,L)
if JL>=1 and I>=1:
    ans1+=6
    J-=1
    L-=1
    I-=1
ans1+=4*(I/2)
ans1+=4*(J/2)
ans1+=4*(L/2)
print(max(ans/2,ans1/2))

Buggy submission (verdict: Runtime Error):
n=int(raw_input())
x=map(int,raw_input().split())
ans=[-1]*(n**2+1)
for i in xrange(n):
    if ans[x[i]]!=-1:
        print("No")
        exit()
    ans[x[i]]=i+1
    cnt=n-1
    for j in xrange(1,n**2+1):
        if cnt==0:break
        if ans[j]==-1:
            cnt-=1
            ans[j]=i+1
    if cnt>0:
        print("No")
        exit()
print("Yes")
print(" ".join(map(str,ans[1:])))

Buggy submission (verdict: Runtime Error):
I,O,T,J,L,S,Z=map(int,raw_input().split())
ans=0
ans+=2*O
ans1+=2*O
ans+=4*(I/2)
ans+=4*(J/2)
ans+=4*(L/2)
JL=min(J,L)
if JL>=1 and I>=1:
    ans1+=6
    J-=1
    L-=1
    I-=1
ans1+=4*(I/2)
ans1+=4*(J/2)
ans1+=4*(L/2)
print(max(ans/2,ans1/2))
Problem p03844 (python)

Fixed submission:
a,op,b=raw_input().split()
if op=="+":
    print(int(a)+int(b))
else:
    print(int(a)-int(b))

Buggy submission (verdict: Runtime Error):
n=int(raw_input())
t=map(int,raw_input().split())
m=int(raw_input())
xt=[map(int,raw_input().split()) for _ in xrange(m)]
ans=[0]*m
for i in xrange(m):
    tmp=t
    tmp[xt[i][0]-1]=xt[i][1]
    for j in xrange(n):
        ans[i]+=tmp[j]
for j in xrange(n):
    print(ans[j])
Problem p03845 (python)

Fixed submission:
import copy
n=int(raw_input())
t=map(int,raw_input().split())
m=int(raw_input())
pt=[map(int,raw_input().split()) for _ in xrange(m)]
ans=[0]*m
for i in xrange(m):
    tmp=copy.deepcopy(t)
    tmp[pt[i][0]-1]=pt[i][1]
    for j in xrange(n):
        ans[i]+=tmp[j]
for i in xrange(m):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
n=int(raw_input())
t=map(int,raw_input().split())
m=int(raw_input())
xt=[map(int,raw_input().split()) for _ in xrange(m)]
ans=[0]*m
for i in xrange(m):
    tmp=t
    tmp[xt[i][0]]=xt[i][1]
    for j in xrange(n):
        ans[i]+=tmp[j]
for j in xrange(n):
    print(ans[j])
Problem p03864 (python)

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 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()

Buggy 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()
Problem p03894 (python)

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 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
Problem p03929 (python)

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 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)
Problem p03937 (python)

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 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)))
Problem p03947 (python)

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 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
Problem p03959 (python)

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 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)
Problem p04019 (python)

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 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")

Buggy 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")
Problem p03238 (python)

Fixed submission:
N = int(input())

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

elif N == 2:
    A = int(input())
    B = int(input())
    print(A+B)

Buggy 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)

Buggy 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)
Problem p03061 (python)

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 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)

Buggy 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)
Problem p03071 (python)

Fixed submission:
a, b = map(int, input().split())
c = max(a,b)
print(c + max(c-1, min(a,b)))

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

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)

Buggy 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)
Problem p03164 (python)

Fixed submission:
N, W = map(int, input().split())
wl = [0]*(N+1)
vl = [0]*(N+1)
for i in range(1, N+1):
    wl[i], vl[i] = map(int, input().split())

NIL = int(1e18)
MAX = int(1e5)

dp = [NIL]*(MAX+1)
dp[0]= 0

for i in range(1, N+1):
    w, v = wl[i], vl[i]
    for k in reversed(range(MAX+1)):
        if k + v <= MAX and dp[k] != NIL:
            dp[k+v] = min(dp[k+v], dp[k] + w)

ans = 0
for i in reversed(range(MAX+1)):
    if dp[i] <= W:
        ans = i
        break
print(ans)

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
wl = [0]*(N+1)
vl = [0]*(N+1)
for i in range(1, N+1):
    wl[i], vl[i] = map(int, input().split())

MAX = W
dp = [0]*(MAX+1)

for i in range(1, N+1):
    w, v = wl[i], vl[i]
    for k in reversed(range(MAX+1-w)):
        if k + w > MAX:
            break
        else:
            dp[k+w] = max(dp[k+w], dp[k] + v)
print(max(dp))