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 sys
import socket

hostnames = ['N551J', 'F551C', 'X553M']
input_file = 'c1.in'
# if socket.gethostname() in hostnames:
#     sys.stdin = open(input_file)


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


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():

    cache = {}
    def f(x):
        if x in cache:
            return cache[x]

    n = read_int()
    a = read_int_list()
    s = [[] for i in range(n)]
    for i in range(n - 1):
        s[a[i] - 1].append(i + 1)
    res = [len(x) for x in s]
    res = '\n'.join(map(str, res))
    return res


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# =map(int,input().split())
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][0]+=1
for i in range(n):
    print(ans[i][0])

Submission status: Accepted

Solution code:
import numpy as np

def main():
    n = int(input())
    a = list(map(int, input().split()))
    c = np.zeros([n], dtype=int)
    for i in a:
        c[i-1] += 1

    for i in c:
        print(i)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

for i in range(N-1):
    counter[As[i]-1] += 1

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

N = int(input())
nums = [int(x.strip()) for x in input().split(' ') ] # 1人は関係ない
leng = len(nums)+ 1
l = [0] * leng

for num in nums:
    l[num-1] = l[num-1] + 1

for ans in l:
    print(ans)

Submission status: Accepted

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

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())
A=[int(x) for x in input().rstrip().split()]
ans=[0 for i 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())
lis = list(map(int, input().split()))
dic = {}
for i in lis:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] =1
for i in range(1, n + 1):
    print(dic.get(i, 0))

Submission status: Accepted

Solution code:
from collections import Counter

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

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

Submission status: Accepted

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

boss_list = A

subordinaties = [0] * N
for boss in boss_list:
    index_of_boss = boss - 1
    subordinaties[index_of_boss] += 1

for subodinate in subordinaties:
    print(subodinate)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = [0]*n;

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

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

Submission status: Accepted

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

ans = np.zeros(N)

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

for i in range(N):
    print(int(ans[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 c[i]:
    print(c[i])
  else:
    print('0')

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n = int(input())
subords = dict()

ords = [int(x) for x in input().split()]

for boss in ords:
    if boss not in subords:
        subords[boss] = 0
    subords[boss] += 1


for boss in range(1, n + 1):
    if boss in subords:
        print(subords[boss])
    else:
        print('0')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    arr = list(map(int,input().split()))
    counts = [0]*(n+1)
    for i in arr:
        counts[i] += 1

    counts.pop(0)
    for i in counts:
        print(i)
        

main()

Submission status: Accepted

Solution code:

# coding: utf-8
import sys
# import collections

# import bisect
# import math
import numpy as np

# from fractions import gcd

"""Template"""


class IP:
    """
    入力を取得するクラス
    """

    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        # 参考
        # https://blog.rossywhite.com/2018/08/06/bit-search/
        # https://atcoder.jp/contests/abc105/submissions/4088632
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    # output.append(a[j])
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def S(self, s, r=0, m=-1):
        """
        ソート関係行います。色々な設定あります。
        :param s: 元となるリスト
        :param r: reversするかどうか 0=False 1=True
        :param m: （2次元配列）何番目のインデックスのソートなのか
        :return: None
        """
        r = bool(r)
        if m == -1:
            s.sort(reverse=r)
        else:
            s.sort(reverse=r, key=lambda x: x[m])

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x // y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)

    def gcd(self, x, y):
        if y == 0:
            return x
        else:
            return self.gcd(y, x % y)

    def lcm(self, x, y):
        return (x * y) // self.gcd(x, y)


"""ここからメインコード"""


def main():
    # 1文字に省略
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    # n, m = ip.IL()
    # a = np.array(ip.IL())
    # for _ in range(m):
    #     a[np.argmax(a)] //= 2
    # print(np.sum(a))
    n = int(input())
    a = np.array(ip.IL())
    
    b = np.bincount(a)[1:]
    m = len(b)
    others = np.zeros(n-m).astype(int)
    # print(b, others)
    print(*b, sep="\n")
    print(*others, sep="\n")
    

main()

Submission status: Accepted

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

c=dict(collections.Counter(a))
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())
listA = list(map(int, input().split()))
memL = [0]*n

for i in range(len(listA)):
    memL[listA[i]-1]+=1

for mem in memL:
    print(mem)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
from collections import defaultdict
sys.setrecursionlimit(10**8)
INF = float("inf")

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


class Graph(object):
    def __init__(self, N):
        self.N = N
        self.E = defaultdict(list)

    def add_edge(self, src, dest, w=1):
        self.E[src].append((dest, w))


g = Graph(N)
for i in range(N-1):
    g.add_edge(A[i]-1, i+1)

for i in range(N):
    print(len(g.E[i]))

Submission status: Accepted

Solution code:
from collections import Counter
import numpy as np
N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
b = np.bincount(A,minlength=N+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()))

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

Submission status: Accepted

Solution code:
import sys
import collections
# from pprint import pprint

N = int(input())
A = map(int, sys.stdin.readline().split())

ans = collections.Counter(A)

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N = INT()
A = LIST()
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
def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnt = [0] * n
    ac = Counter(a)
    for i in range(n):
        cnt[i] = ac[i+1]
    for i2 in range(n):
        print(cnt[i2])


if __name__ == '__main__':
    main()

Submission status: Accepted

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

d={}
for i in range(n-1):
  if l[i] not in d:
    d[l[i]]=1
  else:
    d[l[i]]+=1

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

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

inputLine=input()
A=inputLine.split(" ")

result = []
for i in range(N):
    result.append(0)

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

for i in B:
	print(i)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a_lst = map(int,input().split())
counts = [0 for _ in range(n+1)]
for a in a_lst:
    counts[a] += 1
    
for cnt in counts[1:]:
    print(cnt)

Submission status: Accepted

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

#intの場合
N = int(input())

#intの場合
huga = list(map(int, input().split()))
L = [0] * N

for n in huga:
  L[n-1] += 1
  
[print(i) for i in L]

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N = int(input())
A = list(map(int,input().split()))

M = {}
for a in A:
    try:
        M[a-1]+=1
    except KeyError:
        M[a-1]=1
for x in range(N):
    try:
        print(M[x])
    except KeyError:
        print(0)

Submission status: Accepted

Solution code:
from collections import defaultdict
def c163(n, al):

    count = defaultdict(int)

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

    return count

def main():
    n = int(input())
    al = list(map(int, input().split()))
    dilist = c163(n, al)
    for i in range(1 , n + 1):
        try:
            print(dilist[i])
        except:
            print("0")

if __name__ == '__main__':
    main()

Submission status: Accepted

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

result = [0]*n

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())

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

ans = np.zeros(n, dtype=np.int)

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

for i in range(ans.size):
  print(ans[i])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
P = [int(x)-1 for x in input().split()]
subs = [0]*n
for p in P:
    subs[p] += 1
print(*subs, sep='\n')

Submission status: Accepted

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

A=[0]

for i in range(N):
    A.append(0)

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
p = [int(x) for x in input().split()]

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import numpy as np
import math

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

buka_num = np.array([0]*N)

for a in A:
    buka_num[a-1] += 1
    
for b in buka_num:
    print(b)

Submission status: Accepted

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

Submission status: Accepted

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

cnt_a = [0]*n

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

Submission status: Accepted

Solution code:
from collections import Counter


N=int(input())

s_list = map(int, input().split())

count_s = Counter(s_list)
for i in range(1, N+1):
    print(count_s[i])

Submission status: Accepted

Solution code:
import collections

N = int(input())
S = input().split()

c = collections.Counter(list(S))

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

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

Submission status: Accepted

Solution code:
import collections
n=int(input())
a=list(map(int,input().split()))
m=max(a)
c=collections.Counter(a)
c=c.most_common()
l=[0]*n
for i in range(len(c)):
    l[c[i][0]-1]=c[i][1]
print(l[0])
for j in range(1,n):
    print(l[j])

Submission status: Accepted

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

from sys import stdin
from collections import defaultdict


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

    B = defaultdict(lambda: 0)
    for a in A:
        B[a] += 1

    for n in range(1, N + 1):
        print(B[n])


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import collections
N = int(input())
A = [int(x) for x in input().split()]
c = collections.Counter(A)

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

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
A = iil()
l = [0]*n

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

for i in l:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

tmp = [0 for i in range(N+1)]

for i in ls:
  tmp[i] += 1

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

Submission status: Accepted

Solution code:
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
DP2 = lambda d1, d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1, d2, d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]
from collections import Counter

def main():
    n = II()
    aa = [0] + MII()
    c = Counter(aa)
    for i in range(n):
        print(c[i+1])


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

#output
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)

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

Submission status: Accepted

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

d = defaultdict(int)

for i in A:
    d[i] += 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()))

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

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

Submission status: Accepted

Solution code:
import math
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())
n = ii()
a = li()
b = [0]*(n+10)
for i in range(n-1):
    b[a[i]-1]+=1
for i in range(n):
    print(b[i])

Submission status: Accepted

Solution code:
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
from collections import deque, defaultdict, Counter
import math
import sys
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def main():
    N = int(input())
    A = wi()
    d = defaultdict(int)
    for i in range(0, N-1):
        d[A[i]] += 1
    # print(d)
    for i in range(N):
        print(d[i+1])


if __name__ == '__main__':
    main()

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

Submission status: Accepted

Solution code:
# python3
# -*- coding: utf-8 -*-
import sys
import math
import bisect
from fractions import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint

INF = float('inf')

ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
lmtx = lambda h: [list(map(int, lmis())) for _ in range(h)]
sys.setrecursionlimit(1000000000)


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


# main
n = ii()
alist = lmis()

jlist = [0] * (n+1)

for i in range(n-1):
    jlist[alist[i]] += 1

for j in jlist[1:]:
    print(j)

Submission status: Accepted

Solution code:
N = int(input())
A = list(input().split(" "))
A = [int(i) for i in A]
joushi={}
for i in range(1,N+1):
    joushi[i]=0
for i in A:
    if i in joushi:
        joushi[i]+=1
for v in joushi.values():
    print(v)

Submission status: Accepted

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

Submission status: Accepted

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

dict = {}

for i in range(len(a)):
  dict[i]=0

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

print(0)

Submission status: Accepted

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

    # N = 5
    # A = [1, 1, 2, 2]

    dict = {}
    for num in A:
        if num in dict:
            dict[num] += 1
        else:
            dict[num] = 1

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


if __name__ == '__main__':
    main()

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:


def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    from collections import defaultdict
    count = defaultdict(int)
    for a in A:
        count[a] += 1

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections


def main():
    n = int(input())
    a = input_list()
    ac = collections.Counter(a)
    for i in range(n):
        if i+1 in ac:
            print(ac[i+1])
        else:
            print(0)


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


main()

Submission status: Accepted

Solution code:
def main(n: int, a: list):
    t = [0 for _ in range(n)]

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

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


if __name__ == "__main__":
    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()))
sum = [0 for i in range(n)]
for i in range(n-1):
    num = a[i]
    sum[num-1] += 1
for i in range(n):
    print(sum[i])

Submission status: Accepted

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

###
# main
if(__name__ == '__main__'):
    # input
    n = int(input())
    a = list(map(int, input().split(" ")))

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

    for elem in a:
        boss_num_list[elem-1] += 1

    for ans in boss_num_list:
        print(ans)

# else:
    # do nothing

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

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())
a_list = list(map(int, input().split()))
count = [0] * (n + 1)
for a in a_list:
    count[a] += 1
for i in range(1, n + 1):
    print(count[i])

Submission status: Accepted

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

for a in ans:
    print(a)

Submission status: Accepted

Solution code:
import numpy as np

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

M = np.zeros(N)

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

Submission status: Accepted

Solution code:

a=int(input())
syali=[0] * a
li=list(map(int,input().split()))

for i in li:
    syali[i-1]+=1

for i in syali:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

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

def calculate(n,arr):

    result = [set() for i in range(n)]

    for index,ar in enumerate(arr):
        ar = ar - 1
        result[ar].add(index+1)


    for res in result:
        print(len(res))

calculate(N,ARR)

Submission status: Accepted

Solution code:
n = int(input())
arr = map(int, input().split())
d = {}
for i in arr:
    i -= 1
    if i not in d:
        d[i] = 1
    else:
        d[i] += 1

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

Submission status: Accepted

Solution code:
N = int(input())

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

shine = [0] * (len(A)+1)

# A は 1 から
for jyo in A:
    shine[jyo-1] += 1
    

for s in shine:
    print(s)

Submission status: Accepted

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

ans=[0]*n

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