Problem p02707 (C++) — buggy submission, verdict: Runtime Error

/*Stay true to yourself, yet always be open to learn. Work hard, and never give
up on your dreams, even when nobody else believes they can come true but you.
These are not cliches but real tools you need no matter what you do in life to
stay focused on your path.
*/

/*Pppppppp    UU      UU     CCCCCCCC    CCCCCCCC     HH     HH     UU      UU
  pp    pp    UU      UU     CC          CC           HH     HH     UU      UU
  pp    pp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
  pppppppp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
  pp          UU      UU     CC          CC           HH     HH     UU      UU
  pp          UUUUUUUUUU     CCCCCCCC    CCCCCCCC     HH     HH     UUUUUUUUUU
  */

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

#define int long long
typedef long long ll;
#define loop(i, n) for (int i = 0; i < n; i++)
#define ford(i, a, b) for (int i = b; i >= a; i--)
#define read(a)                                                                \\
  int a;                                                                       \\
  cin >> a;
#define readarr(a, n)                                                          \\
  int a[n];                                                                    \\
  for (int i = 0; i < n; i++)                                                  \\
    cin >> a[i];
#define readmat(a, n, m)                                                       \\
  int a[n][m];                                                                 \\
  for (int i = 0; i < n; i++)                                                  \\
    for (j = 0; j < m; j++)                                                    \\
      cin >> a[i][j];
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int, int>
#define vii vector<vector<int>>
#define sti set<int>
#define vpi vector<pair<int, int>>
#define print(a, n)                                                            \\
  for (int i = 0; i < n; i++)                                                  \\
    cout << a[i] << " ";                                                       \\
  cout << endl;
#define printmat(a, n, m)                                                      \\
  for (int i = 0; i < n; i++) {                                                \\
    for (j = 0; j < m; j++)                                                    \\
      cout << a[i][j] << " ";                                                  \\
    cout << endl;                                                              \\
  }
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define endl "\\n"
#define mp make_pair
const ll inf = 1e18;
const ll mod = 1e9 + 7;

int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

signed main() {

  fast;
  int n, m;
  cin >> n;
  readarr(a, n - 1);
  vi c(n + 1);
  loop(i, n - 1) c[a[i]]++;
  loop(i, n) cout << c[i + 1] << endl;
  return 0;
}

Error: -11

Fixed submission:

/*Stay true to yourself, yet always be open to learn. Work hard, and never give
up on your dreams, even when nobody else believes they can come true but you.
These are not cliches but real tools you need no matter what you do in life to
stay focused on your path.
*/

/*Pppppppp    UU      UU     CCCCCCCC    CCCCCCCC     HH     HH     UU      UU
  pp    pp    UU      UU     CC          CC           HH     HH     UU      UU
  pp    pp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
  pppppppp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
  pp          UU      UU     CC          CC           HH     HH     UU      UU
  pp          UUUUUUUUUU     CCCCCCCC    CCCCCCCC     HH     HH     UUUUUUUUUU
  */

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

#define int long long
typedef long long ll;
#define loop(i, n) for (int i = 0; i < n; i++)
#define ford(i, a, b) for (int i = b; i >= a; i--)
#define read(a)                                                                \\
  int a;                                                                       \\
  cin >> a;
#define readarr(a, n)                                                          \\
  int a[n];                                                                    \\
  for (int i = 0; i < n; i++)                                                  \\
    cin >> a[i];
#define readmat(a, n, m)                                                       \\
  int a[n][m];                                                                 \\
  for (int i = 0; i < n; i++)                                                  \\
    for (j = 0; j < m; j++)                                                    \\
      cin >> a[i][j];
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int, int>
#define vii vector<vector<int>>
#define sti set<int>
#define vpi vector<pair<int, int>>
#define print(a, n)                                                            \\
  for (int i = 0; i < n; i++)                                                  \\
    cout << a[i] << " ";                                                       \\
  cout << endl;
#define printmat(a, n, m)                                                      \\
  for (int i = 0; i < n; i++) {                                                \\
    for (j = 0; j < m; j++)                                                    \\
      cout << a[i][j] << " ";                                                  \\
    cout << endl;                                                              \\
  }
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define endl "\\n"
#define mp make_pair
const ll inf = 1e18;
const ll mod = 1e9 + 7;

int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

signed main() {

  fast;
  int n, m;
  cin >> n;
  readarr(a, n);
  vi c(n + 1);
  loop(i, n) c[a[i]]++;
  loop(i, n) cout << c[i + 1] << endl;
  return 0;
}