Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys
sys.setrecursionlimit(10**5)
max = 10**5+5

def dk(start,node,edge):
  ans = [0] * node
  q = [start]
  
  while(len(q) != 0):
    i = q.pop()
    for j, cost in edge[i]:
      ans[j] = (ans[i] + cost)%2
      q.append(j)
  return ans

#入力
N = int(input())
#エッジ
E = [[] for _ in [0]*(max)]

for i in range(N-1):
  a,b,w = (int(x) for x in input().split())
  E[a-1].append((b-1, w))
  E[b-1].append((a-1, w))


ans = dk(0, N, E)

#出力
print(*ans, sep = "\n")
    

Fixed submission:
import numpy as np
import sys
INF = float('inf')
sys.setrecursionlimit(10**5)
max = 10**5+5

def dk(start,node,edge):
  ans = [INF] * node
  ans[0] = 0
  q = [start]
  
  while(len(q) != 0):
    i = q.pop()
    for j, cost in edge[i]:
      if(ans[j] != INF):
        continue
      ans[j] = (ans[i] + cost)%2
      q.append(j)
  return ans

#入力
N = int(input())
#エッジ
E = [[] for _ in [0]*(max)]

for i in range(N-1):
  a,b,w = (int(x) for x in input().split())
  E[a-1].append((b-1, w))
  E[b-1].append((a-1, w))


ans = dk(0, N, E)

#出力
print(*ans, sep = "\n")

Buggy python submission (verdict: Runtime Error):
from heapq import *
import numpy as np

def dk(start,node,edge):
  d = [0] * node
  d[start] = 0
  q = [(0, start)]
  
  while(len(q) != 0):
    ci, i = heappop(q)
    for j in edge[i]:
      nc = ci + cost[i][j]
      d[j] = int(nc%2)
      heappush(q,(nc, j))
  return d

#入力
N = int(input())
#エッジ
E = [[] for _ in [0]*(N)]
cost = np.zeros((N, N))

for i in range(N-1):
  a,b,w = (int(x) for x in input().split())
  E[a-1].append(b-1)
  cost[a-1][b-1] = w
  cost[b-1][a-1] = w


d = dk(0, N, E)

#出力
print(*d, sep = "\n")
    

Fixed submission:
import numpy as np
import sys
INF = float('inf')
sys.setrecursionlimit(10**5)
max = 10**5+5

def dk(start,node,edge):
  ans = [INF] * node
  ans[0] = 0
  q = [start]
  
  while(len(q) != 0):
    i = q.pop()
    for j, cost in edge[i]:
      if(ans[j] != INF):
        continue
      ans[j] = (ans[i] + cost)%2
      q.append(j)
  return ans

#入力
N = int(input())
#エッジ
E = [[] for _ in [0]*(max)]

for i in range(N-1):
  a,b,w = (int(x) for x in input().split())
  E[a-1].append((b-1, w))
  E[b-1].append((a-1, w))


ans = dk(0, N, E)

#出力
print(*ans, sep = "\n")

Buggy python submission (verdict: Runtime Error):
from heapq import *
import numpy as np
import sys
sys.setrecursionlimit(200000)

def dk(start,node,edge):
  d = [0]*node
  d[start] = 0
  q = [(0, start)]
  
  while(len(q) != 0):
    ci, i = heappop(q)
    for j in edge[i]:
      nc = ci + cost[i][j]
      if nc%2 == 1:
        d[j] = 1
      heappush(q,(nc, j))
  return d

#入力
N = int(input())
#エッジ
E = [[] for _ in [0]*(N+1000)]
cost = np.zeros((N+1000, N+1000))

for i in range(N-1):
  a,b,w = (int(x) for x in input().split())
  E[a-1].append(b-1)
  cost[a-1][b-1] = w
  cost[b-1][a-1] = w


d = dk(0, N, E)

#出力
print(*d, sep = "\n")
    

Fixed submission:
import numpy as np
import sys
INF = float('inf')
sys.setrecursionlimit(10**5)
max = 10**5+5

def dk(start,node,edge):
  ans = [INF] * node
  ans[0] = 0
  q = [start]
  
  while(len(q) != 0):
    i = q.pop()
    for j, cost in edge[i]:
      if(ans[j] != INF):
        continue
      ans[j] = (ans[i] + cost)%2
      q.append(j)
  return ans

#入力
N = int(input())
#エッジ
E = [[] for _ in [0]*(max)]

for i in range(N-1):
  a,b,w = (int(x) for x in input().split())
  E[a-1].append((b-1, w))
  E[b-1].append((a-1, w))


ans = dk(0, N, E)

#出力
print(*ans, sep = "\n")

Buggy python submission (verdict: Runtime Error):
from heapq import *
import numpy as np

def dk(start,node,edge):
  d = [0]*node
  d[start] = 0
  q = [(0, start)]
  
  while(len(q) != 0):
    ci, i = heappop(q)
    for j in edge[i]:
      nc = ci + cost[i][j]
      if nc%2 == 1:
        d[j] = 1
      heappush(q,(nc, j))
  return d

#入力
N = int(input())
#エッジ
E = [[] for _ in [0]*N]
cost = np.zeros((N, N))

for i in range(N-1):
  a,b,w = (int(x) for x in input().split())
  E[a-1].append(b-1)
  cost[a-1][b-1] = w
  cost[b-1][a-1] = w


d = dk(0, N, E)

#出力
print(*d, sep = "\n")
    

Fixed submission:
import numpy as np
import sys
INF = float('inf')
sys.setrecursionlimit(10**5)
max = 10**5+5

def dk(start,node,edge):
  ans = [INF] * node
  ans[0] = 0
  q = [start]
  
  while(len(q) != 0):
    i = q.pop()
    for j, cost in edge[i]:
      if(ans[j] != INF):
        continue
      ans[j] = (ans[i] + cost)%2
      q.append(j)
  return ans

#入力
N = int(input())
#エッジ
E = [[] for _ in [0]*(max)]

for i in range(N-1):
  a,b,w = (int(x) for x in input().split())
  E[a-1].append((b-1, w))
  E[b-1].append((a-1, w))


ans = dk(0, N, E)

#出力
print(*ans, sep = "\n")