Problem p02707 (C++)

Buggy submission (status: Runtime Error):
// Mahir Ratanpara (DA-IICT)
#include <bits/stdc++.h>
using namespace std;
#define Ff(i, a, n) for (i = a; i < n; i++)
#define Fr(i, a, n) for (i = a; i > n; i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll> pa;
typedef vector<ll> vc;
typedef vector<pa> vp;
typedef vector<vc> vvc;
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];
ll a[N];

ll root(ll *a, ll A) {
  while (a[A] != A) {
    a[A] = a[a[A]];
    A = a[A];
  }
  return A;
}

int main() {
  FAST;
  ll t, i, j, k, p, q, r, x, y, u, v, n, m;
  cin >> n;
  ll a[n - 1];
  Ff(i, 0, n - 1) cin >> a[i];

  ll fa[100001] = {0};
  Ff(i, 0, n - 1) { fa[a[i]]++; }
  Ff(i, 1, n + 1) cout << fa[i] << endl;
  return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1)
      result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m) {
  int i, u, v;
  while (m--) {
    cin >> u >> v;
    g[u - 1].pb(v - 1);
    g[v - 1].pb(u - 1);
  }
}

void dfs(int u, int par) {
  for (int v : g[u]) {
    if (v == par)
      continue;
    dfs(v, u);
  }
}

Fixed submission:
// Mahir Ratanpara (DA-IICT)
#include <bits/stdc++.h>
using namespace std;
#define Ff(i, a, n) for (i = a; i < n; i++)
#define Fr(i, a, n) for (i = a; i > n; i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll> pa;
typedef vector<ll> vc;
typedef vector<pa> vp;
typedef vector<vc> vvc;
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];
ll a[N];

ll root(ll *a, ll A) {
  while (a[A] != A) {
    a[A] = a[a[A]];
    A = a[A];
  }
  return A;
}

int main() {
  FAST;
  ll t, i, j, k, p, q, r, x, y, u, v, n, m;
  cin >> n;
  ll a[n - 1];
  Ff(i, 0, n - 1) cin >> a[i];

  ll fa[300001] = {0};
  Ff(i, 0, n - 1) { fa[a[i]]++; }
  Ff(i, 1, n + 1) cout << fa[i] << endl;
  return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1)
      result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m) {
  int i, u, v;
  while (m--) {
    cin >> u >> v;
    g[u - 1].pb(v - 1);
    g[v - 1].pb(u - 1);
  }
}

void dfs(int u, int par) {
  for (int v : g[u]) {
    if (v == par)
      continue;
    dfs(v, u);
  }
}