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:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def input():
    return sys.stdin.readline()


def resolve():
    n = int(input())
    a_list = list(map(int, input().split()))


    ans_list = []
    ans_list.append(0)
    for i in range(len(a_list)):
        ans_list.append(0)

    for ai in a_list:
        ans_list[ai-1] += 1

    for answer in ans_list:
        print(answer)




if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

A.insert(0,0)
mem_id = collections.Counter(A)
sub = []
for i in range(0,N):
    print(mem_id[i + 1])

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())

c = Counter(map(int, input().split()))
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 i in range(N):
      print(ans[i])

Submission status: Accepted

Solution code:
n = int(input())
a = [int(i) for i in 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()))
dic=collections.Counter(a)
for i in range(1,n+1):
    if i in dic.keys():
        print(dic[i])
    else:
        print(0)

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

Submission status: Accepted

Solution code:
import sys
from collections import Counter

lines = 2
inp = list()

for _ in range(lines):
    inp.append(sys.stdin.readline().strip())


n = int(inp[0])
a_lst = inp[1].split()

c = Counter(a_lst)

for i in range(1, n + 1):
    print(c.get(str(i), 0))

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
a_L = list(map(int,input().split()))
a_L = Counter(a_L)
dic = {}

for i,v in a_L.items():
    dic[i] = v
for i in range(n):
    try:
        print(dic[i+1])
    except:
        print(0)

Submission status: Accepted

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

Submission status: Accepted

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

lis=[0]*N

for j in range(0,N-1):
  lis[S[j]-1]+=1
  
  
for i in range(N):
  print(lis[i])

Submission status: Accepted

Solution code:
import collections

n = int(input())

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

cnts = collections.Counter(nums)

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

Submission status: Accepted

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

for i in ls:
    print(i)

Submission status: Accepted

Solution code:
# coding:utf-8
n = int(input())
a = list(map(int, input().split()))
a[0:0] = [0]
# print(a)
ans = [0] * n

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

for item in ans:
    print(item)

Submission status: Accepted

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

if N==2:
    print(1)
    print(0)
else:
    from collections import deque
    da=deque(A)
    
    import numpy as np
    ansl=np.array([0]*N)
    
    for i in range(N-1):
        ansl[da.pop()-1]+=1
    
    for i in ansl:
        print(i)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

for a in ans:
	print(a)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

buka = defaultdict(int)

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

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

Submission status: Accepted

Solution code:
n = int(input())

data = input().split()
jousi = [int(s) for s in data]

buka = [0]*n

for i in jousi:
  buka[i - 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+1)
#print(ans)
for a in A:
#    print(a)
    ans[a] += 1
for i in range(1,N+1):
    print(ans[i])

Submission status: Accepted

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

c = collections.Counter(A)
ans = [0]*N

for ci in c.items():
    ans[ci[0]-1]=ci[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(a)
for i in range(1,N+1):
  print(c[i])

Submission status: Accepted

Solution code:
import numpy as np
N=int(input())
A=[int(x) for x in input().split()]
X=[0]*300000
for i in range(N-1):
    tmp=A[i]
    X[tmp]+=1
for i in range(1,N+1):
    print(X[i])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

def main():
    args = input().rstrip().split(' ')
    N = int(args[0])
    args = input().rstrip().split(' ')
    A = np.array([int(val) for val in args])
    sup = np.zeros(N-1, dtype=np.int)
    
    for a in A:
        sup[a-1] += 1
    for val in sup:
        print(val)
    print(0)
    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

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

num_counter = Counter(num_list)
num_keys = num_counter.keys()

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

Submission status: Accepted

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

for i in range(n-1):
    count[id[i]-1] += 1
for i in range(n):
    print(count[i])

Submission status: Accepted

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

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

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 j in B:
  print(j)

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

buka = [0 for _ in range(n)]
for i in jousi:
    if i >= 0:
        buka[i] += 1

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

Submission status: Accepted

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

for i in ans:
    print(i)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
arr = [int(el) for el in input().split()]
d = {}
for i, sup in enumerate(arr):
    if sup in d:
        d[sup].append(i)
    else:
        d[sup] = [i]
for i in range(1, N + 1):
    print(len(d[i]) if i in d else 0)

Submission status: Accepted

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

for i in range(len(A)):
    li[A[i]] += 1
for i in range(1, len(li)):
    print(li[i])
print(0)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

import sys
input = sys.stdin.readline

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

ans = [0] * N
for 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()))
lst=[0]*N
for a in A:
    lst[a-1]+=1
for l in lst:
    print(l)

Submission status: Accepted

Solution code:
n=int(input())

s=input().split()

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

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

Submission status: Accepted

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

ans_al = [0]*n

# for i in range(n):
#     ans_al[i-1] += al.count(i)

for a in al:
    ans_al[a-1] += 1

for ans in ans_al:
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a  = list(map(int, input().split()))
import numpy  as np
a = np.array(a)
ans = np.zeros(n)
for i in a:
  ans[i-1] += 1
for i in ans:
  print(int(i))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=[0]*(n-1)
a=list(map(int,input().split()))
a=sorted(a)
ans=0
target=1
j=0
for i in range(n):
    if (j<n-1):
        while(a[j]==target):
            ans+=1
            j+=1
            #print(j,"here")
            if (j>n-2):
                break
    print(ans)
    ans=0
    target+=1

Submission status: Accepted

Solution code:
N = int(input())
emp = [0]*(N+1)
sup = [int(_) for _ in input().split()]
for i in sup:
    emp[i] += 1

[print(_) for _ in emp[1:]]

Submission status: Accepted

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

for i in range(N-1):
    number=mylist[i]
    member[number-1]+=1
    
for i in range(N):
    print(member[i])

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

n = int(input())
b = [0]*n
s = list(map(int,input().split()))

for v in s:
    b[v-1] += 1
for bb in b:
    print(bb)

Submission status: Accepted

Solution code:
from collections import Counter

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

zyoshi_counter = Counter(A)

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

Submission status: Accepted

Solution code:
# coding: utf-8

num = int(input())

shain = input().split(" ")
kazu = []
for i in range(len(shain)):
    shain[i] = int(shain[i])
    
for i in range(num):
    kazu.append(0)
    
for j in range(len(shain)):
    kazu[shain[j] - 1] += 1
    
for k in range(num):
    print(kazu[k])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
Alist = list(map(int, input().split()))
boss = {}
for i in Alist:
    if i not in boss:
        boss[i] = 1
    else:
        boss[i] += 1
for j in range(1,N+1):
    if j in boss:
        print(boss[j])
    else:
        print(0)

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
l = len(c) + 1
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+1)

for i in range(len(a)):
    ans[a[i]]+=1
ans=ans[1:]
ansstr=''
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 for _ in range(N)]
for i in A:
    result[i-1] += 1

for i in result:
    print(i)

Submission status: Accepted

Solution code:

n=int(input())
a=list(map(int,input().split()))
d={}
for i in range(n-1):
  if a[i] in d:
    d[a[i]]+=1
  else:
    d[a[i]]=1

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

Submission status: Accepted

Solution code:
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict, deque
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def IS(): return input().rstrip()

def main():
    N = I()
    A = LI()
    res = [0]*N
    for i, a in zip(range(N), A):
        res[a-1] += 1
    for i in range(N):
        print(res[i])

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
arr = [int(s) for s in input().split()]
c = Counter(arr)
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 for i 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()))
x = collections.Counter(A)
for i in range(N):
    print(x[i+1])

Submission status: Accepted

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

nl = [0 for _ in range(n)]
for e in ass:
  nl[e-1] += 1

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

Submission status: Accepted

Solution code:
from collections import Counter

N,*A = map(int,open(0).read().split())
c = Counter(A)
for i in range(1,N+1):
    if i not in c:
        print(0)
    else:
        print(c[i])

Submission status: Accepted

Solution code:
n=int(input(''))
a=input('')
a=a.split(' ')
for i in range(n-1):
    a[i]=int(a[i])

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

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

for i in l:
    print(i)

Submission status: Accepted

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

from collections import Counter

a=Counter(a)

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

Submission status: Accepted

Solution code:
N = int(input())						# 5
A =        list( map(int, input().split()) )	# 1 2 3 4 5 ...

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

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

Submission status: Accepted

Solution code:
INT_MAX=10**18+7
MOD=10**9+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
#################################################################################
n=int(input())
A=INPUT()
ans=[0 for i in range(n+1)]
for i in range(n-1):
    #print(i)
    ans[A[i]]+=1
for i in range(1,n+1):
    print(ans[i])

Submission status: Accepted

Solution code:
N = int(input())
li = list(map(int, input().split()))
dic = {}
for n,i in enumerate(li):
    buka = n+1
    zyousi = i
    if zyousi in dic.keys():
        dic[zyousi].append(buka)
    else:
        dic[zyousi] = [buka]
for n in range(N):
    if n+1 in dic.keys():
        print(len(dic[n+1]))
    else:
        print(0)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
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:

def main():
    for _ in inputt(1):
        n,  = inputi()
        A = inputl()
        L = [0] * (n + 1)
        for a in A:
            L[a] += 1
        print("\n".join(map(str, L[1:])))


# region M


# region import
# 所有import部分

from math import *
from heapq import *
from itertools import *
from functools import reduce, lru_cache, partial
from collections import Counter, defaultdict
import re, copy, operator, cmath
import sys, io, os, builtins
sys.setrecursionlimit(1000)

# endregion

# region fastio
# 快速io，能提升大量时间

BUFSIZE = 8192
class FastIO(io.IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = io.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(io.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):
    sys.stdout.write(kwargs.pop("split", " ").join(map(str, args)))
    sys.stdout.write(kwargs.pop("end", "\n"))
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip()
inputt = lambda t = 0: range(t) if t else range(int(input()))
inputs = lambda: input().split()
inputi = lambda: map(int, inputs())
inputl = lambda t = 0, k = inputi: map(list, (k() for _ in range(t))) if t else list(k())

# endregion

# region bisect
# 二分搜索，标准库没有函数参数

def len(a):
    if isinstance(a, range):
        return -((a.start - a.stop) // a.step)
    return builtins.len(a)
def bisect_left(a, x, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    if key == None: key = do_nothing
    while lo < hi:
        mid = (lo + hi) // 2
        if key(a[mid]) < x: lo = mid + 1
        else: hi = mid
    return lo
def bisect_right(a, x, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    if key == None: key = do_nothing
    while lo < hi:
        mid = (lo + hi) // 2
        if x < key(a[mid]): hi = mid
        else: lo = mid + 1
    return lo
def insort_left(a, x, key = None, lo = 0, hi = None):
    lo = bisect_left(a, x, key, lo, hi)
    a.insert(lo, x)
def insort_right(a, x, key = None, lo = 0, hi = None):
    lo = bisect_right(a, x, key, lo, hi)
    a.insert(lo, x)
do_nothing = lambda x: x
bisect = bisect_right
insort = insort_right
def index(a, x, default = None, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    if key == None: key = do_nothing
    i = bisect_left(a, x, key, lo, hi)
    if lo <= i < hi and key(a[i]) == x: return a[i]
    if default != None: return default
    raise ValueError
def find_lt(a, x, default = None, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    i = bisect_left(a, x, key, lo, hi)
    if lo < i <= hi: return a[i - 1]
    if default != None: return default
    raise ValueError
def find_le(a, x, default = None, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    i = bisect_right(a, x, key, lo, hi)
    if lo < i <= hi: return a[i - 1]
    if default != None: return default
    raise ValueError
def find_gt(a, x, default = None, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    i = bisect_right(a, x, key, lo, hi)
    if lo <= i < hi: return a[i]
    if default != None: return default
    raise ValueError
def find_ge(a, x, default = None, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    i = bisect_left(a, x, key, lo, hi)
    if lo <= i < hi: return a[i]
    if default != None: return default
    raise ValueError

# endregion

# region csgraph
# 稀疏矩阵 图论部分
class Tree:
    def __init__(n):
        self._n = n
        self._conn = [[] for _ in range(n)]
        self._list = [0] * n
    def connect(a, b):
        pass

# endregion

# region ntheory
# number theory 数论部分
class Sieve:
    def __init__(self):
        self._n = 6
        self._list = [2, 3, 5, 7, 11, 13]
    def extend(self, n):
        pass


sieve = Sieve()
def isprime(n):
    pass
def prime(n):
    pass
def factorint(n):
    factordict = defaultdict(int)
    for i in sieve:
        if n <= i * i:
            break
        while not n % i:
            factordict[i] += 1
            n //= i
    if n != 1:
        factordict[n] += 1
    return factordict
# endregion

# region main
# main 函数部分

if __name__ == "__main__":
    main()

# endregion


# endregion

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

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

c = np.bincount(a)[1::]
ans = np.concatenate([c,np.zeros(n-len(c),dtype=np.int64)])
for i in range(n):
    print(ans[i])

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.get(i, 0))

Submission status: Accepted

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

for i in result:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solution():
    n = int(input())
    a = [int(aa) for aa in input().split()]
    ans = [0] * n
    for i in a:
        ans[i-1] += 1
    [print(anss) for anss in ans]

solution()

Submission status: Accepted

Solution code:
N=int(input()) # メンバーの数
A=[0]+list(map(int,input().split(" "))) # 直属の上司の番号リスト
R=[[] for _ in range(N)] # 部下のリスト

for i in range(1,N):
    R[A[i]-1].append(i) # 部下のリストを形成

for j in range(N): # 各メンバーについて
    print(len(R[j])) # 直属の部下の数を表示

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:
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
cnt = Counter(a)
for i in range(1, n+1):
    print(cnt[i])

Submission status: Accepted

Solution code:

n=int(input())
d={}
a=[int(i) for i in input().split()]

for i in a:
    if(d.get(i,None)==None):
        d[i]=0
    d[i]+=1
for i in range(1,n+1):
    if(d.get(i,None)==None):
        print(0)
    else:
        print(d[i])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict

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

buka = defaultdict(int)

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

a_list = [0] * n 

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

for i in a_list:
	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, sep="\n")

Submission status: Accepted

Solution code:
def main_function():
    from sys import stdin
    from sys import stdout
    input = stdin.readline
    print = stdout.write

    n = int(input())
    a = list(map(int, input().split()))
    ans = [0] * n
    for who_boss in a:
        ans[who_boss - 1] += 1
    for i in range(len(ans)):
        print(f'{ans[i]}\n')


if __name__ == '__main__':
    main_function()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))


def main():
    N = II()
    A = LI()

    x = Counter(A)

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



if __name__ == "__main__":
	main()

Submission status: Accepted

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

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

for i in range(n):
  print(hist[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:
n=int(input())
a=[int(i) for i in 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())
Ai = list(map(int,input().split()))

index = N-1
out = [0 for i in range(N)]

for i in range(index):
  out[Ai[i]-1]+=1

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

Submission status: Accepted

Solution code:
input = raw_input


n = int(input())
ds = map(int, input().split(" "))

nums = [None] + [0] * n 
for d in ds:
    nums[d] += 1

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

Submission status: Accepted

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

for e in A:
    l[e-1] += 1

for result in l:
    print(result)

Submission status: Accepted

Solution code:
import collections

n = int(input())
arr = [int(_) for _ in input().split()]
counter = collections.Counter(arr)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def f(N,L):
    S=N*[0]
    for i in range(N-1):
        S[L[i]-1]+=1
    return S
N=int(input())
L=list(map(int,input().split()))
A=f(N,L)
for j in range(N):
    print(A[j])

Submission status: Accepted

Solution code:
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N = int(input())
A = np.array(list(map(int, input().split())), dtype=np.int64)
cnt = np.zeros(N+1, dtype=np.int64)

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

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

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

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
list_A = list(map(int, input().split()))
list_A = list_A + [i for i in range(1, n+1)]
l = Counter(list_A)
ans = sorted(l.items(), key=lambda x:x[0])

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