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

import sys
sys.setrecursionlimit(500000)

N, Q = map(int, input().split())
G = [[] for _ in range(N)]
cnt = [0]*N
visited = [0]*N


def dfs(start_node):
    for i in G[start_node]:
        if visited[i]==0:
            visited[i]=1
            cnt[i] += cnt[start_node]
            dfs(i)

for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

for i in range(Q):
    node, x = map(int, input().split())
    node -= 1
    cnt[node] += x

visited[0]=1
dfs(0)

ans = map(str, cnt)
print(' '.join(ans))


### FIXED CODE ###

import sys
sys.setrecursionlimit(500000)

N, Q = map(int, input().split())
G = [set() for _ in range(N)]
cnt = [0]*N
visited = [0]*N

def dfs(start_node):
    for i in G[start_node]:
        if visited[i]==0:
            visited[i]=1
            cnt[i] += cnt[start_node]
            dfs(i)

for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].add(b)
    G[b].add(a)

for i in range(Q):
    node, x = map(int, input().split())
    node -= 1
    cnt[node] += x

visited[0]=1
#dfs(0)
st = [0]
while st:
    v = st.pop()
    for u in G[v]:
        if visited[u]: continue
        visited[u] = 1
        cnt[u] += cnt[v]
        st.append(u)    

ans = map(str, cnt)
print(' '.join(ans))
### BUGGY CODE ###

#!/usr/bin/env python3
def main():
    import sys

    sys.setrecursionlimit(10 ** 5)
    
    def dfs(now: int, glaph: set):
        """nowを現在の頂点として，つながっている頂点をglaphに集合として記録"""
        if seen[now]:
            return glaph
        seen[now] = True
        # print(now, glaph)
        for next in friends[now]:
            glaph.add(now)
            dfs(next, glaph)

    N, M, K = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in [0] * M]
    CD = [tuple(map(int, input().split())) for _ in [0] * K]

    friends = [set() for _ in [0] * (N + 1)]
    for f in AB:
        friends[f[0]].add(f[1])
        friends[f[1]].add(f[0])
    blocks = [set() for _ in [0] * (N + 1)]
    for b in CD:
        blocks[b[0]].add(b[1])
        blocks[b[1]].add(b[0])
    # print(friends)
    # print(blocks)

    friends_chain = []
    seen = [False] * (N + 1)
    for i in range(1, N + 1):
        if not seen[i]:
            glaph = set()
            dfs(i, glaph)
            friends_chain.append(glaph)
    # print(friends_chain)

    ans = [0] * (N + 1)
    for person in range(1, N + 1):
        for chain in friends_chain:
            if person in chain:
                res = set(chain)
                # print(person, res)
                for block in blocks[person]:
                    res.discard(block)
                for friend in friends[person]:
                    res.discard(friend)
                ans[person] = len(res) - 1
                # print(res)
                # print()
    
    for hoge in ans[1:]:
        print(hoge, end=' ')


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
def main():
    from collections import deque

    N, M, K = map(int, input().split())
    friends = [set() for _ in range(N + 1)]
    for _ in range(M):
        a, b = map(int, input().split())
        friends[a].add(b)
        friends[b].add(a)
    blocks = [set() for _ in range(N + 1)]
    for _ in range(K):
        c, d = map(int, input().split())
        blocks[c].add(d)
        blocks[d].add(c)

    friends_chain = []
    seen = [-1] * (N + 1)
    cnt = 0
    for person in range(1, N + 1):
        if seen[person] != -1:
            continue
        q = deque([person])
        friends_chain.append(set(q))
        while q:
            now = q.pop()
            seen[now] = cnt
            for next in friends[now]:
                if seen[next] != -1:
                    continue
                friends_chain[-1].add(next)
                q.append(next)
        cnt += 1

    for person in range(1, N + 1):
        res = friends_chain[seen[person]]
        tmp_ans = len(res) - len(friends[person]) - 1
        for block in blocks[person]:
            tmp_ans -= 1 if block in res else 0
        print(tmp_ans, end=' ')


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

L, R = map(int, input().split())
ans = 10 ** 9 + 7
if (L - R + 1) >= 2019:
    print(0)
else:
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            ans = min(ans, i * j % 2019)
print(ans)

### FIXED CODE ###

L, R = map(int, input().split())
mod = 2019
ans = mod
for l in range(L, L + mod + 2):
    for r in reversed(range(R - mod - 2, R + 1)):
        if l >= r:
            break
        ans = min(ans, (l * r) % mod)
print(ans)
### BUGGY CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
ans = 0
for i in range(N):
    tmp = A[i]
    while tmp > 1:
        ans += 1
        tmp -= 2
    if i < N - 1 and tmp == 1 and A[i + 1] > 0:
        ans += 1
        A[i + 1] -= 1
print(ans)

### FIXED CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
ans = 0
for i in range(N):
    tmp = A[i]
    ans += (tmp // 2)
    if i < N -1 and tmp % 2 and A[i + 1] > 0:
        ans += 1
        A[i + 1] -= 1
print(ans)
### BUGGY CODE ###

N,M=map(int,input().split())
xyz=[]
for i in range(N):
    xyz.append(list(map(int,input().split())))
coefs=[[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1]
       ,[-1,1,1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]]
ans=[]

for ix,iy,iz in coefs:
    xyz_ = [sum([ix*l[0],iy*l[1],iz*l[2]]) for l in xyz]
    dp=[[0]*(M+1) for i in range(N+1)]
    for i in range(N):
        dp[i+1][0] = dp[i][0]
        for j in range(1,M+1):
            dp[i+1][j] = max(dp[i][j-1]+xyz_[i],dp[i][j])
    ans.append(dp[N][M])
print(max(ans))

### FIXED CODE ###

N,M=map(int,input().split())
xyz=[]
for i in range(N):
    xyz.append(list(map(int,input().split())))
coefs=[[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1]
       ,[-1,1,1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]]
ans=[]

for ix,iy,iz in coefs:
    xyz_ = [sum([ix*l[0],iy*l[1],iz*l[2]]) for l in xyz]
    ans.append(sum(sorted(xyz_,reverse=True)[:M]))
print(max(ans))
### BUGGY CODE ###

def main():
    n = int(input())
    x = input()
    base = 0
    b = 1
    for i in range(n):
        base += int(x[-i - 1]) * b
        b *= 2
    for i in range(n):
        d = 1 if x[i] == "0" else -1
        now = base + d * pow(2, n - i - 1)
        cnt = 0
        while now:
            now %= int(bin(now)[2:].count("1"))
            cnt += 1
        print(cnt)


if __name__ == '__main__':
    main()



### FIXED CODE ###

def search(n):
    res = 0
    while n:
        n %= bin(n).count("1")
        res += 1
    return res


def main():
    n = int(input())
    x = list(input())
    x_decimal = int("".join(map(str, x)), 2)
    first_mod = sum(map(int, list(x)))
    increase_mod = first_mod + 1
    increase_base = x_decimal % increase_mod  # 反転させる桁が元々0だった場合
    decrease_mod = first_mod - 1
    if decrease_mod:
        decrease_base = x_decimal % decrease_mod  # 反転させる桁が元々1だった場合
    for i in range(n):
        cnt = 0
        if x[i] == "1" and decrease_mod:
            cnt = 1 + search((decrease_base - pow(2, n - i - 1, decrease_mod)) % decrease_mod)
        elif x[i] == "0":
            cnt = 1 + search((increase_base + pow(2, n - i - 1, increase_mod)) % increase_mod)
        print(cnt)


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

S = input()
Q = int(input())
s = list(S)
for i in range(Q):
  A = input().split()
  if int(A[0]) == 1:
    s = s[::-1]
  else:
    if int(A[1]) == 1:
      s = [A[2]] + s
    else:
      s = s + [A[2]]
result = ''.join(s)
print(result)
  

### FIXED CODE ###

from collections import deque
S = input()
S = deque(S)
N = int(input())

rev = 0

for i in range(N):
  Q = input().split()
  if Q[0] == "1":
    rev += 1
    rev %= 2
  else:
    if (rev + int(Q[1])) % 2 == 1:
      S.appendleft(Q[2])
    else:
      S.append(Q[2])
S = "".join(S)
if rev == 1:
  S = S[::-1]
print(S)
### BUGGY CODE ###


import math



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

x = 1

num = math.floor(n/b)

if num == 0:
    x = n
    print(math.floor(a*x/b)-a*math.floor(x/b))
    exit()
else:
    ans = 0
    for i in range(1,num+1):
        x = b*i-1
        ans = max(ans,math.floor(a*x/b)-a*math.floor(x/b))
print(ans)

### FIXED CODE ###


import math



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

x = 1

num = math.floor(n/b)

if num == 0:
    x = n
    print(math.floor(a*x/b)-a*math.floor(x/b))
    exit()
if num >= 100000:
    print(b-1)
    exit()
else:
    ans = 0
    for i in range(1,num+1):
        x = b*i-1
        ans = max(ans,math.floor(a*x/b)-a*math.floor(x/b))
print(ans)
### BUGGY CODE ###

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

flag = True

min = N

if K == 1:
    ans = 0
elif N % K == 0:
    ans = 0
elif abs(N - K) > N:
    ans = N
else:
    while(flag):
        if abs(min - K) < min:
            min = abs(min - K)
        else:
            flag = False
            ans = min

print(ans)


### FIXED CODE ###

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

flag = True

min = N

if K == 1:
    ans = 0
elif N % K == 0:
    ans = 0
elif abs(N - K) > N:
    ans = N
else:
    if (N % K) > (K / 2):
        ans = abs((N % K) - K)
    else:
        ans = N % K

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

S = input()

#print('01' in S)
#print('10' in S)

count = 0

while '01' in S or '10' in S:
    #print(S)
    #print('01' in S or '10' in S)
    if '01' in S:
        S = S.replace('01', '', 1)
        count += 1
    if '10' in S:
        S = S.replace('10', '', 1)
        count += 1

print(count * 2)




### FIXED CODE ###

S = input()

count_0 = S.count('0')
count_1 = S.count('1')

print(min(count_0, count_1) * 2)
### BUGGY CODE ###

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]


NN = 10 ** 6 + 100
primes = deque()
isprime = [True for _ in range(NN + 1)]
min_factor = [-1 for _ in range(NN + 1)]
#エラトステネスの篩
for i in range(2, NN + 1):
    if not isprime[i]:
        continue
    primes.append(i)
    min_factor[i] = i
    for j in range(i * 2, NN + 1, i):
        isprime[j] = False
        if min_factor[j] == -1:
            min_factor[j] = i
def prime_factrize(n):
    res = deque()
    while n != 1:
        prime = min_factor[n]
        exp = 0
        while min_factor[n] == prime:
            exp += 1
            n //= prime
        res.append([prime, exp])
    return res


n = INT()
a = LIST()
ll = deque()
for i in range(n):
    aa = prime_factrize(a[i])
    for j in range(len(aa)):
        try:
            idx = [ll[k][0] for k in range(len(ll))].index(aa[j][0])
            ll[idx][1] = max(ll[idx][1], aa[j][1])
        except:
            ll.append(aa[j])
l = 1
for i in range(len(ll)):
    l *= pow(ll[i][0], ll[i][1], mod)
ans = 0
for i in range(n):
    ans += l // a[i]
    ans %= mod
print(ans)


### FIXED CODE ###

import sys
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return list(map(int, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n = INT()
a = LIST()
l = 1
for i in a:
    l = lcm(l, i)
l %= mod
ans = 0
for i in a:
    ans += l * pow(i, mod - 2, mod)
print(ans % mod)
### BUGGY CODE ###

n,q = map(int, input().split())
s = input()
anss = list()
for i in range(q):
    ans = 0
    ss = list()
    l,r = map(int, input().split())
    ss = s[l-1:r]
    for j in range(r-l):
        if ''.join(ss[j]+ss[j+1]) == 'AC':
            ans += 1
    anss.append(ans)
for i in range(q):
    print(anss[i])

### FIXED CODE ###

n,q=map(int,input().split())
s=input()

ac_count=[]
ac=0

for i in range(n-1):
    if s[i:i+2]=='AC':
        ac+=1
    ac_count.append(ac)
    
for i in range(q):
    l,r=map(int,input().split())
    if l==1:
        print(ac_count[r-2])
    else:
        print(ac_count[r-2]-ac_count[l-2])
### BUGGY CODE ###

n = int(input())
p = list(map(int,input().split()))
ans = 0
list_a=[]
for i in range(len(p)):
  for j in range(i+1):
    list_a.append(p[j])
  m = min(list_a)
  if m == p[i]:
    ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
p = list(map(int,input().split()))
ans = 0
list_a=[]
min = p[0]
for i in p:
  if min >= i:
    min = i
    ans += 1
print(ans)
### BUGGY CODE ###

import math

K  = int(input())
ans = 0
for a in range(K+1):
    for b in range(K+1):
        for c in range(K+1):
            if a*b*c !=0:
                s = math.gcd(math.gcd(a,b),c)
                ans = ans +s

print(ans)

### FIXED CODE ###

import math

K  = int(input())
ans = 0
for a in range(K+1):
    for b in range(a,K+1):
        for c in range(b,K+1):
            if a==b and b ==c:
                dabu = 1
            elif a!=b and b!=c and c!=a:
                dabu = 6
            else:
                dabu = 3
            if a*b*c !=0:
                s = math.gcd(math.gcd(a,b),c) * dabu
                ans = ans +s
print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
b = list()
for i in range(n):
	b.append(a[i])
	b = b[::-1]
for x in b:
	print(x, end=' ')
print()

### FIXED CODE ###

from collections import deque
d = deque()
n = int(input())
a = input().split()

for i in range(n):
	if i % 2 == n % 2:
		d.append(a[i])
	else:
		d.appendleft(a[i])

print(' '.join(d))
### BUGGY CODE ###

mod = 10**9+7
def gcd(x,y):
    a,b = max(x,y),min(x,y)
    r = a % b
    while r != 0:
        a,b = b,r
        r = a % b
    return b
N = int(input())
a = list(map(int,input().split()))
g = a[0]
l = a[0]
for i in range(1,N):
    g = gcd(l,a[i])
    l = (a[i]*l)//g
ans = 0
for i in range(N):
    ans = (ans+l//a[i])%mod
print(ans%mod)

### FIXED CODE ###

def pow(x, n, mod):
    ret = 1
    while n > 0:
        if n % 2 == 1:
            ret = ret * x % mod
        x = x * x % mod
        n >>= 1
    return ret
def gcd(x,y):
    a,b = max(x,y),min(x,y)
    r = a % b
    while r != 0:
        a,b = b,r
        r = a % b
    return b
mod = 10**9+7
N = int(input())
a = list(map(int,input().split()))
g = a[0]
l = g
for i in range(1,N):
    g = gcd(l, a[i])
    l = (l*a[i])//g
ans = 0
l %= mod
for i in range(N):
    tmp = (pow(a[i], mod-2, mod)*l)%mod
    ans = (ans+tmp)%mod
print(ans%mod)
### BUGGY CODE ###

import functools
N, C = map(int, input().split())
P = [[] for i in range(C)]
for i in range(N):
  s, t, c = map(int, input().split())
  P[c - 1].append([s, t])
for i in range(C):
  P[i].sort(key=lambda x: x[0])
  _P = []
  p = []
  while P[i]:
    if p:
      if p[1] == P[i][0][0]:
        p = [p[0], P[i][0][1]]
      else:
        _P.append(p)
        p = P[i][0]
    else:
      p = P[i][0]
    P[i] = P[i][1:]
  if p:
    _P.append(p)
  P[i] = _P
_P = [p for p in P if p]
P = functools.reduce(lambda x, y: x + y, _P)
P.sort(key=lambda x: x[0])
R = [0]
for p in P:
  record = False
  for i, r in enumerate(R):
    if r < p[0]:
      R[i] = p[1]
      record = True
      break
  if not record:
    R.append(p[1])
print(len(R))

### FIXED CODE ###

import functools
N, C = map(int, input().split())
T = [[0 for i in range(10 ** 5 + 1)] for j in range(C)]
for i in range(N):
  s, t, c = map(int, input().split())
  for j in range(s - 1, t):
    T[c - 1][j] = 1
ans = 0
for j in range(10 ** 5 + 1):
  r = 0
  for i in range(C):
    r += T[i][j]
  ans = max(ans, r)
print(ans)
### BUGGY CODE ###

from collections import defaultdict
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
ls = []
for i in range(n):
  t = x
  for j in range(i+1)[::-1]:
    t %= a[j]
  ls.append(t)
mod = 10**9+7
rng = 300
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
def inv(a):
  return pow(a,mod-2,mod)
dp = [{} for i in range(n+1)]
dp[0][x] = 1
for i in range(n):
  for j in range(i+1,n+1):
    for k in dp[i].keys():
      num = dp[i][k]
      k %= a[j-1]
      if k in dp[j]:
        dp[j][k] = (dp[j][k]+num*fctr[n-i-1]*inv(fctr[n-j]))%mod
      else:
        dp[j][k] = (num*fctr[n-i-1]*inv(fctr[n-j]))%mod
ans = 0
for i,x in dp[n].items():
  ans = (ans+i*x)%mod
print(ans)

### FIXED CODE ###

from collections import defaultdict
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
mod = 10**9+7
dp = [defaultdict(int) for i in range(n+1)]
dp[0][x] = 1
for i in range(1,n+1):
  for j in dp[i-1].keys():
    k = j%a[i-1]
    dp[i][j] = (dp[i][j]+dp[i-1][j]*(n-i))%mod
    dp[i][k] = (dp[i][k]+dp[i-1][j])%mod
ans = 0
for i,x in dp[n].items():
  ans = (ans+i*x)%mod
print(ans)
### BUGGY CODE ###

import math
n = int(input())
ls = list(map(int,input().split()))
ls.sort()
ans = 0
al = [ls[-1],ls[0]]
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
for i in range(n-1,n):
    di = ls[:i]
    di.append(ls[i]//2)
    di.sort()
    ind = di.index(ls[i]//2)
    il,ir = ind,ind
    if ind > 0:
        il -= 1
    else:
        il = -1
    if ind < len(di)-1:
        ir += 1
    else:
        ir = -1
    c = 0
    if ir > 0:
        if il > 0:
            mx = max(combinations_count(ls[i],di[ir]),combinations_count(ls[i],di[il]))
            c = 1
        else:
            mx = combinations_count(ls[i],di[ir])
            c = 3
    else:
        if il > 0:
            mx = combinations_count(ls[i],di[il])
            c = 2
        else:
            mx = 0
    if mx > ans:
        ans = mx
    if ans == mx:
        if c == 1:
            if combinations_count(ls[i],di[ir]) >= combinations_count(ls[i],di[il]):
                al = [ls[i],di[ir]]
            else:
                al = [ls[i],di[il]]
        elif c == 2:
            al = [ls[i],di[il]]
        elif c == 3:
            al = [ls[i],di[ir]]
print(*al)

### FIXED CODE ###

import math
n = int(input())
ls = list(map(int,input().split()))
ls.sort()
di = ls[:]
di.append(ls[-1]//2)
di.sort()
ind = di.index(ls[-1]//2)
il,ir = -1,-1
if ind > 0:
    il = ind - 1 
if ind < n-1:
    ir = ind + 1
if il < 0 or ir < 0:
    now = max(ir,il)
else:
    if ls[-1] % 2 == 0:
        if abs(ls[-1]//2 - di[ir]) < abs(ls[-1]//2 - di[il]):
            now = di[ir]
        else:
            now = di[il]
    else:
        if min(abs(ls[-1]//2 - di[ir]),abs(ls[-1]//2 + 1 - di[ir])) < min(abs(ls[-1]//2 - di[il]),abs(ls[-1]//2 + 1 - di[il])):
            now = di[ir]
        else:
            now = di[il]
print(ls[-1],now)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
syoji = 1000
kabu = 0
kai = 0
uri = 0
if N ==1:
  print(syoji)
  exit()
sw = 0
for i in range(N):
  if i<N-1 and kabu == 0 and A[i] < A [i+1]:
    for j in range(i+1,N):
      if sw ==1 and uri >= A[j]:
        break

      elif  A[i] < A[j]:
        uri = A[j]
        sw = 1

    if sw ==1:
      for num in range (1000000000):
        if syoji < num*A[i]:
          kabu = num-1
          syoji = syoji - (num-1)*A[i]
          kai = A[i]
          sw = 0
          break
  elif kabu > 0 and A[i]==uri:
    syoji = syoji + kabu*A[i]
    kabu = 0
    uri = 0

        
print(syoji)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
syoji = 1000
kabu = 0
kai = 0
uri = 0
if N ==1:
  print(syoji)
  exit()
sw = 0
for i in range(N):
  if i<N-1 and kabu == 0 and A[i] < A [i+1]:
    for j in range(i+1,N):
      if sw ==1 and uri >= A[j]:
        break
 
      elif  A[i] < A[j]:
        uri = A[j]
        sw = 1
    if sw ==1:
      kabu = syoji // A[i]
      syoji = syoji - kabu*A[i]
      kai = A[i]
      sw = 0
  elif kabu > 0 and A[i]==uri:
    syoji = syoji + kabu*A[i]
    kabu = 0
    uri = 0
 
        
print(syoji)
### BUGGY CODE ###

from collections import deque
N, M = map(int, input().split())
P = list(map(int, input().split()))
K = [[] for _ in range(N)]
for i in range(M):
    x, y = map(int, input().split())
    x, y = x-1, y-1
    K[x].append(y)
    K[y].append(x)
used = [0]*N
OK = []
for i in range(N):
    P[i] -= 1
    if i == P[i]:
        OK.append(i)
ans = 0
for i in range(N):
    if used[i] == 0:
        used[i] = 1
        S = deque([i])
        Enable = [i]
        Origin = [P[i]]
        while S:
            t = S.popleft()
            for j in K[t]:
                if used[j] == 0:
                    used[j] = 1
                    Enable.append(j)
                    Origin.append(P[j])
                    S.append(j)
    T_1 = set(OK + Enable)
    T_2 = set(OK + Origin)
    T_3 = set(OK + Enable + Origin)
    ans = max(ans, len(T_1) + len(T_2) - len(T_3))

print(ans)


### FIXED CODE ###

from collections import deque
N, M = map(int, input().split())
P = list(map(int, input().split()))
K = [[] for _ in range(N)]
for i in range(M):
    x, y = map(int, input().split())
    x, y = x-1, y-1
    K[x].append(y)
    K[y].append(x)
used = [0]*N
OK = []
for i in range(N):
    P[i] -= 1
    if i == P[i]:
        OK.append(i)
ans = 0
for i in range(N):
    if used[i] == 0:
        used[i] = 1
        S = deque([i])
        Enable = [i]
        Origin = [P[i]]
        while S:
            t = S.popleft()
            for j in K[t]:
                if used[j] == 0:
                    used[j] = 1
                    Enable.append(j)
                    Origin.append(P[j])
                    S.append(j)
        T_1 = list(set(OK + Enable))
        T_2 = list(set(OK + Origin))
        ans = max(ans, len(T_1) + len(T_2) - len(set(T_1 + T_2)))

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

import itertools
N = int(input().strip())
A = list(map(int,input().strip().split(' ')))
Z = [[0 for m in range(N+1)] for n in range(N) ]
result = 0

for k in range(N):
        Z[0][k] = A[k]
        if A[k] == 0:
                result = result+1

for i,j in itertools.combinations_with_replacement(range(1,N),2):
        tmp = Z[i-1][j-1]+Z[0][j]
        if tmp ==0:
                result = result+1
        Z[i][j] = tmp
print(result)

### FIXED CODE ###

import collections
N = int(input().strip())
A = list(map(int, input().strip().split(' ')))
C = [0 for j in range(N)]
C[0] = A[0]
for i in range(1,N):
        C[i] = C[i-1] + A[i]
C.sort()

CC = collections.Counter(C)

result = CC[0]
for k in CC.values():
    if k > 1:
        result = result + k*(k-1)/2

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

import bisect
from sys import stdin

def AI(): return list(map(int, stdin))



def main():
	n = int(input())
	A = AI()

	set_A = set(A)
	ans = 0

	for i in set_A:
		c = A.count(i)
		if  c%2 != 0:
			ans += 1
	print(ans)

	
if __name__ == "__main__": main()



### FIXED CODE ###

n = int(input())
card = set()

for i in range(n):
    num = int(input())
    if num in card:
        card.remove(num)
    else:
        card.add(num)
print(len(card))