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

Fixed submission:
from sys import stdin,stdout
n,k=map(int,stdin.readline().split())
a=list(map(int,stdin.readline().split()))
for i in range(k,n):
    print('Yes' if a[i]>a[i-k] else 'No')

Buggy submission (verdict: Runtime Error):
from sys import stdin,stdout
from numba import njit
@njit
def fn(i):
    return pro[i]//(pro[i-k] if i-k>=0 else 1)
n,k=map(int,stdin.readline().split())
a=list(map(int,stdin.readline().split()))
pro=[a[0]]
for v in a[1:]:
    pro+=[pro[-1]*v]
for i in range(k,n):
    #print(fn(i),fn(i-1))
    if fn(i)>fn(i-1):print('Yes')
    else:print('No')
Problem p02684 (python)

Fixed submission:
from sys import stdin,stdout
from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)
def dfs1(src):
    global steps
    if steps==rem:return src
    steps+=1
    return dfs1(g[src][0])
def dfs(src):
    global steps,done,boc,nic
    vis[src]=1
    steps+=1
    if steps-1==k:
        print(src)
        exit(0)
    dfn[src]=steps
    for neigh in g[src]:
        if not vis[neigh]:dfs(neigh)
        else:
            boc,done,nic=[neigh,steps,steps-dfn[neigh]+1]
            # print(done,boc,nic)
            return

n,k=list(map(int,stdin.readline().split()))
done,boc,nic=0,0,0
a=list(map(int,stdin.readline().split()))
g=defaultdict(list)
for i in range(1,n+1):
    g[i]+=[a[i-1]]
vis=[0]*(n+1)
dfn=[0]*(1+n)
steps=0
dfs(1)
# print(done,boc,nic)
left=k-done
rem=(left%nic)
if rem==0:rem=nic
steps=1
print(dfs1(g[boc][0]))

Buggy submission (verdict: Runtime Error):
from sys import stdin,stdout
from collections import defaultdict
def dfs1(src):
    global steps
    if steps==rem:return src
    steps+=1
    return dfs1(g[src][0])
def dfs(src):
    global steps,done,boc,nic
    vis[src]=1
    steps+=1
    dfn[src]=steps
    for neigh in g[src]:
        if not vis[neigh]:dfs(neigh)
        else:
            boc,done,nic=[neigh,steps,steps-dfn[neigh]+1]
            # print(done,boc,nic)
            return

n,k=list(map(int,stdin.readline().split()))
done,boc,nic=0,0,0
a=list(map(int,stdin.readline().split()))
g=defaultdict(list)
for i in range(1,n+1):
    g[i]+=[a[i-1]]
vis=[0]*(n+1)
dfn=[0]*(1+n)
steps=0
dfs(1)
# print(done,boc,nic)
left=k-done
rem=(left%nic)
if rem==0:rem=nic
steps=1
print(dfs1(g[boc][0]))

Buggy submission (verdict: Runtime Error):
from sys import stdin,stdout
from collections import defaultdict
def dfs1(src):
    global steps
    if steps>rem:return src
    steps+=1
    return dfs1(g[src][0])
def dfs(src):
    global steps,done,boc,nic
    vis[src]=1
    steps+=1
    dfn[src]=steps
    for neigh in g[src]:
        if not vis[neigh]:dfs(neigh)
        else:
            boc,done,nic=[neigh,steps,steps-dfn[neigh]+1]
            # print(done,boc,nic)
            return

n,k=list(map(int,stdin.readline().split()))
done,boc,nic=0,0,0
a=list(map(int,stdin.readline().split()))
g=defaultdict(list)
for i in range(1,n+1):
    g[i]+=[a[i-1]]
vis=[0]*(n+1)
dfn=[0]*(1+n)
steps=0
dfs(1)
# print(done,boc,nic)
left=k-done
rem=(left%nic)
if rem==0:rem=nic
steps=1
print(dfs1(boc))
Problem p02582 (python)

Fixed submission:
s = input()

if s[0] == "S":
  if s[1] == "S":
    if s[2] == "S":
      print("0")
    else:
      print("1")
  if s[1] == "R":
    if s[2] == "S":
      print("1")
    else:
      print("2")
if s[0] == "R":
  if s[1] == "S":
    if s[2] == "S":
      print("1")
    else:
      print("1")
  if s[1] == "R":
    if s[2] == "S":
      print("2")
    else:
      print("3")

Buggy submission (verdict: Runtime Error):
s = list(input().split())

if s[0] == S:
  if s[1] == S:
    if s[2] == S:
      print("0")
    else:
      print("1")
  if s[1] == R:
    if s[2] == S:
      print("1")
    else:
      print("2")
if s[0] == R:
  if s[1] == S:
    if s[2] == S:
      print("1")
    else:
      print("1")
  if s[1] == R:
    if s[2] == S:
      print("2")
    else:
      print("3")
Problem p02613 (python)

Fixed submission:
n = int(input())
ACs = 0
WAs = 0
TLEs = 0
REs = 0
for i in range(n):
  result = input()
  if result == "AC":
    ACs += 1
  elif result == "WA":
    WAs += 1
  elif result == "TLE":
    TLEs += 1
  else:
    REs += 1
print("AC x " + str(ACs))
print("WA x " + str(WAs))
print("TLE x " + str(TLEs))
print("RE x " + str(REs))

Buggy submission (verdict: Runtime Error):
n = int(input())
ACs = 0
WAs = 0
TLEs = 0
REs = 0
for i in range(n):
  result = input()
  if result == "AC":
    ACs += 1
  elif result == "WA":
    WAs += 1
  elif result == "TLE":
    TLEs += 1
  else:
    REs += 1
print("AC x " + ACs)
print("WA x " + WAs)
print("TLE x " + TLEs)
print("RE x " + REs)
Problem p02639 (python)

Fixed submission:
num = list(input().split())
for i in range(5):
  if num[i] == "0":
    print(int(str(i + 1)))

Buggy submission (verdict: Runtime Error):
num = list(input().split())
for i in range(6):
  if num[i] == "0":
    print(int(str(i + 1)))

Buggy submission (verdict: Runtime Error):
num = int(input().split())
for i in range(6):
  if num[i] == 0:
    print(int(str(i)))
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
a, b = map(int, input())
print(a*b)
Problem p02675 (python)

Fixed submission:
n = input()
if n[-1] in "24579":
  print("hon")
elif n[-1] in "0168":
  print("pon")
elif n[-1] in "3":
  print("bon")

Buggy submission (verdict: Runtime Error):
n = int(input())
if n[len(n) - 1] == 3:
  print("bon")
elif n[len(n) - 1] == 0 or 1 or 6 or 8:
  print("pon")
else:
  print("hon")
Problem p02681 (python)

Fixed submission:
s = input()
t = input()

if (s == t[:-1]) & (len(s) + 1 == len(t)):
    print("Yes")
else:
    print("No")

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

if (s == t[:-1] & len(s) + 1 == len(t):
    print("Yes")
else:
    print("No")
Problem p02687 (python)

Fixed submission:
s = input()
if s == "ABC":
  print("ARC")
else:
  print("ABC")

Buggy submission (verdict: Runtime Error):
s = input()
if s == ABC:
  print("ARC")
else:
  print("ABC")
Problem p02717 (python)

Fixed submission:
x, y, z = map(int, input().split())
print(z, end='')
print(" ", end='')
print(x, end='')
print(" ", end='')
print(y, end='')

Buggy submission (verdict: Runtime Error):
x, y, z = map(int, input().split())
print(z + " " + x + " " + y)
Problem p02582 (python)

Fixed submission:
s = str(input())
if s == "RRR":
  print(3)
elif s == "RRS" or s == "SRR":
  print(2)
elif s == "RSR" or s == "RSS" or s == "SSR" or s == "SRS":
  print(1)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
if s == "RRR":
  print(3)
elif s == "RRS" or s == "SRR":
  print(2)
elif s == "RSR" or s == "RSS" or s == "SSR" or s == "SRS":
  print(1)
else:
  print(0)
Problem p02842 (python)

Fixed submission:
import math
n = int(input())
px_up = math.ceil(n/1.08)
px_next = (n+1)/1.08
 
if px_up < px_next:
  print(px_up)
else:
  print(":(")

Buggy submission (verdict: Runtime Error):
n = int(input())
px_up = math.ceil(n/1.08)
px_next = (n+1)/1.08
 
if px_up <= px_next:
  print(px_up)
else:
  print(":(")
Problem p02845 (python)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
x=0
y=0
z=0
ans=1
for a in A:
    c=0
    X,Y,Z=x,y,z
    if a==x:
        x+=1
        c+=1
    if a==y:
        c+=1
        if a!=X:
            y+=1
    if a==z:
        c+=1
        if a!=X and a!=Y:
            z+=1
    ans=ans*c%1000000007
print(ans)

Buggy submission (verdict: Runtime Error):
=int(input())
A=list(map(int,input().split()))
x=0
y=0
z=0
ans=1
for a in A:
    c=0
    X,Y,Z=x,y,z
    if a==x:
        x+=1
        c+=1
    if a==y:
        c+=1
        if a!=X:
            y+=1
    if a==z:
        c+=1
        if a!=X and a!=Y:
            z+=1
    ans=ans*c%1000000007
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input()) #長さ
a = str(input().split()) #帽子の数
x = 0
y = 0
z = 0
ans = 1
 
for i in range(n): #1文字目
  if a[i] == str(x):
    if x == y & x == z:
      ans = ans * 3
    elif x == y:
      ans = ans * 2
   	x = x + 1
  elif a[i] == str(y):
    if y == z:
      ans = ans * 2
    y = y + 1
  else:
    z = z + 1
print(ans % 1000000007)

Buggy submission (verdict: Runtime Error):
n = int(input()) #長さ
a = input().split() #帽子の数
x = 0
y = 0
z = 0
ans = 1
 
for i in range(n): #1文字目
  if a[i] == x:
    if x == y & x == z:
      ans = ans * 3
    elif x == y:
      ans = ans * 2
   	x = x + 1
  elif a[i] == y:
    if y == z:
      ans = ans * 2
    y = y + 1
  else:
    z = z + 1
print(ans % 1000000007)

Buggy submission (verdict: Runtime Error):
n = int(input()) #長さ
a = map(int, input().split()) #帽子の数
x = 0
y = 0
z = 0
ans = 1

for i in range(n): #1文字目
  if a[i] == x:
    if x == y & x == z:
      ans = ans * 3
    elif x == y:
      ans = ans * 2
    x = x + 1
  elif a[i] == y:
    if y == z:
      ans = ans * 2
    y = y + 1
  else:
    z = z + 1
print(ans % 1000000007)
Problem p02755 (python)

Fixed submission:
a,b=map(int,input().split())
ans=-1
for i in range(1,10000):
    if i*8//100==a and i*10//100==b:
        ans=i
        break
print(ans)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
x1=a*100//8
x2=b*10
 if x1//10==b:
    print(x1)
else:
    print(-1)
Problem p02579 (python)

Fixed submission:
#辺の重み(変化量)が0である場合は01DFSって特別なやつ
#0の場合はそこでBFSできる
import sys
from collections import deque
sys.setrecursionlimit(10**7)
input=sys.stdin.readline
h,w=map(int,input().split())
c=[int(i)-1 for i in input().split()]
d=[int(i)-1 for i in input().split()]
s=[input() for i in range(h)]
inf=100000000
dp=[[-1 if s[i][j]=="#" else inf for j in range(w)] for i in range(h)]
dp[c[0]][c[1]]=0
now=deque([[c[0],c[1]]])
def bfs():
    global h,w,s,dp,now
    while len(now):
        i,j=now.popleft()
        if i>0:
            if dp[i-1][j]!=-1:
                if dp[i-1][j]>dp[i][j]:
                    dp[i-1][j]=dp[i][j]
                    now.appendleft([i-1,j])
        if j>0:
            if dp[i][j-1]!=-1:
                if dp[i][j-1]>dp[i][j]:
                    dp[i][j-1]=dp[i][j]
                    now.appendleft([i,j-1])
        if i<h-1:
            if dp[i+1][j]!=-1:
                if dp[i+1][j]>dp[i][j]:
                    dp[i+1][j]=dp[i][j]
                    now.appendleft([i+1,j])
        if j<w-1:
            if dp[i][j+1]!=-1:
                if dp[i][j+1]>dp[i][j]:
                    dp[i][j+1]=dp[i][j]
                    now.appendleft([i,j+1])
        for k in range(-2,3):
            for l in range(-2,3):
                if 0<=i+k<h and 0<=j+l<w:
                    if dp[i+k][j+l]!=-1:
                        if dp[i+k][j+l]>dp[i][j]+1:
                            dp[i+k][j+l]=dp[i][j]+1
                            now.append([i+k,j+l])
bfs()
print(dp[d[0]][d[1]] if dp[d[0]][d[1]]!=inf else -1)

Buggy submission (verdict: Runtime Error):
#辺の重み(変化量)が0である場合は01DFSって特別なやつ
#0の場合はそこでBFSできる
import sys
from collections import deque
sys.setrecursionlimit(10**7)
input=sys.stdin.readline
h,w=map(int,input().split())
c=[int(i)-1 for i in input().split()]
d=[int(i)-1 for i in input().split()]
s=[input() for i in range(h)]
inf=100000000
dp=[[-1 if s[i][j]=="#" else inf for j in range(w)] for i in range(h)]
dp[c[0]][c[1]]=0
now=deque([[c[0],c[1]]])
def bfs():
    global h,w,s,dp,now
    while len(now):
        i,j=now.popleft()
        for k,l in [[i-1,j],[i+1,j],[i,j-1],[i,j+1]]:
            if 0<=k<h and 0<=l<w:
                if dp[k][l]!=-1:
                    if dp[k][l]>dp[i][j]:
                        dp[k][l]=dp[i][j]:
                        now.appendleft([k,l])
        for k in range(i-2,i+3):
            for l in range(j-2,j+3):
                if 0<=k<h and 0<=l<w:
                    if dp[k][l]!=-1:
                        if dp[k][l]>dp[i][j]+1:
                            dp[k][l]=dp[i][j]+1
                            now.append([k,l])
bfs()
print(dp[d[0]][d[1]] if dp[d[0]][d[1]]!=inf else -1)
Problem p02603 (python)

Fixed submission:
#bottomかtopか
n=int(input())
a=list(map(int,input().split()))
an=[]
for i in range(1,n):
    if a[i]>a[i-1]:
        an.append(a[i-1])
        if i==n-1:
            an.append(a[i])
        break
pm=0
for j in range(i+1,n):
    #print(pm)
    if pm==0:
        if a[j]>=a[j-1]:
            if j==n-1:
                an.append(a[j])
            continue
        else:
            an.append(a[j-1])
            pm=1
    else:
        if a[j]<=a[j-1]:
            continue
        else:
            an.append(a[j-1])
            pm=0
            if j==n-1:
                an.append(a[j])
#print(an)
ans=1000
k=0
for i in range(len(an)):
    if i%2==0:
        k=ans//an[i]
        ans-=k*an[i]
    else:
        ans+=k*an[i]
        k=0
print(ans)

Buggy submission (verdict: Runtime Error):
#bottomかtopか
n=int(input())
a=list(map(int,input().split()))
an=[]
for i in range(1,n):
    if a[i]>a[i-1]:
        an.append(a[i-1])
        break
pm=0
for j in range(i+1,n):
    #print(pm)
    if pm==0:
        if a[j]>=a[j-1]:
            if j==n-1:
                an.append(a[j])
            continue
        else:
            an.append(a[j-1])
            pm=1
    else:
        if a[j]<=a[j-1]:
            continue
        else:
            an.append(a[j-1])
            pm=0
            if j==n-1:
                an.append(a[j])
#print(an)
ans=1000
k=0
if len(an)==1:
    swvc
    print(ans)
    exit()
for i in range(len(an)):
    if i%2==0:
        k=ans//an[i]
        ans-=k*an[i]
    else:
        ans+=k*an[i]
        k=0
print(ans)
Problem p02609 (python)

Fixed submission:
import math
def popcount(x):
    s=0
    y=int(math.log2(x))+2
    for i in range(y):
        if(x>>i)&1:
            s+=1
    return x%s
n=int(input())
x=input()[::-1]
#1がなんこ出るのか
c=x.count("1")
#c+1とc-1だけ考えれば良い
#c=1の時場合分け
#m[i][j]:2^iまで考えたときのmod(c+j-1)
if c!=1:
    m=[[1%(c-1),1%(c+1)]]
    for i in range(n-1):
        m.append([(2*m[-1][0])%(c-1),(2*m[-1][1])%(c+1)])
    l=[0,0]
    for i in range(n):
        if x[i]=="1":
            l[0]+=m[i][0]
            l[1]+=m[i][1]
            l[0]%=(c-1)
            l[1]%=(c+1)
else:
    m=[[1%(c+1),1%(c+1)]]
    for i in range(n-1):
        m.append([(2*m[-1][0])%(c+1),(2*m[-1][1])%(c+1)])
    l=[0,0]
    for i in range(n):
        if x[i]=="1":
            l[0]+=m[i][0]
            l[1]+=m[i][1]
            l[0]%=(c+1)
            l[1]%=(c+1)
#一個だけ変えたいので全体を求める

#最初以外はpopcount使って間に合う
ans=[0]*n
for i in range(n):
    if x[i]=="1":
        if c-1==0:
            ans[i]=0
            continue
        p=(l[0]+(c-1)-m[i][0])%(c-1)
        ans[i]+=1
        while p!=0:
            p=popcount(p)
            ans[i]+=1
    else:
        p=(l[1]+m[i][1])%(c+1)
        ans[i]+=1
        while p!=0:
            p=popcount(p)
            ans[i]+=1
ans=ans[::-1]
for i in range(n):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
from math import *
def popcount(x):
    s=0
    y=int(log2(x))+2
    for i in range(y):
        if(x>>i)&1:
            s+=1
    return x%s
n=int(input())
x=input()[::-1]
#1がなんこ出るのか
c=x.count("1")
#c+1とc-1だけ考えれば良い
#c=1の時場合分け
#m[i][j]:2^iまで考えたときのmod(c+j-1)
m=[[1%(c-1),1%(c+1)]]
for i in range(1,n):
    m.append([(2*m[-1][0])%(c-1),(2*m[-1][1])%(c+1)])
#一個だけ変えたいので全体を求める
l=[0,0]
for i in range(n):
    if x[i]=="1":
        l[0]+=m[i][0]
        l[1]+=m[i][1]
        l[0]%=(c-1)
        l[1]%=(c+1)
#最初以外はpopcount使って間に合う
ans=[0]*n
for i in range(n):
    if x[i]=="1":
        if c-1==0:
            ans[i]=0
            continue
        p=(l[0]+(c-1)-m[i][0])%(c-1)
        ans[i]+=1
        while p!=0:
            p=popcount(p)
            ans[i]+=1
    else:
        p=(l[1]+m[i][1])%(c+1)
        ans[i]+=1
        while p!=0:
            p=popcount(p)
            ans[i]+=1
ans=ans[::-1]
for i in range(n):
    print(ans[i])
Problem p02651 (python)

Fixed submission:
#一次独立：rankが成分数
import numpy as np
#0-indexed,MSBがma以下の時
def msb(x,ma=59):
    for i in range(ma,-1,-1):
        if (x>>i)&1:
            return i
    return len()
t=int(input())
for _ in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    s=input()
    #独立、msb同じものはない
    #逆に異なれば独立
    msbs=[0 for i in range(60)]
    for i in range(n-1,-1,-1):
        now=a[i]
        m=59
        #独立のときfはTrue、独立でない時fはFalse
        while True:
            m=msb(now,m)
            if msbs[m]==0:
                f=True
                break
            now=msbs[m]^now
            if now==0:
                f=False
                break
        if s[i]=="0":
            if f:
                msbs[m]=now
        else:
            if f:
                print(1)
                break
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
I=input
n=int
for i in range(n(input())):
  I();t=[];x=0
  for i,j in zip(map(n,I().split()[::-1]),I()[::-1]):
    [i^=k*(i^k<i)for k in t];j=n(j);t+=[i*(j^1)];x|=(i>0)&j
  print(x)

Buggy submission (verdict: Runtime Error):
t=int(input())
for _ in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    s=input()
    b=[]
    for i in range(n)[::-1]:
        for e in b:
            a[i]=min(a[i],a[i]^e)
        if a[i]:
            if s[i]=="0":
                b+=a[i]
            else:
                print(1)
                break
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
import numpy as np
t=int(input())
for _ in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    s=input()
    matrix=np.zeros((60,1))
    for i in range(n-1,-1,-1):
        ne=np.array([(a[i]>>j)&1 for j in range(60)])
        matrix=np.c_[matrix,ne]
        col=matrix.shape[1]
        ra=np.linalg.matrix_rank(matrix)
        if s[i]=="0":
            if col!=ra+1:
                matrix=np.delete(matrix,col-1,1)
        else:
            if col==ra+1:
                print(1)
                break
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
import numpy as np
t=int(input())
for _ in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    s=input()
    matrix=np.zeros((60,1))
    for i in range(n-1,-1,-1):
        ne=np.array([(a[i]>>j)&1 for j in range(60)])
        matrix=np.c_[matrix,ne]
        col=matrix.shape[1]
        ra=np.linalg.matrix_rank(matrix) 
        if s[i]=="0":
            if col!=ra+1:
                matrix=np.delete(matrix,col,1)
        else:
            if col==ra+1:
                print(1)
                break
    else:
        print(0)
Problem p02662 (python)

Fixed submission:
mod=998244353
n,s=map(int,input().split())
a=list(map(int,input().split()))
dp=[[0]*(s+1) for i in range(n+1)]
dp[0][0]=1
for i in range(n):
    for j in range(s+1):
        if j-a[i]>=0:
            dp[i+1][j]=dp[i][j]*2+dp[i][j-a[i]]
        else:
            dp[i+1][j]=dp[i][j]*2
        dp[i+1][j]%=mod
print(dp[n][s])

Buggy submission (verdict: Runtime Error):
import math
def combinations_count(n, r):
    if n-r<0:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
mod=998244353
n,s=map(int,input().split())
a=list(map(int,input().split()))
dp=[dict() for i in range(s+1)]
for i in range(n):
    if a[i]<=s:
        if 1 in dp[a[i]]:
            dp[a[i]][1]+=1
        else:
            dp[a[i]][1]=1
for i in range(1,s+1):
    for k in range(i,s+1):
        if k+i<=s:
            if k!=i:
                for j in dp[i]:
                    if j+1 in dp[k+i]:
                        dp[k+i][j+1]+=dp[i][j]
                        dp[k+i][j+1]%=mod
                    else:
                        dp[k+i][j+1]=dp[i][j]
                        dp[k+i][j+1]%=mod
            else:
                for j in dp[i]:
                    if j==1:
                        if j+1 in dp[k+i]:
                            dp[k+i][j+1]+=combinations_count(dp[i][j],2)
                            dp[k+i][j+1]%=mod
                        else:
                            dp[k+i][j+1]=combinations_count(dp[i][j],2)
                            dp[k+i][j+1]%=mod
                    else:
                        if j+1 in dp[k+i]:
                            dp[k+i][j+1]+=dp[i][j]
                            dp[k+i][j+1]%=mod
                        else:
                            dp[k+i][j+1]=dp[i][j]
                            dp[k+i][j+1]%=mod

ans=0
for i in dp[s]:
    ans+=(pow(2,n-i,mod)*dp[s][i])
    ans%=mod
print(ans)
Problem p02665 (python)

Fixed submission:
from itertools import accumulate
n=int(input())
a=list(map(int,input().split()))
c=list(accumulate(a))
b=[0]*(n+1)
#大きくしすぎてしまう場合がある
#いや上限を考えろや
def f():
    global n,a,b
    for i in range(n+1):
        if i==0:
            b[0]=min(c[n]-c[0],1)
        else:
            b[i]=min(2*(b[i-1]-a[i-1]),c[n]-c[i-1])

    if n==0:
        if a[0]!=1:
            print(-1)
        else:
            print(1)
    elif b[n]!=a[n]:
        print(-1)
    else:
        print(sum(b))
        #print(b)
f()

Buggy submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())
t=sum(a);v=w=1
for q in a:
  if(w:=min(2*(w-q),t:=t-q))<0:exit(-1)
  v+=w
print(v)

Buggy submission (verdict: Runtime Error):
n,*a,t=map(int,open(0).read().split()),sum(a)
v=w=1
for q in a:
  w=min(2*(w-q),t:=t-q);(v:=v+w)
  if w<0:print(-1);exit()
print(v)

Buggy submission (verdict: Runtime Error):
n,*a,t=map(int,open(0).read().split()),sum(a)
v=w=1
for q in a:
  w=min(2*(w-q),t:=t-q);(v:=v+w)
  if w<0:print(-1);exit()
print(v)

Buggy submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())
t,v,w=sum(a),1,0
for q in a:
  w=min(2*(v[-1]-q),t:=t-q)
  v+=w
  if w<0:print(-1);exit()
print(v)

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
n=int(input())
a=list(map(int,input().split()))
c=list(accumulate(a))
b=[0]*(n+1)
#大きくしすぎてしまう場合がある
#いや上限を考えろや
def f():
    global n,a,b
    if n==0:
        
    for i in range(n+1):
        if i==0:
            b[0]=min(c[n]-c[0],1)
        else:
            b[i]=min(2*(b[i-1]-a[i-1]),c[n]-c[i-1])

    if n==0:
        if a[0]!=1:
            print(-1)
        else:
            print(1)
    elif b[n]!=a[n]:
        print(-1)
    else:
        print(sum(b))
        #print(b)
f()
Problem p02678 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
from collections import deque
n,m=map(int,input().split())
path=[[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    path[a-1].append(b-1)
    path[b-1].append(a-1)
nan=deque([0])
check=[1 if i==0 else -1 for i in range(n)]
def bfs():
    global n,m,path,nan
    l=len(nan)
    if not l:
        return
    for _ in range(l):
        x=nan.popleft()
        for j in path[x]:
            if check[j]==-1:
                check[j]=x
                nan.append(j)
    bfs()
bfs()
if any([i==-1 for i in check]):
    print("No")
else:
    print("Yes")
    for i in range(1,n):
        print(check[i]+1)

Buggy submission (verdict: Runtime Error):
from collections import deque
n,m=map(int,input().split())
path=[[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    path[a-1].append(b-1)
    path[b-1].append(a-1)
nan=deque([0])
check=[1 if i==0 else -1 for i in range(n)]
def bfs():
    global n,m,path,nan
    l=len(nan)
    if not l:
        return
    for _ in range(l):
        x=nan.popleft()
        for j in path[x]:
            if check[j]==-1:
                check[j]=x
                nan.append(j)
    bfs()
bfs()
if any([i==-1 for i in check]):
    print("No")
else:
    print("Yes")
    for i in range(1,n):
        print(check[i]+1)