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 static System.Console;

namespace AtCoder
{
	public static class Program
	{
		public static void Main(string[] args)
		{
			ReadAllLines()
				.Skip(1)
				.First()
				.SplitToIntList()
				.ToList()
				.ToVariable(out var list)
				.GroupBy(a => a)
				.ToDictionary(a => a.Key, a => a.Count())
				.ToVariable(out var data);
			Enumerable
				.Range(1, list.Count + 1)
				.Select(a => data.TryGetValue(a, out var count) ? count : 0)
				.ForEach(WriteLine);
		}

		#region Utilities

		public static T ToVariable<T>(this T source, out T variable)
		{
			variable = source;
			return source;
		}

		public static IEnumerable<IList<T>> Buffer<T>(
			this IEnumerable<T> source,
			int count)
		{
			return Buffer(source, count, count);
		}

		public static IEnumerable<IList<T>> Buffer<T>(
			this IEnumerable<T> source,
			int count,
			int skip)
		{
			if (source == null)
				throw new ArgumentNullException(nameof(source));
			if (count < 1)
				throw new ArgumentOutOfRangeException(nameof(count));
			if (skip < 1)
				throw new ArgumentOutOfRangeException(nameof(skip));

			var queue = new Queue<List<T>>();
			int step = skip;
			foreach (var item in source)
			{
				if (step == skip)
				{
					step = 0;
					queue.Enqueue(new List<T>(count));
				}
				foreach (var list in queue)
					list.Add(item);
				while (queue.Count > 0 && queue.Peek().Count == count)
					yield return queue.Dequeue();
				step++;
			}
			while (queue.Count > 0) yield return queue.Dequeue();
		}

		public static IEnumerable<IEnumerable<T>> Combination<T>(
			this IEnumerable<T> source,
			int count)
		{
			var stack = new Stack<List<T>[]>();
			stack.Push(new[]
			{
				new List<T>(),
				source.ToList()
			});
			while (stack.Count > 0)
			{
				var item = stack.Pop();
				if (item[0].Count() == count)
				{
					yield return item[0];
				}
				else
				{
					var list = item[1];
					list
						.Select((a, i) => new[]
						{
							item[0].Concat(new[]{ a }).ToList(),
							list.Skip(i + 1).ToList(),
						})
						.TakeWhile(a => a[0].Count + a[1].Count >= count)
						.ForEach(a => stack.Push(a));
				}
			}
		}

		public static IEnumerable<IEnumerable<T>> Permutation<T>(
			this IEnumerable<T> source,
			int count)
		{
			var stack = new Stack<IEnumerable<T>[]>();
			stack.Push(new[]
			{
				Enumerable.Empty<T>(),
				source.ToList()
			});
			while (stack.Count > 0)
			{
				var item = stack.Pop();
				if (item[0].Count() == count)
				{
					yield return item[0];
				}
				else
				{
					var list = item[1];
					list
						.Select((a, i) => new[]
						{
							item[0].Concat(new[]{ a }),
							list.Where((b, j) => j != i),
						})
						.ForEach(a => stack.Push(a));
				}
			}
		}

		public static IEnumerable<string> ReadAllLines()
		{
			return Repeat(ReadLine)
				.TakeWhile(a => a != null);
		}

		public static List<int> SplitToIntList(this string source)
		{
			return source.Split().Select(a => int.Parse(a)).ToList();
		}

		public static List<double> SplitToDoubleList(this string source)
		{
			return source.Split().Select(a => double.Parse(a)).ToList();
		}

		public static IEnumerable<T> Return<T>(params T[] source)
		{
			return source;
		}

		public static string JoinWithSpace<T>(this IEnumerable<T> source)
		{
			return string.Join(" ", source);
		}

		public static IEnumerable<T> Repeat<T>(this T source)
		{
			return Repeat(() => source);
		}

		public static IEnumerable<T> Repeat<T>(Func<T> selector)
		{
			while (true) yield return selector();
		}

		public static IEnumerable<T> Recur<T>(
			this T source,
			Func<T, T> selector)
		{
			var p = source;
			while (true)
			{
				yield return p;
				p = selector(p);
			}
		}

		public static IEnumerable<T> Scan<T>(
			this IEnumerable<T> source,
			Func<T, T, T> selector)
		{
			return Scan(source, default(T), selector);
		}

		public static IEnumerable<T> Scan<T>(
			this IEnumerable<T> source,
			T seed,
			Func<T, T, T> selector)
		{
			var last = seed;
			foreach (var item in source)
			{
				last = selector(last, item);
				yield return last;
			}
		}

		public static void ForEach<T>(
			this IEnumerable<T> source,
			Action<T> unlessEmpty,
			Action ifEmpty = null)
		{
			using (var e = source.GetEnumerator())
			{
				if (e.MoveNext())
				{
					do unlessEmpty?.Invoke(e.Current);
					while (e.MoveNext());
				}
				else
				{
					ifEmpty?.Invoke();
				}
			}
		}

		public static TResult Chain<TSource, TResult>(
			this TSource source,
			Func<TSource, TResult> selector)
		{
			return selector(source);
		}

		public static T Chain<T>(
			this T source,
			Action<T> action)
		{
			action(source);
			return source;
		}

		public static IEnumerable<T> Do<T>(
			this IEnumerable<T> source,
			Action<T> action)
		{
			foreach (var a in source)
			{
				action(a);
				yield return a;
			}
		}

		#endregion

		#region D2

		class D2<T> : IEnumerable<Location>
		{
			public D2(int width, int height, IEnumerable<T> items = null)
			{
				Width = width;
				Height = height;
				var size = Width * Height;
				Items = items?.ToArray() ?? new T[size];
				if (Items.Length != size) throw new Exception();
			}

			public int Width { get; private set; }
			public int Height { get; private set; }

			public T[] Items { get; private set; }

			public T this[int index]
			{
				get { return Items[index]; }
				set { Items[index] = value; }
			}

			public T this[int x, int y]
			{
				get { return Items[y * Width + x]; }
				set { Items[y * Width + x] = value; }
			}

			public T this[Location location]
			{
				get { return this[location.X, location.Y]; }
				set { this[location.X, location.Y] = value; }
			}

			public bool Contains(Location location)
			{
				return 0 <= location.X
					&& 0 <= location.Y
					&& location.X < Width
					&& location.Y < Height;
			}

			public D2<T> Clone()
			{
				return new D2<T>(Width, Height, Items);
			}

			public IEnumerable<IEnumerable<Location>> EnumerateVertical()
			{
				return Enumerable
					.Range(0, Height)
					.Select(y => Enumerable
						.Range(0, Width)
						.Select(x => new Location(x, y)));
			}

			public IEnumerable<IEnumerable<Location>> EnumerateHorizontal()
			{
				return Enumerable
					.Range(0, Width)
					.Select(x => Enumerable
						.Range(0, Height)
						.Select(y => new Location(x, y)));
			}

			public IEnumerator<Location> GetEnumerator()
			{
				foreach (var item in EnumerateVertical().SelectMany(a => a))
				{
					yield return item;
				}
			}

			IEnumerator IEnumerable.GetEnumerator()
			{
				return GetEnumerator();
			}
		}

		#endregion

		#region Location

		struct Location
		{
			public Location(int x, int y)
			{
				X = x;
				Y = y;
			}

			public int X { get; private set; }
			public int Y { get; private set; }

			public override bool Equals(object obj)
			{
				if (!(obj is Location)) return false;
				var other = (Location)obj;
				return other != null &&
					   X == other.X &&
					   Y == other.Y;
			}

			public override int GetHashCode()
			{
				return X << 16 | Y | X >> 16;
			}

			public static bool operator ==(Location left, Location right)
			{
				return EqualityComparer<Location>.Default.Equals(left, right);
			}

			public static bool operator !=(Location left, Location right)
			{
				return !(left == right);
			}

			public static Location operator +(Location left, Location right)
			{
				return new Location(left.X + right.X, left.Y + right.Y);
			}

			public static Location operator -(Location left, Location right)
			{
				return new Location(left.X - right.X, left.Y - right.Y);
			}
		}

		#endregion
	}
}