peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n = int(input())
a = [ int(x) for x in input().split() ]

l = []
if n % 2 == 1:
    i = n-1
    while i >= 0:
        l.append(a[i])
        i -= 2

    j = 1
    while j < n:
        l.append(a[j])
        j += 2
else:
    i = n-1
    while i >= 0:
        l.append(a[i])
        i -= 2

    j = 0
    while j < n:
        l.append(a[j])
        j += 2

print(' '.join(map(str, l)))
# Judge status: Accepted
n = int(input())
MOD = 10**9 + 7

ans = 1

for i in range(1, n+1):
    ans = (ans*i) % MOD
print(ans)
# Judge status: Accepted
# coding: utf-8
# Your code here!
#n = int(input())
A,B,T= map(int, input().split())
# = list(map(int, input().split()))
print(T//A*B)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=[-1,0]
i=0
while i<n-1:
    res=0
    while i+res<=n-1 and a[i+res]-a[i]<=2:
        res+=1
    if res>ans[1]:
        ans[1]=res
        ans[0]=i
    if a[i]==a[-1]:
        break
    i+=1
print(ans[1])
# Judge status: Accepted
a,b,k=map(int,input().split())
x=[]
for i in range(1,101):
    if a%i==0 and b%i==0:
        x.append(i)
x=x[::-1]
print(x[k-1])
# Judge status: Wrong Answer
n, m = map(int ,input().split())
a = list(map(int, input().split()))
ans = sum(a)
for i in range(m):
  x, y = map(int, input().split())
  x-=1
  if y>a[x]:
    ans+=y-a[x]
    a[x]=y
print(ans)
# Judge status: Accepted
s = list(input())
t = s.copy()
t.reverse()
print(len(s)-t.index("Z")-s.index("A"))
# Judge status: Wrong Answer
s = input()
n= 2**(len(s)-1)
ans = 'inf'
for i in range(n):
    total = int(s[0])
    str = s[0]
    for j in range(1,len(s)):
        if i>>(len(s)-j)&1:
            total += int(s[j])
            str += '+' + s[j]
        else:
            total -= int(s[j])
            str += '-' + s[j]
    if total == 7:
        ans = str
print(str+'=7')
# Judge status: Accepted
import math

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

theta_m = (math.pi * 2 * (M/60)) 
theta_h = (math.pi * 2 * (H/12)) + (math.pi/6 * (M/60))

theta = abs(theta_h - theta_m)

Ax, Ay = A *  math.cos(theta), A * math.sin(theta)
Bx, By = B, 0.0

print(math.sqrt(((Ax - Bx) ** 2) + ((Ay - By) ** 2)))
# Judge status: Accepted
from subprocess import*
p=run(('factor',input()),capture_output=1).stdout.split()[1:]
print(sum(int(((8*p.count(i)+1)**.5-1)/2)for i in set(p)))
# Judge status: Accepted
s = input()
x = s.find('A')
y = s.rfind('Z')
print(y-x+1)
# Judge status: Accepted
#ABC-120-A
A, B, C = map(int, input().split())
ans = 0
while B >= A:
    B -= A
    ans += 1
    if ans == C:
        break
        
print(ans)
# Judge status: Accepted
n = int(input())
p = list(map(int,input().split()))
s = sorted(p)
cnt = 0
for i in range(n):
    if p[i] != i+1:
        cnt += 1

    
#print(p)
#print(s)
if cnt > 2:
        print("NO")
else:
    print("YES")
# Judge status: Accepted
numlist = [int(x) for x in input().split()]

for i in range(5):
    if numlist[i] == 0:
        print(i+1)
        break
# Judge status: Wrong Answer
N,M,K=map(int,input().split())
flag=False

for i in range(1,N+1):
    for j in range(1,M+1):
        black= (N-i)*j + (M-j)*i
        if K==black:
            flag=True
            break
    if flag:
        break
       
if flag:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N=int(input())
l=list(map(int,input().split()))
b=10**9+7
d=(sum(l))**2
c=0
for i in range(N):
  c=c+l[i]**2
print((d-c)//2%b)
# Judge status: Wrong Answer
S=input()
if 'a'and'b'and'c' in S:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n,m = map(int,input().split())

mod  = 10**9+7

ans = 1

if n == m:
    ans *= 2
    for i in range(1, n+1):
        ans *= i
        ans %= mod
    for i in range(1, m+1):
        ans *= i
        ans %= mod
elif abs(n-m) == 1:
    for i in range(1, n+1):
        ans *= i
        ans %= mod
    for i in range(1, m+1):
        ans *= i
        ans %= mod
else:
    ans = 0

print(ans)
# Judge status: Accepted
n, m, k = map(int, input().split())

ans = "No"
for i in range(n + 1):
    for j in range(m + 1):
        cnt = (n - i) * j + (m - j) * i
        if cnt == k:
            ans = "Yes"

print(ans)
# Judge status: Accepted
N=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))

minval=[abs(A-(T-item*0.006)) for item in H]
print(minval.index(min(minval))+1)
# Judge status: Wrong Answer
n = int(input())
l = [int(x) for x in input().split()]

max_index = l.index(max(l))

sum_length = 0

for x in range(n):
	if x == max_index:
		continue
	sum_length += l[x]

print ("YES") if sum_length > max(l) else print ("NO")
# Judge status: Accepted
a=int(input())
b=int(input())
if a+b==3:
    print(3)
elif a+b==4:
    print(2)
else:
    print(1)
# Judge status: Wrong Answer
N,M = (int(x) for x in input().split())
if N == M:
  print("yes")
else:
  print("no")
# Judge status: Accepted
N = int(input())
Suji_check = False
for s in range(1,10):
  for t in range(1,10):
    if s*t == N:
      Suji_check = True
      break
if Suji_check:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
n,k = map(int,input().split())
a = list(map(int,input().split()))
minA = min(a)
C = [1 if x==minA else 0 for x in a]
cnt=0
res=0
for i in range(n):
    if a[i] == 1:
        res += -(-cnt//(k-1))
        cnt = 0
    else:
        if i==n-1:
            cnt+=1
            res += -(-cnt//(k-1))
        else:
            cnt+=1
print(res)
# Judge status: Accepted
a, b = map(int, input().split())
if a>8 or b>8: print(":(")
else: print("Yay!")
# Judge status: Wrong Answer
import bisect

n = int(input())

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort()
b.sort()
c.sort()

ans = 0
for i in range(len(b)):
    a_idx = bisect.bisect_left(a, b[i])
    c_idx = bisect.bisect_right(c, b[i] + 1)
    l = len(c[c_idx:])
    ans += a_idx * (n - c_idx)
print(ans)
# Judge status: Accepted
N,M = map(int,(input().split()))
if N >= 2 and M >= 2:
    print((N-2)*(M-2))
elif N == 1 and M == 1:
    print(1)
else:
    print(max(N,M)-2)
# Judge status: Accepted
a,b,c,d = map(int, input().split())

isWin = False
while not isWin:
  if a <= 0 or c <= 0:
    if a <= 0 and c > 0:
      print('No')
      exit()
    else:
      print('Yes')
      exit()
  a -= d
  c -= b
# Judge status: Accepted
a, b = map(int, input().split())
# = list(map(int, input().split()))
# = [int(input()) for _ in range()]
if max(a, b) - min(a, b) > 0:
    print(max(a, b) * 2 - 1)
else:
    print(max(a, b) * 2)
# Judge status: Accepted
from bisect import*
n, *l = map(int, open(0).read().split())
l.sort();c=0
for i in range(n):
  for j in range(i+1, n):
    d = bisect_left(l, l[i] + l[j])
    c += max(0, d-j-1)
print(c)
# Judge status: Wrong Answer
x,a,b=map(int,input().split())
if b-a<=0:ans="delicious"
elif b-a<=x:ans="safe"
else:ans="dengerous"
print(ans)
# Judge status: Wrong Answer
d, t, s = map(int, input().split())
if t <= d/float(s):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
w, a, b = map(int, input().split())
if a<b:
  print(max(0, b-(a+w)))
else:
  print(max(0, a-(b+w)))
# Judge status: Accepted
w,h,n=map(int,input().split())
x1,x2,y1,y2=0,w,0,h
for i in range(n):
  x,y,a=map(int,input().split())
  if a==1 and x > x1:
    x1 = x
  elif a==2 and x < x2:
    x2 = x
  elif a==3 and y > y1:
    y1 = y
  elif a==4 and y < y2:
    y2 = y
if x1 > x2 or y1 > y2:
  print(0)
else:
  print((x2 - x1)*(y2 - y1))
# Judge status: Accepted
s=input()
if s[0]==s[1] and s[0]!=s[2] and s[2]==s[3]:
  print("Yes")
elif s[0]==s[2] and s[0]!=s[1] and s[1]==s[3]:
  print("Yes")
elif s[0]==s[3] and s[0]!=s[1] and s[1]==s[2]:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n, k = map(int, input().split())
a = list(map(int, input().split()))


for i in range(k):
    b = [0] * (n+1)
    for j in range(n):
        l = max(0, j-a[j])
        r = min(n, j+a[j]+1)
        b[l] += 1
        b[r] -= 1
    for j in range(n):
        b[j+1] += b[j]
    b.pop()
    if a == b:
        break
    a = b
print(' '.join(map(str, a)))
# Judge status: Wrong Answer
import numpy as np

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

brk_stair = np.ones(N+1, dtype = int)
dp = np.zeros(N+1, dtype= int)

for _ in range(M):
    brk_stair[int(input())] = 0

#print(brk_stair)

dp[0] = 1
dp[1] = 1 * brk_stair[1]

for i in range(2, N + 1):
    dp[i] = (dp[i - 1] + dp[i-2]) * brk_stair[i]

#print(dp)
print(dp[-1] % 1000000007)
# Judge status: Accepted
W,a,b=map(int,input().split())
print(0 if(a<=b and b<=a+W)or(a<=b+W and b+W<=a+W)else abs(a-b)-W)
# Judge status: Wrong Answer
a = input().split()
b = 0
for i in range(2):
    a.sort(reverse=True)
    b = b + int(a[1])
    a[1] = str(int(a[1]) - 1)
print(b)
# Judge status: Accepted
s=input()
S1=s[0]
S2=s[1]
S3=s[2]

if S1==S2==S3=="A":
    print("No")
elif S1==S2==S3=="B":
    print("No")
else:
    print("Yes")
# Judge status: Accepted
a,b = map(int,input().split())
print(-((-(a+b)//2)))
# Judge status: Wrong Answer
S = list(input())
T = list(input())
lenS = len(S)
lenT = len(T)
if lenS < lenT:
  for _ in range(10 ** 7):
    print("UNRESTORABLE")
# Judge status: Wrong Answer
w,h,n=map(int,input().split())
xya = [list(map(int, input().split())) for _ in range(n)]
w1=w
h1=h
for i in range(n):
    if xya[i][2]==1:
        w1=w-int(xya[i][0])
    elif xya[i][2]==2:
        w1-=(w-int(xya[i][0]))
    elif xya[i][2]==3:
        h1=h-int(xya[i][1])
    elif xya[i][2]==4:
        h1-=(h-int(xya[i][1]))
    else:pass
if w1>0 and h1>0:print(w1*h1)
else:print(0)
# Judge status: Accepted
n, r = map(int, input().split())
if n < 10:
    print(r+100*(10-n))
else:
    print(r)
# Judge status: Accepted
A,B=map(int,input().split())
K=(A+B)/2
Kint=(A+B)//2
if (K==Kint):
  print (Kint)
else:
  print ('IMPOSSIBLE')
# Judge status: Accepted
def ABC_65_A():
    X,A,B = map(int, input().split())
    
    if A >= B:
        print('delicious')
    elif A+X >= B:
        print('safe')
    else:
        print('dangerous')

if __name__ == '__main__':

    ABC_65_A()
# Judge status: Wrong Answer
def gcd(x,y):
  while y>0:
    bk=x%y
    x=y
    y=bk
  return x

k=int(input())
ans=0
for i in range(1,k+1):
  for j in range(1,k+1):
    for h in range(1,k+1):
      ans+=1
print(ans)
# Judge status: Accepted
n,m = map(int,input().split())
if m//2 <= n:
    print(m//2)
else:
    a = m - 2*n
    print(a//4+n)
# Judge status: Accepted
Q, H, S, D = map(int, input().split())
N = int(input())
Q *= 4
H *= 2
S = min(Q, H, S)
print(N // 2 * min(2 * S, D) + N % 2 * S)
# Judge status: Accepted
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    x, y, a, b, c = map(int, input().split())
    p = sorted(list(map(int, input().split())), reverse=True)[0:x]
    q = sorted(list(map(int, input().split())), reverse=True)[0:y]
    r = sorted(list(map(int, input().split())), reverse=True)
    pq = sorted((p + q))
    for i in range(min(c, (x + y))):
        if pq[i] > r[i]:
            break
        pq[i] = r[i]
    print(sum(pq))


if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())

if N % 2 == 0:
  print(0.5)
else:
  print((N // 2 + 1)/N)
# Judge status: Accepted
N = int(input())
S = input()
RGB = 'RGB'

ret = 0
for i in range(1,N):
    mid = S[i]
    rest = list(set(RGB)-set([mid]))
    left0, right0 = S[:i].count(rest[0]), S[i+1:].count(rest[0])
    left1, right1 = S[:i].count(rest[1]), S[i+1:].count(rest[1])
    tmp = left0*right1 + left1*right0
    for j in range(min(i,N-i-1)):
        ss = [S[i-j-1],S[i+j+1]]
        if ss == rest or ss == rest[::-1]:
            tmp -= 1

    ret += tmp
print(ret)
# Judge status: Accepted
s = input()
left = 0
ans = 0
for right in range(0,len(s)):
  if s[right] in ("A","C","G","T"):
    pass
  else:
    left=right+1
  ans = max(ans,right-left+1)
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []
for q in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)

sam = sum(A)
baketu = [0]*(100001)
for a in A:
    baketu[a] += 1

for q in range(Q):
    sam = sam + baketu[B[q]] * (C[q] - B[q])
    baketu[C[q]] += baketu[B[q]]
    baketu[B[q]] = 0
    #print(baketu)
    print(sam)
# Judge status: Accepted
from heapq import heappop,heappush
n,h=map(int,input().split())
a=[]
for i in range(n):
  x,y=map(int,input().split())
  heappush(a,(-x,1))
  heappush(a,(-y,0))
ans=0
while h>0:
  x,y=heappop(a)
  if y:
    ans+=(h-x-1)//(-x)
    break
  else:
    h+=x
    ans+=1
print(ans)
# Judge status: Accepted
n = input()
dic = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i in range(26):
  if n.count(str(dic[i]))==1 or n.count(str(dic[i]))==3 or n.count(str(dic[i]))==4:
    print("No")
    exit()
print("Yes")
# Judge status: Wrong Answer
S = int(input())
x = 10 ** 9 - S % (10 ** 9)
y = S // (10 ** 9) + 1
print('0 0 {0} {1} {2} {3}'.format(10 ** 9, 1, x, y))
# Judge status: Accepted
X=int(input())

if X>=30:
    print("Yes")
    exit()

print("No")
# Judge status: Wrong Answer
import re

input_line = input()
s = input()

content = s.replace(input_line, '', 1)
#print(content)

pattern = '^\w$'

# compile後match
try:
    repatter = re.compile(pattern)
    result = repatter.match(content)
    result.group()
    print ('Yes')
except:
    print ('No')
# Judge status: Accepted
s = input()
# 入力したsの3文字目つまりリストの3-1が4-1と一緒
# 同様に5-1と6-1が一緒ならyes
if s[2] == s[3] and s[4] == s[5]:
  print('Yes')
else: print('No')
# Judge status: Accepted
a,b,c=map(int,input().split())
if a+b<c:
    print('No')
else:
    print('Yes')
# Judge status: Accepted
print((lambda a:a[0]*a[1]//100)(list(map(int,input().replace(".", "").split()))))
# Judge status: Accepted
n = int(input())
a = int(input())
if n % 500 <= a:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import numpy as np
N,K = map(int,input().split())
q = list(map(int,input().split()))
q = np.array(q)

p = (q + 1) /2
p = p.tolist()
a = sum(p[:K])
mx = a

for i in range(0,N-K):
    a = a - p[i] + p[i+K]
    if a > mx:
        mx = a

print(mx)
# Judge status: Accepted
text = "".join(reversed(input()))
words = ["".join(reversed(x)) for x in ["dreamer", "eraser", "dream", "erase"]]

while text != "":
  has_striped = False
  for word in words:
    if text.find(word) != 0: continue
    text = text[len(word):]
    has_striped = True
  if not has_striped: break

print("YES" if text == "" else "NO")
# Judge status: Accepted
N, Q = map(int, input().split())
S = input()
cnt = [0] * N

for i in range(1, N):
    cnt[i] = cnt[i-1] + (1 if S[i-1:i+1] == 'AC' else 0)

ans = []
for _ in range(Q):
    l, r = map(int, input().split())
    ans.append(cnt[r-1] - cnt[l-1])

print('\n'.join(list(map(str, ans))))
# Judge status: Wrong Answer
#d
n = int(input())
a = list(map(int, input().split()))
print(-1)
# Judge status: Wrong Answer
x, n = map(int, input().split())
p = list(map(int, input().split()))
s = 101
ans = 101
for i in range(-100,100+1):
    if not i in p:
        if s > abs(x-i):
            s = abs(x-i)
            ans = i
print(ans)
# Judge status: Wrong Answer
n = int(input())
A = [1]+[pow(6,i) for i in range(1,7)]+[pow(9,i) for i in range(1,6)]
D = [1]+[-1]*(n-1)
for i in range(1,n):
    D[i] = D[i-1]+1
    for j in range(1,7):
        if pow(6,j)>i: break
        D[i] = min(D[i], D[i-pow(6,j)]+1)
    for j in range(1,6):
        if pow(9,j)>i: break
        D[i] = min(D[i], D[i-pow(9,j)]+1)
print(D[-1])
# Judge status: Wrong Answer
# coding: utf-8
alp = "abcdefghijklmnopqrstyvwxyz"
S = []
N = int(input())
for i in range(N):
    s = input()
    S.append(s[:])
ans = []
for a in alp:
    cnt = 0
    min_ = 10**9
    for s in S:
        if a in s:
            cnt += 1
            min_ = min(min_, s.count(a))
    if cnt == N:
        for i in range(min_):
            ans.append(a)
ans.sort()
if ans != "":
    print("".join(ans))
else:
    print()
# Judge status: Wrong Answer
n,l=map(int,input().split())
a=0
for i in range(n):
  a+=i+l
if l>=0:
  print(a-l)
elif l+n+1<0:
  print(a-(l+n-1))
else:
  print(a)
# Judge status: Wrong Answer
x = int(input())
if x > 11:
    if x % 11 == 0:
        print(int(x*2//11))
    else:
        print(int(x*2//11)+1)

elif x < 7:
    print(1)
    
else:
    print(2)
# Judge status: Accepted
index = 0
dic = ['a', 'b', 'c']
a = [list(input()) for i in range(3)]

while len(a[index]) > 0:
  index = dic.index(a[index].pop(0))
print(dic[index].upper())
# Judge status: Accepted
from collections import deque
S=deque(input())
Q=int(input())
reverse=0
for q in range(Q):
    Query=list(input().split())
    T=Query[0]
    if T=="1":
        reverse+=1
    if T=="2":
        F,C=Query[1],Query[2]
        if F=="1" and reverse%2==0 or F=="2" and reverse%2==1:
            S.appendleft(C)
        else:
            S.append(C)
S="".join(S)
print(S if reverse%2==0 else S[::-1])
# Judge status: Accepted
import itertools

N = int(input())

l = list()
lm = list()
for i in range(N):
    x = int(input())
    l.append(x)
    if x % 10 != 0:
        lm.append(x)

lm = sorted(lm)

a = sum(l)
if a % 10 == 0:
    if lm == []:
        print(0)
    else:
        print(a - lm[0])
else:
    print(a)
# Judge status: Accepted
def calc_e(num):
    return (num + 1) / 2

def main():
    n, k = map(int, input().split())
    dices = list(map(int, input().split()))

    current = (sum(dices[:k]) + k) / 2
    e_max = (sum(dices[:k]) + k) / 2
    for i in range(n-k):
        current = current + calc_e(dices[i+k]) - calc_e(dices[i])
        e_max = max(e_max, current)

    print(e_max)


if __name__ == '__main__':
    main()
# Judge status: Accepted
n,k=map(int,input().split())
a=list(map(int,input().split()))
pl=1
visit=[-1]*n
visit[0]=0
loop=0
cnt=0

while 1:
    cnt+=1
    pl=a[pl-1]
    
    
    if visit[pl-1]!=-1:
        loop=visit[pl-1]
        
        break
    visit[pl-1]=cnt
    if cnt==k:
        print(pl)
        exit()

loop_len=cnt-loop

k=(k-loop)%loop_len+loop
print(visit.index(k)+1)
# Judge status: Accepted
n = input()
k = 0
pay = 0
n_list = []
for i in n[::-1]:
    n_list.append(int(i))
n_list.append(0)
ans = 0
for i in range(len(n_list) - 1):
    num = n_list[i]
    if num < 5:
        ans += num
    elif (num <= 5 and n_list[i + 1] < 5):
        ans += num
    else:
        n_list[i + 1] += 1
        ans += 10 - num

ans += n_list[-1]
print(ans)
# Judge status: Wrong Answer
h = int(input())
ans = 0
while True:
    if h == 1:
        break
    elif h == 2:
        ans += 1
        break
    else:
        h //= 2
        ans += 1
print(2**ans)
# Judge status: Accepted
N,K = map(int,input().split())

count = 0

while N > 0:
    N = N // K 
    count += 1

print(count)
# Judge status: Accepted
N, M = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
sum_a = 0
for i in a:
    sum_a += i
if sum_a > N:
    print(-1)
else:
    print(N - sum_a)
# Judge status: Accepted
def count(l):
    res = {'a':0, 'b':0, 'c':0}
    for d in l:
        if d in res:
            res[d] += 1
        else:
            res[d] = 1
    return res

string = input()
cnt = count(string).values()
if max(cnt) - min(cnt) < 2:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
import math
a, b, h, m = map(int, input().split())
angle = abs(30*h - 5.5*m)
distance = (a*a + b*b - 2*a*b*math.cos(math.radians(angle)))
print(math.sqrt(distance))
# Judge status: Wrong Answer
r, g, b = map(int, input().split())

print("Yes" if (int("{}{}{}".format(r,g,b))) % 4 == 0 else "No")
# Judge status: Wrong Answer
A, B = map(int, input().split())
count, outlet = 0, 1
while count >= B:
  outlet += 1
  outlet += A
  count += 1
print(count)
# Judge status: Wrong Answer
n = int(input())
s = input()
t = input()

if s==t:
    print(n)
    exit()

for i in range(n):
    print(s[i:],t[:-i])
    if s[i:]==t[:-i]:
        print(2*n-(n-i))
        exit()
print(2*n)
# Judge status: Accepted
if input() == "ABC":
    print("ARC")
else:
    print("ABC")
# Judge status: Accepted
n, d = map(int, input().split())
cnt = 0
for i in range(n):
    x, y = map(int, input().split())
    if x ** 2 + y ** 2 <= d ** 2:
        cnt += 1
print(cnt)
# Judge status: Wrong Answer
import math
n,a,b = list(map(int, input().split()))
p = 10**9 + 7
ans = 0

for i in range(1,n+1):
    if i == a or i == b:
        continue
    if n >= 1*10**9:
        ans += math.factorial(n) * (math.factorial(n-i)** 5) * (math.factorial(i) ** 5)
    else:
        ans += math.factorial(n) // math.factorial(n - i) * math.factorial(i)
        print(ans)
print(ans)
# Judge status: Accepted
N, A, B = map(int, input().split())
ans = 0
for i in range(1, N+1):
    k = i
    tmp = 0
    while k > 0:
        tmp += k % 10
        k = k // 10
    if tmp >= A and tmp <= B:
        ans += i
print(ans)
# Judge status: Wrong Answer
check=[i*i for i in range(100)]
n,d=list(map(int,input().split()))

def distance(x,y):
  num=0
  for i in range(d):
    num=num+(x[i]-y[i])*(x[i]-y[i])
  return num

diff=[]
for i in range(n):
  x=list(map(int,input().split()))
  diff.append(x)

ans=0
for i in range(n-1):
  for j in range(i+1,n):
    k=distance(diff[i],diff[j])
    if k in check:
      ans+=1
  
print(ans)
# Judge status: Accepted
A,B,C=map(int,input().split())

if A==5:
  if B==5:
    if C==7:
      print("YES")
    else:
      print("NO")
  elif B==7:
    if C==5:
      print("YES")
    else:
      print("NO")
  else:
    print("NO")
elif A==7:
  if B==5 and C==5:
    print("YES")
  else:
    print("NO")
else:
  print("NO")
# Judge status: Accepted
n,m = map(int,input().split())
g = []
for _ in range(n):
    g.append([int(i) for i in input().split()])

c = []
for _ in range(m):
    c.append([int(i) for i in input().split()])

for i in range(n):
    ans = 0
    l = 10**16
    for j in range(m):
        tmp = abs(g[i][0] - c[j][0]) + abs(g[i][1] - c[j][1])
        
        if tmp < l:
            l = tmp
            ans = j + 1
            
    print(ans)
# Judge status: Accepted
loop_cnt = 10 ** 5 + 1

N = map(int, input().split())
A = [0] * (loop_cnt + 1)

A_lis = list(map(int, input().split()))
for a in A_lis:
    A[a] += 1

Q = int(input())

ans = 0

for i in range(loop_cnt):
    ans += i * A[i]

for _ in range(Q):
    B, C = map(int, input().split())
    ans += (C - B) * A[B]
    A[C] += A[B]
    A[B] = 0
    print(ans)
# Judge status: Wrong Answer
import numpy as np

n, k = map(int, input().split())
a = np.array([1] + list(map(int, input().split())))

prod_a = np.cumprod(a)

for i in range(k+1, n+1):
    score = prod_a[i] // prod_a[i-k]
    past_score = prod_a[i-1] // prod_a[i-1-k]
    print('Yes' if score > past_score else 'No')
# Judge status: Accepted
N=int(input())
a=list(map(int,input().split()))
s=sum(a)
if N==0:
    print(1 if a[0]==1 else -1)
    exit()
lim=1
ans=0
for i in range(N+1):
    ans+=lim
    if lim-a[i]<0:
        print(-1)
        exit()
    lim=(lim-a[i])*2
    s-=a[i]
    lim=min(lim,s)
print(ans)
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))
ans=0
for i in range(n):
	for j in range(i+1,n):
		for k in range(j+1,n):
			if (l[i]+l[j]>l[k] and l[j]+l[k]>l[i] and l[i]+l[k]>l[j] and l[i]!=l[j] and l[j]!=l[k] and l[k]!=l[i]):
				ans+=1

print(ans)
# Judge status: Accepted
n = int(input())
a = int(input())

if n%500 <= a:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
if int(input()) in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, 28, 30, 32, 35, 36, 42, 45, 48, 49, 50, 54, 56, 63, 64, 72, 81):
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
a=int(input())
b=int(input())
if b%500<=a:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
import math
n = int(input())
print((math.ceil(n/2))/n)
# Judge status: Accepted
x = input()
if x == 'ABC':
    print('ARC')
if x == 'ARC':
    print('ABC')
# Judge status: Accepted
def return_Lucas(num1, num2):
  return num1 + num2

n = int(input())

n1 = 2
n2 = 1
if n == 0:
  print(n1)
elif n == 1:
  print(n2)
else:  
  for i in range(2, n+1):
    n1, n2 = n2, return_Lucas(n1,n2)
    if i == n:
      print(n2)
# Judge status: Wrong Answer
def main():
  n = int(input())
  A = list(map(int, input().split()))
  
  num = [0] * n
  
  for i in range(0, n-1):
    for k in range(0, len(A)):
      if A[k] == i+1:
        num[i] += 1
      
  print(num)
  
main()