Harryxun/stf_run huggingface dataset:
from collections import Counter

n = int(input())
v = list(map(int, input().split()))

if len(set(v)) == 1:
    print(n//2)
else:
    c1 = Counter(v[0::2])
    c2 = Counter(v[1::2])
    
    c1m = c1.most_common(1)[0]
    c2m = c2.most_common(1)[0]
    
    ans1 = n//2-c2m[1]
    if c1m[0] != c2m[0]:
        ans1 += n//2-c1m[1]
    else:
        ans1 += n//2-c1.most_common(2)[1][1]
    
    ans2 += n//2-c1m[1]
    if c1m[0] != c2m[0]:
        ans2 += n//2-c2m[1]
    else:
        ans2 += n//2-c2.most_common(2)[1][1]
    print(min(ans1, ans2))

### FIXED CODE ###

from collections import Counter

n = int(input())
v = list(map(int, input().split()))

if len(set(v)) == 1:
    print(n//2)
else:
    c1 = Counter(v[0::2])
    c2 = Counter(v[1::2])
    
    c1m = c1.most_common(2)
    c2m = c2.most_common(2)
    
    if c1m[0][0] != c2m[0][0]:
        print(n-c1m[0][1]-c2m[0][1])
    else:
        mn = n
        if len(set(c1)) > 1:
            mn = min(mn, n-c1m[1][1]-c2m[0][1])
        if len(set(c2)) > 1:
            mn = min(mn, n-c1m[0][1]-c2m[1][1])
            
        print(mn)
import math
N = int(input())
a = 1
b = 1
ran = math.floor(math.sqrt(N))
max = 0
for i in range(ran):
    if N%i == 0:
        if i > max:
            max = i
print(i + N/i -2)

### FIXED CODE ###

n = int(input())
s = int(n ** 0.5)
i = 0
while True:
    if n%(s + i) == 0:
        k = 1
        break
    if n%(s - i) == 0:
        k = -1
        break
    i += 1
s = s + i * k 
print((s + n // s) - 2)
S = int(input())
list=[]
for i in range(N):
    list.append(str(input()))
print(len(set(list)))

### FIXED CODE ###

N=int(input())
list=[int(input()) for i in range(N)]
print(len(set(list)))
def is_reachable(src, dst):
    can_go = True
    dt = dst[0] - src[0]
    dist = abs(dst[1] - src[1]) + abs(dst[2] - src[2])
    if dt < dist:
        can_go = False
    if dt % 2 != dist % 2:
        can_go = False
    return can_go


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

# print(route)

reachable = True

for i in range(N):
    source = route[i]
    destination = route[i + 1]
    if not is_reachable(source, destination):
        reachable = False

print(reachable)


### FIXED CODE ###

# https://atcoder.jp/contests/abc086/tasks/arc089_a

N = int(input())


def is_reachable(src, dst):
    can_go = True
    dt = dst[0] - src[0]
    dist = abs(dst[1] - src[1]) + abs(dst[2] - src[2])
    if dt < dist:
        can_go = False
    if dt % 2 != dist % 2:
        can_go = False
    return can_go


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

# print(route)

reachable = True

for i in range(N):
    source = route[i]
    destination = route[i + 1]
    if not is_reachable(source, destination):
        reachable = False

if reachable:
    print("Yes")
else:
    print("No")
import sys
input=sys.stdin.readline
import copy
def knapsack(N,W,weight,value):
  dp=[[999999999999 for i in range(W+1)] for j in range(N+1)]
  dp2=[[0 for i in range(W+1)] for j in range(N+1)]
  for i in range(W+1): dp[0][i]=0
 
  for i in range(N):
    for w in range(W+1):
      if weight[i]<=w:
        if dp[i][w-weight[i]]+value[i]>dp[i][w]:
          dp[i+1][w]=dp[i][w-weight[i]]+value[i]
          dp2[i+1][w]=w-weight[i]
        else:
          dp[i+1][w]=dp[i][w]
          dp2[i+1][w]=w
        
      else:
        dp[i+1][w]=dp[i][w]
        dp2[i+1][w]=w
  
  l=[]
  x=W
  for i in range(n-1,-1,-1):
    if dp2[i+1][x]==x-weight[i]:
      l.append(i)
    x=dp2[i+1][x]
  return dp[N][W],l
 
n,t=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
a=[];b=[]
for i in range(n):
  a.append(l[i][0])
  b.append(l[i][1])
z=knapsack(n,t-1,a,b)
L=[0]*n
for i in range(len(z[1])):
  L[z[1][i]]=1
M=[]
for i in range(n):
  if L[i]==0:
    M.append(l[i][1])
print(z[0]+max(M))

### FIXED CODE ###

import sys
input=sys.stdin.readline
import copy
def knapsack(N,W,weight,value):
  dp=[[999999999999 for i in range(W+1)] for j in range(N+1)]
  for i in range(W+1): dp[0][i]=0
 
  for i in range(N):
    for w in range(W+1):
      if weight[i]<=w:
        if dp[i][w-weight[i]]+value[i]>dp[i][w]:
          dp[i+1][w]=dp[i][w-weight[i]]+value[i]
        else:
          dp[i+1][w]=dp[i][w]
      else:
        dp[i+1][w]=dp[i][w]
  return dp
 
n,t=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
l.sort()
a=[];b=[]
for i in range(n):
  a.append(l[i][0])
  b.append(l[i][1])
dp=knapsack(n,t-1,a,b)
ans=[]
for i in range(n):
  if i!=n:
    ans.append(dp[i][t-1]+b[i])
  else:
    ans.append(dp[n][t-i])
print(max(ans))
X = int(input())
Y = int(input())

for i in range(1, 100):
    j = X - i
    ans = i*2 + j * 4

    if ans == Y:
        print("Yes")
        exit(1)

print("No")


### FIXED CODE ###

X, Y = map(int, input().split())
ans = 'No'

for i in range(X+1):
    j = X - i
    if (i * 2 + j * 4) == Y:
        ans = 'Yes'

print(ans)
N = int(input())

planes = {
  'U': [],
  'R': [],
  'D': [],
  'L': []
}

for _ in range(N):
  x, y, t = input().split()
  x, y = int(x), int(y)
  planes[t].append((x, y))
  
BIG = 10**18
  
def time(ps):
  sort(ps)
  ans = BIG
  for i in range(len(ps)-1):
    y1, x1, t1 = ps[i]
    y2, x2, t2 = ps[i+1]
    
    if y1 != y2:
      continue
    
    if t1 == 1 and t2 = -1:
      ans = min(ans, x2 - x1)
  return 5*ans


ud = [(x, y, 1) for x, y in planes['U']] + [(x, y, -1) for x, y in planes['D']]
lr = [(y, x, 1) for x, y in planes['R']] + [(y, x, -1) for x, y in planes['L']]

ur = [(x+y, y-x, 1) for x, y in planes['U']] + [(x+y, y-x, -1) for x, y in planes['R']]
ul = [(x-y, y+x, 1) for x, y in planes['U']] + [(x-y, y+x, -1) for x, y in planes['L']]
rd = [(x-y, y+x, 1) for x, y in planes['R']] + [(x-y, y+x, -1) for x, y in planes['D']]
ld = [(x+y, y-x, 1) for x, y in planes['L']] + [(x+y, y-x, -1) for x, y in planes['D']]

ans = min(time(ud), time(lr), time(ur), time(ul), time(rd), time(ld))
if ans >= BIG:
  print("SAFE")
else:
  print(ans)

  

### FIXED CODE ###

N = int(input())

planes = {
  'U': [],
  'R': [],
  'D': [],
  'L': []
}

for _ in range(N):
  x, y, t = input().split()
  x, y = int(x), int(y)
  planes[t].append((x, y))
  
BIG = 10**18
  
def time(ps):
  ps.sort()
  ans = BIG
  for i in range(len(ps)-1):
    y1, x1, t1 = ps[i]
    y2, x2, t2 = ps[i+1]
    
    if y1 != y2:
      continue
    
    if t1 == 1 and t2 == -1:
      ans = min(ans, x2 - x1)
  return 5*ans


ud = [(x, y, 1) for x, y in planes['U']] + [(x, y, -1) for x, y in planes['D']]
lr = [(y, x, 1) for x, y in planes['R']] + [(y, x, -1) for x, y in planes['L']]

ur = [(x+y, y-x, 1) for x, y in planes['U']] + [(x+y, y-x, -1) for x, y in planes['R']]
ul = [(x-y, y+x, 1) for x, y in planes['U']] + [(x-y, y+x, -1) for x, y in planes['L']]
rd = [(x-y, y+x, 1) for x, y in planes['R']] + [(x-y, y+x, -1) for x, y in planes['D']]
ld = [(x+y, y-x, 1) for x, y in planes['L']] + [(x+y, y-x, -1) for x, y in planes['D']]

ans = min(time(ud), time(lr), time(ur), time(ul), time(rd), time(ld))
if ans >= BIG:
  print("SAFE")
else:
  print(ans)
import numpy as np

N, K, Q = map(int, input().split())

points = np.array([K for _ in range(N)])

for q in range(Q):
    A = int(input()) - 1
    points -= 1
    points[A] += 1

for n in range(N):
    if points[n] < 1:
        print('No')
    else:
        print('Yes')


### FIXED CODE ###

S = input()

weather = ['Sunny', 'Cloudy', 'Rainy']

if S == weather[0]:
    print(weather[1])
elif S == weather[1]:
    print(weather[2])
elif S == weather[2]:
    print(weather[0])
h, w = map(int, input().split())
cell = []
for _ in range(h):
    temp = input()
    cell.append(temp[:-1])

dist = [[float('inf') for _ in range(w)] for _ in range(h)]
dist[0][0] = 0
next_move = [[0, 0]]
x = [1, 0, -1, 0]
y = [0, 1, 0, -1]

while len(next_move):
    if next_move[0] == [h-1, w-1]:
        break
    
    for i in range(4):
        nx = next_move[0][1] + x[i]
        ny = next_move[0][0] + y[i]
        if (nx >= 0 and nx < w and ny >= 0 and ny < h and 
            cell[ny][nx] != '#' and dist[ny][nx] == float('inf')):
            dist[ny][nx] = dist[next_move[0][0]][next_move[0][1]] + 1
            next_move.append([ny, nx])
    next_move.pop(0)

cnt = 0
for i in range(h):
    for t in range(w):
        
        if cell[i][t] == '#':
            cnt += 1
            
if dist[h-1][w-1] == float('inf'):
    print(-1)
else:
    print((h*w) - (dist[h-1][w-1] + 1) - cnt)

### FIXED CODE ###

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

dist = [[float('inf') for _ in range(w)] for _ in range(h)]
dist[0][0] = 0
next_move = [[0, 0]]
x = [1, 0, -1, 0]
y = [0, 1, 0, -1]

while len(next_move):
    if next_move[0] == [h-1, w-1]:
        break
    
    for i in range(4):
        nx = next_move[0][1] + x[i]
        ny = next_move[0][0] + y[i]
        if (nx >= 0 and nx < w and ny >= 0 and ny < h and 
            cell[ny][nx] != '#' and dist[ny][nx] == float('inf')):
            dist[ny][nx] = dist[next_move[0][0]][next_move[0][1]] + 1
            next_move.append([ny, nx])
    next_move.pop(0)

cnt = 0
for i in range(h):
    for t in range(w):
        
        if cell[i][t] == '#':
            cnt += 1
            
if dist[h-1][w-1] == float('inf'):
    print(-1)
else:
    print((h*w) - (dist[h-1][w-1] + 1) - cnt)
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)

ans = 0
ans += A[0]
for i in range(1, N - 1):
    ans += A[tmp]
    if i % 2 == 0:
        tmp += 1
print(ans)

### FIXED CODE ###

#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
A = LI()

A.sort(reverse=1)
ans = 0
ans += A[0]

tmp = 1
for i in range(1, N - 1):
    ans += A[tmp]
    if i % 2 == 0:
        tmp += 1
print(ans)
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a, b, c, d = map(int, readline().split())
print(min(a, b) + min(c,d))


### FIXED CODE ###

"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a, b, c, d = map(int, read().split())
print(min(a, b) + min(c,d))
import math

x1,y1 = 0, 0

def fact(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

S = int(input())

list1 = sorted(fact(S))#おおきいのが最後

if int(list1[-1]) <= 10**9:
  b = int(list1[-1])
  x2,y2 = b,0
  x3,y3 = 0,S//b

else:
  list2 = []
  list2.append(int(S//list1[-1]))
  while list1[-1] > 10**9:
    dash = list1[-1]
    list1 = fact(dash + 1)
    list2.append(int((dash+1)//list1[-1]))

  sum1 = 1
  for i in range(len(list2)):
    sum1 = list2[i]*sum1
  sum3 = sum1
  sum2 = 0
  sum4 = 1
  for i in range(len(list2)-1):
    sum4 *= list2[i] 
    sum2 += sum4

  y2 = fact(sum2)[-1]
    
  b = list1[-1]
  x2 = b
  x3 = sum2//y2
  y3 = (S + x3*y2)//b
  s = x2*y3 - x3*y2
  
print(int(x1),int(y1),int(x2),int(y2),int(x3),int(y3))

### FIXED CODE ###

S = int(input())

if S == 10**18:
  x1,y1 = 0,0
  x2 = 10**9
  y3 = 10**9
  x3 = 0
  y2 = 0

else:
  x1, y1 = 0,0

#|x2y3-x3y2|=S

  x2 = 10**9
  y2 = 1

#|10**9y3-x3|= s

  y3 = (S//(10**9)) + 1
  x3 = (10**9)*y3 - S

print(int(x1),int(y1),int(x2),int(y2),int(x3),int(y3))
import sys
input = sys.stdin.readline
import numpy as np

n,m = (int(x) for x in input().split())
a = list(map(int, input().split()))

b = [0]*m
tmp = 0

for i in range(n):
	for j in range(n):
		if b[tmp] < a[i]+a[j]:
			b[tmp] = a[i]+a[j]
			tmp = b.index(min(b))

print(sum(b))

### FIXED CODE ###

import sys
input = sys.stdin.readline
# 昇順ソートされた配列の挿入位置indexを返す O(logN)
from bisect import bisect_left

def isOver(a,n,x):
	cnt = 0
	for i in range(n):
		cnt += n-bisect_left(a,x-a[i])
	return cnt

def calX(a,n,m,l,r):
	while r-l>1:
		# x: 握手で得たい最低パワー値
		x = (l+r)//2
		if isOver(a,n,x) >= m:
			l = x
		else: #握手する限界回数すら満たせないほど大きいxなら
			r = x 
	return l

n,m = map(int, input().split())
a = list(map(int, input().split()))

#累積和の下準備
a.sort()
s = [0]*(n+1)
for i in range(n):
	s[i+1] = s[i]+a[i]

x = calX(a,n,m,a[0]*2,a[n-1]*2)

out = 0
for i in range(n):
	idx = bisect_left(a,x-a[i])
	out += s[n]-s[idx]+a[i]*(n-idx)

out -= (isOver(a,n,x)-m)*x

print(out)
# Python 3+
import sys
import math

#file = open("test.txt")
file = sys.stdin

r = int(file.readline())
l = 2*math.pi*r
s = math.pi*r*r

print("%.6f %.6f"%(s, l))

### FIXED CODE ###

# Python 3+
import sys
import math

#file = open("test.txt")
file = sys.stdin

r = float(file.readline())
l = 2*math.pi*r
s = math.pi*r*r

print("{0:.6f} {1:.6f}".format(s, l))
x,a = map(int, input().split())

if x < a:
  print(0)
elif x => a:
  print(10)

### FIXED CODE ###

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

if x < a:
  print(0)
elif x >= a:
  print(10)
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)



def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())

directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact



def serch(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count


def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X % n)
    return str(X % n)

N,K=acinput()
s=Base_10_to_n(N,K)
print(len(s))


### FIXED CODE ###


import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)



def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())

directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact



def serch(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count


def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X % n)
    return str(X % n)

N,K=acinput()
s=Base_10_to_n(N,K)
print(len(s))
a = input()
b = input()
c = input()
first_str = a[0]
a = a[1:]
while(1):
  if first_str == 'a':
    first_str = a[0]
    a = a[1:]
    if len(a)==0:
      print('A')
      break
  elif first_str == 'b':
    first_str = b[0]
    b = b[1:]
    if len(b)==0:
      print('B')
      break
  elif first_str == 'c':
    first_str = c[0]
    c = c[1:]
    if len(c)==0:
      print('C')
      break
  
    

### FIXED CODE ###

a = input()
b = input()
c = input()
first_str = a[0]
a = a[1:]
while(1):
  if first_str == 'a':
    if len(a)==0:
      print('A')
      break
    first_str = a[0]
    a = a[1:]
    
  elif first_str == 'b':
    if len(b)==0:
      print('B')
      break
    first_str = b[0]
    b = b[1:]
    
  elif first_str == 'c':
    if len(c)==0:
      print('C')
      break
    first_str = c[0]
    c = c[1:]
n,m=map(int,input().split())
X=list(map(int,input().split()))

if m==1 :
    print(0)
    exit()

X.sort()
D=[]
for i in range(1,m):
    D.append(X[i]-X[i-1])

D.sort(reverse=True)
d=0
if i>1:
    for i in range(n-1):
        d += D[i]    

ans = sum(D)-d
print(ans)


### FIXED CODE ###

n,m=map(int,input().split())
X=list(map(int,input().split()))

if m==1 :
    print(0)
    exit()

X.sort()
D=[]
for i in range(1,m):
    D.append(X[i]-X[i-1])

D.sort(reverse=True)
d=0
if i>1:
    for i in range(min(n-1,m-1)):
        d += D[i]    

ans = sum(D)-d
print(ans)
n = int(input())
arr = []
for i in range(n-1):
    arr.append([int(s) for s in input().split(" ")])


status = [-1 for i in range(n)]
status2 = [-1 for i in range(n)]
childNodeNums = [0 for i in range(n)]


def prepare(n, arr):
    data = [[] for i in range(n)]
    lens =  [0 for i in range(n)]
    for ar in arr:
        data[ar[0] - 1].append(ar[1] - 1)
        lens[ar[0]-1] += 1
        data[ar[1] - 1].append(ar[0] - 1)
        lens[ar[1]-1] += 1
    return data,lens


def dfs(currentNode, arr):
    status[currentNode] = 1
    childNodes = arr[i]

    for j in childNodes:
        if status[j] == -1:
            childNodeNums[currentNode] += 1
            dfs(j, arr)


def dfs2(currentNode, arr, x):
    status2[currentNode] = 1
    childNodes = arr[currentNode]
    kk = 0
    for index,val in enumerate(childNodes):
        if status2[val] == -1:
            kk = kk + 1
            if kk == x:
                kk = kk + 1
            print(kk)

    kk2 = 0
    for index,val in enumerate(childNodes):
        if status2[val] == -1:
            kk2 = kk2 + 1
            if kk2 == x:
                kk2 = kk2 + 1
            dfs2(val,arr,kk2)


data,lens = prepare(n, arr)
dfs(0, data)
lastIndex = childNodeNums.index(max(childNodeNums))
print(max(lens))
dfs2(lastIndex,data,-1)


### FIXED CODE ###

from sys import setrecursionlimit


def genid(a, b):
    if b < a:
        a, b = b, a
    return a * 100000 + b


def paint(currentNode, usedColor, parentNode, edges, colors):
    color = 1
    for childNode in edges[currentNode]:
        if childNode == parentNode:
            continue
        if color == usedColor:
            color += 1
        colors[genid(currentNode, childNode)] = color
        paint(childNode, color, currentNode, edges, colors)
        color += 1


setrecursionlimit(100000)

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

edges = [[] for _ in range(N)]
for a, b in ab:
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)

colors = {}
paint(0, -1, -1, edges, colors)

print(max(len(e) for e in edges))
for a, b in ab:
    print(colors[genid(a - 1, b - 1)])
a,b = map(int,input().split())
c = list(map(int,input(),split()))
dp = [float("inf") for i in range(n+2)]

for i in range(n+1):
    for j in c:
        if i + j <= n:
            dp[i+j] = min(dp[i+j],dp[i] + 1)
            
print(dp[a])
            
        


### FIXED CODE ###

a,b = map(int,input().split())
c = list(map(int,input().split()))
dp = [float("inf") for i in range(a+2)]
dp[0]=0
for i in range(a+1):
    for j in c:
        if i + j <= a:
            dp[i+j] = min(dp[i+j],dp[i] + 1)
            
print(dp[a])
N = int(input())
a = [[] for _ in range(N)]
b = [[] for _ in range(N)]
for i in range(N-1):
    x, y, z = map(int, input().split())
    x, y, z = x-1, y-1, z % 2
    a[x].append([y, z])
    b[y].append([x, z])
dist = [0] * N
visited = [0] * N
print("")

def dfs(v, prev, dist, predist, visited):
    if visited[v]:
        return dist
    dist[v] = dist[prev] ^ predist
    visited[v] = 1
    for i in a[v]:
        dist = dfs(i[0], v, dist, i[1], visited)
    for i in b[v]:
        dist = dfs(i[0], v, dist, i[1], visited)
    return dist

dist = dfs(0, 0, dist, 0, visited)
for i in dist:
    print(i)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
N = int(input())
a = [[] for _ in range(N)]
b = [[] for _ in range(N)]
for i in range(N-1):
    x, y, z = map(int, input().split())
    x, y, z = x-1, y-1, z % 2
    a[x].append([y, z])
    b[y].append([x, z])
dist = [0] * N
visited = [0] * N
print("")

def dfs(v, prev, dist, predist, visited):
    if visited[v]:
        return dist
    dist[v] = dist[prev] ^ predist
    visited[v] = 1
    for i in a[v]:
        dist = dfs(i[0], v, dist, i[1], visited)
    for i in b[v]:
        dist = dfs(i[0], v, dist, i[1], visited)
    return dist

dist = dfs(0, 0, dist, 0, visited)
for i in dist:
    print(i)
import math
a,b,c=map(int,input().split())
print('YES' if c%math.gcd(a,b)==0 else 'NO')

### FIXED CODE ###

import fractions as f
a,b,c=map(int,input().split())
print('YES' if c%(f.gcd(a,b))==0 else 'NO')
S = input().split(",")
topping = S.count("o")
print(700+topping＊１００)

### FIXED CODE ###

S = input()
topping = S.count("o")
ans = 700 + topping*100
print(ans)
import math
N, K = map(int,input())
A = list(map(int,input().split()))
print(math.ceil(N/(K-1)))

### FIXED CODE ###

import math
N, K = map(int,input().split())
A = list(map(int,input().split()))
print(math.ceil((N-1)/(K-1)))
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

s=int(input())
a=s//100
b=s%100
if (a==0 or a>12) and (b==0 or b>12):
    print("Na")
elif (a==0 or a>12):
    print("YYMM")
elif (b==0 or b>12):
    p12rint("MMYY")
else:
    print("AMBIGUOUS")

### FIXED CODE ###

import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

s=int(input())
a=s//100
b=s%100
if 0<a<13:
    if 0<b<13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 0<b<13:
        print("YYMM")
    else:
        print("NA")
if (500 * K) > X:
  print("Yes")]
else:
  print("No")

### FIXED CODE ###

K,X=map(int,input().split())
if 500*K >= X:
  print("Yes")
else:
  print("No")
a,b = map(int,input().split())
c = b % a
if (b > 1) && (b < a):
    print(1)
elif b == 1:
    print(0)
else:
    print(c + 1)

### FIXED CODE ###

a,b = map(int,input().split())
sum = 1
if ((b > 1) and (b < a)):
    print(1)
elif b == 1:
    print(0)
else:
    b = b - a
    while 0 < b:
        b = b - (a-1)
        sum=sum+1
    print(sum)
n=int(input())
lst=list(map(int,input().split()))
for i in range(n):
  if lst[i]%2==0:
    if lst[i]%3==0 or lst[i]%5==0:
      result=1
  if result==1:
    print("APPROVED")
  else:
    print("DENIED")

### FIXED CODE ###

n=int(input())
check=list(map(int,input().split()))
f=0
for i in range(n):
    if check[i]%2==0:
        if check[i]%3!=0 and check[i]%5!=0:
            f=1
                
if f==1:
    print("DENIED")
else:
    print("APPROVED")
s = input()

s = set(s)

if s.len() == 3:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

s = input()

s = set(s)

if len(s) == 3:
  print("Yes")
else:
  print("No")
a = input()
return a**3


### FIXED CODE ###

x = int(input())
print(x**3)
from math import gcd
from functools import reduce


def gcd_expand(values):
    return reduce(gcd, values)


N, X = map(int, input().split())
x = map(int, input().split())

x_abs = [abs(X - i) for i in x]
print(gcd_expand(x_abs))

### FIXED CODE ###

from fractions import gcd
from functools import reduce


def gcd_expand(values):
    return reduce(gcd, values)


N, X = map(int, input().split())
x = map(int, input().split())

x_abs = [abs(X - i) for i in x]
print(gcd_expand(x_abs))