Harryxun/stf_run huggingface dataset:
import sys
sys.setrecursionlimit(200000)

n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for i in range(m):
    l, r, d = map(int, input().split())
    l -= 1
    r -= 1
    edges[l].append((r, d))
    edges[r].append((l, -d))


coord = [None for i in range(n)]
def dfs(v):
    possible = True
    for u, d in edges[v]:
        if coord[u]:
            if coord[u] != coord[v] + d:
                return False
        else:
            # not visited yet
            coord[u] = coord[v] + d
            possible = possible and dfs(u)

    return possible

ans = True
for i in range(n):
    if coord[i]:
        continue
    coord[i] = 0
    ans = ans and dfs(i)

if ans:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

from collections import deque

def topological_sort(graph: list, n_v: int) -> list:
    # graph[node] = [(cost, to)]
    indegree = [0] * n_v # 各頂点の入次数
    for i in range(n_v):
        for c, v in graph[i]:
            indegree[v] += 1

    cand = deque([i for i in range(n_v) if indegree[i] == 0])
    res = []
    while cand:
        v1 = cand.popleft()
        res.append(v1)
        for c, v2 in graph[v1]:
            indegree[v2] -= 1
            if indegree[v2] == 0:
                cand.append(v2)

    return res




n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for i in range(m):
    l, r, d = map(int, input().split())
    l -= 1
    r -= 1
    edges[l].append((d, r))

ts = topological_sort(edges, n)

if len(ts) != n:
    ans = "No"
    # print("Not DAG")
else:
    # DAG
    dist = [-1] * n
    ans = "Yes"
    for i in range(n):
        v = ts[i]
        if dist[v] == -1:
            dist[v] = 0

        for c, u in edges[v]:
            if dist[u] == -1:
                dist[u] = dist[v] + c
            elif dist[u] != dist[v] + c:
                ans = "No"
                break

print(ans)
A,B,K=map(int,input().split())
while K!==0:
  if A>=1:
    A--
    K--
  else:
    B--
    K--
print(A,' ',B)

### FIXED CODE ###

A,B,K=map(int,input().split())
if K>=A:
  K=K-A
  if K>=B:
    K=K-B
    print('0 0')
  else:
    B=B-K
    print(0,' ',B)
else:
  print(A-K,' ',B)
N, M = map(int, input().split())
D = [int(input()) for i in range(N)]
C = [int(input()) for i in range(M)]
memo = {}
def dfs(i, j):
    if i == N:
        return 0
    if j == M:
        return 10**9
    if (i, j) in memo:
        return memo[i, j]
    memo[i, j] = res = min(dfs(i+1, j+1) + D[i]*C[j], dfs(i, j+1))
    return res
print(dfs(0, 0))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
N, M = map(int, input().split())
D = [int(input()) for i in range(N)]
C = [int(input()) for i in range(M)]
memo = {}
def dfs(i, j):
    if i == N:
        return 0
    if j == M:
        return 10**9
    if (i, j) in memo:
        return memo[i, j]
    memo[i, j] = res = min(dfs(i+1, j+1) + D[i]*C[j], dfs(i, j+1))
    return res
print(dfs(0, 0))
n,m = [int(i) for i in input().split()]

cakes = []
ranking = [[] for i in range(8)]
ranking2 = []

for i in range(n):
    cakes.append(list(map(int,input().split())))

a = 0
for i in range(2):
    for j in range(2):
        for k in range(2):
            for x in range(n):
                kirei = cakes[x][0]
                oisii = cakes[x][1]
                ninki = cakes[x][2]
                if i ==1:
                    kirei = (-1)*kirei
                if j ==1:
                    oisii = (-1) * oisii
                if k==1:
                    ninki = (-1)*ninki
                sum = kirei + oisii + ninki
                ranking[a].append(sum)
            a += 1

for i in ranking:
    i = sorted(i)
    i = i[::-1]
    ranking2.append(i)

ans = 0

maxi = 0

for x in ranking2:
    ans = 0
    for i in range(m):
        ans += x[i]
    maxi = max(maxi,ans)
print(maxi)n,m = [int(i) for i in input().split()]

cakes = []
ranking = [[] for i in range(8)]
ranking2 = []

for i in range(n):
    cakes.append(list(map(int,input().split())))

a = 0
for i in range(2):
    for j in range(2):
        for k in range(2):
            for x in range(n):
                kirei = cakes[x][0]
                oisii = cakes[x][1]
                ninki = cakes[x][2]
                if i ==1:
                    kirei = (-1)*kirei
                if j ==1:
                    oisii = (-1) * oisii
                if k==1:
                    ninki = (-1)*ninki
                sum = kirei + oisii + ninki
                ranking[a].append(sum)
            a += 1

for i in ranking:
    i = sorted(i)
    i = i[::-1]
    ranking2.append(i)

ans = 0

maxi = 0

for x in ranking2:
    ans = 0
    for i in range(m):
        ans += x[i]
    maxi = max(maxi,ans)
print(maxi)

### FIXED CODE ###

n,m = [int(i) for i in input().split()]

cakes = []
ranking = [[] for i in range(8)]
ranking2 = []

for i in range(n):
    cakes.append(list(map(int,input().split())))

a = 0
for i in range(2):
    for j in range(2):
        for k in range(2):
            for x in range(n):
                kirei = cakes[x][0]
                oisii = cakes[x][1]
                ninki = cakes[x][2]
                if i ==1:
                    kirei = (-1)*kirei
                if j ==1:
                    oisii = (-1) * oisii
                if k==1:
                    ninki = (-1)*ninki
                sum = kirei + oisii + ninki
                ranking[a].append(sum)
            a += 1

for i in ranking:
    i = sorted(i)
    i = i[::-1]
    ranking2.append(i)

ans = 0

maxi = 0

for x in ranking2:
    ans = 0
    for i in range(m):
        ans += x[i]
    maxi = max(maxi,ans)
print(maxi)
n = int(input())
a = np.array([0] + list(map(int, input().split())) + [0])

whole = np.abs((np.diff(a))).sum()

for i in range(n):
    print(whole - abs(a[i + 1] - a[i]) -
          abs(a[i + 2] - a[i + 1]) + abs(a[i + 2] - a[i]))

### FIXED CODE ###

import numpy as np
n = int(input())
a = np.array([0] + list(map(int, input().split())) + [0])

whole = np.abs((np.diff(a))).sum()

for i in range(n):
    print(whole - abs(a[i + 1] - a[i]) -
          abs(a[i + 2] - a[i + 1]) + abs(a[i + 2] - a[i]))
s = int(input())
rec = {}


def f(x):
    if x % 2 == 0:
        return x//2
    else:
        return 3*x + 1


c = 0
while True:
    if s in rec:
        print(c)
        exit()
    rec.add(s)
    s = f(s)
    c += 1


### FIXED CODE ###

s = int(input())
rec = set()


def f(x):
    if x % 2 == 0:
        return x//2
    else:
        return 3*x + 1


c = 1
while True:
    if s in rec:
        print(c)
        exit()
    rec.add(s)
    s = f(s)
    c += 1
import copy 

def gcd(a,b):
    if b > a:
        a, b = b, a
    while b:
        a, b = b, a%b
    return a

N = int(input())
T = list(map(int,input().split()))
T.sort()
LIS = [0]*N
LIS[0] += T[0]
for i in range(N-1):
    LIS[i+1] += gcd(LIS[i],T[i+1])
GCD = 0
GCD += LIS[N-1]
if N == 2:
    ANS = max(T[0],T[1])
else:
    #第１項がtarget
    S = copy.copy(T)
    S.pop(0)
    LS = [0]*(N-1)
    LS[0] += S[0]
    for i in range(N-2):
        LS[i+1] += gcd(LS[i],S[i+1])
    ANSA = LS[N-2]

    #その他の場合
    LJ = []
    for i in range(N-1):
        if LIS[i] != LIS[i+1]:
            LJ.append(i+1)

    LK = []
    for j in range(len(LJ)):
        U = copy.copy(T)
        U.pop(LJ[j])
        print(U)
        LS = [0]*(N-1)
        LS[0] += U[0]
        for i in range(N-2):
            LS[i+1] += gcd(LS[i],S[i+1])
        LK.append(LS[N-2])
    ANSB = max(LK)
    ANS = max(ANSA,ANSB)
print(ANS)


### FIXED CODE ###

import copy 

def gcd(a,b):
    if b > a:
        a, b = b, a
    while b:
        a, b = b, a%b
    return a

N = int(input())
T = list(map(int,input().split()))
T.sort()
LIS = [0]*N
LIS[0] += T[0]
for i in range(N-1):
    LIS[i+1] += gcd(LIS[i],T[i+1])
F = LIS.index(min(LIS))
if len(T) == 2:
    ANS = max(T[0],T[1])
elif F == 0:
    U = copy.copy(T)
    V = copy.copy(T)
    U.pop(1)
    V.pop(0)
    LU = [0]*(N-1)
    LU[0] = U[0]
    LV = [0]*(N-1)
    LV[0] = V[0]
    for i in range(N-2):
        LU[i+1] += gcd(LU[i],U[i+1])
    ANSU = LU[N-2]
    for i in range(N-2):
        LV[i+1] += gcd(LV[i],V[i+1])
    ANSV = LV[N-2]
    ANS = max(ANSU,ANSV)
    
else:
    U = copy.copy(T)
    V = copy.copy(T)
    U.pop(F)
    V.pop(0)
    LU = [0]*(N-1)
    LU[0] = U[0]
    LV = [0]*(N-1)
    LV[0] = V[0]
    ANSU = 0
    ANSV = 0
    for i in range(N-2):
        LU[i+1] += gcd(LU[i],U[i+1])
    ANSU = LU[N-2]
    for i in range(N-2):
        LV[i+1] += gcd(LV[i],V[i+1])
    ANSV = LV[N-2]
    ANSP = max(ANSU,ANSV)
    ANS = max(ANSP,LIS[N-1])
        
print(ANS)
import math 
a,b,x=map(int,input().split())
if x==(a*a*b)//2:
    print(math.degrees(math.atan(b/a)))
elif x>(a*a*b)//2:
    x=((2*x)/(a*b))-a
    print(math.degrees(math.atan(b/(a-x))))



### FIXED CODE ###

from math import atan2, degrees

a, b, x = map(int, input().split())

s = x/a
if s >= a*b/2:
    z = 2*b - 2*x/a**2
    ans = degrees(atan2(z, a))
else:
    z = 2*x/(a*b)
    ans = 90-degrees(atan2(z, b))
print(ans)
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
V = []
W = []
for _ in range(n):
    v, w = LI()
    V.append(v)
    W.append(w)

q = I()
vl = []
maxL = 0
for _ in range(q):
    v, l = LI()
    maxL = max(maxL, l)
    vl.append([v,l])

m = int(math.sqrt(n))
dp = [[0]*(maxL + 1) for _ in range(m + 1)]

for i in range(1, m+1):
    for j in range(maxL+1):
        if j < W[i-1]:
            dp[i][j] = dp[i//2][j]
        else:
            dp[i][j] = max(dp[i//2][j],dp[i//2][j-W[i-1]] + V[i-1])

for i in range(q):
    v, L = vl[i]
    if v <= m:
        print(dp[v][L])
        continue
    x = v.bit_length() - m.bit_length()
    ret = 0
    for j in range(1 << x):
        weight_sum = 0
        value_sum = 0
        tmp = v
        for k in range(x):
            if j >> k & 1:
                weight_sum += W[tmp - 1]
                if weight_sum > L:
                    break
                value_sum += V[tmp - 1]
            tmp //= 2
        else:
            value_sum += dp[tmp][L - weight_sum]
            ret = max(ret, value_sum)
    print(ret)


### FIXED CODE ###

#!/usr/bin/env python3

def main():
    import sys
    def I(): return int(sys.stdin.readline())
    def LI(): return list(map(int,sys.stdin.readline().split()))

    n = I()
    V = []
    W = []

    maxL = 10**5
    m = min(n, 1 << 10)
    dp = [[0]*(maxL + 1)]
    
    for i in range(n):
        v, w = LI()
        if i <= m:
            d_ = dp[(i+1)>>1][:]
            for j in range(w, maxL+1)[::-1]:
                d_[j] = max(d_[j], d_[j - w] + v)
            dp.append(d_)
        V.append(v)
        W.append(w)
    
    q = I()
    for i in range(q):
        v, L = LI()
        if v <= m:
            print(dp[v][L])
            continue
        cnt = 0
        v_ = []
        w_ = []
        while v > m:
            v_.append(V[v-1])
            w_.append(W[v-1])
            v >>= 1
            cnt += 1
        ret = dp[v][L]
        v_tmp = [0] * (1 << cnt)
        w_tmp = [0] * (1 << cnt)
        for b in range(1, 1 << cnt):
            lsb = b & -b
            l = lsb.bit_length()
            w_t = w_tmp[b - lsb] + w_[l-1]
            w_tmp[b] = w_t
            if w_t <= L:
                v_t = v_tmp[b - lsb] + v_[l-1]
                v_tmp[b] = v_t
                ret = max(ret, v_t + dp[v][L - w_t])
        print(ret)
    return

if __name__ == "__main__":
    main()
h, w = map(int, input().split())
lsa = [list(map(int, input().split())) for i in range(h)]
lsb = [list(map(int, input().split())) for i in range(h)]
ls = [[abs(lsa[i][j] - lsb[i][j]) for j in range(w)] for i in range(h)]

p=0
for i in range(h):
    p+= sum(ls[i])

dp = [[[False]*p for _ in range(w)] for _ in range(h)]

dp[0][0][ls[0][0]] = True

for i in range(h):
    for j in range(w):

        if j != 0:  
            for k in range(p):
                if dp[i][j-1][k]:
                    dp[i][j][k+ls[i][j]] = True
                    dp[i][j][abs(k-ls[i][j])] = True

        if i != 0:
            for k in range(p):
                if dp[i-1][j][k]:
                    dp[i][j][k+ls[i][j]] = True
                    dp[i][j][abs(k-ls[i][j])] = True

for i in range(p):
    if dp[h-1][w-1][i]:
        break

print(i)
            

### FIXED CODE ###

h, w = map(int, input().split())
lsa = [list(map(int, input().split())) for i in range(h)]
lsb = [list(map(int, input().split())) for i in range(h)]
ls = [[abs(lsa[i][j] - lsb[i][j]) for j in range(w)] for i in range(h)]
bias = 80*80*80

dp = [[0 for _ in range(w)] for _ in range(h)]

dp[0][0] = 1 << ls[0][0]+bias

for i in range(h):
    for j in range(w):

        if j != 0:  
            dp[i][j] |= dp[i][j-1] << ls[i][j]
            dp[i][j] |= dp[i][j-1] >> ls[i][j]

        if i != 0:
            dp[i][j] |= dp[i-1][j] << ls[i][j]
            dp[i][j] |= dp[i-1][j] >> ls[i][j]

ans = dp[h-1][w-1] >> bias
idx = 0
while(1):
    if 1 << idx & ans:
        break
    idx += 1
print(idx)
import sys
import itertools
import functools
from math import gcd


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


def lcm(x):
    return functools.reduce(lcm2, x)


def resolve(in_):
    N = int(next(in_))
    A = tuple(map(int, next(in_).split()))
    a_lcm = lcm(A)

    mod = 10 ** 9 + 7

    ans = 0
    for a in A:
        ans += a_lcm // a
        ans %= mod
            
    return ans


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

H, M = map(int, next(sys.stdin.buffer).split())
print('Yes' if H == M else 'No')
D,N = map(int,input().split())
0 5
A = [int(i) for i in range(1,100)] + [101]
B = [int(i*100) for i in range(1,100)] + [10001]
C = [int(i*10000) for i in range(1,101)] + [10000001]

if D == 0:
	print(A[N-1])
elif D == 1:
	print(B[N-1])
else:
	print(C[N-1])

### FIXED CODE ###

D,N = map(int,input().split())
A = [int(i) for i in range(1,100)] + [101]
B = [int(i*100) for i in range(1,100)] + [10100]
C = [int(i*10000) for i in range(1,100)] + [1010000]

if D == 0:
	print(A[N-1])
elif D == 1:
	print(B[N-1])
else:
	print(C[N-1])
n = int(input())
A = [int(i) for i in input().split()]
count = 0
for j in range(n):
    for k in range(1,n-j+1,1):
        print(A[j:j+k])
        if not sum(A[j:j+k]):
            count += 1
print(count)

### FIXED CODE ###

from collections import Counter
n = int(input())
A = [int(i) for i in input().split()]
S = [0]*(n+1)
for i in range(n):
    S[i+1] = S[i] + A[i]
def hello(data):
    dt = Counter()
    for i in data:
        dt[str(i)] += 1
    return dt
num = hello(S)
out = [i*(i-1)//2 for i in num.values() if i>1]
print(sum(out))
n = int(input())
a = input().split()
for i in range(n):
    a[i] = int(a[i])
a = sorted(a)
while len(a) > 1:
    for i in range(1,len(a)):
        if a[len(a)-i] % a[0] == 0:
            a.pop(len(a)-i)
        else: a[len(a)-i] %= a[0]
    a = sorted(a)
print(a[0])

### FIXED CODE ###

n = int(input())
a = input().split()
for i in range(n):
    a[i] = int(a[i])
def gcm(a,b):
    if a >= b:
        if a % b == 0:
            return b 
        else:
            return gcm(b,a%b)
    else: return gcm(b,a)
for i in range(1,len(a)):
    a[0] = gcm(a[0],a[i])
print(a[0])
case = input()
for i in range(len(case)):
  AC = 0
  WA = 0
  TLE = 0
  RE = 0
  others = 0
  if case[i] == "AC":
    AC += 1
    return AC
  elif case[i] == "WA":
    WA += 1
    return WA
  elif case[i] == "TLE":
    TLE += 1
    return TLE
  elif case[i] == "RE":
    RE += 1
    return RE
  else :
    others += 1
    return others
print("AC"+"x"+AC)
print("WA"+"x"+WA)
print("TLE"+"x"+TLE)
print("RE"+"x"+RE)

### FIXED CODE ###

N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
others = 0
for i in range(N):
  case = input()
  if case == "AC":
    AC += 1
      
  elif case == "WA":
    WA += 1
      
  elif case == "TLE":
    TLE += 1
      
  elif case == "RE":
    RE += 1
      
print("AC"+" x "+str(AC))
print("WA"+" x "+str(WA))
print("TLE"+" x "+str(TLE))
print("RE"+" x "+str(RE))
# -*- coding: utf-8 -*- 
price, K = map(int, input().split())
 
kirai_data =input().split()
#print(set(data))
 
lst = list(range(price,10001))
for min in lst:
   
    shugo = set(kirai_data) & set(list(str(min))) 
    if  len(shugo) != 0 :                         
        continue
    else:
      #print(price)
      print(min)
      break

### FIXED CODE ###

# -*- coding: utf-8 -*-

input_list = input().split()

cnt7 = 0
cnt5 = 0

for n in input_list:
    if int(n) == 7:
        cnt7 += 1
    elif int(n) == 5:
        cnt5 += 1
    else:
        continue
if cnt7 == 1 and cnt5 == 2:
    print("YES")
else:
    print("NO")
N = int(input())
S = list(input())

# N=4000
# S=[random.choice(['R','G','B']) for _ in range(N)]

S_dict={'R':set(),'G':set(),'B':set()}
for s_idx,s in enumerate(S):
    S_dict[s].add(s_idx+1)
    
# print(S_dict)
B_ = [0]*(2*N)
for s_b in S_dict['B']:
    B_[s_b]=1
    
S_R=S_dict['R']
S_G=S_dict['G']
    
ans=0
ans__=len(S_dict['B'])
for s_r in S_R:
    for s_g in S_G:
        ans_=ans__
        c_= abs(s_r-s_g)
        c_mean = 0
        if (s_r + s_g)%2 == 0:
            c_mean = (s_r + s_g)//2
            ans_ = get_ans(ans_,c_mean)
            
#         print('=====')
#         print(s_r,s_g,c_,c_mean)
        
        if s_r > s_g:
            ans_ = get_ans(ans_,s_r + c_)
            ans_ = get_ans(ans_,s_g - c_)
            
#             print(s_r + c_,s_g - c_)
            
        else:
            ans_=get_ans(ans_,s_r - c_)
            ans_=get_ans(ans_,s_g + c_)
            
#             print(s_r - c_,s_g + c_)
        
        ans+=ans_
        
#         print(ans_,ans)
        
print(ans)

### FIXED CODE ###

N = int(input())
S = list(input())

def get_ans(ans_,c):
    if c < 0:
        pass
    else:
        ans_ -= B_[c]
    return ans_

# N=4000
# S=[random.choice(['R','G','B']) for _ in range(N)]

S_dict={'R':set(),'G':set(),'B':set()}
for s_idx,s in enumerate(S):
    S_dict[s].add(s_idx+1)
    
# print(S_dict)
B_ = [0]*(2*N)
for s_b in S_dict['B']:
    B_[s_b]=1
    
S_R=S_dict['R']
S_G=S_dict['G']
    
ans=0
ans__=len(S_dict['B'])
for s_r in S_R:
    for s_g in S_G:
        ans_=ans__
        c_= abs(s_r-s_g)
        c_mean = 0
        if (s_r + s_g)%2 == 0:
            c_mean = (s_r + s_g)//2
            ans_ = get_ans(ans_,c_mean)
            
#         print('=====')
#         print(s_r,s_g,c_,c_mean)
        
        if s_r > s_g:
            ans_ = get_ans(ans_,s_r + c_)
            ans_ = get_ans(ans_,s_g - c_)
            
#             print(s_r + c_,s_g - c_)
            
        else:
            ans_=get_ans(ans_,s_r - c_)
            ans_=get_ans(ans_,s_g + c_)
            
#             print(s_r - c_,s_g + c_)
        
        ans+=ans_
        
#         print(ans_,ans)
        
print(ans)
K = int(input())
S = input()
if len(S) > K:
	new_S = S[:K]
	new_S += '...'
    print(new_S)
else:
  print(S)


### FIXED CODE ###

N = int(input())
 
if N % 10 == 3:
	print('bon')
elif N%10 == 0 or N%10 == 1 or N%10 == 6 or N%10 == 8:
	print('pon')
else: print('hon')
#ARC066-C
N=int(input())
A=[int(i) for i in input().split()]
const=10**9+7
cnt={}
ans=0
flag=True
if N%2==0:
    for k in range(1,N,2):
        cnt[k]=0
    for a in A:
        cnt[a]+=1
    for k in range(1,N,2):
        if cnt[k]!=2:
            flag=False
            break
    if flag: ans=pow(2,N//2,const)
else:
    for k in range(0,N,2):
        cnt[k]=0
    for a in A:
        cnt[a]+=1
    for k in range(0,N,2):
        if k==0:
            if cnt[0]!=1:
                flag=False
                break
        else:
            if cnt[k]!=2:
                flag=False
                break
    if flag: ans=pow(2,(N-1)//2,const)
print(ans)
    

### FIXED CODE ###

#AGC015-B
if False:
    S=list(input())
    N=len(S)
    ans=0
    for i in range(N):
        if S[i]=='U':
            ans+=N-(i+1)
            ans+=i*2
        else:
            ans+=(N-(i+1))*2
            ans+=i
    print(ans)
            
#ARC069-C
if False:
    N,M=map(int,input().split())
    ans=min(N,M//2)
    if N<(M//2):
        ans+=((M//2-N)*2+(M%2))//4
    print(ans)

#ABC028-D
if False:
    N,K=map(int,input().split())
    ans=3*(N-1)+6*(K-1)*(N-K)+1
    ans=ans/(N**3)
    print(ans)

#ABC133-D
if False:
    N=int(input())
    A=[int(i) for i in input().split()]
    ANS=[sum(A)-2*sum(A[1::2])]
    for i in range(N-1):
        ANS.append(2*A[i]-ANS[-1])
    print(*ANS)

#ARC066-C
N=int(input())
A=[int(i) for i in input().split()]
const=10**9+7
cnt={}
ans=0
flag=True
if N%2==0:
    for k in range(N):
        cnt[k]=0
    for a in A:
        cnt[a]+=1
    for k in range(1,N,2):
        if cnt[k]!=2:
            flag=False
            break
    if flag: ans=pow(2,N//2,const)
else:
    for k in range(N):
        cnt[k]=0
    for a in A:
        cnt[a]+=1
    for k in range(0,N,2):
        if k==0:
            if cnt[0]!=1:
                flag=False
                break
        else:
            if cnt[k]!=2:
                flag=False
                break
    if flag: ans=pow(2,(N-1)//2,const)
print(ans)
N,K = map(int, input().split())
l = list(map(int,input().split()))

def E(n):
  return sum(range(1,n+1)) / n

j = sum(l[0:0+K])
m = 0
if N == 1:
  l2 = list(map(E, l))
  print(sum(l2))
  
else:
  for i in range(1,len(l)-(K-1)):
      j = j - l[i-1] + l[i+K-1]
      if l[i] < l[i-1]:
          continue
      elif m < j:
          m = j
          t = l[i:i+K]

  l2 = list(map(E, t))

  print(sum(l2))

### FIXED CODE ###

N,K = map(int, input().split())
l = list(map(int,input().split()))
 
def E(n):
  return (1 + n) / 2
 
j = sum(l[0:0+K])
m = 0
if N == 1:
  l2 = list(map(E, l))
  print(sum(l2))
elif N == K:
  l2 = list(map(E, l))  
  print(sum(l2))
else:
  for i in range(1,len(l)-(K-1)):
      j = j - l[i-1] + l[i+K-1]
      if l[i] < l[i-1]:
          continue
      elif m < j:
          m = j
          t = l[i:i+K]

  l2 = list(map(E, t))
 
  print(sum(l2))
n = int(input())

def prime_decomposition(n):
    # 素因数分解
    if n < 2:
        return []
    prime_factors = []
    while n % 2 == 0:
        prime_factors.append(2)
        n >>= 1

    while n % 3 == 0:
        prime_factors.append(3)
        n //= 3

    a = 5
    b = 7
    while a ** 2 <= n:
        if n % a == 0:
            prime_factors.append(a)
            n //= a
        elif n % b == 0:
            prime_factors.append(b)
            n //= b
        else:
            a += 6
            b += 6
    if n > 1:
        prime_factors.append(n)
    return prime_factors

pfs = prime_decomposition(n)
pfs.reverse()

def ds(n):

    ret = 1
    while 10**ret <= n:
        ret += 1
    return ret

ln = len(pfs)
size = 2**ln

min_v = 100
for i in range(size):
    p = 1
    for j in range(ln):
        if 1<<j & i:
            p *= pfs[j]
    min_v = min(min_v, max(ds(p), ds(n//p)))
print(min_v)

### FIXED CODE ###

a,b=map(int, input().split())
print((a+b)%24)
def main():
    n = int(input())
    
    G=[[] for _ in range(n)]
    for _ in range(n-1):
        u,v,w = map(int, input().split())
        G[u-1].append([v-1,w])
        G[v-1].append([u-1,w])
    ans=[-1]*n
    
    def sub(node,distance):
        for next_node, edge in G[node]:
            if ans[next_node]==-1:
                ans[next_node]=(distance+edge)%2
                sub(next_node,(distance+edge)%2)
    sub(0,0)
    
    for i in ans:
        print(i)
main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)


def main():
    n = int(input())
    
    G=[[] for _ in range(n)]
    for _ in range(n-1):
        u,v,w = map(int, input().split())
        G[u-1].append([v-1,w])
        G[v-1].append([u-1,w])
    ans=[-1]*n
    
    def sub(node,distance):
        for next_node, edge in G[node]:
            if ans[next_node]==-1:
                ans[next_node]=(distance+edge)%2
                sub(next_node,(distance+edge)%2)
    sub(0,0)
    
    for i in ans:
        print(i)
main()