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 collections
N = int(input())

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

c = collections.Counter(A)

for x in range(1, N+1):
  if x in c.keys():
    print(c[x])
  else:
    print(0)

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

Submission status: Accepted

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

Submission status: Accepted

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

    tree = [[] for _ in range(N)]
    for k, a in enumerate(A, 2):
        tree[a - 1].append(k - 1)

    ans = [len(t) for t in tree]
    return '\n'.join(map(str, ans))

print(c_management())

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()

import collections

c = collections.Counter(a)

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

Submission status: Accepted

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

for i in range(N-1):
    A[i] -= 1
#上司の社員番号は自分より小さい
dic = {}
for i in range(N):
    dic[i] = 0

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n = int(input())
    a = [int(i) for i in input().split()]

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

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


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Accepted

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

tmp = 0
cnt = 0
for i in range(1, n+1):
    while tmp < n-1 and a[tmp] == i:
        cnt += 1
        tmp += 1
    print(cnt)
    cnt = 0

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
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())
l=list(map(int,input().split()))
an = [0]*n
for i in l:
  an[i-1]+=1
for i in an:
	print(i)

Submission status: Accepted

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

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

for a in ans:
    print(a)

Submission status: Accepted

Solution code:

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

if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

def solve(N: int, A: "List[int]"):
    result = {k+1:0 for k in range(N)}

    for idx, a in enumerate(A):
        idx = idx + 2
        result[a] += 1
    for k, v in result.items():
        print(v)
    return


# Generated by 1.1.6 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 sys
N = int(sys.stdin.readline().rstrip())
A = list(map(int, sys.stdin.readline().rstrip().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]*n
for i in a:
    l[i-1]+=1
for i in l:
    print(i)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1000000)
import collections
def solve(N, A):
    c = collections.Counter(A)
    ans = []
    for i in range(N):
        if (i+1) not in c:
            ans.append("0")
        else:
            ans.append(str(c[i+1]))
    return "\n".join(ans)

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split(" ")))

    print(solve(N, A))

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
else:
  for i in s:
  	print(i)

Submission status: Accepted

Solution code:
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/input.txt"
exit $?
'''
import sys


def _i(): return int(sys.stdin.readline().strip())


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    n = _i()
    a = _ia()
    ret = [0]*n
    for ai in a:
        ret[ai-1] += 1
    return "\n".join(map(str, ret))


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

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

[print(n) for n in ans]

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()))
ans = [0]*N

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

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter

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

c = Counter()

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


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 x in range(1, N+1):
  if x in c.keys():
    print(c[x])
  else:
    print(0)

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[i])

Submission status: Accepted

Solution code:
n=int(input())
arr = [int(x) for x in input().split()]
dc={}
for k in range(1,n+1):
    dc[k]=0
for item in arr:
    dc[item]+=1
for k in range(1,n+1):
    print(dc[k])

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 itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    A = readInts() # n-1人いるようです
    B = [0] * (n)
    for i in range(n-1):
        a = A[i] - 1
        B[a] += 1
    print(*B,sep='\n')
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
n = int(input())
dic = {i:0 for i in range(1, n+1)}
for value in map(int, input().split()):
    dic[value] += 1
for i, j in sorted(dic.items(), key=lambda x: x[0]):
    print(j)

Submission status: Accepted

Solution code:
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
from bisect import bisect_left
setrecursionlimit(1000000)

INF = int(1e10)
MOD = int(1e9 + 7)

def input():
    return stdin.readline()[:-1]


def main():
    from builtins import int, map
    N = int(input())
    A = list(map(int, input().split()))
    ans = [0] * (N + 1)
    for a in A:
        ans[a] += 1
    for a in ans[1:]:
        print(a)

   
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    num_list = list(map(int, input().split()))

    result_list = [0]*n

    for i in range(n-1):
        result_list[num_list[i]-1] += 1

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().strip().split()))
c = [0] * 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 = [int(i) for i in input().split()]
chk=[0]*n
for i in a:
  chk[i-1] += 1
for i in chk:
  print(i)

Submission status: Accepted

Solution code:
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
superior = lr()
sub = [0] * (N+1)
for i in range(2, N+1):
    x = superior[i-2]
    sub[x] += 1

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

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

Submission status: Accepted

Solution code:
N = int(input())
zyousi_arr = [int(i) for i in input().split(' ')]
res_map = {}

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

for zyousi in zyousi_arr:
    res_map[zyousi] += 1

for k, v in sorted(res_map.items()):
    print(v)

Submission status: Accepted

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

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

Submission status: Accepted

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

array = [0] * n

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

Submission status: Accepted

Solution code:
N=int(input())
*A,=map(int, input().split())
G=[[] for _ in range(N)]
for i,a in enumerate(A):
    G[a-1].append(i)
for g in G:
    print(len(g))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(lambda x: int(x) - 1, input().split()))
staff = [0 for _ in range(n)]

for a_ in a:
    staff[a_] += 1

for staff_ in staff:
    print(staff_)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

for aaa in ans:
  print(aaa)

Submission status: Accepted

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
b = [0] * n

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

for i in b:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

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

l = [0 for _ in range(n+1)]

for j in a:
  l[j] += 1

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
lst1 = list(map(int,readline().split()))

lst2 = [0]*n

for i in range(n-1):
    lst2[lst1[i]-1] += 1

for i in lst2:
    print(i)

Submission status: Accepted

Solution code:


#C

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

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

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

for v in buka.values():
  print(v)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import collections
n = int(input())
a = [int(i) for i in input().split()]

c = collections.Counter(a)
for i in range(1,n + 1):
    print(c[i])

Submission status: Accepted

Solution code:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
p = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    n = ni()
    a = nl()

    ans = [0]*n

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

    for value in ans:
        print(value)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

buka = {}
for a in A:
  if a in buka:
    buka[a] += 1
  else:
    buka[a] = 1

for i in range(N+1)[1:]:
  if i in buka:
    print(buka[i])
  else:
    print(0)

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:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    ans=[0]*n
    a=LIST()
    for i in a:
        ans[i-1]+=1
    
    for i in ans:
        print(i)
if __name__ == '__main__':
    do()

Submission status: Accepted

Solution code:
def resolve():
    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)
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
cnt=[0]*N
for i in A:
    cnt[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(' ')))
cnt = [0 for i in range(n)]
for i in a:
	cnt[i - 1] += 1
for i in range(n):
	print(cnt[i])

Submission status: Accepted

Solution code:
from collections import defaultdict
n = int(input())
al = list(map(int, input().split()))
d = defaultdict(lambda: 0)
for i, a in enumerate(al):
    d[str(a-1)] += 1
for i in range(n):
    print(d[str(i)], sep=' ')

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 = [int(i) for i in input().split()]

B=[0]*N

for i in range(N-1):
    B[A[i]-1]+=1
print("\n".join([str(i) for i in B]))

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

counts = [0] * N

for a in map(int, input().strip().split()):
	counts[a - 1] += 1

print(*counts)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

n = n_in()
A = l_in()

from collections import Counter

c = Counter()
for a in A:
    c[a] += 1

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

Submission status: Accepted

Solution code:
import math

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

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


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

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
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

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

N = inputI()
A = inputIL()

dic = [0]*N

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

for i in dic:
  print(i)

Submission status: Accepted

Solution code:
N = int(input())
As =list(map(lambda x: int(x), input().split(" ")))

result = [0] * N

for a in As:
    result[a-1] += 1

for r in result:
    print(r)

Submission status: Accepted

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

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

for r in res:
    print(r)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
X = [0]*N
for a in A:
    X[a-1]+=1
for x in X:
    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())
aes = list(map(int, input().split()))

anss = [0] * n

for a in aes:
  anss[a - 1] += 1

for ans in anss:
  print(ans)

Submission status: Accepted

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

cnt = Counter(a)


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

Submission status: Accepted

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


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

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
import math
from functools import reduce


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

num_buka = np.zeros(n)
for _a in a:
    num_buka[_a-1] += 1

for e in num_buka:
    print(int(e))

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 arr:
    print(i)

Submission status: Accepted

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

a = [i-1 for i in a]
di = [0 for _ in range(n)]

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

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

Submission status: Accepted

Solution code:
"""
// Author : snape_here - Susanta Mukherjee
     
 """
 
from __future__ import division, print_function
 
import os,sys
from io import BytesIO, IOBase
 
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
 
 
def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())
 
 
def read():
    sys.stdin = open('input.txt', 'r')  
    sys.stdout = open('output.txt', 'w') 
 
def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

mod=1000000007

import math

import bisect

abc="abcdefghijklmnopqrstuvwxyz"

def main():

    n=ii()
    f=[0]*(n+5)
    a=li()
    for i in range(n-1):
        f[a[i]]+=1 
    for i in range(1,n+1):
        print(f[i])

        
# region fastio

 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()
 
 
if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
 
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
# endregion
 
 
if __name__ == "__main__":
    #read()
    main()

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

Submission status: Accepted

Solution code:
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

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

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

for di in d:
    print(di)

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())) #N-1個
from collections import Counter
d=dict(Counter(A))

#print(d)

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

Submission status: Accepted

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

Submission status: Accepted

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

count = [0 for i in range(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:
n = int(input())
ls = [int(x) for x in input().split()]
res = [0]*n
for x in ls:
    res[x-1] += 1
for x in res:
    print(x)

Submission status: Accepted

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

buka = {i: 0 for i in range(N)}

import collections

buka_count = collections.Counter(A)

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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

Submission status: Accepted

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

Submission status: Accepted

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

buka = [0 for _ in range(n)]

for i in range(n-1):
    buka[a[i] - 1] += 1
    
for i in range(len(buka)):
    print(buka[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 an in ans:
    print(an)