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

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

int main() {
  int n, m;
  int a[100];
  int s = 0;

  cin >> n >> m;

  for (int i = 0; i < m; i++) {
    cin >> a[i];
    s += a[i];
  }
  if (s > n) {
    cout << -1 << endl;
  } else {
    cout << n - s << endl;
  }
}

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

int main() {
  int n, m;
  int a[100100];
  int s = 0;

  cin >> n >> m;

  for (int i = 0; i < m; i++) {
    cin >> a[i];
    s += a[i];
  }
  if (s > n) {
    cout << -1 << endl;
  } else {
    cout << n - s << endl;
  }
}
Problem p02706 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>

using namespace std;

int main() {
  int n;
  int m;
  int a[1000];

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

  int sum = 0;
  for (int i = 0; i < m; i++) {
    sum = sum + a[i];
  }

  if (n - sum < 0) {
    cout << -1 << endl;
  } else {
    cout << n - sum << endl;
  }

  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int n;
  int m;
  int a[10000];

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

  int sum = 0;
  for (int i = 0; i < m; i++) {
    sum = sum + a[i];
  }

  if (n - sum < 0) {
    cout << -1 << endl;
  } else {
    cout << n - sum << endl;
  }

  return 0;
}
Problem p02706 (C++)

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

#define ll long long
#define ar array

int main() {
  int n, m, a[1000];
  cin >> n >> m;
  int sum = 0;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (sum <= n) {
    cout << n - sum;
  } else {
    cout << -1;
  }
}


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

#define ll long long
#define ar array

int main() {
  int n, m, a[10000];
  cin >> n >> m;
  int sum = 0;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (sum <= n) {
    cout << n - sum;
  } else {
    cout << -1;
  }
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <ctime>
#include <fstream>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define ll long long
#define sc(n) static_cast<ll>(n)
#define IO                                                                     \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);

int main() {
  IO;
#ifdef _DEBUG
  ifstream cin("In.txt");
#endif
  ll n, a;
  cin >> n >> a;
  vector<ll> vc(n);
  for (int i = 0; i < n - 1; i++) {
    cin >> a;
    vc[--a]++;
  }
  for (int i = 0; i < n; i++)
    cout << vc[i] << '\n';
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <ctime>
#include <fstream>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define ll long long
#define sc(n) static_cast<ll>(n)
#define IO                                                                     \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);

int main() {
  IO;
#ifdef _DEBUG
  ifstream cin("In.txt");
#endif
  ll n, a;
  cin >> n;
  vector<ll> vc(n);
  for (int i = 0; i < n - 1; i++) {
    cin >> a;
    vc[--a]++;
  }
  for (int i = 0; i < n; i++)
    cout << vc[i] << '\n';
  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main(void) {
  // Your code here!

  int human_number;
  int __report[160000], __sums[160000] = {0};

  cin >> human_number;

  for (int index = 1; index < human_number; index++) {
    cin >> __report[index];
    __sums[__report[index]]++;
  }

  for (int index = 1; index <= human_number; index++) {
    cout << __sums[index] << endl;
  }
}


Fixed submission:
#include <iostream>
using namespace std;
int main(void) {
  // Your code here!

  int human_number;
  int __report[2560000], __sums[2560000] = {0};

  cin >> human_number;

  for (int index = 1; index < human_number; index++) {
    cin >> __report[index];
    __sums[__report[index]]++;
  }

  for (int index = 1; index <= human_number; index++) {
    cout << __sums[index] << endl;
  }
}
Problem p02707 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
const double PI = 3.14159265358979323846;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 1; i <= n; i++) {
    int b = 0;
    for (int j = 0; j < n; j++) {
      cin >> a[j];
      if (a[j] == i) {
        b++;
      }
    }
    cout << b << endl;
  }
  return 0;
}

// g++ lo.cpp
// ./a.exe
// g++ -o つくりたいふぁいるめい　もとのふぁいる.cpp
/*
for (int i = 0; i < n - 2; i++) {
  for (int j = i + 1; j < n - 1; j++) {
    int k = 2 * j - i;*/

Fixed submission:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
const double PI = 3.14159265358979323846;
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> b(N);
  for (int i = 0; i < N - 1; i++) {
    b.at(a.at(i) - 1)++;
  }
  for (int i = 0; i < N; i++) {
    cout << b.at(i) << endl;
  }
  return 0;
}

// g++ lo.cpp
// ./a.exe
// g++ -o つくりたいふぁいるめい　もとのふぁいる.cpp
/*
for (int i = 0; i < n - 2; i++) {
  for (int j = i + 1; j < n - 1; j++) {
    int k = 2 * j - i;*/
Problem p02707 (C++)

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

int main() {
  int N;
  int A[21000];

  cin >> N;
  A[1] = 1;
  for (int i = 2; i <= N; ++i)
    cin >> A[i];

  int B[N];
  for (int i = 1; i <= N; ++i) {
    B[i] = 0;
  }
  for (int i = 1; i <= N; ++i) {
    if (i != A[i])
      B[A[i]] += 1;
  }
  for (int i = 1; i <= N; ++i) {
    cout << B[i] << endl;
  }
}

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

int main() {
  int N;
  int A[220000];

  cin >> N;
  A[1] = 1;
  for (int i = 2; i <= N; ++i)
    cin >> A[i];

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

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

int main() {
  int n, arr[10000], p = 0;
  memset(arr, 0, sizeof(arr));
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int x;
    cin >> x;
    arr[x]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << arr[i] << "\n";
  }
  return 0;
}


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

int main() {
  int n, arr[1000000], p = 0;
  memset(arr, 0, sizeof(arr));
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int x;
    cin >> x;
    arr[x]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << arr[i] << "\n";
  }
  return 0;
}
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);
  for (int i = 0; i < N - 1; i++) {
    cin >> A[i];
  }

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

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

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 - 1; i++) {
    cin >> A[i];
  }

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

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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

/////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
typedef long long ll;
#define rep(i, s, n) for (ll i = s; i < n; i++)
#define repe(i, s, n) for (ll i = s; i <= n; i++)

int a[100001] = {};
int main() {
  int n;
  cin >> n;
  repe(i, 2, n) {
    int x;
    cin >> x;
    a[x]++;
  }
  repe(i, 1, n) { cout << a[i] << endl; }

  return 0;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

/////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
typedef long long ll;
#define rep(i, s, n) for (ll i = s; i < n; i++)
#define repe(i, s, n) for (ll i = s; i <= n; i++)

int a[200001] = {};
int main() {
  int n;
  cin >> n;
  repe(i, 2, n) {
    int x;
    cin >> x;
    a[x]++;
  }
  repe(i, 1, n) { cout << a[i] << endl; }

  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <stack>
using namespace std;

#define read(x) scanf("%d", &x)
#define readl(x) scanf("%lld", &x)
#define ll long long
#define ull unsigned long long

int n, l;
int b[100005] = {0};

int main() {
  read(n);
  for (int i = 2; i <= n; i++)
    read(l), b[l]++;
  for (int i = 1; i <= n; i++)
    printf("%d\n", b[i]);
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <stack>
using namespace std;

#define read(x) scanf("%d", &x)
#define readl(x) scanf("%lld", &x)
#define ll long long
#define ull unsigned long long

int n, l;
int b[200005] = {0};

int main() {
  read(n);
  for (int i = 2; i <= n; i++)
    read(l), b[l]++;
  for (int i = 1; i <= n; i++)
    printf("%d\n", b[i]);
  return 0;
}
Problem p02707 (C++)

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

typedef long long ll;
typedef pair<int, int> pii;

const int N = 1e5 + 11;
const int M = 1e6 + 11;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);

int son[N];

int main(int argc, char **args) {
  // freopen("in.txt", "r", stdin);
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int fa;
    scanf("%d", &fa);
    son[fa]++;
  }

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

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

typedef long long ll;
typedef pair<int, int> pii;

const int N = 2e5 + 11;
const int M = 1e6 + 11;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);

int son[N];

int main(int argc, char **args) {
  // freopen("in.txt", "r", stdin);
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int fa;
    scanf("%d", &fa);
    son[fa]++;
  }

  for (int i = 1; i <= n; i++) {
    printf("%d\n", son[i]);
  }
  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#define ll long long
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define loop(i, start, stop) for (int i = start; i < (stop); i++)
using namespace std;

int main() {

  ll N;
  cin >> N;
  ll A[100001] = {0};
  ll ans[100001] = {0};
  loop(i, 0, N) {
    cin >> A[i];
    ans[A[i]]++;
  }

  loop(i, 1, N + 1) cout << ans[i] << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#define ll long long
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define loop(i, start, stop) for (int i = start; i < (stop); i++)
using namespace std;

int main() {

  ll N;
  cin >> N;
  ll A[200001] = {0};
  ll ans[200001] = {0};
  loop(i, 0, N) {
    cin >> A[i];
    ans[A[i]]++;
  }

  loop(i, 1, N + 1) cout << ans[i] << endl;

  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {
  int num;
  int tmp;
  cin >> num;
  vector<pair<int, int>> v;
  array<int, 20010> ans;
  for (int i = 2; i <= num; i++) {
    cin >> tmp;
    ans[tmp]++;
  }
  for (int i = 1; i <= num; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {
  int num;
  int tmp;
  cin >> num;
  array<long long, 200010> ans = {};
  for (int i = 1; i < num; i++) {
    cin >> tmp;
    ans[tmp]++;
  }
  for (int i = 1; i <= num; i++) {
    cout << ans[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;
  int ans[n];
  for (int i = 0; i < n; i++) {
    ans[i] = 0;
  }
  int a;
  for (int i = 1; i < n; i++) {
    cin >> a;
    for (int j = 1; j <= n; j++) {
      if (j == a) {
        ans[j - 1] = ans[j - 1] + 1;
        break;
      }
    }
  }
  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;
  int ans[n];
  for (int i = 0; i < n; i++) {
    ans[i] = 0;
  }
  int a;
  for (int i = 1; i < n; i++) {
    cin >> a;
    ans[a - 1] = ans[a - 1] + 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, sum = 0;
  int a[10000], b[10000] = {};
  int i = 0;
  cin >> N;

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


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

int main() {
  int N, sum = 0;
  int a[1000000], b[1000000] = {};
  int i = 0;
  cin >> N;

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

Buggy submission (status: Runtime Error):
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <bitset>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define ll long long
typedef long double ld;
#define all(v) ((v).begin()), ((v).end())
#define vec2(n, m) vector<vector<ll>> vv(n + 10, vector<ll>(m + 10, 0));
#define p_q1 priority_queue<int, vector<int>, greater<int>> pq1;
#define format(n) fixed << setprecision(n)
#define ll_min LLONG_MIN;
#define ll_max LLONG_MIN;
#define endl "\n"
#define F first
#define S second
#define mkpr(x, y) make_pair(x, y)
using namespace std;
void weza() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
int main() {
  weza();
  int n, m, a, mx = 0;
  cin >> n;
  vector<int> fre(100100);
  for (int i = 1; i < n; i++) {
    cin >> a;
    fre[a]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << fre[i] << endl;
  }
}

Fixed submission:
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <bitset>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define ll long long
typedef long double ld;
#define all(v) ((v).begin()), ((v).end())
#define vec2(n, m) vector<vector<ll>> vv(n + 10, vector<ll>(m + 10, 0));
#define p_q1 priority_queue<int, vector<int>, greater<int>> pq1;
#define format(n) fixed << setprecision(n)
#define ll_min LLONG_MIN;
#define ll_max LLONG_MIN;
#define endl "\n"
#define F first
#define S second
#define mkpr(x, y) make_pair(x, y)
using namespace std;
void weza() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
int main() {
  weza();
  int n, m, a, mx = 0;
  cin >> n;
  vector<int> fre(200100);
  for (int i = 1; i < n; i++) {
    cin >> a;
    fre[a]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << fre[i] << endl;
  }
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> vec(n - 1);
  for (int i = 0; i < n - 1; i++) {
    cin >> vec.at(i);
  }
  vector<int> ans(n, 0);
  for (int i = 0; i < n - 1; i++) {
    ans.at(vec.at(i) - 1)++;
  }
  // cout << ans.at(0);
  for (int i = 0; i <= n; i++) {
    cout << ans.at(i) << endl;
  }
}

Fixed submission:
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> vec(n - 1);
  for (int i = 0; i < n - 1; i++) {
    cin >> vec.at(i);
  }
  vector<int> ans(n, 0);
  for (int i = 0; i < n - 1; i++) {
    ans.at(vec.at(i) - 1)++;
  }
  cout << ans.at(0);
  for (int i = 1; i < n; i++) {
    cout << endl << ans.at(i);
  }
}
Problem p02707 (C++)

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

using namespace std;
int main() {

  int S[100000] = {0};
  int M;
  int W;
  cin >> M;

  for (int i = 0; i < M - 1; i++) {
    cin >> W;
    S[W - 1]++;
  }
  cout << "";
  for (int i = 0; i < M; i++) {
    cout << S[i] << "\n";
  }
  return 0;
}


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

using namespace std;
int main() {

  int S[200000] = {0};
  int M;
  int W;
  cin >> M;

  for (int i = 0; i < M - 1; i++) {
    cin >> W;
    S[W - 1]++;
  }
  cout << "";
  for (int i = 0; i < M; i++) {
    cout << S[i] << "\n";
  }
  return 0;
}
Problem p02707 (C++)

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)
#define pow10(n) int(1e##n + n)

typedef long long LL;
typedef pair<int, int> P;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;

int buka[pow10(5)];

void solve() {
  int N;
  cin >> N;

  FOR(i, 2, N + 1) {
    int a;
    cin >> a;
    buka[a]++;
  }

  REP1(i, N) { std::cout << buka[i] << endl; }
}

int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  solve();
  return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)
#define pow10(n) int(1e##n + n)

typedef long long LL;
typedef pair<int, int> P;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;

int buka[2 * pow10(5)];

void solve() {
  int N;
  cin >> N;

  FOR(i, 2, N + 1) {
    int a;
    cin >> a;
    buka[a]++;
  }

  REP1(i, N) { std::cout << buka[i] << endl; }
}

int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  solve();
  return 0;
}
Problem p02707 (C++)

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

int main(void) {
  int n, m;
  cin >> n;
  // cin>>m;
  int a[n];
  int sum = 0;
  for (int i = 0; i < n; i++) {
    a[i] = 0;
  }

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

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

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

int main(void) {
  int n, m;
  cin >> n;
  // cin>>m;
  int a[n];
  int sum = 0;
  for (int i = 0; i < n; i++) {
    a[i] = 0;
  }

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

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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long;
#define dbg(x) cout << #x << "--------------" << x << endl;
#define dl cout << "LINE" << __LINE__ << endl;
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n;
  int a[9999];
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int x;
    cin >> x;
    a[x]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << endl;
  }

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define ll long long;
#define dbg(x) cout << #x << "--------------" << x << endl;
#define dl cout << "LINE" << __LINE__ << endl;
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n;
  int a[999999];
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int x;
    cin >> x;
    a[x]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << endl;
  }

  return 0;
}
Problem p02707 (C++)

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


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

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(n) n.begin(), n.end()

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(6);
  int n;
  cin >> n;
  vi a(n);
  rep(i, n - 1) cin >> a[i];

  vi ans(n + 1, 0);
  rep(i, n) { ans[a[i] - 1]++; }

  rep(i, n) { cout << ans[i] << endl; }
  return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(n) n.begin(), n.end()

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(6);
  int n;
  cin >> n;
  vi a(n);
  rep(i, n - 1) cin >> a[i];

  vi ans(n + 1, 0);
  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 <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;

int main() {
  int i, n;
  int *C;

  cin >> n;
  C = (int *)malloc(sizeof(int));
  for (i = 0; i < n; i++) {
    C[i] = 0;
  }

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

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

  free(C);
}


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

int main() {
  int i, n;
  int *C;

  cin >> n;
  C = (int *)malloc(sizeof(int) * n);
  for (i = 0; i < n; i++) {
    C[i] = 0;
  }

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

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

  free(C);
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

using namespace std;

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n, 0);
  for (int i = 0; i < n - 1; i++)
    cin >> a[i];
  for (auto e : a)
    b[e - 1]++;
  for (auto e : b)
    cout << e << endl;
}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(16);

  solve();

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

using namespace std;

void solve() {
  int n;
  cin >> n;
  vector<int> a(n - 1);
  vector<int> b(n, 0);
  for (int i = 0; i < n - 1; i++)
    cin >> a[i];
  for (auto e : a)
    b[e - 1]++;
  for (auto e : b)
    cout << e << endl;
}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(16);

  solve();

  return 0;
}
Problem p02707 (C++)

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

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 &y) {
  if (x > y)
    x = y;
}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 &y) {
  if (x < y)
    x = y;
}

int n;
vector<int> a;

void read() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    x--;
    a[x]++;
  }
  for (auto i : a)
    cout << i << "\n";
}

void run() {}

void write() {}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  read();
  run();
  write();
  return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 &y) {
  if (x > y)
    x = y;
}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 &y) {
  if (x < y)
    x = y;
}

int n;
vector<int> a;

void read() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n - 1; i++) {
    int x;
    cin >> x;
    x--;
    a[x]++;
  }
  for (auto i : a)
    cout << i << "\n";
}

void run() {}

void write() {}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  read();
  run();
  write();
  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#define ll long int
const int ARR = 1e5 + 2;
using namespace std;
int main() {
  ll n;
  cin >> n;
  ll a[ARR];
  a[0] = 1;
  for (int i = 1; i < n; i++) {
    cin >> a[i];
  }
  ll ans[ARR] = {0};
  for (int i = 1; i < n; i++) {
    ans[a[i] - 1]++;
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Fixed submission:
#include <iostream>
#define ll long int
const int ARR = 2e5 + 5;
using namespace std;
int main() {
  ll n;
  cin >> n;
  ll a[ARR];
  a[0] = 1;
  for (int i = 1; i < n; i++) {
    cin >> a[i];
  }
  ll ans[ARR] = {0};
  for (int i = 1; i < n; 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 <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {

  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);

  A[0] = 0;
  B[0] = 0;

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

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

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

  return 0;
}


Fixed submission:


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

int main() {

  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);

  A[0] = 0;
  B[0] = 0;

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

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

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

  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <climits>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main() {
#ifdef RUN_LOCAL
  ifstream in("../input.txt");
  cin.rdbuf(in.rdbuf());
#endif

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

  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);

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

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

  return 0;
}


Fixed submission:
#include <algorithm>
#include <climits>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main() {
#ifdef RUN_LOCAL
  ifstream in("../input.txt");
  cin.rdbuf(in.rdbuf());
#endif

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

  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);

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

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

  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int A[100005];
int main() {
  int N, M;
  cin >> N;
  for (int i = 1; i < N; i++) {
    int t;
    cin >> t;
    A[t - 1]++;
  }
  for (int i = 0; i < N; i++)
    cout << A[i] << endl;
  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;
int A[200005];
int main() {
  int N, M;
  cin >> N;
  for (int i = 1; i < N; i++) {
    int t;
    cin >> t;
    A[t - 1]++;
  }
  for (int i = 0; i < N; i++)
    cout << A[i] << endl;
  return 0;
}
Problem p02707 (C++)

Buggy submission (status: 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];
  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;
}

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];
  vector<int> z(n);
  rep(i, n - 1) { z[a[i] - 1] += 1; }
  rep(i, n) { cout << z[i] << endl; }

  return 0;
}
Problem p02707 (C++)

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

using namespace std;
const int MAXN = 1e5 + 2;

int arr[MAXN];
int main() {
  int N;
  cin >> N;

  for (int i = 2; i <= N; i++) {
    int pos;
    cin >> pos;
    arr[pos]++;
  }
  for (int i = 1; i <= N; i++) {
    cout << arr[i] << "\n";
  }
  return 0;
}


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

using namespace std;
const int MAXN = 2e5 + 2;

int arr[MAXN];
int main() {
  int N;
  cin >> N;

  for (int i = 2; i <= N; i++) {
    int pos;
    cin >> pos;
    arr[pos]++;
  }
  for (int i = 1; i <= N; i++) {
    cout << arr[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> s(N, 0);
  for (int i = 1; i < N; i++) {
    cin >> s.at(i);
  }
  vector<int> result(N, 0);
  for (int i = 1; i < N; i++) {
    for (int j = 1; j < N; j++) {
      if (s.at(j) == i) {
        result.at(i - 1) += 1;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    cout << result.at(i) << endl;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> s(N, 0);
  for (int i = 1; i < N; i++) {
    cin >> s.at(i);
  }
  vector<int> result(N, 0);
  for (int i = 1; i < N; i++) {
    result.at(s.at(i) - 1) += 1;
  }
  for (int i = 0; i < N; i++) {
    cout << result.at(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 - 1);
  vector<int> b(N);
  for (int i = 0; i < N - 1; i++) {
    cin >> a[i];
  }

  for (int j = 0; j < N - 1; j++) {
    for (int k = 1; k < N; k++) {
      if (a[j] == k)
        b[k - 1]++;
    }
  }

  for (int l = 0; l < N; l++) {
    cout << b[l] << endl;
  }
}


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

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

  for (int j = 0; j < N - 1; j++) {
    b[a[j] - 1]++;
  }

  for (int l = 0; l < N; l++) {
    cout << b[l] << endl;
  }
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
typedef long long int ll;
using namespace std;
#define maxN 200007

int n;

int solve() {
  int temp[maxN] = {};
  for (int i = 0; i < n - 1; i++) {
    int a;
    cin >> a;
    temp[a]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << temp[i] << endl;
  }
}

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

  cin >> n;
  solve();
}

Fixed submission:
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
typedef long long int ll;
using namespace std;
#define maxN 200007

int n;

void solve() {
  int temp[maxN] = {};
  for (int i = 0; i < n - 1; i++) {
    int a;
    cin >> a;
    temp[a]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << temp[i] << endl;
  }
}

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

  cin >> n;
  solve();
}
Problem p02707 (C++)

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

signed main() {
  int subs[100000];
  int n;
  cin >> n;
  subs[0] = 0;
  for (int i = 1; i < n; i++) {
    subs[i] = 0;
    int no;
    cin >> no;
    subs[no - 1]++;
  }
  for (int i = 0; i < n; i++) {
    cout << subs[i] << endl;
  }
}


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

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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <cmath>
#include <math.h>
#include <stdio.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll = long long;
using ull = unsigned long long;
const ll INF = 1001001001;

// 10億7。　　　100000007

// 最大公約数
ll gcd(ll a, ll b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}
// 最小公倍数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main() {
  cout << fixed << setprecision(10);
  // cin.tie(0); ios::sync_with_stdio(false);

  ll N;
  cin >> N;
  vector<ll> vec(N - 1);
  vector<ll> vecans(N);
  for (int i = 0; i < N - 1; i++) {
    cin >> vec[i];
  }
  for (int i = 0; i < N; i++) {
    vecans[i] = 0;
  }
  for (int i = 0; i < N; i++) {
    vecans[vec[i] - 1]++;
  }

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


Fixed submission:
#include <bits/stdc++.h>
#include <cmath>
#include <math.h>
#include <stdio.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll = long long;
using ull = unsigned long long;
const ll INF = 1001001001;

// 10億7。　　　100000007

// 最大公約数
ll gcd(ll a, ll b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}
// 最小公倍数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main() {
  cout << fixed << setprecision(10);
  // cin.tie(0); ios::sync_with_stdio(false);

  ll N;
  cin >> N;
  vector<ll> vec(N - 1);
  vector<ll> vecans(N);
  for (int i = 0; i < N - 1; i++) {
    cin >> vec[i];
  }
  for (int i = 0; i < N; i++) {
    vecans[i] = 0;
  }
  for (int i = 0; i < N - 1; i++) {
    vecans[vec[i] - 1]++;
  }

  for (int i = 0; i < N; i++) {
    cout << vecans[i] << endl;
  }
}
Problem p02707 (C++)

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

int a[100001];

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

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

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

int a[200001];

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

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

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

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

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

  for (int i = 1; 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> vec(N - 1);
  for (int i = 0; i < N - 1; i++) {
    cin >> vec.at(i);
  }

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

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

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v1(n);
  vector<int> v2(n - 1);
  for (int i = 0; i < n - 1; ++i) {
    cin >> v2[i];
  }
  for (int i = 1; i < n; ++i) {
    for (int j = 0; j < n - 1; j++) {
      if (i == v2[j])
        v1[i - 1]++;
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << v1[i] << endl;
  }
  return 0;
}


Fixed submission:
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v1(n);
  vector<int> v2(n - 1);
  for (int i = 0; i < n - 1; ++i) {
    cin >> v2[i];
    v1[v2[i] - 1]++;
  }
  for (int i = 0; i < n; ++i) {
    cout << v1[i] << endl;
  }
  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int main() {
  int n;
  cin >> n;
  int a[n + 1];
  for (int i = 2; i <= n; i++)
    cin >> a[i];
  int v[n + 1];
  for (int i = 1; i <= n; i++) {
    v[i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    v[a[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << v[i] << "\n";
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int main() {
  int n;
  cin >> n;
  int a[n + 1];
  for (int i = 2; i <= n; i++)
    cin >> a[i];
  int v[n + 1];
  for (int i = 1; i <= n; i++) {
    v[i] = 0;
  }
  for (int i = 2; i <= n; i++) {
    v[a[i]]++;
  }
  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;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);

  for (int x : A) {
    cin >> x;
    B.at(x - 1)++;
  }
  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 - 1);
  vector<int> B(N);

  for (int x : A) {
    cin >> x;
    B.at(x - 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;
int main() {
  int t, i, c[100], x;
  cin >> t;
  for (i = 1; i <= t - 1; i++) {
    cin >> x;
    c[x]++;
  }
  for (int i = 1; i <= t; i++)
    cout << c[i] << endl;
}


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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;

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

#define forn(i, n) for (int(i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

const int N = 150000;
const int M = 500;
const int MOD = 1e9 + 7;
const int alpha = 26;
const double PI = acos(-1);
ll n, k;
ll ans = 0;
ll a[N];
ll b[N];

signed main() {
#ifdef ONLINE_JUDGE
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
#endif // ONLINE_JUDGE
  cin >> n;
  for (int i = 1; i < n; i++)
    cin >> k, a[k]++;
  for (int i = 1; i <= n; i++)
    cout << a[i] << "\n";
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;

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

#define forn(i, n) for (int(i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

const int N = 250000;
const int M = 500;
const int MOD = 1e9 + 7;
const int alpha = 26;
const double PI = acos(-1);
ll n, k;
ll ans = 0;
ll a[N];
ll b[N];

signed main() {
#ifdef ONLINE_JUDGE
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
#endif // ONLINE_JUDGE
  cin >> n;
  for (int i = 1; i < n; i++)
    cin >> k, a[k]++;
  for (int i = 1; i <= n; i++)
    cout << a[i] << "\n";
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
/**
 *    author:  musasi
 *    created: 19.04.2020 21:29:30
 **/

#include <bits/stdc++.h>

using namespace std;
#define rep2(x, from, to) for (long long(x) = (from); (x) < (to); (x)++)
#define rep(x, to) rep2(x, 0, to)
#define MOD 10000007 // 10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ALL(x) (x).begin(), (x).end()
#define ASSERT(expr...) assert((expr))
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef pair<ll, PP> PPP;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int n;
int ans[100006];
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> n;
  vector<int> a(n - 1);
  rep(i, n - 1) {
    cin >> a[i];
    ans[a[i] - 1]++;
  }
  rep(i, n) cout << ans[i] << endl;

  return 0;
}

Fixed submission:
/**
 *    author:  musasi
 *    created: 19.04.2020 21:29:30
 **/

#include <bits/stdc++.h>

using namespace std;
#define rep2(x, from, to) for (long long(x) = (from); (x) < (to); (x)++)
#define rep(x, to) rep2(x, 0, to)
#define MOD 10000007 // 10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ALL(x) (x).begin(), (x).end()
#define ASSERT(expr...) assert((expr))
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef pair<ll, PP> PPP;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int n;
int ans[200006];
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> n;
  vector<int> a(n - 1);
  rep(i, n - 1) {
    cin >> a[i];
    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;

const int N = 100005;

vector<int> g[N];

int sz[N];
int dfs(int u, int p) {
  sz[u] = 1;
  for (int v : g[u])
    if (v != p)
      sz[u] += dfs(v, u);
  return sz[u];
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    int p;
    scanf("%d", &p);
    sz[p]++;
    g[p].push_back(i);
  }
  // 	dfs(1, 1);

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


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

using namespace std;

const int N = 200005;

vector<int> g[N];

int sz[N];
int dfs(int u, int p) {
  sz[u] = 1;
  for (int v : g[u])
    if (v != p)
      sz[u] += dfs(v, u);
  return sz[u];
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    int p;
    scanf("%d", &p);
    sz[p]++;
    g[p].push_back(i);
  }
  // 	dfs(1, 1);

  for (int i = 1; i <= n; i++) {
    printf("%d\n", sz[i]);
  }
}
Problem p02707 (C++)

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

int main() {
  long long n;
  cin >> n;
  vector<long long> a(n - 1);
  for (int i = 0; i < n - 1; i++) {
    cin >> a.at(i);
  }
  vector<int> sum(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n - 1; j++) {
      if (i + 1 == a.at(j)) {
        sum.at(i) += 1;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << sum.at(i) << endl;
  }
  return 0;
}

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

int main() {
  long long n;
  cin >> n;
  vector<long long> a(n - 1);
  for (int i = 0; i < n - 1; i++) {
    cin >> a.at(i);
  }
  vector<int> sum(n);
  for (int i = 0; i < n - 1; i++) {
    sum.at(a.at(i) - 1)++;
  }
  for (int i = 0; i < n; i++) {
    cout << sum.at(i) << endl;
  }
  return 0;
}