alexjercan/bugnet huggingface dataset:
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>

using namespace std;

int main() {
  long int n;
  cin >> n;
  long int i;
  vector<long int> b(n);
  long int s;

  for (i = 0; i < n - 1; i++) {
    cin >> s;
    b[s - 1]++;
  }

  for (i = 0; i < n; i++) {
    cout << b[i] << endl;
  }

  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
#include <vector>

using namespace std;

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

  int s;

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

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

  return 0;
}
Problem p02707 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n;
  cin >> n;
  vector<int> ans(n);

  rep(i, n - 1) {
    int a;
    cin >> a;
    ans[a - 1]++;
  }

  for (int x : ans) {
    cout << x << endl;
  }
}

Error: TLE

Fixed submission:

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

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

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

  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    rep(j, n) if (i == a[j]) cnt++;
    cout << cnt << endl;
  }
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
using ll = long long;

int n, m, a;
string s, t;
int ans[200005];

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

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
using ll = long long;

int n, m, a;
string s, t;
int ans[100005];

int main() {
  cin >> n;
  rep(i, n - 1) cin >> a, ans[a - 1]++;
  rep(i, n) cout << ans[i] << endl;
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

template <typename T> std::string NumberToString(T Number) {
  std::ostringstream ss;
  ss << Number;
  return ss.str();
} // Usages NumberToString(3)
template <typename T> T StringToNumber(const string &Text) {
  istringstream ss(Text);
  T result;
  return ss >> result ? result : 0;
} // StringToNumber<int>("3")

int vec[900006];

int main() {

  ios::sync_with_stdio(0);
  cin.tie(0);

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

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

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

template <typename T> std::string NumberToString(T Number) {
  std::ostringstream ss;
  ss << Number;
  return ss.str();
} // Usages NumberToString(3)
template <typename T> T StringToNumber(const string &Text) {
  istringstream ss(Text);
  T result;
  return ss >> result ? result : 0;
} // StringToNumber<int>("3")

int vec[100006];

int main() {

  ios::sync_with_stdio(0);
  cin.tie(0);

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

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

  return 0;
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int x;
  rep(i, n - 1) {
    cin >> x;
    a[x - 1]++;
  }
  rep(i, n) { cout << a[i] << " "; }
  cout << endl;
}

Error: -6
double free or corruption (out)


Fixed submission:

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

const long long INF = numeric_limits<long long>::max();
using ll = long long int;
using ppi = pair<ll, ll>;
using pql = priority_queue<ll, vector<ll>, greater<ll>>;
using pq = priority_queue<ll>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep2(i, 1, n) cin >> a[i];

  vector<int> b(n);
  rep(i, n) b[i] = 0;

  rep(i, n) { b[a[i] - 1]++; }
  rep(i, n) { cout << b[i] << " "; }
  cout << endl;
  return 0;
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define FasterIO                                                               \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
using namespace std;
int main() {
  FasterIO int n, a;
  cin >> n;
  int b[n + 2] = {0};

  for (int i = 1; i < n; i++) {
    cin >> a;
    b[a]++;
  }
  for (int i = 1; i <= n; i++)
    cout << b[i] << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define FasterIO                                                               \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
using namespace std;
int main() {
  FasterIO int n, a[99999], b[99999];
  vector<int> vec;
  cin >> n;
  for (int i = 0; i < n - 1; i++)
    cin >> a[i];
  int cnt = 1, j = 0;
  for (int i = 0; i < n - 1; i++) {
    if (a[i] == a[i + 1]) {
      cnt++;
      if (i + 1 == n - 2) {
        b[j] = cnt;
        cnt = 1;
        j++;
        break;
      }
      continue;
    } else {
      b[j] = cnt;
      cnt = 1;
      j++;
    }
    if (i + 1 == n - 2) {
      b[j] = cnt;
      cnt = 1;
      j++;
      break;
    }
  }
  for (int i = j; i < n; i++)
    b[i] = 0;
  for (int i = 0; i < n; i++)
    cout << b[i] << endl;
  return 0;
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int mp[1000200];
int s[1000200];
int main() {
  int a, i;
  cin >> a;
  for (i = 2; i <= a; i++) {
    cin >> s[i];
    mp[s[i]]++;
  }
  for (i = 1; i <= a; i++) {
    cout << mp[i] << endl;
  }
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int mp[100200];
int s[100200];
int main() {
  int a, i;
  cin >> a;
  for (i = 2; i <= a; i++) {
    cin >> s[i];
    mp[s[i]]++;
  }
  for (i = 1; i <= a; i++) {
    cout << mp[i] << endl;
  }
  return 0;
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, i;
  cin >> a;
  map<int, int> mp;
  int s[a], ss = 0;
  for (i = 1; i < a; i++) {
    cin >> s[i];
    mp[s[i]]++;
  }
  for (i = 1; i <= a; i++) {
    cout << mp[i] << endl;
  }
  return 0;
}


Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, i;
  cin >> a;
  int mp[a];
  int s[a];
  for (i = 2; i <= a; i++) {
    cin >> s[i];
    mp[s[i]]++;
  }
  for (i = 1; i <= a; i++) {
    cout << mp[s[i]] << endl;
  }
  return 0;
}
Problem p02707 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstring>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;

int main() {
  ll n;
  cin >> n;
  vector<int> a(n - 1);
  rep(i, n - 1) cin >> a[i];
  vector<int> z(n);
  rep(i, n - 1) { z[a[i] - 1] += 1; }
  rep(i, n) { cout << z[i] << endl; }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstring>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;

int main() {
  ll n;
  cin >> n;
  vector<int> a(n - 1);
  rep(i, n - 1) cin >> a[i];
  ll ans1 = 0;
  rep(i, n - 1) {
    if (a[i] == 1)
      ++ans1;
  }
  cout << ans1 << endl;
  for (int z = 2; z <= n; ++z) {
    ll ans2 = 0;
    rep(i, n) {
      if (a[i] == z) {
        ++ans2;
      }
    }
    cout << ans2 << endl;
  }
  return 0;
}
Problem p02707 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int N;
  cin >> N;
  vector<int> A(2 * N);
  for (int i = 2; i < N + 1; i++) {
    cin >> A.at(i);
  }
  map<int, int> cnt;
  for (int i = 1; i < N + 1; i++) {
    cnt[i] = 0;
  }
  for (int x : A) {
    if (cnt.count(x)) {
      cnt.at(x)++;
    } else {
      cnt[x] = 1;
    }
  }

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

Error: TLE

Fixed submission:

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

int main() {
  int N;
  cin >> N;
  int A[200010];

  for (int i = 2; i < N + 1; i++) {
    cin >> A[i];
  }
  for (int i = 1; i < N + 1; i++) {
    int count = 0;
    for (int j = i + 1; j < N + 1; j++) {
      if (i == A[j])
        count++;
    }
    cout << count << endl;
  }
}
Problem p02707 (C++) — buggy submission, verdict: Time Limit Exceeded

/******************************************************************************

                        بسم الله الرحمن الرحيم
                    Author: Mst: Mhamuda Khatun
                              RUCSE27

*******************************************************************************/

#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define pi 2 * acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio                                                                 \\
  {                                                                            \\
    ios_base::sync_with_stdio(false);                                          \\
    cin.tie(NULL);                                                             \\
  }
#define mod 1000000007
#define MAX 1000000000000
#define N 305

int main() {
  fastio;
  ll n, p, i;
  cin >> n;

  vector<ll> v(n + 1);

  v.assign(n + 1, 0);

  for (i = 0; i < n - 1; i++) {
    cin >> p;
    v[p]++;
  }

  for (i = 1; i <= n; i++) {
    cout << v[i];
    cout << "\\n";
  }

  return 0; //: D
}


Error: TLE

Fixed submission:

/******************************************************************************

                        بسم الله الرحمن الرحيم
                    Author: Mst: Mhamuda Khatun
                              RUCSE27

*******************************************************************************/

#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define pi 2 * acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio                                                                 \\
  {                                                                            \\
    ios_base::sync_with_stdio(false);                                          \\
    cin.tie(NULL);                                                             \\
  }
#define mod 1000000007
#define MAX 1000000000000
#define N 305

int main() {
  fastio;
  ll n, p, i;
  cin >> n;

  vector<ll> v;

  for (i = 0; i < n - 1; i++) {
    cin >> p;
    v.push_back(p);
  }

  for (i = 1; i <= n; i++) {
    cout << count(v.begin(), v.end(), i);
    cout << "\\n";
  }

  return 0; //: D
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

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

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

Error: 0

Fixed submission:

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N, 0);
  for (int i = 2; i <= N; i++) {
    cin >> A[i];
  }
  vector<int> C(N, 0);
  for (int i = 2; i <= N; i++) {
    C[A[i]]++;
  }
  for (int i = 1; i <= N; i++) {
    cout << C[i] << endl;
  }
  return 0;
}
Problem p02707 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

void solve(long N, vector<long> A) {
  vector<long> count(N);
  rep(i, N - 1) { count[A[i] - 1]++; }
  rep(i, N) { cout << count[i] << endl; }
}

int main() {
  // int 3E4
  // long 2E9
  // long long 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  long N;
  cin >> N;
  vector<long> A(N - 2 + 1);
  for (int i = 0; i < N - 2 + 1; i++) {
    cin >> A[i];
  }
  solve(N, move(A));
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

void solve(long N, vector<long> A) {
  rep(i, N) { cout << count(A.cbegin() + i, A.cend(), i + 1) << endl; }
}

int main() {
  // int 3E4
  // long 2E9
  // long long 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  long N;
  cin >> N;
  vector<long> A(N - 2 + 1);
  for (int i = 0; i < N - 2 + 1; i++) {
    cin >> A[i];
  }
  solve(N, move(A));
  return 0;
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int arr[200005];
int n, tmp;
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> tmp;
    arr[tmp]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << arr[i] << "\\n";
  }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int arr[100005];
int n, tmp;
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> tmp;
    arr[tmp]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << arr[i] << "\\n";
  }
  return 0;
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

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

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


Error: -11

Fixed submission:

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

int main() {
  int N;
  cin >> N;
  int A[N], B[N];
  for (int i = 0; i < N; i++) {
    B[i + 1] = 0;
  }
  for (int i = 0; i < N; i++) {
    cin >> A[i + 2];
    B[A[i + 2]]++;
  }
  for (int i = 1; i <= N; i++) {
    cout << B[i] << endl;
  }
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

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

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


Error: -11

Fixed submission:

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

int main() {
  int N;
  cin >> N;
  int A[N], B[N];
  for (int i = 0; i < N; i++) {
    B[i + 1] = 0;
  }
  for (int i = 0; i < N; i++) {
    cin >> A[i + 1];
    B[A[i + 1]]++;
  }
  for (int i = 0; i < N; i++) {
    cout << B[i + 1] << endl;
  }
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N;
  cin >> N;
  int A[N], B[N];
  for (int i = 1; i <= N; i++) {
    B[i] = 0;
  }
  for (int i = 1; i < N; i++) {
    cin >> A[i];
    B[A[i]]++;
  }
  for (int i = 1; i <= N; i++) {
    cout << B[i] << endl;
  }
}


Error: -11

Fixed submission:

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

int main() {
  int N, A[N], B[N];
  cin >> N;
  for (int i = 1; i <= N; i++) {
    B[i] = 0;
  }
  for (int i = 1; i < N; i++) {
    cin >> A[i];
    B[A[i]]++;
  }
  for (int i = 1; i <= N; i++) {
    cout << B[i] << endl;
  }
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n;
  cin >> n;
  int A[n];
  int B[n + 1];
  for (int i = 1; i <= n; i++) {
    B[i] = 0;
  }
  for (int i = 1; i < n; i++) {
    cin >> A[i];
    B[A[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << B[i] << endl;
  }
}


Error: -11

Fixed submission:

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

int main() {
  int N, A[N], S[N + 1];
  cin >> N;
  for (int i = 1; i <= N; i++) {
    S[i] = 1;
  }
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    S[A[i]]++;
  }
  for (int i = 1; i <= N; i++) {
    cout << S[i] << endl;
  }
}
Problem p02707 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

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

  vector<int> num(n);
  for (int j = 0; j < n - 1; j++) {
    num[a[j] - 1]++;
  }

  for (int k = 0; k < n; k++) {
    cout << num[k] << endl;
  }
}


Error: TLE

Fixed submission:

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

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

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

  vector<int> sum(N);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      while (A.at(j) == i + 1) {
        sum.at(i)++;
      }
    }
  }

  for (int i = 0; i < N; i++) {
    cout << sum.at(i) << endl;
  }
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int main() {
  ll n;

  cin >> n;

  vector<ll> a(n);
  vector<ll> b(n, 0);
  for (ll i = 1; i < n; i++) {
    cin >> a.at(i);
  }

  for (ll i = 1; i < n; i++) {
    ll c = a.at(i) - 1;
    b.at(c)++;
  }
  rep(i, n) { cout << b[i] << endl; }
}

Error: -6
munmap_chunk(): invalid pointer


Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int main() {
  ll n;

  cin >> n;

  vector<ll> a(n);
  vector<ll> b(n, 0);
  for (ll i = 1; i < n; i++) {
    cin >> a[i];
  }

  rep(i, n) {
    ll c = a[i] - 1;
    b[c]++;
  }
  rep(i, n) { cout << b[i] << endl; }
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 1; i < N; i++) {
    int X;
    cin >> X;
    A[X - 1]++;
  }
  for (int i = 0; i < N; i++) {
    cout << A[i] << std::endl;
  }

  return 0;
}


Error: 0

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> cnt(N);
  for (int i = 2; i <= N; i++) {
    cin >> A[i];
  }

  for (int i = 2; i <= N; i++) {
    cnt[A[i]]++;
  }

  for (int i = 1; i <= N; i++) {
    cout << cnt[i] << std::endl;
  }

  return 0;
}
Problem p02707 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <vector>
using namespace std;

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

  vector<int> a(N);
  vector<int> b(N);

  int i;

  a.at(0) = 0;
  b.at(0) = 0;

  for (i = 1; i <= N - 1; ++i) {
    cin >> a.at(i);
    b.at(i) = 0;
  }

  for (i = 1; i <= N - 1; ++i) {
    ++b.at(a.at(i) - 1);
  }

  for (i = 0; i <= N - 1; ++i) {
    cout << b.at(i) << endl;
    ;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;

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

  vector<int> a(N);

  int i, j, k;

  a.at(0) = 0;

  for (i = 1; i <= N - 1; ++i) {
    cin >> a.at(i);
  }

  for (j = 1; j <= N; ++j) {
    k = 0;
    for (i = 1; i <= N - 1; ++i) {
      if (a.at(i) == j) {
        ++k;
      }
    }
    cout << k << endl;
  }
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

#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;
}

Error: 0

Fixed submission:

#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;
}
Problem p02707 (C++) — buggy submission, verdict: 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 = 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';
}


Error: WA

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 = 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';
}
Problem p02707 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

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

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>

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];

  for (int i = 0; i < N; i++) {
    cout << count(A.begin(), A.end(), i + 1) << endl;
  }
  return 0;
}