Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

const double PI = acos(-1);
#define MOD 1000000007

#define pb push_back
#define F first
#define S second
#define test                                                                   \
  int tc;                                                                      \
  cin >> tc;                                                                   \
  while (tc--)
#define forn(i, n) for (i = 0; i < n; i++)
#define rforn(i, n) for (i = n - 1; i >= 0; i--)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(x) x.size()
#define el << '\n'
#define sp << ' '

#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (abs(a * b) / gcd(a, b))
#define sqr(a) (a * a)

#define optimize()                                                             \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define file()                                                                 \
  freopen("input.txt", "r", stdin);                                            \
  freopen("output.txt", "w", stdout);
int a[100001];
int main() {
  /// optimize();
  int n, i, b;
  cin >> n;
  for (i = 1; i < n; i++) {
    cin >> b;
    a[b]++;
  }
  for (i = 1; i <= n; i++)
    cout << a[i] el;

  return 0;
}

/// Brainless people are gonna understand this code.

/// Brainless_Loco Terminates Here!


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

const double PI = acos(-1);
#define MOD 1000000007

#define pb push_back
#define F first
#define S second
#define test                                                                   \
  int tc;                                                                      \
  cin >> tc;                                                                   \
  while (tc--)
#define forn(i, n) for (i = 0; i < n; i++)
#define rforn(i, n) for (i = n - 1; i >= 0; i--)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(x) x.size()
#define el << '\n'
#define sp << ' '

#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (abs(a * b) / gcd(a, b))
#define sqr(a) (a * a)

#define optimize()                                                             \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define file()                                                                 \
  freopen("input.txt", "r", stdin);                                            \
  freopen("output.txt", "w", stdout);
int a[200001];
int main() {
  /// optimize();
  int n, i, b;
  cin >> n;
  for (i = 1; i < n; i++) {
    cin >> b;
    a[b]++;
  }
  for (i = 1; i <= n; i++)
    cout << a[i] el;

  return 0;
}

/// Brainless people are gonna understand this code.

/// Brainless_Loco Terminates Here!