prithivMLmods/Coder-Stat huggingface dataset:
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
  int n;
  cin >> n;
  vector<int> a(n - 1);
  vector<int> b(200000);
  int ans = 0;
  rep(i, n - 1) {
    cin >> a.at(i);
    b.at(a.at(i))++;
  }
  rep2(i, 1, n + 1) { cout << b.at(i) << endl; }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
  int n;
  cin >> n;
  vector<int> a(n - 1);
  vector<int> b(200200);
  int ans = 0;
  rep(i, n - 1) {
    cin >> a.at(i);
    b.at(a.at(i))++;
  }
  rep2(i, 1, n + 1) { cout << b.at(i) << endl; }
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (LL i = m; i n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define int long long
struct initon {
  initon() {
    cin.tie(0);
    ios::sync_with_stdio(false);
  };
};
signed main() {
  int n;
  cin >> n;
  vector<int> a(20010);
  vector<int> ans(200010);
  REP(i, 200010) {
    a[i] = 0;
    ans[i] = 0;
  }
  for (int i = 2; i <= n; i++)
    cin >> a[i];
  for (int i = 2; i <= n; i++)
    ans[a[i]]++;
  for (int i = 1; i <= n; i++)
    cout << ans[i] << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (LL i = m; i n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define int long long
struct initon {
  initon() {
    cin.tie(0);
    ios::sync_with_stdio(false);
  };
};
signed main() {
  int n;
  cin >> n;
  vector<int> a(200010);
  vector<int> ans(200010);
  REP(i, 200010) {
    a[i] = 0;
    ans[i] = 0;
  }
  for (int i = 2; i <= n; i++)
    cin >> a[i];
  for (int i = 2; i <= n; i++)
    ans[a[i]]++;
  for (int i = 1; i <= n; i++)
    cout << ans[i] << endl;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
/*! at-abc163c.cc
 *  2020-04-30
 *  GCC+17
 *  Type (opt):
 *  Notes (opt):
 */
#include <cstdio>
using llu = long long unsigned;
using ll = long long;

int main(void) {
  int co[100001];

  llu n, i, a;
  scanf("%llu", &n);
  for (i = 1; i < n; i++) {
    //        printf("%d", i);
    scanf("%llu", &a);
    co[a]++;
  }
  for (i = 1; i < n + 1; i++)
    printf("%i\n", co[i]);

  return 0;
}


Fixed submission:
/*! at-abc163c.cc
 *  2020-04-30
 *  GCC+17
 *  Type (opt):
 *  Notes (opt):
 */
#include <cstdio>
using llu = long long unsigned;
using ll = long long;

int main(void) {
  int co[1000000];

  llu n, i, a;
  scanf("%llu", &n);
  for (i = 1; i < n; i++) {
    //        printf("%d", i);
    scanf("%llu", &a);
    co[a]++;
  }
  for (i = 1; i < n + 1; i++)
    printf("%i\n", co[i]);

  return 0;
}
Problem p02707 (C++)

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

using namespace std;
using ll = long long;

int n;
vector<int> A;
ll cnt[20001];

void solve() {
  for (int i = 0; i < n; i++) {
    cnt[i] = 0;
  }
  for (auto &e : A) {
    cnt[e - 1]++;
  }
  for (int i = 0; i < n; i++)
    cout << cnt[i] << endl;
}

int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a;
    cin >> a;
    A.push_back(a);
  }
  solve();

  return EXIT_SUCCESS;
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int n;
vector<int> A;
int cnt[200000];

void solve() {
  for (int i = 0; i < n; i++) {
    cnt[i] = 0;
  }
  for (auto &e : A) {
    cnt[e - 1]++;
  }
  for (int i = 0; i < n; i++)
    cout << cnt[i] << endl;
}

int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a;
    cin >> a;
    A.push_back(a);
  }
  solve();

  return EXIT_SUCCESS;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
int main() {
  int n;
  cin >> n;
  int stuff[n], boss[200010] = {0};
  repi(i, 1, n) cin >> stuff[i];
  rep(i, n) boss[stuff[i] - 1]++;
  for (int i = 0; i < n; i++)
    cout << boss[i] << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
int main() {
  int n;
  cin >> n;
  int stuff[n], boss[200010] = {0};
  for (int i = 2; i <= n; i++)
    cin >> stuff[i];
  for (int i = 2; i <= n; i++)
    boss[stuff[i]]++;
  for (int i = 1; i <= n; i++)
    cout << boss[i] << endl;
}
Problem p02707 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#include <map>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  for (int j = 1; j <= n; j++) {
    int ans = 0;
    rep(i, n) {
      if (a[i] == j)
        ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <map>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n - 1);
  rep(i, n - 1) cin >> a[i];
  vector<int> ans(n);
  rep(i, n - 1) ans[a[i] - 1]++;
  rep(i, n) cout << ans[i] << endl;
  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 1; i < (int)(n); i++)
#define ll long long
#define BIT_FLAG_0 (1 << 0) // 0000 0000 0000 0001
#define BIT_FLAG_1 (1 << 1) // 0000 0000 0000 0010
#define BIT_FLAG_2 (1 << 2) // 0000 0000 0000 0100
#define BIT_FLAG_3 (1 << 3) // 0000 0000 0000 1000
#define BIT_FLAG_4 (1 << 4) // 0000 0000 0001 0000
#define BIT_FLAG_5 (1 << 5) // 0000 0000 0010 0000
#define BIT_FLAG_6 (1 << 6) // 0000 0000 0100 0000
#define BIT_FLAG_7 (1 << 7) // 0000 0000 1000 0000

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n - 1);
  vector<ll> s(n + 1);

  rep(i, n) { s[i] = 0; }
  rep(i, n) {
    cin >> a[i];
    s[a[i]]++;
    /*for(int j=0;j<n;j++){
    if(j==a[i])
    s[j]++;
    }*/
  }
  rep(i, n + 1) cout << s[i] << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 1; i < (int)(n); i++)
#define ll long long
#define BIT_FLAG_0 (1 << 0) // 0000 0000 0000 0001
#define BIT_FLAG_1 (1 << 1) // 0000 0000 0000 0010
#define BIT_FLAG_2 (1 << 2) // 0000 0000 0000 0100
#define BIT_FLAG_3 (1 << 3) // 0000 0000 0000 1000
#define BIT_FLAG_4 (1 << 4) // 0000 0000 0001 0000
#define BIT_FLAG_5 (1 << 5) // 0000 0000 0010 0000
#define BIT_FLAG_6 (1 << 6) // 0000 0000 0100 0000
#define BIT_FLAG_7 (1 << 7) // 0000 0000 1000 0000

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> s(n + 1);

  rep(i, n) { s[i] = 0; }
  rep(i, n) {
    cin >> a[i];
    s[a[i]]++;
    /*for(int j=0;j<n;j++){
    if(j==a[i])
    s[j]++;
    }*/
  }
  rep(i, n + 1) cout << s[i] << endl;
  return 0;
}
Problem p02707 (C++)

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  A.at(0) = 0;
  for (int i = 1; i < N; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < N - 1; i++) {
    B.at(i) = 0;
    for (int j = i + 1; j < N; j++) {
      if (i + 1 == A.at(j)) {
        B.at(i)++;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    cout << B.at(i) << endl;
  }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  A.at(0) = 0;
  for (int i = 1; i < N; i++) {
    cin >> A.at(i);
  }
  for (int i = 1; i < N; i++) {
    B.at(A.at(i) - 1)++;
  }
  for (int i = 0; i < N; i++) {
    cout << B.at(i) << endl;
  }
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include "bits/stdc++.h"
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl
const int maxn = 1e5 + 5;
int cnt[maxn];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n;
  cin >> n;
  int a;
  for (int i = 2; i <= n; i++) {
    cin >> a;
    cnt[a]++;
  }

  for (int i = 1; i <= n; i++) {
    cout << cnt[i] << endl;
  }
  return 0;
}


Fixed submission:
#include "bits/stdc++.h"
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl
const int maxn = 2e5 + 5;
int cnt[maxn];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n;
  cin >> n;
  int a;
  for (int i = 2; i <= n; i++) {
    cin >> a;
    cnt[a]++;
  }

  for (int i = 1; i <= n; i++) {
    cout << cnt[i] << endl;
  }
  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
#define pb push_back
#define pop pop_back
#define mp make_pair
#define vii vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vpi vector<pii>
#define vpl vector<pll>
#define fi first
#define sz size
#define len length
#define se second

const ll mod = 1e9 + 7;
const ll inf = 1e18 + 1e17;
// const ll mod = 998244353;

ll modInverse(ll a, ll m) {
  ll m0 = m;
  ll y = 0, x = 1;
  if (m == 1)
    return 0;
  while (a > 1) {
    ll q = a / m;
    ll t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0)
    x += m0;
  return x;
}
ll powm(ll a, ll b) {
  a = a % mod;
  ll res = 1;
  while (b) {
    if (b & 1)
      res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return (res % mod);
}

const ll N = 1e5 + 6;
const long double pi = 3.14159265358979323;

vii v[N];
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int aa;
    cin >> aa;
    v[aa].pb(i + 2);
  }
  for (int i = 1; i <= n; i++)
    cout << v[i].sz() << '\n';
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll t = 1;
  //	cin>>t;
  for (int i = 1; i <= t; i++) {
    //	cout<<"Case #"<<i<<": ";
    solve();
  }
}


Fixed submission:
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
#define pb push_back
#define pop pop_back
#define mp make_pair
#define vii vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vpi vector<pii>
#define vpl vector<pll>
#define fi first
#define sz size
#define len length
#define se second

const ll mod = 1e9 + 7;
const ll inf = 1e18 + 1e17;
// const ll mod = 998244353;

ll modInverse(ll a, ll m) {
  ll m0 = m;
  ll y = 0, x = 1;
  if (m == 1)
    return 0;
  while (a > 1) {
    ll q = a / m;
    ll t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0)
    x += m0;
  return x;
}
ll powm(ll a, ll b) {
  a = a % mod;
  ll res = 1;
  while (b) {
    if (b & 1)
      res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return (res % mod);
}

const ll N = 2e5 + 6;
const long double pi = 3.14159265358979323;

vii v[N];
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int aa;
    cin >> aa;
    v[aa].pb(i + 2);
  }
  for (int i = 1; i <= n; i++)
    cout << v[i].sz() << '\n';
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll t = 1;
  //	cin>>t;
  for (int i = 1; i <= t; i++) {
    //	cout<<"Case #"<<i<<": ";
    solve();
  }
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <array>
#include <cfenv>
#include <cmath>
#include <deque>
#include <forward_list>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <streambuf>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;

using namespace std;

int main() {
  int N;
  int A[100000];
  int ans[100000];
  cin >> N;
  for (int i = 0; i < 100000; i++) {
    ans[i] = 0;
  }
  for (int i = 0; i < N - 1; i++) {
    cin >> A[i];
    ans[A[i] - 1]++;
  }
  for (int i = 0; i < N; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <array>
#include <cfenv>
#include <cmath>
#include <deque>
#include <forward_list>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <streambuf>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;

using namespace std;

int main() {
  int N;
  int A[500000];
  int ans[500000];
  cin >> N;
  for (int i = 0; i < 100000; i++) {
    ans[i] = 0;
  }
  for (int i = 0; i < N - 1; i++) {
    cin >> A[i];
    ans[A[i] - 1]++;
  }
  for (int i = 0; i < N; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>

using namespace std;

int main() {
  int n, a;
  cin >> n;
  vector<int> vec(n, 0);

  for (int i = 0; i < n; i++) {
    cin >> a;
    vec[--a]++;
  }

  for (int i = 0; i < n; i++)
    cout << vec[i] << ' ';
  cout << endl;
}


Fixed submission:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>

using namespace std;

int main() {
  int n, a;
  cin >> n;
  vector<int> vec(n, 0);

  for (int i = 0; i < n - 1; i++) {
    cin >> a;
    vec[--a]++;
  }

  for (int i = 0; i < n; i++)
    cout << vec[i] << ' ';
  cout << endl;
}
Problem p02707 (C++)

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

#define rep(i, m, n) for (int i = m; i < n; i++)
#define pb push_back
#define ll long long
#define out(n) cout << #n << ' = ' << '\n'

using namespace std;

const int maxn = 1e5;
int a[maxn];
int ans[maxn];

int main() {
  int n;
  cin >> n;
  rep(i, 0, n - 1) {
    cin >> a[i];
    ans[a[i]]++;
  }
  rep(i, 1, n + 1) cout << ans[i] << '\n';
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

#define rep(i, m, n) for (int i = m; i < n; i++)
#define pb push_back
#define ll long long
#define out(n) cout << #n << ' = ' << '\n'

using namespace std;

const int maxn = 2e5 + 10;
int a[maxn];
int ans[maxn];

int main() {
  int n;
  cin >> n;
  rep(i, 0, n - 1) {
    cin >> a[i];
    ans[a[i]]++;
  }
  rep(i, 1, n + 1) cout << ans[i] << '\n';
  return 0;
}
Problem p02707 (C++)

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n - 1);
  for (int i = 0; i < n - 1; i++) {
    cin >> a[i];
  }
  vector<int> ans(n, 0);
  for (int i = 0; i < n - 1; i++) {
    for (int j = 1; j <= n; j++) {
      if (j == a[i])
        ans[j - 1]++;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n - 1);
  for (int i = 0; i < n - 1; i++) {
    cin >> a[i];
  }
  vector<int> ans(n, 0);
  for (int i = 0; i < n - 1; i++) {

    ans[a[i] - 1]++;
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
}
Problem p02707 (C++)

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

int main() {
  int N;
  vector<int> vec(N - 1);
  vector<int> vec2(N);
  for (int i = 0; i < N - 1; i++) {
    int a;
    cin >> a;
    vec.at(i) = a;
  }
  for (int i = 0; i < N - 1; i++) {
    vec2.at(vec.at(i) - 1)++;
  }
  for (int i = 0; i < N; i++) {
    cout << vec2.at(i) << endl;
  }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N - 1);
  vector<int> vec2(N);
  for (int i = 0; i < N - 1; i++) {
    int a;
    cin >> a;
    vec.at(i) = a;
  }
  for (int i = 0; i < N - 1; i++) {
    vec2.at(vec.at(i) - 1)++;
  }
  for (int i = 0; i < N; i++) {
    cout << vec2.at(i) << endl;
  }
}
Problem p02707 (C++)

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

int main() {
  int n;

  cin >> n;

  vector<int> a(n);
  vector<int> ans(n);

  for (int i = 2; i <= n; i++)
    cin >> a[i];

  for (int i = 2; i <= n; i++)
    ans[a[i]]++;

  for (int i = 1; i <= n; i++)
    cout << ans[i] << endl;

  return 0;
}


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

int main() {
  int n;

  cin >> n;

  vector<int> a(n + 1);
  vector<int> ans(n + 1);

  for (int i = 2; i <= n; i++)
    cin >> a[i];

  for (int i = 2; i <= n; i++)
    ans[a[i]]++;

  for (int i = 1; i <= n; i++)
    cout << ans[i] << endl;

  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

int main() {
  // 　数値の定義
  int N; // 人数
  cin >> N;

  int num[N];  // 上司番号{0,1,1,2,2}
  int buka[N]; // 部下の数{2,2,0,0,0}

  for (int i = 0; i < N; i++) { // 部下の数をループ
    buka[i] = 0;
    if (i > 0) {
      cin >> num[i];
      for (int j = 0; j < N; j++) { // 上司の数をループ
        // cout << "num[i] = " << num[i] << "   "<< "j+1 = " << j+1 << endl;
        if (num[i] == j + 1) {
          // cout << "--> correct" << endl;
          buka[j]++;
          break;
        }
      }
    }
  }

  // 判定
  for (int i = 0; i < N; i++) {
    cout << buka[i] << endl;
  }

  return 0;
}

Fixed submission:
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

int main() {
  // 　数値の定義
  int N; // 人数
  cin >> N;

  int num[N];  // 上司番号{0,1,1,2,2}
  int buka[N]; // 部下の数{2,2,0,0,0}

  for (int i = 0; i < N; i++) { // 部下の数をループ
    buka[i] = 0;
    if (i > 0) {
      cin >> num[i];
      buka[num[i] - 1]++;
    }
  }

  // 判定
  for (int i = 0; i < N; i++) {
    cout << buka[i] << endl;
  }

  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <string.h>
#include <vector>

using namespace std;

int N, M, A[20002] = {0}, i, j, k;

int main() {
  cin >> N;

  for (i = 1; i < N; i++) {
    cin >> k;
    A[k]++;
  }

  for (i = 1; i <= N; i++) {
    cout << A[i] << endl;
  }
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <string.h>
#include <vector>

using namespace std;

int N, M, A[200002] = {0}, i, j, k;

int main() {
  cin >> N;

  for (i = 1; i < N; i++) {
    cin >> k;
    A[k]++;
  }

  for (i = 1; i <= N; i++) {
    cout << A[i] << endl;
  }
}
Problem p02707 (C++)

Buggy submission (status: Time Limit Exceeded):
#define _GLIBCXX_DEBUG
#include <algorithm>
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  n -= 1;
  vector<int> a(200000);
  vector<int> b(200000);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= i + 1; j++) {
      if (a[i] == j) {
        b[j - 1]++;
        continue;
      }
    }
  }
  for (int i = 0; i <= n; i++) {
    cout << b[i] << endl;
  }
}

Fixed submission:
#define _GLIBCXX_DEBUG
#include <algorithm>
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  n -= 1;
  vector<int> a(200000);
  vector<int> b(200000);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    b[a[i] - 1]++;
  }
  for (int i = 0; i <= n; i++) {
    cout << b[i] << endl;
  }
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int n, a[100005];
int main() {
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int x;
    cin >> x;
    a[x]++;
  }
  for (int i = 1; i <= n; ++i)
    cout << a[i] << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int n, a[200005];
int main() {
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int x;
    cin >> x;
    a[x]++;
  }
  for (int i = 1; i <= n; ++i)
    cout << a[i] << endl;
}
Problem p02707 (C++)

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

const int maxn = 1e5 + 5;
int ind[maxn];

int main() {
  int n;
  cin >> n;
  for (int i = 2; i <= n; ++i) {
    int x;
    cin >> x;
    ind[x]++;
  }
  for (int i = 1; i <= n; ++i) {
    cout << ind[i] << endl;
  }
}

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

const int maxn = 2e5 + 5;
int ind[maxn];

int main() {
  int n;
  cin >> n;
  for (int i = 2; i <= n; ++i) {
    int x;
    cin >> x;
    ind[x]++;
  }
  for (int i = 1; i <= n; ++i) {
    cout << ind[i] << endl;
  }
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int a[100000];
int ans[100000];
int main() {
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++)
    cin >> a[i];
  for (int i = 2; i <= n; i++)
    ans[a[i]]++;
  for (int i = 1; i <= n; i++)
    cout << ans[i] << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int a[200010];
int ans[200010];
int main() {
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++)
    cin >> a[i];
  for (int i = 2; i <= n; i++)
    ans[a[i]]++;
  for (int i = 1; i <= n; i++)
    cout << ans[i] << endl;
}
Problem p02707 (C++)

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

using namespace std;

const int maxn = 100010;
long long n, m;
int tem, cnt[maxn] = {0};

int read() {
  int x = 0, w = 1;
  char ch = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  return x * w;
}

inline void write(int x) {
  static int sta[35];
  int top = 0;
  do {
    sta[top++] = x % 10, x /= 10;
  } while (x);
  while (top)
    putchar(sta[--top] + 48);
}

int main() {
  n = read();
  m = n;
  n--;
  while (n--) {
    tem = read();
    cnt[tem]++;
  }
  for (int i = 1; i <= m; i++) {
    printf("%d\n", cnt[i]);
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

const int maxn = 200010;
long long n, m;
int tem, cnt[maxn] = {0};

int read() {
  int x = 0, w = 1;
  char ch = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  return x * w;
}

inline void write(int x) {
  static int sta[35];
  int top = 0;
  do {
    sta[top++] = x % 10, x /= 10;
  } while (x);
  while (top)
    putchar(sta[--top] + 48);
}

int main() {
  n = read();
  m = n;
  n--;
  while (n--) {
    tem = read();
    cnt[tem]++;
  }
  for (int i = 1; i <= m; i++) {
    printf("%d\n", cnt[i]);
  }
  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
typedef long long ll;

int main() {
  ll N;
  cin >> N;
  vector<ll> ans(100100, 0);

  for (ll i = 1; i < N; ++i) {
    ll temp;
    cin >> temp;
    ++ans[temp - 1];
  }
  for (ll i = 0; i < N; ++i) {
    cout << ans[i] << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
typedef long long ll;

int main() {
  ll N;
  cin >> N;
  vector<ll> ans(200100, 0);

  for (ll i = 1; i < N; ++i) {
    ll temp;
    cin >> temp;
    ++ans[temp - 1];
  }
  for (ll i = 0; i < N; ++i) {
    cout << ans[i] << endl;
  }
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

typedef long long ll;

int main() {
  int N;
  int b[20000] = {0};
  cin >> N;
  for (int i = 1; i < N; i++) {
    int tmp;
    cin >> tmp;
    b[tmp - 1]++;
  }
  for (int i = 0; i < N; i++)
    cout << b[i] << endl;
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;

typedef long long ll;

int main() {
  int N;
  int b[200000] = {0};
  cin >> N;
  for (int i = 1; i < N; i++) {
    int tmp;
    cin >> tmp;
    b[tmp - 1]++;
  }
  for (int i = 0; i < N; i++)
    cout << b[i] << endl;
  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
const int nmax = 20005;
int v[nmax];
int main() {
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int x;
    cin >> x;
    if (x < i)
      v[x]++;
  }
  for (int i = 1; i <= n; i++)
    cout << v[i] << "\n";
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
const int nmax = 200005;
int v[nmax];
int main() {
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int x;
    cin >> x;
    if (x < i)
      v[x]++;
  }
  for (int i = 1; i <= n; i++)
    cout << v[i] << "\n";
}
Problem p02707 (C++)

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template <class T, class U> using P = pair<T, U>;
template <class T> using Heap = priority_queue<T>;
template <class T> using heaP = priority_queue<T, vector<T>, greater<T>>;
template <class T, class U> using umap = unordered_map<T, U>;
template <class T> using uset = unordered_set<T>;

template <class T> bool ChangeMax(T &a, const T &b) {
  if (a >= b)
    return false;
  a = b;
  return true;
}

template <class T> bool ChangeMin(T &a, const T &b) {
  if (a <= b)
    return false;
  a = b;
  return true;
}

template <class T, size_t N, class U> void Fill(T (&a)[N], const U &v) {
  fill((U *)a, (U *)(a + N), v);
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
  for (auto &e : v)
    is >> e;
  return is;
}

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  cin >> v;
  vector<int> ans(n);
  for (auto e : v) {
    ans[e - 1]++;
  }
  for (auto e : ans)
    cout << e << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template <class T, class U> using P = pair<T, U>;
template <class T> using Heap = priority_queue<T>;
template <class T> using heaP = priority_queue<T, vector<T>, greater<T>>;
template <class T, class U> using umap = unordered_map<T, U>;
template <class T> using uset = unordered_set<T>;

template <class T> bool ChangeMax(T &a, const T &b) {
  if (a >= b)
    return false;
  a = b;
  return true;
}

template <class T> bool ChangeMin(T &a, const T &b) {
  if (a <= b)
    return false;
  a = b;
  return true;
}

template <class T, size_t N, class U> void Fill(T (&a)[N], const U &v) {
  fill((U *)a, (U *)(a + N), v);
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
  for (auto &e : v)
    is >> e;
  return is;
}

int main() {
  int n;
  cin >> n;
  vector<int> v(n - 1);
  cin >> v;
  vector<int> ans(n);
  for (auto e : v) {
    ans[e - 1]++;
  }
  for (auto e : ans)
    cout << e << endl;
  return 0;
}
Problem p02707 (C++)

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n), ans(n);
  for (int i = 2; i <= n; ++i)
    cin >> a[i], ans[a[i]]++;
  for (int i = 1; i <= n; ++i)
    cout << ans[i] << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n + 5), ans(n + 5);
  for (int i = 2; i <= n; ++i)
    cin >> a[i], ans[a[i]]++;
  for (int i = 1; i <= n; ++i)
    cout << ans[i] << endl;
  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  // Your code here!
  int n;
  vector<int> data(20001, 0);
  cin >> n;
  int x;
  for (int i = 0; i < n - 1; i++) {
    cin >> x;
    data.at(x - 1) += 1;
  }
  for (int i = 0; i < n; i++) {
    cout << data.at(i) << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  // Your code here!
  int n;
  vector<int> data(200001, 0);
  cin >> n;
  int x;
  for (int i = 0; i < n - 1; i++) {
    cin >> x;
    data.at(x - 1) += 1;
  }
  for (int i = 0; i < n; i++) {
    cout << data.at(i) << endl;
  }
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, x;
  cin >> n;
  vector<int> a(n);
  for (i = 0; i < n; i++) {
    cin >> x;
    x--;
    a[x]++;
  }
  for (i = 0; i < n; i++)
    cout << a[i] << "\n";
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, x;
  cin >> n;
  vector<int> a(n);
  for (i = 0; i < n - 1; i++) {
    cin >> x;
    x--;
    a[x]++;
  }
  for (i = 0; i < n; i++)
    cout << a[i] << "\n";
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int main() {
  int N;
  cin >> N;
  int A[20010];
  int ans[20010];
  for (int i = 2; i <= N; i++) {
    cin >> A[i];
  }
  for (int i = 2; i <= N; i++) {
    ans[A[i]]++;
  }
  for (int i = 1; i <= N; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}

Fixed submission:
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int main() {
  int N;
  cin >> N;
  int A[200010];
  int ans[200010];
  for (int i = 2; i <= N; i++) {
    cin >> A[i];
  }
  for (int i = 2; i <= N; i++) {
    ans[A[i]]++;
  }
  for (int i = 1; i <= N; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}
Problem p02707 (C++)

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

int main() {
  int a;
  cin >> a;
  vector<int> c(a);
  c[a] = 0;

  for (int i = 0; i < a - 1; i++) {
    int b;
    cin >> b;
    c[b - 1]++;
  }

  for (int i = 0; i < a; i++) {
    cout << c[i] << endl;
  }

  return 0;
}

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

int main() {
  int a;
  cin >> a;
  vector<int> c(a);
  for (int i = 0; i < a; i++) {
    c[i] = 0;
  }

  for (int i = 0; i < a - 1; i++) {
    int b;
    cin >> b;
    c[b - 1]++;
  }

  for (int i = 0; i < a; i++) {
    cout << c[i] << endl;
  }

  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#define _GLIBCXX_DEBUG // TLEの原因になるので注意！！！！！！！！！！！
#include <bits/stdc++.h>
#include <cmath>
using ll = long long;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int, int>> qu2;
priority_queue<int> pq;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i, s, n) for (int i = s; i < n; i++)
#define Rreps(i, n, e) for (int i = n - 1; i >= e; --i)
#define Rrep(i, n) Rreps(i, n, 0)
deque<int> deq;
#define fi first
#define se second
// #define int long long

// cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

// const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
// const ll INF = 1LL << 60;
// typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}

bool chmn(int &a, int b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}

int A[20005];

int main() {
  int n;
  cin >> n;
  rep(i, n - 1) {
    int a;
    cin >> a;
    a--;
    A[a]++;
  }
  rep(i, n) { cout << A[i] << endl; }
  return 0;
}


Fixed submission:
#define _GLIBCXX_DEBUG // TLEの原因になるので注意！！！！！！！！！！！
#include <bits/stdc++.h>
#include <cmath>
using ll = long long;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int, int>> qu2;
priority_queue<int> pq;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i, s, n) for (int i = s; i < n; i++)
#define Rreps(i, n, e) for (int i = n - 1; i >= e; --i)
#define Rrep(i, n) Rreps(i, n, 0)
deque<int> deq;
#define fi first
#define se second
// #define int long long

// cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

// const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
// const ll INF = 1LL << 60;
// typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}

bool chmn(int &a, int b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}

int A[200005];

int main() {
  int n;
  cin >> n;
  rep(i, n - 1) {
    int a;
    cin >> a;
    a--;
    A[a]++;
  }
  rep(i, n) { cout << A[i] << endl; }
  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <functional>
#include <queue>
using namespace std;

int main(void) {
  int n, i, a, cnt[100001];
  scanf("%d", &n);
  for (i = 1; i <= n; i++)
    cnt[i] = 0;
  for (i = 2; i <= n; i++) {
    scanf("%d", &a);
    cnt[a]++;
  }
  for (i = 1; i <= n; i++)
    printf("%d\n", cnt[i]);
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <functional>
#include <queue>
using namespace std;

int main(void) {
  int n, i, a, cnt[200001];
  scanf("%d", &n);
  for (i = 1; i <= n; i++)
    cnt[i] = 0;
  for (i = 2; i <= n; i++) {
    scanf("%d", &a);
    cnt[a]++;
  }
  for (i = 1; i <= n; i++)
    printf("%d\n", cnt[i]);
  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

const int N = 1e5 + 7;

vector<int> g[N];

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int p;
    cin >> p;
    p--;
    g[p].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    cout << g[i].size() << ' ';
  }
  cout << '\n';
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

const int N = 3e5 + 7;

vector<int> g[N];

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int p;
    cin >> p;
    p--;
    g[p].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    cout << g[i].size() << ' ';
  }
  cout << '\n';
}
Problem p02707 (C++)

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N - 1);
  for (int i = 0; i < N - 1; i++) {
    cin >> A.at(i);
  }

  vector<int> buka(N);
  for (int i = 0; i < N; i++) {
    buka.at(i) = 0;
  }

  for (int i = 0; i < N - 1; i++) {
    for (int j = 1; j < N + 1; j++) {
      if (j == A.at(i)) {
        buka.at(j - 1)++;
      }
    }
  }

  for (int i = 0; i < N; i++) {
    cout << buka.at(i) << endl;
  }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N - 1);
  for (int i = 0; i < N - 1; i++) {
    cin >> A.at(i);
  }

  vector<int> buka(N);
  for (int i = 0; i < N; i++) {
    buka.at(i) = 0;
  }

  for (int i = 0; i < N - 1; i++) {
    buka.at(A.at(i) - 1)++;
  }

  for (int i = 0; i < N; i++) {
    cout << buka.at(i) << endl;
  }
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
const int M = 2 * 10000 + 5;
int s[M], n, x, i;

int main() {
  cin >> n;

  for (i = 2; i <= n; i++) {
    cin >> x;
    s[x]++;
  }

  for (i = 1; i <= n; i++)
    cout << s[i] << endl;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
const int M = 2 * 100000 + 5;
int s[M], n, x, i;

int main() {
  cin >> n;

  for (i = 2; i <= n; i++) {
    cin >> x;
    s[x]++;
  }

  for (i = 1; i <= n; i++)
    cout << s[i] << endl;

  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef vector<vector<ll>> VVL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main() {
  int N;
  cin >> N;
  VI A(N - 1);
  rep(i, N - 1) cin >> A[i];
  VI B(N);
  rep(i, N) B[A[i] - 1]++;
  rep(i, N) cout << B[i] << endl;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef vector<vector<ll>> VVL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main() {
  int N;
  cin >> N;
  VI A(N - 1);
  rep(i, N - 1) cin >> A[i];
  VI B(N);
  rep(i, N - 1) B[A[i] - 1]++;
  rep(i, N) cout << B[i] << endl;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define MOD 1000000000
#define inf -100000
#define fast                                                                   \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
using namespace std;
int main() {
  fast;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ll int n;
  cin >> n;
  ll int a[n - 1];
  ll int i, z, s = 0;
  ll int f[100005] = {0};
  for (i = 0; i < n - 1; i++) {
    cin >> a[i];
    f[a[i]]++;
  }
  for (i = 1; i <= n; i++) {
    cout << f[i] << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define MOD 1000000000
#define inf -100000
#define fast                                                                   \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
using namespace std;
int main() {
  fast;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ll int n;
  cin >> n;
  ll int a[n - 1];
  ll int i, z, s = 0;
  ll int f[200005] = {0};
  for (i = 0; i < n - 1; i++) {
    cin >> a[i];
    f[a[i]]++;
  }
  for (i = 1; i <= n; i++) {
    cout << f[i] << endl;
  }
}
Problem p02707 (C++)

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N, 0);
  vector<int> count(N, 0);
  for (int i = 0; i < N - 1; i++) {
    cin >> A.at(i);
    count.at(A.at(i - 1)) += 1;
  }
  for (int i = 0; i < N; i++) {
    cout << count.at(i) << endl;
  }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N, 0);
  vector<int> count(N, 0);
  for (int i = 0; i < N - 1; i++) {
    cin >> A.at(i);
    count.at(A.at(i) - 1) += 1;
  }
  for (int i = 0; i < N; i++) {
    cout << count.at(i) << endl;
  }
}
Problem p02707 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;

int main(void) {
  int N;
  cin >> N;
  int l;
  vector<int> A(N);
  vector<int> sum(N);
  sum[0] = 0;
  A[0] = 0;
  for (int i = 1; i < N; i++) {
    cin >> l;
    A[i] = l;
    sum[i] = 0;
  }

  for (int i = 1; i < N; i++) {
    for (int j = 1; j <= i; j++) {
      if (j == A[i]) {
        sum[A[i] - 1] = sum[A[i] - 1] + 1;
      }
    }
  }

  for (int i = 0; i < N; i++) {
    printf("%d\n", sum[i]);
  }

  return 0;
}

Fixed submission:
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;

int main(void) {
  int N;
  cin >> N;
  int l;
  vector<int> A(N);
  vector<int> sum(N);
  sum[0] = 0;
  A[0] = 0;
  for (int i = 1; i < N; i++) {
    cin >> l;
    A[i] = l;
    sum[i] = 0;
  }

  for (int i = 1; i < N; i++) {
    sum[A[i] - 1] = sum[A[i] - 1] + 1;
  }

  for (int i = 0; i < N; i++) {
    printf("%d\n", sum[i]);
  }

  return 0;
}
Problem p02707 (C++)

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  fill((T *)array, (T *)(array + N), val);
}
template <class T1, class T2, class Pred = std::less<T2>>
struct sort_pair_second {
  bool operator()(const std::pair<T1, T2> &left,
                  const std::pair<T1, T2> &right) {
    Pred p;
    return p(left.second, right.second);
  }
};

int a[100010];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  rep(i, N - 1) {
    int A;
    cin >> A;
    a[A - 1]++;
  }
  rep(i, N) cout << a[i] << endl;
  return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  fill((T *)array, (T *)(array + N), val);
}
template <class T1, class T2, class Pred = std::less<T2>>
struct sort_pair_second {
  bool operator()(const std::pair<T1, T2> &left,
                  const std::pair<T1, T2> &right) {
    Pred p;
    return p(left.second, right.second);
  }
};

int a[200010];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  rep(i, N - 1) {
    int A;
    cin >> A;
    a[A - 1]++;
  }
  rep(i, N) cout << a[i] << endl;
  return 0;
}
Problem p02707 (C++)

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

int main() {
  int N;
  cin >> N;

  vector<int> boss(N - 1);
  for (int i = 0; i < N - 1; i++)
    cin >> boss.at(i);

  vector<int> num(N);
  for (int i = 0; i < N - 1; i++) {
    int count = 0;
    for (int j : boss) {
      if (i == j - 1)
        count++;
    }
    num.at(i) = count;
  }

  for (int i = 0; i < N; i++)
    cout << num.at(i) << endl;
}

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

int main() {
  int N;
  cin >> N;

  vector<int> boss(N - 1);
  for (int i = 0; i < N - 1; i++)
    cin >> boss.at(i);

  vector<int> num(N);
  for (int i = 0; i < N - 1; i++) {
    num.at(boss.at(i) - 1) += 1;
  }

  for (int i = 0; i < N; i++)
    cout << num.at(i) << endl;
}