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

l = [0] * n

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

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

Submission status: Accepted

Solution code:
# 2020/04/19
# AtCoder Beginner Contest 163 - C

# Input
n = int(input())
a = list(map(int,input().split()))
alist = [0] * n

# Calc
for i in range(n-1):
    alist[a[i]-1] = alist[a[i]-1] + 1

# Output
for i in range(n):
    print(alist[i])

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
a_list = list(map(int, input().split())) # 2...N
a_list = map(lambda x: x-1, a_list)
counter = Counter(a_list)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input().rstrip())
d = {}
As = [int(x) for x in input().rstrip().split()]
for i in range(1, N+1):
    d[i] = 0
for n in As:
    d[n] += 1
for i in range(1, N+1):
    print(d[i])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n = ii()
    L = lmi_0()
    cnt = [0] * n
    for elm in L:
        cnt[elm] += 1
    for elm in cnt:
        print(elm)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

#print(N, A_list)

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

for ai in A_list:
   aa[ai-1] = aa[ai-1] + 1

for a in aa:
    print(a)

Submission status: Accepted

Solution code:
ninnzuu = int(input())
zyousi_list = input().split()
zyousi_list_int = []
buka_list = []
for i in range(len(zyousi_list)):
    zyousi_list_int.append(int(zyousi_list[i]))
    buka_list.append(0)
buka_list.append(0)
for j in range(len(zyousi_list)):
    buka_list[zyousi_list_int[j]-1] += 1
for l in range(ninnzuu):
    print(buka_list[l])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

b = []
for h in range(n):
    b.append(0)

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

for j in b:
    print(j)

Submission status: Accepted

Solution code:
import math
if __name__ == '__main__':
    N = int(input())
    s = input().rstrip().split(' ')
    temp = [int(elem) for elem in s] 
    A = [-1]*(N+1)
    for i in range(2,N+1):
        A[i] = temp[i-2]

    assign = {}
    for i in range(2, N+1):
        if A[i] in assign:
            assign[A[i]] += 1
        else:
            assign[A[i]] = 1

    for i in range(1, N+1):
        if not i in assign:
            assign[i] = 0

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

Submission status: Accepted

Solution code:
import collections
import math
import operator as op
from functools import reduce
from collections import Counter
import numpy as np
import math
import bisect
import heapq


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def main():
    N = get_input(int)
    A = get_inputs(int)


    idx2children = [[] for _ in range(N+1)]
    for i in range(2, N+1):
        idx2children[A[i-2]].append(i)

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



    










if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
lists=list(map(int,input().split()))
from collections import Counter
dic=dict(Counter(lists))
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=[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:
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())
a = list(map(int,input().split()))
t = [0]*(len(a)+1)

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

num=[0]*N
for i in A:
    num[i-1]+=1

for j in range(len(num)):
    print(num[j])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    N = int(input())
    A_list = list(map(int, input().split()))
    subordinate_counter_list = [0 for i in range(N)]
    for i in A_list:
        subordinate_counter_list[i-1] += 1
    for i in subordinate_counter_list:
        print(i)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

buka = [0]*(int(n))

for i in list:
    buka[i-1] += 1
    
for j in range(int(n)):
    print(buka[j])

Submission status: Accepted

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

N = int(input().strip())
A_list = list(map(int, input().rstrip().split()))
#-----

employee = {}  # { int : List[int] }

for i,v in enumerate(A_list):
    employee.setdefault(v,[])
    employee[v].append(i+2)

for i in range(1,len(A_list)+2):
    if i in employee:
        print( len(employee[i]) )
    else:
        print(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
import numpy as np

lines = stdin.readlines()

n = int(lines[0].rstrip().split()[0])
a_s = [int(x) for x in lines[1].rstrip().split()]

a_size = len(a_s)
res = np.zeros((a_size))

for i in range(a_size):
    res[a_s[i]-1] += 1

for j in range(n-1):
    print(int(res[j]))
print(0)

Submission status: Accepted

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

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

for s in sub:
    print(s)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from collections import Counter
N = int(input())
As = list(map(int, input().split()))
c = Counter(As)
for i in range(1,N):
    print(c[i])
print(0)

Submission status: Accepted

Solution code:
a = int(input())

list = [0 for i in range(a)]

data = []

data[len(data):len(data)] = map(int, input().split())

for i in data:
  list[i-1]+=1
  
for i in list:
  print(i)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdin, stdout
import math,sys
from itertools import permutations, combinations
from collections import defaultdict,deque,OrderedDict
import bisect as bi
import heapq 
'''
#------------------PYPY FAst I/o--------------------------------#

def I():return (int(stdin.readline()))
def In():return(map(int,stdin.readline().split()))
'''
#------------------Sublime--------------------------------------#

#sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');
def I():return (int(input()))
def In():return(map(int,input().split()))

def find_gt(a, x):
    #'Find leftmost value greater than x'
    i = bi.bisect_right(a, x)
    if i != len(a):
        return i
    else:
        return -1


def main():
    try:
        n=I()
        l=list(In())
        d={}
        for x in l:
            if d.get(x,0)!=0:
                d[x]+=1
            else:
                d[x]=1
        
        for i in range(1,n+1):
            if d.get(i,0)!=0:
                print(d[i])
            else:
                print(0)

            
    except:
        pass
        
M = 998244353
P = 1000000007

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re
import math
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul	# 
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd	# 最大公約数
from heapq import heappush, heappop

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

# -*- coding: utf-8 -*-
n = INT()
a = LIST()
list = [0] * (n + 1)

for x in a:
    list[x] += 1

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
N=int(input())
A=nl()


l_b=[0]*N

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

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

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

for i in As:
    res[i-1] += 1

for i in res:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(*A)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from operator import itemgetter
import collections
import math

def r(n, a):
    d = [0] * n
    for aa in a:
        d[aa-1] = d[aa-1] + 1
    for nn in range(n):
        print(d[nn])


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

    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

result = [0] * N

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

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

Submission status: Accepted

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

ans = [0]*a
for i in range(a-1):
    ans[li[i]-1] += 1
    
for j in range(a):
    print(ans[j])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x


def main():
    n = int(input().strip())
    a = list(map(lambda x : int(x) - 1, input().strip().split()))
    
    l=[0 for i in range(n)]
    for i in range(n-1):
        l[a[i]]+=1
        
    for i in range(n):
        print(l[i])
if __name__ == '__main__':
    main()

Submission status: Accepted

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

n = int(input())
boss_list = map(int, input().split())

subordinate_list = [0] * n
for boss in boss_list:
  subordinate_list[boss - 1] += 1

for subordinate in subordinate_list:
  print(subordinate)

Submission status: Accepted

Solution code:
def main():
    """"ここに今までのコード"""
from collections import Counter

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

dic = Counter(lis)

for i in range(1, n+1):
	print(dic[i])
    
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

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

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

for j in range(n):
	print("%d" % staff[j])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from collections import Counter

def solve():
    N = int(input())
    c =  Counter(input().split())
    return '\n'.join([str(c.get(str(i),0)) for i in range(1, N+1)])


if __name__ == '__main__':
    print(solve())

Submission status: Accepted

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

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

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

Submission status: Accepted

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

joushi_buka = [0 for ni in range(n)]
for ai in a:
    joushi_buka[ai-1] += 1

for jb in joushi_buka:
    print(jb)

Submission status: Accepted

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

ans=[0]*N

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

x = [0 for i in range(n)]

for j in range(n-1):
    x[l[j]-1] +=  1

for k in x:
    print(k)

Submission status: Accepted

Solution code:
N = int(input())

A = [int(i) for i in input().split()]

S = [0] * (N+1)

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

for s in S[1:]:
    print(s)

Submission status: Accepted

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

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

print('\n'.join(list(map(str, ans))))

Submission status: Accepted

Solution code:
from collections import defaultdict
n = int(input())
a = [int(x) for x in input().split()]
upper = defaultdict(int)
for i in range(1,n+1):
    upper[i] = 0
for i in a:
    upper[i] += 1
ans = sorted(upper.items())
for k,v in ans:
    print(v)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
ans = [0]*N
for a in range(len(A)-1,-1,-1):
    ans[A[a]-1] += 1
for a in ans:
    print(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
for i in S:
    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()))
import collections
c = collections.Counter(A)


for i in range(1, N+1):
    if c.get(i) != None:
        print(c.get(i))
    else:
        print(0)

Submission status: Accepted

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

for j in A:
    dictio[j] += 1

L = dictio.values()
print(*L, sep="\n")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

N=int(input())
X=list(map(int, input().split()))
c = collections.Counter(X)

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

Submission status: Accepted

Solution code:
import sys
N = int(input())
A = list(map(int, sys.stdin.readline().strip().split()))

ans = [0] * N
ans[0] = 0

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

for A in ans:
    print(A)

Submission status: Accepted

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

for i in a:
  num[i]+=1
  
for j in range(1,n+1):
  print(str(num[j]))

Submission status: Accepted

Solution code:
n=int(input())
li=[int(x) for x in input().split()]
d={}
for i in range(len(li)):
	if li[i] in d:
		d[li[i]]+=1
	else:
		d[li[i]]=1

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

for s in sub:
    print(s)

Submission status: Accepted

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

result = [0]*N

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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:


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

    count = [0] * (N)

    for i in range(len(A)):
        # print(i)
        count[A[i]-1] += 1

    for s in range(len(count)):
        print(count[s])






if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
a = list(map(lambda x: x - 1, a))

cnts = [0 for _ in range(n)]
for ai in a:
    cnts[ai] += 1

for cnt in cnts:
    print(cnt)

Submission status: Accepted

Solution code:
num = int(input())

s = input().split(" ")
count = [0 for i in range(1,num+1)]
#print(count)
for i in range(num-1):
    count[int(s[i])-1] += 1
#print(count)
for i in count:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
odata = input().split(' ')
data = [int(odata[i]) for i in range(n - 1)]
result = [0 for i in range(n)]
for per in data:
    result[per - 1] += 1

for per in result:
    print(per)

Submission status: Accepted

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

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

Submission status: Accepted

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

result = [0 for x in range(0, n)]

for i, v in enumerate(a):
	result[v-1] += 1

for i, v in enumerate(result):
	print(v)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

import sys, copy, math, heapq, bisect
from itertools import accumulate
from collections import deque, defaultdict, Counter
input = sys.stdin.readline # 文字列の入力のとき'/n'まで受け取るので注意!!!
sys.setrecursionlimit(500000)

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

C = Counter(A)
for i in range(N):
    print(C[i+1])

Submission status: Accepted

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

d = {}
for i in range(1, n+1):
    d[i] = 0

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

for k, v in d.items():
    print(v)

Submission status: Accepted

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

for i in range(len(a_list)):
    dp[a_list[i]-1] += 1

for j in range(len(dp)):
    print(dp[j])

Submission status: Accepted

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

if __name__ == '__main__':
  main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

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

A_count = Counter(A)

ans_list = [0] * N
for key in A_count:
  ans_list[key - 1] = A_count[key]
  
print(*ans_list)

Submission status: Accepted

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

map = [[i, 0] for i in range(1, n+1)]

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

for i in range(n):
    print(map[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 range(n):
    print(B[j])