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

Fixed submission:
import heapq
K=int(input())
if K<10:
  print(K)
  exit()
  
nums=[1, 2, 3, 4, 5, 6, 7, 8, 9]
heapq.heapify(nums)
for i in range(K):
  value=heapq.heappop(nums)
  tmp=str(value)
  if tmp[-1]=='0':
    cand=[int(tmp+'0'), int(tmp+'1')]
  elif tmp[-1]=='9':
    cand=[int(tmp+'8'), int(tmp+'9')]
  else:
    h=int(tmp[-1])
    cand=[int(tmp+str(h-1)), int(tmp+str(h)), int(tmp+str(h+1))]
  for c in cand:
    heapq.heappush(nums, c)
print(value)

Buggy submission (verdict: Runtime Error):
#キューを使います
from collections import deque

#関数f:入力xの1の位がyだとした時、「xの末尾に(y-1)を付加したもの」を出力
def f(x):
  s=str(x) #文字列にする
  y=int(s[-1]) #末尾を取り出し数字に戻したものをyとする
  return s+str(y-1) #yから1引いて、元の文字列の末尾に追加

#関数g:入力xの1の位がyだとした時、「xの末尾にyを付加したもの」を出力
def g(x):
  s=str(x) #文字列にする
  y=int(s[-1]) #末尾を取り出し数字に戻したものをyとする
  return s+str(y) #yを元の文字列の末尾に追加

#関数h:入力xの1の位がyだとした時、「xの末尾にy+1を付加したもの」を出力
def h(x):
  s=str(x) #文字列にする
  y=int(s[-1]) #末尾を取り出し数字に戻したものをyとする
  return s+str(y+1) #y+1を元の文字列の末尾に追加

#入力受け取り
K=int(input())

#キューの準備
q=deque()

#キューには1から9の整数を先に入れておく
for i in range(1, 10):
  q.append(i)
  
#キューから数字を取り出し、末尾に数字を付けることで作れるルンルン数をキューに追加する
#この操作をK-1回行う
for i in range(K-1):
  num=q.popleft()　#キューから数字を取り出す
  if v%10!=0: #末尾が0の時は、末尾から-1した数字を付加してもルンルン数とならないため除外
    q.append(f(num))
    
  q.append(g(num))
  
  if v%10!=9: #末尾が9の時は、末尾に+1した数字を付加してもルンルン数とならないため除外
    q.append(h(num))
    
print(q.popleft()) #K回目に出てくるルンルン数を出力
Problem p02722 (python)

Fixed submission:
N=int(input())
if N==2:
    print(1)
    exit()

ans=0
def f(x):
    out=set()
    for i in range(1, int(x**(1/2))+1):
        if x%i==0:
            out.add(i)
            out.add(x//i)
    out=list(out)
    out.sort()
    return out[1:]

tmp=f(N)
for K in tmp:
    x=N
    while x>=K:
        if x%K==0:
            x=x//K
        else:
            x=x%K
            
    if x==1:
        ans+=1
        
tmp=f(N-1)
ans+=len(tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
#関数f:入力xの1以外の約数をリストで出力
def f(x):
  out=set() #約数を保存するセット
  for i in range(1, (pow(x, 1/2)):
    #1-x**(1/2)未満の整数iについて、xを割り切れるか判定
    if x%i==0:
      #xをiで割り切れるのであれば、iとx/iを保存
      out.add(i)
      out.add(x//i)
      
  #x**(1/2)でxを割り切れる(つまりxが平方数)なら、出力にx**(1/2)を追加
  if x%(x**(1/2))==0:
    out.add(x**(1/2))
    
  #セットから昇順のリストに変換します
  out=list(out)
  out.sort()
  
  #昇順にした結果1が先頭に来ているため、インデックス1以降を出力
  return out[1:]

#入力受け取り
N=int(input())
ans=0 #最後に出力する変数

for K in f(N): #Nの1以外の約数について、操作の結果1になるかをそれぞれ調べる
    x=N #Nを直接書き換えると後に影響するため、ここではxとする
    #xをKで割り切れる間は、Kで割り続ける
    while x%K==0:
      x/=K
      
    #xをKで割り切れなくなったら、xからKを引けるだけ引く(=割って余りをとる)
    x%=K
    
    #操作後x=1となったならば、出力に1を足す
    if x==1:
        ans+=1
        
#(N-1)の1を除いた約数はすべて条件を満たすため、出力にf(N-1)の要素数を足す
ans+=len(f(N-1))

#出力
print(ans)
Problem p02727 (python)

Fixed submission:
X, Y, A, B, C=map(int, input().split())
p=list(map(int, input().split()))
p.sort()
q=list(map(int, input().split()))
q.sort()
r=list(map(int, input().split()))
r.sort(reverse=True)

i=-X
j=-Y
k=0
deru=0
while deru==0 and k<C and (r[k]>p[i] or r[k]>q[j]):
  if p[i]>q[j] and j<0:
    j+=1
    k+=1
  elif p[i]>q[j] and j>=0 and i<0 and p[i]<r[k]:
    i+=1
    k+=1
  elif p[i]<=q[j] and i<0:
    i+=1
    k+=1
  elif p[i]<=q[j] and i>=0 and j<0 and q[j]<r[k]:
    j+=1
    k+=1
  else:
    deru=1
    
if i==0:
  a=0
else:
  a=sum(p[i:])
  
if j==0:
  b=0
else:
  b=sum(q[j:])
  
if k==0:
  c=0
else:
  c=sum(r[:k])
  
print(a+b+c)

Buggy submission (verdict: Runtime Error):
X, Y, A, B, C=map(int, input().split())
p=list(map(int, input().split()))
p.sort()
q=list(map(int, input().split()))
q.sort()
r=list(map(int, input().split()))
r.sort(reverse=True)

i=-X
j=-Y
k=0
deru=0
while deru=0 and k<C and (r[k]>p[i] or r[k]>q[j]):
  if p[i]>q[j] and j<0:
    j+=1
    k+=1
  elif p[i]>q[j] and j>=0 and i<0:
    i+=1
    k+=1
  elif p[i]<q[j] and i<0:
    i+=1
    k+=1
  elif p[i]<q[j] and i>=0 and j<0:
    j+=1
    k+=1
  else:
    deru=1
    
if i==0:
  a=0
else:
  a=sum(p[i:])
  
if j==0:
  b=0
else:
  b=sum(q[j:])
  
if k==0:
  c=0
else:
  c=sum(r[:k])
  
print(a+b+c)

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

N, X, Y=map(int, input().split())
ans=[0 for _ in range(N)]
link=[[]]+[[2]]+[[i-1, i+1] for i in range(2, N)]+[[N-1]]
link[X].append(Y)
link[Y].append(X)

def f(p, length, moto):
  ans[length]+=1
  for data in link[p]:
    if data!=moto:
      f(data, length+1, p)
      
for i in range(1, N+1):
  for data in link[i]:
    f(data, 1, i)
    
print(*ans[1:], sep='\n')
Problem p02787 (python)

Fixed submission:
H, N=map(int, input().split())
AB=[list(map(int, input().split())) for _ in range(N)]

nums=[-1]*20001
for i in range(N):
  if nums[AB[i][0]]<0:
    nums[AB[i][0]]=AB[i][1]
  else:
    nums[AB[i][0]]=min(AB[i][1], nums[AB[i][0]])
  
for i in range(1, H):
  if nums[i]>0:
    for j in range(N):
      if nums[i+AB[j][0]]>0:
        if nums[i+AB[j][0]]>nums[i]+AB[j][1]:
          nums[i+AB[j][0]]=nums[i]+AB[j][1]
      else:
        nums[i+AB[j][0]]=nums[i]+AB[j][1]
      
anss=[]
for i in range(H, 20000):
  if nums[i]>0:
    anss.append(nums[i])
    
print(min(anss))

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

nums=[-1]*20001
for i in range(N):
  if nums[AB[i][0]]<0:
    nums[AB[i][0]]=AB[i][1]
  else:
    nums[AB[i][0]]=min(AB[i][1], nums[AB[i][0]])
  
for i in range(1, H):
  if nums[i]>0:
    for j in range(N):
      if nums[i+AB[j][0]]>0:
        if nums[i+AB[j][0]]>nums[i]+AB[j][1]:
          nums[i+AB[j][0]]=nums[i]+AB[j][1]
      else:
        nums[i+AB[j][0]]=nums[i]+AB[j][1]
      
for i in range(H, 20000):
  if nums[i]>0:
    anss.append(nums[i])
    
print(min(nums))
Problem p02813 (python)

Fixed submission:
from itertools import permutations

N=int(input())
l=[i+1 for i in range(N)]
P=tuple(map(int, input().split()))
Q=tuple(map(int, input().split()))
counter=0
for t in permutations(l):
  if P==t:
    a=counter
    
  if Q==t:
    b=counter
    
  counter+=1
  
print(abs(a-b))

Buggy submission (verdict: Runtime Error):
from itertools import permutations
import numpy as np
N=int(input())
l=[i+1 for i in range(N)]
P=np.array(list(map(int, input().split())))
Q=np.array(list(map(int, input().split())))
counter=0
for t in permutations(l):
  tmp=np.array(t)
  if all(P==tmp):
    a=counter
    
  if all(Q==tmp):
    b=counter
    
  counter+=1
  
print(abs(a-b))

Buggy submission (verdict: Runtime Error):
from itertools import permutations
import numpy as np
N=int(input())
l=[i+1 for i in range(N)]
P=np.array(list(map(int, input().split())))
Q=np.array(list(map(int, input().split())))
counter=0
for t in permutations(l):
  tmp=np.array(t)
  if sum(P==tmp)==N:
    a=counter
    
  if sum(Q==tmp)==N:
    b=counter
    
  counter+=1
  
print(abs(a-b))
Problem p02814 (python)

Fixed submission:
import fractions
def func(x, y):
  tmp=fractions.gcd(x, y)
  return x*y//tmp

N, M=map(int, input().split())
if N==1:
  a=int(input())
  c=a//2
  if c>M:
    print(0)
  else:
    print(int((M/c-1)/2)+1)
  exit()

a=list(map(int, input().split()))
b=[a[i]//2 for i in range(N)]

def f(x):
  out=0
  while x%2==0:
    out+=1
    x//=2
  return out

c=func(b[0], b[1])
for i in range(2, N):
  c=func(c, b[i])
  
p=[f(a[i]) for i in range(N)]
p.sort()
for i in range(N-1):
  if p[i]!=p[i+1]:
    print(0)
    exit()
    
if c>M:
  print(0)
else:
  print(int((M/c-1)/2)+1)

Buggy submission (verdict: Runtime Error):
import fractions
def func(x, y):
  tmp=fractions.gcd(x, y)
  return x*y//tmp

N, M=map(int, input().split())
if N==1:
  a=int(input())
  c=a//2
  if c>M:
    print(0)
  else:
    print(int((M/C-1)/2)+1)
  exit()

a=list(map(int, input().split()))
b=[a[i]//2 for i in range(N)]

c=func(b[0], b[1])
for i in range(2, N):
  c=func(c, b[i])
  
if c>M:
  print(0)
else:
  print(int((M/C-1)/2)+1)

Buggy submission (verdict: Runtime Error):
import fractions
def func(x, y):
  tmp=fractions.gcd(x, y)
  return x*y//tmp

N, M=map(int, input().split())
a=list(map(int, input().split()))
b=[a[i]//2 for i in range(N)]

p=func(b[0], b[1])
for i in range(2, N):
  p=func(p, b[i])
  
if M-p<0:
  print(0)
else:
  print((M-p)//(2*p)+1)
Problem p02845 (python)

Fixed submission:
MOD=10**9+7
N=int(input())
A=list(map(int, input().split()))

huts=[0, 0, 0]
out=1
for i in range(N):
  out*=huts.count(A[i])
  if out==0:
    print(0)
    exit()
  huts[huts.index(A[i])]+=1
print(out%MOD)

Buggy submission (verdict: Runtime Error):
MOD=10**9+7
N=int(input())
A=list(map(int, input().split()))
huts=[0]*3
out=1
for i in range(N):
  out*=huts.count(A[i])
  huts[huts.index(A[i])]+=1
print(out%MOD)
Problem p02850 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

N=int(input())
ab=[list(map(int, input().split())) for i in range(N-1)]
link=[[] for i in range(N+1)]
for i in range(0, N-1):
  link[ab[i][0]].append([ab[i][1], i])
  link[ab[i][1]].append([ab[i][0], i])
  
out=[0]*(N-1)
def f(num, prenum=0, prec=0):
  postc=1
  for postnum, linknum in link[num]:
    if postnum==prenum:
      continue
    if postc==prec:
      postc+=1
      
    out[linknum]=postc
    f(postnum, num, postc)
    postc+=1
    
f(1)

print(max(out))
for i in range(N-1):
  print(out[i])

Buggy submission (verdict: Runtime Error):
N=int(input())
ab=[list(map(int, input().split())) for i in range(N-1)]
link=[[] for i in range(N+1)]
for i in range(0, N-1):
  link[ab[i][0]].append([ab[i][1], i])
  link[ab[i][1]].append([ab[i][0], i])
  
out=[0]*(N-1)
def f(num, prenum=0, prec=0):
  postc=1
  for postnum, linknum in link[num]:
    if postnum==prenum:
      continue
    if postc==prec:
      postc+=1
      
    out[linknum]=postc
    f(postnum, num, postc)
    postc+=1
    
f(1)

print(max(out))
for i in range(N-1):
  print(out[i])

Buggy submission (verdict: Runtime Error):
import numpy as np
N=int(input())
l=[list(map(int, input().split())) for i in range(N-1)]

net=np.zeros((N+1, N+1))
for i in range(N-1):
  net[l[i][0], l[i][1]]=1
  
net=net+net.T
num_c=np.max(np.sum(net, axis=1))

print(int(num_c))

c_net=np.zeros((N+1, N+1, num_c))
for i in range(N-1):
  a=l[i][0]
  b=l[i][1]
  
  j=0
  while np.sum(c_net[a, :, j]==1)>0 or np.sum(c_net[b, :, j]==1)>0:
    j+=1
    if j>=num_c-1:
      break
    
  c_net[a, b, j]=1
  c_net[b, a, j]=1
  print(j+1)
Problem p02865 (python)

Fixed submission:
print((int(input())-1)//2)

Buggy submission (verdict: Runtime Error):
print((int(input)-1)//2)
Problem p02947 (python)

Fixed submission:
N=int(input())
s=[''.join(sorted(input())) for i in range(N)]


dic={}
counter=0
for i in range(N):
  if (s[i] in dic.keys())==True:
    counter+=dic[s[i]]
    dic[s[i]]=dic[s[i]]+1
  else:
    dic[s[i]]=1

print(counter)

Buggy submission (verdict: Runtime Error):
N=int(input())
s=[sorted(list(input())) for i in range(N)]
s.sort()

counter=long(0)

i=0
while i<N-1:
  j=i+1
  while j<N:
    if s[i]==s[j]:
	    counter+=1
	    j+=1
    else:
      break
    
  i+=1
  
print(counter)
Problem p02952 (python)

Fixed submission:
N=int(input())

counter=0
for i in range(1, N+1):
  if len(str(i))%2==1:
    counter+=1
    
print(counter)

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

N=int(input())

counter=0
for i in range(1, N+1):
  if int(np.log10(i))%2==0:
    counter+=1
    
print(counter)
Problem p02953 (python)

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

index=N-1
output='Yes'
while index>0:
  if h[index-1]-h[index]>1:
    output='No'
    break
  elif h[index-1]-h[index]==1:
    h[index-1]-=1
  else:
    pass
  index-=1
  
print(output)

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

for i in range(N-1):
  if h[i]-h[i+1]>0:
    h2.append(h[i])

output='Yes'

if h[0]-h[1]>1:
  output='No'
  
for i in range(1, N-1):
  if h[i]-h[i-1]>0 and h[i]-h[i+1]>0:
    if h[i]-min(h[i+1:])>1:
      output='No'
      
print(output)

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

a=max([h[i]-min(h[i+1:]) for i in range(n-1)])

if a>1:
  print('No')
else:
  print('Yes')

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

Hsub=[H[i+1]-H[i] for i in range(N-1)]

output='Yes'
for i in range(N):
  if Hsub>0:
    if H[i]-min(H[i+1])>1:
      output='No'
      
print(output)
Problem p02957 (python)

Fixed submission:
temp=input().split()
A=int(temp[0])
B=int(temp[1])

m=int((A+B)/2)

if m==(A+B)/2 and m>=0:
  print(int(m))
else:
  print('IMPOSSIBLE')

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

temp=list(map(int, input().split()))
temp=np.mean(temp)
if temp-int(temp)>0:
  output='IMPOSSIBLE'
else:
  output=temp
  
print(int(output))
Problem p02958 (python)

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

counter=0
for i in range(N):
  if p[i]!=int(i+1):
    counter+=1
    
if counter==0 or counter==2:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
N=int(input())
p=np.array(list(map(int, input().split())))
q=np.arange(N)+1

temp=np.sum(p==q)
if temp==0 or temp==2:
  print('YES')
else:
  print('NO')
Problem p02963 (python)

Fixed submission:
S=int(input())
X1=0
Y1=0
if S==10**18:
  print(' '.join(['0', '0', '0', '1000000000', '1000000000', '0']))
else:
  X2=10**9
  Y2=1
  Y3=S//(10**9)+1
  X3=Y3*(10**9)-S
  print(' '.join(map(str, [X1, Y1, X2, Y2, X3, Y3])))

Buggy submission (verdict: Runtime Error):
S=int(input())
X1=0
Y1=0
if S==10**18:
  print(' '.join(['0', '0', '0', '1000000000', '1000000000', '0']))
else:
  X2=10**9
  Y2=1
  Y3=S//(10**9)+1
  X3=Y3*(10**9)-S

print(' '.join(map(str, [X1, Y1, X2, Y2, X3, Y3])))
Problem p02969 (python)

Fixed submission:
r=int(input())
print(3*r*r)

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

print(3*value*value)
Problem p02971 (python)

Fixed submission:
N=int(input())
s=[int(input()) for i in range(N)]

temp=s.copy()
s_max=max(temp)
temp.remove(s_max)
s_max2=max(temp)

for i in range(N):
  if s[i]<s_max:
    print(s_max)
  else:
    print(s_max2)

Buggy submission (verdict: Runtime Error):
N = int(input())
s = [int(input()) for i in range(N)]
temp=s.copy()
s_max=max(temp)
temp=temp.remove(s_max)
s_max2=max(temp)

for i in range(N):
  if s[i]<s_max:
    print(s_max)
  else:
	print(s_max2)

Buggy submission (verdict: Runtime Error):
N = int(input())
s = [int(input()) for i in range(N)]
temp=s.copy()
s_max=max(temp)
temp.remove(s_max)
s_max2=max(temp)

for i in range(N):
  if s[i]<s_max:
    print(s_max)
  else:
	print(s_max2)

Buggy submission (verdict: Runtime Error):
N = int(input())
s = [int(input()) for i in range(N)]
temp=s.copy()
s_max=temp.remove(max(temp))
s_max2=temp.remove(max(temp))

for i in range(N):
  if s[i]<s_max:
    print(s_max)
  else:
	print(s_max2)

Buggy submission (verdict: Runtime Error):
N = int(input())
s = [int(input()) for i in range(N)]
temp=s.copy()
s_max=temp.pop(max(temp))
s_max2=temp.pop(max(temp))

for i in range(N):
  if s[i]<s_max:
    print(s_max)
  else:
	print(s_max2)

Buggy submission (verdict: Runtime Error):
N = int(input())
s = [int(input()) for i in range(N)]

s_max=s.pop(max(s))
s_max2=s.pop(max(s))

for i in range(N):
  if s[i]<s_max:
    print(s_max)
  else:
	print(s_max2)

Buggy submission (verdict: Runtime Error):
N = int(input())
s = [int(input()) for i in range(N)]

s_max=max(s)

for i in range(N):
  if s[i]<s_max:
    print(s_max)
  else:
	print(max([s[x] for x in range(i)]+[s[x] for x in range(i+1, N)]))
Problem p02982 (python)

Fixed submission:
temp=input().split()
N=int(temp[0])
D=int(temp[1])

points=[]
for i in range(N):
  temp=input().split()
  points.append([int(temp[x]) for x in range(D)])
  
counter=0
for i in range(N):
  for j in range(i+1, N):
    l=pow(sum([pow(points[i][x]-points[j][x], 2) for x in range(D)]), 1/2)
    if l.is_integer():
      counter+=1
      
print(counter)

Buggy submission (verdict: Runtime Error):
temp=input().split()
N=int(temp[0])
D=int(temp[1])

points=[]
for i in range(N):
  temp=input().split()
  points.append([int(temp[x]) for x in range(D)])
  
counter=0
for i in range(N):
  for j in range(i+1, N):
    l=pow(sum([pow(points[i, x]-points[j, x], 2) for x in range(D)]), 1/2)
    if l.is_integer():
      counter+=1
      
print(counter)

Buggy submission (verdict: Runtime Error):
temp=input().split()
N=int(temp[0])
D=int(temp[1])

points=[]
for i in range(N):
  temp=input().split()
  points.add([int(temp[x]) for x in range(D)])
  
counter=0
for i in range(N):
  for j in range(i+1, N):
    l=pow(sum([pow(points[i, x]-points[j, x], 2) for x in range(D)]), 1/2)
    if l.is_integer():
      counter+=1
      
print(counter)

Buggy submission (verdict: Runtime Error):
temp=input().split()
N=int(temp[0])
D=int(temp[1])

points=[]
for i in range(N):
  temp=input().split()
  points.add([int(temp[x]) for x in range(D)])
  
counter=0
for i in range(N):
  for j in range(i+1, N):
    l=pow(sum([pow(points[i, x]-points[j, x], 2) for x in range(D)]), 1/2)
    if l==int(l):
      counter+=1
      
print(counter)
Problem p02983 (python)

Fixed submission:
temp=input().split()
L=int(temp[0])
R=int(temp[1])

if R-L>=2019:
  print(0)
else:
  print(min([(i*j)%2019 for i in range(L, R) for j in range(i+1, R+1)]))

Buggy submission (verdict: Runtime Error):
temp=input().split()
L=int(temp[0])
R=int(temp[1])

print(min([(i*j)%2019 for i in range(L, R-1) for j in range(i, R)]))

Buggy submission (verdict: Runtime Error):
temp=input().split()
L=int(temp[0])
R=int(temp[1])

print(min([(i*j)%2019 for i in range(L, R-1) for j in range(i, R)]))
Problem p02995 (python)

Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)

temp=input().split()
A=int(temp[0])
B=int(temp[1])
C=int(temp[2])
D=int(temp[3])

x=B//C-(A-1)//C
y=B//D-(A-1)//D
s=lcm(C, D)
z=B//s-(A-1)//s

print(int(B-A+1-x-y+z))

Buggy submission (verdict: Runtime Error):
import math

A, B, C, D=map(int, input().split())
x=math.gcd(C, D)
p=B//C-(A-1)//C
q=B//D-(A-1)//D
r=B//x-(A-1)//x
print(B-(A-1)-(p+q-r))

Buggy submission (verdict: Runtime Error):
temp=input().split()
A=int(temp[0])
B=int(temp[1])
C=int(temp[2])
D=int(temp[3])

for i in range(A, B+1):
  if i%C==0 and i%D==0:
    counter+=1
    
print(counter)
Problem p03000 (python)

Fixed submission:
import numpy as np

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

N=temp[0]
X=temp[1]

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

ind=1
while np.sum(L[:ind])<=X and ind<=N:
  ind+=1
  
print(ind)

Buggy submission (verdict: Runtime Error):
N, X=map(int, input().split())
L=list(map(int, input().split()))
L=[0]+L
 
l=int(0)
counter=int(0)
while l+L[counter]<=X and counter<N+1:
  l+=L[counter]
  counter+=int(1)
  
print(counter)

Buggy submission (verdict: Runtime Error):
N, X=map(int, input().split())
L=list(map(int, input().split()))
 
l=int(0)
counter=int(0)
while l<=X and counter<=N+1:
  l+=L[counter]
  counter+=int(1)
  
print(counter)

Buggy submission (verdict: Runtime Error):
N, X=map(int, input().split())
L=list(map(int, input().split()))
 
l=int(0)
counter=int(0)
while l<=X:
  l+=L[counter]
  counter+=int(1)
  
print(counter)

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

l=0
counter=0
while l<=X:
  l+=L[counter]
  counter+=1
  
print(counter)

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

length=0
counter=0
while l<=X:
  length+=L[counter]
  counter+=1
  
print(counter)

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

length=0
counter=0
while l<=X:
  length+=L[counter]
  counter+=1

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

l=0
counter=0
while l<=X:
  l+=L[counter]
  counter+=1

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

l=0
counter=0
while l<=X:
  l+=L[counter-1]
  counter+=1

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

N=temp[0]
X=temp[1]

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

ind=1
while np.sum(L[:ind])<=X and ind<N:
  ind+=1
  
print(ind)
Problem p03031 (python)

Fixed submission:
import numpy as np

N, M=map(int, input().split())
matrix=np.zeros((M, N))

for i in range(M):
  temp=np.array(list(map(int, input().split())))
  temp-=1
  matrix[i, temp[1:]]=1
  
p=np.array(list(map(int, input().split())))

counter=0
for i in range(pow(2, N)):
  s=np.array(list(map(int, list(format(i, '0'+str(N)+'b')))))
  if all(np.dot(matrix, s)%2==p)==True:
    counter+=1
    
print(counter)

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

temp=input().split()
N=int(temp[0])
M=int(temp[1])

A=np.zeros((M, N))

for i in range(M):
  temp=list(map(int, input().split()))
  for j in range(1, temp[0]+1):
    A[i, temp[j]-1]=1
    
    
p=list(map(int, input().split()))

counter=0
for i in range(pow(2, N)):
  temp=format(i, '0'+str(N)+'b')
  s=[int(temp[j]) for j in range(N)]
  
  a=np.dot(A, s)%2
  
  if all(p==a):
    counter+=1
    
print(counter)

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

temp=input().split()
N=int(temp[0])
M=int(temp[1])

A=np.zeros((M, N))

for i in range(M):
  temp=list(map(int, input().split()))
  for j in range(1, temp[0]+1):
    A[i, temp[j]]=1
    
    
p=list(map(int, input().split()))

counter=0
for i in range(pow(2, N)):
  temp=format(i, '0'+str(N)+'b')
  s=[temp[j] for j in range(N)]
  
  a=np.dot(A, s)%2
  
  if p==a:
    counter+=1
    
print(counter)
Problem p03044 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**5+1)

N=int(input())
uvw=[list(map(int, input().split())) for i in range(N-1)]
nodelink=[[] for i in range(N+1)]
for i in range(N-1):
  nodelink[uvw[i][0]].append([uvw[i][1], uvw[i][2]])
  nodelink[uvw[i][1]].append([uvw[i][0], uvw[i][2]])
  
color=[-1]*(N+1)

def f(nuru, iro):
  color[nuru]=iro
  tonari=nodelink[nuru]
  for nuruyo in tonari:
    if color[nuruyo[0]]<0:
      if (nuruyo[1]%2)==0:
        f(nuruyo[0], iro)
      else:
        f(nuruyo[0], 1-iro)
      
f(1, 0)

for i in range(1, N+1):
  print(color[i])

Buggy submission (verdict: Runtime Error):
def f(x):
  for tmp in links[x]:
    if c[tmp[0]]<0:
      if tmp[1]%2==0:
        c[tmp[0]]=c[x]+0
      else:
        c[tmp[0]]=1-c[x]
      f(tmp[0])

N=int(input())
links=[[] for _ in range(N+1)]
for _ in range(N-1):
  u, v, w=map(int, input().split())
  links[u].append([v, w])
  links[v].append([u, w])
  
c=[-1]*(N+1)
c[1]=0
f(1)

print(*c[1:], sep='\n')

Buggy submission (verdict: Runtime Error):
N=int(input())
uvw=[list(map(int, input().split())) for i in range(N-1)]
nodelink=[[] for i in range(N+1)]
for i in range(N-1):
  nodelink[uvw[i][0]].append([uvw[i][1], uvw[i][2]])
  nodelink[uvw[i][1]].append([uvw[i][0], uvw[i][2]])
  
color=[-1]*(N+1)

def f(nuru, iro):
  color[nuru]=iro
  tonari=nodelink[nuru]
  for nuruyo in tonari:
    if color[nuruyo[0]]<0:
      if (nuruyo[1]%2)==0:
        f(nuruyo[0], iro)
      else:
        f(nuruyo[0], 1-iro)
      
f(1, 0)

for i in range(1, N+1):
  print(color[i])