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

Fixed submission:

from copy import copy
N=int(input())
G=[[] for _ in range(N)]
di=[-1]*N
for i in range(N-1):
    u,v,w=map(int,input().split())
    G[u-1].append([v-1,w])
    G[v-1].append([u-1,w])

di[0]=0
for g,w in G[0]:
    di[g]=w

for i in range(1,N):
    if di[i]!=-1:continue
    seen=[0]*N
    stack=copy(G[0])
    seen[0]=1
    dis=0
    while stack:
        y,d=stack.pop()
        if seen[y]==1:continue
        seen[y]=1
        if y==i:
            di[i]=dis+d
            break
        else:
            for z,dist in G[y]:
                if seen[z]==0:
                    di[z]=dis+d+dist
                    stack.append([z,dis+d+dist])

for i in range(N):
    if di[i]%2==0:
        print(0)
    else:
        print(1)

Buggy submission (verdict: Runtime Error):

from copy import copy
N=int(input())
G=[[] for _ in range(N)]
di=[-1]*N
for i in range(N-1):
    u,v,w=map(int,input().split())
    G[u-1].append([v-1,w])
    G[v-1].append([u-1,w])

def dfs(a,b):
    seen[a]=1
    #distance of a to b
    for g,d in G[a]:
        if seen[g]==1:continue
        if g==b:
            return d
        seen[g]=1
        dis=dfs(g,b)
        if dis !=0:
            return d+dis
        seen[g]=0
    return 0

di[0]=0
for i in range(N):
    if di[i]!=-1:continue
    seen=[0]*N
    di[i]=dfs(0,i)

for i in range(N):
    if di[i]%2==0:
        print(0)
    else:
        print(1)

Buggy submission (verdict: Runtime Error):
N=int(input())
G=[[] for _ in range(N)]
ans=[-1]*N

for i in range(N-1):
    u,v,w=map(int,input().split())
    d=w%2
    G[u-1].append([v-1,d])
    G[v-1].append([u-1,d])

def dfs(x):
    if ans[x]!=-1:
        return ans[x]
    for y,w in G[x]:
        if seen[y]:continue
        seen[y]=True
        if ans[y]!=-1:
            seen[y]=False
            return (ans[y]+1)%2
        temp=dfs(y)
        if temp==None:
            seen[y]=False
        else:
            seen[y]=False
            return (temp+w)%2

ans[0]=0
seen=[False]*N
for g,e in G[0]:
    ans[g]=e%2


for i in range(N):
    ans[i]=dfs(i)

for a in ans:
    print(a)
Problem p03048 (python)

Fixed submission:
R, G, B, N = map(int, input().split())

ans = 0
for i in range(int(N / R) + 1):
    for j in range(int((N - i * R) / G) + 1):
        if ((N - (i * R + j * G)) % B == 0):
            ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
R,G,B,N=map(int,input().split())

RL=(N+R-1)//R
if RL*F>N:
    RL=RL-1

cnt=0
for r in range(RL+1):
    GL=(N-r*R+G-1)//G
    for g in range(GL+1):
        if (r*R+g*G)>N:continue
        if (N-r*R-g*G)%B==0:
            cnt+=1

print(cnt)
Problem p03085 (python)

Fixed submission:
b = input()
if b == "A":
    print("T")
elif b == "T":
    print("A")
elif b == "C":
    print("G")
else:
    print("C")

Buggy submission (verdict: Runtime Error):
b = input()

if b == "A":
    print("T")
elif b == "T":
    prnt("A")
elif b == "C":
    print("G")
else:
    print("C")
Problem p03087 (python)

Fixed submission:
N, Q = map(int, input().split())
S = input()
SC = [0] * N

for i in range(N - 1):
    if S[i:i + 2] == "AC":
        SC[i + 1] = SC[i] + 1
    else:
        SC[i + 1] = SC[i]

for i in range(Q):
    l, r = map(int, input().split())
    print(SC[r - 1] - SC[l - 1])

Buggy submission (verdict: Runtime Error):
N,Q=map(int,input().split())
S=input()
C=[0]*N

for i in range(1,N):
    if S[i-1:i+1]=="AC":
        C[i]+=1

for i in range(Q):
    l,r=map(int,input().split())
    print(C[r]-C[i])
Problem p03147 (python)

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

if N==1:
    print(h[0])
    exit()

mi=min(h)
p=0
h0=h[0]
c=h0-mi
ans=mi+h0
for i in range(1,N):
    if h0<h[i]:
        c+=h[i]-h0
    elif h0>h[i]:
        c=h0-min(h[p:i])
        ans+=c
        p = i
        c=h[i]-mi
    h0=h[i]

ans+=c-min(h[p:])
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
h=list(map(int,input().split()))

mi=min(h)
h0=h[0]
c=h0-mi
ans=mi
for i in range(1,N):
    if h0<h[i]:
        c+=h[i]-h0
    elif h0>h[i]:
        ans+=c
        mi = min(h[i:])
        c=h[i]-mi
    h0=h[i]

if h[-2]<h[-1]:
    ans+=c
print(ans)
Problem p03160 (python)

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

DP=[100000]*N

DP[0]=0
DP[1]=abs(h[1]-h[0])

for i in range(2,N):
    DP[i]=min(DP[i-2]+abs(h[i]-h[i-2]),DP[i-1]+abs(h[i]-h[i-1]))

print(DP[N-1])

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)


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

INF=float("inf")

DP=[INF]*(N+1)

def rec(n):
    if DP[n]<INF: return DP[n]
    if n==0:
        return 0
    ans=INF
    ans=min(ans,rec(n-1)+abs(h[n]-h[n-1]))
    if n>1:
        ans=min(ans,rec(n-2)+abs(h[n]-h[n-2]))
    DP[n]=ans

    return DP[n]

ans=rec(N-1)
print(ans)

Buggy submission (verdict: Runtime Error):

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

INF=float("inf")

DP=[INF]*(N+1)

def rec(n):
    if DP[n]<INF: return DP[n]
    if n==0:
        return 0
    ans=INF
    ans=min(ans,rec(n-1)+abs(h[n]-h[n-1]))
    if n>1:
        ans=min(ans,rec(n-2)+abs(h[n]-h[n-2]))
    DP[n]=ans

    return DP[n]

ans=rec(N-1)
print(ans)
Problem p03161 (python)

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

DP=[10000000000]*N

DP[0]=0
for i in range(1,N):
    temp=[]
    if i<K:
        for j in range(i):
            temp.append(DP[j]+abs(h[j]-h[i]))
    else:
        for j in range(1,K+1):
            temp.append(DP[i-j]+abs(h[i]-h[i-j]))
    DP[i]=min(temp)

print(DP[N-1])

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000000000)


N,K=map(int,input().split())
h=list(map(int,input().split()))

INF=float("inf")

DP=[INF]*(N+1)
DP[0]=0

def rec(n):
    if DP[n]!=INF:return DP[n]
    res=INF
    for i in range(1,K+1):
        if n-i<0:break
        res=min(res,rec(n-i)+abs(h[n-i]-h[n]))
    DP[n]=res
    return res

ans=rec(N-1)

print(ans)
Problem p03206 (python)

Fixed submission:
D = int(input())

print("Christmas" + " Eve" * (25-D))

Buggy submission (verdict: Runtime Error):
N = int(input())
p = [0]*N
s = 0

for i in range(N):
   p[i] = int(input())
   s = s + p[i]
   
print(s-max(p)//2)
Problem p03268 (python)

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

if K%2==0:
    print((N//K)**3+((N//(K//2))-(N//K))**3)
else:
    print((N//K)**3)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
c=0
if K%2==0:
    d=K//2
else:
    print(N//K**3)

for i in range(d,N+1,d):
    for j in range(d,N+1,d):
        for k in range(d,N+1,d):
            if (i+j)%K==0 and (j+k)%K==0 and (k+i)%K==0:
                c+=1
print(c)
Problem p03304 (python)

Fixed submission:
n,m,d=map(int,input().split())

if d==0:
    ans=(m-1)/n
else:
    ans=(n-d)*2*(m-1)/(n*n)

print(ans)

Buggy submission (verdict: Runtime Error):

n,m,d=map(int,input().split())

DP=[[[0]*m for _ in range(n)] for _ in range(m)]

for i in range(n):
    DP[0][i][0]=1

for i in range(1,m):
    for j in range(n):
        for k in range(m):
            if k==0:
                if j-d<0:
                    DP[i][j][k]=DP[i-1][j+d][0]
                elif j+d>=n:
                    DP[i][j][k]=DP[i-1][j-d][0]
                else:
                    DP[i][j][k]=DP[i-1][j+d][0]+DP[i-1][j+d][0]
            else:
                if j-d<0:
                    DP[i][j][k]=DP[i-1][j+d][k-1]+DP[i-1][j][k]
                elif j+d>=n:
                    DP[i][j][k]=DP[i-1][j-d][k-1]+DP[i-1][j][k]
                else:
                    DP[i][j][k]=DP[i-1][j+d][k-1]+DP[i-1][j-d][k-1]+DP[i-1][j][k]
            DP[i][j][k]=DP[i][j][k]/n

ans=0
for i in range(n):
    for j in range(1,m):
        ans+=DP[m-1][i][j]*j
ans=ans/n
print(ans)
Problem p03328 (python)

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

i = 0
s = 0

for i in range(1, b - a):
    s += i
print(s - a)

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

i = 0
s = 0

for i in range(1, b - a):
    s += i
print(s - a)
Problem p03425 (python)

Fixed submission:
import math


def combi(a, b):
    ans = math.factorial(a) / (math.factorial(a - b) * math.factorial(b))
    return ans


N = int(input())
S = [0] * 5

for i in range(N):
    s = input()
    temp = s[0]
    if temp == "M":
        S[0] += 1
    elif temp == "A":
        S[1] += 1
    elif temp == "R":
        S[2] += 1
    elif temp == "C":
        S[3] += 1
    elif temp == "H":
        S[4] += 1

c = 0
N = 0
for i in range(5):
    N += S[i]
    if S[i] != 0:
        c += 1

if c <= 2:
    print(0)

else:
    ans = 0
    for i in range(3):
        for j in range(i + 1, 4):
            for k in range(j + 1, 5):
                ans += S[i] * S[j] * S[k]
    print(ans)

Buggy submission (verdict: Runtime Error):
import math


def combi(a, b):
    ans = math.factorial(a) / (math.factorial(a - b) * math.factorial(b))
    return ans

N=int(input())
S=[0]*5

for i in range(N):
    s=input()
    temp=s[0]
    if temp=="M":
        S[0]+=1
    elif temp=="A":
        S[1]+=1
    elif temp=="R":
        S[2]+=1
    elif temp=="C":
        S[3]+=1
    elif temp=="H":
        S[4]+=1

c=0
N=0
for i in range(5):
    N+=S[i]
    if S[i]!=0:
        c+=1

if c<=2:
    print(0)

else:

    for i in range(5):
        if S[i]>=3:
            NG=combi(S[i],3)+combi(S[i],2)*(N-S[i])
        elif S[i]==2:
            NG=combi(S[i],2)*(N-S[i])
    print(int(combi(N,3)-NG))
Problem p03487 (python)

Fixed submission:
import collections

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

a_dict=collections.Counter(a)

ans=0
for i,n in a_dict.items():
    if i>n:
        ans+=n
    elif i<n:
        ans+=n-i

print(ans)

Buggy submission (verdict: Runtime Error):
import collections

N=int(input())

a_dict=collections.Counter(a)
a=list(a_dict.items())

L=len(a)

ans=0
for i,n in a_dict.items():
    if i>n:
        ans+=n
    elif i<n:
        ans+=n-i

print(ans)
Problem p03544 (python)

Fixed submission:
N = int(input())
L = [0] * (N + 1)
L[0] = 2
L[1] = 1

if N ==1:
    print(L[1])
    exit()
for i in range(2, N + 1):
    L[i] = L[i - 2] + L[i - 1]

print(L[i])

Buggy submission (verdict: Runtime Error):
N = int(input())
L = [0] * (N + 1)
L[0] = 2
L[1] = 1

if N ==1:
    print(L[1])
for i in range(2, N + 1):
    L[i] = L[i - 2] + L[i - 1]

print(L[i])

Buggy submission (verdict: Runtime Error):
N = int(input())
L = [0] * (N + 1)
L[0] = 2
L[1] = 1

for i in range(2, N + 1):
    L[i] = L[i - 2] + L[i - 1]

print(L[i])
Problem p03575 (python)

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

C=[[] for i in range(N)]

for i in range(M):
    a,b=map(int,input().split())
    C[a-1].append(b-1)
    C[b-1].append(a-1)

cnt=0
f=True
while f:
    f=False
    for i in range(N):
        if len(C[i])==1:
            cnt+=1
            idx=C[C[i][0]].index(i)
            C[C[i][0]].pop(idx)
            C[i].pop()
            f=True
print(cnt)

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

graph=[[False]*N for i in range(N)]
visited=[False]*N
a=[0]*N
b=[0]*N

for i in range(M):
    a[i],b[i]=map(int,input().split())
    a[i]-=1
    b[i]-=1
    graph[a[i]][b[i]]=True
    graph[b[i]][a[i]]=True


def dfs(v):
    visited[v]=True
    for v2 in range(N):
        if graph[v][v2]==False:continue
        if visited[v2]==True:continue
        dfs(v2)

ans=0
for i in range(M):
    graph[a[i]][b[i]]=False
    graph[b[i]][a[i]]=False
    for j in range(N):
        visited[j]=False
    dfs(0)
    bridge=False
    for j in range(N):
        if visited[j]==False:
            bridge=True
    if bridge==True:
        ans+=1
    graph[a[i]][b[i]] = True
    graph[b[i]][a[i]] = True

print(ans)
Problem p03599 (python)

Fixed submission:
A,B,C,D,E,F =map(int,input().split())

amax = F//(100*A)
bmax = F//(100*B)

concmx =0
wholemx =0
sugarmx =0

for a in range(amax,-1,-1):
    for b in range(bmax,-1,-1):
        cmax = (F-100*A*a-100*B*b)//C
        dmax = (F-100*A*a-100*B*b)//D
        for c in range(cmax,-1,-1):
            for d in range(dmax,-1,-1):
                sugar =C*c+D*d
                whole = 100*A*a+100*B*b+sugar
                if whole ==0:
                    break
                elif sugar/whole <= E/(100+E) and whole <=F:
                    if sugar/whole >= concmx:
                        concmx =sugar/whole
                        sugarmx = sugar
                        wholemx =whole
                    
                   
print(str(wholemx)+" "+str(sugarmx))

Buggy submission (verdict: Runtime Error):
A,B,C,D,E,F =map(int,input().split())

amax = F//(100*A)
bmax = F//(100*B)
cmax = F//C
dmax = F//D
concmx =0

for a in range(amax,-1,-1):
    for b in range(bmax,-1,-1):
        cmax = (F-100*A*a-100*B*b)//C
        dmax = (F-100*A*a-100*B*b)//D
        for c in range(cmax,-1,-1):
            for d in range(dmax,-1,-1):
                sugar =C*c+D*d
                whole = 100*A*a+100*B*b+sugar
                if whole ==0:
                    break
                elif sugar/whole <= E/(100+E) and whole <=F:
                    if sugar/whole > concmx:
                        concmx =sugar/whole
                        sugarmx = sugar
                        wholemx =whole
                    
                   
print(str(wholemx)+" "+str(sugarmx))
Problem p03633 (python)

Fixed submission:
import fractions

N=int(input())
T0=int(input())

if N==1:
  print(T0)
  exit()

for i in range(1,N):
    T=int(input())
    g=fractions.gcd(T0,T)
    ans=T0*T//g
    T0=ans
print(ans)

Buggy submission (verdict: Runtime Error):
from fractions import gcd

N=int(input())
T0=int(input())
for i in range(1,N):
    T=int(input())
    g=gcd(T0,T)
    ans=T0*(T)//g
    T0=ans
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions

N=int(input())
T0=int(input())
for i in range(1,N):
    T=int(input())
    g=fractions.gcd(T0,T)
    ans=T0*(T//g)
    T0=ans
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions

N=int(input())
T0=int(input())
for i in range(1,N):
    T=int(input())
    ans=T0*(T//fractions.gcd(T0,T))
    T0=ans
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions

N=int(input())
T0=int(input())
for i in range(1,N):
    T=int(input())
    ans=(T0*T)//fractions.gcd(T0,T)
    T0=ans
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions

N=int(input())
T0=int(input())
for i in range(1,N):
    T=int(input())
    ans=(T0*T)//fractions.gcd(T0,T)
    T0=T
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions

N=int(input())
T0=int(input())
for i in range(1,N):
    T=int(input())
    ans=T0*T//fractions.gcd(T0,T)
    T0=T
print(ans)
Problem p03695 (python)

Fixed submission:
N = int(input())

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

C = [0] * 9

for i in range(N):
    if 1 <= A[i] <= 399:
        C[0] = 1
    elif 400 <= A[i] <= 799:
        C[1] = 1
    elif 800 <= A[i] <= 1199:
        C[2] = 1
    elif 1200 <= A[i] <= 1599:
        C[3] = 1
    elif 1600 <= A[i] <= 1999:
        C[4] = 1
    elif 2000 <= A[i] <= 2399:
        C[5] = 1
    elif 2400 <= A[i] <= 2799:
        C[6] = 1
    elif 2800 <= A[i] <= 3199:
        C[7] = 1
    else:
        C[8] += 1

num = sum(C[0:8])

ans1 = str(max(num, 1))
ans2 = str( num + C[8])
print(ans1 + " " + ans2)

Buggy submission (verdict: Runtime Error):
N = int(input())

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

C = [0] * 9

for i in range(N):
    if 1 <= A[i] <= 399:
        C[0] += 1
    elif 400 <= A[i] <= 799:
        C[1] += 1
    elif 800 <= A[i] <= 1199:
        C[2] += 1
    elif 1200 <= A[i] <= 1599:
        C[3] += 1
    elif 1600 <= A[i] <= 1999:
        C[4] += 1
    elif 2000 <= A[i] <= 2399:
        C[5] += 1
    elif 2400 <= A[i] <= 2799:
        C[6] += 1
    elif 2800 <= A[i] <= 3199:
        C[7] += 1
    else:
        C[8] += 1

blank = C[0:8].count(0)

if blank == 0:
    print("8 8")
    exit()

if C[8] == 0:
    ans = str(8 - blank)
    print(ans + " " + ans)
    exit()
elif C[8] >= 8:
    ans = str(max(8 - blank, 1))
    print(ans + " " + 8)
elif 1 <= C[8] <= 7:
    ans = str(8 - blank)
    ans2 = str(min(8, 8 - blank + C[8]))
    print(ans + " " + ans2)
Problem p03696 (python)

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

temp=list(S)
f=True

while f :
    f=False
    L=len(temp)
    for i in range(L-2,-1,-1):
        if  "".join(temp[i:i+2])=="()":
            temp.pop(i+1)
            temp.pop(i)
            f=True

Ltemp=len(temp)
if Ltemp==0:
    print(S)
    exit()
    
if temp[0]=="(":
    add=")"*len(temp)
    ans=S+add
else:
    cnt1=0
    cnt2=0
    for i in range(Ltemp):
        if temp[i]==")":
            cnt1+=1
        else:
            cnt2+=1
        add1="("*cnt1
        add2=")"*cnt2
    ans=add1+S+add2


print(ans)

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

temp=list(S)
f=True

while f:
    f=False
    L=len(temp)
    for i in range(L-2,-1,-1):
        if  "".join(temp[i:i+2])=="()":
            temp.pop(i+1)
            temp.pop(i)
            f=True

Ltemp=len(temp)
if temp[0]=="(":
    add=")"*len(temp)
    ans=S+add
else:
    cnt1=0
    cnt2=0
    for i in range(Ltemp):
        if temp[i]==")":
            cnt1+=1
        else:
            cnt2+=1
        add1="("*cnt1
        add2=")"*cnt2
    ans=add1+S+add2


print(ans)
Problem p03848 (python)

Fixed submission:
import collections

N=int(input())
A_data=list(map(int,input().split()))
mod=10**9+7

A=collections.Counter(A_data)

f=True
if N%2==1:
    if not A[0]==1:
        ans=0
    else:
        for i in range(2,N,2):
            if not A[i]==2:
                ans=0
                f=False
                break
        if f==True:
            ans=2**((N-1)//2)%mod
elif N%2==0:
    for i in range(1,N,2):
        if not A[i]==2:
            ans=0
            f=False
            break
    if f==True:
        ans=2**(N//2)%mod

print(ans)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
mod=10**9+7
a=[]
for i in range(M):
    a.append(int(input()))


DP=[1]*(N+1)

if 1 in a:
    DP[1]=0

for i in range(2,N+1):
    if i in a:
        DP[i]=0
        if DP[i-1]==0:
            print(0)
            exit()
    else:
        DP[i]=DP[i-1]+DP[i-2]
        DP[i]=DP[i]%mod

print(DP[N])

Buggy submission (verdict: Runtime Error):
import collections

N=int(input())
A_data=list(map(int,input().split()))
mod=10**9+7

A=collections.Counter(A_data)

if N%2==1:
    if not A[0]==1:
        ans=0
    else:
        for i in range(2,N,2):
            if not A[i]==2:
                ans=0
                break
        if ans!=0:
            ans=2**((N-1)//2)%mod
elif N%2==0:
    for i in range(1,N,2):
        if not A[i]==2:
            ans=0
            break
    if ans!=0:
        ans=2**(N//2)%mod

print(ans)
Problem p03944 (python)

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

wl = 0
wr = W
hu = H
hl = 0

for i in range(N):
    x,y,a = map(int,input().split())
    if a == 1 and x > wl:
        wl = x
    elif a == 2 and x < wr:
        wr = x
    elif a == 3 and y > hl:
        hl =y
    elif a == 4 and y < hu:
        hu = y
    
if wl>wr or hl>hu:
    print(0)
else:
    print((wr-wl)*(hu-hl))

Buggy submission (verdict: Runtime Error):
W,H,N = map(int,input().split())
x=[]
y=[]
a=[]

A1=[]
A2=[]
A3=[]
A4=[]

for n in range(N):
    i,j,k = map(int,input().split())
    x.append(i)
    y.append(j)
    a.append(k)
a1,a2,a3,a4 = 0,0,0,0

for n in range(N):
    if a[n] == 1:
        A1.append(x[n])
        a1 = a1 + 1
    elif a[n] == 2:
        A2.append(x[n])
        a2 = a2 + 1
    elif a[n] == 3:
        A3.append(y[n])
        a3 = a3 + 1
    else:
        A4.append(y[n])
        a4 = a4 + 1

if a1 == 0 and a2 == 0:
    width = W
elif a1 == 0:
    width = min(A2)
elif a2 == 0:
    width = W - max(A1)
else:
    width = min(A2) - max(A1)
    if width <0:
        width = 0

if a3 == 0 and a4 == 0:
    height == H
elif a3 == 0:
    height =min(A4)
elif a4 ==0:
    height = H-max(A3)
else:
    height =min(A4) - max(A3)
    if width <0:
        width = 0

print(height*width)
Problem p03994 (python)

Fixed submission:
s=list(input())
K=int(input())

abc="bcdefghijklmnopqrstuvwxyza"

cnt=K
for i in range(len(s)):
    temp=25-abc.index(s[i])
    if cnt>=temp:
        s[i]="a"
        cnt-=temp

if cnt!=0:
    s[-1]=abc[(abc.index(s[-1])+cnt)%26]

print("".join(s))

Buggy submission (verdict: Runtime Error):
s=list(input())
K=int(input())

abc="bcdefghijklmnopqrstuvwxyza"

cnt=K
for i in range(len(s)):
    temp=25-abc.index(s[i])
    if cnt>=temp:
        s[i]="a"
        cnt-=temp

if cnt!=0:
    if abc.index(s[-1])+cnt>25:
        s[-1]=abc[abc.index(s[-1])+cnt-26]
    else:
        s[-1]=abc[abc.index(s[-1])+cnt]

print("".join(s))
Problem p03998 (python)

Fixed submission:
SA = input()
SB = input()
SC = input()

ca,cb,cc = 0,0,0
t = "a"
while ca <= len(SA) and cb <= len(SB) and cc <= len(SC):
    if t == "a":
        if ca == len(SA):
            print("A")
            exit()
        t = SA[ca]
        ca = ca + 1
        
    elif t == "b":
        if cb == len(SB):
            print("B")
            exit()
        t = SB[cb]
        cb = cb + 1
    else:
        if cc == len(SC):
            print("C")
            exit()
        t = SC[cc]
        cc = cc +1

Buggy submission (verdict: Runtime Error):
SA = input()
SB = input()
SC = input()

ca,cb,cc = 0,0,0
t = "a"
while ca < len(SA) and cb < len(SB) and cc < len(SC):
    if t == "a":
        answer = "A"
        t = SA[ca]
        ca = ca + 1      
    elif t == "b":
        answer = "B"
        t = [cb]
        cb = cb + 1
    else:
        answer ="C"
        t = SC[cb]
        cb = cb +1
print(answer)
Problem p04020 (python)

Fixed submission:
N=int(input())

ans=0
co=0
for i in range(N):
    a=int(input())
    ans+=(a+co)//2
    if a==0:
        co=0
    else:
        co=(a+co)%2
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=[0]*N
DP=[0]*N

for i in range(N):
    A[i]=int(input())

DP[0]=A[0]//2
DP[1]=max(A[0]//2+A[1]//2,min(A[0],A[1]))

for i in range(2,N):
    DP[i]=max(DP[i-2]+A[i-1]//2+A[i]//2,DP[i-2]+min(A[i-1],A[i]))

print(DP[N-1])