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:
from collections import Counter

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

ll = Counter(l)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter,mul
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left,bisect_right
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time
#from functools import lru_cache,reduce
#from math import factorial,hypot
#import sys
#from fractions import gcd
setrecursionlimit(10**6+1)
input=stdin.readline

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

Submission status: Accepted

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

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

for item in a:
    N[item] += 1

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

Submission status: Accepted

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

c = collections.Counter(a)

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().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:
def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    result = [0] * N
    for boss in A:
        result[boss-1] += 1
    for x in result:
        print(x)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

l = [0]*(n+1)
for i in range(n-1):
  l[a[i]] += 1
  
print(*l[1:], sep = '\n')

Submission status: Accepted

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

ans = [0 for _ in range(len(a)+1)]
count = 0
for t in a:
    ans[t-1] += 1
for i in ans:
    print(i)

Submission status: Accepted

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

for ans in count:
  print(ans)

Submission status: Accepted

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

from collections import Counter

c=Counter(IDs)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

# sys.setrecursionlimit(100000)
input = sys.stdin.buffer.readline
INF = 2**62-1


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


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    b = Counter()
    for a in A:
        b[a] += 1

    return '\n'.join(map(str, [b[i] for i in range(1, N+1)]))


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

for i in list1:
    list2[i-1]+=1

for i in list2:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(str,input().split()))
from collections import Counter
x = Counter(a)
for i in range(1,n+1):
    print(x[str(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 an in ans:
    print(an)

Submission status: Accepted

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

Submission status: Accepted

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

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

for i in range(n):
    print(ans[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:
#!/usr/bin/env python3
import collections

def main():
    *I, = map(int, open(0).read().split())
    N = I[0]
    A = I[1:]

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

main()

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split()))
a_len = len(a)
b = [0] * (a_len + 1)

for i in range(a_len):
    b[(a[i] -1)] += 1

for shain in b:
    print(shain)

Submission status: Accepted

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

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

for x in lst:
    box[x] += 1

for mybuka in box[1:n+1]:
    print(mybuka)

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

Submission status: Accepted

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

l = [0] * n

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import collections
n = int(input()) 
l = sorted(list(map(int, input().split())))
c = collections.Counter(l)
[print(c[i]) for i in range(1, n+1)]

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
# sys.stdin = open('input.txt')

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

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

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

Submission status: Accepted

Solution code:
from itertools import repeat
 
n = int(input())
lis = list(map(int, input().split()))
d = [[0] for i in repeat(None, n)]
 
for i in lis:
  d[i - 1][0] += 1
  
for i in d:
  print(i[0])

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

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

all_list = []

for i in range(N):
    all_list.append(0)
    
for i in range(N - 1):
    all_list[input2[i] - 1] += 1
    
for i in range(N):    
    print(all_list[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 buka:
    print(i)

Submission status: Accepted

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

for j in a:
    aa[j-1]  += 1
    #print(j)


for k in aa:
    print(k)

Submission status: Accepted

Solution code:
"""
NTC here
"""
 

#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase

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

def main():
    T = 1
    while T:
        T-=1
        n = iin()
        a = lin()
        ans = [0]*(n)
        for i in a:
            ans[i-1]+=1
        print(*ans, sep='\n')

        
        








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

# endregion

if __name__ == "__main__":
    main()

Submission status: Accepted

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

from collections import Counter
from collections import deque

c = Counter(A)
d = deque(sorted(c.most_common()))
# print(d)

# print(d.popleft())

frg = True
for i in range(1, n+1):
    if d and frg:
        _q = d.popleft()
        frg = False
    elif not d and frg:
        _q = (-1, -1)

    if _q[0] == i:
        print(_q[1])
        frg = True

    else:
        print(0)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect

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


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n = I()
    a = LI()
    ca = Counter(a)
    for i in range(1,n):
        print(ca[i])
    print(0)
    return


if __name__ == "__main__":
    solve()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# cook your dish here
n=int(input())
arr=list(map(int,input().split()))
blank=[0]*n
for i in range(len(arr)):
    blank[arr[i]-1]+=1
for i in blank:
    print(i)

Submission status: Accepted

Solution code:
import collections
N = int(input())
A = list(map(int,input().split()))
B = collections.Counter(A)
C = [0]*N
for i in B.keys():
  C[i-1]=(i,B[i])
#print(C)
a = 0
for j in range(len(C)):
  try:
    print(C[j][1])
  except:
    print(0)
  a += 1
for l in range(N-a):
  print(0)

Submission status: Accepted

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

Submission status: Accepted

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

sorted(A)
ans = [0] * N

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

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

Submission status: Accepted

Solution code:
import sys
import math
import re
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
from functools import reduce
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
import itertools
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

ans = [0] * N

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

for i in ans:
    print(i)

Submission status: Accepted

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

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

for i in A_boss:
   print(i)

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N= int(input())

x=[0]*N

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

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


for i in x:
  print(i)

Submission status: Accepted

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

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:
import collections

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

c = collections.Counter(A)
for n in range(1, int(N)+1):
    print(c[n])

Submission status: Accepted

Solution code:
#! /usr/bin python3
N = int(input())
A = list(map(int, input().split()))

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

for i in member:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

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

b = sorted(a)
#print(b)
c = [0] * n

for i in range(len(b)):
    c[b[i]-1] += 1

for j in c:
    print(j)

Submission status: Accepted

Solution code:
n = int(input())
manage = [0] * n
for x in input().split():
    manage[int(x) - 1] += 1

for x in manage:
    print(x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#C
M = int(input())
A = list(map(int, input().split())) 
ans = [0] * M

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    n = int(input())
    b = [int(x) for x in input().split()]

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

    for bi in b:
        c[bi - 1] += 1
    
    for ci in c:
        print(ci)

Submission status: Accepted

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

Submission status: Accepted

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

an_map = [0] * n
for ai in an:
    an_map[ai - 1] += 1
for ai_map in an_map:
    print(ai_map)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
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())
ans = [0]*n

for i in input().split():
    ans[int(i)-1] += 1
        
for i in ans:
    print(i)

Submission status: Accepted

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

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

for i in Boss:
  print(i)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# C - management
# 標準入力の取得
N = int(input())
A = list(map(int, input().split()))

# 求解処理
result = [0 for n in range(N)]
for a in A:
    result[a-1] += 1

for r in result:
    print(r)

Submission status: Accepted

Solution code:
import collections

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A = collections.Counter(A)
    for i in range(1,N+1):
        print(A[i] if A[i] is not None else 0)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

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

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

Submission status: Accepted

Solution code:
from collections import defaultdict as f
n=int(input())
d=f(int)
for a in map(int,input().split()):d[a]+=1
for k in range(1,n+1):print(d[k])

Submission status: Accepted

Solution code:
from collections import Counter

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

Submission status: Accepted

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

Submission status: Accepted

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

pdict = {}

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

for elm in elms:
  pdict[elm-1] += 1
  
for i in range(N):
  print( pdict[i] )

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys
from collections import Counter
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


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


def main():
    N = int(input())
    cA = Counter(inpl())
    for i in range(1, N + 1):
        print(cA.get(i, 0))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

for ele in ans[1:]:
    print(ele)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    A = []
    A = input().split()

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

    for i in range(N-1):
        tmp = count[int(A[i])-1]
        count[int(A[i])-1] = tmp + 1

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

    

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math

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

m = {}
for i in A:
    if i in m:
        m[i] = m[i] + 1
    else:
        m[i] = 1


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

Submission status: Accepted

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

for item in num:
  ans[item - 1] += 1

for item in ans:
  print(item)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
N = int(input())
M_list = []
#社員のそれぞれの部下を記録するためのリストを用意する。
#インデックス０番目は一番偉い人で、もし各社員から上司を言われたら
#数字を一足していく。
for i in range(N):
  M_list.append(0)
#⁺リストでは各社員の上司を言っていく。例えば最初の社員が
#1というと、M_listの０の数字が１増える。
plus_list = input().split()

for i in range(N-1):
  M_list[int(plus_list[i])-1] += 1
  
for i in range(N):
  print(M_list[i])

Submission status: Accepted

Solution code:
import collections

n = int(input())

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

c = collections.Counter(l)

print(c[1])
for i,value in enumerate(l):
  print(c[i+2])

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10000000)
 

def main():
    N = int(input())
    A = [int(c) for c in input().split()]


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

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

    for _, v in dicts.items():
        print(v)



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import numpy as np


def solve(N: int, A: "List[int]"):
    emp = [0] * N
    for a in A:
        emp[a-1]+=1

    for e in emp:
        print(e)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N - 2 + 1)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    A = map(int, input().split())

    boss = defaultdict(int)
    for i, n in enumerate(A, start=2):
        boss[n] += 1
    for i in range(1, N + 1):
        print(boss[i])


main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# vim: set fileencoding=utf-8

# pylint: disable=unused-import, invalid-name, missing-docstring, bad-continuation


"""Module docstring
"""

import functools
import heapq
import itertools
import logging
import math
import random
import string
import sys
from argparse import ArgumentParser
from collections import defaultdict, deque
from copy import deepcopy
from typing import Dict, List, Optional, Set, Tuple


def solve(values: List[str], nb: int) -> Dict[int, int]:
    subord = defaultdict(int)
    for v in values:
        subord[v] += 1
    return subord


def do_job():
    "Do the work"
    LOG.debug("Start working")
    # first line is number of test cases
    N = int(input())
    values = list(map(int, input().split()))
    result = solve(values, N)
    for i in range(N):
        print(result[i + 1])


def print_output(testcase: int, result) -> None:
    "Formats and print result"
    if result is None:
        result = "IMPOSSIBLE"
    print("Case #{}: {}".format(testcase + 1, result))
    # 6 digits float precision {:.6f} (6 is the default value)
    # print("Case #{}: {:f}".format(testcase + 1, result))


def configure_log(log_file: Optional[str] = None) -> None:
    "Configure the log output"
    log_formatter = logging.Formatter(
        "%(asctime)s - %(filename)s:%(lineno)d - " "%(levelname)s - %(message)s"
    )
    if log_file:
        handler = logging.FileHandler(filename=log_file)
    else:
        handler = logging.StreamHandler(sys.stdout)
    handler.setFormatter(log_formatter)
    LOG.addHandler(handler)


LOG = None
# for interactive call: do not add multiple times the handler
if not LOG:
    LOG = logging.getLogger("template")
    configure_log()


def main(argv=None):
    "Program wrapper."
    if argv is None:
        argv = sys.argv[1:]
    parser = ArgumentParser()
    parser.add_argument(
        "-v",
        "--verbose",
        dest="verbose",
        action="store_true",
        default=False,
        help="run as verbose mode",
    )
    args = parser.parse_args(argv)
    if args.verbose:
        LOG.setLevel(logging.DEBUG)
    do_job()
    return 0


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    sys.exit(main())


class memoized:
    """Decorator that caches a function's return value each time it is called.
    If called later with the same arguments, the cached value is returned, and
    not re-evaluated.
    """

    def __init__(self, func):
        self.func = func
        self.cache = {}

    def __call__(self, *args):
        try:
            return self.cache[args]
        except KeyError:
            value = self.func(*args)
            self.cache[args] = value
            return value
        except TypeError:
            # uncachable -- for instance, passing a list as an argument.
            # Better to not cache than to blow up entirely.
            return self.func(*args)

    def __repr__(self):
        """Return the function's docstring."""
        return self.func.__doc__

    def __get__(self, obj, objtype):
        """Support instance methods."""
        return functools.partial(self.__call__, obj)

Submission status: Accepted

Solution code:
n = int(input().strip())
a=[0] * n

for i in map(int, input().strip().split()):
    a[i-1] += 1

for i in a:
    print(i)

Submission status: Accepted

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