Harryxun/stf_run huggingface dataset:
N = int(input())
list = [int(i) for i in input().split()]
score == 0
for i in range(N):
    if list[i] != i+1:
        score += 1
if score == 0 or 2:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

N = int(input())
l = list(map(int, input().split()))
score = 0
for i in range(N):
  if not l[i] == i+1:
    score += 1
if score  ==0 or score ==2:
  print("YES")
else:
  print("NO")
a, b = map(int, input().split())
print((a+b)/2)

### FIXED CODE ###

R = int(input())
G = int(input())
print(2*G-R)
# メモ
# 連結無効グラフ　＝　全部が繋がっている

# N = int(input())
# D = list(map(int, input()))

N = int(input())
D = list(map(int, input().split()))

JOSU = 998244353

anser = 0

deep = [-1] * (N + 1)
deep[0] = 0
memo = [0] * N

# 各深さの数を求める
for i in range(N):
    if deep[D[i]] == -1:
        deep[D[i]] = 0
    deep[D[i]] += 1

def dfs(n, end, sum):
    if n == end:
        return sum
    elif deep[n + 1] == -1:
        return dfs(n + 1, end, sum)
    else:
        return dfs(n + 1, end, sum * deep[n] ** deep[n + 1])

print(dfs(0, N, 1) % JOSU)

### FIXED CODE ###

# 再帰関数の最大再帰回数を変更
import sys
sys.setrecursionlimit(1000000)

# 再帰関数で作る木の個数を返す
def dfs(now, end, summary):
    # 終了条件
    if now == end:
        return summary
    # 1つ前の頂点時点で作ることのできる木の個数 *（１つ前の深さの頂点の数 ^ 現在の深さの頂点の数）で再帰関数
    else:
        return dfs(now + 1, end, summary * (deep[now - 1] ** deep[now]))

# 最後に割る数の定数
JOSU = 998244353

# 入力
N = int(input())
D = list(map(int, input().split()))

# 深さをメモするため、Dの最大値 + 1の数の配列を用意
# 例：深さの最大が2なら、0, 1, 2の3つが必要
deep = [0] * (max(D) + 1)

# 各深さの頂点の数を記録
for i in range(N):

    # 頂点1が深さ0以外なら制約違反
    if i == 0 and D[i] != 0:
        print(0)
        exit()
    # 頂点1以外が深さ0なら制約違反
    elif i > 0 and D[i] == 0:
        print(0)
        exit()

    deep[D[i]] += 1

# 再帰関数で計算
print(dfs(1, len(deep), 1) % JOSU)
a,b,c = list(map(int, input().split()))
print(max(0, c-(a-b))

### FIXED CODE ###

a,b,c = list(map(int, input().split()))
print(max(0, c-(a-b)))
n = int(input());
ans = 1;
for i in range(n):
    a = int(input())
    ans*=a
if ans>=1000000000000000001:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

n = int(input());
ans = 1;
lis = list(map(int,input().split()))
flag = False
flag2 = False
for i in range(n):
    if lis[i]==0:
        flag = True
    if ans*lis[i]>=1000000000000000001:
        flag2 = True
    else:
        ans *= lis[i]

if flag:
    print(0)
elif flag2:
    print(-1)
else:
    print(ans)
num = input()
L = []
house = []
for i in range(int(num)):
    k = input().split()
    k[0] = int(k[0])
    k[1] = int(k[1])
    k[2] = int(k[2])
    k[3] = int(k[3])
    L.append(k)

for i in range(3):
    a = ["","0","0","0","0","0","0","0","0","0","0","0"]
    b = ["","0","0","0","0","0","0","0","0","0","0","0"]
    c = ["","0","0","0","0","0","0","0","0","0","0","0"]
    d = ["#"*20]
    house.append([a,b,c,d])

a = ["","0","0","0","0","0","0","0","0","0","0","0"]
b = ["","0","0","0","0","0","0","0","0","0","0","0"]
c = ["","0","0","0","0","0","0","0","0","0","0","0"]
house.append([a,b,c])

for i in L:
    house[i[0]][i[1]][i[2]] = str(i[3])

for i in house:
    for j in i:
        k = " ".join(j)
        print(k)



### FIXED CODE ###

num = input()
L = []
house = []
for i in range(int(num)):
    k = input().split()
    k[0] = int(k[0])
    k[1] = int(k[1])
    k[2] = int(k[2])
    k[3] = int(k[3])
    L.append(k)

for i in range(3):
    a = ["","0","0","0","0","0","0","0","0","0","0"]
    b = ["","0","0","0","0","0","0","0","0","0","0"]
    c = ["","0","0","0","0","0","0","0","0","0","0"]
    d = ["#"*20]
    house.append([a,b,c,d])

a = ["","0","0","0","0","0","0","0","0","0","0"]
b = ["","0","0","0","0","0","0","0","0","0","0"]
c = ["","0","0","0","0","0","0","0","0","0","0"]
house.append([a,b,c])

for i in L:
    house[i[0]-1][i[1]-1][i[2]] = str(int(house[i[0]-1][i[1]-1][i[2]])+i[3])

for i in house:
    for j in i:
        k = " ".join(j)
        print(k)
A,B,K = map(int, input().split())
List =[]
if A==1 or B==1:
  print("1")
for num in range(1,A):
  if A%num == 0 and B%num == 0:
    List.append(num)
print(List[-K])

### FIXED CODE ###

A,B,K = map(int, input().split())
List =[]
for num in range(1,A+1):
  if A%num == 0 and B%num == 0:
    List.append(num)
print(List[-K])
tmp = int(input())
A = []
for i in range(0,tmp):
    A.append(int(input()))
sum = 0
for i in range(0,tmp):
    sum = sum + 1/A.pop()

print(1/sum)

### FIXED CODE ###

tmp = int(input())
A = [int(i) for i in input().split()]
sum = 0
for i in range(0,tmp):
    sum = sum + 1/A.pop()
print(1/sum)
from dataclasses import dataclass
     
    class BIT:
        '''
        All methods use 0-based index while the implementation use 1-based index
        '''
        def __init__(self, N, val=0):
            self.data = [val] * (N + 1)
            self.N = N
     
        def add_at(self, idx, val):
            i = idx + 1
            while i <= self.N:
                self.data[i] += val
                i += i & (-i)
     
        def sum_to(self, idx):
            res = 0
            i = idx + 1
            while i > 0:
                res += self.data[i]
                i -= i & (-i)
            return res
     
        def sum_in(self, l, r): # [l, r]
            return self.sum_to(r) - self.sum_to(l - 1)
     
     
    @dataclass
    class Query:
        i: int
        l: int
        r: int
     
     
    N, Q = map(int, input().split())
    C = list(map(int, input().split()))
     
    queries = [[] for _ in range(N)]
    for i in range(Q):
        l, r = map(int, input().split())
        l, r = l - 1, r - 1
        queries[r].append(Query(i, l, r))
     
    V = max(C)
    bit = BIT(N)
    last = [-1] * (V + 1)
     
    query_idx = 0
    ans = [-1] * Q
    for i, c in enumerate(C):
        if last[c] != -1:
            bit.add_at(last[c], -1)    
        bit.add_at(i, +1)
        last[c] = i
     
        for q in queries[i]:
            ans[q.i] = bit.sum_in(q.l, q.r)
     
    print('\n'.join(map(str, ans)))

### FIXED CODE ###


class BIT:
    '''
    All methods use 0-based index while the implementation use 1-based index
    '''
    def __init__(self, N, val=0):
        self.data = [val] * (N + 1)
        self.N = N
    
    def add_at(self, idx, val):
        i = idx + 1
        while i <= self.N:
            self.data[i] += val
            i += i & (-i)
    
    def sum_to(self, idx):
        res = 0
        i = idx + 1
        while i > 0:
            res += self.data[i]
            i -= i & (-i)
        return res
    
    def sum_in(self, l, r): # [l, r]
        return self.sum_to(r) - self.sum_to(l - 1)
    
    
class Query:
    def __init__(self, i, l, r):
        self.i = i
        self.l = l
        self.r = r
    
    
N, Q = map(int, input().split())
C = list(map(int, input().split()))
    
queries = [[] for _ in range(N)]
for i in range(Q):
    l, r = map(int, input().split())
    l, r = l - 1, r - 1
    queries[r].append(Query(i, l, r))
    
bit = BIT(N)
last = [-1] * (max(C) + 1)
    
query_idx = 0
ans = [-1] * Q
for i, c in enumerate(C):
    if last[c] != -1:
        bit.add_at(last[c], -1)    
    bit.add_at(i, +1)
    last[c] = i
    
    for q in queries[i]:
        ans[q.i] = bit.sum_in(q.l, q.r)
    
print('\n'.join(map(str, ans)))
a,b = map(int, raw_input().split())

print a/b, a % b, real(a)/real(b)

### FIXED CODE ###

a,b = map(int, raw_input().split())

print("%d %d %f" % (a//b, a % b, a/float(b)))
# ????????????
n,m,l = list(map(int,input().split()))
matrixA,matrixB = [],[]
for i in range(n):
	matrixA.append(list(map(int,input().split())))
for j in range(m):
	matrixB.append(list(map(int,input().split())))

matrix = []
for i in range(l):
	mtr = []
	for j in range(m):
		mtr.append(matrixB[j][i])
	matrix.append(mtr)

matrixC = []
for i in range(l):
	mtr = []
	for j in range(n):
		num_sum = 0
		# print(matrixA[j],matrix[i])
		for a,b in zip(matrixA[j],matrix[i]):
			num_sum += a*b
		mtr.append(num_sum)
	matrixC.append(mtr)

matrix = []
for i in range(l):
	out = ''
	for j in range(n):
		out += str(matrixC[j][i]) + ' '
	print(out[:-1])

### FIXED CODE ###

# ????????????
n,m,l = list(map(int,input().split()))
matrixA,matrixB = [],[]
for i in range(n):
	matrixA.append(list(map(int,input().split())))
for j in range(m):
	matrixB.append(list(map(int,input().split())))

matrix = []
for i in range(l):
	mtr = []
	for j in range(m):
		mtr.append(matrixB[j][i])
	matrix.append(mtr)

matrixC = []
for i in range(l):
	mtr = []
	for j in range(n):
		num_sum = 0
		# print(matrixA[j],matrix[i])
		for a,b in zip(matrixA[j],matrix[i]):
			num_sum += a*b
		mtr.append(num_sum)
	matrixC.append(mtr)

matrix = []
for i in range(n):
	out = ''
	for j in range(l):
		out += str(matrixC[j][i]) + ' '
	print(out[:-1])
a = list(map(int,input().split()))
b=int(input())
for i in b:
  if list[0]>=list[1]:
    list[1]=list[1]*2
  else:
    if list[1]>=list[2]:
      list[2]=list[2]*2
if list[0]<list[1]<list[2]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a = list(map(int,input().split()))
b=int(input())
for i in range(b):
  if a[0]>=a[1]:
    a[1]=a[1]*2
  else:
    if a[1]>=a[2]:
      a[2]=a[2]*2
if a[0]<a[1]<a[2]:
  print("Yes")
else:
  print("No")
N = int(input())
a = list(map(int, input().split()))
b = 1
if 0 in a:
  b = 0
else:
  for i in range(N):
    b = b * a[i]
    if b > 10 ** 18:
      b = 'out'

if b == 'out':
  print(-1)
else:
  print(b)


### FIXED CODE ###

import sys
n = input()
list_num =list(map(int,input().split()))
output = 1
if 0 in list_num:
    print(0)
    sys.exit()
for i in list_num:
    output = output * i
    if output > 10 ** 18:
        print(-1)
        sys.exit()
print(output)
N=int(input())
xy=[list(map(int,input().split()))for _ in range(N)]

count=[]
for x1,y1 in xy:
    for x2,y2 in xy:
        if x1==x2 and y1==y2:
            continue
        c=str(x1-x2)+':'+str(y1-y2)
        count.append(c)

from collections import*
C=Counter(count)
print(N-max(C.values()))

### FIXED CODE ###

N=int(input())
xy=[list(map(int,input().split()))for _ in range(N)]

count=[]
for x1,y1 in xy:
    for x2,y2 in xy:
        if x1==x2 and y1==y2:
            continue
        c=str(x1-x2)+':'+str(y1-y2)
        count.append(c)

from collections import*
C=Counter(count)
C['zentsu999']=0
print(N-max(C.values()))
S = list(map(int ,input().split()))
S.sort()
if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

S = list(map(str ,input()))
S.sort()
if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
  print("Yes")
else:
  print("No")
N = int(input())
A = list(map(int, input().split()))


cnt = 0
for i in range(N - 1):
    if A[i] == A[i + 1]:
        A[i] = '#'
        cnt += 1

for _ in range(cnt):
    A.remove('#')
#print(A)

if A[0] < A[1]:
    plus = 1
else:
    plus = -1

i = 1
ans = 1
while i < len(A) - 1:
    if A[i-1] < A[i] < A[i+1] or A[i-1] > A[i] > A[i+1]:
        pass
    else:
        i += 1
        ans += 1
    i += 1
print(ans)



### FIXED CODE ###

N = int(input())
B = list(map(int, input().split()))

if N == 1:
    print(1)
elif N == 2:
    print(1)
else:
    A = [B[0]]
    cnt = 0
    for i in range(N - 1):
        if B[i] == B[i + 1]:
            pass
        else:
            A.append(B[i+1])

    i = 1
    ans = 1
    n = len(A)
    while i < n - 1:
        if A[i-1] < A[i] < A[i+1] or A[i-1] > A[i] > A[i+1]:
            pass
        else:
            i += 1
            ans += 1
        i += 1
    print(ans)
K = int(input())
A, B = [int(s) for s in input().split()]
 
largest = B // K * K

print("OK" if largest >= a else "NG")

### FIXED CODE ###

K = int(input())
A, B = [int(s) for s in input().split()]
 
largest = B // K * K
 
print("OK" if largest >= A else "NG")
A,B,X = map(int, input().split())

def func(N):
    return (A*N + B*len(str(N)))


def search(start, end):
    median = int((end - start)//2)
    if median == 0:
        if func(end) <= X:
            return end
        elif func(start) <= X:
            return start
        else:
            return 0

    val = func(start+median)
    if val == X:
        return (start+median)
    elif val > X:
        return search(start, start+median)
    elif val < X:
        return search(start+median, end)

result = search(1,10**9)
if result >= 1000000000:
    print(1000000000)
else:
    print(result)

### FIXED CODE ###

S = input()

if S == "SUN":
    print("7")
elif S == "MON":
    print("6")
elif S == "TUE":
    print("5")
elif S == "WED":
    print("4")
elif S == "THU":
    print("3")
elif S == "FRI":
    print("2")
elif S == "SAT":
    print("1")
import math

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

result = a * b / math.gcd(a, b)

print(int(result))



### FIXED CODE ###

import fractions

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

result = a * b / fractions.gcd(a, b)

print(int(result))
N = int(input())
A = [int(x) for x in input().split()]
from collections import defaultdict as dd
Dict = dd(lambda:0)
for a in A:
    Dict[a] += 1
    
if N & 1: Dict[0] += 1
f = (lambda:(lambda x:0 if x&1 else 2) if N&1 else (lambda x:2 if x&1 else 0))()
Possible = {i:f(i) for i in range(N)}
for key,value in Dict.items:
    if value != Possible[key]:
        print(0)
        exit()
else:
    print(2**(N//2)%1000000007)
                



### FIXED CODE ###

N = int(input())
A = [int(x) for x in input().split()]

cnt = {}
if N & 1:
    bit = 1
else:
    bit = 0

for a in A:
    if a & bit:
        ans = 0
        break
    if a in cnt:
        cnt[a] += 1
    else:
        cnt[a] = 1

for key in cnt.keys():
    if key == 0 and cnt[key] != 1:
        ans = 0
        break
    if key != 0 and cnt[key] != 2:
        ans = 0
        break
else:
    ans = 2**(N//2) %1000000007
print(ans)
n,m=[int(i)for i in input()]
list=[int(i) for i in input().split()]
a=n-sum(list)
if a>=0:
  print(a)
else:
  print('-1')

### FIXED CODE ###

n,m=[int(i)for i in input().split()]
list=[int(i) for i in input().split()]
a=n-sum(list)
if a>=0:
  print(a)
else:
  print('-1')
def read_int(): return int(input())
N = read_int()
def read_str(): return input().strip()
S = list(read_str())
 
__DEBUG__ = False
 
def solution():
    count = 0    
    for i in range(N-2):
        if __DEBUG__: print(f"checking {S[i]} at index: {i}")
        if S[i] == 'A':
            if S[i+1] == 'B' and S[i+2] == 'C':
                count += 1
                # continue
    return count
 
    
if __name__ == '__main__':
  	import sys
  	sys.setrecursionlimit(200000)
    print(solution())
    

### FIXED CODE ###

N = int(input())
S = str(input())
 


count = 0    
for i in range(N-2):
  if S[i] == 'A':
    if S[i+1] == 'B' and S[i+2] == 'C':
      count += 1
    
print(count)
n,x,t=map(int,input().split())
u=x
v=t
while(x<n):
  x+=u
  a+=v
print(t)

### FIXED CODE ###

n,x,t=map(int,input().split())
m=t
a=x
while(x<n):
  x+=a
  t+=m
print(t)
N = int(input())
L = [int(n) for n in input().split()]
maxL = max(L)
if maxL < sum(L) - maxL
	print("yes")
else:
	print("no")

### FIXED CODE ###

N=int(input())
l=list(map(int,input().split()))
max=max(l)
if max<sum(l)-max:
 print("Yes")
else:
 print("No")
def main():
  N = input()
  A = [int(x) for x in input().split()]
  
  B = [0] * N
  for i in range(N):
    B[A[N-i-1]] += 1
  
  for i in range(N):
    print(B[i])
    
if __name__ == '__main__':
  main()

### FIXED CODE ###

def main():
  N = int(input())
  A = [int(x) for x in input().split()]
  
  B = [0] * N    
  for i in range(N-1):
      B[A[N-i-2]-1] += 1
  
  for i in range(N):
    print(B[i])
    
if __name__ == '__main__':
  main()
a=[int(i) for i in input().split(" ")]
kouho=[1,9,7,4]
for k in a:
	if k in kouho:
        kouho.pop(k)
if kouho==[]:
    print("YES")
else:
    print("NO")


### FIXED CODE ###

a=[int(i) for i in input().split(" ")]
kouho=set([1,9,7,4])
for k in a:
    if k in kouho:
        kouho.remove(k)
if kouho==set([]):
    print("YES")
else:
    print("NO")
import numpy as np
N = input()
A = np.array(list(map(int, input().split())))
count = 0
while all(a%2==0 for a in A):
    A = A/2
    count+=1
print(count)

### FIXED CODE ###

input()
A=list(map(int,input().split()))
count=0
while all(a%2==0 for a in A):
    A=[a/2 for a in A]
    count+=1
print(count)
N,K = map(int,input().split())
a = list(map(int,input().split()))
A = [0]*(N+1)
S = [0]*(N+1)

for i in range(N):
    A[i+1] = A[i]+max(0,a[i])
    S[i+1] = S[i]+a[i]

ans = -inf
for i in range(0,N-K+1):
    ans = max(ans,A[i]+max(0,S[i+K]-S[i])+(A[N]-A[i+K]))

print(ans)

### FIXED CODE ###

from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

#色を塗るタイプの操作は逆順に見ていけば確定した色が上書きされることは無いと思える
N,K = map(int,input().split())
a = list(map(int,input().split()))
A = [0]*(N+1)
S = [0]*(N+1)

for i in range(N):
    A[i+1] = A[i]+max(0,a[i])
    S[i+1] = S[i]+a[i]

ans = -inf
for i in range(0,N-K+1):
    ans = max(ans,A[i]+max(0,S[i+K]-S[i])+(A[N]-A[i+K]))

print(ans)
n = int(input())
lst = map(str, input().split())
res = 0
def f(l):
  while True:
    for i in l:
      if int(i[-1]) % 2 == 1:
        return res
    l = [str(int(j) / 2) for j in l]
    res += 1
f(lst)

### FIXED CODE ###

lst = [int(i) for i in str(input())]
print(sum(lst))
N, K = map(int, input().split())
A = list(map(int, input().split()))

for _ in range(min(K, 50)):
    lamp = [0 for i in range(N + 1)]
    for i in range(N):
        lamp[max(0, i - A[i])] += 1
        lamp[min(N, i + A[i] + 1)] -= 1

    for i in range(N):
        lamp[i] += lamp[i - 1]
    A = lamp

[print(A[i], end=' ') for i in range(N)]
print()


### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))

for i in range(min(K, 50)):
    B = [0 for i in range(N)]
    for j in range(0, N):
        l = max(0, j - A[j])
        r = min(N - 1, j + A[j])
        B[l] += 1
        if r + 1 < N:
            B[r + 1] -= 1

    for j in range(1, N):
        B[j] += B[j - 1]
        
    A = B

[print(i, end=' ') for i in B]
print()
N = input()
ans = 0
for n in N:
  ans += int(n)
if int(N) % ans == 0:
  print("Yes")
else:s
  print("No")

### FIXED CODE ###

N = int(input())
sn = 0
for s in str(N):
    sn += int(s)
if N % sn == 0:
    print("Yes")
else:
    print("No")
a,b = int(input().strip().split())
p = 500 * a
if p >= b:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a,b = input().strip().split()
a = int(a)
b = int(b)
p = 500 * a
if p >= b:
  print("Yes")
else:
  print("No")
from collections import Counter

H, W, M = map(int, input().split())

h = []
w = []
for _ in range(M):
    x, y = map(int, input().split())
    h.append(x)
    w.append(y)

ch = Counter(h)
cw = Counter(w)

h_max = max(ch.values())
w_max = max(cw.values())

h_idx = [x for (x, y) in ch.items() if y == h_max]
w_idx = [x for (x, y) in cw.items() if y == w_max]

boms = set([(x, y) for x, y in zip(h, w)])

minus = []
for x in h_idx:
    for y in w_idx:
        if (x, y) in boms:
            minus.append(-1)

print(h_max + w_max + max(minus))

### FIXED CODE ###

H, W, M = map(int, input().split())

h = [0] * H
w = [0] * W
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x - 1] += 1
    w[y - 1] += 1
    boms.add((x, y))

h_max = max(h)
w_max = max(w)

h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 for x, y in enumerate(w) if y == w_max]

minus = -1
for x in h_idx:
    for y in w_idx:
        if not (x, y) in boms:
            minus = 0
            break

print(h_max + w_max + minus)
str = input()
for i in range(len(str)):
  str[i] = "x"
print(str)

### FIXED CODE ###

str = input()
ans = ""
for i in range(len(str)):
  ans += "x"
print(ans)
h,w=map(int,input().split())
c=[]
for _ in range(h):
    c.append(list(map(str,input())))
    
ans=[c[i//2] for i in range(2h)]

for j in ans:
    print(''.join(j))

### FIXED CODE ###

h,w=map(int,input().split())
c=[]
for _ in range(h):
    c.append(list(map(str,input())))
    
ans=[c[i//2] for i in range(2*h)]

for j in ans:
    print(''.join(j))
num = [input() for i in range(2)]
k = (num[0] + num[1]) / 2
if k > int(k):
  print(IMPOSSIBLE)
else:
  print(k)

### FIXED CODE ###

num = [int(i) for i in input().split()]
k = (num[0] + num[1]) / 2
if k > int(k):
  print('IMPOSSIBLE')
else:
  print(int(k))
def dfs(i, V, E):
    for k in E[i].keys():
        if V[k] >= 0:
            continue
        if E[i][k] % 2:
            V[k] = 1 - V[i]
        else:
            V[k] = V[i]
        V = dfs(k, V, E)
    return V

n = int(input())
E = {}
for i in range(n - 1):
    ui, vi, wi = map(int, input().split())
    if ui in E.keys():
        E[ui][vi] = wi
    else:
        E[ui] = {vi: wi}
    if vi in E.keys():
        E[vi][ui] = wi
    else:
        E[vi] = {ui: wi}
V = [-1 for _ in range(n + 1)]
V[1] = 0
V = dfs(1, V, E)
for vi in V[1:]:
    print(vi)


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 5 + 1)

def dfs(i, V, E):
    for k in E[i].keys():
        if V[k] >= 0:
            continue
        if E[i][k] % 2:
            V[k] = 1 - V[i]
        else:
            V[k] = V[i]
        V = dfs(k, V, E)
    return V

n = int(input())
E = {}
for i in range(n - 1):
    ui, vi, wi = map(int, input().split())
    if ui in E.keys():
        E[ui][vi] = wi
    else:
        E[ui] = {vi: wi}
    if vi in E.keys():
        E[vi][ui] = wi
    else:
        E[vi] = {ui: wi}
V = [-1 for _ in range(n + 1)]
V[1] = 0
V = dfs(1, V, E)
for vi in V[1:]:
    print(vi)
while True:
    data = int(input())
    if data == 0:
        break
        
    print(sum([int(i) for i in data]))

### FIXED CODE ###

while True:
    data = input()
    if data[0] == '0':
        break

    print(sum([int(i) for i in data]))
import math
a, b, x = map(int, input().split())
if ((a**2) * b) / 2 == x:
    print(45)
elif ((a**2) * b) / 2 < x:
    atan = math.degrees(math.atan((a**3)/(2*b*(a**2) - 2*x)))
    print(90-atan)
else:
    atan = math.degrees(math.atan((2*x)/(a*(b**2))))
    print(90-atan)

### FIXED CODE ###

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

if abs(((a**2) * b) / 2 - x) < 1e-2:
    print(45)
elif ((a**2) * b) == x:
    print(0)
elif ((a**2) * b) / 2 < x:
    atan = math.degrees(math.atan((a**3)/(2*b*(a**2) - 2*x)))
    print(90-atan)
else:
    atan = math.degrees(math.atan((2*x)/(a*(b**2))))
    print(90-atan)
from math import gcd
from collections import Counter
import sys

N = int(input())
K = 10**9
L = 10**18
A = [0] * N
C = Counter()
ans = 0

for i in range(N):
	A[i] = round(K * float(input()))
	C[gcd(A[i],L)] += 1 #辞書型だから[]内のkeyに対応するvalueの値を+1している。ここでは10^9-nの値をCに加えていっている。
	
for k1,v1 in C.items():
	for k2 ,v2 in C.items():
		if k1 == k2:
			if k1*k2 % L == 0:
				ans += v1*(v1-1)/2
		elif k1 < k2:
			if k1*k2 % L == 0:
				ans += v1 * v2

int(print(ans))
			
	
	

### FIXED CODE ###

from math import gcd
from collections import Counter
import sys

N = int(input())
K = 10**9
L = 10**18
A = [0] * N
C = Counter()
ans = 0

for i in range(N):
	A[i] = round(K * float(input()))
	C[gcd(A[i],L)] += 1 
	
for k1,v1 in C.items():
	for k2 ,v2 in C.items():
		if k1 == k2:
			if k1*k2 % L == 0:
				ans += v1*(v1-1)/2
		elif k1 < k2:
			if k1*k2 % L == 0:
				ans += v1 * v2

print(int(ans))
import math
x, y = map(int, input().split())
a = (2 * y - x) / 3
b = (2 * x - y) / 3
ans = 0
if a.is_integer() and b.is_integer():
    m = math.factorial(a + b)
    n = math.factorial(a) * math.factorial(b)
    ans = m // n
    ans %= 10 ** 9 + 7
print(ans)

### FIXED CODE ###

x, y = map(int, input().split())
a = (2 * y - x) / 3
b = (2 * x - y) / 3

def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod

mod = 10 ** 9 + 7
N = 10 ** 6
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

if a.is_integer() and b.is_integer():
    a = int(a)
    c = int(a + b)
    print(cmb(c, a, mod))
else:
    print(0)