Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
V = list(map(int,input().split(" ")))
e,o = [],[]

for i,v in enumerate(V):
    if i % 2 == 0:
        e.append(v)
    else:
        o.append(v)

e_ele = list(set(e))
o_ele = list(set(o))
e1,e2,e1c,e2c = 0,0,0,0
o1,o2,o1c,o2c = 0,0,0,0

for val in e_ele:
    valc = e.count(val)
    if valc > e1c:
        e1 = val
        e1c = valc
        continue
    if valc > e2c:
        e2 = val
        e2c = valc

for val in o_ele:
    valc = o.count(val)
    if valc > o1c:
        o1 = val
        o1c = valc
        continue
    if valc > o2c:
        o2 = val
        o2c = valc

ans = 0
elen = len(e)
olen = len(o)
if e1 != o1:
    ans = elen - e1c + olen - o1c
else:
    ans = elen - e1c + olen - o2c
    if ans > olen - o1c + elen - e2c:
        ans = olen - o1c + elen - e2c
print(ans)

Fixed submission:
import collections

n = int(input())
v = list(map(int,input().split(" ")))
e,o = [],[]
e = v[::2]
o = v[1::2]

ec = collections.Counter(e).most_common(2)
oc = collections.Counter(o).most_common(2)

if ec[0][0] != oc[0][0]:
    print(n - ec[0][1] - oc[0][1])
else:
    if len(ec) == 1:
        print(n // 2)
    else:
        print(n - max(ec[0][1] + oc[1][1], ec[1][1] + oc[0][1]))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
V = list(map(int,input().split(" ")))
e,o = [],[]

for i,v in enumerate(V):
    if i % 2 == 0:
        e.append(v)
    else:
        o.append(v)

e_ele = list(set(e))
o_ele = list(set(o))
e1,e2 = None,None
o1,o2 = None,None

for val in e_ele:
    if e.count(val) > e.count(e1):
        e1 = val
        continue
    if e.count(val) > e.count(e2):
        e2 = val

for val in o_ele:
    if o.count(val) > o.count(o1):
        o1 = val
        continue
    if o.count(val) > o.count(o2):
        o2 = val

ans = 0
if e1 != o1:
    ans = len(e) - e.count(e1) + len(o) - o.count(o1)
else:
    ans = len(e) - e.count(e1) + len(o) - o.count(o2)
    if ans > len(o) - o.count(o1) + len(e) - e.count(e2):
        ans = len(o) - o.count(o1) + len(e) - e.count(e2)
print(ans)

Fixed submission:
import collections

n = int(input())
v = list(map(int,input().split(" ")))
e,o = [],[]
e = v[::2]
o = v[1::2]

ec = collections.Counter(e).most_common(2)
oc = collections.Counter(o).most_common(2)

if ec[0][0] != oc[0][0]:
    print(n - ec[0][1] - oc[0][1])
else:
    if len(ec) == 1:
        print(n // 2)
    else:
        print(n - max(ec[0][1] + oc[1][1], ec[1][1] + oc[0][1]))
Buggy python submission (verdict: Runtime Error):
import functools
import fractions

n,x = map(int,input().split())
cities = list(map(int,input().split()))
if n == x:
    ans = cities[0] - x
    print(ans)
else:
    cities.sort()
    dist = []
    for i in range(1,len(cities)):
        dist.append(cities[i] - cities[i-1])
    ans = functools.reduce(fractions.gcd, dist)
    print(ans)

Fixed submission:
import functools
import fractions
 
n,x = map(int,input().split())
cities = list(map(int,input().split()))
if n == 1:
    ans = abs(cities[0] - x)
    print(ans)
else:
    cities.append(x)
    cities.sort()
    dist = []
    for i in range(1,len(cities)):
        dist.append(cities[i] - cities[i-1])
    ans = functools.reduce(fractions.gcd, dist)
    print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())

s = list(set(map(int,S)))
s.sort

min = 0
if s[0] == 1:
    min = s[1]
else:
    min = s[0]
    
if (K == 1 and s[0] == 1):
    print(1)
else:
    print(min)

Fixed submission:
S = input()
K = int(input())
s = list(map(int,S))

num = 1
one_cnt = 0
for i in s:
    if i != 1:
        num = i
        break
    else:
        one_cnt += 1
if (one_cnt >= K):
    print(1)
else:
    print(num)
Buggy python submission (verdict: Runtime Error):
answer = C-(A-B)
if answer<0:
  answer=0
print(int(answer))

Fixed submission:
A,B,C=(int(x) for x in input().split())
answer = C-(A-B)
if answer<0:
  answer=0
print(int(answer))

Buggy python submission (verdict: Runtime Error):
  answer = C-(A-B)
  if answer<0:
    answer=0
  print(int(answer))

Fixed submission:
A,B,C=(int(x) for x in input().split())
answer = C-(A-B)
if answer<0:
  answer=0
print(int(answer))
Buggy python submission (verdict: Runtime Error):
N=int(input())
if N<10:
  A=N
elif N<100:
  A=9
elif N<1000:
  A=9+N-99
elif N<10000:
  A=9+900
elif N<100000:
  A=9+900+N-9999
else
  A=9+900+90000  
print(A)

Fixed submission:
N=int(input())
if N<10:
  A=N
elif N<100:
  A=9
elif N<1000:
  A=9+N-99
elif N<10000:
  A=9+900
elif N<100000:
  A=9+900+N-9999
else:
  A=9+900+90000  
print(A)
Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    restaurants = []
    for i in range(N):
        si, pi = input().split()
        restaurants.append([i+1, si, int(pi)])
    cities = sorted(set([restaurant[1] for restaurant in restaurants]))

    for city in cities:
        same_cities = []
        for restaurant in restaurants:
            if restaurant[1] == city:
                same_cities.append(restaurant)
        sorted_restaurants = sorted(same_cities, key=lambda restaurant: restaurant[2], reverse=True)
        [print(restaurant[0]) for restaurant in sorted_restaurants]


if __name__ == '__main__':
    main()


Fixed submission:

def main():
    A, P = [ int(x) for x in input().split() ]
    n = (A * 3 + P) / 2
    print(int(n))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
paper = []
paper.append(1000000001)

for i in range(N):
    # Aのi番目
    ai = int(input())
    for p in range(len(paper)):
        if paper[p] < ai:
            continue
        elif paper[p] == ai:
            paper.remove(ai)
            break
        else:
            paper.insert(p, ai)
            break

print(len(paper) -1)

Fixed submission:
def main():
    N = int(input())

    paper = []
    for i in range(N):
        paper.append(int(input()))

    # TimSortっていうMergeSortの改良版らしい
    paper.sort()

    preNum = paper[0]
    sameNumCount = 1
    ans = 0
    for num in paper[1:]:
        if preNum == num:
            sameNumCount += 1
        else:
            ans += sameNumCount % 2
            preNum = num
            sameNumCount = 1
    # 一番最後の判定
    if paper[-1] == preNum:
        ans += sameNumCount % 2

    print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

paper = []

for i in range(N):
  ai = int(input())
  if ai in paper:
    paper.remove(ai)
  else:
    paper.append(ai)

print(len(paper))

Fixed submission:
def main():
    N = int(input())

    paper = []
    for i in range(N):
        paper.append(int(input()))

    # TimSortっていうMergeSortの改良版らしい
    paper.sort()

    preNum = paper[0]
    sameNumCount = 1
    ans = 0
    for num in paper[1:]:
        if preNum == num:
            sameNumCount += 1
        else:
            ans += sameNumCount % 2
            preNum = num
            sameNumCount = 1
    # 一番最後の判定
    if paper[-1] == preNum:
        ans += sameNumCount % 2

    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
N = int(input())
if N < 10 ** 1:
    print(N)
elif N < 10 ** 2:
    print(9)
elif N < 10 ** 3:
    print(N - 90)
elif N < 10 ** 4:
    print(909)
elif N < 10 ** 5:
    print(N - 9090)
else:
     print(90909)

Fixed submission:
A, B, C = map(int, input().split())
if A >= 1 and A <=20 and B >= 1 and B <=20 and A >= B and C >= 1 and C <=20:
    if C - (A - B) >= 0:
        print(C - (A - B))
    else:
        print(0)
Buggy python submission (verdict: Runtime Error):
if N < 10 ** 1:
    print(N)
elif N < 10 ** 2:
    print(9)
elif N < 10 ** 3:
    print(N - 90)
elif N < 10 ** 4:
    print(909)
elif N < 10 ** 5:
    print(N - 9090)
else:
     print(90909)

Fixed submission:
N = int(input())
if N < 10:
    print(N)
elif N < 100:
    print(9)
elif N < 1000:
    print(N - 90)
elif N < 10000:
    print(909)
elif N < 100000:
    print(N - 9090)
else:
     print(90909)

Buggy python submission (verdict: Runtime Error):
if N < 10 ** 1:
    print(N)
elif N < 10 ** 2:
    print(9)
elif N < 10 ** 3:
    print(N - 90)
elif N < 10 ** 4:
    print(909)
elif N < 10 ** 5:
    print(N - 9090)
else:
     print(90909)

Fixed submission:
N = int(input())
if N < 10:
    print(N)
elif N < 100:
    print(9)
elif N < 1000:
    print(N - 90)
elif N < 10000:
    print(909)
elif N < 100000:
    print(N - 9090)
else:
     print(90909)
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
if C - (A - B) >= 0:
    print(C - (A - B))
else:
    print(0)

Fixed submission:
A, B = map(int, input().split())
if ( A + B ) % 2 == 0:
    print(int(( A + B ) / 2))
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
a,b,c = input().split()
print(max(b+c-a, 0))


Fixed submission:
a, b, c = map(int, input().split())
print(max(b+c-a, 0))
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a >= 13:
  print(B)
else if a >= 6 and a < 12:
  print(B/2)
else:
  print(0)
  


Fixed submission:
a, b = map(int, input().split())
if a >= 13:
    print(b)
elif (a >= 6 and a <= 12):
    print(b//2)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
a = map(int, input().split())
print(max(a)-min(a))

Fixed submission:
a = list(map(int, input().split()))
print(max(a) - min(a))
Buggy python submission (verdict: Runtime Error):
A, B, C, = taple(map(int, input().split()))
if (A - B) >= C:
  	print(0)
else:
  	print(C - (A - B))


Fixed submission:
A, B, C, = tuple(map(int, input().split()))
if (A - B) >= C:
  	print(0)
else:
  	print(C - (A - B))

Buggy python submission (verdict: Runtime Error):
A,　B, C, = taple(map(int, input().split()))
if (A - B) >= C:
  	print(0)
else:
  	print(C - (A - B))

Fixed submission:
A, B, C, = tuple(map(int, input().split()))
if (A - B) >= C:
  	print(0)
else:
  	print(C - (A - B))
Buggy python submission (verdict: Runtime Error):
AB = int(stdin.readline().rstrip().split())
x = max(AB)
y = max(x-1, min(AB))
print(x + y)


Fixed submission:
a,b = map(int,input().split())
c = 0
d = 0
e = 0
c += max(a,b)
d += c
d -= 1
e += min(a,b)
c += max(d,e)
print(c)
Buggy python submission (verdict: Runtime Error):
if B >= 1 and A >= B and A <= 20 and C >= 1 and C <= 20:
    capacity = A - B
    if capacity <= C:
        remaining = C - capacity
    else:
        remaining = 0
    print(remaining)

Fixed submission:
A,B,C = map(int, input().split())
if B >= 1 and A >= B and A <= 20 and C >= 1 and C <= 20:
    capacity = A - B
    if capacity <= C:
        remaining = C - capacity
    else:
        remaining = 0
    print(remaining)

Buggy python submission (verdict: Runtime Error):
N = int(input())
2 ans = 0
3 for i in range(1, N + 1):
4 if len(str(i)) % 2 == 1:
5 ans += 1
6 print(ans)


Fixed submission:
A,B,C = map(int, input().split())
if B >= 1 and A >= B and A <= 20 and C >= 1 and C <= 20:
    capacity = A - B
    if capacity <= C:
        remaining = C - capacity
    else:
        remaining = 0
    print(remaining)

Buggy python submission (verdict: Runtime Error):
if N < 10:
    print(N)
elif N >= 10 and N < 100:
    print(9)
elif N >= 100 and N < 1000:
    print(N - 90)
elif N >= 1000 and N < 10000:
    print(909)
elif N >= 10000 and N < 100000:
    print(N-9090)
else:
    print(90909)

Fixed submission:
A,B,C = map(int, input().split())
if B >= 1 and A >= B and A <= 20 and C >= 1 and C <= 20:
    capacity = A - B
    if capacity <= C:
        remaining = C - capacity
    else:
        remaining = 0
    print(remaining)
Buggy python submission (verdict: Runtime Error):
ans = 0

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

Fixed submission:
N = int(input())

ans = 0

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

Buggy python submission (verdict: Runtime Error):
ans = 0

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

Fixed submission:
N = int(input())

ans = 0

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

Buggy python submission (verdict: Runtime Error):
if N < 10:
    print(N)
elif 10 <= N < 100:
    print(9)
elif 100 <= N < 1000:
    print(N - 90)
elif 1000 <= N < 10000:
    print(909)
elif 10000 <= N < 100000:
    print(N-9090)
else:
    print(90909)

Fixed submission:
N = int(input())

ans = 0

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

Buggy python submission (verdict: Runtime Error):
if N < 10:
    print(N)
elif N >= 10 and N < 100:
    print(9)
elif N >= 100 and N < 1000:
    print(N - 90)
elif N >= 1000 and N < 10000:
    print(909)
elif N >= 10000 and N < 100000:
    print(N-9090)
else:
    print(90909)

Fixed submission:
N = int(input())

ans = 0

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

Buggy python submission (verdict: Runtime Error):
if N < 10:
    print(N)
elif N >= 10 and N < 100:
    print(9)
elif N >= 100 and N < 1000:
    print(N - 90)
elif N >= 1000 and N < 10000:
    print(909)
elif N >= 10000 and N < 100000:
    print(N-9090)
else:
    print(90909)

Fixed submission:
N = int(input())

ans = 0

for i in range(1, N + 1):
    if len(str(i)) % 2 == 1:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
list1=list(reversed(input().split()))#まだintになってないことに注意 さらに後ろから考えるために逆順になっていることに注意
list2=list(map(int,list1))
#print(list2)#int,逆順の配列完成
for i in range(len(list2)):
    print(i)
    d=list2[i]-list2[i+1]
    if d==-1:
        list2[i+1]-=1
    if d<-1:
        print("No")
        break
    if i==len(list2)-2:
        print("Yes")
        break
#print(list2)

Fixed submission:
n=int(input())
list1=list(reversed(input().split()))#まだintになってないことに注意 さらに後ろから考えるために逆順になっていることに注意
list2=list(map(int,list1))
#print(list2)#int,逆順の配列完成
if len(list2)==1:
    print("Yes")
else:
    for i in range(len(list2)):
        #print(i)
        d=list2[i]-list2[i+1]
        if d==-1:
            list2[i+1]-=1
        if d<-1:
            print("No")
            break
        if i==len(list2)-2:
            print("Yes")
            break
#print(list2)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a%2==b%2:
  return ((a+b)/2)
else:
  print("IMPOSSIBLE")


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

Buggy python submission (verdict: Runtime Error):
a,b=map(int,imput().split())
if a%2==b%2:
  print((a+b)/2)
else:
  print("IMPOSSIBLE")


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

Buggy python submission (verdict: Runtime Error):
a,b=map(int,imput().split())
if (a+b)%2==1:
  print("IMPOSSIBLE")
else:
  print((a+b)/2)

Fixed submission:
a,b=map(int,input().split())
if a%2==b%2:
  print (int((a+b)/2))
else:
  print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
n=int(input())
listA=(input().split())
list1=[0 for i in range(n)]
list2=[]
numOfBox=0
#考えるべきボールの数の合計
for i in range(n,0,-1):#n,n-1,...1って感じです
    #print(i)
    count=1
    s=0
    while i*count<=n:
        s+=list1[i*count-1]
        count+=1
    #print(s)
    if s%2!=int(listA[i-1]):
        list1[i-1]+=1
        numOfBox+=1
        list2.append(i)
#print(list1)
print(numOfBox)
for i in range(len(list2)):
    print(list2[i],end=" ")

Fixed submission:
r=int(input())
m=3*r*r
print(m)
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = [int(x) for x in input().split(" ")]
 
for i in range(1, n):
  if h[-i]-h[-i-1] >= 0:
    continue  
  elif h[-i]-h[-i-1] == -1:
    h[-i-1] = h[i-1] - 1
    continue
  elif h[i]-h[-i-1] < -1:
    ans = "No"
    break
else:
  ans = "Yes"
 
print(ans)

Fixed submission:
a, b, c = [int(x) for x in input().split(" ")]
 
rest = a - b
ans = c - rest
if ans < 0:
  ans = 0
 
print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(S: int):
    a, b = str(S)[:2], str(S)[2:]
    if a == '00' or b == '00':
        print('NA')
        return
    fa, fb = False, False
    if int(a) > 12:
        fa = True
    if int(b) > 12:
        fb = True
    if fa and fb:
        print('NA')
        return
    if fa and not fb:
        print('YYMM')
        return
    if not fa and fb:
        print('MMYY')
        return
    if not fa and not fb:
        print('AMBIGUOUS')
        return
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools
# (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  # type: int
    solve(S)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys


def solve(S: int):
    s = '{:04d}'.format(S)
    a, b = str(s)[:2], str(s)[2:]

    def judge(s):
        if s == '00' or int(s) > 12:
            return 'y'
        return 'ym'

    fa, fb = judge(a), judge(b)

    if fa == 'y' and fb == 'y':
        print('NA')
    elif fa == 'y' and fb == 'ym':
        print('YYMM')
    elif fa == 'ym' and fb == 'y':
        print('MMYY')
    elif fa == 'ym' and fb == 'ym':
        print('AMBIGUOUS')
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools
# (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  # type: int
    solve(S)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
import math


def solve(N: int, K: int):
    l = [(1 / 2) ** max(0, math.ceil(math.log2(K / i))) for i in range(1, N + 1)]
    print(sum(l) / len(l))
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools
# (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
import math


def solve(N: int, K: int):
    l = [(1 / 2) ** max(0, math.ceil(math.log2(K / i))) for i in range(1, N + 1)]
    print(sum(l) / len(l))
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools
# (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
import math


def solve(N: int, K: int):
    l = [(1 / 2) ** max(0, math.ceil(math.log2(K / i))) for i in range(1, N + 1)]
    print(sum(l) / len(l))
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools
# (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
import math


def solve(N: int, K: int):
    l = [(1 / 2) ** max(0, math.ceil(math.log2(K / i))) for i in range(1, N + 1)]
    print(sum(l) / len(l))
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools
# (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(N: int, u: "List[int]", v: "List[int]", w: "List[int]"):
    res = [0 for i in range(N)]
    G = [[] for i in range(N)]
    for i, j, k in zip(u, v, w):
        # print(i, j, k)
        i -= 1
        j -= 1
        # print(i, j, k)
        G[i].append((j, k))
        G[j].append((i, k))

    # v を c に塗る。 p は v の親。
    def dfs(v, p, c):
        res[v] = c
        for e in G[v]:
            if e[0] == p:
                continue
            if e[1] & 1:
                dfs(e[0], v, 1 - c)
            else:
                dfs(e[0], v, c)

    dfs(0, -1, 1)

    for x in res:
        print(x)

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools
# (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    u = [int()] * (N - 1)  # type: "List[int]"
    v = [int()] * (N - 1)  # type: "List[int]"
    w = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        u[i] = int(next(tokens))
        v[i] = int(next(tokens))
        w[i] = int(next(tokens))
    solve(N, u, v, w)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10 ** 7)


def solve(N: int, u: "List[int]", v: "List[int]", w: "List[int]"):
    res = [0 for i in range(N)]
    G = [[] for i in range(N)]
    for i, j, k in zip(u, v, w):
        # print(i, j, k)
        i -= 1
        j -= 1
        # print(i, j, k)
        G[i].append((j, k))
        G[j].append((i, k))
    # print(G)

    # v を c に塗る。 p は v の親。
    def dfs(v, p, c):
        res[v] = c
        for e in G[v]:
            if e[0] == p:
                continue
            if e[1] & 1:
                dfs(e[0], v, 1 - c)
            else:
                dfs(e[0], v, c)

    dfs(0, -1, 1)

    for x in res:
        print(x)

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools
# (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    u = [int()] * (N - 1)  # type: "List[int]"
    v = [int()] * (N - 1)  # type: "List[int]"
    w = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        u[i] = int(next(tokens))
        v[i] = int(next(tokens))
        w[i] = int(next(tokens))
    solve(N, u, v, w)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
a, b, c = [int(x) for x in input()]
string = max([c - a - b,0])
print(string)

Fixed submission:
a, b, c = [int(x) for x in input().split()]
water = max(c - (a - b), 0)
print(water)

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
print(str(c - a - b) + "ml")

Fixed submission:
a, b, c = [int(x) for x in input().split()]
water = max(c - (a - b), 0)
print(water)

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
print(str((b + c) % a) + "ml")

Fixed submission:
a, b, c = [int(x) for x in input().split()]
water = max(c - (a - b), 0)
print(water)