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

Fixed submission:
S = input()
i = 0
n = len(S)
while i <= n-5:
    if S[i:i+5] == "dream":
        i += 5
        if S[i:i+2] == "er" and S[i:i+5] != "erase":
            i += 2
    elif S[i:i+5] == "erase":
        i += 5
        if S[i:i+1] == "r":
            i += 1
    else:
        break
if i != len(S):
    print("NO")
else:
    print("YES")

Buggy submission (verdict: Runtime Error):
S = input()
i = 0
while i <= len(S)-5:
    if S[i:i+5] == "dream":
        i += 5
        if S[i:i+2] == "er" and S[i:i+5] != "erase":
            i += 2
    elif S[i:i+5] == "erase":
        i += 5
        if S[i] == "r":
            i += 1
    else:
        break
if i != len(S):
    print("NO")
else:
    print("YES")
Problem p02582 (python)

Fixed submission:
import sys
input = sys.stdin.readline
def main():
    S = input().rstrip()
    CNT = 0
    ans = 0
    for c in S:
        if c == 'R':
            CNT += 1
        else:
            ans = max(ans,CNT)
            CNT = 0

    ans = max(ans,CNT)
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def main():
    S = input().rstrip()
    CNT = 0
    ans = 0
    for c in S:
        if c == 'R':
            CNT += 1
        else:
            ans = max(ans,CNT)
            CNT = 0
    print(ans)


if __name__ == '__main__':
    main)
Problem p02684 (python)

Fixed submission:
import sys
input = sys.stdin.readline
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    D = 1
    LOG = {}
    PATH = []
    for i in range(N):
        PATH.append(D)
        LOG.setdefault(D,i)

        if LOG[D] == i:
            D = A[D-1]
            # print(PATH,LOG, i)
            continue
        else:
            # print("break",D, i)
            break

    # if i-LOG[D] < K:
    if LOG[D] < K:
        K = (K-i)%(i-LOG[D])
        LAST = PATH[LOG[D]+K]
    else:
        LAST = PATH[K]
    print(LAST)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    flag = True
    D = 0
    now = 1
    LOG = {}
    PATH = []
    for i in range(N):
        PATH.append(D)
        LOG.setdefault(D,i)

        if LOG[D] == i:
            D = A[D]-1
            continue
        else:
            print("break",D)
            start = D
            break
        # print(PATH, D)
    K = K%i
    LAST = PATH[LOG[D] + K] +1
    print(LAST)



if __name__ == '__main__':
    main()
Problem p02732 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
CNT = [0]*(N+1)
# IND = list(set(A))
# CNT = [A.count(x) for x in IND]
for i in A:
    CNT[i] += 1
# print(IND)
# print(CNT)
# CONB = [A.count(x)*(A.count(x)-1)//2 for x in IND]
CONB = [CNT[x]*(CNT[x]-1)//2 for x in range(len(CNT))]
# print(CONB)
SUM = sum(CONB)
for i in A:
    ans = SUM - CNT[i] + 1
    print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
IND = list(set(A))
CNT = [A.count(x) for x in IND]
# print(IND)
# print(CNT)
# CONB = [A.count(x)*(A.count(x)-1)//2 for x in IND]
CONB = [CNT[x]*(CNT[x]-1)//2 for x in range(len(CNT))]
# print(CONB)
SUM = sum(CONB)
for i in A:
    ans = SUM - CNT[i-1] + 1
    print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
IND = list(set(A))
CNT = [A.count(x) for x in IND]
# print(IND)
# print(CNT)
CONB = [CNT[x-1]*(CNT[x-1]-1)//2 for x in IND]
# print(CONB)
SUM = sum(CONB)
CALC = [-1]*(N+1)
for i in A:
    if CALC[i] != -1:
        print(CALC[i])
    else:
        # n = CNT[IND.index(i)]
        # ans = SUM - CONB[IND.index(i)] + (n-1)*(n-2)//2
        ans = SUM - CNT[i-1] + 1
        CALC[i] = ans
        print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
IND = list(set(A))
# CNT = [A.count(x) for x in IND]
# print(IND)
# print(CNT)
CONB = [A.count(x)*(A.count(x)-1)//2 for x in IND]
# print(CONB)
SUM = sum(CONB)
CALC = [-1]*(N+1)
for i in A:
    if CALC[i] != -1:
        print(CALC[i])
    else:
        # n = CNT[IND.index(i)]
        # ans = SUM - CONB[IND.index(i)] + (n-1)*(n-2)//2
        ans = SUM - CONB[IND.index(i)] + CONB[IND.index(i-1)]
        CALC[i] = ans
        print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
IND = list(set(A))
CNT = [A.count(x) for x in IND]
# print(IND)
# print(CNT)
CONB = [x*(x-1)//2 for x in CNT]
# print(CONB)
SUM = sum(CONB)
CALC = [-1]*N
for i in A:
    if CALC[i] != -1:
        print(CALC[i])
    else:
        n = CNT[IND.index(i)]
        ans = SUM - CONB[IND.index(i)] + (n-1)*(n-2)//2
        CALC[i] = ans
        print(ans)
Problem p02812 (python)

Fixed submission:
n = int(input())
s = str(input())
c = 0
for i in range(n-2):
  if s[i] == "A":
    if s[i+1] == "B" and s[i+2] == "C":
      c += 1
print(c)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = str(input())
c = 0
for i in range(len(s)):
  if s[i] == "A":
    if s[1+1] == "B" and s[i+2] == "C":
      c += 1
print(c)
Problem p02945 (python)

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

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
print(max(max(A+B, A-B), A*B))
Problem p02957 (python)

Fixed submission:
A, B = map(int, input().split())
if (A+B)%2 == 0:
    print((A+B)//2)
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
if (A+B)%2 != 0:
    print((A+B)//2)
else:
    print("IMPOSSIBLE)
Problem p02958 (python)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))
CNT = 0
for i in range(N):
  if P[i] != i+1:
    CNT += 1
print('YES' if  CNT <=  2 else 'NO')

Buggy submission (verdict: Runtime Error):
N = int(input())
P = list(map(int, input().split()))
CNT = 0
for i in range(N):
  if P[i] == i+1
    CNT += 1
print('YES' if  CNT <=  2 else 'NO')
Problem p02993 (python)

Fixed submission:
S = input()
for i in range(1,4):
  if S[i] == S[i-1]:
    print('Bad')
    break
else:
  print('Good')

Buggy submission (verdict: Runtime Error):
S = input()
for i in range(1,5):
  if S[i] == S[i-1]:
    print('Bad')
    break
else:
  print('Good')

Buggy submission (verdict: Runtime Error):
S = input()
for i in range(1,5):
  if S[i] == S[i-1]:
    print('Bad')
    break
Problem p03044 (python)

Fixed submission:
import sys
input = sys.stdin.readline
from collections import deque
def bfs(now):
    plan = deque()
    plan.append(now)
    while plan:
        now = plan.popleft()
        color = COLOR[now]
        for bady, l in LINK[now]:
            if COLOR[bady] != -1:
                continue
            plan.append(bady)
            if l%2:
                COLOR[bady] = 1 - color
            else:
                COLOR[bady] = color

if __name__ == '__main__':
    N = int(input())
    LINK = [[]*(N+1) for i in range(N+1)]
    # LINK = [deque()*(N+1) for i in range(N+1)]
    for i in range(N-1):
        a, b, l = map(int, input().split())
        LINK[a].append([b, l])
        LINK[b].append([a, l])
    # print(LINK)
    # print(LINK[1])
    # print(LINK[1][0])
    COLOR= [-1]*(N+1)
    COLOR[1] = 1
    bfs(1)
    for i in range(1,N+1):
        print(COLOR[i])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from collections import deque
def bfs(now):
    plan = deque()
    plan.append(now)
    while plan:
        now = plan.popleft()
        for bady, l in LINK[now]:
            if COLOR[bady] != -1:
                continue
            plan.append(bady)
            if l%2:
                COLOR[bady] = 1
            else:
                COLOR[bady] = 0

if __name__ == '__main__':
    N = int(input())
    LINK = [deque()*(N+1) for i in range(N+1)]
    for i in range(N-1):
        a, b, l = map(int, input().split())
        LINK[a].append([b, l])
        LINK[b].append([a, l])
    # print(LINK)
    # print(LINK[1])
    # print(LINK[1][0])
    COLOR= [-1]*(N+1)
    bfs(1)
    for i in range(1,N+1):
        print(COLOR[i])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from collections import deque
def bfs(now):
    plan = deque()
    plan.append(now)
    while plan:
        now = plan.popleft()
        for bady, l in LINK[now]:
            print(bady, l)
            if COLOR[bady] != -1:
                continue
            plan.append(bady)
            if l%2:
                COLOR[bady] = 1
            else:
                COLOR[bady] = 0

if __name__ == '__main__':
    N = int(input())
    LINK = [deque()*(N+1) for i in range(N+1)]
    for i in range(N-1):
        a, b, l = map(int, input().split())
        LINK[a].append([b, l])
        LINK[b].append([a, l])
    # print(LINK)
    # print(LINK[1])
    # print(LINK[1][0])
    COLOR= [-1]*(N+1)
    bfs(1)
    for i in range(1,N+1):
        print(COLOR[i])
Problem p03433 (python)

Fixed submission:
n = int(input())
a = int(input())
coin = n%500
if a >= coin:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = int(input())
coin = n%500
if a >= coin:
  print("Yes")
else:
  priont("No")
Problem p03633 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**9) 
input = sys.stdin.readline
def gdc(a, b):
    if b == 0:
        return a
    return gdc(b, a%b)
def lcm(a,b):
    return a*b//gdc(a,b)

def main():
    N = int(input())
    T = [int(input()) for i in range(N)]
    if N == 1:
        return print(T[0])
    ans = lcm(max(T[0], T[1]), min(T[0], T[1]))
    if N == 2:
        print(ans)
        return
    for i in range(2,N):
        ans = lcm(max(ans, T[i]), min(ans, T[i]))
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9) 
input = sys.stdin.readline
def gdc(a, b):
    if b == 0:
        return a
    return gdc(b, a%b)
def lcm(a,b):
    return a*b//gdc(a,b)

def main():
    N = int(input())
    T = [int(input()) for i in range(N)]
    ans = lcm(max(T[0], T[1]), min(T[0], T[1]))
    if N == 2:
        print(ans)
        return
    for i in range(2,N):
        ans = lcm(max(ans, T[i]), min(ans, T[i]))
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def gdc(a, b):
    if b == 0:
        return a
    return gdc(b, a%b)
def lcm(a,b):
    return a*b//gdc(a,b)

def main():
    N = int(input())
    T = [int(input()) for i in range(N)]
    ans = lcm(max(T[0], T[1]), min(T[0], T[1]))
    if N == 2:
        print(ans)
        return
    for i in range(2,N):
        ans = lcm(max(ans, T[i]), min(ans, T[i]))
    print(ans)

if __name__ == '__main__':
    main()
Problem p03262 (python)

Fixed submission:
import fractions

N, X = map(int, input().split())
x = list(map(int, input().split()))

ans = abs(X-x[0])
for pos in x:
    ans = fractions.gcd(ans, abs(X-pos))

print(ans)

Buggy submission (verdict: Runtime Error):
import bisect

N, X = map(int, input().split())
x = list(map(int, input().split()))

x.sort()
lb = bisect.bisect_left(x, X)
ub = bisect.bisect_right(x, X)
left = abs(x[lb] - X)
right = abs(x[ub] - X)
ans = min(left, right)

print(ans)
Problem p03282 (python)

Fixed submission:
s = input()
k = int(input())

for i in range(min(len(s), k)):
    if int(s[i]) > 1:
        print(s[i])
        exit(0)

print(1)

Buggy submission (verdict: Runtime Error):
s = input()
k = input()

if s[0] == '1':
    print(s[1])
else:
    print(s[0])
Problem p03612 (python)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
p.append(0)
for i in range(n): p[i] -= 1

ans = 0
for i in range(n):
    if p[i] == i:
        ans += 1
        p[i], p[i+1] = p[i+1], p[i]

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
p = list(map(int, input().split()))
for i in range(n): p[i] -= 1

ans = 0
for i in range(n):
    if p[i] == i:
        ans += 1
        p[i], p[i+1] = p[i+1], p[i]

print(ans)
Problem p02548 (python)

Fixed submission:
N = int(input())
count = 0
for i in range(1,N):
    count = count + (N-1)//i
print(count)

Buggy submission (verdict: Runtime Error):
import sympy
N = int(input())
count = 0
for i in range(0,N):
    count = count + sympy.divisor_count(i)
print(count)
Problem p02621 (python)

Fixed submission:
N = int(input())
print(N+N*N+N*N*N)

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
import bisect

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_acc = [0] + list(accumulate(a))  # aを0冊読む=1冊も読まない場合があるので、[0]を先頭に追加します
b_acc = list(accumulate(b))  # bisect_rightでは、x以下の要素がいくつあるか？を求めるので、こちらに0は入れません

ans = 0
for an in range(n + 1):
    rem = k - a_acc[an]
    if rem < 0:
        # aをこれ以上読めません
        break

    bn = bisect.bisect_right(b_acc, rem)
    ans = max(ans, an + bn)

print(ans)
Problem p02628 (python)

Fixed submission:
A,B=map(int,input().split())
C = list(map(int,input().split()))
C.sort()
D = 0
for i in range(0,B):
    D = D + C[i]
print(D)

Buggy submission (verdict: Runtime Error):
A,B=map(int,input().split())
C = list(map(int,input().split()))
C.sort()
D = C[0]+C[1]+C[2]
print(D)
Problem p02553 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
ans=0
if a>=0:
    if c>=0:
        ans=b*d
    elif d>=0:
        ans=b*d
    else:
        ans=a*d
elif b>=0:
    if c>=0:
        ans=b*d
    elif d>=0:
        ans=max(b*d,a*c)
    else:
        ans=a*c
else:
    if c>=0:
        ans=b*c
    elif d>=0:
        ans=a*c
    else:
        ans=a*c
print(ans)

Buggy submission (verdict: Runtime Error):
ans=max(max(a*c,a*d),max(b*c,b*d))
print(ans)

Buggy submission (verdict: Runtime Error):
ans=max(a*c,a*d,b*c,b*d)
print(ans)
Problem p02573 (python)

Fixed submission:
from collections import deque

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

group=[]
seen=[0]*N
ans=0
for i in range(N):
    if seen[i]: continue
    que=deque()
    seen[i]=1
    cnt=0
    que.append(i)
    while que:
        cnt+=1
        v=que.popleft()
        for nv in G[v]:
            if seen[nv]: continue
            seen[nv]=1
            que.append(nv)
    ans=max(ans,cnt)

print(ans)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(M)]

f=[[] for _ in range(N+1)]
for i in range(M):
    f[s[i][0]].append(s[i][1])

found=[0 for _ in range(N+1)]
ans=0

def find(bi,i,root,found):
    if root[i]:
        return
    root[i]=1
    found[i]=1
    f[i].append(bi)
    for j in range(len(f[i])):
        find(i,f[i][j],root,found)

for i in range(1,N+1):
    if found[i]: continue
    root=[0 for _ in range(N+1)]
    find(i,i,root,found)
    tmp=root.count(1)
    if ans<tmp:
        ans=tmp
print(ans)
Problem p02579 (python)

Fixed submission:
from collections import deque

H,W=map(int,input().split())
sy,sx=map(int,input().split())
gy,gx=map(int,input().split())
field=[list(input()) for _ in range(H)]
sy,sx,gy,gx=sy-1,sx-1,gy-1,gx-1

Walk=[[1,0],[0,1],[-1,0],[0,-1]]
Warp=[[i,j] for i in range(-2,3) for j in range(-2,3)] 

dist=[[-1]*W for _ in range(H)]
que=deque()
dist[sy][sx]=0
que.append([sy,sx])

while que:
    y,x=que.popleft()
    for walk in Walk:
        nx,ny=x+walk[0],y+walk[1]
        if nx<0 or nx>=W or ny<0 or ny>=H: continue
        if field[ny][nx]=="#": continue
        if dist[ny][nx]!=dist[y][x]:
            dist[ny][nx]=dist[y][x]
            que.appendleft([ny,nx])
    
    for warp in Warp:
        nx,ny=x+warp[0],y+warp[1]
        if nx<0 or nx>=W or ny<0 or ny>=H: continue
        if field[ny][nx]=="#": continue
        if dist[ny][nx]==-1:
            dist[ny][nx]=dist[y][x]+1
            que.append([ny,nx])

print(dist[gy][gx])

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
C=list(map(int,input().split()))
C[0]+=1
C[1]+=1
D=list(map(int,input().split()))
D[0]+=1
D[1]+=1
S=["#"*(W+4)]
S.append("#"*(W+4))
for _ in range(H):
    tmp=input()
    tmp="##"+tmp+"##"
    S.append(tmp)
S.append("#"*(W+4))
S.append("#"*(W+4))

def walk(k,alk,x,y):
    global found
    if x==D[0] and y==D[1]:
        S[x]=S[x][:y]+"{}".format(k)+S[x][y+1:]
        found=True
        return 0
    if S[x][y]==".":
        alk.append([x,y])
        S[x]=S[x][:y]+"{}".format(k)+S[x][y+1:]
        walk(k,alk,x-1,y)
        walk(k,alk,x,y-1)
        walk(k,alk,x+1,y)
        walk(k,alk,x,y+1)

def warp(k,arp,x,y):
    for i in range(-2,3):
        for j in range(-2,3):
            if S[x+i][y+j]==".":
                arp.append([x+i,y+j])
                S[x+i]=S[x+i][:y+j]+"{}".format(k)+S[x+i][y+j+1:]

k=0
alk=[]
arp=[[C[0],C[1]]]
found=False
while not found:
    alk=arp
    for i in range(len(arp)):
        x,y=arp[i][0],arp[i][1]
        walk(k,alk,x,y)
        if found:
            print(k)
            break
    if found:
        break
    k+=1
    arp=[]
    for i in range(len(alk)):
        x,y=alk[i][0],alk[i][1]
        warp(k,arp,x,y)
    if len(arp)==0:
        print(-1)
        break
Problem p02607 (python)

Fixed submission:
N=int(input())
a=list(map(int,input().split()))
cnt=0

for i in range(0,len(a),2):
    if a[i]%2==1:
        cnt+=1

print(cnt)

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

for i in range(int(len(a)/2)+1):
    if a[2*i]%2==1:
        cnt+=1

print(cnt)
Problem p02616 (python)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
div=7+10**9
ans=1
t=0
i,j=0,N-1

if A[-1]<0 and K%2==1:
    for i1 in range(N-K,N):
        ans*=A[i1]
        ans%=div
else:
    while t<K-1:
        if A[i]*A[i+1]>A[j]*A[j-1]:
            ans*=A[i]*A[i+1]
            ans%=div
            i+=2
            t+=2
        else:
            ans*=A[j]
            ans%=div
            j+=-1
            t+=1
    if t==K-1:
        ans*=A[j]
        ans%=div

print(ans)

Buggy submission (verdict: Runtime Error):
import copy
N,K=map(int,input().split())
A=list(map(int,input().split()))

B=[]
onlyminus=True
for i in range(N):
    if A[i]>=0:
        B.append([A[i],1])
        onlyminus=False
    else:
        B.append([abs(A[i]),-1])

C=[]
ans=1
div=7+10**9

if onlyminus:
    A.sort(reverse=True)
    for i in range(K):
        ans*=A[i]
else:
    B.sort(reverse=True)
    cnt=0
    for i in range(K):
        C.append(B[i])
        if B[i][1]==-1:
            cnt+=1

    if cnt%2==1:
        Ck=copy.deepcopy(C[-1])
        del C[-1]
        i=K
        if Ck[1]==1:
            while B[i][1]==1:
                i+=1
        else:
            while B[i][1]==-1:
                i+=1
        C.append(B[i])

    for i in range(K):
        ans*=C[i][0]

print(ans%div)
Problem p02814 (python)

Fixed submission:
from functools import reduce
import math
def lcm_base(x, y):
  return (x * y) // math.gcd(x, y)

def lcm(*numbers):
  return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
  return reduce(lcm_base, numbers, 1)

n,m = map(int, input().split())
a = list(map(int, input().split()))
a = [i//2 for i in list(set(a))]
nothing = False
cnt_common = -1
for i in a:
  cnt = 0
  while i % 2 == 0:
    i = i//2
    cnt += 1
  if cnt_common == -1:
    cnt_common = cnt
    continue
  if cnt_common != cnt:
    nothing = True
    break

b=lcm_list(a)
if nothing:
  print(0)
else:
  ans = (m-b)//(2*b) + 1
  print(max(ans,0))

Buggy submission (verdict: Runtime Error):
from functools import reduce
import math
def lcm_base(x, y):
  return (x * y) // math.gcd(x, y)

def lcm(*numbers):
  return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
  return reduce(lcm_base, numbers, 1)

n,m = map(int, input().split())
a = list(map(int, input().split()))
a = [i//2 for i in list(set(a))]

cnt_common = -1
for i in a:
  cnt = 0
  while i % 2 == 0:
    i = i//2
    cnt += 1
  if cnt_common == -1:
    cnt_common = cnt
    continue
  if cnt_common != cnt:
    nothing = True
    break

b=lcm_list(a)
if nothing:
  print(0)
else:
  ans = (m-b)//(2*b) + 1
  print(max(ans,0))
Problem p02838 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
MOD = 10 ** 9 + 7
digit = 60
o=[0]*digit
z=[0]*digit

for i in a:
  for j in range(digit):
    if (i >> j) & 1:
      o[j] += 1
    else:
      z[j] += 1
ans = 0    
for j in range(digit):
  ans += (o[j]*z[j]*pow(2,j,MOD))
print(ans % MOD)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
MOD = 10 ** 9 + 7
digit = 60
o=[0]*digit
z=[0]*digit

for i in a:
  for j in range(digit):
    if (i >> j) & 1:
      o[j] += 1
    else:
      z[j] += 1
ans = 0
for j in range(digit):
  ans += (o[j]*z[j]*2**j
print(ans % MOD)
Problem p02885 (python)

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

if 2 * m <= n:
  print(n - 2 * m)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
import sys

def wf(d):
  for i in range(n):
    for j in range(n):#start
      for k in range(n):#end
        d[j][k]=min(d[j][k], d[j][i] + d[i][k])
  return d

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

d=[[sys.maxsize]*(n) for _ in range(n)]
e=[[sys.maxsize]*(n) for _ in range(n)]
for i in range(n):
  d[i][i] = 0
  e[i][i] = 0

for _ in range(m):
  a,b,c = map(int, input().split())
  d[a-1][b-1]=c
  d[b-1][a-1]=c

d=wf(d)
for i in range(n):
  for j in range(n):
    if d[i][j] <= l:
      e[i][j] = 1

e=wf(e)

q=int(input())
for _ in range(q):
  s,t = map(int, input().split())
  if e[s-1][t-1] == sys.maxsize:
    print(-1)
  else:
    print(e[s-1][t-1]-1)

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

if n % 2 == 0:
  print((n // 2) / n)
else:
  print((int(n / 2) + 1)  / n)
Problem p02936 (python)

Fixed submission:
import sys
sys.setrecursionlimit(200000000)
n,q = map(int, input().split())
graph1 = [[] for _ in range(n+1)]
graph2 = [[] for _ in range(n+1)]
ans=[0]*(n+1)
reached=[0]*(n+1)
def main():
  for i in range(n-1):
    a,b = map(int, input().split())
    graph1[a].append(b)
    graph2[b].append(a)

  for i in range(q):
    p,x = map(int, input().split())
    ans[p] += x
  dfs(1) 
  print(' '.join([str(i) for i in ans[1:]]))

def dfs(i):
  if reached[i] == 1:
    return
  reached[i] = 1
  for g in graph1[i], graph2[i]:
    for j in g:
      if reached[j] == 1:
        continue
      ans[j] += ans[i]
      dfs(j)

if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
n,q = map(int, input().split())
graph1 = [[] for _ in range(n+1)]
graph2 = [[] for _ in range(n+1)]
ans=[0]*(n+1)
reached=[0]*(n+1)
def main():
  for i in range(n-1):
    a,b = map(int, input().split())
    graph1[a].append(b)
    graph2[b].append(a)

  for i in range(q):
    p,x = map(int, input().split())
    ans[p] += x
  dfs(1) 
  print(' '.join([str(i) for i in ans[1:]]))

def dfs(i):
  if reached[i] == 1:
    return
  reached[i] = 1
  for g in graph1[i], graph2[i]:
    for j in g:
      if reached[j] == 1:
        continue
      ans[j] += ans[i]
      dfs(j)

if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
n,q = map(int, input().split())
graph = [[] for _ in range(n+1)]
ans=[0]*(n+1)
def main():
  for i in range(n-1):
    a,b = map(int, input().split())
    graph[a].append(b)

  for i in range(q):
    p,x = map(int, input().split())
    ans[p] += x
  dfs(1) 
  print(' '.join([str(i) for i in ans[1:]]))

def dfs(i):
  for j in graph[i]:
    ans[j] += ans[i]
    dfs(j)

if __name__ == '__main__':
    main()
Problem p02999 (python)

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

if x >= a:
  print(10)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))

d=[0]
for i in range(1, n+1):
  d.append(d[-1]+l[i-1])
  
print(len([i for i in d if i <= x]))