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

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

dp=[[[None for i in range(n*X+1)] for h in range(n+1)] for g in range(n+1)]
for j in range(n+1):
    for k in range(n+1):
        for s in range(n*X+1):
            if j==0 and k==0 and s==0:
                dp[j][k][s]=1
            elif j>=1 and x[j-1]>s:
                dp[j][k][s]=dp[j-1][k][s]
            elif j>=1 and k>=1 and x[j-1]<=s:
                dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-x[j-1]]
            else:
                dp[j][k][s]=0
                
ans=0
for i in range(1,n+1):
    ans+=dp[n][i][i*a]

print(ans)

### FIXED CODE ###

n,a=map(int,input().split())
x=list(map(int,input().split()))
X=max(max(x),a)
y=[]
for i in x:
    y.append(i-a)
dp=[[None for i in range(2*n*X+1)] for h in range(n+1)]
for j in range(n+1):
    for t in range(2*n*X+1):
            if j==0 and t==n*X:
                dp[j][t]=1
            elif j>=1 and (t-y[j-1]<0 or t-y[j-1]>2*n*X):
                dp[j][t]=dp[j-1][t]
            elif j>=1 and t-y[j-1]>=0 and t-y[j-1]<=2*n*X:
                dp[j][t]=dp[j-1][t]+dp[j-1][t-y[j-1]]
            else:
                dp[j][t]=0
                
print(dp[n][n*X]-1)
### BUGGY CODE ###

import math

n = int(input())

def xyz(n):
    count = 0
    for i in range(1, int(math.sqrt(n))):
        for j in range(1, int(math.sqrt(n))):
            for k in range(1, int(math.sqrt(n))):
                zyx = i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i
                if zyx == n:
                    count += 1
    return count


for i in range(n):
    print(xyz(i + 1))

### FIXED CODE ###

n = int(input())
ans = [0]*10**5


def xyz():
    count = 0
    for i in range(1, 101):
        for j in range(1, 101):
            for k in range(1, 101):
                zyx = i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i
                ans[zyx] += 1


xyz()
for i in range(n):
    print(ans[i+1])
### BUGGY CODE ###

n = int(input())
s = set()

for i in range(n):
    s = s ^ {input()}

print(len(s))

### FIXED CODE ###

import sys
input = sys.stdin.readline

import bisect

def main():
    n = int(input())
    s = []

    for i in range(n):
        a = int(input())
        i = bisect.bisect_left(s, a)
        if len(s) > i and s[i] == a:
            s.remove(a)
        else:
            s.insert(i, a)


    print(len(s))


main()
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
p = 1
for i in range(n):
    p *= a[i]
if p > 10**18:
    print("-1")
else:
    print(p)

### FIXED CODE ###

def main():
    n = int(input())
    a = list(map(int, input().split()))
    if 0 in a:
        print(0)
        return
    prod = 1
    for i in a:
        prod *= i
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod)
main()
### BUGGY CODE ###

#D問題
A,B,Q = map(int,(input().split()))
si = [-(10**10)]+[int(input()) for _ in range(A)]+[2*(10**10)] # 範囲外に追加して、xの左右に常にデータがあるようにする
ti = [-(10**10)]+[int(input()) for _ in range(B)]+[2*(10**10)]
A +=2
B +=2

for _ in [0]*Q:
    x = int(input())
    l = 0
    r = A-1
    while l+1<r:
        i = (l+r)//2
        if si[i]<x:
            l = i
        else:
            r = i
    sl = si[l]
    sr = si[r]
    
    l = 0
    r = B-1
    while l+1<r:
        i = (l+r)//2
        if ti[i]<x:
            l = i
        else:
            r = i
    tl = ti[l]
    tr = ti[r]
    dsl = x-sl
    dsr = sr-x
    dtl = x-tl
    dtr = tr-x
    print(min(max(dsr,dtr),max(dsl,dtl),dsl+dtr+min(dsl,dtr),dsr+dtl+min(dsr,dtl)))

### FIXED CODE ###

A,B,Q = map(int,(input().split()))
si = [-(10**10)]+[int(input()) for _ in range(A)]+[2*(10**10)]
ti = [-(10**10)]+[int(input()) for _ in range(B)]+[2*(10**10)]
xi = [(i,int(input())) for i in range(Q)]
A +=2
B +=2

#xを小さい順に考える
xi.sort(key = lambda x:x[1])
ans = [0]*Q
x = xi[0][1]
for i_sr,sr in enumerate(si):
    if sr>x:
        sl = si[i_sr-1]
        break
for i_tr,tr in enumerate(ti):
    if tr>x:
        tl = ti[i_tr-1]
        break
for i,x in xi:
    while sr < x:
        sl = sr
        i_sr += 1
        sr = si[i_sr]
    while tr < x:
        tl = tr
        i_tr += 1
        tr = ti[i_tr]
    dsl = x-sl
    dsr = sr-x
    dtl = x-tl
    dtr = tr-x
    ans[i] = min(max(dsr,dtr),max(dsl,dtl),dsl+dtr+min(dsl,dtr),dsr+dtl+min(dsr,dtl))
for out in ans:
    print(out)
### BUGGY CODE ###

h,w=map(int, input().split())
ch,cw=map(int, input().split())
ch-=1
cw-=1
dh,dw=map(int, input().split())
dh-=1
dw-=1
grid=[]
es=[[] for _ in range(h*w)]

for i in range(h):
    s=list(input())
    news=[-1 if x=='#' else 0 for x in s]
    grid.append(news)
dif=set([(1,0),(-1,0),(0,1),(0,-1)])
warp=set([(i,j) for i in range(-2,3) for j in range(-2,3)])
warp=warp.difference(dif.union({(0,0)}))
dif=list(dif)
warp=list(warp)

for i in range(h):
    for j in range(w):
        if grid[i][j]!=-1:
            for d in dif:
                if 0<=i+d[0]<h and 0<=j+d[1]<w and grid[i+d[0]][j+d[1]]!=-1:
                    es[i*w+j].append([(i+d[0])*w+j+d[1], 0])
            for d in warp:
                if 0<=i+d[0]<h and 0<=j+d[1]<w and grid[i+d[0]][j+d[1]]!=-1:
                    es[i*w+j].append([(i+d[0])*w+j+d[1], 1])

from heapq import heappush, heappop
def dijkstra(edges, size, source):
    distance = [float('inf')] * size
    distance[source] = 0
    visited = [False] * size
    pq = []
    heappush(pq, (0, source))
    while pq:
        dist_v, v = heappop(pq)
        visited[v] = True
        for u, weight in edges[v]:
            if not visited[u]:
                new_dist = dist_v + weight
                if distance[u] > new_dist:
                    distance[u] = new_dist
                    heappush(pq, (new_dist, u))
    return distance

dist=dijkstra(es,h*w,ch*w+cw)
if dist[dh*w+dw]==float('inf'):
    print(-1)
else:
    print(dist[dh*w+dw])

### FIXED CODE ###

h,w=map(int, input().split())
ch,cw=map(int, input().split())
ch-=1
cw-=1
dh,dw=map(int, input().split())
dh-=1
dw-=1
grid=[]
for i in range(h):
    s=list(input())
    news=[-1 if x=='#' else 0 for x in s]
    grid.append(news)
dif=[(1,0),(-1,0),(0,1),(0,-1)]
from collections import deque
col=0
for i in range(h):
    for j in range(w):
        if grid[i][j]==0:
            col+=1
            stack=deque([(i,j)])
            grid[i][j]=col
            while stack:
                nowi,nowj=stack.popleft()
                for di,dj in dif:
                    if 0<=nowi+di<h and 0<=nowj+dj<w and grid[nowi+di][nowj+dj]==0:
                        stack.append((nowi+di,nowj+dj))
                        grid[nowi+di][nowj+dj]=col
start=grid[ch][cw]-1
end=grid[dh][dw]-1
if start==end:
    print(0)
    exit()
es=[set([]) for _ in range(col)]
visited=[-1]*col

for i in range(h):
    for j in range(w):
        now=grid[i][j]
        if now!=-1: 
            for x in range(-2, 3):
                for y in range(-2, 3):
                    if 0<=i+x<h and 0<=j+y<w:
                        nex=grid[i+x][j+y]
                        if nex!=-1 and now!=nex:
                            es[now-1].add(nex-1)

stack=deque([start])
visited[start]=0
while stack:
    now=stack.popleft()
    for e in es[now]:
        if visited[e]==-1:
            visited[e]=visited[now]+1
            stack.append(e)
#print(grid)
print(visited[end])
### BUGGY CODE ###

import bisect
A, B, Q = map(int, input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
X = [int(input()) for _ in range(Q)]

for x in X:
    SL, SR, TL, TR = 10**20, 10**20, 10**20, 10**20
    i = bisect.bisect_left(S, x)
    if i != 0:
        SL = x-S[i-1]
    if i != A:
        SR = S[i]-x

    j = bisect.bisect_left(T, x)
    if j != 0:
        TL = x-T[j-1]
    if j != B:
        TR = T[j]-x

    ans = min(max(SL, TL), min(2*SL+TR, SL+2*TR),
              min(2*TL+SR, TL+2*SR), max(SR, TR))
    print(ans)


### FIXED CODE ###

import bisect
A, B, Q = map(int, input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
X = [int(input()) for _ in range(Q)]

for x in X:
    p0, p1, p2, p3 = (10**12 for _ in range(4))
    si = bisect.bisect_left(S, x)
    ti = bisect.bisect_left(T, x)

    if si != 0 and ti != 0:
        p0 = max(x-S[si-1], x-T[ti-1])
    if si != 0 and ti != B:
        p1 = min(x-S[si-1], T[ti]-x)*2+max(x-S[si-1], T[ti]-x)
    if si != A and ti != 0:
        p2 = min(S[si]-x, x-T[ti-1])*2+max(S[si]-x, x-T[ti-1])
    if si != A and ti != B:
        p3 = max(S[si]-x, T[ti]-x)
    print(min(p0, p1, p2, p3))
### BUGGY CODE ###

N = int(input())
A = []

for i in range(N):
    Ai = int(input())
    if Ai in A:
        A.remove(Ai)
    else:
        A.append(Ai)

print(len(A))


### FIXED CODE ###

N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
A.sort()
ans = 0
cnt = 1
for i in range(1, N):
    if A[i] == A[i-1]:
        cnt += 1
    else:
        ans += cnt%2
        cnt = 1
ans += cnt%2
print(ans)
### BUGGY CODE ###

s = input()
x = []

for i in range(0,len(s)):
  for j in range(i,len(s)):
    if(s[i] == "A" and s[j] =="Z"):
      x.append(len(s[i:j+1]))
      
print(max(x))

### FIXED CODE ###

s = input()
i = 0
j = len(s) - 1
t1 = []
t2 = []

while True:
  #print(i,j)
  if(s[i] == "A"):
    t1.append(i)
    #print(t1)
  if(s[j] == "Z"):
    t2.append(j)
  if(len(t1) != 0 and len(t2) != 0):
    break
  i += 1
  j -= 1
  
print(t2[0]-t1[0] +1)
### BUGGY CODE ###

import itertools

n = int(input())
s = []
textSet = set()
ans = 0

for i in range(n):
    s.append(''.join(sorted(input())))

s.sort()

# print(s)
cnt = 0

for i in range(1, n):
    if s[i] == s[i-1]:
        cnt += 1
    elif cnt > 0:
        # ans += cntC2
        ans += len(list(itertools.combinations(range(cnt+1), 2)))
        cnt = 0

if cnt > 0:
    ans += len(list(itertools.combinations(range(cnt + 1), 2)))

print(ans)

### FIXED CODE ###

import itertools

n = int(input())
s = []
textSet = set()
ans = 0

for i in range(n):
    s.append(''.join(sorted(input())))

s.sort()

# print(s)
cnt = 0

for i in range(1, n):
    if s[i] == s[i-1]:
        cnt += 1
    elif cnt > 0:
        # ans += cntC2
        # ans += len(list(itertools.combinations(range(cnt+1), 2)))
        ans += (cnt + 1) * cnt // 2
        cnt = 0

if cnt > 0:
    # ans += len(list(itertools.combinations(range(cnt + 1), 2)))
    ans += (cnt + 1) * cnt // 2

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

n=int(input())
a=list(map(int,input().split()))
#print(n)
#print(a)
count=0
flag=True
while(flag):
    flag=False
    for i in range(n):
        if(a[i]%2==0):
            #print(i)
            #a=list(map(lambda x:x*3,a))
            a[i]=int(a[i]/2)
            #print(a)
            count+=1
            flag=True
            break
print(count)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
#print(n)
#print(a)
count=0
flag=True
while(flag):
    flag=False
    for i in range(n):
        while(a[i]%2==0):
            #print(i)
            #a=list(map(lambda x:x*3,a))
            a[i]=int(a[i]/2)
            #print(a)
            count+=1
            flag=True
            #break
print(count)
#たぶんリスト全部に3かけて該当を６で割ればよさそう
#３倍する必要がない
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import collections
N,X,Y = map(int,input().split())
ToltN=N*(N-1)/2
Dist=[[0 for i in range(N)] for i in range(N)]
for i in range(N):
    for j in range(i,N):    
        MyDist=abs(i-(X-1))+abs(j-(Y-1))+1
        if MyDist<j-i:
            Dist[i][j]=MyDist
        else:
            Dist[i][j] = j-i
for j in range(N-1):
    ans=[0]
    for i in range(N):
        ans+=Dist[i]
c = collections.Counter(ans)
for i in range(N-1):
    print(c[i+1])


### FIXED CODE ###

# -*- coding: utf-8 -*-
import collections
N,X,Y = map(int,input().split())
ToltN=N*(N-1)/2
Dist=[[0 for i in range(N)] for i in range(N)]
c=[0]*N
for i in range(N):
    for j in range(i+1,N):
        MyDist=abs(i-(X-1))+abs(j-(Y-1))+1
        if MyDist<j-i:
            Dist[i][j]=MyDist
            c[MyDist-1]+=1
        else:
            Dist[i][j] = j-i
            c[j-i-1]+=1
for i in range(N-1):
    print(c[i])
### BUGGY CODE ###

import sys
from collections import defaultdict, deque

input = sys.stdin.readline

def chmax(a, b):
    if a > b:
        return a
    else:
        return b

def main():
    N, W = map(int, input().split())
    f_inf = float('inf')
    # DP テーブルを初期化　(最小化問題なので INF に初期化)
    MAX_N = 110000
    dp = [0] * (W + 1)


    for _ in range(N):
        w, v = map(int, input().split())
        for sum_w in range(W, w-1, -1):
            if sum_w - w >= 0:
                dp[sum_w] = chmax(dp[sum_w], dp[sum_w - w] + v)
    print(dp[-1])

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from collections import defaultdict, deque

input = sys.stdin.readline


def main():
    N, W = map(int, input().split())
    f_inf = float('inf')
    # DP テーブルを初期化　(最小化問題なので INF に初期化)
    MAX_N = 110000
    dp = [0] * (W + 1)


    for _ in range(N):
        w, v = map(int, input().split())
        for sum_w in range(W, w-1, -1):
            tv = dp[sum_w - w] + v
            if tv > dp[sum_w]:
                dp[sum_w] = tv
    print(dp[-1])

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


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

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

def right(N, A):
    X = [0] * N
    for i in range(N):
        X[i] = abs(A[i] - (i+1))

    return max(X)

r = right(N, A)
#print(r)

ans = float('inf')
for b in range(-r, r+1):
    c = 0
    for i in range(1, N+1):
        c += abs(A[i-1] - (b+i))

    ans = min(ans, c)

print(ans)

### FIXED CODE ###



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

N = int(input())
A = list(map(int, input().split()))
a = [0] * len(A)

# bの値は中央値
# https://qiita.com/Noiri/items/291ae9bf4a2eacab6f5f
for i in range(N):
    a[i] = A[i]-i-1

a.sort()
b = a[N // 2 - 1] if (N % 2 == 0) else a[(N + 1) // 2 - 1]

ans = 0
for i in range(N):
    ans += abs(a[i] - b)

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

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

sort = []
count = 1
for i in range(len(A)):
    for i,a in enumerate(A):
        if a == count:
            sort.append(i+1)
            count += 1
            break
sort = [str(s) for s in sort]
print(" ".join(sort))

### FIXED CODE ###

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

sort = [0 for i in range(N)]
count = 1

for i, a in enumerate(A):
    sort[a-1] = i+1

sort = [str(s) for s in sort]
print(" ".join(sort))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import fractions
import sys
input = sys.stdin.readline


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 set(divisors)


def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [i for i in range(1, n+1) if is_prime[i-1]]
    return is_prime, table


def main():
    a, b = map(int, input().split())

    divisors = []
    max_divisor = fractions.gcd(a, b)

    divisors = make_divisors(max_divisor)
    _, table = sieve(max(divisors))
    result = divisors & set(table)

    size = len(result) + 1
    print(size)


if __name__ == '__main__':
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import math
import fractions


def prime_factorization(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n = n // i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return list(set(table))


def main():
    a, b = map(int, input().split())

    gcd = fractions.gcd(a, b)
    table = prime_factorization(gcd)
    print(len(table) + 1)


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

n = int(input())
s = input()
ans = 0

for i in range(n):
    for j in range(i+1, n+1):
        if (s[i:j] in s[j:]) == True and ans < len(s[i:j]):
            ans = len(s[i:j])
print(ans)

### FIXED CODE ###

n = int(input())
s = input()
high = n//2
low = 1
ans = 0

while low <= high:
    t = set()
    i = (high+low)//2
    for j in range(n-i*2+1):
        t.add(s[j:i+j])
        if s[i+j:j+2*i] in t:
            if ans < i:
                ans = i
                low = i+1
                break
    if ans < i:
        high = i-1
print(ans)
### BUGGY CODE ###

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

count = 0
for K in range(min(d),max(d)+1):
    ARC = [i for i in d if i >= K]
    ABC = [j for j in d if j < K]
    if len(ARC) == len(ABC):
        count += 1
print(count)

### FIXED CODE ###

N = int(input())
d = list(map(int,input().split()))
d_sorted = sorted(d, reverse = False)

count = d_sorted[(N-1) //2 + 1] - d_sorted[(N-1) // 2]
print(count)
### BUGGY CODE ###

n,k,*a=map(int,open(0).read().split())
for _ in range(min(k,99)):
  b=[0]*n
  for i,q in enumerate(a):
    b[max(0,i-q)]+=1
    if (r:=i+q+1)<n:
      b[r]-=1
  for i in range(1,n):
    b[i]+=b[i-1]
  a=b[:]
print(*a)

### FIXED CODE ###

# coding: utf-8
# Your code here!
import time
t1=time.time()
def LI():return list(map(int,input().split()))
n,k=LI()
a=LI()

for _ in range(k):
    tab=[0]*(n)
    for i in range(n):
        q=a[i]
        if 0<=i-q:
            tab[i-q]+=1
        else:
            tab[0]+=1
        if i+q+1<=n-1:
            tab[i+q+1]-=1
        else:
            pass
    b=[tab[0]]
    for i in range(n-1):
        b.append(tab[i+1]+b[-1])
    a=b[:]
    if time.time()-t1>1.5:
        print(*a)
        exit()
print(*a)
### BUGGY CODE ###

#import numpy as np
N = int(input())
M = list(map(int, input().split()))
result = 0
for i in range(N):
  x = M[i]
  #print(i, x)
  result += len([1 for m,n in enumerate(range(i+x+1, N)) if m+1 == M[n]])
print(result)


### FIXED CODE ###

N = int(input())
M = list(map(int, input().split()))
L = [0] * N
R = [0] * N
for i,m in enumerate(M):
  if i+m >= N:
    continue
  L[i+m] += 1
for i,m in enumerate(M[::-1]):
  if i+m >= N:
    continue
  R[i+m] += 1
R = R[::-1]
#print(L)
#print(R)
print(sum([l*r for l,r in zip(L,R)]))
### BUGGY CODE ###

#from functools import lru_cache
import sys
def vfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:f(*x,**kwargs),*lst))

def reader():return vfunc(lambda l:l.split())(sys.stdin.readlines())

n=int(reader()[0][0])
a=[]
for i in range(200001):
    a.append(n%10)
    n//=10
print('Yes' if sum(a)%9==0 else 'No')

### FIXED CODE ###

#from functools import lru_cache
import sys
def vfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:f(*x,**kwargs),*lst))

def reader():return vfunc(lambda l:l.split())(sys.stdin.readlines())

n=reader()[0][0]
i=vfunc(lambda n:int(n))(n)
print('Yes' if sum(i)%9==0 else 'No')
### BUGGY CODE ###

K,S = list(map(int,input().split()))

x=0
count = 0

if S>K: n=K+1
else: n=S+1
for i in range(n):
	y=0
	while S-x>=0 and S-x<=2*K:
		if S-x-y>=0 and x<=K and y<=K and S-x-y<=K: count+=1
		if y>K: break
		y+=1
	x+=1

print(count)


### FIXED CODE ###

K,S = list(map(int,input().split()))

count = 0

if K>S: n=S
else: n=K
x=0
for i in range(n+1):
	if K>S-x: m=S-x
	else: m=K
	y=0
	for j in range(m+1):
		if S-x-y<=K: count +=1
		y+=1
	x+=1

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

n, k= map(int, input().split())
h = list(map(int, input().split()))
h = [0] + h

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

for i in range(1, n+1):
  for d in range(1, k+1):
    if i > d:
      dp[i] = min(dp[i], dp[i - d] + abs(h[i] - h[i - d]))

print(dp[n])

### FIXED CODE ###

n, k= map(int, input().split())
h = list(map(int, input().split()))
h = [0] + h

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

for i in range(1, n+1):
  for d in range(1, k+1):
    if i > d:
      dp[i] = min(dp[i], dp[i - d] + abs(h[i] - h[i - d]))

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

n=int(input())

ans=1
for i in range(1,n+1):
  ans*=i
print(ans%(10**9+7))

### FIXED CODE ###

n=int(input())

ans=1
for i in range(1,n+1):
  ans=(ans*i)%(10**9+7)
print(ans)
### BUGGY CODE ###

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

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

### FIXED CODE ###

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

P = [0]*N
for i in range(N-1):
    P[A[i]-1] += 1

for i in range(N):
    print(P[i])
### BUGGY CODE ###

N, Q = map(int, input().split())
query = []
for i in range(Q):
    v, w = map(int, input().split())
    if v > w:
        v, w = w, v
    query.append((v - 1, w - 1))


def f(v, w):
    L = set()
    L.add(0)
    while w != 0:
        L.add(w)
        w = (w - 1) // N
    while v != 0:
        if v in L:
            return v + 1
        v = (v - 1) // N
    return 1


for v, w in query:
    print(f(v, w))


### FIXED CODE ###

import sys
N, Q = map(int, input().split())
query = []
for i in range(Q):
    v, w = map(int, input().split())
    if v < w:
        v, w = w, v
    query.append((v - 1, w - 1))


def f(v, w):
    L = set()
    L.add(0)
    while w != 0:
        L.add(w)
        w = (w - 1) // N
    while v != 0:
        if v in L:
            return v + 1
        v = (v - 1) // N
    return 1

if N==1:
    for v, w in query:
        print(w+1)
    sys.exit()
for v, w in query:
    print(f(v, w))
### BUGGY CODE ###

value_list = []
number_of_test = int(input())
while True:
	try:
		value = int(input())
		if value in value_list:
			value_list.remove(value)
		else:
			value_list.append(value)
	except EOFError:
		break
print(len(value_list))


### FIXED CODE ###

import collections

cnt = int(input())
array = []
for i in range(cnt):
    array.append(int(input()))
cnt_dict = collections.Counter(array)

res = 0
for j in cnt_dict.values():
    if j % 2 != 0:
        res += 1
print(res)
### BUGGY CODE ###

def all_you_can_eat(n, t, a, b):
    dp = [[0 for _ in range(2)] for _ in range(t)]
    for x in range(n):
        for i in reversed(range(t)):
            if i + a[x] < t:
                dp[i + a[x]][0] = max(dp[i + a[x]][0], dp[i][0] + b[x])
                dp[i + a[x]][1] = max(dp[i + a[x]][1], dp[i][1] + b[x])
            dp[i][1] = max(dp[i][1], dp[i][0] + b[x])
    return dp[t-1][1]


def solve():
    n, t = map(int, input().split())
    a = [0 for _ in range(n)]
    b = [0 for _ in range(n)]
    for i in range(n):
        a[i], b[i] = map(int, input().split())

    print(all_you_can_eat(n, t, a, b))


if __name__ == "__main__":
    solve()


### FIXED CODE ###

import numpy as np


def solve():


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

    A = []
    B = []

    for _ in range(N):
        A_temp, B_temp = map(int, input().split())
        A.append(A_temp)
        B.append(B_temp)

    A = np.array(A, np.int)
    B = np.array(B, np.int)

    idx = np.argsort(A)
    A = A[idx]
    B = B[idx]

    dp = np.zeros((N, T), np.int)

    for i in range(N - 1):
        dp[i + 1, :A[i]] = dp[i, :A[i]]
        dp[i + 1, A[i]:] = np.maximum(dp[i, A[i]:], dp[i, :-A[i]] + B[i])

    print(np.max(dp[:, -1] + B))


if __name__ == "__main__":
    solve()
### BUGGY CODE ###

N = int(input())
As = list(map(int, input().split()))
preans = [n for n in range(N)]
for n in range(1, N):
    preans[n] = As[n-1] - 1
del preans[0]
for n in range(N):
    print(preans.count(n))

### FIXED CODE ###

N = int(input())
As = list(map(int, input().split()))
preans = [0 for _ in range(N)]
for a in As:
    preans[a-1] += 1
for n in preans:
    print(n)