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

count = int(raw_input())
k = [int(raw_input()) for i in xrange(count)]
temp = []
for i in xrange(len(k)):
    if k[i] not in temp:
        temp.append(k[i])
    elif k[i] in temp:
        temp.remove(k[i])

print len(temp)


### FIXED CODE ###

from collections import Counter

count = int(raw_input())
k = [int(raw_input()) for i in xrange(count)]
temp = Counter(k)
counter = 0
for key, value in temp.iteritems():
    if value % 2 != 0:
        counter += 1

print counter
### BUGGY CODE ###

A,B,K=map(int,input().split())
s=range(A,B+1)
t=[x for x in s if A<=x<=A+K-1 or B-K+1<=x<=B]
t.sort()
for i in t:
    print(i)


### FIXED CODE ###

A,B,K=map(int,input().split())
if B-A>200:
    k=range(A,A+K)
    l=range(B-K+1,B+1)
    for i in k:
        print(i)
    for i in l:
        print(i)
else:
    s=range(A,B+1)
    t=[x for x in s if A<=x<=A+K-1 or B-K+1<=x<=B]
    t.sort()
    for i in t:
        print(i)
### BUGGY CODE ###

n=int(input())
l = [ i for i in range(1,n+1) if i*i <= n]
for a in l[::-1]:
    if n % a == 0:
        print(max(len(str(a)),len(str(n//a))))
        break


### FIXED CODE ###

import math
n=int(input())
k = math.floor(math.sqrt(n))
for a in range(k+1,0,-1):
    if n % a == 0:
        print(max(len(str(a)),len(str(n//a))))
        break
### BUGGY CODE ###

n = int(input())
s = str(input())
count = 0
for i in range(n):
    for j in range(n):
        for k in range(n):
            if i < j < k:
                a = (s[i], s[j], s[k])
                #print(a)
                a_set = set(a)
                #print(a_set)
                if len(a_set) == 3 and (j - i) != (k - j):
                    count += 1
print(count)

### FIXED CODE ###

n = int(input())
s = str(input())
count = 0
sum_RGB = s.count("R") * s.count("G") * s.count("B")
for i in range(n):
    for j in range(i, n):  # rangeをiからにすることでループ減らせる
        # for k in range(n): # sum_RGBから減らしていくのでｋがi,jで決まる
        k = 2*j - i
        if k < n:
            a = (s[i], s[j], s[k])
            # print(a)
            a_set = set(a)
            # print(a_set)
            if len(a_set) == 3:
                count += 1

print(sum_RGB - count)
### BUGGY CODE ###

R, G, B, n = map(int, input().split())
a, s = range(n+1), 0
for r in a:
  for g in a:
    b = (n-r*R-g*G)/B
    s += b.is_integer() and b >= 0
print(s)

### FIXED CODE ###

R, G, B, n = map(int, input().split())
a, s = range(n+1), 0
for r in a:
  for g in a:
    b = (n-r*R-g*G)/B
    s += b.is_integer() and b >= 0
print(s)
### BUGGY CODE ###

from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))

divisible = [False for _ in range(int(1e6+1))]
cnt = defaultdict(int)

for a in A:
    cnt[a] += 1
    if divisible[a] == False:
        for i in range(a+a, len(divisible), a):
            divisible[i] = True
ans = 0
for a in A:
    if divisible[a] is False and cnt[a] <= 1:
        ans += 1
print(ans)


### FIXED CODE ###

from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)

divisible = [False for _ in range(int(1e6+1))]
cnt = defaultdict(int)

for a in A:
    cnt[a] += 1
    if divisible[a] == False and cnt[a] <= 1:
        for i in range(a+a, len(divisible), a):
            divisible[i] = True
ans = 0
for a in A:
    if divisible[a] is False and cnt[a] <= 1:
        ans += 1
print(ans)
### BUGGY CODE ###

from collections import deque #pypyでも使える
n,q=map(int,input().split())
oyako=[]
for i in range(n-1):
	ab=list(map(lambda x:int(x)-1,input().split()))
	#もっといい感じの書き方ないかな?
	oyako.append(ab)
nodes=[0]*n
for i in range(q):
	p,x=map(int,input().split())
	p-=1
	nodes[p]+=x
#oyakoを、親についての単調増加にしたい->デフォで先頭要素でのソートになるので安心
#oyako.sort()
#と思ったけどソートじゃ無理っぽい
#根から順に処理->bfs幅優先探索
que=deque([0])
color=[0]*n #全てのノードに対して、未探索の0を入れる
color[0]=0 #colorは親としての処理を終えたかどうかを入れる。終えたら1にする
while que: #qが空でないのはこう表現できる
	i=que.popleft()
	if color[i]==0:
		for ab in oyako:
			if ab[0]==i and color[ab[1]]==0:
				nodes[ab[1]]+=nodes[i]
				que.append(ab[1])
			elif ab[1]==i and color[ab[0]]==0:
				nodes[ab[0]]+=nodes[i]
				que.append(ab[0])
		color[i]=1

#綺麗にかけそうでこの書き方をしたけど大丈夫かな?
for node in nodes:
	print(node,end=' ')

### FIXED CODE ###

from collections import deque #pypyでも使える
n,q=map(int,input().split())

edges=[[] for i in range(n)] #枝がどことどこをつなぐかの情報を入れておく二次元配列
for i in range(n-1):
	a,b=map(lambda x:int(x)-1,input().split()) #ラムダ式は必見
	#もっといい感じの書き方ないかな?
	edges[a].append(b) #edges[a]には、ノードaの相方を格納
	edges[b].append(a) #edges[b]には、ノードbの相方を格納する決まり

#nodesの重さを格納
nodes=[0]*n
for i in range(q):
	p,x=map(int,input().split())
	nodes[p-1]+=x

#oyakoを、親についての単調増加にしたい->デフォで先頭要素でのソートになるので安心
#oyako.sort()
#と思ったけどソートじゃ無理っぽい
#根から順に処理->bfs幅優先探索
que=deque([0])
color=[0]*n #全てのノードに対して、未探索の0を入れる
color[0]=0 #colorは親としての処理を終えたかどうかを入れる。終えたら1にする
#TLEなった。二重ループはだめねえ。
# ->oyako(edges)を、二次元配列にしてインデックスの数字を持つものをedges[i]に格納すれば
while que: #qが空でないのはこう表現できる
	i=que.popleft()
	if color[i]==0:
		for edge in edges[i]:
			if color[edge]==0: #相方が親じゃなければ(親ならすでに探索済みのはず)
				nodes[edge]+=nodes[i]
				que.append(edge)
		color[i]=1

#綺麗にかけそうでこの書き方をしたけど大丈夫かな?
for node in nodes:
	print(node,end=' ')
### BUGGY CODE ###

def make_divisors(n):

    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()

    return divisors


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

import fractions

n = fractions.gcd(A, B)
divisors = make_divisors(n)
N = len(divisors)

count = 0
flag = [0] * N
for i in range(1, N - 1):
    for j in range(i + 1, N):
        if divisors[j] % divisors[i] == 0:
            if flag[j] == 0:
                count += 1
                flag[j] = 1

print(N - count)


### FIXED CODE ###

def make_divisors(n):

    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()

    return divisors

def is_remainder(n):
    if n == 1:
        return True

    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    
    return True
        

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

import fractions
n = fractions.gcd(A, B)
divisors = make_divisors(n)
N = len(divisors)

count = 0
flag = [0] * N
for item in divisors:
    if is_remainder(item):
        count += 1

print(count)
### BUGGY CODE ###

from fractions import gcd

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

#とりあえず。どうせTLE
sugoilcm = A[0]
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
for i in range(1,N):
    sugoilcm = A[i] * sugoilcm / gcd(A[i], sugoilcm)

ans = 0
for i in range(N):
    ans += sugoilcm//A[i]
print(int(ans%(10**9+7)))

### FIXED CODE ###

import fractions

def main():
    mod = 10**9+7
    N = int(input())
    A = list(map(int,input().split()))
    lcm = 1
    for Ai in A:
        lcm = lcm*Ai//fractions.gcd(lcm,Ai)
    lcm %= mod
    ans = 0
    for Ai in A:
        ans += lcm*pow(Ai,mod-2,mod)%mod
        ans %= mod
    print(ans)
    
if __name__ == '__main__':
    main()
### BUGGY CODE ###

# coding: utf-8
N,M,K=map(int,input().split())
FB=[[False for i in range(N+1)] for j in range(N+1)]

par = [i for i in range(N+1)]
rank = [0 for i in range(N+1)]
 
def find(x):
    if x==par[x]:
        return x
    else:
        par[x]=find(par[x])
        return par[x]
 
 
def unite(x,y):
    rx=find(x)
    ry=find(y)

    if rx==ry:
        return
    
    
    if rank[rx]<rank[ry]:
        par[rx]=ry
    else:
        par[ry]=rx

    if rank[rx]==rank[ry]:
        rank[rx]+=1
 

def some(x,y):
    return find(x)==find(y)
 
for i in range(M):
    A,B=map(int,input().split())
    unite(A,B)
    FB[A][B]=True
    FB[B][A]=True

for i in range(K):
    C,D=map(int,input().split())
    FB[C][D]=True
    FB[D][C]=True

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

for i in range(1,N+1):
    for j in range(1,N+1):
        if FB[i][j]:
            continue
        else:
            if some(i,j) and i!=j:
                ans[i-1]+=1


print(*ans)    












### FIXED CODE ###

# coding: utf-8
import collections

N,M,K=map(int,input().split())
F=[[] for i in range(N+1)]
Bl=[[] for i in range(N+1)]

par = [i for i in range(N+1)]
rank = [0 for i in range(N+1)]
 
def find(x):
    if x==par[x]:
        return x
    else:
        par[x]=find(par[x])
        return par[x]
 
 
def unite(x,y):
    rx=find(x)
    ry=find(y)

    if rx==ry:
        return
    
    
    if rank[rx]<rank[ry]:
        par[rx]=ry
    else:
        par[ry]=rx

    if rank[rx]==rank[ry]:
        rank[rx]+=1
 

def some(x,y):
    return find(x)==find(y)
 
for i in range(M):
    A,B=map(int,input().split())
    unite(A,B)
    F[A].append(B)
    F[B].append(A)

for i in range(K):
    C,D=map(int,input().split())
    Bl[C].append(D)
    Bl[D].append(C)

ans=[0 for i in range(N)]
for i in range(N):
    find(i+1)
c = collections.Counter(par)

for i in range(N):
    ans[i]+=c[find(i+1)]-1
    ans[i]-=len(F[i+1])
    for j in range(len(Bl[i+1])):
        if some(i+1,Bl[i+1][j]):
            ans[i]-=1
print(*ans)
### BUGGY CODE ###

from collections import Counter

def factorization(n):
    counter = Counter()
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            counter[i] = cnt

    if temp!=1:
        counter[temp] = 1

    if len(counter)==0:
        counter[n] = 1

    return counter

def main():
    mod = 10**9+7
    N = int(input())
    A = list(map(int,input().split()))
    
    A_primefact = [0]*N
    union = Counter()
    for i in range(N):
        A_primefact[i] = factorization(A[i])
        union = union | A_primefact[i]
    
    ans = 0
    for i in range(N):
        tmp = 1
        for prime in (union-A_primefact[i]).most_common():
            tmp *= prime[0]**prime[1]
            tmp %= mod
        ans += tmp
    ans %= mod
    
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import fractions

def main():
    mod = 10**9+7
    N = int(input())
    A = list(map(int,input().split()))
    lcm = 1
    for Ai in A:
        lcm = lcm*Ai//fractions.gcd(lcm,Ai)
    lcm %= mod
    ans = 0
    for Ai in A:
        ans += lcm*pow(Ai,mod-2,mod)%mod
        ans %= mod
    print(ans)
    
if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys
readline = sys.stdin.readline

H, W = map(int, readline().split())
G = [[0]*W for _ in range(H)]
L1 = [[0]*1000 for _ in range(W+H-1)]
geta1 = W-1
L2 = [[0]*1000 for _ in range(W+H-1)]
for i in range(H):
    S = [1 if s == '#' else 0 for s in readline().strip()]
    for j in range(W):
        G[i][j] = S[j]
        if S[j]:
            L1[i-j+geta1][i] = 1
            L2[i+j][i] = 1
for sub in range(W+H-1):
    for i in range(630):
        L1[sub][i] += L1[sub][i-1]
        L2[sub][i] += L2[sub][i-1]

res = 0
for su in range(2*max(H, W)+1):
    for w in range(max(0, su-H+1), min(W, su+1)):
        h = su-w
        if not G[h][w]:
            continue
        for k in range(1, min(h+1, W-w)):
            if not G[h-k][w+k]:
                continue
            idx1 = h+w-2*k
            if 0 <= idx1 < H+W-1:
                res += L2[idx1][h-k-1] - L2[idx1][h-2*k]
            idx2 = h+w+2*k
            if 0 <= idx2 < H+W-1:
                res += L2[idx2][h+k-1] - L2[idx2][h]

for mi in range(1-W, H):
    for w in range(max(0, -mi), min(W, H-mi)):
        h = mi + w
        if not G[h][w]:
            continue
        for k in range(1, min(H-h, W-w)):
            if not G[h+k][w+k]:
                continue
            idx1 = h-w-2*k + geta1
            if 0 <= idx1 < H+W-1:
                res += L1[idx1][h] - L1[idx1][h-k-1]
            idx2 = h-w+2*k + geta1
            if 0 <= idx2 < H+W-1:
                res += L1[idx2][h+2*k] - L1[idx2][h+k-1]

print(res)

### FIXED CODE ###

import sys
readline = sys.stdin.readline

H, W = map(int, readline().split())
G = [[0]*W for _ in range(H)]
L1 = [[0]*1000 for _ in range(W+H-1)]
geta1 = W-1
L2 = [[0]*1000 for _ in range(W+H-1)]
for i in range(H):
    S = [1 if s == '#' else 0 for s in readline().strip()]
    for j in range(W):
        G[i][j] = S[j]
        if S[j]:
            L1[i-j+geta1][i] = 1
            L2[i+j][i] = 1
for sub in range(W+H-1):
    for i in range(630):
        L1[sub][i] += L1[sub][i-1]
        L2[sub][i] += L2[sub][i-1]

res = 0
for su in range(2*max(H, W)+1):
    for w in range(max(0, su-H+1), min(W, su+1)):
        h = su-w
        if not G[h][w]:
            continue
        for k in range(1, min(h+1, W-w)):
            if not G[h-k][w+k]:
                continue
            idx1 = h+w-2*k
            if 0 <= idx1 < H+W-1:
                res += L2[idx1][h-k-1] - L2[idx1][h-2*k]
            idx2 = h+w+2*k
            if 0 <= idx2 < H+W-1:
                res += L2[idx2][h+k-1] - L2[idx2][h]

for mi in range(1-W, H):
    for w in range(max(0, -mi), min(W, H-mi)):
        h = mi + w
        if not G[h][w]:
            continue
        for k in range(1, min(H-h, W-w)):
            if not G[h+k][w+k]:
                continue
            idx1 = h-w-2*k + geta1
            if 0 <= idx1 < H+W-1:
                res += L1[idx1][h] - L1[idx1][h-k-1]
            idx2 = h-w+2*k + geta1
            if 0 <= idx2 < H+W-1:
                res += L1[idx2][h+2*k] - L1[idx2][h+k-1]

print(res)
### BUGGY CODE ###

from collections import Counter

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

if p == 2 or p == 5:
    ans = 0
    for i, e in enumerate(s, 1):
        if int(e) % p == 0:
            ans += i

    print(ans)

else:
    li = [0]
    for i, e in enumerate(s[::-1], 1):
        li.append((li[-1] + int(e) * 10 ** i) % p)

    c = Counter(li)
    ans = 0
    for v in c.values():
        ans += v * (v - 1) // 2

    print(ans)


### FIXED CODE ###

from collections import Counter

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

if p == 2 or p == 5:
    ans = 0
    for i, e in enumerate(s, 1):
        if int(e) % p == 0:
            ans += i

    print(ans)

else:
    li = [0]
    for i, e in enumerate(s[::-1], 1):
        li.append((li[-1] + int(e) * pow(10, i, p)) % p)

    c = Counter(li)
    ans = 0
    for v in c.values():
        ans += v * (v - 1) // 2

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

#1:初期化
N, K = map(int,input().split())
h = list(map(int, input().split()))
#h = [int(x) for x in input().split()] #こっちのほうが早い？
inf = float("inf")
dp = [inf]*(N)

#2:初期値
dp[0] = 0

#3:dp実行部(貰うDP)
for i in range(1,N):
    L = [dp[j]+abs(h[i]-h[j]) for j in range(max(0,i-K),i)]
    dp[i] = min(L)
#    for k in range(1,min(N-i-1,K)+1):
#        dp[i+k] = min(dp[i+k], dp[i] + abs(h[i] - h[i+k]))
        #print(dp,i,k)

#4:出力
print(dp[N-1])

### FIXED CODE ###

# -*- coding: utf-8 -*- 
def cost(h,N,K):
    dp=[0]*N
    dp[1]=abs(h[0]-h[1])
    for i in range(2,N):
        tmp=[abs(h[i]-h[j])+dp[j] for j in range(max(0,i-K),i)]
        dp[i]=min(tmp)
    return dp[-1]

N,K=map(int,input().split())
h=[int(num) for num in input().split()]

print(cost(h,N,K))
### BUGGY CODE ###

def main():
    N = int(input())
    A = [x for x in input().split()]
    l = [0] * N
    C = list(set(A))
    for i in C:
        l[int(i)-1] = A.count(i)
    for i in range(N):
        print(l[i])
        
main()

### FIXED CODE ###

def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    l = [0]*N
    for i in A:
        l[i-1] += 1
    for j in l:
        print(j)
main()
### BUGGY CODE ###

def main():
    num = int(input())
    suzi = list(map(int,input().split()))
    ans = 1
    if 0 in suzi:
	    print(0)
	    return

    for kazu in suzi:
	    ans *= kazu
    if ans >  1000000000000000000:
	    print(-1)
    else:
	    print(ans)

main()

### FIXED CODE ###

def main():
    num = int(input())
    suzi = list(map(int,input().split()))

    if 0 in suzi:
	    print(0)
	    return
    ans = 1
    for kazu in suzi:
        ans *= kazu
        if ans > 1000000000000000000:
            print(-1)
            return
    print(ans)


main()
### BUGGY CODE ###

import math
import queue

def readInt():
	return int(input())

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

def readChars():
	return input().split()

s = input()

count = 0
for i in range(0,len(s)):
	for j in range(i+4,len(s)+1):
		if int(s[i:j])%2019==0:
			count+=1

print(count)

### FIXED CODE ###

import math

def readInt():
	return int(input())

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

def readChars():
	return input().split()

s = reversed(input())

ai = 0
si = 0

p = 2019
countarr = [0]*2019

for i, j in enumerate(s):
	ai = (int(j)*pow(10,i,p))%p
	si = (si+ai)%p
	countarr[si]+=1

res = countarr[0]
for i in range(p):
	c = countarr[i]
	res += c*(c-1)//2

print(res)
### BUGGY CODE ###

import numpy as np

n, m = [int(x) for x in input().split()]
data = [[0]*n for _ in range(m)]
for i in range(m):
    x, y, _ = [int(x) - 1 for x in input().split()]
    data[i][x], data[i][y] = 1, -1

mat = np.array(data)
r = np.linalg.matrix_rank(mat)

ans = n - r

print(ans)

### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n

    def root(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.par[x] = y
            else:
                self.par[y] = x
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

    def samegrp(self, x, y):
        return self.root(x) == self.root(y)

n, m = [int(x) for x in input().split()]
A = UnionFind(n)
ans = n
for i in range(m):
    x, y, _ = [int(z) - 1 for z in input().split()]
    if not A.samegrp(x, y):
        ans -=1
    A.union(x, y)

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

n,m=map(int, input().split())
a=[]
for i in range(m):
  a.append(int(input()))

mod=1000000007

dp=[0]*(n+1)
dp[0]=1
dp[1]=1

for i in range(n-1):
  if not i+2 in a:
    if i in a and i+1 in a:
      dp[i+2]=0
    elif i in a:
      dp[i+2]=dp[i+1]
    elif i+1 in a:
      dp[i+2]=dp[i]
    else:
      dp[i+2]=dp[i+1]+dp[i]

  dp[i+2] = dp[i+2] % mod
  #print(dp)

print(dp[n])



### FIXED CODE ###

n,m=map(int, input().split())
a=[]
for i in range(m):
  a.append(int(input()))
  

mod=1000000007

dp=[0]*(n+1)
dp[0]=1


if n==1:
  print(1)
  exit()

if m==0:
  dp[1]=1
  for i in range(n-1):
    dp[i+2]=dp[i+1]+dp[i]
  dp[i+2] = dp[i+2] % mod
  print(dp[n])
  exit()

if a[0]==1:
  dp[1]=0
else:
  dp[1]=1



a_i2=0
a_i1=0
a_i=0

for i in range(n-1):
  if i+2 == a[a_i2]:
      a_i2 += 1
      if a_i2 == m:
        a_i2 -= 1
  else:
    if i+1 == a[a_i1]:
      if i == a[a_i]:
        dp[i+2]=0
        a_i += 1
        if a_i == m:
          a_i -= 1
      else:
        dp[i+2]=dp[i]
      a_i1 += 1
      if a_i1 == m:
        a_i1 -= 1
    else:
      if i == a[a_i]:
        dp[i+2]=dp[i+1]
        a_i += 1
        if a_i == m:
          a_i -= 1
      else:
        dp[i+2]=dp[i+1]+dp[i]

  dp[i+2] = dp[i+2] % mod
  #print(dp)

print(dp[n])
### BUGGY CODE ###

x = int(input())
root5x = int(pow(x, 0.2)) + 1
factor = []
fact = 1
while fact * fact < x:
  if x % fact == 0:
    factor.append(fact)
    factor.append(x // fact)
  fact += 1
if fact * fact == x:
  factor.append(fact)
for d in factor:
  rest = x // d
  if rest % 5 > 1:
    continue
  for a in range(d):
    b = a - d
    if x == a ** 5 - b ** 5:
      print(a, b)
      break
  else:
    continue
  break

### FIXED CODE ###

x = int(input())
for a in range(-200, 200):
  for b in range(-200, 200):
    if a ** 5 - b ** 5 == x:
      print(a, b)
      break
  else:
    continue
  break
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
b = set(a)
b = list(b)
x = [0 for i in range(len(b))]
for i in a:
    y = b.index(i)
    x[y] += 1
ans = 0
for i,j in zip(b,x):
    if j < i:
        ans += j
    else:
        ans += j - i
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
a.sort()
count = 0
x = 0
tmp_count = 0
for i in a:
    if i != x:
        if tmp_count < x:
            count += tmp_count
        else:
            count += tmp_count - x
        tmp_count = 1
        x = i
    else:
        tmp_count += 1
if tmp_count < x:
    count += tmp_count
else:
    count += tmp_count - x
print(count)
### BUGGY CODE ###

# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	x,y = map(int,input().split())	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# 3
# hoge
# foo
# bar
# n=int(input())
# string_list=[input() for i in range(n)]
# N, M = map(int,input().split())

# P, Y = [], []
# for _ in range(M):
#     P_i, Y_i = = map(int,input().split())
#     P.append(P_i)
#     Y.append(Y_i)

N, M = map(int, input().split())
py = {}
all_py = []
for _ in range(M):
  p, y = map(int, input().split())
  if not p in py:
    py[p] = []
  py[p].append(y)
  all_py.append([p, y])

sort_p = {}
for k, v in all_py:
  if not k in sort_p:
    sort_p[k] = sorted(py[k])
  print("{}{}".format(str(k).zfill(6), str((sort_p[k]).index(v)+1).zfill(6)))

### FIXED CODE ###

# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	x,y = map(int,input().split())	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# 3
# hoge
# foo
# bar
# n=int(input())
# string_list=[input() for i in range(n)]
# N, M = map(int,input().split())

# P, Y = [], []
# for _ in range(M):
#     P_i, Y_i = map(int,input().split())
#     P.append(P_i)
#     Y.append(Y_i)
def inpl(): return list(map(int, input().split()))

N, M = inpl()
A = [""]*M
P = [[] for _ in range(N+1)]
for i in range(M):
  p, y = inpl()
  P[p].append((y, i))

# print(P)
for ind, p in enumerate(P):
  p = sorted(p, key=lambda x: x[0])
  for j, (y, i) in enumerate(p):
    A[i] = "{}{}".format(str(ind).zfill(6), str(j+1).zfill(6))

print("\n".join(A))
### BUGGY CODE ###

from collections import deque

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

graph, parents, values, visited = [],[],[],[]
for _ in range(N):
  graph.append([])
  parents.append(-1)
  values.append(0)
  visited.append(False)

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

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

bfs_queue = deque()
bfs_queue.append(0)
bfs_queue_len = 1
while bfs_queue_len:
  cur = bfs_queue.popleft()
  bfs_queue_len -= 1
  visited[cur] = True

  for other in graph[cur]:
    if not visited[other]:
      parents[other] = cur
      values[other] += values[cur]
      bfs_queue_len += 1
      bfs_queue.append(other)

for i in range(N):
  print(values[i],end=" ")



### FIXED CODE ###

from collections import deque

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

graph, parents, values, visited = [],[],[],[]
for _ in range(N):
  graph.append([])
  parents.append(-1)
  values.append(0)
  visited.append(False)

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

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

bfs_queue = deque()
bfs_queue.append(0)
bfs_queue_len = 1
while bfs_queue_len:
  cur = bfs_queue.popleft()
  bfs_queue_len -= 1
  visited[cur] = True

  for other in graph[cur]:
    if not visited[other]:
      parents[other] = cur
      values[other] += values[cur]
      bfs_queue_len += 1
      bfs_queue.append(other)

print(*values)