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

Solution in Rust (1.42.0) (judge verdict: Accepted)

#![allow(unused_imports)]pub mod pcl{pub mod macros{#[macro_export]macro_rules!rtl{(@ lhs($($ lhs:tt)*)@ rest+=$($ rest:tt)*)=>{rtl!(@ op+=@ lhs($($ lhs)*)@ rhs()@ rest $($ rest)*)};(@ lhs($($ lhs:tt)*)@ rest-=$($ rest:tt)*)=>{rtl!(@ op-=@ lhs($($ lhs)*)@ rhs()@ rest $($ rest)*)};(@ lhs($($ lhs:tt)*)@ rest*=$($ rest:tt)*)=>{rtl!(@ op*=@ lhs($($ lhs)*)@ rhs()@ rest $($ rest)*)};(@ lhs($($ lhs:tt)*)@ rest/=$($ rest:tt)*)=>{rtl!(@ op/=@ lhs($($ lhs)*)@ rhs()@ rest $($ rest)*)};(@ lhs($($ lhs:tt)*)@ rest%=$($ rest:tt)*)=>{rtl!(@ op%=@ lhs($($ lhs)*)@ rhs()@ rest $($ rest)*)};(@ lhs($($ lhs:tt)*)@ rest $ head:tt $($ rest:tt)*)=>{rtl!(@ lhs($($ lhs)*$ head)@ rest $($ rest)*);};(@ op $ op:tt @ lhs($($ lhs:tt)*)@ rhs($($ rhs:tt)*)@ rest)=>{let __rhs=$($ rhs)*;$($ lhs)*$ op __rhs;};(@ op $ op:tt @ lhs($($ lhs:tt)*)@ rhs($($ rhs:tt)*)@ rest $ head:tt $($ rest:tt)*)=>{rtl!(@ op $ op @ lhs($($ lhs)*)@ rhs($($ rhs)*$ head)@ rest $($ rest)*);};($($ rest:tt)*)=>{rtl!(@ lhs()@ rest $($ rest)*)};}}pub mod math{pub mod modint{#[macro_use]pub mod consts{use super::ModintInnerType;pub trait ModintConst{const MOD:ModintInnerType;}#[macro_export]macro_rules!define_modint_const{($(#[doc=$ doc:expr])*pub const $ name:ident=$ value:literal;)=>{$(#[doc=$ doc])*pub enum $ name{}impl $ crate::pcl::math::modint::consts::ModintConst for $ name{const MOD:$ crate::pcl::math::modint::ModintInnerType=$ value;}};}}use num::{Num,One,Zero};use self::consts::ModintConst;use super::super::traits::math::Group;use std::cmp::Ordering;use std::fmt;use std::hash::{Hash,Hasher};use std::iter::{Product,Sum};use std::marker::PhantomData;use std::mem;use std::ops::{Add,AddAssign,Div,DivAssign,Mul,MulAssign,Neg,Rem,RemAssign,Sub,SubAssign,};pub type ModintInnerType=i64;define_modint_const!{#[doc="1e9+7 を表す定数。"]pub const MOD17=1_000_000_007;}pub type Modint17=Modint<MOD17>;pub struct Modint<C>{value:ModintInnerType,marker:PhantomData<C>,}impl<C>Modint<C>{pub unsafe fn new_unchecked(value:ModintInnerType)->Modint<C>{#[allow(unknown_lints,renamed_and_removed_lints,redundant_field_names)]Modint{value:value,marker:PhantomData,}}pub fn inner(self)->ModintInnerType{self.value}}impl<C:ModintConst>Modint<C>{pub fn new(mut value:ModintInnerType)->Modint<C>{let modulus=C::MOD;assert_ne!(modulus,0,"MOD is 0");if value<0{let m=(-value)/modulus;value+=(m+1)*modulus;}unsafe{Modint::new_unchecked(value%modulus)}}pub fn inv(self)->Modint<C>{let mut modulus=C::MOD;let mut a=self.value;let mut u=1;let mut v=0;while modulus>0{let t=a/modulus;a-=t*modulus;u-=t*v;mem::swap(&mut a,&mut modulus);mem::swap(&mut u,&mut v);}Modint::new(u)}}impl<C:ModintConst>PartialEq for Modint<C>{fn eq(&self,other:&Self)->bool{self.inner()==other.inner()}}impl<C:ModintConst>PartialOrd for Modint<C>{fn partial_cmp(&self,other:&Self)->Option<Ordering>{self.inner().partial_cmp(&other.inner())}}impl<C:ModintConst>Eq for Modint<C>{}impl<C:ModintConst>Ord for Modint<C>{fn cmp(&self,other:&Self)->Ordering{self.inner().cmp(&other.inner())}}impl<C:ModintConst>Hash for Modint<C>{fn hash<H:Hasher>(&self,state:&mut H){self.inner().hash(state);}}impl<C>fmt::Debug for Modint<C>{fn fmt<'a>(&self,f:&mut fmt::Formatter<'a>)->fmt::Result{write!(f,"{}",self.inner())}}impl<C>Clone for Modint<C>{fn clone(&self)->Self{*self}}impl<C>Copy for Modint<C>{}impl<C:ModintConst>AddAssign for Modint<C>{fn add_assign(&mut self,rhs:Modint<C>){let modulus=C::MOD;self.value+=rhs.value;if self.value>=modulus{self.value-=modulus;}}}impl<C:ModintConst>SubAssign for Modint<C>{fn sub_assign(&mut self,rhs:Modint<C>){let modulus=C::MOD;self.value-=rhs.value;if self.value<0{self.value+=modulus;}}}impl<C:ModintConst>MulAssign for Modint<C>{fn mul_assign(&mut self,rhs:Modint<C>){let modulus=C::MOD;self.value*=rhs.value;self.value%=modulus;}}impl<C:ModintConst>DivAssign for Modint<C>{fn div_assign(&mut self,rhs:Modint<C>){if rhs.value==0{panic!("attempted to divide by zero");}*self*=rhs.inv();}}impl<C:ModintConst>RemAssign for Modint<C>{fn rem_assign(&mut self,rhs:Modint<C>){if rhs.value==0{panic!("attempted to divide by zero.")}self.value%=rhs.value;}}impl<C:ModintConst>Neg for Modint<C>{type Output=Self;fn neg(self)->Self{Self::zero()-self}}macro_rules!impl_arith_by_assign{(impl $ traitname:ident::$ fnname:ident{use $ op:tt;})=>{impl<C:ModintConst>$ traitname for Modint<C>{type Output=Modint<C>;fn $ fnname(mut self,rhs:Modint<C>)->Modint<C>{self $ op rhs;self}}};}impl_arith_by_assign!(impl Add::add{use+=;});impl_arith_by_assign!(impl Sub::sub{use-=;});impl_arith_by_assign!(impl Mul::mul{use*=;});impl_arith_by_assign!(impl Div::div{use/=;});impl_arith_by_assign!(impl Rem::rem{use%=;});impl<C:ModintConst>One for Modint<C>{fn one()->Modint<C>{let modulus=C::MOD;assert_ne!(modulus,1,"one()is called for Modint with MOD=1");unsafe{Modint::new_unchecked(1)}}}impl<C:ModintConst>Sum for Modint<C>{fn sum<I:Iterator<Item=Modint<C>>>(iter:I)->Modint<C>{iter.fold(Modint::zero(),Add::add)}}impl<C:ModintConst>Product for Modint<C>{fn product<I:Iterator<Item=Modint<C>>>(iter:I)->Self{iter.fold(Modint::one(),Mul::mul)}}impl<C:ModintConst>Zero for Modint<C>{fn zero()->Modint<C>{unsafe{Modint::new_unchecked(0)}}fn is_zero(&self)->bool{self.inner()==0}}impl<C>fmt::Display for Modint<C>{fn fmt(&self,b:&mut fmt::Formatter)->fmt::Result{write!(b,"{}",self.inner())}}impl<C:ModintConst>Num for Modint<C>{type FromStrRadixErr=<ModintInnerType as Num>::FromStrRadixErr;fn from_str_radix(src:&str,radix:u32)->Result<Self,Self::FromStrRadixErr>{ModintInnerType::from_str_radix(src,radix).map(Modint::new)}}impl<C:ModintConst>Group for Modint<C>{fn op(x:Self,y:Self)->Self{x+y}fn id()->Self{Self::zero()}fn inv(x:Self)->Self{-x}}}pub mod sum{use super::super::traits::Group;use std::cmp;use std::ops::{Bound,RangeBounds};pub struct CumSum<T>{sum:Vec<T>,}#[allow(unknown_lints,renamed_and_removed_lints,len_without_is_empty)]impl<T:Group+Copy>CumSum<T>{pub fn from_array<A:AsRef<[T]>>(array:A)->CumSum<T>{let array=array.as_ref();let mut sum=vec![T::id();array.len()+1];for i in 0..array.len(){let i=i+1;sum[i]=T::op(sum[i-1],array[i-1]);}#[allow(unknown_lints,renamed_and_removed_lints,redundant_field_names)]CumSum{sum:sum}}pub fn sum<R:RangeBounds<usize>>(&self,range:R)->T{let orig_len=self.sum.len()-1;let start=range_start(&range,0);let end=range_end(&range,orig_len);if end<=start{return T::id();}T::op(self.sum[end],T::inv(self.sum[start]))}pub fn len(&self)->usize{self.sum.len()-1}}pub struct CumSum2D<T>{sum:Vec<Vec<T>>,}impl<T:Group+Copy>CumSum2D<T>{pub fn from_matrix<M,A>(matrix:M)->CumSum2D<T>where M:AsRef<[A]>,A:AsRef<[T]>,{let array=matrix.as_ref();let height=array.len();if height==0{return CumSum2D{sum:vec![vec![T::id()]],};}let width=array[0].as_ref().len();let mut sum=vec![vec![T::id();width+1];height+1];for i in 0..height{let i=i+1;for j in 0..width{let j=j+1;assert_eq!(array[i-1].as_ref().len(),width,"the array's length is differ line by line");sum[i][j]=T::op(T::op(T::op(sum[i-1][j],sum[i][j-1]),T::inv(sum[i-1][j-1]),),array[i-1].as_ref()[j-1],)}}#[allow(unknown_lints,renamed_and_removed_lints,redundant_field_names)]CumSum2D{sum:sum}}pub fn sum<RY,RX>(&self,yrange:RY,xrange:RX)->T where RY:RangeBounds<usize>,RX:RangeBounds<usize>,{let orig_height=self.sum.len()-1;let orig_width=unsafe{self.sum.get_unchecked(0).len()}-1;let ystart=range_start(&yrange,0);let yend=range_end(&yrange,orig_height);let xstart=range_start(&xrange,0);let xend=range_end(&xrange,orig_width);if yend<=ystart||xend<=xstart{return T::id();}T::op(T::op(T::op(self.sum[yend][xend],self.sum[ystart][xstart]),T::inv(self.sum[ystart][xend]),),T::inv(self.sum[yend][xstart]),)}pub fn size(&self)->(usize,usize){(self.sum.len()-1,self.sum[0].len()-1)}}fn range_start<R:RangeBounds<usize>>(range:&R,min:usize)->usize{let start=match range.start_bound(){Bound::Included(&x)=>x,Bound::Excluded(&x)=>x+1,Bound::Unbounded=>0,};cmp::max(start,min)}fn range_end<R:RangeBounds<usize>>(range:&R,max:usize)->usize{let end=match range.end_bound(){Bound::Included(&x)=>x+1,Bound::Excluded(&x)=>x,Bound::Unbounded=>max,};cmp::min(end,max)}}pub use self::modint::{Modint,Modint17};pub use self::sum::{CumSum,CumSum2D};}pub mod structure{pub mod disjoint_sets{use std::mem::swap;pub struct DisjointSets{par:Vec<i64>,size:usize,}impl DisjointSets{pub fn new(n:usize)->DisjointSets{DisjointSets{par:vec![-1;n],size:n,}}pub fn merge(&mut self,mut x:usize,mut y:usize)->bool{let len=self.par.len();assert!(x<len,"index out of range:x is{}but len is{}",x,len);assert!(y<len,"index out of range:y is{}but len is{}",y,len);x=self.root(x);y=self.root(y);if x==y{return false;}if self.par[x]<self.par[y]{swap(&mut x,&mut y);}debug_assert!(self.par[x]<0&&self.par[y]<0,"critical error:parent has invalid value for rank");self.par[x]+=self.par[y];self.par[y]=x as i64;self.size-=1;true}pub fn in_same(&mut self,x:usize,y:usize)->bool{self.root(x)==self.root(y)}pub fn root(&mut self,x:usize)->usize{let parx=self.par[x];if parx<0{x}else{let root=self.root(parx as usize);self.par[x]=root as i64;root}}pub fn size_of(&mut self,mut x:usize)->usize{x=self.root(x);debug_assert!(self.par[x]<0,"critical error:parent has invalid value for rank");-self.par[x]as usize}pub fn size(&self)->usize{self.size}}}pub use self::disjoint_sets::DisjointSets;}pub mod traits{pub mod math{pub trait Group{fn op(x:Self,y:Self)->Self;fn id()->Self;fn inv(x:Self)->Self;}macro_rules!impl_group_for_primitives_using_add{($($ ty:ty)*)=>{$(impl Group for $ ty{fn op(x:Self,y:Self)->Self{x+y}fn id()->Self{<$ ty as Zero>::zero()}fn inv(x:Self)->Self{-x}})*};}use num::Zero;impl_group_for_primitives_using_add!{i8 i16 i32 i64 isize f32 f64}impl_group_for_primitives_using_add!{i128}}pub use self::math::*;}}
use itertools::Itertools as _;
use proconio::input;
fn main() {
    input! { n : usize , a : [ usize ; n - 1 ] , }
    let mut children = vec![0; n];
    for x in a {
        children[x - 1] += 1;
    }
    for child in children {
        println!("{}", child);
    }
}