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

Fixed submission:
import math

def f(x, y, z):
  return(x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x)

n = int(input())
fs = [0] * n

lim = math.floor(math.sqrt(n))
rng = range(1, lim)

for x in rng:
  for y in rng:
    for z in rng:
      v = f(x, y, z)
      if v <= n:
      	fs[v - 1] += 1
      
for i in range(n):
  print(fs[i])

Buggy submission (verdict: Runtime Error):
import math

def f(x, y, z):
  return(x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x)

n = int(input())
fs = [0] * n

lim = math.floor(math.sqrt(n))
rng = range(2, lim)

for(x in rng):
  for(y in rng):
    for(z in rng):
      v = f(x, y, z)
      if v <= n:
      	fs[v - 1] += 1
      
for(i in range(n)):
  print(fs[i])

Buggy submission (verdict: Runtime Error):
import math

def f(x, y, z):
  return(x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x)

n = int(input())
fs = [0] * n

lim = math.floor(math.sqrt(n))
rng = range(2, lim)

for(x in rng):
  for(y in rng):
    for(z in rng):
      fs[f(x, y, z) - 1] += 1
      
for(i in range(n)):
  print(fs[i])

Buggy submission (verdict: Runtime Error):
def g(x, y, z):
  return x * x + y * y + z * z + x * y + y * z + z * x
  
def f(n):
  if(n < 6):
    return 0
  
  sum = 0
  lim = math.floor(math.sqrt(n)) + 1
  for x in range(1, lim, 1):
    for y in range(1, lim, 1):
      for z in range(1, lim, 1):
        a = g(x, y, z)
        if a > n:
          break
        if a == n:
          sum += 1
  return sum

for i in range(n + 1):
  print(f(i))
Problem p02630 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
q = int(input())

dp = [0] *( 10 ** 5 +10)

bc = [input() for _ in range(q)]

for ai in a:
  dp[ai] += 1
ans = 0
for i in range(1,len(dp)):
  ans += dp[i] * i
  
for bci in bc:
  b,c = map(int,bci.split())
  ans += (dp[b] * c) -(dp[b] * b)
  print(ans)
  dp[c] += dp[b] 
  dp[b] = 0

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

dp = [0] *( 10 ** 5)

bc = [input() for _ in range(q)]

for ai in a:
  dp[ai] += 1
ans = 0
for i in range(1,len(dp)):
  ans += dp[i] * i
  
for bci in bc:
  b,c = map(int,bci.split())
  ans += (dp[b] * c) -(dp[b] * b)
  print(ans)
  dp[c] += dp[b] 
  dp[b] = 0
Problem p02910 (python)

Fixed submission:
s = input()

w1 = [ "R", "U", "D"]
w2 = [ "L", "U", "D"]

for i in range(len(s)):
  if i % 2 == 0:
    if not s[i] in w1 :
      print("No")
      exit()
  else :
    if not s[i] in w2 :
      print("No")
      exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
    s = input()
     
    w1 = [ "R", "U", "D"]
    w2 = [ "L", "U", "D"]
     
    for i in range(len(s)):
      if i % 2 == 0:
        if not s[i] in w1 :
          print("No")
          exit()
      else :
        if not s[i] in w2 :
          print("No")
          exit()
    print("Yes")
Problem p02924 (python)

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

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

ans = list(range(1,n))

print(sum(ans))
Problem p02885 (python)

Fixed submission:
A, B = [int(i) for i in input().split()]
0<=A<=100
0<=B<=100

if A>B*2:
  print(A-B*2)

else:
  print(0)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())

0<=A<=100
0<=B<=100
 
if A>B*2:
  print(A-B*2)
 
else:
  print(0)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())

0<=A<=100
0<=B<=100

if A>B*2:
  print(A-B*2)

else:
  print(0)

Buggy submission (verdict: Runtime Error):
A = input()
B = input()

0<=int(A)<=100
0<=int(B)<=100

if int(A)>int(B)*2:
  print(int(A)-int(B)*2)

else:
  print(0)

Buggy submission (verdict: Runtime Error):
0<=int(A)<=100
0<=int(B)<=100

if int(A)>int(B)*2:
  print(int(A)-int(B)*2)

else:
  print(0)

Buggy submission (verdict: Runtime Error):
if int(A)-int(B)*2 <=0:
  print('0')

else:
  print(str(int(A)-int(B)*2))

Buggy submission (verdict: Runtime Error):
if A-2*B <= 0:
  print(0)

else:
  print(A-2*B)
Problem p02909 (python)

Fixed submission:
S=input()

if S == 'Sunny':
  print('Cloudy')
if S == 'Cloudy':
  print('Rainy')
if S == 'Rainy':
  print('Sunny')

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

if S ='Sunny':
  print('Cloudy')

if S = ('Cloudy'):
  print('Rainy')

if S = ('Rainy'):
  print('Sunny')

Buggy submission (verdict: Runtime Error):
S =['Sunny', 'Cloudy', 'Rainy']

if S == Sunny:
  print(Cloudy)

if S == Cloudy:
  print(Rainy)

if S == Rainy:
  print(Sunny)
Problem p02921 (python)

Fixed submission:
S=input()
T=input()

ans=0
for s,t in zip(S,T):
  if s==t:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
s = [input() for i in range(2)]
#出力['s_1', 's_2']

x=s[0].split(',')
y=s[1].split(',')

ans = 0
if x[0]==y[0]:
  ans += 1
  if x[1]==y[1]:
    ans += 1
    if x[2]==y[2]:
      ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
s = [input() for i in range(2)]
#出力['s_1', 's_2']

x=s[0].split(',')
y=s[1].split(',')

if x[0]==y[0]:
  ans += 1
  if x[1]==y[1]:
    ans += 1
    if x[2]==y[2]:
      ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
S =[]
T =[]
i = random.choice(S,C,R)
S[0] ='i'
q = random.choice(S,C,R)
S[1] ='q'
g = random.choice(S,C,R)
S[2] ='g'
 
h = random.choice(S,C,R) 
T[0] ='h'
k = random.choice(S,C,R)
T[1] ='k'
m = random.choice(S,C,R)
T[2] ='m'
 
if S[0]=T[0]:
  correct += 1
  if S[1]=T[1]:
    correct += 1
    if S[2]=S[2]:
      correct += 1
 
print(correct)

Buggy submission (verdict: Runtime Error):
S =[]
T =[]
i = random.choice(S,C,R)
 S[0] ='i'
i = random.choice(S,C,R)
S[1] ='i'
i = random.choice(S,C,R)
S[2] ='i'

i = random.choice(S,C,R) 
T[0] ='i'
i = random.choice(S,C,R)
T[1] ='i'
i = random.choice(S,C,R)
T[2] ='i'
 
if S[0]=T[0]:
  correct += 1
  if S[1]=T[1]:
    correct += 1
    if S[2]=S[2]:
      correct += 1
 
print(correct)

Buggy submission (verdict: Runtime Error):
問題文
ある3日間の天気予報が、長さ 3の文字列Sとして与えられます。
Sのi(1≤i≤3)文字目が S のとき、i日目の天気予報が晴れだったことを、
C のときは曇りだったことを、
R のときは雨だったことを意味します。

また3日間の実際の天気が、長さ 3の文字列Tとして与えられます。
Tの i (1≤i≤3)文字目が S のとき、i日目の実際の天気が晴れだったことを、
C のときは曇りだったことを、
R のときは雨だったことを意味します。
3日間で天気予報が的中した日が何日あるかを出力してください。

制約
SおよびTは長さ 3の文字列である。
SおよびTは S, C, R のみからなる。

S =[]
T =[]
i = random.choice(S,C,R)

S[0] ='i'
S[1] ='i'
S[2] ='i'

T[0] ='i'
T[1] ='i'
T[2] ='i'

if S[0]=T[0]:
  correct += 1
  if S[1]=T[1]:
    correct += 1
    if S[2]=S[2]:
      correct += 1

print(correct)
Problem p02922 (python)

Fixed submission:
A,B = map(int, input().split())

if A == B:
    anss=1
    print(anss)
    
else:
    count = 0
    outlet = A
    while outlet < B + A -1 :
        count += 1
        outlet += A-1
    print(count)

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

outlet = A

if A == B:
    print(1)
    
else:
    count = 1
    while outlet <= B:
        count += 1
        outlet += A-1
        ans = count
        break
    print(ans)
Problem p02952 (python)

Fixed submission:
n = int(input())

if 1<= n < 10:
    print(n)
elif 10<= n < 100:
    print(9)
elif 100<= n <1000:
    print(9+n-99)
elif 1000<= n < 10000:
    print(909)
elif 10000<= n <100000:
    print(909+n-9999)
else:
    print(90909)

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

ans = 0
for i range(1, n+1):
  if len(str(i))%2 == 1:
    ans += 1
print(ans)
Problem p02957 (python)

Fixed submission:
A,B = [int(i) for i in input().split(' ')]

0<=A
B<=10**9

if (A+B)%2 == 0:
  print((A+B)//2)
else:
  print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
A,B = [int(i) for i in input().split(' ')]

0<=A
B<=10**9

if (A%2==0) AND (B%2==0):
  print((A+B)/2)
elif (A%2 !=0) AND (B%2 !=0):
  print((A+B)/2)
else:
  print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
A,B = [int(i) for i in input().split(' ')]

0<=A
B<=10**9

if A%2==0 AND B%2==0:
  print((A+B)/2)
elif A%2 !=0 AND B%2 !=0:
  print((A+B)/2)
else:
  print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
A,B = [int(i) for i in input().split(' ')]

0<=A
B<=10**9

if (A%2==0 AND B%2==0) OR (A%2 !=0 AND A%2 !=0):
  print((A+B)/2)
else:
  print('IMPOSSIBLE')
Problem p02958 (python)

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

dif = []
for i in range(1,n+1):
  if p[i-1] != i:
    dif.append(i)

if len(dif) == 0 or len(dif) == 2:
  print('YES')
else:
  print('NO')

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

dif = []
for i in range(1,n+1):
  if p[i-1] != i:
    dif.append(i)

if len(dif) == 0 or len(dif) == 2:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
n = input()
p = [int(input()) for i in range(3)]

dif = []
for i in range(1,n+1):
  if p[i-1] != i:
    dif.append(1)

if len(dif) == 0 or len(dif) == 2:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
n = input()
p = [int(input()) for i in range(3)]

dif = []
for i in range(n):
  if p[i]!= i:
    dif.append(1)

if len(dif) == 0 or len(dif) == 2:
  print('YES')
else:
  print('NO')
Problem p02993 (python)

Fixed submission:
S = str(input())

if S[0] == S[1] or S[1]==S[2] or S[2]==S[3]:
  print('Bad')
else:
  print('Good')

Buggy submission (verdict: Runtime Error):
S = str(input())

if S[0] == S[1] or S[1]==S[2] or S[2]==S[3] or S[3]==S[4]:
  print('Bad')
else:
  print('Good')
Problem p02999 (python)

Fixed submission:
x,a = [int(i) for i in input().split(' ')]

if x<a:
  print(0)
else:
  print(10)

Buggy submission (verdict: Runtime Error):
x, a = [int(i) for i in input().split(' ')]

if X<A:
  print(0)
else:
  print(10)
Problem p03035 (python)

Fixed submission:
A,B = map(int,input().split())
 
answer = B
if 6 <= A <= 12:
  answer = B//2
elif A <= 5:
  answer = 0
  
print(answer)

Buggy submission (verdict: Runtime Error):
a,b = [int(x) for x in input().split()]

answer = B
if 6 <= A <= 12:
  answer = B//2
elif A <= 5:
  answer = 0
  
print(answer)
Problem p03238 (python)

Fixed submission:
n = int(input())
 
if n == 1:
	print("Hello World")
else:
	a = int(input())
	b = int(input())
	print(a+b)

Buggy submission (verdict: Runtime Error):
N = int(input())
s = [int(input()) for i in range(2)]
  
if N==1:
  print('Hello World')

elif N==2:
  print(s[0]+s[1])

Buggy submission (verdict: Runtime Error):
N = int(input())
A,B = [int(input()) for i in range(2)]
  
if N==1:
  print('Hello World')

elif N==2:
  print(A+B)
Problem p03399 (python)

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

if i[0]<i[1]:
  train = i[0]
elif i[1]<=i[0]:
  train = i[1]
  
if i[2]<i[3]:
  bus= i[2]
elif i[3]<=i[2]:
  bus= i[3]

print(train+bus)

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

if i[0]<i[1]:
  train = i[0]
elif i[1]<i[0]:
  train = i[1]
  
if i[2]<i[3]:
  bus= i[2]
elif i[3]<i[2]:
  bus= i[3]

print(train+bus)
Problem p03415 (python)

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

print(s[0][0]+s[1][1]+s[2][2])

Buggy submission (verdict: Runtime Error):
a,b,c = input().split()
d,e,f = input().split()
g,h,i = input().split()

print(a+e+i)
Problem p03433 (python)

Fixed submission:
n,a = [int(input()) for i in range(2)]

x=n%500 

if x<=a:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n,a = [input() for i in range(2)]

x=n%500 

if x<=a:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n,a = [input() for i in range(2)]

x=N%500 

if x<=a:
  print('Yes')
else:
  print('No')
Problem p03547 (python)

Fixed submission:
x,y = input().split()
if x>y:
  print('>')
elif x==y:
  print('=')
else:
  print('<')

Buggy submission (verdict: Runtime Error):
x,y = input().split()
if x>y:
  print('>')
elif x=y:
  print('=')
else:
  print('<')
Problem p03597 (python)

Fixed submission:
n,a = [int(input()) for i in range(2)]
print(n**2-a)

Buggy submission (verdict: Runtime Error):
n,a = [input() for i in range(2)]
print(n**2-a)

Buggy submission (verdict: Runtime Error):
n,a = [input() for i in range(3)]
print(n**2-a)
Problem p03719 (python)

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

if a<= c <=b:
  print('Yes')
else:
  print('No')

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

if a<= c <=b:
  print('Yes')
else:
  print('No')

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

if a<= b <=c:
  print('Yes')
else:
  print('No')
Problem p02609 (python)

Fixed submission:
n=int(input())
x=input()
t=int(x,2)
c=x.count('1')
a=t%-~c
b=0 if c<2 else t%~-c
for i in range(n):
  if int(x[i]):
    if c<2: print(0); continue
    else: t=(b-pow(2,n-i-1,c-1))%~-c
  else: t=(a+pow(2,n-i-1,c+1))%-~c
  z=1
  while t:
    d=bin(t).count('1')
    t%=d
    z+=1
  print(z)

Buggy submission (verdict: Runtime Error):
def change_num(tmp, i):
    if tmp[i] == "0":
        return int(tmp, 2)+pow(2, N-i-1)
    else:
        return int(tmp, 2)-pow(2, N-i-1)


N = int(input())
X = input()
flag = 0

for i in range(N):
    tmp = change_num(X, i)
    while True:
        num1 = 0
        for i in bin(tmp):
            # if i == 1:
            if "1" in i:
                num1 += 1

        tmp = tmp % num1
        flag += 1
        if tmp == 0:
            break
    print(flag)
    flag = 0

Buggy submission (verdict: Runtime Error):
def change_num(tmp, i):
    if tmp[i] == "0":
        return int(tmp, 2)+pow(2, N-i-1)
    else:
        return int(tmp, 2)-pow(2, N-i-1)


N = int(input())
X = input()
flag = 0

for i in range(N):
    tmp = change_num(X, i)
    while True:
        num1 = 0
        for i in bin(tmp):
            # if i == 1:
            if "1" in i:
                num1 += 1

        tmp = tmp % num1
        flag += 1
        if tmp == 0:
            break
    print(flag)
    flag = 0
Problem p02817 (python)

Fixed submission:
# -*- coding: utf-8 -*-

S,T = input().split()
print(T+S)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

S = input()
T = input()
print(T+S)
Problem p03210 (python)

Fixed submission:
age = int(input())
shichigosanAges = {3, 5, 7}
print("YES" if age in shichigosanAges else "NO")

Buggy submission (verdict: Runtime Error):
age = int(input())
shichigosanAges = {3, 5, 7}
print(age in shichigosanAges ? "YES" : "NO")
Problem p02814 (python)

Fixed submission:
def gcd(x, y):
    while y > 0:
        r = x % y
        x = y
        y = r
    return x

def lcm(x, y):
    return x // gcd(x, y) * y

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

l = 1
for i in range(n):
    a[i] //= 2
    l = lcm(a[i], l)

flg = True
for x in a:
    if (l // x) % 2 == 0:
        flg = False
        break

if flg:
    print(m // l - m // (l * 2))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
def gcd(x, y):
    while y > 0:
        r = x % y
        x = y
        y = r
    return x

def lcm(x, y):
    return x // gcd(x, y) * y

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

l = 1
for i in range(n):
    a[i] //= 2
    l = lcm(a[i], l)

flg = True
for x in a:
    if (l / x) % 2 == 0:
        flg = False
        continue

if flg:
    print(m // l - m // (l * 2))
else:
    print(0)
Problem p02642 (python)

Fixed submission:
n,*a=map(int,open(0).read().split())
a.sort()
num=[True for i in range(a[-1]+1)]
for i in range(n):
  if num[a[i]]:
    for j in range(a[-1]//a[i]+1):
      if j<2:
        continue
      num[a[i]*j]=False
    if i==n-1:
      pass
    elif a[i]==a[i+1]:
      num[a[i]]=False
    else:
      pass
  else:
    continue
ans=0
for i in range(n):
  if num[a[i]]:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())
a.sort()
num=[True for i in range(a[-1]+1)]
for i in range(n):
  if num[i]:
    for j in range(a[-1]//a[i]):
      if j<2:
        continue
      num[a[i]*j]=False
    if i!=n-1 and a[i]==a[i+1]:
      num[a[i]]=False
  else:
    pass
ans=0
for i in range(n):
  if num[a[i]]:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n,*a=map(int,open(0).read().split())
a.sort()
p=0
a=np.array(a)
ans=0
while True:
  i=0
  if len(a)>1:
    while a[i]==a[i+1]:
      i+=1
      if i==n-1:
        break
    first=a[i]
    ans+=1
    a=a[i:]
  elif len(a)==1:
    ans+=1
    break
  else:
    break
  b=a.copy()
  if len(b)==0:
    break
  b%=first
  a=a[b!=0]
print(ans)
Problem p02761 (python)

Fixed submission:
N,M=map(int,input().split())
n=int(N)
m=int(M)
numlist=[]
loglist=[]
for i in range(n):
  numlist.append(0)
  loglist.append(0)
answer=0

for i in range(m):
  s,c=map(int,input().split())
  s=int(s)
  c=int(c)
  if s==1 and c==0 and n!=1:
    answer=-1
  elif loglist[s-1]!=0 and numlist[s-1]!=c:
    answer=-1
  else:
    numlist[s-1]=c
    loglist[s-1]=1

if answer==-1:
  print(answer)
elif n==1 and numlist[0]==0:
  print(0)
else:
  if numlist[0]==0:
    numlist[0]=1
  else:
    pass
  for i in range(n):
    answer+=numlist[i]*10**(n-i-1)
  print(answer)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
n=int(N)
m=int(M)
numlist=[0,0,0]
access_log=[0,0,0]
answer=0
for i in range(m):
  s,c=map(int,input().split())
  s=int(s)
  c=int(c)
  if access_log[s]==1 and numlist[s]!=c:
    answer=-1
    break
  else:
    numlist[s]=c
    access_log[s]=1
if answer==-1:
  print(answer)
else:
  answer=numlist[2]*10**2+numlist[1]*10+numlist[0]
  if answer==0:
    print(-1)
  else:
    print(answer)
Problem p02786 (python)

Fixed submission:
h=int(input())
def f(n):
  if n==1:
    return 1
  else:
    return 2 * f(n//2) + 1
hit=f(h)
print(hit)

Buggy submission (verdict: Runtime Error):
h=int(input())
def f(n):
  if n==1:
    return 1
  else:
    return 2 * f(n) + 1
hit=f(h)
print(hit)
Problem p03044 (python)

Fixed submission:
n=int(input())
node=[-1 for i in range(n)]
g=[[] for i in range(n)]
for i in range(n-1):
  u,v,w=map(int,input().split())
  u-=1
  v-=1
  w%=2
  g[u].append([v,w])
  g[v].append([u,w])
queue=[0]
node[0]=0
while len(queue)>0:
  t=queue.pop()
  for v,w in g[t]:
    if node[v]>-1:
      continue
    node[v]=node[t]^w
    queue.append(v)
for i in range(n):
  print(node[i])

Buggy submission (verdict: Runtime Error):
n=int(input())
node=[-1 for i in range(n)]
g=[[] for i in range(n)]
def color(par,i,ini):
  if node[i]>-1:
    return
  else:
    if par==-1:
      node[i]=0
    else:
      node[i]=node[par]^ini
  for j in range(len(g[i])):
    color(i,g[i][j][0],g[i][j][1])
  return
for i in range(n-1):
  u,v,w=map(int,input().split())
  u-=1
  v-=1
  w%=2
  g[u].append([v,w])
  g[v].append([u,w])
color(-1,0,0)
for i in range(n):
  if node[i]==-1:
    node[i]=0
  print(node[i])

Buggy submission (verdict: Runtime Error):
n=int(input())
node=[-1 for i in range(n)]
g=[[] for i in range(n)]
def color(par,i,ini):
  if node[i]>-1:
    return
  else:
    if par==-1:
      node[i]=0
    else:
      node[i]=abs(node[par]-ini)
  for j in range(len(g[i])):
    color(i,g[i][j][0],g[i][j][1])
  return
for i in range(n-1):
  u,v,w=map(int,input().split())
  u-=1
  v-=1
  w%=2
  g[u].append([v,w])
  g[v].append([u,w])
color(-1,0,0)
for i in range(n):
  if node[i]==-1:
    node[i]=0
  print(node[i])

Buggy submission (verdict: Runtime Error):
n=int(input())
node=[-1 for i in range(n)]
g=[[] for i in range(n)]
def color(par,i,ini):
  if node[i]>-1:
    return
  else:
    if par==-1:
      node[i]=0
    else:
      node[i]=abs(node[par]-ini)
  for j in range(len(g[i])):
    color(i,g[i][j][0],g[i][j][1])
  return
for i in range(n-1):
  u,v,w=map(int,input().split())
  u-=1
  v-=1
  w%=2
  g[u].append([v,w])
  g[v].append([u,w])
for i in range(n):
  color(-1,i,0)
for i in range(n):
  print(node[i])

Buggy submission (verdict: Runtime Error):
n=int(input())
node=[-1 for i in range(n)]
g=[[]for i in range(n)]
def color(par,i,ini):
  if node[i]>-1:
    return
  else:
    if par==-1:
      node[i]=0
    else:
      node[i]=abs(node[par]-ini)
    for j in range(len(g[i])):
      color(i,g[i][j][0],g[i][j][1])
for i in range(n-1):
  u,v,w=map(int,input().split())
  u-=1
  v-=1
  w%=2
  g[u].append([v,w])
  g[v].append([u,w])

for i in range(n):
  color(-1,i,0)
for i in range(n):
  if node[i]==-1:
    node[i]=0
  print(node[i])

Buggy submission (verdict: Runtime Error):
n=int(input())
node=[0 for i in range(n)]
chil=[[] for i in range(n)]
change=[True for i in range(n)]
def renew(i):
  if chil[i]==[]:
    node[i]=abs(node[i]-1)
  else:
    for j in chil[i]:
      if change[j]:
        node[j]=abs(node[j]-1)
        change[j]=False
        renew(j)
  return
for i in range(n-1):
  u,v,w=map(int,input().split())
  u-=1
  v-=1
  t=w%2
  if t:
    if node[u]==node[v]:
      renew(v)
    else:
      pass
  else:
    if node[u]!=node[v]:
      renew(v)
    else:
      pass
  chil[u].append(v)
  chil[v].append(u)
  change=[True for i in range(n)]
for i in node:
  print(i)
Problem p03682 (python)

Fixed submission:
n=int(input())
x=[]
y=[]
for i in range(n):
  xx,yy=map(int,input().split())
  x.append([xx,i])
  y.append([yy,i])
x.sort()
y.sort()
px=[]
py=[]
for i in range(n-1):
  px.append([x[i+1][0]-x[i][0],x[i][1],x[i+1][1]])
  py.append([y[i+1][0]-y[i][0],y[i][1],y[i+1][1]])
p=px+py
x=[]
y=[]
px=[]
py=[]
p.sort()
r=[i for i in range(n)]
rank=[1 for i in range(n)]
def root(x):
  if x==r[x]:
    return x
  else:
    r[x]=root(r[x])
    return r[x]
def union(path):
  rx=root(path[1])
  ry=root(path[2])
  if rx==ry:
    return 0
  else:
    if rank[rx]>rank[ry]:
      r[rx]=ry
      rank[rx]+=rank[ry]
    else:
      r[ry]=rx
      rank[ry]+=rank[rx]
    return path[0]
ans=0
for i in range(len(p)):
  ans+=union(p[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import heapq
n=int(input())
x=[]
y=[]
for i in range(n):
  xx,yy=map(int,input().split())
  x.append([xx,i])
  y.append([yy,i])
x=sorted(x)
y=sorted(y)
px=[]
py=[]
for i in range(n-1):
  px.append([x[i+1][0]-x[i][0],x[i][1],x[i+1][1]])
  py.append([y[i+1][0]-y[i][0],y[i][1],y[i+1][1]])
p=px+py
heapq.heapify(p)
r=[i for i in range(n)]
def root(x):
  if x==r[x]:
    return x
  else:
    r[x]=root(r[x])
    return r[x]
def union(x,y):
  rx=root(x)
  ry=root(y)
  if rx==ry:
    return
  else:
    r[rx]=ry
ans=0
while p:
  path=heapq.heappop(p)
  if root(path[1])==root(path[2]):
    continue
  union(path[1],path[2])
  ans+=path[0]
print(ans)
Problem p02607 (python)

Fixed submission:
N = int(input())
arr = tuple(map(int, input().split()))
count = 0

for i in range(0, N, 2):
    if arr[i] % 2 != 0:
        count += 1
        
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
arr = tuple(map(int, input().split()))
count = 0

for i in range(0, N + 1, 2):
    if arr[i] % 2 != 0:
        count += 1
        
print(count)

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

for i in range(0, N + 1, 2):
    if arr[i] % 2 != 0:
        count += 1
        
print(count)

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

for i in range(1, len(arr) + 1, 2):
    if arr[i] % 2 != 0:
        count += 1
        
print(count)

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

for i in range(1, len(arr) + 1, 2):
    if arr[i] % 2 == 0:
        count += 1
        
print(count)

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

for i in range(1, len(arr), 2):
    if arr[i] % 2 == 0:
        count += 1
        
print(count)
Problem p03238 (python)

Fixed submission:
N = input()

if N == '1':
    print('Hello World')
else:
    A = int(input())
    B = int(input())
    print(A + B)

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

if n == 1:
    print("Hello Workd")
else:
    a = int(input())
    b = int(input())
    print(a + b)
Problem p02606 (python)

Fixed submission:
L, R, d = list(map(int, input().split()))
result = 0
for i in range(L, R + 1):
  if i % d == 0:
    result += 1
print(result)

Buggy submission (verdict: Runtime Error):
L, R, d = list(map(int, input().split()))
result = 0
for i in range(L, R + 1):
  if i % d == 0:
    result += 1
print(result)L, R, d = list(map(int, input().split()))
result = 0
for i in range(L, R + 1):
  if i % d == 0:
    result += 1
print(result)