Problem:


Score : 300 points

Problem Statement

A company has N members, who are assigned ID numbers 1, ..., N.

Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number.

When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X.

You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.

Constraints

2 \leq N \leq 2 \times 10^5

1 \leq A_i < i

Input

Input is given from Standard Input in the following format:

N
A_2 ... A_N

Output

For each of the members numbered 1, 2, ..., N, print the number of immediate subordinates it has, in its own line.

Sample Input 1

5
1 1 2 2

Sample Output 1

2
2
0
0
0

The member numbered 1 has two immediate subordinates: the members numbered 2 and 3.

The member numbered 2 has two immediate subordinates: the members numbered 4 and 5.

The members numbered 3, 4, and 5 do not have immediate subordinates.

Sample Input 2

10
1 1 1 1 1 1 1 1 1

Sample Output 2

9
0
0
0
0
0
0
0
0
0

Sample Input 3

7
1 2 3 4 5 6

Sample Output 3

1
1
1
1
1
1
0



Sample input:
5
1 1 2 2


Sample output:
2
2
0
0
0

Submission status: Accepted

Solution code:
N = int(input())
An = list(map(int,input().split(' ')))
emploees = [0]*N
for i in range(N-1):
    emploees[An[i]-1] += 1
for e in emploees:
    print(e)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
h = {}
for v in a:
    if v not in h:
        h[v] = 0
    h[v] += 1

for i in range(1, n + 1):
    if i in h:
        print(h[i])
    else:
        print(0)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

buka = [0] * N

for i in range(N - 1):
    buka[A[i]-1] += 1

print('\n'.join(map(str, buka)))

Submission status: Accepted

Solution code:
N = int(input())
AA = list(map(int,input().split()))

ans = [0]*N

for a in AA:
    ans[(a-1)] +=1
    
for j in ans:
    print(j)

Submission status: Accepted

Solution code:
N = int(input())
A = tuple(map(int, input().split()))
lst = [0] * N
for a in A:
    lst[a - 1] += 1
for x in lst:
    print(x)

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int, input().split()))

ans = [0] * n
for a in A:
    ans[a-1] += 1

for a in ans:
    print(a)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
l = [0 for i in range(n)]
for i in range(len(a)):
    l[a[i] - 1] += 1
for i in range(n):
    print(l[i])

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    A = tuple(map(int, input().split()))

    ans = [0] * (n + 1)
    for a in A:
        ans[a] += 1
    print(*ans[1:], sep='\n')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)

INF = 110110110
_INFL = -INF * INF

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

ans = [0] * N

for a in A:
    ans[a-1] += 1

for a in ans:
    print(a)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int, input().split()))

s = [[] for i in range(n)]
for i in range(n-1):
    s[a[i]-1].append(i)

for i in range(n):
    print(len(s[i]))

Submission status: Accepted

Solution code:
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solve():
    n = II()
    A = LI()

    j = {}
    for a in A:
        j[a] = j.setdefault(a, 0) + 1

    # j = sorted(j.items())
    # print(j)
    for i in range(n):
        print(j.get(i+1, 0))

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
n= int(input())
# import math
# s =input()
# n,m = map(int, input().split())
a = list(map(int, input().split()))
# a,b = map(str, input().split())
# ab = [list(map(int,input().split())) for _ in range(n)]

count = [0] *n

for i in a:
    count[i-1]+=1
for i in count:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = [0]*N
for i in A:
    ans[i-1]+=1
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
List=list(map(int,input().split()))

num = [0 for i in range(N+1)]

for i in  range(len(List)):
  a = List[i]
  num[a] += 1
  
for i in range(1,N+1):
  print(num[i])

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]
c = Counter(A)
for i in range(1, N + 1):
    if i in c:
        print(c[i])
    else:
        print(0)

Submission status: Accepted

Solution code:
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	A = getlist()
	D = defaultdict(int)
	for i in range(N - 1):
		D[A[i]] += 1
	for i in range(N):
		print(D[i + 1])	
	


if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int, input().split()))
b=[0]*n
for i in a:
	b[i-1]+=1
for i in b:
	print(i)

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
D=[0 for i in range(N)]
for i in range(len(A)):
    D[A[i]-1]+=1
for i in range(len(D)):
    print(D[i])

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
lis = {i:0 for i in range(1,N+1)}
for one in A:
    lis[one]+=1
for i in range(1, N+1):
    print(lis[i])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
persons = list(map(int, input().split()))
ans = [0 for i in range(n)]
for p in persons:
    ans[p - 1] += 1
for a in ans:
    print(a)

Submission status: Accepted

Solution code:
n = int(input())
a = [int(x) for x in input().split()]

d = {x: 0 for x in range(1,n+1)}
for x in a:
    d[x] += 1

for k in d.keys():
    print(d[k])

Submission status: Accepted

Solution code:
from collections import defaultdict
n = int(input())
a = list(map(int,input().split()))
d = defaultdict(int)
for i in a:
    d[i] += 1
for i in range(1,n+1):
    print(d[i])

Submission status: Accepted

Solution code:
n = int(input())
li = list(map(int,input().split()))
ans_l=[0]*n

for i in li:
    ans_l[i-1] += 1
print(*ans_l,sep="\n")

Submission status: Accepted

Solution code:
import bisect,sys
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


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


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac =fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV
        
    return CONV()



sys.setrecursionlimit(200005)


def main():
    N= iRaw()
    As = isRaw()
    nbukas = [0]*N
    for a in As:
        nbukas[a-1]+=1
    return "\n".join([str(nb) for nb in nbukas])

if __name__ == "__main__":
    print(main())

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    from collections import defaultdict
    N = int(input())
    A = list(map(int, input().split()))
    dic = defaultdict(int)
    for i in A:
        dic[i] += 1
    for i in range(1, N+1):
        print(dic[i])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
a = Counter(map(int, input().split()))

for n in range(1, n+1):
    try:
        print(a[n])
    except:
        print(0)

Submission status: Accepted

Solution code:
N=int(input())
A = [int(i) for i in input().split()]
Buka = [0]*N
for a in A:
    Buka[a-1] += 1
print(*Buka,sep="\n")

Submission status: Accepted

Solution code:
from collections import Counter

# print('input >>')
N = int(input())
As = list(map(int,(input().split())))

c = Counter(As)

# print('-----output-----')
for i in range(1, N+1):
    print(c[i])

Submission status: Accepted

Solution code:
n, *a = map(int, open(0).read().split())
l = [0]*n
for i in a:
  l[i-1] += 1
print(*l, sep="\n")

Submission status: Accepted

Solution code:
n = int(input())
nums = list(map(int, input().split()))

childs = [0] * n
for num in nums:
    childs[num - 1] += 1
print('\n'.join(list(map(str, childs))))

Submission status: Accepted

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from math import factorial, sqrt, ceil, gcd
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    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
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定
def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True


# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret


# ここから書き始める
n = int(input())
cnt = [0 for i in range(n)]
a = list(map(int, input().split()))
for i in a:
    cnt[i - 1] += 1
for i in cnt:
    print(i)

Submission status: Accepted

Solution code:
from sys import stdin
from sys import setrecursionlimit

setrecursionlimit(10 ** 7)

n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))

li = [0]*n

for i in a:
    li[i-1] += 1

for i in li:
    print(i)

Submission status: Accepted

Solution code:
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
d = defaultdict(int)
for i in A:
    d[i] += 1
for i in range(1,N+1):
    print(d[i])

Submission status: Accepted

Solution code:
## coding: UTF-8
from decimal import *
from itertools import permutations, combinations,combinations_with_replacement,product
import math

N = int(input())
s = input().split()
p = [int(w) for w in s] #これで勝手にNまで拾ってくれます
ans_list = [0 for i in range(N)]

for i in range(len(p)):
    ans_list[p[i]-1] += 1

for i in range(N):
    print(ans_list[i])

Submission status: Accepted

Solution code:
# ABC163

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

d=[0]*n
for i in range(n-1):
    d[a[i]-1]+=1

for i in d:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
D = {i: [] for i in range(N)}
A = list(map(int, input().split()))
for i in range(N-1):
  D[A[i]-1].append(i)
for i in range(N):
  print(len(D[i]))

Submission status: Accepted

Solution code:
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

cnt = [0] * (N + 1)
for a in A:
    cnt[a] += 1

for i in range(1, N + 1):
    print(cnt[i])

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
li=[0]*n
for i in a:
  li[i-1]+=1
for i in range(n):
  print(li[i])

Submission status: Accepted

Solution code:
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft

n = int(input())
a = [int(i) - 1 for i in input().split()]
b = [[] for i in range(n)]
for i in range(n-1):
    b[a[i]].append(i)

#
# ans = [0] * n
#
#
# def solve(i):
#     if len(b[i]) == 0:
#         return 0
#     if ans[i] > 0:
#         return ans[i]
#     ret = 0
#     for k in b[i]:
#         ret += solve(k)
#     ans[i] = ret
#     return ret
#
# for i in range(n):
#     solve(i)

for i in b:
    print(len(i))

Submission status: Accepted

Solution code:
n = int(input())
li = list(map(int,input().split()))
all_li = [0 for _ in range(n)]
for i,l in enumerate(li):
    all_li[l-1] += 1
for a in all_li:
    print(a)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
joushi = [0 for _ in range(N)]
for Ai in A:
    joushi[Ai-1] += 1

for ans in joushi:
    print(ans)

Submission status: Accepted

Solution code:
n = int(input().strip())
a = list(map(int, input().split()))
dic = {}
for i in range(len(a)):
    if dic.get(a[i]):
        dic[a[i]] += 1
    else:
        dic[a[i]] = 1
for i in range(1, n + 1):
    if dic.get(i):
        print(dic[i])
    else:
        print(0)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = [0]*N

#print(ans)
for i in range(N-1):
    ans[A[i]-1] += 1
for i in range(N):
    print(ans[i])

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
res = [0]*n
for i in range(n-1):
  res[a[i]-1] += 1
print(*res)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(x)-1 for x in input().split()]
ans = [0] * N
for a in A:
    ans[a] += 1
for a in ans:
    print(a)

Submission status: Accepted

Solution code:
def main():
    from collections import defaultdict
    n=int(input())
    a=list(map(int,input().split()))
    dd=defaultdict(int)
    for i in a:
        dd[i]+=1
    for i in range(n):
        print(dd[i+1])

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int,input().split()))
ans = [0]*n
for a in A:
    ans[a-1]+=1
for a in ans:
    print(a)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
joshi_dic = {}
def add_dic(p):
    if not p in joshi_dic:
        joshi_dic[p] = 1
    else:
        joshi_dic[p] += 1

for i in a:
    add_dic(i)
for i in range(1, n+1):
    if not i in joshi_dic:
        print(0)
    else:
        print(joshi_dic[i])

Submission status: Accepted

Solution code:
n = int(input())
dat = list(map(int, input().split()))
dat.reverse()
count = [0] * (n + 1)
for i in range(n - 1):
    count[dat[i]] += 1
#print(count)
res = count[1:]
for i in range(len(res)):
    print(res[i])

Submission status: Accepted

Solution code:
i=int(input())
a=list(map(int,input().split()))
l=[0]*i
for j in a:
  l[j-1]=l[j-1]+1
print(*l)

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces

def main():
    n = ni()
    a = na()
    anss = [0 for i in range(n)]
    for i in a:
        anss[i-1] += 1
    for i in anss:
        print(i)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
inf = 10**15
mod = 10**9+7

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = [0] * (N)
for a in A:
    ans[a - 1] += 1
[print(a) for a in ans]

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

bosses = [0] * N
for a in A:
    bosses[a - 1] += 1

print(*bosses, sep='\n')

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
mo = 10**9+7

def main():
	n = II()
	a = LI()
	ans = [0]*n
	for aa in a:
		ans[aa-1]+=1
	printV(ans)


if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
subs = [0] * (n + 1)
for i in a:
    subs[i] += 1
for j in subs[1:]:
    print(j)

Submission status: Accepted

Solution code:
import sys

# S = input()
# N, M = map(int, input().split())
# As = [int(input()) for _ in range(N)]
# nums = list(map(int, input().split()))
# nums_2d = [list(map(int, input().split())) for _ in range(N)]


def main():
    solve()


def solve():
    N = int(input())
    As = list(map(int, input().split()))

    dc = dict()

    for i in range(N):
        dc[i+1] = 0

    for i, a in enumerate(As):
        dc[a] += 1

    for value in dc.values():
        print(value)

    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))

sub = [0 for _ in range(n)]
for i,j in zip(range(2,n+1),a):
    sub[j-1] += 1
for i in sub:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
ki = [[] for i in range(n)]
for i in range(n-1):
    ki[a[i]-1].append(i+1)
    ki[i+1].append(a[i]-1)
for i in range(n):
    if i == 0:
        print(len(ki[i]))
        continue
    print(len(ki[i])-1)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))

lst = [0 for i in range(n+1)]
for i in range(n-1):
    lst[a[i]] += 1
for i in range(1, n+1):
    print(lst[i])

Submission status: Accepted

Solution code:
from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json
# import numpy as np
import bisect
import sys
import math
import bisect
from functools import lru_cache

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7
INF = 10 ** 17


def main():
    N = int(input())
    # N,M = [int(a) for a in input().split()]
    A = [int(a) for a in input().split()]
    res = [0] * N

    for i in range(1, N):
        joushi = A[i - 1]
        res[joushi - 1] += 1

    for a in res:
        print(a)

    # @lru_cache(None)
    # def f(i, j):
    #     if i < 0 or j < 0:
    #         return -INF
    #     if i == 0:
    #         return -INF
    #     if abs(j - i // 2 - 1) >= 2:
    #         return -INF
    #     if j == 0:
    #         return 0
    #     if j == 1:
    #         return max(A[:i])
    #     return max(A[i - 1] + f(i - 2, j - 1), f(i - 1, j))
    #
    # print(f(N, math.floor(N / 2)))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
arr = list(map(int, input().split()))
ans = [0]*(N+1)
for i in range(N-1):
    ans[arr[i]] += 1
for i in range(1,N+1):
    print(ans[i])

Submission status: Accepted

Solution code:
n = int(input())
a_list = list(map(int, input().split()))
ret_list = [0] * n

for i in range(len(a_list)):
    ret_list[a_list[i]-1] += 1

for item in ret_list:
    print(item)

Submission status: Accepted

Solution code:

import heapq
from collections import defaultdict, deque
from math import ceil, factorial, gcd
from itertools import accumulate
import sys
import bisect
import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))

# ----------

N = ii()
A = lmii()

buka = defaultdict(int)

for a in A:
    buka[a] += 1

for i in range(1, N+1):
    print(buka[i])

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 15
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

n = I()
G = [[] for _ in range(n)]
A = LI()
for i in range(n - 1):
    G[A[i] - 1] += [i - 1]

for j in range(n):
    print(len(G[j]))

Submission status: Accepted

Solution code:
import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]

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

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

for a in A:
    ans[a-1] += 1

print(*ans, sep='\n')

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    N=ii()
    A=lmis()
    d=defaultdict(int)
    for a in A:
        a -= 1
        d[a]+=1
    for i in range(N):
        print(d[i])



main()

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
l = [0 for i in range(n)]
for i in range(n-1):
    l[a[i]-1] += 1
for i in l:
    print(i)

Submission status: Accepted

Solution code:
from math import sqrt,ceil




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

m=[0]*(n+1)
for i in a:
    m[i]+=1
m=m[1:]

for i in m:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
alist = [0]*N

for i in range(N-1):
    a = A[i]
    alist[a-1] += 1
    
for i in range(N):
    print(alist[i])

Submission status: Accepted

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

from collections import defaultdict

d = defaultdict(int)
for i in range(len(A)):
    d[A[i]] += 1

for i in range(1, N+1):
    print(d[i])

Submission status: Accepted

Solution code:
import collections
n=int(input())
a=list(map(int,input().split()))
c = collections.Counter(a)
for i in range(1,n+1):
  print(c[i])

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

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

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

for i in range(N-1):
    mm = A[i]-1
    ans[mm] += 1

print(*ans,sep="\n")

Submission status: Accepted

Solution code:
N = int(input())
L=list(map(lambda x:int(x)-1,input().split()))

ins=[0]*N
for l in L:
    ins[l]+=1

print("\n".join(map(str,ins)))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))

ans = [0]*n

for i in range(n-1):
    ans[a[i]-1]+=1

print('\n'.join(map(str, ans)))

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
counter = Counter(A)
for i in range(1, N+1):
    print(counter[i])

Submission status: Accepted

Solution code:
n = int(input())
l=list(map(int,input().split()))
d={i:0 for i in range(1,n+1)}
for i in l:
    d[i]=d[i]+1
for i in d:
    print(d[i])

Submission status: Accepted

Solution code:
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

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

Submission status: Accepted

Solution code:
from collections import defaultdict

N, = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
graph = defaultdict(list)
for i, x in enumerate(A, 2):
    graph[x].append(i)
for i in range(1, N + 1):
    print(len(graph[i]))

Submission status: Accepted

Solution code:
n=int(input())

t = list(map(int,input().split()))

memo = [0]*n

for i in t:
    memo[i-1] += 1

for j in memo:
    print(j)

Submission status: Accepted

Solution code:
N = int(input())
l = list(map(int, input().split()))

ans = [0] * N

for i in range(len(l)):
    ans[l[i] - 1] += 1

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(int(1E+7))
N = int(input())
A = list( map(int,input().split()))
cnt = [0] * N
for a in A:
    cnt[a-1]+=1
for n in range(N):
    print (cnt[n])

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

ans = [0]*N
for i, a in enumerate(A):
    ans[a-1] += 1

print(*ans, sep="\n")

Submission status: Accepted

Solution code:
N = int(input())
A = map(int,input().split())

res = [0]*N
for a in A:
    res[a-1] += 1
print(*res, sep='\n')