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

#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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

# nums = [0]*(maxA+2) # osoi?
nums = set()
A.sort()
sA = list(set(A))
cnt = 0 
ans = defaultdict(int)
for a in sA:
    # print('nums', nums)
    new = False
    # if nums[a]==0:
    if not(a in nums):
        # print(a)
        cnt += 1
        ans[a] += 1
        new = True
    mlt = a
    nums.add(a)
    while new and a + mlt < maxA+2:
        a += mlt
        # print(' a:', a)
        # nums[a] += 1
        nums.add(a)

for an in ans.keys():
    if A.count(an)>1:
        cnt -= 1
print(cnt)

### FIXED CODE ###

#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
A = list(map(int, input().split()))
A.sort()
C = Counter(A)
S = set(A)

maxA = A[-1]
chk = [0] * (maxA+1)
for s in S:
    for i in range(s, maxA+1, s):
        chk[i] += 1

res = [s for s in S if chk[s] == 1 and C[s] == 1]
# print(res)
print(len(res))
### BUGGY CODE ###

import sys
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
start = 0
end = 1
a_ls = [bin(i)[2:].zfill(20) for i in a_ls] + ["2" * 20]
dic = {i : 0 if j == "0" else 1 for i,j in enumerate(a_ls[0])}
cnt = 0
while start < n and end <= n:
    flg = True
    a = a_ls[end]
    for i, j in enumerate(a):
        if dic[i] + int(j) > 1:
            flg = False
    if flg:
        for i, j in enumerate(a):
            dic[i] += int(j)
        end += 1
    else:
        cnt += (end - start - 1)
        for i, j in enumerate(a_ls[start]):
            dic[i] -= int(j)
        start += 1
        if end == start:
            for i, j in enumerate(a):
                dic[i] += int(j)
            end += 1
print(cnt + n)

### FIXED CODE ###

import sys
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
start = 0
end = 1
a_ls = [bin(i)[2:].zfill(20) for i in a_ls] + ["2" * 20]
dic = {i : 0 if j == "0" else 1 for i,j in enumerate(a_ls[0])}
cnt = 0
while start < n and end <= n:
    flg = True
    a = a_ls[end]
    for i, j in enumerate(a):
        if dic[i] + int(j) > 1:
            flg = False
    if flg:
        for i, j in enumerate(a):
            dic[i] += int(j)
        end += 1
    else:
        cnt += (end - start - 1)
        for i, j in enumerate(a_ls[start]):
            dic[i] -= int(j)
        start += 1
        if end == start:
            for i, j in enumerate(a):
                dic[i] += int(j)
            end += 1
print(cnt + n)
### BUGGY CODE ###

def main():
    h,w=map(int,input().split())
    L=80*(h+w)+1
    a=[list(map(int,input().split())) for i in range(h)]
    b=[list(map(int,input().split())) for i in range(h)]


    x=[[abs(a[i][j]-b[i][j]) for j in range(w)] for i in range(h)]
    
    p=x[0][0]
    L=8000
    
    state=[[[False for k in range(L)] for j in range(w)] for i in range(h)]


    state[0][0][p]=True

    for j in range(1,w):
        p=x[0][j]
        for k in range(L):
            if state[0][j-1][k]==True:
                state[0][j][k+p]=True
                state[0][j][abs(k-p)]=True

    for i in range(1,h):
        p=x[i][0]
        for k in range(L):
            if state[i-1][0][k]==True:
                state[i][0][k+p]=True
                state[i][0][abs(k-p)]=True

    for i in range(1,h):
        for j in range(1,w):
            p=x[i][j]
            for k in range(L):
                if state[i-1][j][k] | state[i][j-1][k]==True:
                    if k+p<L: state[i][j][k+p]=True
                    state[i][j][abs(k-p)]=True



    for k in range(L):
        if state[h-1][w-1][k]==True:
            print(k)
            break
if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    h,w=map(int,input().split())
    L=80*(h+w)+1
    a=[list(map(int,input().split())) for i in range(h)]
    b=[list(map(int,input().split())) for i in range(h)]


    x=[[abs(a[i][j]-b[i][j]) for j in range(w)] for i in range(h)]
    

    L=12800
    
    state=[[0]*w for _ in range(h)]
    delta=x[0][0]
    state[0][0]=(2**L>>delta)|(2**L<<delta)

    for j in range(1,w):
        delta=x[0][j]
        state[0][j]=(state[0][j-1]>>delta)|(state[0][j-1]<<delta)

    for i in range(1,h):
        delta=x[i][0]
        state[i][0]=(state[i-1][0]>>delta)|(state[i-1][0]<<delta)

    for i in range(1,h):
        for j in range(1,w):
            delta=x[i][j]
            state[i][j]=(state[i][j-1]>>delta)|(state[i][j-1]<<delta)
            state[i][j]|=(state[i-1][j]>>delta)|(state[i-1][j]<<delta)

    
    ans = 10**9
    for i in range(L*2):
        if state[h-1][w-1] & 1:
            ans = min(ans,abs(i-L))
        state[h-1][w-1]>>=1
    print(ans)



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

N, K = map(int, input().split())
*V, = map(int, input().split())
V.sort()
A = [0]*(N+1)
B = [0]*(N+1)
MASK = 2**(K+1)-1
A[0] = 1
for i in range(N):
    if K <= V[i]:
        A[i+1] = A[i]
    else:
        A[i+1] = (A[i] | ((A[i] << V[i]) & MASK))
B[N] = 1 << K
for i in range(N-1, -1, -1):
    if K <= V[i]:
        B[i] = B[i+1]
    else:
        B[i] = (B[i+1] | (B[i+1] >> V[i]))

ans = N
for i in range(N):
    if K <= V[i]:
        ans -= 1
        continue
    a = A[i]; b = B[i+1]
    t = K
    K0 = K-V[i]
    for s in range(K+1):
        if a & 1 == 0:
            a >>= 1
            if not a: break
            continue
        while b and (s + t >= K or b & 1 == 0):
            t -= 1
            b >>= 1
        if not b: break
        if K0 <= s + t:
            ans -= 1
            break
        a >>= 1
print(ans)


### FIXED CODE ###

import random
N, K = map(int, input().split())
*V, = map(int, input().split())
A = [0]*(N+1)
B = [0]*(N+1)
MASK = 2**(K+1)-1
A[0] = 1
for i in range(N):
    if K <= V[i]:
        A[i+1] = A[i]
    else:
        A[i+1] = (A[i] | ((A[i] << V[i]) & MASK))
B[N] = 1 << K
for i in range(N-1, -1, -1):
    if K <= V[i]:
        B[i] = B[i+1]
    else:
        B[i] = (B[i+1] | (B[i+1] >> V[i]))

ans = N
for i in range(N):
    if K <= V[i]:
        ans -= 1
        continue
    a = A[i]; b = B[i+1]
    VM = 2**(V[i]+1)-2
    l = 1
    while a and b and l:
        if a & 1 and b & VM:
            ans -= 1
            break
        l = max((a & -a).bit_length()-1, (b & -b).bit_length()-V[i]-1)
        a >>= l; b >>= l
print(ans)
### BUGGY CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]


N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    print(A.index(i+1) +1, end =' ')

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
for i in range(n):
  ans[a[i]-1] = i +1
for i in range(n):
  print(ans[i])
### BUGGY CODE ###

N=int(input())
S=list(map(int,input().split()))
count=0
P=[0]*(N*N+1)
for j in range(N*N):
  P[j+1]=S.index(j+1)
for i in range(N*N):
  player=S[i]
  hayasa=P[player]
  
  que=[[] for _ in range(N)]
  d=[-1]*(N*N+1)
  que[0].append(player)
  d[player]=i
  
  j=0
  finish=0
  while True:
    for kouho in que[j]:
      if kouho%N==0:
        finish=1
        break
      if kouho%N==1:
        finish=1
        break
      if kouho+N>N*N:
        finish=1
        break
      if kouho<N:
        finish=1
        break
        
      if d[kouho+N]<i:
        if P[kouho+N]>hayasa:
          que[j+1].append(kouho+N)
          d[kouho+N]=i
        else:
          que[j].append(kouho+N)
          d[kouho+N]=i
          
      if d[kouho-N]<i:
        if P[kouho-N]>hayasa:
          que[j+1].append(kouho-N)
          d[kouho-N]=i
        else:
          que[j].append(kouho-N)
          d[kouho-N]=i
          
      if d[kouho+1]<i:
        if P[kouho+1]>hayasa:
          que[j+1].append(kouho+1)
          d[kouho+1]=i
        else:
          que[j].append(kouho+1)
          d[kouho+1]=i
          
      if d[kouho-1]<i:
        if P[kouho-1]>hayasa:
          que[j+1].append(kouho-1)
          d[kouho-1]=i
        else:
          que[j].append(kouho-1)
          d[kouho-1]=i
    if finish==1:
      count+=j
      break
    j+=1    
print(count)

### FIXED CODE ###

from numba import njit
import numpy as np

@njit
def main(N, P):
    lista = [1, -1, N, -N]
    d = np.zeros((N, N), dtype=np.int32)
    d = d.ravel()
    sit = np.ones_like(d)
    stack = np.empty_like(d)
    count = 0
    for i in range(N*N):
        d[i] = min(i % N, (N-1-i) % N, i//N, N-1-i//N)
    for player in P:
        sit[player-1] = 0
        count += d[player-1]
        stack[0] = player
        num = 0
        while num >= 0:
            p = stack[num]
            num -= 1
            a = d[p-1]+sit[p-1]
            for i in lista:
                if p+i < 1 or p + i > N*N:
                    continue
                if d[p+i-1] > a:
                    d[p+i-1] = a
                    num += 1
                    stack[num] = p+i
    print(count)

N = int(input())
P = np.array(input().split(), np.int32)

main(N, P)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10000)

H, W = map(int, input().split())
##計算の都合、 通路(.)を正の整数、壁(#)を-1に変換する
Mij = [[0] * W for _ in range(H)]
space_count = 0
for i in range(H):
    s = input()
    for j in range(W):
        if s[j] == ".":
            space_count += 1
            Mij[i][j] = 100000
        else:
            Mij[i][j] = -1

dirs = [[1, 0], [0, 1], [-1, 0], [0, -1]]

def search(i, j, step):
    if i == H - 1 and j == W - 1:
        return step

    best = None
    for d in dirs:
        i2 = i + d[0]
        j2 = j + d[1]
        if 0 <= i2 < H and 0 <= j2 < W:
            if step + 1 < Mij[i2][j2]:
                Mij[i2][j2] = step
                r = search(i2, j2, step + 1)
                if not r:
                    continue
                if not best or best > r:
                    best = r
    return best

total_steps = search(0, 0, 1)
if total_steps is None:
    print(-1)
else:
    print(space_count - total_steps)


### FIXED CODE ###

H, W = map(int, input().split())
##計算の都合、 通路(.)を正の整数、壁(#)を-1に変換する
LARGE_VALUE = 100000
Mij = [[0] * W for _ in range(H)]
space_count = 0
for i in range(H):
    s = input()
    for j in range(W):
        if s[j] == ".":
            space_count += 1
            Mij[i][j] = LARGE_VALUE
        else:
            Mij[i][j] = -1

dirs = [[1, 0], [0, 1], [-1, 0], [0, -1]]

queue = [[0, 0]]

def search():
    while len(queue):
        p = queue[0]
        del queue[0]
        i = p[0]
        j = p[1]
        step = Mij[i][j]

        for d in dirs:
            i2 = i + d[0]
            j2 = j + d[1]
            if 0 <= i2 < H and 0 <= j2 < W:
                if step + 1 < Mij[i2][j2]:
                    Mij[i2][j2] = step + 1
                    queue.append([i2, j2])

Mij[0][0] = 1
search()
total_steps = Mij[H - 1][W - 1]
if total_steps == LARGE_VALUE:
    print(-1)
else:
    print(space_count - total_steps)
### BUGGY CODE ###

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

#output
from collections import Counter
l = Counter(A)
l = l.most_common()

maximum_operation = [0] * N
for K in range(len(l)):
    l = Counter(A)
    l = l.most_common()
    while l[K][1] > 0:
        for i in range(K+1):
            l[i] = (l[i][0], l[i][1]-1)
        l = sorted(l, key = lambda x:x[1], reverse = True)
        maximum_operation[K] += 1

for m in maximum_operation:
    print(m)

### FIXED CODE ###

import sys
input = sys.stdin.readline

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

#output
from collections import Counter
import bisect

l = Counter(A).most_common()
l = [b for a, b in l]
M = len(l)
l.sort()
p = sum(l)

maximum_operation = [0] * N

ll = []
for x in reversed(range(1, N+1)):
    a = bisect.bisect_left(l, x)
    if a == 0:
        b = M*x
        c = 0
    elif a >= M:
        b = 0
        c = p
    else:
        b = (M-a)*x
        c = sum(l[0:a]) 
    ll.append((b + c)/x)

for K in range(M):
    maximum_operation[K] = N - bisect.bisect_left(ll, K+1)

for m in maximum_operation:
    print(m)
### BUGGY CODE ###

import math
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
#def LI(): return list(map(int, input().split())
n=I()
bls=list(MI())
ls=sorted(bls, reverse=True)
trans=0
for i in range(n-2):
    answer=0
    for j in range(i+1,n-1):
        l1=ls[i]
        l2=ls[j]
        l,r = j,n
#あえて左右一つ分ずつ広く取る
        while l+1 < r:
#この条件で探索の終点がうまく定められる
            mid = (l+r)//2
            if l1<l2+ls[mid]:
                l = mid
            else:
                r = mid
        ansij=l-j
        #print(ansij)
        answer+=ansij
    trans+=answer
print(trans)

### FIXED CODE ###

import math
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
#def LI(): return list(map(int, input().split())
n=I()
bls=list(MI())
ls=sorted(bls, reverse=True)
trans=0
for i in range(n-2):
    answer=0
    for j in range(i+1,n-1):
        l1=ls[i]
        l2=ls[j]
        l,r = j,n
#あえて左右一つ分ずつ広く取る
        while l+1 < r:
#この条件で探索の終点がうまく定められる
            mid = (l+r)//2
            if l1<l2+ls[mid]:
                l = mid
            else:
                r = mid
        ansij=l-j
        #print(ansij)
        answer+=ansij
    trans+=answer
print(trans)
### BUGGY CODE ###

import numpy
h,w=map(int,input().split())
s=[list(input())for _ in range(h)]
score=numpy.zeros((h,w))
ans=0
range_w=range(w)
range_h=range(h)
for i in range_h:
  tmp_1=0
  tmp_2=0
  for j in range_w:
    if s[i][j]=="#":
      tmp_1=0
    else:
      tmp_1+=1
    score[i][j]+=tmp_1
    
    if s[i][-j-1]=="#":
      tmp_2=0
    else:
      tmp_2+=1
    score[i][-j-1]+=tmp_2
    
for j in range_w:
  tmp_3=0
  tmp_4=0
  for i in range_h:
    if s[i][j]=="#":
      tmp_3=0
    else:
      tmp_3+=1
    score[i][j]+=tmp_3
    
    if s[-i-1][j]=="#":
      tmp_4=0
    else:
      tmp_4+=1
    score[-i-1][j]+=tmp_4-3
print(int(score.max()))

### FIXED CODE ###

h,w=map(int,input().split())
s=[list(input())for _ in range(h)]
score=[[0]*w for _ in range(h)]
ans=0
range_w=range(w)
range_h=range(h)
for i in range_h:
  tmp_1=0
  tmp_2=0
  for j in range_w:
    if s[i][j]=="#":
      tmp_1=0
    else:
      tmp_1+=1
    score[i][j]+=tmp_1
    
    if s[i][-j-1]=="#":
      tmp_2=0
    else:
      tmp_2+=1
    score[i][-j-1]+=tmp_2
    
for j in range_w:
  tmp_3=0
  tmp_4=0
  for i in range_h:
    if s[i][j]=="#":
      tmp_3=0
    else:
      tmp_3+=1
    score[i][j]+=tmp_3
    
    if s[-i-1][j]=="#":
      tmp_4=0
    else:
      tmp_4+=1
    score[-i-1][j]+=tmp_4-3
for i in range(h):
  for j in range(w):
    ans=max(ans,score[i][j])
print(ans)
### BUGGY CODE ###


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################


N, Q = map(int, input().split())
S = input().rstrip()
for i in range(Q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1

    count = 0
    for j in range(l+1, r+1):
        if S[j-1] == 'A' and S[j] == 'C':
            count += 1
    print(count)


### FIXED CODE ###


N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)

'''
累積和
t[1] = t[0] + (if S[0]からの2文字がACなら1 or 0) → AC の C 位置なら1
t[2] = t[1] + (if S[1]からの2文字がACなら1 or 0)
t[3] = t[2] + (if S[2]からの2文字がACなら1 or 0)
t[4] = t[3] + (if S[3]からの2文字がACなら1 or 0)
t[5] = t[4] + (if S[4]からの2文字がACなら1 or 0)
t[6] = t[5] + (if S[5]からの2文字がACなら1 or 0)
t[7] = t[6] + (if S[6]からの2文字がACなら1 or 0)
t[8] = t[7] + (if S[7]からの2文字がACなら1 or 0)

# 01234567
# ACACTACG
# 011222333
'''

for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)

#print(t)

for i in range(Q):
    l, r = map(int, input().split())

    # 3, 7 なら、t[7-1] - t[3-1]
    #  → t[5]以下の数 - t[1]以下の数
    print(t[r-1] - t[l-1])
### BUGGY CODE ###

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

mod = 10**9+7

def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if is_prime[i]:
            for j in range(i*2, n+1, i):
                is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]

primes = sieve(10**6)

def primeFactorization(n):
    ans = [0 for _ in range(len(primes))]
    temp = n
    for i in range(len(primes)):
        while temp%primes[i] == 0:
            ans[i] += 1
            temp /= primes[i]
    return ans

AFactorized = list(map(primeFactorization, A))
# print(AFactorized)

lcm = [0 for _ in range(len(primes))]
for i in range(len(primes)):
    for j in AFactorized:
        lcm[i] = max(lcm[i], j[i])

# print(lcm)

lcm_val = 1
for i in range(len(primes)):
    lcm_val *= pow(primes[i], lcm[i], mod)

# print(lcm_val)
ans = 0
for a in A:
    ans += lcm_val * pow(a, mod-2, mod)
    ans %= mod

print(ans)

### FIXED CODE ###

import fractions
from functools import reduce

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

p = 10**9+7

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

lcm = lcm_list(A)

B = [lcm//i for i in A]

print(sum(B)%p)
### BUGGY CODE ###

import numpy as np
(n, m) = list(map(int, input().split()))
a = np.array(list(map(int, input().split()))).astype("int64") 
a = np.cumsum(a)
a %= m
count = np.sum(a == 0)
unique_key = np.unique(a)
counts = [np.sum(a == i) for i in unique_key]
counts = np.array(counts).astype("int64")
counts = counts * (counts - 1) // 2
print(count + np.sum(counts))

### FIXED CODE ###

import numpy as np
(n, m) = list(map(int, input().split()))
a = np.array(list(map(int, input().split()))).astype("int64") 
a = np.cumsum(a)
a %= m
count = np.sum(a == 0)
a.sort()
tc = 1
for i in range(1, n):
    if a[i - 1] == a[i]:
        tc += 1
    else:
        count += tc * (tc - 1) // 2
        tc = 1
else:
    count += tc * (tc - 1) // 2
print(count)
### BUGGY CODE ###

A,B,K = map(int,input().split())

for i in range(K):
	if A >= 1:
		A = A - 1
	elif B >= 1:
		B = B -1
	else:
		break
print(A,B)

### FIXED CODE ###

A,B,K = map(int,input().split())

if K <= A:
	print(A - K ,B)
elif K <= (A + B):
	print(0,B-(K-A))
else:
	print(0,0)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from operator import itemgetter
from scipy.sparse import lil_matrix

N = int(input())
edge = lil_matrix((N,N))

XY = [[i] + [int(x) for x in input().split()] for i in range(N)]
for key in [itemgetter(1), itemgetter(2)]:
  XY.sort(key = key)
  for i in range(N-1):
    i1,x1,y1 = XY[i]
    i2,x2,y2 = XY[i+1]
    d = min(abs(x1-x2),abs(y1-y2))
    edge[i1,i2] = d

edge = edge.tocsr()

# 最小全域木
from scipy.sparse.csgraph import minimum_spanning_tree
tree = minimum_spanning_tree(edge, overwrite = True).astype(int)
answer = tree.sum()
print(answer)

### FIXED CODE ###

import sys
input = sys.stdin.readline
from operator import itemgetter
from scipy.sparse import csr_matrix
import numpy as np

N = int(input())

XY = [[i] + [int(x) for x in input().split()] for i in range(N)]

edge = [set() for _ in range(N)]
for key in [itemgetter(1),itemgetter(2)]:
  XY.sort(key = key)
  for i in range(N-1):
    i1,x1,y1 = XY[i]
    i2,x2,y2 = XY[i+1]
    d = min(abs(x1-x2),abs(y1-y2))
    edge[i1].add((i2,d))
    
# csr形式に直す
indptr = []
indrow = []
value = []
ptr = 0
for i in range(N):
  indptr.append(ptr)
  for j,v in edge[i]:
    indrow.append(j)
    value.append(v)
    ptr += 1
indptr.append(ptr)
value = np.array(value,dtype=int)
graph = csr_matrix((value,indrow,indptr),shape=(N,N))

# 最小全域木
from scipy.sparse.csgraph import minimum_spanning_tree
tree = minimum_spanning_tree(graph, overwrite = True).astype(int)
answer = tree.sum()
print(answer)
### BUGGY CODE ###

n = int(input())
a = map(int, input().split())
b = []
for ai in a:
  b.append(str(ai))
  b = list(reversed(b))
print(' '.join(b))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
#b = []
#for ai in a:
#  b.append(str(ai))
#  b = list(reversed(b))
#print(' '.join(b))
if len(a) % 2 == 0:
  even = []
  odd = []
  for i, ai in enumerate(a):
    if (i + 1) % 2 == 0:
      even.append(str(ai))
    else:
      odd.append(str(ai))

  r = list(reversed(even))
  answer = r + odd
  print(' '.join(answer))
else:
  even = []
  odd = []
  for i, ai in enumerate(a):
    if (i + 1) % 2 == 0:
      even.append(str(ai))
    else:
      odd.append(str(ai))
  r = list(reversed(odd))
  answer = r + even
  print(' '.join(answer))
### BUGGY CODE ###

def main():
    N = int(input())
    A_list = [A for A in input().split()]
    A_list = list(map(int, A_list))
    #ans_list = []

    for n_cycle in range(1,N+1) :
        #ans_list.append(A_list.count(n_cycle))
        print(A_list.count(n_cycle))
    #for ans in ans_list :
    #    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    from collections import Counter
    N = int(input())
    A_list = [A for A in input().split()]
    A_list = list(map(int, A_list))
    #ans_list = []
    ans = Counter(A_list)

    for n_cycle in range(N) :
        n_cycle = n_cycle + 1
        #ans_list.append(A_list.count(n_cycle))
        print(ans[n_cycle])

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

import heapq as h
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
e6 = 10**6
q = [-b[i]*e6-i for i in range(n)]
q.sort()
cnt = 0
while q:
  w = -h.heappop(q)
  v, i = divmod(w, e6)
  u = b[i-1] + b[(i+1)%n]
  if v < u or a[i] == v: continue
  elif a[i] > v: print(-1); exit(0)
  t = (v-a[i])//u
  if not t: print(-1); exit(0)
  cnt += t
  b[i] -= t*u
  if b[i] > a[i]:
    h.heappush(q,-b[i]*e6-i)
print(cnt if a==b else -1)

### FIXED CODE ###

import heapq as h
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
e6 = 10**6
q = [-b[i]*e6-i for i in range(n)]
h.heapify(q)
cnt = 0
while q:
  w = -h.heappop(q)
  v,i = w//e6, w%e6
  u = b[(i-1)%n] + b[(i+1)%n]
  if v < u or a[i] == v: continue
  elif a[i] > v: print(-1); exit(0)
  t = (v-a[i])//u
  if not t: print(-1); exit(0)
  cnt += t
  b[i] -= t*u
  if b[i] > a[i]:
    h.heappush(q,-b[i]*e6-i)
print(cnt if a==b else -1)
### BUGGY CODE ###

import fractions

A, B = map(int, input().split())

f = fractions.gcd(A, B)

kouyakusuu = []

if f % 2 == 0:
    kouyakusuu.append(2)
    while f % 2 == 0:
        f = f / 2

for i in range(3, int(f)+1, 2):
    # print(f, i)
    if f % i != 0:
        continue
    else:
        kouyakusuu.append(i)
        while f % i == 0:
            f = f / i
    if f == 1:
        break
print(len(kouyakusuu)+1)

### FIXED CODE ###

import fractions

A, B = map(int, input().split())

f = fractions.gcd(A, B)

kouyakusuu = []

if f % 2 == 0:
    kouyakusuu.append(2)
    while f % 2 == 0:
        f = f / 2

i = 3
while i*i <= f:
    if f % i == 0:
        kouyakusuu.append(i)
        while f % i == 0:
            f = f / i
    i += 2
if f != 1:
    kouyakusuu.append(f)
print(len(kouyakusuu)+1)