alexjercan/bugnet huggingface dataset:
Problem p02707 (C++) — buggy submission, verdict: 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[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;
}

Error: 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[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;
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

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


Error: 0

Fixed submission:

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

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

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N - 1); // 入力値
  vector<int> buka(N);    // 直属の部下数

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

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

Error: TLE

Fixed submission:

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

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

  for (int i = 0; i < N; i++) {
    int k = 0;
    for (int j = 0; j < N - 1; j++) {
      if (vec.at(j) == i + 1) {
        k++;
      }
    }
    cout << k << endl;
  }
}
Problem p02707 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  int ans[n];
  for (int i = 1; i < n; i++) {
    cin >> arr[i];
    ans[i] = 0;
  }
  for (int i = 1; i < n; i++)
    ans[arr[i]]++;
  for (int i = 1; i < n; i++)
    cout << ans[i] << endl;
  cout << 0;
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int N, x = 1, sum;
  cin >> N;
  int arr[N];
  for (int i = 1; i < N; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < N; i++) {
    sum = 0;
    for (int j = i + 1; j < N; j++) {
      if (arr[j] == i + 1)
        sum += 1;
    }
    arr[i] = sum;
  }
  for (int i = 0; i < N; i++) {
    cout << arr[i] << endl;
  }

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

// Joy Shree Kriskna
#include <bits/stdc++.h>
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL)
#define rep(i, n) for (i = 0; i < n; i++)
#define rep1(i, n) for (i = n - 1; i >= 0; i--)
#define rep2(j, t) for (j = 1; j <= t; j++)
#define rep3(i, a, b) for (i = a; i <= b; i++)
#define PI acos(-1)
#define remove(s) s.erase(unique(s.begin(), s.end()), s.end());
#define e return 0
// #define lcm(a,b) ((a*b)/__gcd(a,b))
#define endl "\\n"
#define al(v) v.begin(), v.end()
#define ll long long
using namespace std;
void solve() {
  ll i, n, j, k = 0, c;
  cin >> n;
  vector<ll> a(n - 1);
  ll b[n + 1];
  memset(b, 0, sizeof b);
  rep(i, n - 1) cin >> a[i];
  sort(al(a));
  for (i = 1; i <= n; i++) {
    c = 0;
    for (j = i - 1 + k; j < n - 1; j++) {
      if (a[j] == i)
        c++;
      else if (a[j] > i)
        break;
    }
    k += c - 1;
    cout << c << endl;
  }
  // rep(i,n)cout<<b[i]<<endl;
}

int main() {
  fast;
  int i, n, t;
  solve();
}
// arupsaha52
// 1704052_Arup


Error: TLE

Fixed submission:

// Joy Shree Kriskna
#include <bits/stdc++.h>
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL)
#define rep(i, n) for (i = 0; i < n; i++)
#define rep1(i, n) for (i = n - 1; i >= 0; i--)
#define rep2(j, t) for (j = 1; j <= t; j++)
#define rep3(i, a, b) for (i = a; i <= b; i++)
#define PI acos(-1)
#define remove(s) s.erase(unique(s.begin(), s.end()), s.end());
#define e return 0
// #define lcm(a,b) ((a*b)/__gcd(a,b))
#define endl "\\n"
#define al(v) v.begin(), v.end()
#define ll long long
using namespace std;
void solve() {
  ll i, n, j, k, c;
  cin >> n;
  vector<ll> a(n - 1);
  ll b[n + 1];
  memset(b, 0, sizeof b);
  rep(i, n - 1) cin >> a[i];
  sort(al(a));
  for (i = 1; i <= n; i++) {
    c = 0;
    for (j = i - 1; j < n - 1; j++) {
      if (a[j] == i)
        c++;
      else if (a[j] > i)
        break;
    }
    cout << c << endl;
  }
  // rep(i,n)cout<<b[i]<<endl;
}

int main() {
  fast;
  int i, n, t;
  solve();
}
// arupsaha52
// 1704052_Arup
Problem p02707 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int N, j;
  vector<int> A(200001, 0);
  cin >> N;

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

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

Error: TLE

Fixed submission:

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

int main() {
  int N;
  cin >> N;
  int syain[N];
  // 代入
  syain[0] = 0;
  rep(i, N) cin >> syain[i + 1];

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

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

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

  vector<long long> A(N), B(N);
  for (int i = 1; i < N; i++) {
    cin >> A.at(i);
  }

  sort(A.begin(), A.end());
  int k = 0;

  for (int i = 0; i < N; i++) {
    for (int j = k; j < N; j++) {
      if (A.at(j) == i + 1)
        B.at(i)++;
      else if (A.at(j) > i + 1)
        break;
    }
    k += B.at(i);
  }

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

Error: TLE

Fixed submission:

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

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

  vector<long long> A(N), B(N);
  for (int i = 1; i < N; i++) {
    cin >> A.at(i);
  }

  sort(A.begin(), A.end());

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (A.at(j) == i + 1)
        B.at(i)++;
      else if (A.at(j) > i + 1)
        break;
    }
  }

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

#include <stdio.h>

#define MAX_N (200000)

int main() {
  int N;
  int buka_kazu[MAX_N + 2];
  int joushi_bango;

  scanf("%d", &N);

  for (auto i = 0; i < N + 2; i++) {
    buka_kazu[i] = 0;
    // printf("%d %d\\n", i, buka_kazu[i]);
  }

  for (auto i = 2; i < N + 1; i++) {
    scanf("%d", &joushi_bango);
    // printf("%d %d\\n", joushi_bango, buka_kazu[joushi_bango]);
    buka_kazu[joushi_bango]++;
    // printf("%d %d\\n", joushi_bango, buka_kazu[joushi_bango]);
  }

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

  return (0);
}

Error: 0

Fixed submission:

#include <stdio.h>

#define MAX_N (2 * 10 ^ 5)

int main() {
  int N;
  int buka_kazu[MAX_N + 2];
  int joushi_bango;

  for (auto i = 0; i < MAX_N + 2; i++) {
    buka_kazu[i] = 0;
  }

  scanf("%d", &N);
  for (auto i = 2; i < N + 1; i++) {
    scanf("%d", &joushi_bango);
    buka_kazu[joushi_bango]++;
  }

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

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

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

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

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

Error: TLE

Fixed submission:

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

int main() {
  int n, ans;
  cin >> n;
  vector<int> vec(n - 1);
  for (int i = 0; i < n - 1; i++) {
    cin >> vec.at(i);
  }
  for (int i = 1; i <= n; i++) {
    ans = 0;
    for (int j = 0; j < n - 1; j++) {
      if (vec.at(j) == i) {
        ans++;
      }
    }
    cout << ans << endl;
  }
}
Problem p02707 (C++) — buggy submission, verdict: 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;
    ans[a - 1] = ans[a - 1] + 1;
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
}


Error: TLE

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

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

int main(void) {
  int N;
  cin >> N;
  vector<int> v(N);
  map<int, int> b;
  for (int i = 1; i < N; i++) {
    cin >> v[i];
  }
  for (int i = 1; i < N; i++) {
    b[v[i]]++;
  }
  for (int i = 1; i <= N; i++) {
    cout << b[i] << endl;
  }
  return 0;
}


Error: 0

Fixed submission:

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

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

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

int main() {
  int N;
  int a;
  cin >> N;
  vector<int> A;
  rep(i, N - 1) {
    cin >> a;
    A.push_back(a);
  }
  vector<int> ans(N);
  for (int ai : A) {
    ans[ai - 1] += 1;
  }

  for (int an : ans) {
    cout << an << endl;
  }
  return 0;
}

Error: -6
double free or corruption (out)


Fixed submission:

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

int main() {
  int N;
  int a;
  cin >> N;
  vector<int> A(N);
  rep(i, N - 1) {
    cin >> a;
    A.push_back(a);
  }
  vector<int> ans(N);
  for (int ai : A) {
    ans[ai - 1] += 1;
  }

  rep(i, ans.size()) { cout << ans[i] << endl; }
  return 0;
}
Problem p02707 (C++) — buggy submission, verdict: Time Limit Exceeded

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

/* */

int main() {

  // 入力スタンダード（複数指定）
  int n;
  cin >> n;

  int joushi;
  int a[n + 1] = {0};
  for (int i = 2; i < n + 1; i++) {
    cin >> joushi;
    a[joushi]++;
  }
  // **************************************

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

  return 0;
}

Error: TLE

Fixed submission:

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

/* */

int main() {

  // 入力スタンダード（複数指定）
  int n;
  cin >> n;
  // **************************************
  int a[n + 1];
  for (int i = 2; i < n + 1; i++)
    cin >> a[i];
  // **************************************

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

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

#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>

using namespace std;
#define range(a) a.begin(), a.end()
#define rep(i, c) for (int i = 0; i < (int)c; i++)
typedef long long ll;

template <typename T> ostream &operator<<(ostream &out, vector<T> &v) {
  for (int i = 0; i < (int)v.size(); i++) {
    out << v[i] << ' ';
  }
  return out;
}

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

  // float n; cin >> n;
  //
  // cout << n * 2 * 3.141592653589 << endl;

  // int n, m; cin >> n >> m;
  // vector<int> a(m);
  // int sum = 0;
  // rep(i, m){
  //   cin >> a[i];
  //   sum += a[i];
  // }
  // if(sum == n) cout << 0 << endl;
  // else if (sum < n) cout << n - sum << endl;
  // else cout << -1 << endl;

  int n;
  cin >> n;
  vector<int> a(n + 10, 0);
  vector<int> ans(n + 10, 0);
  a.push_back(0);
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    ans[a[i]]++;
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i + 1] << endl;
  }

  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>

using namespace std;
#define range(a) a.begin(), a.end()
#define rep(i, c) for (int i = 0; i < (int)c; i++)
typedef long long ll;

template <typename T> ostream &operator<<(ostream &out, vector<T> &v) {
  for (int i = 0; i < (int)v.size(); i++) {
    out << v[i] << ' ';
  }
  return out;
}

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

  // float n; cin >> n;
  //
  // cout << n * 2 * 3.141592653589 << endl;

  // int n, m; cin >> n >> m;
  // vector<int> a(m);
  // int sum = 0;
  // rep(i, m){
  //   cin >> a[i];
  //   sum += a[i];
  // }
  // if(sum == n) cout << 0 << endl;
  // else if (sum < n) cout << n - sum << endl;
  // else cout << -1 << endl;

  int n;
  cin >> n;
  vector<int> a(n - 1, 0);
  vector<int> ans(n, 0);

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

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(n) for (int i = 0; i < (n); i++)
#define lp(x, s, e) for (int x = (s); x < (e); x++)
#define lpe(x, s, e) for (int x = (s); x <= (e); x++)
#define endl '\\n'
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int a[n - 1];
  int freq[200009] = {0};
  lp(i, 0, n - 1) {
    cin >> a[i];
    freq[a[i]]++;
  }
  lpe(i, 1, n) cout << freq[i] << endl;
}


Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(n) for (int i = 0; i < (n); i++)
#define lp(x, s, e) for (int x = (s); x < (e); x++)
#define lpe(x, s, e) for (int x = (s); x <= (e); x++)
#define endl '\\n'
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll n;
  cin >> n;
  int a[n];
  int freq[200009] = {0};
  lp(i, 0, n) {
    cin >> a[i];
    freq[a[i]]++;
  }
  loop(n) cout << freq[i] << endl;
}
Problem p02707 (C++) — buggy submission, verdict: Time Limit Exceeded

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


Error: TLE

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  int cnt[n];
  for (int i = 0; i < n; i++) {
    cnt[i] = 0;
  }
  for (int i = 1; i < n; i++) {
    int temp;
    cin >> temp;
    for (int j = 1; j <= n; j++) {
      if (temp == j) {
        cnt[j - 1]++;
        break;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << cnt[i] << "\\n";
  }
  return 0;
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  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;
  }
}

Error: -6
double free or corruption (out)


Fixed submission:

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

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

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

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

#include <cmath>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
using ll = long long int;
typedef pair<int, int> P;

int main(void) {
  int N;
  cin >> N;
  int mp[200009] = {0};
  int k;
  for (int i = 1; i < N; i++) {
    scanf("%d", &k);
    mp[k]++;
  }

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

Error: WA

Fixed submission:

#include <cmath>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
using ll = long long int;
typedef pair<int, int> P;

int main(void) {
  int N;
  cin >> N;
  int mp[20] = {0};
  int k;
  for (int i = 1; i < N; i++) {
    scanf("%d", &k);
    mp[k]++;
  }
  for (int i = 1; i < N; i++) {
    cout << mp[i] << endl;
  }
}
Problem p02707 (C++) — buggy submission, verdict: 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[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;
}

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

#include <bits/stdc++.h>

using namespace std;

int main() {
  int N;
  cin >> N;
  map<int, int> map;
  for (int i = 0; i < N; i++) { // 0desyokika
    map[i] = 0;
  }
  for (int i = 1; i < N; i++) { // kazuwokazoeru
    int A;
    cin >> A;
    map[A - 1] += 1;
  }
  for (int i = 0; i < N; i++) {
    cout << map[i] << endl;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> data(N);
  data.at(0) = -1;
  for (int i = 1; i < N; i++) {
    cin >> data.at(i);
  }
  for (int n = 1; n < N + 1; n++) { // 社員番号
    int sum = 0;
    for (int i = n; i < N; i++) {
      if (data.at(i) == n) {
        sum++;
      }
    }
    cout << sum << endl;
  }
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

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

Error: -11

Fixed submission:

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, i, j;
  cin >> n;
  vector<int> a(n);
  for (i = 0; i < n - 1; ++i) {
    cin >> j;
    ++a[j - 1];
  }
  for (auto it : a)
    cout << it << "\\n";
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, i;
  cin >> n;
  vector<int> a(n);
  for (i = 0; i < n - 1; ++i)
    cin >> a[i];
  for (i = 1; i <= n; ++i)
    cout << count(a.begin(), a.end(), i) << "\\n";
  return 0;
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N;
  cin >> N;
  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;
}

Error: -6
double free or corruption (out)


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

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