Problem:


Score : 300 points

Problem Statement

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

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

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

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

Constraints

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

1 \leq A_i < i

Input

Input is given from Standard Input in the following format:

N
A_2 ... A_N

Output

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

Sample Input 1

5
1 1 2 2

Sample Output 1

2
2
0
0
0

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

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

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

Sample Input 2

10
1 1 1 1 1 1 1 1 1

Sample Output 2

9
0
0
0
0
0
0
0
0
0

Sample Input 3

7
1 2 3 4 5 6

Sample Output 3

1
1
1
1
1
1
0



Sample input:
5
1 1 2 2


Sample output:
2
2
0
0
0

Submission status: Accepted

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

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

Submission status: Accepted

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

from collections import Counter

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

Submission status: Accepted

Solution code:
N=int(input())
A=input().split()
S=[int(a)-1 for a in A]
numbers=[0]*N
for z in S:
    numbers[z]+=1
for b in numbers:
    print(b)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
#N, M, C = (int(i) for i in input().split())
#B = [int(x) for x in stdin.readline().rstrip().split()]
#A = [[int(i) for i in input().split()] for i in range(N)]
N = int(input())
A = [int(x) for x in input().split()]

persons = [0]*(N+1)

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

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

Submission status: Accepted

Solution code:
from collections import Counter
def main():
  N = int(input())
  A = Counter([int(_) for _ in input().split()])
  for i in range(1, N+1):
    print(A[i])
  return

if __name__ == '__main__':
  main()

Submission status: Accepted

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

# C - management

n = int(input())
a = list(map(int, input().split()))
assert len(a) == n - 1

sub = [0] * n
for b in a:
    sub[b - 1] += 1

for s in sub:
    print(s)

Submission status: Accepted

Solution code:
import sys,math,copy,queue,itertools,bisect
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))
N = NI()
A = [0 for _ in range(N+1)]
S = LI()
for i in S:
    A[i] += 1
for i in range(1,N+1):
    print (A[i])

Submission status: Accepted

Solution code:
N = int(input())
a_list = list(map(int, input().split()))
dic_a = {}
for i in range(N-1):
    if a_list[i]-1 in dic_a:
        dic_a[a_list[i]-1] += 1
    else:
        dic_a[a_list[i]-1] = 1
ans = [0 for i in range(N)]
for k,v in dic_a.items():
    ans[k] = v
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
a = list(map(lambda x: int(x) - 1, input().split()))
ind = [0] * n
for i, x in enumerate(a):
    ind[x] += 1
print(*ind, sep="\n")

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
import re
import math
from collections import defaultdict
import itertools
from copy import deepcopy
import random
from heapq import heappop,heappush
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
readline=sys.stdin.readline
sys.setrecursionlimit(2000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_power(a,b):#aはbの累乗数か
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)
###################################################
def main():
    n=int(input())
    A=list(map(int,input().split()))
    B=[0]*n
    for a in A:
        B[a-1]+=1
    for b in B:
        print(b)
main()

Submission status: Accepted

Solution code:
c = [0]*int(input())
for x in input().split():
  c[int(x)-1]+=1
print('\n'.join(str(x) for x in c))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

for a in ans:
    print(a)

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))
def inpl_str():
    '''
    一行に複数の文字
    '''
    return list(input().split())

n = inp()
a = inpl()
ans = defaultdict(lambda: 0)
for i in a:
    ans[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()))

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 for _ in range(N)]

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

for i in ans:
    print(i)

Submission status: Accepted

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

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

b = [0] * (n + 1)

for e in a:
  b[e] += 1

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

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
f=[[] for j in range(n+1)]

for i in range(len(a)):
    f[a[i]-1].append(i)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

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

rtn = np.zeros(n, dtype=int)
for i in a:
    rtn[i-1] += 1

for x in rtn:
    print(x)

Submission status: Accepted

Solution code:
# coding: utf-8
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:
def main():

    N = int(input())
    A = list(map(int, input().split()))
    d = dict()
    for i in range(len(A)):
        d[A[i]] = d.get(A[i], 0) + 1
    for i in range(1, len(A)+2):
        if i in d:
            print(d[i])
        else:
            print(0)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect
import collections
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline
ACMOD = 1000000007
INF = 1 << 62


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


def llmi(n):
    return [lmi() for _ in range(n)]


N = int(input())
A = lmi()

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 19 21:04:52 2020

@author: black
"""


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:
import sys
input = sys.stdin.readline
N = int(input())
A= list(map(int,input().split()))
a=0
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()))
l=[0 for i in range(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(int, input().split()))
ans = [0 for _ in range(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()))

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

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

Submission status: Accepted

Solution code:
N=int(input())
ls=[int(s) for s in input().split()]
ans=[0 for _ in range(N)]
for e in ls:
  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()))

list =[0] * n

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


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

Submission status: Accepted

Solution code:
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	a = int(input())
	al = list(IN())
	#b , c = IN()
	#s = input()
	cc=[0]*a
	for v in al:
		cc[v-1]+=1
	for c in cc:
		print(c)
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
#from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [LI()for i in range(n)]
#inf = 10**17
#mod = 10**9 + 7
#s=input().rstrip()
    
n=I()
A=LI()
ans=[0]*n
for a in A:
    ans[a-1]+=1
for answer in ans:
    print(answer)

Submission status: Accepted

Solution code:
def main():
    from collections import Counter
    n, *a = map(int, open(0).read().split())
    b = Counter(a)
    for i in range(1, n + 1):
        m = b.get(i)
        if m is None:
            m = 0
        print(m)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
from collections import Counter

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N = int(input())
    A = [0, 0] + list(map(int, input().split()))
    # print(A)
    count = Counter(A)
    for i in range(1, N + 1):
        print(count[i])


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

dic = defaultdict(int)
for i in range(2, N+1):
    own_snum = i
    joshi = A[i-2]
    # dic[joshi].append(i)
    dic[joshi] += 1
for i in range(1, N+1):
    print(dic[i])

Submission status: Accepted

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

nodes = [[] for i in range(n)]

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# py abc163c.py
bosses = {}
n = int(input())
arr = list(map(int,input().split()))
for i in range(n):
	bosses[i+1] = 0
for i in arr:
	bosses[i]+=1

for i in bosses.values():
	print(i)

Submission status: Accepted

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

Submission status: Accepted

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

p_dict = {}

for i in range(n):
    p_dict[i+1] = 0

for a in a_list:
    p_dict[a] += 1

for k in p_dict:
    print(p_dict[k])

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

Submission status: Accepted

Solution code:
n = int(input())
a_list = map(int, input().split())
people_dic = {}
for person_num in range(1, n+1):
    people_dic[person_num] = 0
for a in a_list:
    people_dic[a] += 1

for cost in list(people_dic.values()):
    print(cost)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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 a in A:
    l[a-1] += 1

for l_i in l:
    print(l_i)

Submission status: Accepted

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

res_dict = {}
for i in range(len(a)):
    if not a[i] in res_dict.keys():
        res_dict[a[i]] = 1
    else:
        res_dict[a[i]] += 1

for i in range(len(a)+1):
    if not i+1 in res_dict.keys():
        print(0)
    else:
        print(res_dict[i+1])

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:
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

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

N = one_int()
A=many_int()

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

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

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

Submission status: Accepted

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

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

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

for i in B:
    print(i)

Submission status: Accepted

Solution code:
import math
import copy
import sys
import fractions
# import numpy as np
# import statistics
import decimal
import heapq
import collections
import itertools
import bisect

# from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputIntList():
    outputDataList = []
    inputData = input().split()
    outputDataList = [int(n) for n in inputData]

    return outputDataList


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = int(input())
data = getInputIntList()

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

for d in data:
    ans[d] += 1

for i, a in enumerate(ans):
    if i == 0 : continue
    print(a)

Submission status: Accepted

Solution code:
import collections
from collections import defaultdict

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

ans = defaultdict(int)
for i in range(n):
    ans[i] = 0


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

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

Submission status: Accepted

Solution code:
import collections

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

count = collections.Counter(a)

for i in range(1,n+1):
	print(count[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()))
n = [0]*(N)

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

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

Submission status: Accepted

Solution code:
from collections import OrderedDict

d = OrderedDict()

N = int(input())

for i in range(N):
    d[i] = 0

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

for key, value in d.items():
    print(value)

Submission status: Accepted

Solution code:
n = int(input())

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

ans = [0]*n

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

for a in ans:
  print(a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

li = [0]*(n)

for i in range(n-1):
    li[ai[i]-1] += 1
    
for i in range(n):
    print(li[i])

Submission status: Accepted

Solution code:
n = int(input())

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

sub = [0] * (n + 2)

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

for i in range(1, len(a) + 2):
    print(sub[i])

Submission status: Accepted

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

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:
from collections import Counter as C
n,*a=map(int,open(0).read().split())
a=C(a)
for i in range(1,n+1):
    print(a[i])

Submission status: Accepted

Solution code:
def main():
    N=int(input())
    A=[int(_) for _ in input().split()]
    S=[0]*N
    for a in A:
        S[a-1]+=1
    for s in S:
        print(s)

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math  # noqa
import bisect  # noqa
import queue  # noqa


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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
ans = [0]*n
s = list(map(int,input().split()))
k = dict(Counter(s))
for i in k:
    ans[i-1] = k[i]
print(*ans,sep="\n")

Submission status: Accepted

Solution code:
n = int(input())
out = [0] * n
l = map(int,input().split())
for v in l:
    out[v - 1] += 1
print('\n'.join(map(str,out)))

Submission status: Accepted

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

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

for n in ans:
    print(n)

Submission status: Accepted

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

Submission status: Accepted

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

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

for i in b:
    print(i)

Submission status: Accepted

Solution code:

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

res_list = [0] * N

for i in A_list:
    res_list[i-1] += 1

for i in res_list:
    print(i)

Submission status: Accepted

Solution code:
n=int(input())

import collections

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

c = collections.Counter(l)

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 for k in range(N)]
for k in range(N-1):
    B[A[k]-1]+=1
for k in range(N):
    print(B[k])

Submission status: Accepted

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

A = [a-1 for a in A]

A.reverse()

B = [0]*n

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

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

Submission status: Accepted

Solution code:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N = ir()
    A = lr()
    t = [0]*N
    for i in range(1, N):
        t[A[i-1]-1] += 1
    print(*t, sep='\n')
resolve()

Submission status: Accepted

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

N = int(input())

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

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

for k in cnt:
    print(k)

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

Submission status: Accepted

Solution code:
from collections import defaultdict


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


association = defaultdict(int)
for a in A:
    association[a-1] += 1


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
N = int(input())
A = list(map(int,input().split()))
d = {}
for i in A:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
for i in range(1,N+1):
    if i in d.keys():
        print(d[i])
    else:
        print(0)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
cnt = Counter(a)
ans = [0]*n
for k in cnt.keys():
    ans[k-1] = cnt[k]
for i in range(n): print(ans[i])