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:
def resolve():
    n = int(input())
    A = list(map(int,input().split()))
    ans = [0]* n
    for i in range(n-1):
        joushi = A[i]
        ans[joushi-1] += 1
    
    for i in range(n):
        print(str(ans[i]))
 
resolve()

Submission status: Accepted

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

au = [ 0 ] * n
for ai in a:
    au[ ai-1 ] += 1

for aui in au:
    print( aui )

Submission status: Accepted

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

for i in A:
    D[i-1] += 1

for i in range(len(D)):
    print(D[i])

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())

A = list(map(int, input().split()))
         
c = [0 for i in range(N)]

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

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

Submission status: Accepted

Solution code:

n=int(input())
a=list(map(int,input().split()))
dict={}
for i in range(1,n+1):
    dict[i]=0
for x in a:
    dict[x]+=1
for v in dict.values():
    print(v)

Submission status: Accepted

Solution code:
n = int(input())
a = input().split()
b = [str(i) for i in range(1, n+1)]
d = {}

for s in a:
  if s in d:
    d[s] = d[s] + 1
  else:
    d[s] = 1

for i in b:
  if i in d:
    print(d[i])
  else:
    print(0)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from collections import Counter

emproyee_num = int(input())
bosses = list(map(int, input().split()))
boss_counter = Counter(bosses)

for i in range(1, emproyee_num+1):
    print(boss_counter[i])

Submission status: Accepted

Solution code:
n = int(input())
res_list = []
for _ in range(n):
    res_list.append(0)

a_list = list(map(int, input().split())) 
for a in a_list:
    res_list[a-1]+=1

for res in res_list:
    print(res)

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 range(n):
    print(ans[i])

Submission status: Accepted

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


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

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

Submission status: Accepted

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

junior=[0]*N
for j in range(N-1):
    junior[li[j]-1]+=1

for k in range(N):
    print(junior[k])

Submission status: Accepted

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

for i in range(n):
    print(a[i+1])

Submission status: Accepted

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

for i in range(n):
    print(e[i])

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()))
ans = [0 for _ in range(n)]
for a in A:
    ans[a-1] += 1
for ans_v in ans:
    print(ans_v)

Submission status: Accepted

Solution code:
N=int(input())
A=[int(v) for v in input().split()]
B = [0]*(N+1)
for a in A:
  B[a]+=1
for b in B[1:]:
  print(b)

Submission status: Accepted

Solution code:
from typing import List
from collections import defaultdict

def management(N: int, A_i: List[int]):
    sub_dict = defaultdict(set)

    for i in range(2, N+1):
        sub_dict[A_i[i]].add(i)

    def get_sub_num(i):
        # if len(sub_dict[i]):
        #     return len(sub_dict[i]) + sum([get_sub_num(j) for j in sub_dict[i]])
        return len(sub_dict[i])

    for i in range(1, N+1):
        print(get_sub_num(i))

if __name__ == '__main__':
    N = int(input())
    A_i = [0, 0] + list(map(int, input().split()))
    management(N, A_i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import os
import bisect, collections, copy, itertools, math, string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int, input().split()))
def LS(): return list(input().split())

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

	dic = {}
	for i in range(n):
		dic.setdefault(i+1, 0)

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

	for key in dic:
		print(dic[key])
	
if __name__ == '__main__':
	solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

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

counter = collections.Counter(A)
for i in range(1, N + 1):
    print(counter[i])

Submission status: Accepted

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

for j in range(n):
    print(ans[j])

Submission status: Accepted

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

N = int(input())
A = list(map(int, input().split()))
sheet = [0]*(N)
for i in range(N-1):
    sheet[A[i]-1]=sheet[A[i]-1]+1


for i in range(N):
    print("{}".format(sheet[i]))

Submission status: Accepted

Solution code:
s = input()

j = [0]*int(s)

a = list(map(int,input().split()))
for i in  range(int(s)-1):
    j[a[i]] += 1
for i in range(len(j)-1):
    print(j[(i+1)])

print(0)

Submission status: Accepted

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
ans = [0 for i in range(n)]
c = 1
if n==2:
  ans[0] = 1
for i in range(1,n-1):
  if a[i]==a[i-1]:
    c += 1
  else:
    ans[a[i-1]-1] = c
    c = 1
  if i==n-2:
    ans[a[i]-1] = c
  
for i in range(n):
  print(ans[i])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    strA = input()
    listA = strA.split(" ")

    X = [0] * N
    for i in range(0, N-1):
        X[int(listA[i])-1] += 1

    for j in X:
        print(j)

if __name__ == '__main__':
    main()

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
print(*li, sep="\n")

Submission status: Accepted

Solution code:
n = int(input())

A = [int(x) for x in input().split()]
B = {}

for a in A:
    if a not in B:
        B[a] = 0
    B[a] += 1

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

Submission status: Accepted

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

for i in range(len(number)):
    a[number[i]-1]+=1


for j in range(N):
    print(a[j])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import defaultdict
N = int(input())
A = [int(n) for n in input().split()]

d = defaultdict(int)
for i in A:
    d[i-1] += 1
for n in range(N):
    print(d[n])

Submission status: Accepted

Solution code:
# 1,2 .. n 社員番号
# 上司は部下より社員番号が小さい
# 入力は上司の社員番号

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

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

for i in range(1,n+1):
  print(x[i])

Submission status: Accepted

Solution code:
N=int(input())
src=list(map(int,input().split()))
T=[0]*N
for s in src:
  T[s-1]+=1
for t in T:
  print(t)

Submission status: Accepted

Solution code:
n=int(input())
buka = [0]*n
for joushi in input().split():
  buka[int(joushi)-1] += 1
print(*buka,sep='\n')

Submission status: Accepted

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

tmp = [0 for _ in range(N)]
for i in range(len(A)):
  tmp[A[i]-1] += 1

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
input = lambda: sys.stdin.readline().strip()

def main():
    N = int(input())
    A_list = list(input().split())
    buka_dict = {str(i+1): 0 for i in range(N)}
    for i in A_list:
        buka_dict[str(i)] += 1
    for i in buka_dict.values():
        print(i)


main()

Submission status: Accepted

Solution code:
#ABC163c
n = int(input())
a = [int(i) for i in input().split()]
a.insert(0, 0)
joushi = [0]*n

for i in range(n):
    if i == 0:
        pass
    else:
        joushi[a[i]-1] += 1
for i in range(n):
    print(joushi[i])

Submission status: Accepted

Solution code:
# ABC 163
N =int(input())
A =[int(j) for j in input().split()]
memo = [0] * N

for a in A:
    memo[a -1]+=1
for i in memo:
    print(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
[print(i) for i in ans]

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

freq = [0 for _ in range(n)]
cur = list(map(int, input().split()))

for i in cur:
    freq[i - 1] += 1

for i in range(n):
    print(freq[i])

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect


if __name__ == '__main__':
    n = int(input())
    data = list(map(int, input().split()))

    subordinate_data = [None] * n
    for i, _ in enumerate(subordinate_data):
        subordinate_data[i] = []
    i = 2 # id
    for v in data:
        boss = v - 1
        subordinate_data[boss].append(i)
        i += 1
    #print('subordinate_data') # debug
    #print(subordinate_data) # debug
    for l in subordinate_data:
        print(len(l))


    #print('\33[32m' + 'end' + '\033[0m') # debug

Submission status: Accepted

Solution code:
import collections

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

s = collections.defaultdict(int)

for n in A:
  s[n] += 1
  
for n in range(1, N + 1):
  print(s[n])

Submission status: Accepted

Solution code:
n = int(input())

nums = [0]*n

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

for boss in bosses:
    nums[boss-1] += 1

for num in nums:
    print(num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
nl=[0 for a in range(n)]

al=input().split()
for x in range(n-1):
  nl[int(al[x])-1]+=1
  
for y in nl:
  print(y)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
a_0 = [0 for i in range(n)]

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

for i in a_0:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
A = input().split()
CountSubordinateNum = [0]*(N+1)

for boss in A:
    CountSubordinateNum[int(boss)] += 1
    
for index, count in enumerate(CountSubordinateNum):
    if index==0:
        pass
    else:
        print(count)

Submission status: Accepted

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

count = 0
buka = [0 for _ in range(N)]

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

for k in range(N):
    print(buka[k])

Submission status: Accepted

Solution code:
# C - management

N = int(input())
A = [0] * N
for a in [*map(int, input().split())]: A[a - 1] += 1
print(*A, sep='\n')

Submission status: Accepted

Solution code:
ninnzuu = (int)(input())
joushi = list(map(int, input().split(" ")))
buka = [0 for i in range(ninnzuu)]
for i in range(ninnzuu - 1):
    buka[joushi[i]] += 1
for i in range(1, ninnzuu):
  print(buka[i])
print(0)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

d=defaultdict(int)
for item in a:
    d[item-1]+=1
for i in range(n):
    print(d[i])

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    n = int(stdin.readline())
    a = list(map(int, stdin.readline().split()))

    ans = [0] * n

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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

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

a = [0]*N

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed May  6 00:55:08 2020

@author: shinba
"""

from collections import Counter

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

B = Counter(A)

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

Submission status: Accepted

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

import collections

c = collections.Counter(A)
for j in range(n):
  if j+1 in c:
    print(c[j+1])
  else: print(0)

Submission status: Accepted

Solution code:
from collections import defaultdict
import collections

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

# for i in range(N-1):
#   print(List.count(i+1))
# print(0)

c = collections.Counter(List)
# print(c)
for i in range(1,N+1):
  # print(i)
  print(c[i])
  # print()

Submission status: Accepted

Solution code:
n = int(input());
v = [0 for i in range(n)];

d = {};
kk = [int(i) for i in input().split()];

for k in kk:
    v[k - 1] += 1;

for i in v:
    print(i);

Submission status: Accepted

Solution code:
n = input()
n = int(n)

x = input().split()

a = [int(i) for i in x]

b = [0]*n
for j in range(0,len(a)):
    k = a[j] - 1
    b[k] = b[k] + 1

for i in range(0,n):
  print(b[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:
from collections import defaultdict
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:
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int,input().split()))
a = list(map(lambda x:x-1,a))
ret = [0]*n
for ai in a:
    ret[ai]+=1

for i in ret:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
List = list(map(int,input().split()))
C = Counter(List)

for i in range(1,N):
  if i in C.keys():
    print(C[i])
  else:
    print(0)
print(0)

Submission status: Accepted

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

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    ll=[0]*n
    for i in range(n-1):
        ll[l[i]-1]+=1
    for i in ll:
        print(i)
resolve()

Submission status: Accepted

Solution code:
N = int(input())

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

ans=[0]*N
for i in l:
  ans[i-1] = ans[i-1]+1

for a in ans:
  print(a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
B = {}
for i in A:
  if i not in B:
    B[i] = 0
  B[i] += 1
  
for j in range(1,N+1):
  try:
    print(B[j])
  except KeyError:
    print(0)

Submission status: Accepted

Solution code:
counts = [0] * int(input())
for i in map(lambda n: int(n) - 1, input().split()):
    counts[i] += 1
print(*counts, sep="\n")

Submission status: Accepted

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

Submission status: Accepted

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

AA=[0]*N
for j in A:
    AA[j-1]+=1

for i in AA:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(_) for _ in input().split()]

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(0, n-1):
  d[int(c[i])-1] +=1

for j in d:
  print(j)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

for i in range(n):
    num = num_lst[i]
    print(num)

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):
    print(c[i])
    
print(0)

Submission status: Accepted

Solution code:

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

buka = [str(A.count(i)) for i in range(1, N+1, 1)] # countメソッドのためTLE

print("\n".join(buka))
"""
"""
# sys（入力メイン）-----------------------------------------
import sys
read = sys.stdin.buffer.read # 全読み込み
readline = sys.stdin.buffer.readline # 一行読み込み
readlines = sys.stdin.bufer.readlines # 一行ずつ全読み込み
sys.setrecursionlimit(10**7) # 再帰限界変更（デフォルトは1000）

# 文字列（数値変換も含む）
n = readline().rstrip() # １行に１文字列のみ
lis = readline().rstrip().split() # # １行に複数の文字列

# 数値（文字変換も含む）
n = int(readline().rstrip()) # １行に数値１個のみ
a, b, c = int(readline().rstrip().split()) # １行に複数の数値
lis = [readline().rstrip().split() for _ in range(n)] # １行に複数の数値(m個)かつ、n行続く場合（出力は二次元リスト：[['1', '2'], ['4', '5']]）

-----------------------------------------
"""

import sys
read = sys.stdin.buffer.read # 全読み込み
readline = sys.stdin.buffer.readline # 一行読み込み
readlines = sys.stdin.buffer.readlines # 一行ずつ全読み込み
sys.setrecursionlimit(10**7) # 再帰限界変更（デフォルトは1000）

N = int(readline().rstrip()) 
A = list(map(int,readline().rstrip().split()))

buka=[0]*N

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

L=[str(a) for a in buka]
L="\n".join(L)
print(L)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    a = LI_()
    r = [0] * n
    for c in a:
        r[c] += 1

    return JA(r, "\n")


print(main())

Submission status: Accepted

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

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

for i in range(n):
  print(ans[i])

Submission status: Accepted

Solution code:
import numpy as np

def calculate_num_boss(num_person, boss):
    boss_count = np.zeros([num_person])
    result, num = np.unique(boss, return_counts=True)
    for idx in range(result.shape[0]):
        ids = result[idx]
        boss_count[ids-1] = num[idx]

    return boss_count


if __name__ == "__main__":
    num_person = int(input().split()[0])
    bosses = np.array([int(i) for i in input().split()])
    count = calculate_num_boss(num_person, bosses)
    for i in count:
        print(int(i))

Submission status: Accepted

Solution code:
import collections

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

Submission status: Accepted

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

Submission status: Accepted

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

HowManySubordinate = []
for i in range(n):
    HowManySubordinate.append(0)

for i in range(n-1):
    t = As[i] - 1
    HowManySubordinate[t] += 1

for i in range(len(HowManySubordinate)):
    print(HowManySubordinate[i])

Submission status: Accepted

Solution code:
import collections

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

Cs = collections.Counter(As)

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

Submission status: Accepted

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

ans = "\n".join(map(str,ans))
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(a) for a in input().split()]

A.sort()
j = 0
cnt = 0
for i in range(1, N+1):
    if j < 0:
        print(0)
        continue
    cnt = 0
    while A[j] == i:
        j += 1
        cnt += 1
        if j == N-1:
            j = -1
            break
    print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
ans = [0]*N

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

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
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 LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    n = II()
    A = LI()
    ans = [0] * n
    for i, a in enumerate(A):
        ans[a-1] += 1

    for a in ans:
        print(a)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

list = [0]*n

for i in a_:
    list[i-1] += 1

for i in list:
    print(i)

Submission status: Accepted

Solution code:
B = {}#辞書作成
N = int(input())
A = list(map(int, input().split()))


for i in range(N):
    B[i+1] = 0
#print(B)
for j in A:
    B[j] += 1
#print(B)
for k in B.values():
    print(k)

Submission status: Accepted

Solution code:
dic = {}
N = int(input())
lists = list(map(int, input().split()))
for i in range(1, N+1):
  dic[i] = 0
for j in lists:
  dic[j] += 1
for k in dic.values():
  print(k)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

x = int(input())
l = [0] * x
A = list(map(int, input().split()))

for num in range(x-1):
    l[A[num]-1] += 1

for i in range(x):
    print(l[i])

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
from collections import Counter

def solve(N: int, A: "List[int]"):
    c = Counter()
    c[1] = 0
    for a in A:
        c[a] += 1
    for i in range(len(A) + 1):
        print(c[i+1])
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N-2+1) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

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:
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
for i in range(1,n):
   b[a[i-1]-1] +=1

for k in range(1,n+1):
  print(b[k-1])

Submission status: Accepted

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

ls = [0 for i in range(N+1)]
for i in range(N-1):
  ls[A[i]] +=1
  
for i in range(1,N+1):
  print(ls[i])

Submission status: Accepted

Solution code:
a = int(input())
b = list(map(int,input().split()))
c = [0]*a

for i in b:
  c[i-1] += 1
  
for s in range(len(c)):
  print(c[s])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

buka = [0]*N
for josi in A:
  buka[josi -1] +=1
for b in buka:
  print(str(b))

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

n = I()
A = LI()
N = [0]*n

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

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

Submission status: Accepted

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
ans = [0 for i in range(N)]
for num in A:
    ans[num - 1] += 1
for n in ans:
    print(n)

Submission status: Accepted

Solution code:
import itertools
N=int(input())
listA=list(map(int,input().split()))
listA.sort()
listA2=[0]*N
for i in listA:
  listA2[i-1]+=1
listA=set(listA)  
for i in range(1,N+1):
  if i in listA:
    print(listA2[i-1])
  else:
    print(0)

Submission status: Accepted

Solution code:
# input
n = int(input())
inp_ls = input().split(" ")
a_ls = [int(e) for e in inp_ls[:n-1]]

# calc
w_ls = [0 for i in range(n)]
for a in a_ls:
	w_ls[a-1] += 1

# result
for w in w_ls:
	print(w)

Submission status: Accepted

Solution code:
n = int(input())
input_line = list(map(int, input().split()))
data = [0 for i in range(n)]

for i in range(len(input_line)):
  data[input_line[i]-1] += 1

for i in data:
  print(i)

Submission status: Accepted

Solution code:
# input
n = int(input())
inp_ls = input().split(" ")
a_ls = [int(e) for e in inp_ls[:n-1]]

# calc
w_ls = {i+1: 0 for i in range(n)}
for a in a_ls:
	w_ls[a] += 1

# result
for i in range(n):
	print(w_ls[i+1])

Submission status: Accepted

Solution code:
n = int(input())
tmp = input().split()
a = [None]
a += tmp
# [None,1,1,2,2]

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

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
A = list(map(int,input().split()))
datas = np.zeros(N)
for a in A:
  datas[a-1] += 1
for data in datas:
  print(int(data))

Submission status: Accepted

Solution code:
N = int(input())
Mgr = [int(num) for num in input().split()]
sub = [0]*N

for i in range(len(Mgr)):
    sub[Mgr[i]-1] += 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from _collections import defaultdict

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

res = defaultdict(int)
for a in arr:
    res[a] += 1

for i in range(1, n + 1):
    print(res[i])

Submission status: Accepted

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