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 C# (.NET Core 3.1.201) (judge verdict: Accepted)

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            input_iter = LazyLoadAllLines();
            //------------------------------------------------//
            //var n = Read<long>();
            //var s = Read();
            //var als = Read<long>(n);
            //var sls = Read(n);
            //List<List<long>> abls = new List<List<long>>();
            //List<long> cls = new List<long>();
            /*List<long> edgeNum = Enumerable.Repeat(0L, (int)n).ToList();
            for (int i = 0; i < n - 1; ++i)
            {
                abls.Add(Read<long>(2));
                abls[i].Add(i);
                abls[i].Add(-1);
                --abls[i][0];
                --abls[i][1];
                //cls.Add(Read<long>());
                ++edgeNum[(int)abls[i][0]];
                ++edgeNum[(int)abls[i][1]];
            }*/

            //als.Sort((l, r) => (r - l));
            //sls.Sort(StringComparer.OrdinalIgnoreCase);

            // DP?Graph?
            // int -> long

            var n = Read<long>();
            var als = Read<long>(n - 1);

            long[] num = new long[n + 1];
            foreach (var a in als)
            {
                ++num[a];
            }

            for (int i = 1; i <= n; i++)
            {
                Console.WriteLine(num[i]);
            }
        }

        static IEnumerator<string> input_iter;

        static IEnumerator<string> LazyLoadAllLines(bool doSplit = true)
        {
            string line;
            if (doSplit)
            {
                do
                {
                    line = Console.ReadLine();
                    foreach (var s in line.Split(' '))
                        yield return s;
                } while (line != null);
            }
            else
            {
                do
                {
                    line = Console.ReadLine();
                    yield return line;
                } while (line != null);
            }
        }
        // single 1 elem.
        static _T Read<_T>() where _T : struct
        {
            input_iter.MoveNext();
            return (_T)Convert.ChangeType(input_iter.Current, typeof(_T));
        }
        static string Read()
        {
            input_iter.MoveNext();
            return input_iter.Current;
        }
        // single n-elems.
        static List<_T> Read<_T>(long num) where _T : struct
        {
            List<_T> res = new List<_T>();
            for (long i = 0; i < num; ++i)
            {
                input_iter.MoveNext();
                res.Add((_T)Convert.ChangeType(input_iter.Current, typeof(_T)));
            }
            return res;
        }
        static List<string> Read(long num)
        {
            List<string> res = new List<string>();
            for (long i = 0; i < num; ++i)
            {
                input_iter.MoveNext();
                res.Add(input_iter.Current);
            }
            return res;
        }
        // multiple(single type) n-elems. (Range, Edge etc.)
        static List<List<_T>> Read<_T>(long elemNum, long typeNum, bool toSort = false) where _T : struct
        {
            List<List<_T>> res = new List<List<_T>>();
            for (int i = 0; i < elemNum; ++i)
            {
                var elem = Read<_T>(typeNum);
                if (toSort) elem.Sort();
                res.Add(elem);
            }
            return res;
        }
        // multiple(multiple type) n-elems.
        static List<(_T1, _T2)> Read<_T1, _T2>(long num) where _T1 : struct where _T2 : struct
        {
            List<(_T1, _T2)> res = new List<(_T1, _T2)>();
            for (int i = 0; i < num; ++i)
            {
                res.Add((Read<_T1>(), Read<_T2>()));
            }
            return res;
        }

        static void Swap<_T>(ref _T l, ref _T r)
        {
            _T temp = l;
            l = r;
            r = temp;
        }

        public class PriorityQueue<T> : IEnumerable<T>
        {
            private readonly List<T> _data = new List<T>();
            private readonly IComparer<T> _comparer;
            private readonly bool _isDescending;

            public PriorityQueue(IComparer<T> comparer, bool isDescending = true)
            {
                _comparer = comparer;
                _isDescending = isDescending;
            }

            public PriorityQueue(Comparison<T> comparison, bool isDescending = true)
                : this(Comparer<T>.Create(comparison), isDescending)
            {
            }

            public PriorityQueue(bool isDescending = true)
                : this(Comparer<T>.Default, isDescending)
            {
            }

            public void Enqueue(T item)
            {
                _data.Add(item);
                var childIndex = _data.Count - 1;
                while (childIndex > 0)
                {
                    var parentIndex = (childIndex - 1) / 2;
                    if (Compare(_data[childIndex], _data[parentIndex]) >= 0)
                        break;
                    Swap(childIndex, parentIndex);
                    childIndex = parentIndex;
                }
            }

            public T Dequeue()
            {
                var lastIndex = _data.Count - 1;
                var firstItem = _data[0];
                _data[0] = _data[lastIndex];
                _data.RemoveAt(lastIndex--);
                var parentIndex = 0;
                while (true)
                {
                    var childIndex = parentIndex * 2 + 1;
                    if (childIndex > lastIndex)
                        break;
                    var rightChild = childIndex + 1;
                    if (rightChild <= lastIndex && Compare(_data[rightChild], _data[childIndex]) < 0)
                        childIndex = rightChild;
                    if (Compare(_data[parentIndex], _data[childIndex]) <= 0)
                        break;
                    Swap(parentIndex, childIndex);
                    parentIndex = childIndex;
                }
                return firstItem;
            }

            public T Peek()
            {
                return _data[0];
            }

            public void Clear()
            {
                _data.Clear();
            }

            private void Swap(int a, int b)
            {
                var tmp = _data[a];
                _data[a] = _data[b];
                _data[b] = tmp;
            }

            private int Compare(T a, T b)
            {
                return _isDescending ? _comparer.Compare(b, a) : _comparer.Compare(a, b);
            }

            public int Count => _data.Count;

            public IEnumerator<T> GetEnumerator()
            {
                return _data.GetEnumerator();
            }

            IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
        }
    }
}