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

Fixed submission:
# vim: set fileencoding=utf-8:
import bisect


def main():
    N, K = map(int, raw_input().split())
    x = [int(ele) for ele in raw_input().split()]
    o = bisect.bisect_right(x, 0)
    top = min(o + K, N)
    bottom = max(o - K, 0)
    best = 999999999999
    for i in xrange(K):
        if top < bottom + i + K:
            break

        if x[bottom + i + K - 1] < 0:
            best = min(best, abs(x[bottom + i]))
        elif x[bottom + i] < 0 <= x[bottom + i + K - 1]:
            ans1 = 2 * min(abs(x[bottom + i]), x[bottom + i + K - 1])
            ans2 = max(abs(x[bottom + i]), x[bottom + i + K - 1])
            ans = min(best, ans1 + ans2)
            best = min(best, ans)
        elif 0 <= x[bottom + i]:
            best = min(best, x[bottom + i + K - 1])

    print(best)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
# vim: set fileencoding=utf-8:
import bisect


def main():
    N, K = map(int, raw_input().split())
    x = [int(ele) for ele in raw_input().split()]
    o = bisect.bisect_right(x, 0)
    top = min(o + K, N)
    bottom = max(o - K, 0)
    best = 999999999999
    for i in xrange(K):
        if top < bottom + i + K:
            break

        print(x[bottom + i:bottom + i + K])
        print(x[bottom + i + K - 1])
        if x[bottom + i + K - 1] < 0:
            best = min(best, abs(x[bottom + i]))
        elif x[bottom + i] < 0 <= x[bottom + i + K - 1]:
            best = min(best, 2 * abs(x[bottom + i]) + x[bottom + i + K - 1])
        elif 0 <= x[bottom + i]:
            best = min(best, x[bottom + i + K - 1])

    print(best)


if __name__ == "__main__":
    main()
Problem p03455 (python)

Fixed submission:
# vim: set fileencoding=utf-8 :
a, b = map(int, raw_input().split())

if a % 2 == 0 or b % 2 == 0:
    print("Even")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
a,b=map(int,raw_input()).split()
if a%2==0 or b%2==0:
    print("Even")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
a,b=map(int,raw_input()).split()
if a%2==0 or b%2==0:
  print("Even")
else:
  print("Odd")
Problem p03495 (python)

Fixed submission:
# vim: set fileencoding=utf-8 :
from collections import Counter

n, k = map(int, raw_input().split())
a = map(int, raw_input().split())
c = Counter(a)
v = sorted(c.values())
print(sum(v[:-k]))

Buggy submission (verdict: Runtime Error):
# vim: set fileencoding=utf-8 :
from collections import Counter

n, k = map(int, raw_input().split())
a = map(int, raw_input().split())
c = Counter(a).values().sort(reverse=True)
print(sum(c[:k]))
Problem p03547 (python)

Fixed submission:
# utf-8:

def main():
    X, Y = map(str, raw_input().split())
    d = {"A": 10, "B": 11, "C": 12, "D": 13, "E": 14, "F": 15}
    if d[X] < d[Y]:
        print("<")
    elif d[X] > d[Y]:
        print(">")
    elif d[X] == d[Y]:
        print("=")


if __name__ == '__main__':
    main()

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

def main():
    X, Y = map(str, raw_input().split())
    d = {"A": 10, "B": 11, "C": 12, "D": 13, "E": 14, "E": 15}
    if d[X] < d[Y]:
        print("<")
    elif d[X] > d[Y]:
        print(">")
    elif d[X] == d[Y]:
        print("=")


if __name__ == '__main__':
    main()

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

def main():
    X, Y = map(str, raw_input().split())
    d = {"A": 10, "B": 11, "C": 12, "D": 12, "E": 12, "E": 12}
    if d[X] < d[Y]:
        print("<")
    elif d[X] > d[Y]:
        print(">")
    elif d[X] == d[Y]:
        print("=")


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

Fixed submission:
# utf-8:
import math as np


def main():
    n = int(raw_input())
    a = int(np.sqrt(n))
    print(a * a)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# utf-8:
import math as np


def main():
    n = int(raw_input())
    for i in range(n, 0, -1):
        sqrt = np.sqrt(i)
        if sqrt - int(sqrt) == 0:
            print(i)
            break


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# utf-8:
import numpy as np


def main():
    n = int(raw_input())
    for i in range(n, 0, -1):
        sqrt = np.sqrt(i)
        if sqrt - int(sqrt) == 0:
            print(i)
            break


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# utf-8:
import numpy as np


def main():
    n = int(raw_input())
    if n == 1:
        print(n)
    else:
        for i in range(n, 0, -1):
            sqrt = np.sqrt(n)
            if sqrt - int(sqrt) == 0:
                print(n)
                break


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# utf-8:
import numpy as np


def main():
    n = int(raw_input())
    if n == 1:
        print(n)
    else:
        for i in range(n):
            sqrt = np.sqrt(n - i + 1)
            if sqrt - int(sqrt) == 0:
                print(n - i)
                break


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# utf-8:
import numpy as np


def main():
    n = int(raw_input())
    for i in range(n):
        sqrt = np.sqrt(n - i +1)
        if sqrt - int(sqrt) == 0:
            print(n - i)
            break


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# utf-8:
import numpy as np


def main():
    n = int(raw_input())
    for i in range(n):
        sqrt = np.sqrt(n - i)
        if sqrt - int(sqrt) == 0:
            print(n - i)
            break


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

Fixed submission:
# vim: set fileencoding=utf-8 :
n = int(raw_input())
kyaku = 0

for _ in range(n):
    l, r = map(int, raw_input().split())
    kyaku += r - l + 1

print(kyaku)

Buggy submission (verdict: Runtime Error):

import sys

def main():
    N = input()
    ans = 0
    for _ in range(N):
        l, r =  map(int, sys.stdin.readline().rstrip().split())
        ans += abs(r-l) + 1

    print(ans)

if __name__ == "__main__":
    main()
Problem p03633 (python)

Fixed submission:
import fractions


def main():
    N = int(input())
    ans = int(input())
    for i in range(N-1):
        T = int(input())
        ans = (ans * T) // fractions.gcd(ans, T)  # 最小公倍数
        ans = int(ans)
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math
import fractions


def main():
    N = int(input())
    ans = int(input())
    for i in range(N-1):
        T = int(input())
        ans = (ans * T) / fractions.gcd(ans, T)  # 最小公倍数
        ans = int(ans)
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import fractions


def main():
    N = int(input())
    ans = int(input())
    for i in range(N-1):
       T = int(input())
       ans = (ans * T) / fractions.gcd(ans, T)
       ans = int(ans)


    print(ans)


if __name__ == "__main__":
    main()
Problem p03722 (python)

Fixed submission:
#!/usr/bin/python3
# vim: set fileencoding=utf-8:
import sys
sys.setrecursionlimit(100000)

N, M = [int(ele) for ele in input().split()]
edges = []

d = [-100000000000000000000000000000000000000000000000] * (N+1)
d_tmp = []

for _ in range(M):
    src, dst, w = [int(ele) for ele in input().split()]
    if src == 1:
        d[dst] = w
    edges.append([src, dst, w])

yet = [ele for ele in range(1, N+1)]


def main():
    print(d[-1] if bellman_ford() != -1 else "inf")


def bellman_ford():
    for _ in range(N - 1):
        for src, dst, w in edges:
            if d[dst] < w + d[src]:
                d[dst] = w + d[src]

    d_tmp = d[-1]

    for src, dst, w in edges:
        if d[dst] < w + d[src]:
            d[dst] = w + d[src]

    if d_tmp != d[-1]:
        return -1

    return


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python3
# vim: set fileencoding=utf-8:
import collections

stack = collections.deque()
N, M = [int(ele) for ele in input().split()]
edges = []
adj_list = []
for _ in range(N+1):
    adj_list.append([])

d = [-1000000000000000000000000000000000000000000000000000000] * (N+1)

for _ in range(M):
    src, dst, w = [int(ele) for ele in input().split()]
    if src == 1:
        d[dst] = w
    edges.append([src, dst, w])
    adj_list[src].append(dst)

yet = [ele for ele in range(1, N+1)]
queue = collections.deque()


def main():
    global edges
    queue.append(1)
    bfs(queue)
    edges = list(filter(lambda x: x[0] not in yet or x[1] not in yet, edges))

    print(d[-1] if bellman_ford() != -1 else "inf")


def bfs(queue):
    if not queue:  # queueが空ならfalseで終了
        return

    n = queue[-1]
    yet.remove(n)

    for dst in adj_list[n]:
        if dst in yet and dst not in queue:  # 未訪問かつqueueにもない
            queue.appendleft(dst)
    else:
        queue.pop()
        bfs(queue)


def bellman_ford():
    for _ in range(N - 1):
        for src, dst, w in edges:
            if d[dst] < w + d[src]:
                d[dst] = w + d[src]

    for src, dst, w in edges:
        if d[dst] < w + d[src]:
            return -1

    return


if __name__ == "__main__":
    main()
Problem p03035 (python)

Fixed submission:
a, b = map(int, input().split())
 
if a < 6:
  print(0)
elif a <= 12:
  print(int(b/2))
else: 
  print(b)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
 
if a > 13:
  return b
elif a < 6:
  return 0
elif a >= 6 and a <= 12: 
  return int(b/2)

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

if a > 13:
  return b
elif a < 6:
  return 0
else: 
  return b//2
Problem p03030 (python)

Fixed submission:
import numpy as np
from operator import itemgetter
 
N = int(input())
 
list = []
for i in range(N):
    a,b=input().split()
    list.append([a, int(b),i+1])
sort1 = sorted(list, key=itemgetter(0))
if N == 1:
  	print(1)
else:
    ans = []
    kari = []
    end = 1
    k = 1
    for i in range(0,N-1):
        if end == 1:
            kari.append(sort1[i])
        else:
            k = 0
        if sort1[i][0] == sort1[i+1][0]:  
            kari.append(sort1[i+1])
            end = 0
            if i+1 > N-2:
            	kari.sort(key=itemgetter(1),reverse=True)
            	ans.extend(kari)

        else:
            kari.sort(key=itemgetter(1),reverse=True)
            ans.extend(kari)
            if i+1 > N-2:
            	ans.append(sort1[i+1])
            kari = []
            end = 1
    
    for i in range(0,len(ans)):
        print(ans[i][2])

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

N = int(input())

list = []
for i in range(N):
    a,b=input().split()
    list.append([a, int(b),i+1])
sort1 = sorted(list, key=itemgetter(0))
if N == 1:
  print(1)
else:
  ans = []
  kari = []
  end = 1
  k = 1
  for i in range(0,N-1):
    if end == 1:
      kari.append(sort1[i])
      else:
        k = 0
        if sort1[i][0] == sort1[i+1][0]:  
          kari.append(sort1[i+1])
          end = 0
          if i+1 > N-2:
            kari.sort(key=itemgetter(1),reverse=True)
            ans.extend(kari)

            else:
              kari.sort(key=itemgetter(1),reverse=True)
              ans.extend(kari)
              if i+1 > N-2:
                ans.append(sort1[i+1])
                kari = []
                end = 1
  print(sort1)
  print(ans)
  for i in range(0,len(ans)):
      print(ans[i][2])

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

N = int(input())

list = []
for i in range(N):
    a,b=input().split()
    list.append([a, int(b),i+1])
sort1 = sorted(list, key=itemgetter(0))
ans = []
kari = []
end = 1
k = 1
for i in range(0,N-1):
    if end == 1:
    	kari.append(sort1[i])
    else:
      	k = 0
    if sort1[i][0] == sort1[i+1][0]:  
        kari.append(sort1[i+1])
        if i+1 > N-2:
        	kari.sort(key=itemgetter(1),reverse=True)
        	ans.extend(kari)
        end = 0
    else:
        kari.sort(key=itemgetter(1),reverse=True)
        ans.extend(kari)
        if i+1 > N-2:
        	ans.extend(sort1[i+1])
        kari = []
        end = 1

for i in range(0,len(ans)):
	print(ans[i][2])
Problem p03323 (python)

Fixed submission:
a,b=input().split()
if int(a)<=8 and int(b)<=8:
    print('Yay!')
else:
    print(':(')

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
if a<=8 and b<=8:
    print('Yay!')
else:
    print(':(')
Problem p03126 (python)

Fixed submission:
N, M = map(int, input().split())
a = []
for i in range(N):
    listed_a = list(map(int, input().split()))
    listed_a.pop(0)
    a.append(set(listed_a))


seki = a[0]
for i in range(N-1):
    seki = seki & a[i+1]
    
print(len(seki))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = []
for i in range(N):
    listed_a = list(map(int, input().split())).pop(0)
    a.append(set(listed_a))


seki = a[0]
for i in range(N-1):
    seki = seki & a[i+1]
    
print(len(seki))
Problem p03227 (python)

Fixed submission:
S = input()

listed_S = list(S)
if len(listed_S)==2:
    print(S)
elif len(listed_S)==3:
    print(S[::-1])

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

listed_S = list[S]
if len(listed_S)==2:
    print(S)
elif len(listed_S)==3:
    print(S[::-1])
Problem p03316 (python)

Fixed submission:
N = input()
mapped_N  = map(int, list(N))
sum_s = sum(list(mapped_N))
if int(N) % sum_s == 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = input("N:")
mapped_N  = map(int, list(N))
sum_s = sum(list(mapped_N))
if N % sum_s == 0:
    print("Yes")
else:
    print("No")
Problem p03079 (python)

Fixed submission:
a, b, c = map(int, input().split())
if a == b & a == c:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if a = b & a = c:
    print("Yes")
else:
    print("No")
Problem p03037 (python)

Fixed submission:
n,m = map(int,input().split())
l,r = 1,n
for i in range(m):
  L,R = map(int,input().split())
  l = max(l,L)
  r = min(r,R)
print(max(0,r-l+1))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
l,r = 1,N
for i in range(m):
  L,R = map(int,input().split())
  L = max(l,L)
  R = min(r,R)
print(max(0,L-R+1))
Problem p03101 (python)

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

Buggy submission (verdict: Runtime Error):
A,B = input().split()
a,b = input().split()
print(A*B-a*B-b*A+a*b)
Problem p03047 (python)

Fixed submission:
import math

n,k = (int(i) for i in input().split()) 
print(n-k+1)

Buggy submission (verdict: Runtime Error):
n = int(input())
strs=[]
ind_a=[]
ind_b=[]
ind_both=[]
num=0
for i in range(n):
   str=input()
   num=num+str.count("AB")
   if str[len(str)-1]=="A":
       if str[0]=="B":
           ind_both.append(i)
       else:
           ind_a.append(i)
   elif str[0]=="B":
       ind_b.append(i)
big=0
small=0
both=len(ind_both)
if len(ind_a) > len(ind_b):
    big=len(ind_a)
    small=len(ind_b)
else:
    big=len(ind_b)
    small=len(ind_a)
if (big-small)>=both:
    num=num+small+both
else:
    both=both-(big-small)+1
    num=num+big+int(both/2)
print(num)
Problem p03079 (python)

Fixed submission:
a, b, c = (int(i) for i in input().split())  
if a==b and b==c and a==c:
   print('Yes')
else:
   print('No')

Buggy submission (verdict: Runtime Error):
N, Q = (int(i) for i in input().split())  
s = input()
s="!"+s+"?"
spells = [input().split() for _ in range(Q)]
 
masu=[1]*(N+2)
for spell in spells:
   t=spell[0]
   d=spell[1]
   indexes = [i for i, x in enumerate(s) if x == t]
   if d=="R":
      for index in indexes:
         index=index+1
         masu[index]+=masu[index-1]
         masu[index-1]=0
   else:
      for index in indexes:
         masu[index]+=masu[index+1]
         masu[index+1]=0
 
masu.pop(0)
masu.pop(N)
print(sum(masu)-1)

Buggy submission (verdict: Runtime Error):
N, Q = (int(i) for i in input().split())  
s = input()
s="!"+s+"?"
spells = [input().split() for _ in range(Q)]
 
masu=[1]*(N+2)
for spell in spells:
   t=spell[0]
   d=spell[1]
   indexes = [i for i, x in enumerate(s) if x == t]
   if d=="R":
      for index in indexes:
         index=index+1
         masu[index]+=masu[index-1]
         masu[index-1]=0
   else:
      for index in indexes:
         masu[index]+=masu[index+1]
         masu[index+1]=0
 
masu.pop(0)
masu.pop(N)
print(sum(masu)+1)
Problem p03080 (python)

Fixed submission:
N=int(input())
hats=input()
 
red=0
for hat in hats:
   if hat=="R":
      red=red+1
 
if red>N-red:
   print("Yes")
else:
   print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
hats=input()
 
red=0
for hat in hats:
   if hat=="R":
      red++
 
if red>N-red:
   print("Yes")
else:
   print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
hats=input()
 
red=0
for hat in range(len(hats)):
   if hat=="R":
      red++
 
if red>N-red:
   print("Yes")
else:
   print("No")

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

red=0
for hat in hats:
   if hat=="R":
      red++

if red>N-red:
   print("Yes")
else:
   print("No")
Problem p03030 (python)

Fixed submission:

n = int(input())
list = []

for i in range(n):
    sp = input().split()
    s = str(sp[0])
    p = int(sp[1])
    list.append([i+1, s, p])

list.sort(key=lambda x:(x[1],-x[2]))
for l in list:
    print(l[0])

Buggy submission (verdict: Runtime Error):

n = input()
list = []

for i in range(n):
    print("str: ")
    s,p = input().split()
    
    #s, p = sp[0], int(sp[1])
    list.append([i+1, s, p])
"""
list.append([1, "test2", 3])
list.append([2, "test3", 1])
list.append([3, "test1", 5])
list.append([4, "test1", 4])
"""

list.sort(key=lambda x:(x[1],x[2]))
for l in list:
    print(l[0])

Buggy submission (verdict: Runtime Error):

n = input()
list = []

for i in range(n):
    print("str: ")
    sp = input().split()
    s = str(sp[0])
    p = int(sp[1])

    #s, p = sp[0], int(sp[1])
    list.append([i+1, s, p])
"""
list.append([1, "test2", 3])
list.append([2, "test3", 1])
list.append([3, "test1", 5])
list.append([4, "test1", 4])
"""

list.sort(key=lambda x:(x[1],x[2]))
for l in list:
    print(l[0])

Buggy submission (verdict: Runtime Error):

n = input()
list = []

for i in range(n):
    s, p = map(input().split())
    #s, p = sp[0], int(sp[1])
    list.append([i+1, s, p])

list.sort(key=lambda x:(x[0],x[1]))
for l in list:
    print(l[0])

Buggy submission (verdict: Runtime Error):

n = input()
list = []

for i in range(n):
    s, p = input().split()
    #s, p = sp[0], int(sp[1])
    list.append([i+1, s, p])

list.sort(key=lambda x:(x[0],x[1]))
for l in list:
    print(l[0])

Buggy submission (verdict: Runtime Error):

n = input()
list = []

for i in range(n):
    s, p = input().split()
    #s, p = sp[0], int(sp[1])
    list.append(i+1, s, p)

list.sort(key=lambda x:(x[0],x[1]))
for l in list:
    print(l[0])

Buggy submission (verdict: Runtime Error):

n = input()
list = []

for i in range(n):
    sp = input().split()
    s, p = sp[0], int(sp[1])
    list.append(i+1, s, p)

list.sort(key=lambda x:(x[0],x[1]))
for l in list:
    print(l[0])
Problem p03037 (python)

Fixed submission:
N,M = map(int, input().split())
gate_l = [[int(x) for x in input().split()] for _ in range(M)]

min_card = max(l[0] for l in gate_l)
max_card = min(l[1] for l in gate_l)

if max_card >= min_card:
    print(max_card - min_card +1)
    
else:
    print(0)

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

min_card = max(l[0] for l in gate_l)
max_card = min(l[1] for l in gate_l)

if max_card > min_card:
    print(max_card - min_card +1)
    
else:
    print(0)

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

min_card = max(l[0] for l in gate_l)
max_card = min(l[1] for l in gate_l)

print(max_card - min_card +1)
Problem p03493 (python)

Fixed submission:
s = str(input().split())
print(s.count("1"))

Buggy submission (verdict: Runtime Error):
a,b,c= map(str, input().split())
print("{}{}{}".format(a,b,c).count("1"))
Problem p03044 (python)

Fixed submission:
read = input
n = int(read())
v = [[] for i in range(n+1)] # 邻接
used = [0 for i in range(n+1)] # 节点 1~n
def add(f,t,w):
    v[f].append((t, w))
for i in range(n-1):
    f,t,w = map(int, read().split())
    add(f,t,w)
    add(t,f,w)
# 从1出发，贪心即可，1画1，理论不会有回环，总是能画成二分图
from queue import Queue
q = Queue() # 队列
#def dfs(f, s, fa=-1):
#    if s % 2 == 0: 
#        used[f] = 1
#    for t, w in v[f]:
##         print('%d->%d->%d'%(fa, f, t,), s, w)
#        if t == fa:continue
#        dfs(t, w + s, f)
#
#
#dfs(1,0)
q.put_nowait((1, 0, -1)) #(目标节点号，根节点到目标节点的距离，与目标节点相连的上一个节点号)
while not q.empty():
    f, s, fa = q.get_nowait()
    if s % 2 == 0: 
        used[f] = 1 #used数组从1开始填充颜色
    for t, w in v[f]:
#         print('%d->%d->%d'%(fa, f, t,), s, w)
        if t == fa:continue  #fa为与目标节点相连的上一个节点号，防止成环。2->3则，3->2不能再遍历一遍
        q.put_nowait(
            (t, w + s, f)
        )
    
for i in used[1:]: #球号从1开始，故used[0]无意义
    print(used[i])

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
w = np.zeros(shape = (N,N))
flag = N-1
while flag:
    l = input().split()
    i = int(l[0])-1
    j = int(l[1])-1
    w[i][j] = int(l[2])
    flag -= 1
color = np.ones(shape = (N,))
for i in range(N-1):
    for j in range(i+1,N):
        weight = w[i][j]
        if weight % 2 == 0:
            color[j] = color[i]       
        else :
            color[j] = -color[i]
for i in color:
    if i == -1:
        print(0)
    else:
        print(1)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
w = np.zeros(shape = (N,N))
flag = N-1
while flag:
    l = input().split()
    i = int(l[0])-1
    j = int(l[1])-1
    w[i][j] = int(l[2])
    flag -= 1
color = np.ones(shape = (N,))
for i in range(N//2 + 1):
    for j in range(i+1,N):
        weight = w[i][j]
        if weight!=0 and weight % 2 == 0:
            color[j] = color[i]       
        else:
            color[j] = -color[i]
for i in color:
    if i == -1:
        print(0)
    else:
        print(1)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
w = np.zeros(shape = (N,N))
flag = N-1
while flag:
    l = input().split()
    i = int(l[0])-1
    j = int(l[1])-1
    w[i][j] = int(l[2])
    flag -= 1
color = np.ones(shape = (N,))
for i in range(N//2 + 1):
    for j in range(i+1,N):
        weight = w[i][j]
        if weight!=0 and weight % 2 == 0:
            color[j] = color[i]       
        else:
            color[j] = -color[i]
for i in color:
    if i == -1:
        print(0)
    else:
        print(1)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
w = np.zeros(shape = (N,N))
flag = N-1
while flag:
    l = input.split()
    i = int(l[0])-1
    j = int(l[1])-1
    w[i][j] = int(l[2])
    flag -= 1
color = np.ones(shape = (N,))
for i in range(N//2 + 1):
    for j in range(i+1,N):
        weight = w[i][j]
        if weight!=0 and weight % 2 == 0:
            color[j] = color[i]       
        else:
            color[j] = 0
for i in color:
    print(int(i))
Problem p03035 (python)

Fixed submission:
A,B = input().split()
if int(A) < 6:
  out = 0
elif int(A) > 12:
  out = int(B)
else:
  out = int(B) // 2
print(out)

Buggy submission (verdict: Runtime Error):
A,B = list(input())
if int(A) < 6:
  out = 0
elif int(A) > 12:
  out = int(B)
else:
  out = int(B) // 2
print(out)
Problem p03037 (python)

Fixed submission:
n,m= input().split()
n = int(n)
m = int(m)
g=[input().split() for i in range(m)]
av =[-1,1000000]
for i in range(m):
  av[0] = max(int(g[i][0]),av[0])
  av[1] = min(int(g[i][1]),av[1])
print(max(av[1] -av[0]+1,0))

Buggy submission (verdict: Runtime Error):
n,m= input().split()
n = int(n)
m = int(m)
g=[input().split() for i in range(m)]

for i in int(m):
  av =[0,0]
  av[0] = max(int(g[i][0]),av[0])
  av[1] = min(int(g[i][1]),av[1])
print(av[1] -av[0]+1)