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:
import sys


def resolve(in_, out):
    n = int(in_.readline())
    b = [0] * (n + 1)
    for a in map(int, in_.readline().split()):
        b[a] += 1
    out.write('\n'.join(map(str, b[1:])))


def main():
    resolve(sys.stdin.buffer, sys.stdout)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
c = collections.Counter(a)
l = [0]*n
for i,x in c.items():
    l[i-1] = x
    
for i in l:
    print(i)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = [0]*(N+1)

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
a = inpl()
ans = [0] * n

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

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

Submission status: Accepted

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

for i in range(n - 1):
    if a[i] > 0:
        l[a[i] - 1] += 1

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

Submission status: Accepted

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

def main():

    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)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n,*aa = map(int, open(0).read().split())
from collections import Counter
c = Counter(aa)
for i in range(1,n+1):
  print(c[i])

Submission status: Accepted

Solution code:
from collections import defaultdict
from sys import stdin
input = stdin.readline


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

  dic = defaultdict(int)
  for i, a in enumerate(A):
    dic[a] += 1

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


if(__name__ == '__main__'):
  main()

Submission status: Accepted

Solution code:
N = int(input())
A = list(input().split())
boss = [0]

for i in range(N-1):
  boss.append(0)
  boss[int(A[i])-1] += 1

for i in range(N):
  print(str(boss[i]))

Submission status: Accepted

Solution code:
# abc163_c.py
# https://atcoder.jp/contests/abc163/tasks/abc163_c

# C - management /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 300点

# 問題文
# N人の社員からなる会社があり、各社員には 1,...,Nの社員番号が割り当てられています。
# 社員番号 1の社員以外の全ての社員には、自分より社員番号が小さい直属の上司がちょうど 1人います。
# Xさんが Y さんの直属の上司であるとき、Y さんは Xさんの直属の部下であるといいます。
# 社員番号 iの社員の直属の上司の社員番号が Aiであることが与えられます。
# 各社員について直属の部下が何人いるか求めてください。

# 制約
#     2≤N≤2×105
#     1≤Ai<i

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N
# A2 ... AN

# 出力
# 社員番号 1,2,...,Nのそれぞれの社員について、直属の部下が何人いるか、改行区切りで出力せよ。

# 入力例 1
# 5
# 1 1 2 2

# 出力例 1
# 2
# 2
# 0
# 0
# 0

# 社員番号 1の社員の直属の部下は社員番号 2,3 の 2人です。
# 社員番号 2の社員の直属の部下は社員番号 4,5 の 2人です。
# 社員番号 3,4,5の社員には直属の部下はいません。

# 入力例 2
# 10
# 1 1 1 1 1 1 1 1 1

# 出力例 2
# 9
# 0
# 0
# 0
# 0
# 0
# 0
# 0
# 0
# 0

# 入力例 3
# 7
# 1 2 3 4 5 6

# 出力例 3
# 1
# 1
# 1
# 1
# 1
# 1
# 0


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    N = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    results = [0] * N

    for value in values:
        results[value-1] += 1

    return results


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['5', '1 1 2 2']
        lines_export = [2, 2, 0, 0, 0]
    if pattern == 2:
        lines_input = ['10', '1 1 1 1 1 1 1 1 1']
        lines_export = [9, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    if pattern == 3:
        lines_input = ['7', '1 2 3 4 5 6']
        lines_export = [1, 1, 1, 1, 1, 1, 0]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
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):
    if i in c:
        print(c[i])
    else:
        print(0)

Submission status: Accepted

Solution code:
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    aList = sorted(list(map(int, readline().rstrip().split())))
    z = [0] * n
    for a in aList:
        z[a-1] += 1

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import itertools
import math
import sys

INF = float('inf')


def solve(N: int, A: "List[int]"):
    c = collections.Counter(A)
    return "\n".join([f'{c[i+1]}' for i in range(N)])


def main():

    sys.setrecursionlimit(10 ** 6)

    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]"
    print(solve(N, A))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import itertools
import math
import sys

INF = float('inf')


def solve(N: int, A: "List[int]"):
    c = collections.Counter(A+[i+1 for i in range(N)])
    return "\n".join([f'{c[i+1]-1}' for i in range(N)])


def main():

    sys.setrecursionlimit(10 ** 6)

    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]"
    print(solve(N, A))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

m = Counter(a)

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

Submission status: Accepted

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

ans = [0] * n
for i in range(n-1):
  number = lst[i]
  ans[number - 1] += 1

for i in ans:
  print(i)

Submission status: Accepted

Solution 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)

Submission status: Accepted

Solution code:
n = int(input())
d = dict(zip([i for i in range(1, n + 1)], [0] * n))
l = map(int, input().split())
for i in l:
    d[i] += 1
for i in d.values():
    print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
import sys, math

n = int(stdin.readline().rstrip())

a = [0 for i in range(n)]
d = [int(x) for x in stdin.readline().rstrip().split()]

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from collections import Counter

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

Submission status: Accepted

Solution code:
N = int(input())

A2N = list(map(int, input().split()))
import collections
c = collections.Counter(A2N)
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 collections
N = int(input())
ls = list(map(int,input().split()))
count = collections.Counter(ls)
for i in range(1,N+1):
    if i in count.keys():
        print(count[i])
    else:
        print(0)

Submission status: Accepted

Solution code:
N = int(input())
an = [int(i) for i in input().split()]

result = { i + 1: 0 for i in range(N) }

for ai in an:
    result[ai] += 1

for r in result.values():
    print(r)

Submission status: Accepted

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

boss = [[] for _ in range(n)]

for i,j in enumerate(a):
    boss[j-1].append(i)

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())

lis = [0]*N
for a in As:
    lis[a-1]+= 1

for l in lis:
    print(l)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
subordinate_cnt = [0] * N
for boss_num in A:
  subordinate_cnt[boss_num - 1] += 1
print("\n".join(map(str, subordinate_cnt)))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
subordinates = [0] * N
boss_and_cnt = Counter(A)
for boss, cnt in boss_and_cnt.items():
  subordinates[boss - 1] = cnt
for s in subordinates:
  print(s)

Submission status: Accepted

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

if __name__ == "__main__":
  resolve()

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
A.insert(0,0)
A.insert(0,0)
C = {i:[] for i in range(1,N+1)}
for i in range(2,N+1):
    C[A[i]].append(i)
for i in range(1,N+1):
    print(len(C[i]))

Submission status: Accepted

Solution code:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
a=lnii()

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

for i in ans:
  print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input(""))
lista=[0]*n
a=input("").split(" ")
for i in a:
    lista[int(i)-1]+=1
for i in lista:
    print(i)

Submission status: Accepted

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

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())
A = map(lambda x: x - 1, map(int, input().split()))
B = [0] * N
for a in A:
    B[a] += 1
print('\n'.join(map(str, B)))

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(N):
  print(D[i+1])

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())
cc = list(map(int,input().split()))
num = [0]*N
for i in cc:
  num[i-1] += 1
for i in num:
  print(i)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

lis = [0]*(N+1)
for a in A:
    lis[a] += 1
for num in lis[1:]:
    print(num)

Submission status: Accepted

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

I = [0]*N

for i in range(len(A)):
    I[A[i] - 1 ] += 1


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

Submission status: Accepted

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

arr = [0] * n

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

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

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())
    array = [0 for i in range(N)]
    buka = [int(i) for i in input().split()]

    for num in buka:
        array[num - 1] += 1
    for i in array:
        print(i)
resolve()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))

S = [0] * N # S[i]は社員iの直属の部下数

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

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

Submission status: Accepted

Solution code:
#import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N = int(input())
    A = list(map(int, input().split()))

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

    for c in C:
        print(c)

main()

Submission status: Accepted

Solution code:
n = int(input())

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

a.sort()

tmp=0
cnt=0

for bangou in range(1,n+1):
    if tmp<len(a):
        while a[tmp]==bangou:
            cnt+=1
            tmp+=1
            if tmp==len(a):
                break
    print(cnt)
    cnt=0

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())
a = list(map(int, input().split()))

menber = [0]*n

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

Submission status: Accepted

Solution code:
# C management

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

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

for s in S:
  print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = readInts()
dic = defaultdict(int)
for i in range(n):
    dic[i+1] = 0
for a in A:
    dic[a] += 1
for i in range(n):
    print(dic[i+1])

Submission status: Accepted

Solution code:
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()
ac = Counter(inl())


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

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
from collections import Counter
ctr = Counter(A)
ans = [ctr[i+1] for i in range(N)]
print(*ans, sep='\n')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
A = Counter(list(map(int, input().split())))
ans = [0] * n
for x,y in A.items():
    ans[x-1] = y
for i in ans: print(i)

Submission status: Accepted

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

A = Counter(A)
for i in range(1,n+1):
    print(A[i])

Submission status: Accepted

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

for i in buka:
    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
print(*ans)

Submission status: Accepted

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

n = int(input())
a = list(map(int, input().split()))
g = [[] for _ in range(n)]

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

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

Submission status: Accepted

Solution code:
N = int(input())
A_list = [int(i) for i in input().split()]

staff_count_list = [0] * N

for i in A_list:
    staff_count_list[i - 1] += 1
for i in staff_count_list:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n = int(input())
arr = [0] * n

for i in input().split():
    i = int(i)
    arr[i - 1] += 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
import collections

def main():
    bosses=[]
    count={}
    n = int(input())
    bosses=list(map(int,input().split()))
    ans=[0]*n
    for i in bosses:
        ans[i-1]+=1

    for a in ans:
        print(a)

if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import defaultdict

n = int(input().strip())
dp = [0] * (n+1)
A = [int(i) for i in input().strip().split()]

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

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

Submission status: Accepted

Solution code:
N = int(input())
ls = list(map(int,input().split()))
cnt = [0] * (N+1)

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

Submission status: Accepted

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

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

for i in ans_li:
  print(i)

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:
import collections

n = int(input())
a  = list(map(int,input().split()))
b = collections.Counter(a)
for d in range(n):
    print(b[d+1])

Submission status: Accepted

Solution code:
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(N):
  print(cnt[i])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
from collections import defaultdict
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())
a=sorted(list(map(int,input().split())))
adj=[0]*10**6
count=0
for i in a:
  adj[i]+=1
for i in range(n):
  print(adj[i+1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import  Counter

N = int(input())

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

C = Counter(A)

for i in range(1, N+1):
    print(C.get(i,0))

Submission status: Accepted

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

c=collections.Counter(b)
n,m=zip(*c.most_common())
n,m=list(n),list(m)
o=c.most_common()

result=[0]*a
for i in range(len(o)):
    result[o[i][0]-1]=o[i][1]

for i in result:
    print(i)

Submission status: Accepted

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

for i in A:
  cnt[i] += 1

for i in cnt[1:]:
  print(i)

Submission status: Accepted

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

Submission status: Accepted

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

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

for b in B:
  print(b)

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:
import collections
N = int(input())
A = list(map(int, input().split())) 
c = collections.Counter(A)
for i in range(N):
    print(c[i+1])

Submission status: Accepted

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

num = [0]*(n+1)

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

for j in range(1,n+1):
    print(num[j])

Submission status: Accepted

Solution code:
n = int(input())

# boss[m] = b.  member m has boss b
boss = [int(i) - 1 for i in input().split()]

sub = { i: 0 for i in range(n) }
for b in boss:
  sub[b] += 1

for m in range(n):
  print(sub[m])

Submission status: Accepted

Solution code:
import collections
n = int(input())
A = list(map(int,input().split()))
Ac = collections.Counter(A)
for i in range(1,n+1):
    if i in Ac.keys():
        print(Ac[i])
    else:
        print(0)

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
d = {i:[] for i in range(1,n+1)}
for i,num in enumerate(a):
    d[num].append(i+2)
ans = []
for i in range(1,n+1):
    ans.append(len(d[i]))
write("\n".join(map(str, ans)))

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
*A, = map(int, input().split())
c = 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()))
ans=[0]*N

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in a:
    l[i - 1] += 1
    
for k in range(n):
    print(l[k])

Submission status: Accepted

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

buka = [0]*N

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

result = [0] * N
for a in A:
    result[a - 1] += 1
#print('\n'.join(map(str, result)))
print(*result, sep='\n')

Submission status: Accepted

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

result = [0] * N
for a in A:
    result[a - 1] += 1
print('\n'.join(map(str, result)))
#print(*result, sep='\n')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
  a = int(input())
  b =[0]*a
  
  for c in map(int, input().split()):
    b[c-1] += 1
    
  print('\n'.join(map(str, b)))
 
main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections
N = int(input())
A = [int(_) for _ in input().split()]
cnt = collections.defaultdict(int)
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()))
s=[0]*n
for i in range(n-1):
    s[a[i]-1]+=1
for i in range(n):
    print(s[i])

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
subs = [[] for _ in range(N)]
for i, a in enumerate(A):
    subs[a - 1].append(i)

for i in range(N):
    print(len(subs[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):
    print(c[i])

print(0)

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())
a = list(map(int, input().split()))

import collections

c = collections.Counter(a) 


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