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

Fixed submission:
import sys
input = sys.stdin.readline

S = input().strip()
a = ['A', 'T', 'G', 'C']

ans = 0
j = []
for i in range(len(S)):
  j = i
  count = 0
  while True:
    ans = max(ans, count)
    if j >= len(S):
      break
    if S[j] in a:
      count += 1
      j += 1
    else:
      break
  
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys,sydin.readline

S = input().strip()
a = ['A', 'T', 'G', 'C']

ans = 0
j = []
for i in range(len(S)):
  j = i
  count = 0
  while True:
    if j >= len(S):
      break
    if S[j] in a:
      count += 1
      j += 1
    else:
      ans = max(ans, count)
      break
  
print(ans)
Problem p03244 (python)

Fixed submission:
import sys
from collections import Counter
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    n = readint()
    v = list(readnums())
    ve = [x for i, x in enumerate(v) if not i % 2]
    vo = [x for i, x in enumerate(v) if i % 2]
    cve = Counter(ve)
    cvo = Counter(vo)
    if cve.most_common()[0][0] == cvo.most_common()[0][0]:
        if len(cve) == 1:
            print(n // 2)
        else:
            print(min(len(ve) - cve.most_common()[1][1] + len(vo) - cvo.most_common()[0][1], len(ve) - cve.most_common()[0][1] + len(vo) - cvo.most_common()[1][1]))
    else:
        print(len(ve) - cve.most_common()[0][1] + len(vo) - cvo.most_common()[0][1])


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
from collections import Counter
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    n = readint()
    v = list(readnums())
    ve = [x for i, x in enumerate(v) if not i % 2]
    vo = [x for i, x in enumerate(v) if i % 2]
    cve = Counter(ve)
    cvo = Counter(vo)
    if cve.most_common()[0][0] == cvo.most_common()[0][0]:
        print(min(len(ve) - cve.most_common()[1][1] + len(vo) - cvo.most_common()[0][1], len(ve) - cve.most_common()[0][1] + len(vo) - cvo.most_common()[1][1]))
    else:
        print(len(ve) - cve.most_common()[0][1] + len(vo) - cvo.most_common()[0][1])


if __name__ == "__main__":
    main()
Problem p03387 (python)

Fixed submission:
A, B, C = map(int, input().split())
if sum((A, B, C)) % 2 == max(A, B, C) % 2:
  print((max(A, B, C) * 3 - sum((A, B, C))) // 2)
else:
  print(((max(A, B, C) + 1) * 3 - sum((A, B, C))) // 2)

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
if sum(A, B, C) % 2 == max(A, B, C) * 3:
  print((max(A, B, C) * 3 - sum(A, B, C)) // 2)
else:
  print(((max(A, B, C) + 1) * 3 - sum(A, B, C)) // 2)
Problem p03545 (python)

Fixed submission:
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    abcd = list(map(int, list(readstr())))
    l = [['+', '+', '+'], ['+', '+', '-'], ['+', '-', '+'], ['+', '-', '-'], ['-', '+', '+'], ['-', '+', '-'], ['-', '-', '+'], ['-', '-', '-']]
    for ll in l:
        ans = abcd[0]
        for i, x in enumerate(ll):
            if x == '+':
                ans += abcd[i + 1]
            else:
                ans -= abcd[i + 1]
        if ans == 7:
            s = ''
            for i in range(3):
                s += str(abcd[i]) + ll[i]
            s += str(abcd[3])
            print(s + '=7')
            break


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    abcd = list(map(int, list(readstr())))
    l = [['+', '+', '+'], ['+', '+', '-'], ['+', '-', '+'], ['+', '-', '-'], ['-', '+', '+'], ['-', '+', '-'], ['-', '-', '+'], ['-', '-', '-']]
    for ll in l:
        ans = abcd[0]
        for i, x in enumerate(ll):
            if x == '+':
                ans += abcd[i + 1]
            else:
                ans -= abcd[i + 1]
        if ans == 7:
            print(f'{abcd[0]}{ll[0]}{abcd[1]}{ll[1]}{abcd[2]}{ll[2]}{abcd[3]}=7')
            break


if __name__ == "__main__":
    main()
Problem p03665 (python)

Fixed submission:
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


N, P = readnums()
A = map(lambda x: x % 2, readnums())

if P:
    if not sum(A):
        print(0)
    else:
        print(2 ** N // 2)
else:
    if not sum(A):
        print(2 ** N)
    else:
        print(2 ** N // 2)

Buggy submission (verdict: Runtime Error):

  
  import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


N, P = readnums()
A = map(lambda x: x % 2, readnums())

if not sum(A):
    print(0)
else:
    print(2 ** N // 2)
Problem p03482 (python)

Fixed submission:
S=input()
prev=S[0]
T=len(S)
for i in range(1, len(S)):
    if S[i]!=prev:
        T=min(T,max(i,len(S)-i))
        prev=S[i]
print(T)

Buggy submission (verdict: Runtime Error):
S=input()+'2'
prev=S[0]
cnt=1
li=[]
for i in range(1,len(S)):
    if S[i]!=prev:
        li.append(cnt)
        prev=S[i]
        cnt=1
    else:
        cnt+=1
if len(li)==1:
    print(li[0])
elif len(li)==2:
    print(max(li))
elif len(li)%2==1:
    ans=li[0]+li[1]
    for i in range(len(li)-1):
        ans=min(ans,li[i]+li[i+1])
    print(ans)
else:
    ans1=li[0]+li[1]
    ans2=li[1]+li[2]
    for i in range(len(li)-2):
        ans1=min(ans1,li[i]+li[i+1])
    for i in range(1,len(li)-1):
        ans2=min(ans2,li[i]+li[i+1])
    print(max(a1,a2))
Problem p03489 (python)

Fixed submission:
import collections
N=int(input())
A=[int(a) for a in input().split()]
c=collections.Counter(A)
ans=0
for k,v in c.items():
  if k>v:
    ans+=v
  else:
    ans+=v-k
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
num={}
for a in input().split():
  num[a]+=1
ans=0
for k,v in num:
  if k>v:
    ans+=v
  else:
    ans+=v-k
print(ans)
Problem p03552 (python)

Fixed submission:
n,z,w=map(int,input().split())
A=[int(x) for x in input().split()]
print(max(abs(A[n-2]-A[n-1]),abs(A[n-1]-w))) if n!=1 else print(abs(A[0]-w))

Buggy submission (verdict: Runtime Error):
n,z,w=map(int,input().split())
A=[int(x) for x in input().split()]
print(max(abs(A[n-2]-A[n-1]),abs(A[n-1],w))) if n!=1 else print(abs(a[0]-w))
Problem p02582 (python)

Fixed submission:
S = input()
count = 0

if S.count("R") == 0:
    count = 0
elif S.count("R") == 1:
    count= 1
elif S.count("R") == 2:
    if S == "RSR":
        count = 1
    else:
        count = 2
else:
    count = 3
    
print(count)

Buggy submission (verdict: Runtime Error):
X,K,D = map(int,input().split())
List = []

if abs(X) > K*D:
    print(abs(X) - K*D)
elif K == 1:
    print(min(abs(X-D),abs(X+D)))
elif K == 2:
    print(min(abs(X+D+D),abs(X-D-D),abs(X)))
elif K == 3:
    print(min(abs(X+D+D+D),abs(X+D),abs(X-D),abs(X-D-D-D)))
else:
    for i in range(3):
        if abs(X - D) >= abs(X+D):
            List.append(abs(X+D))
            X = X+D
        else:
            List.append(abs(X-D))
            X = X-D

    for i in range(K-3):
        if List[i] == List[i+2]:
            if K%2 == i%2:
                print(List[i+1])
            else:
                print(List[i])
            break
        else:
            if abs(X - D) >= abs(X+D):
                List.append(abs(X+D))
                X = X+D
            else:
                List.append(abs(X-D))
                X = X-D

    if len(List) == K:
        print(List[K-1])
    else:
        pass

Buggy submission (verdict: Runtime Error):
X,K,D = map(int,input().split())
List = []

if K == 1:
    print(min(abs(X-D),abs(X+D)))
elif K == 2:
    print(min(abs(X+D+D),abs(X-D-D),abs(X)))
elif K == 3:
    print(min(abs(X+D+D+D),abs(X+D),abs(X-D),abs(X-D-D-D)))
else:
    for i in range(3):
        if abs(X - D) >= abs(X+D):
            List.append(abs(X+D))
            X = X+D
        else:
            List.append(abs(X-D))
            X = X-D

    for i in range(K-3):
        if List[i] == List[i+2]:
            if K%2 == i%2:
                print(List[i+1])
            else:
                print(List[i])
            break
        else:
            if abs(X - D) >= abs(X+D):
                List.append(abs(X+D))
                X = X+D
            else:
                List.append(abs(X-D))
                X = X-D

    if len(List) == K:
        print(List[K-1])
    else:
        pass

Buggy submission (verdict: Runtime Error):
X,K,D = map(int,input().split())
List = []

if K == 1:
    print(min(abs(X-D),abs(X+D)))
elif K == 2:
    print(min(abs(X+D+D),abs(X-D-D),abs(X)))
elif K == 3:
    print(min(abs(X+D+D+D),abs(X+D),abs(X-D),abs(X-D-D-D)))
else:
    for i in range(3):
        if abs(X - D) >= abs(X+D):
            List.append(abs(X+D))
            X = X+D
        else:
            List.append(abs(X-D))
            X = X-D

    for i in range(K-3):
        if List[i] == List[i+2]:
            if K%2 == i%2:
                print(List[i+1])
            else:
                print(List[i])
            break
        else:
            if abs(X - D) >= abs(X+D):
                List.append(abs(X+D))
                X = X+D
            else:
                List.append(abs(X-D))
                X = X-D
    print(List[K-1])
Problem p02584 (python)

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

t = abs(X) // D
s = abs(X) % D

if abs(X) > K*D:
    print(abs(X) - K*D)
elif t%2 == K%2:
    print(s)
else:
    print(D-s)

Buggy submission (verdict: Runtime Error):
X,K,D = map(int,input().split())
List = []

if K == 1:
    print(min(abs(X-D),abs(X+D)))
elif K == 2:
    print(min(abs(X+D+D),abs(X-D-D),abs(X)))
elif K == 3:
    print(min(abs(X+D+D+D),abs(X+D),abs(X-D),abs(X-D-D-D)))
else:
    for i in range(3):
        if abs(X - D) >= abs(X+D):
            List.append(abs(X+D))
            X = X+D
        else:
            List.append(abs(X-D))
            X = X-D

    for i in range(K-3):
        if List[i] == List[i+2]:
            if K%2 == i%2:
                print(List[i+1])
            else:
                print(List[i])
            break
        else:
            if abs(X - D) >= abs(X+D):
                List.append(abs(X+D))
                X = X+D
            else:
                List.append(abs(X-D))
                X = X-D
        print(List[K-1])

Buggy submission (verdict: Runtime Error):
X,K,D = map(int,input().split())
List = []

if K == 1:
    print(min(abs(X-D),abs(X+D)))
elif K == 2:
    print(min(abs(X+D+D),abs(X-D-D),abs(X)))
else:
    for i in range(3):
        if abs(X - D) >= abs(X+D):
            List.append(abs(X+D))
            X = X+D
        else:
            List.append(abs(X-D))
            X = X-D

    for i in range(K-3):
        if List[i] == List[i+2]:
            break
            if K%2 == i%2:
                print(List[i])
            else:
                print(List[i+1])
        else:
            if abs(X - D) >= abs(X+D):
                List.append(abs(X+D))
                X = X+D
            else:
                List.append(abs(X-D))
                X = X-D
        print(List[K-1])
Problem p02645 (python)

Fixed submission:
a = input()
print(a[0]+a[1]+a[2])

Buggy submission (verdict: Runtime Error):
a = input()
print(a[3]+a[4]+a[5])
Problem p02675 (python)

Fixed submission:
N = int(input())
if N%10==2 or N%10==4 or N%10==5 or N%10==7 or N%10==9:
    print("hon")
elif N%10==0 or N%10==1 or N%10==6 or N%10==8:
    print("pon")
elif N%10==3:
    print("bon")

Buggy submission (verdict: Runtime Error):
import math
A,B,H,M = map(float,input().split())
vec = 0
c = abs((30.0*H + M*0.5) - (M*6.0))
if c <= 180.0:
    vec = c
else:
    vec = 360.0 - c
ans = math.sqrt(A**2 + B**2 - 2.0*A*B*math.cos(vec))
print(ans)
Problem p03434 (python)

Fixed submission:
N = int(input())
list_a = list(map(int,input().split()))
list_a.sort(reverse=True)
alice = 0; bob = 0
for i in range(len(list_a)):
    if i % 2 == 0:
        alice += list_a[i]
    else:
        bob += list_a[i]
print(alice-bob)

Buggy submission (verdict: Runtime Error):
N = int(input())
list_a = list(map(int,input().split()))
list_a.sort(reverse=True)
alice = 0; bob = 0
for i in range(0,100):
    if i % 2 == 0:
        alice += list_a[i]
    else:
        bob += list_a[i]
print(alice-bob)

Buggy submission (verdict: Runtime Error):
N = int(input())
list_a = list(map(int,input().split()))
list_b = list_a.sort()
alice = 0; bob = 0
for i in range(100):
    if i % 2 == 0:
        alice += list_b[i]
    else:
        bob += list_b[i]
print(alice-bob)
Problem p03449 (python)

Fixed submission:
N = int(input())
a = [list(map(int,input().split())) for i in range(2)]
b = []
for i in range(0,N):
    s = 0
    v = 0
    for j in range(0,i+1):
        s += a[0][j]
    for j in range(i,N):
        v += a[1][j]
    b.append(s+v)
print(max(b))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [list(map(int,input().split())) for i in range(2)]
s = 0; t = 0; u = 0; v = 0
for i in range(0,N):
    for j in range(0,i+1):
        s += a[0][j]
        t += a[1][j]
        u += a[0][N-j-1]
        v += a[1][N-j-1]
	if s>=t and v>=u:
        print(s+v)
Problem p03470 (python)

Fixed submission:
N = int(input())
list_a = [int(input()) for i in range(N)]
s = []
for i in list_a:
    if s.count(i) == 0:
        s.append(i)
print(len(s))

Buggy submission (verdict: Runtime Error):
N = int(input())
list_a = [int(input()) for i in range(N)]
s = []
for i in list_a:
    if s.count(i) == 0
        s.append(i)
print(len(s))
Problem p03471 (python)

Fixed submission:
N,Y = map(int,input().split())
c = 0
for i in range(0,N+1):
    for j in range(0,N+1):
        c = ((Y-(10000*i+5000*j))/1000)
        if c.is_integer and c >= 0 and i+j+c == N:
            d = int(c)
            print(i,j,d)
            exit()
print(-1,-1,-1)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
b1 = 0
b2 = 0
b3 = 0
s = 0
s1 = 0
s2 = 0
t = 0
t1 = 0
u = 0
if b>=10000:
	s = b // 10000
	b1 = b - s*10000
    if 5000<=b1<10000:
        b2 = b1 - 5000
        s1 = b2 // 1000
        if (s + 1 + s1) <= a:
            print(s,1,s1)
        else:
            print(-1,-1,-1)
elif 5000<=b<10000:
    t = b // 5000
    b3 = b - t*5000
    t1 = b3 // 1000
    if (t + t1) <= a:
        print(0,t,t1)
    else:
        print(-1,-1,-1)
elif b<5000:
    u = b // 1000
    if u <= a:
        print(0,0,u)
    else:
        print(-1,-1,-1)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
b1 = 0
b2 = 0
s = 0
s1 = 0
s2 = 0
t = 0
t1 = 0
u = 0
if b>=10000:
	s = b // 10000
	b1 = b - s*10000
    if 5000<=b1<10000:
        b2 = b1 - 5000
        s1 = b2 // 1000
        if (s + 1 + s1) <= a:
            print(s,1,s1)
        else:
            print(-1,-1,-1)
elif 5000<=b<10000:
    t = b // 5000
    b1 = b - t*5000
    t1 = b1 // 1000
    if (t + t1) <= a:
        print(0,t,t1)
    else:
      print(-1,-1,-1)
elif b<5000:
    u = b // 1000
    if u <= a:
        print(0,0,u)
    else:
        print(-1,-1,-1)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
b1 = 0
b2 = 0
s = 0
s1 = 0
s2 = 0
t = 0
t1 = 0
u = 0
if b>=10000:
	s = b / 10000
	b1 = b - s*10000
    if 5000<=b1<10000:
        b2 = b1 - 5000
        s1 = b2 / 1000
        if (s + 1 + s1) <= a:
            print(s,1,s1)
        else:
            print(-1,-1,-1)
elif 5000<=b<10000:
    t = b / 5000
    b1 = b - t*5000
    t1 = b1 / 1000
    if (t + t1) <= a:
        print(0,t,t1)
    else:
      print(-1,-1,-1)
elif b<5000:
    u = b / 1000
    if u <= a:
        print(0,0,u)
    else:
        print(-1,-1,-1)
Problem p03502 (python)

Fixed submission:
N = int(input())
n = N
s = 0
for i in range(10):
    a = n % 10
    s += a
    if n // 10 == 0:
        break
    else:
        n = n // 10
if N % s == 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
s = 0
while N//10 > 0
    a = N % 10
    s += a
    N = N // 10
if N % s == 0:
    print("Yes")
else:
    print("No")
Problem p02613 (python)

Fixed submission:
N = int(input())

ac, wa, tle, re = 0, 0, 0, 0

for i in range(N):
  S = input()
  if S=='AC':
    ac+=1
  elif S=='WA':
    wa+=1
  elif S=='TLE':
    tle+=1
  elif S=='RE':
    re+=1

print('AC x %d'%ac)
print('WA x %d'%wa)
print('TLE x %d'%tle)
print('RE x %d'%re)

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

ac, wa, tle, re = 0, 0, 0, 0

for i in range(N):
  S = int(input())
  if S=='AC':
    ac+=1
  elif S=='WA':
    wa+=1
  elif S=='TLE':
    tle+=1
  elif S=='RE':
    re+=1

print('AC x %d'%ac)
print('WA x %d'%wa)
print('TLE x %d'%tle)
print('RE x %d'%re)

Buggy submission (verdict: Runtime Error):
N = int(input())
ac, wa, tle, re = 0, 0, 0, 0
for _ in range(10):
  S = int(input())
  if S == 'AC':
    ac+=1
  elif S == 'WA':
    wa+=1
  elif S == 'TLE':
    tle+=1
  elif S == 'RE':
    re+=1

print('AC x %d'%ac)
print('WA x %d'%wa)
print('TLE x %d'%tle)
print('RE x %d'%re)

Buggy submission (verdict: Runtime Error):
N = int(input())
ac, wa, tle, re = 0, 0, 0, 0
for _ in range(N):
  S = int(input())
  if S == 'AC':
    ac+=1
  elif S == 'WA':
    wa+=1
  elif S == 'TLE':
    tle+=1
  elif S == 'RE':
    re+=1

print('AC x %d'%ac)
print('WA x %d'%wa)
print('TLE x %d'%tle)
print('RE x %d'%re)

Buggy submission (verdict: Runtime Error):
N = int(input())
ac, wa, tle, re = 0, 0, 0, 0
for _ in range(N):
  S = int(input())
  if S == 'AC':
    ac+=1
  elif S == 'WA':
    wa+=1
  elif S == 'TLE':
    tle+=1
  elif S == 'RE':
    re+=1

print('AC x %d'%ac)
print('WA x %d'%wa)
print('TLE x %d'%tle)
print('RE x %d'%re)

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

ac, wa, tle, re = 0, 0, 0, 0

for _ in range(N):
    S = int(input())
    if S == 'AC':
        ac+=1
    elif S == 'WA':
        wa+=1
    elif S == 'TLE':
        tle+=1
    elif S == 'RE':
        re+=1

print('AC x %d'%ac)
print('WA x %d'%wa)
print('TLE x %d'%tle)
print('RE x %d'%re)

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

ac, wa, tle, re = 0, 0, 0, 0

for _ in range(N):
    S = int(input())
    if S == 'AC':
        ac+=1
    elif S == 'WA':
        wa+=1
    elif S == 'TLE':
        tle+=1
    elif S == 'RE':
        re+=1

print('AC x %d'%ac)
print('WA x %d'%wa)
print('TLE x %d'%tle)
print('RE x %d'%re)

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

ac, wa, tle, re = 0, 0, 0, 0

for _ in range(N):
    S = int(input())
    if S == 'AC':
        ac+=1
    elif S == 'WA':
        wa+=1
    elif S == 'TLE':
        tle+=1
    elif S == 'RE':
        re+=1

print('AC x %d'%ac)
print('WA x %d'%wa)
print('TLE x %d'%tle)
print('RE x %d'%re)
Problem p02639 (python)

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

_sum = sum(data)

print( 15-_sum )

Buggy submission (verdict: Runtime Error):
data = list(map(int, input()))

_sum = sum(data)

print( 15-_sum )
Problem p02628 (python)

Fixed submission:
n,k = map(int,input().split())
p = [int(i) for i in input().split()]
p.sort()
s = 0
for i in range(k) :
    s += p[i]
print(s)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
p = [int(i) for i in input().split()]
p.sort()
for i in range(k) :
    s += p[i]
print(s)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
p = [int(i) for i in input().split()]
p.sort()
s = p[0]+p[1]+p[2]
print(s)
Problem p03000 (python)

Fixed submission:
N,X = map(int,input().split())
L = [int(i) for i in input().split()]
D = 0
for i in range(N) :
    D = L[i]+D
 #   print(i,D)
    if D>X :
        print(i+1)
        exit()

print(N+1)

Buggy submission (verdict: Runtime Error):
N,X = map(int,input().split())
L = [int(i) for i in input().split()]
D = 0
for i in range(N+2) :
    D = L[i]+D
#    print(i,D)
    if D>X :
        print(i+1)
        exit()

print(N)
Problem p03544 (python)

Fixed submission:
N = int(input())
l = [2,1]
if N  == 1 :
    print(l[1])
    exit()
for i in range(2,N+1) :
    l.append(l[i-2] + l[i-1])
print(l[-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
l = [2,1]
if N <= 2 :
    print(l[N])
    exit()
for i in range(2,N+1) :
    l.append(l[i-2] + l[i-1])
print(l[-1])
Problem p03861 (python)

Fixed submission:
a,b,x = map(int,input().split())
fb = b//x+1
if a!= 0 :
    fa = (a-1)//x+1
else :
    fa = 0
print(fb-fa)

Buggy submission (verdict: Runtime Error):
a,b,x = map(int,input().split())
fb = b//x+1
if a!= 0 :
    fa = (a-1)//x+1
else :
    0
print(fb-fa)
Problem p03971 (python)

Fixed submission:
N, A, B = map(int,input().split())
S = list(input())
b = 0
c = 0

for i in range(N) :
    if (S[i] == 'a') and (c < A + B) :
        print('Yes')
        c += 1
    elif S[i] == 'b' and (c < A + B) and b < B:
        print('Yes')
        b += 1
        c += 1
    else :
        print('No')

Buggy submission (verdict: Runtime Error):
or i in range(N) :
    if (S[i] == 'a') and (c < A + B) :
        print('Yes')
        c += 1
    elif S[i] == 'b' and (c < A + B) and b < B:
        print('Yes')
        b += 1
        c += 1
    else :
        print('No')
Problem p02630 (python)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
q = int(input())
BC = [list(map(int, input().split())) for i in range(q)]

list=[0]*100001
sum=sum(A)
for i in A:
    list[i]+=1

for bc in BC:
    x=list[bc[0]]
    sum+=(bc[1]-bc[0])*x
    print(sum)
    list[bc[0]]-=x
    list[bc[1]]+=x

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
q = int(input())
BC = [list(map(int, input().split())) for i in range(q)]

list=[0]*100000
sum=sum(A)
for i in A:
    list[i]+=1

for bc in BC:
    x=list[bc[0]]
    sum+=(bc[1]-bc[0])*x
    print(sum)
    list[bc[0]]-=x
    list[bc[1]]+=x

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
q = int(input())
BC = [list(map(int, input().split())) for i in range(q)]

list=[0]*100000
sum=sum(A)
for i in A:
    list[i]+=1

for bc in BC:
    x=list[bc[0]]
    sum-=bc[0]*x
    sum+=bc[1]*x
    print(sum)
    list[bc[0]]-=x
    list[bc[1]]+=x
Problem p02678 (python)

Fixed submission:
import numpy as np

n, m = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(m)]

root = []
for i in range(n):
    root.append(set())

for ab in AB:
    root[ab[0]-1].add(ab[1]-1)
    root[ab[1]-1].add(ab[0]-1)

sign = [0]*n
sign[0]=-1
list = [0]

while True:
    x = list.pop(0)

    for next in root[x]:
        if sign[next]==0:
            sign[next]=x+1
            list.append(next)

    if len(list)==0:
        break

print('Yes')
for p in sign[1:]:
    print(p)

Buggy submission (verdict: Runtime Error):
import numpy as np

n, m = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(m)]

root = np.zeros((n,n), dtype = int)

for ab in AB:
    root[ab[0]-1][ab[1]-1]=1
    root[ab[1]-1][ab[0]-1]=1

sign = [0]*n
sign[0]=-1
list = [0]

while True:
    x = list.pop(0)

    for y, bool in enumerate(root[x]):
        if sign[y]==0 and bool==1:
            sign[y]=x+1
            list.append(y)

    if len(list)==0:
        break

print('Yes')
for p in sign[1:]:
    print(p)