Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

b = []
count = []
def sarch(num):
    for i in range(len(b)):
        if num == b[i]:
            return i
    b.append(num)
    count.append(0)
    return len(b) - 1
    
N = input()
a = list(map(int, input().split()))
ans = 0
for i in range(len(a)):
    if a[i] != 0:
        count[sarch(a[i])] += 1
for i in range(len(count)):
    if b[i] > count[i]:
        ans += count[i]
    elif b[i] < count[i]:
        ans += (count[i] - b[i])
print(ans)


### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
a.sort()
i = 1
cnt = 1
key = a[0]
ans = 0
while True:
    if i >= len(a):
        break
    if key == a[i]:
        cnt += 1
    else:
        if key != cnt:
            if cnt > key:
                ans += cnt - key
            else:
                ans += cnt
        cnt = 1
        key = a[i]
    
    i += 1

if key != cnt:
    if cnt > key:
        ans += cnt - key
    else:
        ans += cnt

print(ans)
### BUGGY CODE ###

n=input()
a=map(int,input().split())
m=0
from itertools import*
for i,j in combinations(a,2):
    k=i*j
    m+=k
if m<=1000000007:
    print(m)
else:
    print(m%1000000007)

### FIXED CODE ###

N=int(input())
A=list(map(int, input().split()))
MOD = 10 ** 9 + 7

cumsum = [A[0]]
for i in range(1, N):
    cumsum.append(A[i] + cumsum[i - 1])

ans = 0
for i in range(N):
    ans += (A[i] * (cumsum[-1] - cumsum[i])) % MOD
    ans %= MOD

print(ans)
### BUGGY CODE ###

def main():
    N = int(input())
    A = list(map(int, input().split()))

    counter = 0
    for i in range(N):
        for j in range(i, N):
            if j - i == A[i] + A[j]:
                counter += 1

    print(counter)

if __name__ == '__main__':
    main()


### FIXED CODE ###

def test():
    import numpy as np
    N = 10000
    print(N)
    A = np.random.randint(0, 10, [N])
    print(count(N,A))


def count(N, A):
    #i < j
    #A[i] + A[j] == j - i
    #A[i] + i == j - A[j]
    left = dict()
    right = dict()
    for i in range(N):
        l = i+1 + A[i]
        r = i+1 - A[i]
        left[l] = left.get(l, 0) + 1
        right[r] = right.get(r, 0) + 1

    counter = 0
    for k, v in left.items():
        if k in right:
            counter += right[k] * v

    return counter

def main():
    #test()
    N = int(input())
    A = list(map(int, input().split()))

    result = count(N,A)
    print(result)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

from fractions import gcd

MOD = 10 ** 9 + 7

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

tmp = 1
for a in A:
    tmp *= a // gcd(tmp, a)

ans = 0
for a in A:
    ans += (tmp // a) % MOD
    ans %= MOD

print (ans)


### FIXED CODE ###

def main():
    from fractions import gcd

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

    MOD = 10 ** 9 + 7

    tmp = 1
    for a in A:
        tmp *= a // gcd(tmp, a)

    ans = 0
    for a in A:
        ans += tmp // a
    ans %= MOD

    print (ans)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

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

ans = 1
for i in range(N):
    ans *= A[i]
if ans > 10**18:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

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

if A[0] == 0:
    print(0)
    exit()
else:
    ans = 1
    for i in range(N):
        ans *= A[i]
        if ans > 10**18:
            print(-1)
            exit()
    print(ans)
### BUGGY CODE ###

from itertools import permutations

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

edges=[[10**9 for i in range(n+1)] for i in range(n+1)]

for i in range(m):
  a,b,c = map(int,input().split())
  edges[a][b] = c
  edges[b][a] = c


for k in range(1,n+1):
  for i in range(1,n+1):
    for j in range(1,n+1):
      edges[i][j] = min(edges[i][k]+edges[k][j], edges[i][j])
      edges[j][i] = edges[i][j]

# print(edges)

permutations
ans = 10**9
for i in permutations(R):
  tmp = 0
  for j in range(r-1):
    # print("i",i,"j",j)
    tmp += edges[i[j]][i[j+1]]
  ans = min(tmp, ans)

print(ans)

### FIXED CODE ###

from itertools import permutations

n,m,r = map(int,input().split())
R = list(map(int,input().split()))
inf = 10**9

edges=[[inf for i in range(n+1)] for i in range(n+1)]

for i in range(m):
  a,b,c = map(int,input().split())
  edges[a][b] = c
  edges[b][a] = c


for k in range(1,n+1):
  for i in range(1,n):
    for j in range(i,n+1):
      if edges[i][j] > edges[i][k] + edges[k][j]:
        edges[i][j] = edges[i][k]+edges[k][j]
        edges[j][i] = edges[i][j]


ans = inf
for i in permutations(R):
  tmp = 0
  for j in range(r-1):
    tmp += edges[i[j]][i[j+1]]
  ans = min(tmp, ans)

print(ans)
### BUGGY CODE ###

import bisect

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

event = []
for _ in range(N) :
    s, t, x = map(int, input().split())
    event.append([s - x, True, x])
    event.append([t - x, False, x])

D = [int(input()) for _ in range(Q)]

event.sort(key=lambda x: x[0])
constraction = []

ei = 0

for d in D :
    while ei < 2 * N and event[ei][0] <= d :
        if event[ei][1] :
            bisect.insort_left(constraction, event[ei][2])
        else :
            constraction.pop(bisect.bisect_left(constraction, event[ei][2]))
        ei += 1

    if len(constraction) == 0 :
        print(-1)
    else :
        print(min(constraction))

### FIXED CODE ###

import sys, heapq
input = sys.stdin.readline

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

event = []
for _ in range(N) :
    s, t, x = map(int, input().split())
    event.append([s - x, t - x, x])

D = [int(input()) for _ in range(Q)]

event.sort()

closed = []
ei = 0

for d in D :
    while ei < N and event[ei][0] <= d :
        heapq.heappush(closed, (event[ei][2], event[ei][1]))
        ei += 1
    while closed and closed[0][1] <= d :
        heapq.heappop(closed)
    
    if closed :
        print(closed[0][0])
    else :
        print(-1)
### BUGGY CODE ###

s = list(input())
K = int(input())

res = []
charGram = [[''.join(s[i:i + n]) for i in range(len(s) + 1 - n)] for n in range(1,len(s) + 1)]

for i in range(len(charGram)):
    res += charGram[i]

res = sorted(set(res))
print(res[K - 1])


### FIXED CODE ###

s = list(input())
K = int(input())

res = []
charGram = [[''.join(s[i:i + n]) for i in range(len(s) + 1 - n)] for n in range(1,K + 1)]

for i in range(len(charGram)):
    res += charGram[i]

res = sorted(set(res))
print(res[K - 1])
### BUGGY CODE ###

import sys 
from collections import deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
S = list(map(int,readline().split()))
A = sorted(set(S))
q = deque(A)
ans = 0
while q:
  t = q.popleft()
  if t == 1:
    if S.count(1) == 1:
      print(1)
      sys.exit()
    else:
      print(0)
      sys.exit()
  if S.count(t) ==1:
    ans += 1
  count = 0
  for j in range(len(q)):
    if q[j] % t == 0:
      count +=1
      q.remove(q[j])
      q.appendleft(1)
  for i in range(count):
    q.remove(1)
print(ans)

### FIXED CODE ###

import sys 
import numpy as np
from numba import jit
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


@jit(cache=True)
def solve(A):
  count = np.zeros(10**6+10)
  for x in A:
    if count[x] > 1:
      continue
    count[::x] += 1
  ans = 0
  for x in A:
    ans += count[x] == 1
  return ans

N = int(readline())
A = list(map(int,readline().split()))
A = np.array(A)
print(solve(A))
### BUGGY CODE ###

h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
ch -= 1
cw -= 1
dh -= 1
dw -= 1
maze = [input() for _ in range(h)]
directions = [(-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2),
              (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2),
              (0, -2),  (0, -1),           (0, 1),  (0, 2),
              (1, -2),  (1, -1),  (1, 0),  (1, 1),  (1, 2),
              (2, -2),  (2, -1),  (2, 0),  (2, 1),  (2, 2)]

INF = 10 ** 9
mp = [[INF for _ in range(w)] for _ in range(h)]
mp[ch][cw] = 0
q = [(ch, cw)]
for y, x in q:
    for dy, dx in directions:
        ny, nx = y + dy, x + dx
        if (ny < 0 or h <= ny) or (nx < 0 or w <= nx):
            continue
        if maze[ny][nx] == '#':
            continue
        is_teleported = abs(dy) + abs(dx) > 1
        cost = mp[y][x] + is_teleported
        if mp[ny][nx] > cost:
            mp[ny][nx] = cost
            q.append((ny, nx))

if mp[dh][dw] == INF:
    print(-1)
else:
    print(mp[dh][dw])

### FIXED CODE ###

h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
ch -= 1
cw -= 1
dh -= 1
dw -= 1
maze = [input() for _ in range(h)]
walk = [(-1, 0),  (1, 0), (0, -1), (0, 1)]
teleport = [(-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2),
            (-1, -2), (-1, -1),          (-1, 1), (-1, 2),
            (0, -2),                              (0, 2),
            (1, -2),  (1, -1),           (1, 1),  (1, 2),
            (2, -2),  (2, -1),  (2, 0),  (2, 1),  (2, 2)]

INF = 10 ** 9
mp = [[INF for _ in range(w)] for _ in range(h)]
mp[ch][cw] = 0
walkable = [(ch, cw)]
while True:
    for y, x in walkable:
        for dy, dx in walk:
            ny, nx = y + dy, x + dx
            if (ny < 0 or h <= ny) or (nx < 0 or w <= nx):
                continue
            if maze[ny][nx] == '#':
                continue
            if mp[ny][nx] != INF:
                continue
            mp[ny][nx] = mp[y][x]
            walkable.append((ny, nx))

    teleportable = []
    for y, x in walkable:
        for dy, dx in teleport:
            ny, nx = y + dy, x + dx
            if (ny < 0 or h <= ny) or (nx < 0 or w <= nx):
                continue
            if maze[ny][nx] == '#':
                continue
            if mp[ny][nx] != INF:
                continue
            mp[ny][nx] = mp[y][x] + 1
            teleportable.append((ny, nx))

    if mp[dh][dw] != INF:
        print(mp[dh][dw])
        break
    if teleportable == []:
        print(-1)
        break
    walkable = teleportable
### BUGGY CODE ###

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

a.append(0)
a.insert(0, 0)

for i in range(1, n+1):
    total = 0
    for j in range(1, n+2):
        if j == i + 1:
            total += abs(a[j] - a[j-2])
        elif j != i:
            total += abs(a[j] - a[j-1])
    print(total)

### FIXED CODE ###

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

a.insert(0, 0)
a.append(0)

total_tmp = 0
for i in range(1, n+2):
    total_tmp += abs(a[i] - a[i-1])

for i in range(1, n+1):
    # delete the i-th spot
    total = total_tmp - abs(a[i] - a[i-1]) - abs(a[i+1] - a[i]) + abs(a[i+1] - a[i-1])
    print(total)
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()
question = []
for i in range(Q):
  question.append(list(map(int, input().split())))

# Sの中で、ACという部分文字列が含まれるときの（Aの）index
index = []
for i in range(N-1):
  if S[i]+S[i+1] == "AC":
    index.append(i)

for i, q in enumerate(question):
  ans = 0
  for j in range(len(index)):
    if index[j] >= q[0]-1 and index[j]+1 <= q[1]-1:
      ans +=1
  print(ans)
    



### FIXED CODE ###

import bisect

N, Q = map(int, input().split())
S = input()
question = []
for i in range(Q):
  question.append(list(map(int, input().split())))

# Sの中で、ACという部分文字列が含まれるときの（Aの）index
index = []
for i in range(N-1):
  if S[i]+S[i+1] == "AC":
    index.append(i)

# i番目の文字以降に存在するACという部分文字列の数
sum_index = [0]*N
sum_ac = 0
for i in range(N-1):
  if S[N-(i+2)]+S[N-(i+1)] == "AC":
    sum_ac += 1
  sum_index[N-(i+2)] = sum_ac

for i, q in enumerate(question):
  ans = sum_index[q[0]-1] - sum_index[q[1]-1]
  print(ans)
### BUGGY CODE ###

totalNumbers=int(input())
array=map(int,input().split())
current=1
for number in array:
  current*=number
print(-1 if current>10**18 else current)

### FIXED CODE ###

totalNumbers = int(input())
array = list(map(int, input().split()))
answer = 1
if 0 in array:
    print(0)
else:
    for number in array:
        answer*=number
        if answer>10**18:
            answer=-1
            break
    print(answer)
### BUGGY CODE ###

N = int(input())
As = map(int, input().split())
result = 1
 
for a in As:
  result *= a
  
if 0 in As:
  print(0)
elif result > 10**18:
  print(-1)
else:
  print(result)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
result = 1
 
if 0 in A:
  print(0)
  exit()

for a in A:
  result *= a
  if result > 10**18:
    print(-1)
    exit()

print(result)
### BUGGY CODE ###

N, K = map(int, input().split())
H = list(map(int, input().split())) + [0] * K

INF = 10 ** 9
cost = [INF] * (N + 5 + K)
cost[0] = 0
for i in range(0, N):
    for j in range(1, min(K + 1, N - i)):
        cost[i + j] = min(cost[i + j], cost[i] + abs(H[i] - H[i + j]))

# print (cost)
print (cost[N - 1])

### FIXED CODE ###

N, K = map(int, input().split())
H = list(map(int, input().split())) + [0] * K

INF = 10 ** 9
cost = [INF] * (N + 5 + K)
cost[0] = 0
for i in range(0, N):
    for j in range(1, K + 1):
        cost[i + j] = min(cost[i + j], cost[i] + abs(H[i] - H[i + j]))

# print (cost)
print (cost[N - 1])
### BUGGY CODE ###

n = int(input())
ans = 0
ls = []
for _ in range(n):
    s = ''.join(sorted(input()))
    for j in ls:
        if j == s:
            ans +=1
    ls.append(s)
print(ans)

### FIXED CODE ###

n = int(input())
ans = 0
ls = {}
for _ in range(n):
    s = ''.join(sorted(input()))
    if s in ls:
        ans += ls[s]
        ls[s] += 1
    else:
        ls[s] = 1
print(ans)
### BUGGY CODE ###

S = input()
n = len(S)
p = 10**9+7
DP = [[0]*13 for i in range(n+1)]
DP[0][0] = 1
for i in range(1, n+1):
    for j in range(13):
        if S[i-1] == '?':
            DP[i][j] = sum([DP[i-1][(4*(j-k)) % 13] for k in range(10)]) % p
        else:
            k = int(S[i-1])
            DP[i][j] = DP[i-1][(4*(j-k)) % 13]
print(DP[n][5])


### FIXED CODE ###

S = list(input())
S.reverse()
N = len(S)
mod = 10**9+7
dp = [[0 for r in range(13)] for n in range(N+1)]
dp[0][0] = 1
lookup = [[0 for d in range(10)] for n in range(N)]
for n in range(N):
    for d in range(10):
        lookup[n][d] = d*pow(10, n, 13) % 13
for n in range(1, N+1):
    if S[n-1] == '?':
        for d in range(10):
            for r in range(13):
                dp[n][(r+lookup[n-1][d]) % 13] += dp[n-1][r] % mod
    else:
        for r in range(13):
            dp[n][(r+lookup[n-1][int(S[n-1])]) % 13] += dp[n-1][r] % mod
print(dp[-1][5] % mod)
### BUGGY CODE ###

S = input()
Q = int(input())

for q in range(Q):
    T = input()
    if T == '1':
        S = S[::-1]

    else:
        t, f, c = T.split()

        if f == '1':
            S = c + S
        else:
            S = S + c

print(S) 


### FIXED CODE ###

from sys import stdin

S = input()
Q = int(input())

reverse_flg = False

former_list = []
latter_list = []

for q in range(Q):
    T = stdin.readline()[:-1]

    if T == '1':
        if reverse_flg:
            reverse_flg = False
        else:
            reverse_flg = True
    
    else:
        t, f, c = T.split()
        if (f == '1' and reverse_flg == False) or (f == '2' and reverse_flg == True):
            former_list.append(c)
        else:
            latter_list.append(c)


if reverse_flg:
    latter_list = ''.join(reversed(latter_list))
    former_list = ''.join(former_list)
    S = ''.join(list(reversed(S)))
    S = ''.join([latter_list, S, former_list])

else:
    former_list = ''.join(reversed(former_list))
    latter_list = ''.join(latter_list)
    S = ''.join([former_list, S, latter_list])

print(S)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input(). split()))
prod = 1
for a in A:
    if a is 0:
        prod = 0
    prod *= a
    if prod > 1000000000000000000:
        prod = -1
print(prod)

### FIXED CODE ###

def main():
    n = int(input())
    A = [int(x) for x in input().split()]
    if 0 in A:
        print(0)
        return

    mul = 1
    for a in A:
        mul *= a

        if mul > 1e18:
            print(-1)
            return

    print(mul)


main()
### BUGGY CODE ###

import sys

N, K = map(int, sys.stdin.readline().split())
A = list(map(int, sys.stdin.readline().split()))

dp = [None] * N
for n in range(N):
    if n == 0:
        min_num = 0
    else:
        l = min(n, K)
        min_num = 10 ** 10
        for k in range(1, l + 1):
            min_num = min(abs(A[n] - A[n - k]) + dp[n - k], min_num)
    dp[n] = min_num

print(dp[-1])


### FIXED CODE ###

import sys

N, K = map(int, sys.stdin.readline().split())
A = list(map(int, sys.stdin.readline().split()))

dp = [0] + [None] * (N - 1)
for n, a in enumerate(A):
    if n:
        l = max(0, n - K)
        dp[n] = min(abs(a - a2) + d for a2, d in zip(A[l : n], dp[l : n]))

print(dp[-1])
### BUGGY CODE ###

import sys
from collections import defaultdict
input = sys.stdin.readline
mod = 998244353
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2] != 1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return ( m + x%m ) % m
def main():
    n,s = map(int,input().split())
    a = list(map(int, input().split()))
    dp = [[0 for _ in range(s+1)] for _ in range(n+1)]
    dp[0][0] = pow(2,n,mod)
    MODINV2 = mod_inv(2,mod)
    for i in range(n):
        for j in range(s,-1,-1):
            if j-a[i] < 0:
                continue
            dp[i+1][j] += dp[i][j-a[i]]*MODINV2
            dp[i+1][j] %= mod
        for j in range(s,-1,-1):
            dp[i+1][j] += dp[i][j]
            dp[i+1][j] %= mod
    print(dp[n][s]%mod)
if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
from collections import defaultdict
input = sys.stdin.readline
mod = 998244353
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2] != 1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return ( m + x%m ) % m
def main():
    n,s = map(int,input().split())
    a = list(map(int, input().split()))
    dp = [[0 for _ in range(s+1)] for _ in range(n+1)]
    dp[0][0] = pow(2,n,mod)
    MODINV2 = mod_inv(2,mod)
    ans = 0
    for i in range(n):
        for j in range(s,-1,-1):
            if j-a[i] < 0:
                continue
            dp[i+1][j] += dp[i][j-a[i]]*MODINV2
            dp[i+1][j] %= mod
        for j in range(s,-1,-1):
            if j == s:
                ans += dp[i+1][j]
                ans %= mod
            else:
                dp[i+1][j] += dp[i][j]
                dp[i+1][j] %= mod
    print(ans)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 9)

n, m, k = map(int, input().split())
ab = [[] for i in range(n)]

for i in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  ab[a].append(b)
  ab[b].append(a)

block = [[] for i in range(n)]
for i in range(k):
  c, d = map(int, input().split())
  c -= 1
  d -= 1
  block[c].append(d)
  block[d].append(c)

ans = [0 for i in range(n)]

def dfs(s):
  vis[s] = True
  ary.append(s)
  for i in ab[s]:
    if vis[i] == False:
      dfs(i)

for i in range(n):
  vis = [False for i in range(n)]
  vis[i] = True
  x = ab[i]
  for j in x:
    vis[j] = True
  c = 0
  for j in x:
    ary = []
    dfs(j)
    ary.pop(0)
    blo = set(block[i])
    cnt = set(ary) - blo
    c += len(cnt)
  ans[i] = c
print (*ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 9)

n, m, k = map(int, input().split())
ab = [[] for i in range(n)]

for i in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  ab[a].append(b)
  ab[b].append(a)

block = [set() for i in range(n)]
for i in range(k):
  c, d = map(int, input().split())
  c -= 1
  d -= 1
  block[c].add(d)
  block[d].add(c)

ans = [0 for i in range(n)]

def dfs(s):
  if vis[s] == False:
    vis[s] = True
    r[cnt].add(s)
    for i in ab[s]:
      dfs(i)

vis = [False for i in range(n)]
r = []
cnt = 0
for i in range(n):
  if vis[i] == False:
    r.append(set())
    dfs(i)
    cnt += 1

ans = [0 for i in range(n)]
for i in r:
  l = len(i)
  for j in i:
    ans[j] = l - len(ab[j]) - len(i&block[j]) - 1

print (*ans)
### BUGGY CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,m = LI()
    a = [LI() for _ in range(m)]
    e = [[] for _ in range(n)]
    for l,r,d in a:
        e[l-1].append((r-1,d))
        e[r-1].append((l-1,-d))

    b = [False] * n
    def g(i,c):
        if b[i] != False:
            return b[i] == c
        if c == False:
            c = 0
        b[i] = c
        for r,d in e[i]:
            if not g(r,c+d):
                return False
        return True

    for i in range(n):
        if b[i] != False:
            continue
        if not g(i,False):
            return 'No'
    return 'Yes'


print(main())





### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,m = LI()
    e = [[] for _ in range(n)]
    if m > 0:
        for _ in range(m):
            l,r,d = LI()
            e[l-1].append((r-1,d))
            e[r-1].append((l-1,-d))

    b = [None] * n

    for i in range(n):
        if not b[i] is None:
            continue
        b[i] = 0
        q = [i]
        qi = 0
        nq = []
        while True:
            if len(q) == qi:
                if not nq:
                    break
                q = nq
                qi = 0
                nq = []
            j = q[qi]
            qi += 1
            c = b[j]
            for r,d in e[j]:
                if b[r] is None:
                    b[r] = c+d
                    nq.append(r)
                else:
                    if b[r] != c+d:
                        return 'No'

    return 'Yes'


print(main())
### BUGGY CODE ###

from sys import stdin
N = int(input())
A = list(map(int, stdin.readline().split()))

for i in range(1, N+1):
    print(A.count(i))




### FIXED CODE ###

from sys import stdin
import collections

def main():
    readline = stdin.readline
    N = int(input())
    A = list(map(int, readline().split()))
    listN = list(range(1, N+1))    
    c = collections.Counter(A)
    
    for i in listN:
        print(c[i])
main()
### BUGGY CODE ###

n = int(input())
T = []
for _ in range(n-1):
    T += [list(map(int, input().split()))]
P = [0]+[-1]*(n-1)
while T:
    T_sub = []
    for t in T:
        u, v, w = t
        pu, pv = P[u-1], P[v-1]
        if (pu < 0) & (pv < 0):
            T_sub += [t]
        elif (pu >= 0) & (pv < 0):
            P[v-1] = (pu+(w%2))%2
        else:
            P[u-1] = (pv+(w%2))%2
    T = T_sub
for p in P: print(p)

### FIXED CODE ###

n = int(input())
L = [[] for _ in range(n+1)]
R = [[] for _ in range(n+1)]
for _ in range(n-1):
    u, v, w = map(int, input().split())
    w %= 2
    L[u] += [[u, v, w]]
    R[v] += [[v, u, w]]
P = [[] for _ in range(2*n+2)]
P[1] += (L[1]+R[1])
L[1] = R[1] = []
for i in range(1, 2*n):
    for _, v, w in P[i]:
        P[i+2-w] += (L[v]+R[v])
        L[v] = R[v] = []
A = []
for p in P[1::2]: A += p
B = set([u for u, *_ in A])
for i in range(1, n+1): print(1 if i in B else 0)