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

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

for el in A_list:
    dic[el] += 1

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

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:
n=int(input())
A=input().split()

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
LI = lambda: list(map(int,input().split()))
MI = lambda: map(int,input().split())
yes = lambda: print("YES")
no = lambda: print("NO")
I = lambda: list(input())
J = lambda x: "".join(x)
II = lambda: int(input())
SI = lambda: input()
#---khan17---template
t = int(input())
a = LI()
d = {}
for i in a:
	if i not in d:
		d[i] = 1
	else:
		d[i]+=1
for i in range(1,t+1):
	if i in d:
		print(d[i])
	else:
		print(0)

Submission status: Accepted

Solution code:
n = int(input())
a_list = list(map(int, input().split(' ')))
ans_list = [0 for i in range(n)]

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

for ans in ans_list:
    print(ans)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,*A = map(int, read().split())

    E = [0]* (N)
    for a in A:
        E[a-1] += 1

    for e in E:
        print(e)



if __name__ == "__main__":
    main()

Submission status: Accepted

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

resolve()

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:
# -*- coding: utf-8 -*-


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    from collections import defaultdict
    n = input_int()
    a = input_to_int_tuple()

    syain = defaultdict(int)

    for a_i, josi_no in enumerate(a):
        syain_no = a_i + 1
        syain[josi_no] = syain[josi_no] + 1

    for syain_no in range(1, n + 1):
        print(syain[syain_no])


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=input()
arr=map(int, raw_input().split())
l=[0]*(n+1)
for i in xrange(len(arr)):
    l[arr[i]]+=1

for i in xrange(1, n+1):
    print l[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):
    
    if(i in c):
        print(c[i])
    else:
        print(0)

Submission status: Accepted

Solution code:
from sys import stdin


def get_result(data):
    N = data[0][0]
    A = data[1]
    ans = [0 for _ in range(N)]
    for val in A:
        ans[val-1] += 1
    for val in ans:
        print(val)


if __name__ == '__main__':
    raw_data = [val.rstrip() for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    get_result(data)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

B = [0 for _ 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_lst = [int(elem) for elem in input().split()]

import collections

c = collections.Counter(a_lst)
for i in range(1, n+1):
    if i in c.keys():
        print(c[i])
    else:
        print(0)

Submission status: Accepted

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

ans_list = [0] * N

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

for ans in ans_list:
    print(ans)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    l = [int(x) - 1 for x in input().split()]
    lb = [0] * n
    for no in l:
        lb[no] += 1
    for i in lb:
        print(i)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
cntA = Counter(A)

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

c = collections.Counter(A_list)

for i in range(1,N+1):
    if c.get(i) is not None:
        print(c[i])
    else:
        print(0)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

for i in R:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

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

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

for i in mem:
    print(i)

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())
    arr = list(map(int, input().split()))
    from collections import defaultdict
    nums = defaultdict(int)
    for num in arr:
        nums[num] += 1
    for i in range(1, N+1):
        print(nums.get(i, 0))
resolve()

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]].append(i + 2)
    else:
        d[A[i]] = [i + 2]

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

Submission status: Accepted

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

Submission status: Accepted

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

def main():
     n = int(input())
     boss = list(map(int, input().split()))
     ans = [0 for i in range(n)]

     for i in range(len(boss)):
          ans[boss[i]-1] += 1
     
     for i in range(len(ans)):
          print(ans[i])

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict
N=int(input())
L=list(map(int,input().split()))
L.insert(0,0)
Hash=defaultdict(lambda:0)
for i in L:
    Hash[i]+=1
for i in range(1,N+1):
    print(Hash[i])

Submission status: Accepted

Solution code:

N = int(input())
A = [int(x) for x in input().split()]
d = {}
for i in range(N-1):
    try:
        d[A[i]] += 1
    except:
        d[A[i]] = 1
for i in range(N):
    try:
        print(d[i+1])
    except:
        print(0)

Submission status: Accepted

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

ans = [0] * N

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

Submission status: Accepted

Solution code:
from collections import Counter


n = int(input())
A = Counter(list(map(int, input().split())))
for i in range(1, n + 1):
    print(A.get(i, 0))

Submission status: Accepted

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

Submission status: Accepted

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

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

for x in ans:
    print(x)

Submission status: Accepted

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

N = int(input())

I = input().split()

Buka = [0] * N

for i in range(N-1):
    Buka[ int(I[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()))
# print(A)
B = [0]*n

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

for b in B:
    print(b)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

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

S = [0] * N

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

for s in S:
    print(s)

Submission status: Accepted

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

Submission status: Accepted

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

temp_dict = {}
for i in A_list:
    if i not in temp_dict:
        temp_dict[i] = 1
    else:
        temp_dict[i] += 1

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

n = int(input())
a = [int(x) for x in input().split()]
r = [0] * (n + 1)

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

for x in r[1:]:
    print(x)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log,pi
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？


n=ii()
arr=limii()
ans=[0]*n
for i in arr:
    ans[i-1]+=1
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
import sys
from collections import Counter


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

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

count = Counter(A)

for i in range(N):
  if count.get(i):
    print(count.get(i))
  else:
    print(0)

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

n = int(input())
a = list(map(int, input().split()))
buka = [0 for _ 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 defaultdict
n = int(input())
a = list(map(int, input().split()))
cnt = defaultdict(int)
for i in range(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()))

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

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
from collections import defaultdict
n = int(input())
arr = list(map(int, input().split(" ")))

di = defaultdict(int)

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
As = input().split()

ans = [0] * (n+1)
for a in As:
    ans[int(a)] += 1

ansstr = ""
for i in range(1, n+1):
    print(ans[i])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a_list = list(map(int,input().split()))
l = [0 for _ in range(n-1)]

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
# import sys

# A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
N = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
# A, B = [str(x) for x in stdin.readline().rstrip().split()]

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

# print(A)
d = {}
for i in range(len(A)):
    d[A[i]] = d.get(A[i], 0)+1
for i in range(1, N[0]+1):
    print(d.get(i, 0))

Submission status: Accepted

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

import sys

DEBUG = False

def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep = " "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    n = read(int)
    as_ = read_list(int)

    buka = [0] * (n + 1)
    for i, a in enumerate(as_):
        buka[a] += 1

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

if __name__ == "__main__":
    main()

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

from collections import Counter
cnt = Counter(A)

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

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
counter = Counter(map(int, input().split()))

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

Submission status: Accepted

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

result = [0] * N
for v in A:
    result[v - 1] += 1

for v in result:
    print(v)

Submission status: Accepted

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

Submission status: Accepted

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


def main():
  N = int(input())
  counts = [0] * N

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

  for c in counts:
    print(c)


if __name__ == '__main__':
  main()

Submission status: Accepted

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

Submission status: Accepted

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

result = [0]*n

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

for ri in result:
    print(ri)

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:
import sys
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()
A = rl()

B = [0] * (len(A)+1)
for i, a in enumerate(A):
    j = a - 1
    B[j] += 1
for b in B:
    print(b)

Submission status: Accepted

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


INF=1001001001
__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


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

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x



if __name__ == '__main__':
    N = intinput()
    datas = list(mulinputs())
    bucket = [0] * N
    for data in datas:
        bucket[data-1] += 1

    # 出力
    for b in bucket:
        print(b)

Submission status: Accepted

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

for m in man:
    emp[m-1] += 1

for e in emp:
    print(e)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = sorted(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(n):
  i += 1
  if i in d:
    print(d[i])
  else:
    print(0)

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())
    A = tuple(map(int, input().split()))
    AL = [0]*N

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

    for al in AL:
        print(al)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
N = input()
A = input().split()

N = int(N)
A = [int(a) for a in A]

ans = [0 for _ in range(N)]
for a in A:
    ans[a-1] += 1

for a in ans:
    print(a)

Submission status: Accepted

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

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(1)
	n = int(sys.stdin.readline())
	a = list(map(int, sys.stdin.readline().split()))
	cnt = {}
	for i in range(len(a)):
		cnt[a[i]-1] = cnt.get(a[i]-1, 0) + 1
	for i in range(n):
		print(cnt.get(i, 0))


	


main()

Submission status: Accepted

Solution code:
#C

#デバッグ
debug=1
def pront(*n):
    if debug==1:
        print(n)
        
#10**9+7を底とした処理

base=10**9+7

def add(a,b):#a+b
    return (a+b)%base

def sub(a,b):#a-b
    return (a-b)%base

def multi(a,b):#a*b
    return (a*b)%base

def exp(a,b):#a**b
    x=1
    c=a
    d=b
    while d!=0:
        if d%2==1:
            x=multi(x,c)
        c=(c**2)%base
        d=d//2
    return x

def div(a,b):#a/b
    return(multi(a,exp(b,base-2)))

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

#処理
X={}

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

for i in range(N+1):
    if i==0 or i==1:
        continue
    if i in X:
        X[A[i-2]]+=1
    else:
        X[A[i-2]]=1
        
for i in X.values():
    print(i)

Submission status: Accepted

Solution code:
N = int(input())

A = list(map(int, input().split()))
rel = [0] * (N+1)

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

for r in rel[1:]:
    print(r)

Submission status: Accepted

Solution code:

from collections import defaultdict
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input().rstrip()))
def inlt():
    return(list(map(int,input().rstrip().split())))
def insr():
    s = input().rstrip()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().rstrip().split()))
################################################################
n = inp()
nums = inlt()
num_dict = defaultdict(int)
for i in range(n - 1):
    num_dict[nums[i]] += 1

for i in range(1,n + 1):
    print(num_dict[i])
    
#print(n - s if s <= n else -1)
#print('No')
#print()

Submission status: Accepted

Solution code:
import sys
import os
from io import BytesIO, IOBase

#########################
# imgur.com/Pkt7iIf.png #
#########################

# returns the list of prime numbers less than or equal to n:
'''def sieve(n):
    if n < 2: return list()
    prime = [True for _ in range(n + 1)]
    p = 3
    while p * p <= n:
        if prime[p]:
            for i in range(p * p, n + 1, p):
                prime[i] = False
        p += 2
    r = [2]
    for p in range(3, n + 1, 2):
        if prime[p]:
            r.append(p)
    return r'''

# returns all the divisors of a number n(takes an additional parameter start):
'''def divs(n, start=1):
    divisors = []
    for i in range(start, int(n**.5) + 1):
        if n % i == 0:
            if n / i == i:
                divisors.append(i)
            else:
                divisors.extend([i, n // i])
    return len(divisors)'''

# returns the number of factors of a given number if a primes list is given:
'''def divn(n, primes):
    divs_number = 1
    for i in primes:
        if n == 1:
            return divs_number
        t = 1
        while n % i == 0:
            t += 1
            n //= i
        divs_number *= t
    return divs_number'''

# returns the leftmost and rightmost positions of x in a given list d(if x isnot present then returns (-1,-1)):
'''def flin(d, x, default=-1):
    left = right = -1
    for i in range(len(d)):
        if d[i] == x:
            if left == -1: left = i
            right = i
    if left == -1:
        return (default, default)
    else:
        return (left, right)'''

#count xor of numbers from 1 to n:
'''def xor1_n(n):
    d={0:n,1:1,2:n+1,3:0}
    return d[n&3]'''

def cel(n, k): return n // k + (n % k != 0)
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(map(int, input().split()))
def lcm(a, b): return abs(a * b) // math.gcd(a, b)
def prr(a, sep=' '): print(sep.join(map(str, a)))
def dd(): return defaultdict(int)
def ddl(): return defaultdict(list)
def ddd(): return defaultdict(defaultdict(int))

# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

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

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

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

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


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


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

from collections import defaultdict 
#from collections import deque
#from collections import OrderedDict
from math import gcd,pi
#import time
#import itertools
#import timeit
#import random
#from bisect import bisect_left as bl
#from bisect import bisect_right as br
#from bisect import insort_left as il
#from bisect import insort_right as ir
#from heapq import *
#from queue import PriorityQueue
#mod=998244353
#mod=10**9+7
# for counting path pass prev as argument:
# for counting level of each node w.r.t to s pass lvl instead of prev:

n=ii()
a=li()
d=dd()
for i in a:
    d[i]+=1
for i in range(1,n+1):
    print(d[i])