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

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


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) {
  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;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define MAX(a, b) a = a > b ? a : b
#define MIN(a, b) a = a < b ? a : b
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPR(i, x, n) for (int i = n - 1; i >= x; i--)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
  ll n, m, a[101010], sum[101010] = {};
  string s;
  cin >> n;
  rep(i, n - 1) {
    cin >> a[i];
    sum[a[i]]++;
  }
  rep(i, n) { cout << sum[i + 1] << endl; }
  // cout<<endl;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define MAX(a, b) a = a > b ? a : b
#define MIN(a, b) a = a < b ? a : b
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPR(i, x, n) for (int i = n - 1; i >= x; i--)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
  ll n, m, a[201010], sum[201010] = {};
  string s;
  cin >> n;
  rep(i, n - 1) {
    cin >> a[i];
    sum[a[i]]++;
  }
  rep(i, n) { cout << sum[i + 1] << endl; }
  // cout<<endl;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<int> a(n - 1);
  map<int, int> b;
  for (int i = 1; i < n; 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;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<int> a(n - 1);
  map<int, int> b;
  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):
#include <bits/stdc++.h>
using namespace std;
long long n, m, ans, temp;
int a[111111];
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> temp;
    a[temp]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
long long n, m, ans, temp;
int a[11111111];
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> temp;
    a[temp]++;
  }
  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;
int main() {
  int n, a, i, m;
  cin >> n;
  int arr[20000];
  memset(arr, 0, 20000);
  m = n - 1;
  while (m--) {
    cin >> a;
    arr[a - 1]++;
  }
  for (i = 0; i < n; i++)
    cout << arr[i] << endl;
}

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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ARB                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define ll long long
#define bp __builtin_popcount
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set;
const int maxn = 1e5 + 5;
const double EPS = 1e-14;
const int MOD = 1000000007;
int arr[maxn];
int fr[maxn] = {0};
int main() {
  ARB int n;
  cin >> n;
  for (int i = 1; i < n; i++)
    cin >> arr[i];
  for (int i = 1; i <= n; i++)
    fr[arr[i]]++;
  for (int i = 1; i <= n; i++)
    cout << fr[i] << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ARB                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define ll long long
#define bp __builtin_popcount
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set;
const int maxn = 1e8 + 5;
const double EPS = 1e-14;
const int MOD = 1000000007;
int arr[maxn];
int fr[maxn] = {0};
int main() {
  ARB int n;
  cin >> n;
  for (int i = 1; i < n; i++)
    cin >> arr[i];
  for (int i = 1; i <= n; i++)
    fr[arr[i]]++;
  for (int i = 1; i <= n; i++)
    cout << fr[i] << endl;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
int main() {
  int n, a[100000], b[100000] = {0}, i;
  cin >> n;
  for (i = 1; i < n; i++) {
    cin >> a[i];
  }
  for (i = 1; i < n; i++) {
    b[a[i]]++;
  }
  for (i = 1; i <= n; i++) {
    cout << b[i] << endl;
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
int main() {
  int n, a[300000], b[300000] = {0}, i;
  cin >> n;
  for (i = 1; i < n; i++) {
    cin >> a[i];
  }
  for (i = 1; i < n; i++) {
    b[a[i]]++;
  }
  for (i = 1; i <= n; i++) {
    cout << b[i] << endl;
  }
  return 0;
}
Problem p02707 (Python)

Buggy submission (status: Time Limit Exceeded):
n = int(input())

line = list(map(int, input().strip().split(" ")))

for i in range(1, n + 1):
    print(line.count(i))


Fixed submission:
n = int(input())

line = list(map(int, input().strip().split(" ")))

ans = [0 for s in range(n)]

for i in line:
    ans[i - 1] += 1

for i in range(n):
    print(ans[i])
Problem p02707 (C++)

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

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[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;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define lli long long
int main() {
  lli n, i, j, c = 0, s = 0;
  cin >> n;
  lli arr[n - 1];
  lli brr[10001] = {0};
  for (i = 0; i < n - 1; i++)
    cin >> arr[i];
  unordered_map<lli, lli> m;
  for (i = 0; i < n - 1; i++) {
    m[arr[i]]++;
  }
  for (auto it : m) {
    brr[it.first] = it.second;
  }
  for (i = 1; i <= n; i++) {
    cout << brr[i] << endl;
  }

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define lli long long
int main() {
  lli n, i, j, c = 0, s = 0;
  cin >> n;
  lli arr[n - 1];
  lli brr[1000001] = {0};
  for (i = 0; i < n - 1; i++)
    cin >> arr[i];
  unordered_map<lli, lli> m;
  for (i = 0; i < n - 1; i++) {
    m[arr[i]]++;
  }
  for (auto it : m) {
    brr[it.first] = it.second;
  }
  for (i = 1; i <= n; i++) {
    cout << brr[i] << endl;
  }

  return 0;
}
Problem p02707 (C++)

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

using namespace std;

int main() {
  int d[20001], a[20001], i, n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    cin >> a[i];
    d[a[i]]++;
  }
  for (int i = 1; i <= n; i++)
    cout << d[i] << "\n";
  return 0;
}


Fixed submission:
#include <iostream>

using namespace std;

int main() {
  long long d[2000001], a[2000001], i, n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    cin >> a[i];
    d[a[i]]++;
  }
  for (int i = 1; i <= n; i++)
    cout << d[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> vec(N);
  int A;
  vec.at(0) = 0;
  for (int i = 1; i < N; i++) {
    cin >> A;
    vec.at(i) = A;
  }
  sort(vec.begin(), vec.end());
  int counter;
  int start = 0;
  for (int i = 0; i < N; i++) {
    counter = 0;
    for (int j = start; j < N; j++) {
      if (vec.at(j) == i + 1)
        counter++;
    }
    cout << counter << endl;
    start += counter;
  }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  int A;
  vec.at(0) = 0;
  for (int i = 1; i < N; i++) {
    cin >> A;
    vec.at(i) = A;
  }
  sort(vec.begin(), vec.end());
  int counter;
  int start = 0;
  for (int i = 0; i < N; i++) {
    counter = 0;
    for (int j = start; j < N; j++) {
      if (vec.at(j) == i + 1)
        counter++;
      if (vec.at(j) > i + 1)
        break;
    }
    cout << counter << endl;
    start += counter;
  }
}
Problem p02707 (C++)

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

Fixed submission:
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int a;
  cin >> a;
  vector<int> b(a - 1), c(a);
  for (int i = 0; i < a - 1; i++) {
    cin >> b.at(i);
    c.at(b.at(i) - 1)++;
  }
  for (int i = 0; i < a; i++) {
    cout << c.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(200010);
  vector<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;
using namespace std;

#define ll long long
#define f(i, a, b) for (int i = a; i < b; i++)
#define endl '\n'
#define spc " "
#define pb push_back
#define mp make_pair

int main()

{
  ios::sync_with_stdio(0);
  cin.tie(0);
  // freopen("in.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  ll n;
  cin >> n;
  ll a[10000];
  f(i, 0, n - 1) { cin >> a[i]; }
  map<ll, ll> m;
  f(i, 1, n + 1) m[i] = 0;
  f(i, 0, n - 1) { m[a[i]]++; }
  f(i, 1, n + 1) { cout << m[i] << endl; }
}

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

#define ll long long
#define f(i, a, b) for (int i = a; i < b; i++)
#define endl '\n'
#define spc " "
#define pb push_back
#define mp make_pair

int main()

{
  ios::sync_with_stdio(0);
  cin.tie(0);
  // freopen("in.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  ll n;
  cin >> n;
  ll a[n];
  f(i, 0, n - 1) { cin >> a[i]; }
  map<ll, ll> m;
  f(i, 1, n + 1) m[i] = 0;
  f(i, 0, n - 1) { m[a[i]]++; }
  f(i, 1, n + 1) { cout << m[i] << endl; }
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define INF 9003372036854775807LL
#define mod 998244353
#define fixed fixed << setprecision(12)
#define abs(x, y) (max(x, y) - min(x, y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
lol a[100010];
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  lol n, m, k, r, x, y;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> m;
    a[m]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << '\n';
  }
  return (0);
}


Fixed submission:
#include <bits/stdc++.h>
#define INF 9003372036854775807LL
#define mod 998244353
#define fixed fixed << setprecision(12)
#define abs(x, y) (max(x, y) - min(x, y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
lol a[300010];
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  lol n, m, k, r, x, y;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> m;
    a[m]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << '\n';
  }
  return (0);
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
const double pi = acos(-1);
int n, c[N], a;
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    scanf("%d", &a);
    c[a]++;
  }
  for (int i = 1; i <= n; ++i)
    printf("%d\n", c[i]);
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
const double pi = acos(-1);
int n, c[N], a;
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    scanf("%d", &a);
    c[a]++;
  }
  for (int i = 1; i <= n; ++i)
    printf("%d\n", c[i]);
}
Problem p02707 (C++)

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

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

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

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

Buggy submission (status: Time Limit Exceeded):
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  int num[n - 1];

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

  int buka[n];
  for (int i = 0; i < n; i++) {
    buka[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n - 1; j++) {
      if (i + 1 == num[j]) {
        buka[i] = buka[i] + 1;
      }
    }
  }

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

  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  int num[n - 1];

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

  int buka[n] = {};
  for (int i = 0; i < n - 1; i++) {
    buka[num[i] - 1] = buka[num[i] - 1] + 1;
  }

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

  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h> // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repto(i, n) for (int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

__attribute__((constructor)) void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int cnt[20001] = {0};

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

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

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


Fixed submission:
#include <bits/stdc++.h> // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repto(i, n) for (int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

__attribute__((constructor)) void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int cnt[200001] = {0};

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

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

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

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

#define ff first
#define ss second
#define pb push_back
#define sz size()
#define mp make_pair

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

int ans[N];

int main() {
  int n, x;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> x;
    ans[x]++;
  }
  for (int i = 1; i <= n; i++)
    printf("%d\n", ans[i]);
  return 0;
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

#define ff first
#define ss second
#define pb push_back
#define sz size()
#define mp make_pair

const int N = 2e5 + 5;
const int MOD = 1e9 + 7;

int ans[N];

int main() {
  int n, x;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> x;
    ans[x]++;
  }
  for (int i = 1; i <= n; i++)
    printf("%d\n", ans[i]);
  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
#include <set>
#include <string>
#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];
  vector<int> ans(n);
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < n; j++) {
      if (a[i] == j + 1)
        ans[j]++;
    }
  }
  for (int i = 0; i < n; i++)
    cout << ans[i] << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
#include <set>
#include <string>
#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];
  vector<int> ans(n);
  for (int i = 0; i < n - 1; 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 <vector>
using namespace std;

#define ll long long
#define pb push_back

const int maxn = 1e5 + 20;

vector<int> adj[maxn];

bool visited[maxn];

void dfs(int v) {
  visited[v] = 1;
  for (auto u : adj[v])
    if (!visited[u])
      dfs(u);
}

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

  int n;
  cin >> n;

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

    adj[a].pb(i);
  }
  for (int i = 0; i < n; i++) {
    cout << adj[i].size() << endl;
  }
  return 0;
}

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

#define ll long long
#define pb push_back

const int maxn = 2e5 + 20;

vector<int> adj[maxn];

bool visited[maxn];

void dfs(int v) {
  visited[v] = 1;
  for (auto u : adj[v])
    if (!visited[u])
      dfs(u);
}

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

  int n;
  cin >> n;

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

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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <deque>
#include <forward_list>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#define TitansGo                                                               \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define all(v) v.begin(), v.end()
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define ll long long
#define endl "\n"
#define S second
#define F first
using namespace std;
int frq[50000];
int main() {
  TitansGo int n, a;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> a;
    frq[a]++;
  }
  for (int i = 1; i <= n; i++)
    cout << frq[i] << endl;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <deque>
#include <forward_list>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#define TitansGo                                                               \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define all(v) v.begin(), v.end()
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define ll long long
#define endl "\n"
#define S second
#define F first
using namespace std;
int frq[200000];
int main() {
  TitansGo int n, a;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> a;
    frq[a]++;
  }
  for (int i = 1; i <= n; i++)
    cout << frq[i] << endl;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
// #pragma GCC optimize(“O2”)
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define pi 3.14159265358979323846264338327950254
#define STDIN                                                                  \
  freopen("in.txt", "r", stdin);                                               \
  freopen("out.txt", "w", stdout); //************************************

#define ll long long
// #define int ll

const int mod = 100999;
const int N = 1e5 + 10;
int son[N];
int main() {
  // STDIN
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int t;
    cin >> t;
    son[t]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << son[i] << endl;
  }
}


Fixed submission:
// #pragma GCC optimize(“O2”)
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define pi 3.14159265358979323846264338327950254
#define STDIN                                                                  \
  freopen("in.txt", "r", stdin);                                               \
  freopen("out.txt", "w", stdout); //************************************

#define ll long long
// #define int ll

const int mod = 100999;
const int N = 3e5 + 10;
int son[N];
int main() {
  // STDIN
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int t;
    cin >> t;
    son[t]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << son[i] << endl;
  }
}
Problem p02707 (C++)

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

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return (0)
#define rep(i, n) for (int(i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for (int(i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for (auto &(e) : (elem))
#define FAST                                                                   \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e);
#define INF 1e+12
#define PI acos(-1)
using ll = long long;
using ull = unsigned long long;

int a[100010];

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

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

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

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return (0)
#define rep(i, n) for (int(i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for (int(i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for (auto &(e) : (elem))
#define FAST                                                                   \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e);
#define INF 1e+12
#define PI acos(-1)
using ll = long long;
using ull = unsigned long long;

int a[200010];

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

  for (int i = 1; i <= n; ++i) {
    println(a[i]);
  }
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dp[50000];
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    dp[a[i]]++;
  }

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dp[50000000];
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    dp[a[i]]++;
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#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.at(i);
  sort(a.begin(), a.end());
  rep(i, n) {
    if (i < a.back()) {
      cout << count(a.begin(), a.end(), i + 1) << endl;
    } else {
      cout << 0 << endl;
    }
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#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);
  for (int i = 2; i <= n; i++) {
    int num;
    cin >> num;
    a.at(num)++;
  }
  for (int i = 1; i <= n; i++) {
    cout << a.at(i) << endl;
  }
  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define longlongvector vector<long long>
#define intvector vector<int>
#define size size()
using namespace std;

int n, m, k;

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

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

  // system("pause");
}

Fixed submission:
#include <bits/stdc++.h>
#define longlongvector vector<long long>
#define intvector vector<int>
#define size size()
using namespace std;

int n, m, k;

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

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

  // system("pause");
}
Problem p02707 (C++)

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

using namespace std;

typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;

const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int k;

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

  return gcd(b, a % b);
}

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

  for (int i = 1; i < n; i++)
    cin >> a_[i];

  vector<int> cnt(n, 0);

  rep(i, n) { cnt[a_[i] - 1]++; }

  rep(i, n) cout << cnt[i] << endl;

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;

const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int k;

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

  return gcd(b, a % b);
}

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

  for (int i = 1; i < n; i++)
    cin >> a_[i];

  vector<int> cnt(n, 0);

  for (int i = 1; i < n; i++) {
    cnt[a_[i] - 1]++;
  }

  rep(i, n) cout << cnt[i] << endl;

  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

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

Fixed submission:
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(), obj.end()
#define SORT(obj) sort(obj.begin(), obj.end())
#define pb(obj) push_back(obj)
#define REP(i, N) for (int i = 0; i < N; i++)
typedef long long ll;
ll const MOD = 1e9 + 7;
using ll = long long;

int main() {
  ll n;
  cin >> n;
  vector<int> data(n - 1, 0);
  REP(i, n - 1) {
    int a;
    cin >> a;
    data[a - 1]++;
  }
  REP(i, n) { cout << data.at(i) << endl; }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(), obj.end()
#define SORT(obj) sort(obj.begin(), obj.end())
#define pb(obj) push_back(obj)
#define REP(i, N) for (int i = 0; i < N; i++)
typedef long long ll;
ll const MOD = 1e9 + 7;
using ll = long long;

int main() {
  ll n;
  cin >> n;
  vector<int> data(n);
  REP(i, n - 1) {
    int a;
    cin >> a;
    data[a - 1]++;
  }
  REP(i, n) { cout << data.at(i) << endl; }
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);
#define endl "\n"
#define MAXN 100123
#define ll long long
#define INF INT_MAX
#define FORE(i, m, n) for (int i = m; i < n; i++)
#define FOR(i, n) FORE(i, 0, n)
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define ps(v) push_back(v)
#define ms(v, x) memset(v, x, sizeof(v))

using namespace std;

int n, v;
int freq[MAXN];

int main() {
  _ cin >> n;

  FOR(i, n - 1) {
    cin >> v;
    freq[v]++;
  }

  FORE(i, 1, n + 1) { cout << freq[i] << endl; }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);
#define endl "\n"
#define MAXN 2 * 100123
#define ll long long
#define INF INT_MAX
#define FORE(i, m, n) for (int i = m; i < n; i++)
#define FOR(i, n) FORE(i, 0, n)
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define ps(v) push_back(v)
#define ms(v, x) memset(v, x, sizeof(v))

using namespace std;

int n, v;
int freq[MAXN];

int main() {
  _ cin >> n;

  FOR(i, n - 1) {
    cin >> v;
    freq[v]++;
  }

  FORE(i, 1, n + 1) { cout << freq[i] << endl; }
  return 0;
}
Problem p02707 (C++)

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

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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

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

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

int main() {
  int g[100100] = {};
  int n;
  cin >> n;

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

  repi(i, 1, n + 1) { cout << g[i] << endl; }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

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

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

int main() {
  int g[200100] = {};
  int n;
  cin >> n;

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

  repi(i, 1, n + 1) { cout << g[i] << endl; }
  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int cnt[N] = {};
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, x;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> x;
    cnt[x]++;
  }
  for (int i = 1; i <= n; i++)
    cout << cnt[i] << '\n';
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int cnt[N] = {};
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, x;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> x;
    cnt[x]++;
  }
  for (int i = 1; i <= n; i++)
    cout << cnt[i] << '\n';
  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 7;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;

int vis[maxn];

int main() {
  memset(vis, 0, sizeof(vis));
  int n;
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    int x;
    scanf("%d", &x);
    vis[x]++;
  }
  for (int i = 1; i <= n; i++) {
    printf("%d\n", vis[i]);
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 7;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;

int vis[maxn];

int main() {
  memset(vis, 0, sizeof(vis));
  int n;
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    int x;
    scanf("%d", &x);
    vis[x]++;
  }
  for (int i = 1; i <= n; i++) {
    printf("%d\n", vis[i]);
  }
  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main(int argc, char *argv[]) {
  ll n, m, sum = 0;
  cin >> n;
  ll a;
  ll Employee[100005] = {};
  for (int i = 1; i < n; i++) {
    cin >> a;
    Employee[a]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << Employee[i] << endl;
  }
  return 0;
}

Fixed submission:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main(int argc, char *argv[]) {
  ll n, m, sum = 0;
  cin >> n;
  ll a;
  ll Employee[200005] = {};
  for (int i = 1; i < n; i++) {
    cin >> a;
    Employee[a]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << Employee[i] << endl;
  }
  return 0;
}
Problem p02707 (C++)

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

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define pie 3.1415926
int ara[200020], ara2[200020];
int main() {
  int n, i;
  cin >> n;
  for (i = 2; i <= n; i++) {
    cin >> ara[i];
    ara2[ara[i]]++;
  }
  for (i = 1; i <= n; i++)
    cout << ara2[i] << endl;

  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int N;
  const int n = 100000;
  int A[n];
  int M[n] = {0};

  cin >> N;

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

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

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int N;
  const int n = 1000000;
  int A[n];
  int M[n] = {0};

  cin >> N;

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

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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
int cnt[100005];
int main() {
  int n, x;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> x;
    cnt[x]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << cnt[i] << endl;
  }

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
int cnt[10000005];
int main() {
  int n, x;
  cin >> n;
  for (int i = 0; i < n - 1; 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>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using lint = long long int;

int main() {
  lint n;
  cin >> n;
  vector<lint> vc;
  rep(i, n - 1) {
    int x;
    cin >> x;
    vc.push_back(x);
  }
  vector<lint> cnt(5);
  rep(i, n - 1) cnt[(vc[i] - 1)]++;
  rep(i, n) cout << cnt[i] << endl;
  return 0;
}


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

int main() {
  lint n;
  cin >> n;
  vector<lint> vc;
  rep(i, n - 1) {
    int x;
    cin >> x;
    vc.push_back(x);
  }
  vector<lint> cnt(n);
  rep(i, n - 1) cnt[(vc[i] - 1)]++;
  rep(i, n) cout << cnt[i] << endl;
  return 0;
}
Problem p02707 (Python)

Buggy submission (status: Time Limit Exceeded):
n = int(input())
a = map(int, input().split())

a = list(a)
for i in range(n):
    count = 0
    for j in range(i, n - 1):
        if a[j] == i + 1:
            count += 1
    print(count)


Fixed submission:
n = int(input())
a = map(int, input().split())

a = list(a)
result = [0] * n
for i in range(n - 1):
    result[a[i] - 1] += 1

print(*result, sep="\n")
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define erep(i, n) for (int i = 0; i <= (n); i++)
#define erep1(i, n) for (int i = 1; i <= (n); i++)
using namespace std;
using ll = long long;
int main() {
  int N;
  cin >> N;
  int n = n + 1;
  vector<int> a(n);
  for (int i = 2; i <= N; i++) {
    cin >> a[i];
  }
  vector<int> d(n);
  for (int i = 2; i <= N; i++) {
    ++d[a[i]];
  }
  erep1(i, N) cout << d[i] << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define erep(i, n) for (int i = 0; i <= (n); i++)
#define erep1(i, n) for (int i = 1; i <= (n); i++)
using namespace std;
using ll = long long;
int main() {
  int N;
  cin >> N;
  int n = N + 1;
  vector<int> a(n);
  for (int i = 2; i <= N; i++) {
    cin >> a[i];
  }
  vector<int> d(n);
  for (int i = 2; i <= N; i++) {
    ++d[a[i]];
  }
  erep1(i, N) cout << d[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 - 1);
  for (int i = 0; i < N - 1; i++) {
    cin >> A.at(i);
  }

  vector<int> ans(N);
  for (int i = 0; i < N; i++) {
    ans.at(i) = 0;
  }
  for (int i = 0; i < N; i++) {
    ans.at(A.at(i)) = ans.at(A.at(i)) + 1;
  }
  for (int i = 0; i < N; i++) {
    cout << ans.at(i) << endl;
  }
  return 0;
}

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> ans(N);
  for (int i = 0; i < N; i++) {
    ans.at(i) = 0;
  }
  for (int i = 0; i < N - 1; i++) {
    ans.at(A.at(i) - 1) = ans.at(A.at(i) - 1) + 1;
  }
  for (int i = 0; i < N; i++) {
    cout << ans.at(i) << endl;
  }
  return 0;
}
Problem p02707 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;

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

  vector<long long> ANS(N, 0);
  for (int i = 0; i < N; i++)
    ANS[A[i] - 1]++;
  for (int i = 0; i < N; i++)
    cout << ANS[i] << endl;
}


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

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

  vector<long long> ANS(N, 0);
  for (int i = 1; i < N; 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 <algorithm>
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 1; i < n; i++)
    cin >> A[i];

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

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


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

int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 1; i < n; i++)
    cin >> A[i];

  vector<int> ans(n);
  for (int i = 1; i < n; i++) {
    int supervisor = A[i] - 1;
    ans[supervisor] += 1;
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#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);
  vector<int> b(n, 0);
  rep(i, n - 1) cin >> a[i];
  sort(a.begin(), a.end());
  rep(i, n - 1) {
    for (int j = i; j < n - 1; ++j) {
      if (i + 1 == a[j]) {
        ++b[i];
      } else if (i + 1 < a[j]) {
        break;
        i = j;
      }
    }
  }
  rep(i, n) cout << b.at(i) << "\n";
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#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);
  vector<int> b(n, 0);
  rep(i, n - 1) cin >> a[i];
  sort(a.begin(), a.end());
  int i = 1, j = 0;
  while (i < n) {
    if (i == a[j]) {
      ++b[i - 1];
      ++j;
      continue;
    } else if (i != a[j]) {
      ++i;
      continue;
    }
  }
  rep(i, n) cout << b.at(i) << "\n";
  return 0;
}
Problem p02707 (C++)

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

#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define ms memset
// #define MAXN 10005
// #define MAXM 100005
#define pi 3.14159265359

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef long long ll;
typedef priority_queue<int> pqi;
typedef priority_queue<pii, vpii, greater<pii>> dij;

int N, n;
int A[100010];

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

  cin >> N;

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

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

  return 0;
}

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

#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define ms memset
// #define MAXN 10005
// #define MAXM 100005
#define pi 3.14159265359

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef long long ll;
typedef priority_queue<int> pqi;
typedef priority_queue<pii, vpii, greater<pii>> dij;

int N, n;
int A[200010];

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

  cin >> N;

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

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

  return 0;
}