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

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 2; i <= (int)(n); i++)

long long A[211111];
long long dp[211111];
int main() {
  long long N;
  cin >> N;

  rep(i, N) {
    cin >> A[i];

    dp[A[i]]++;
  }

  for (int i = 1; i <= N; ++i)
    cout << dp[i] << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 2; i <= (int)(n); i++)

long long A[21111];
long long dp[21111];
int main() {
  long long N;
  cin >> N;

  rep(i, N) {
    cin >> A[i];

    dp[A[i]]++;
  }

  for (int i = 1; i <= N; ++i)
    cout << dp[i] << endl;

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

#include <bits/stdc++.h>

#define NREP() for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(x)                                                                 \\
  ll t;                                                                        \\
  cin >> t;                                                                    \\
  x.push_back(t);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<string> vvs;

const static ll MOD = 1e9 + 7;

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

  ll sum[200100];

  REP(i, 200100) { sum[i] = 0; }

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

  for (ll i = 1; i <= n; i++) {
    MSG(sum[i])
  }
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

#define NREP() for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(x)                                                                 \\
  ll t;                                                                        \\
  cin >> t;                                                                    \\
  x.push_back(t);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<string> vvs;

const static ll MOD = 1e9 + 7;

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

  ll sum[20010];

  REP(i, 20010) { sum[i] = 0; }

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

  for (ll i = 1; i <= n; i++) {
    MSG(sum[i])
  }
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>

using namespace std;

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

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

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

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

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <vector>

using namespace std;

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

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

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

  for (int i = 0; i < N; 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;
  multiset<int> boss;
  for (int i = 2; i <= n; i++) {
    int input;
    cin >> input;
    boss.insert(input);
  }
  vector<int> sub(n + 1);
  for (int i = 1; i <= n; i++) {
    sub[i] = boss.count(i);
    boss.erase(i);
  }
  for (int i = 1; i <= n; i++)
    cout << sub[i] << "\\n";
}


Error: TLE

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  vector<int> boss(n + 1);
  for (int i = 2; i <= n; i++)
    cin >> boss[i];
  vector<int> sub(n + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = 2; j <= n; j++) {
      if (boss[j] == i)
        sub[i]++;
    }
  }
  for (int i = 1; i <= n; i++)
    cout << sub[i] << "\\n";
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll n, a[1000010], b[1000010];
  cin >> n;
  for (int i = 2; i <= n; i++) {
    cin >> a[i];
    ++b[a[i]];
  }
  for (int i = 1; i <= n; i++)
    cout << b[i] << endl;
  return 0;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll n, a[200010], b[200010];
  scanf("%lld", &n);
  for (int i = 2; i <= n; i++) {
    scanf("%lld", &a + i);
    ++b[a[i]];
  }
  for (int i = 1; i <= n; i++)
    printf("%lld\\n", b[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> A(N + 1);
  vector<int> result(N + 1, 0);

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

  for (int i = 2; i < N + 1; i++)
    result.at(A.at(i))++;

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


Error: TLE

Fixed submission:

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N - 1);
  vector<int> result(N, 0);

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

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

#include <iostream>
#include <vector>

int main() {
  int n_persons;
  std::cin >> n_persons;

  std::vector<std::size_t> n_of_bukas(n_persons);
  for (std::size_t i = 0; i < n_persons - 1; ++i) {
    int josi;
    std::cin >> josi;
    ++n_of_bukas[--josi];
  }
  for (auto &&n_buka : n_of_bukas) {
    std::cout << n_buka << std::endl;
  }
}


Error: -11

Fixed submission:

#include <iostream>
#include <vector>

int main() {
  int n_persons;
  std::cin >> n_persons;

  std::vector<std::size_t> n_of_bukas;
  for (std::size_t i = 0; i < n_persons; ++i) {
    int josi;
    std::cin >> josi;
    ++n_of_bukas[josi];
  }
  for (auto &&n_buka : n_of_bukas) {
    std::cout << n_buka << std::endl;
  }
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

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

Error: 0

Fixed submission:

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

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

int cnt[200005];

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

Error: 0

Fixed submission:

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

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

int main() {
  long long N, temp;
  vector<long long> A(100000 * 3, 0); // 配列の宣言

  cin >> N;

  rep(i, N - 1) {
    cin >> temp;
    A[temp - 1]++;
  }

  rep(i, N) { cout << A[i] << " "; }
}

Error: WA

Fixed submission:

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

int main() {
  long long N, temp;
  vector<int> A(10000 * 3, 0); // 配列の宣言

  cin >> N;

  rep(i, N - 1) {
    cin >> temp;
    A[temp - 1]++;
  }

  rep(i, N) { cout << A[i]; }
}
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 + 1);
  vector<int> ans(n + 1);

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

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

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

  return 0;
}


Error: 0

Fixed submission:

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

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

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

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

Error: 0

Fixed submission:

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

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

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

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

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

  return 0;
}

Error: 0

Fixed submission:

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

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

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  // 整数の入力
  int N;
  cin >> N;
  // スペース区切りの整数の入力
  int sum[N] = {0};
  int a;

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

    sum[a - 1] += 1;
  }

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

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  // 整数の入力
  int N;
  cin >> N;
  // スペース区切りの整数の入力
  int A[N - 1];

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

  for (int i = 1; i < N + 1; i++) {
    cout << count(A, A + N - 1, i) << endl;
  }

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

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
// #define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;

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


Error: -6
double free or corruption (out)


Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
// #define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;

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

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

int gcd(int p, int q) {
  if (p % q == 0) {
    return q;
  }
  return gcd(q, p % q);
}

int main() {
  int n;
  cin >> n;
  vector<int> A(n, 0);
  for (int i = 1; i < n; i++) {
    cin >> A[i];
  }
  vector<int> boss(n, 0);
  rep(i, n) {
    if (A[i] != 0) {
      boss[A[i] - 1]++;
    }
  }

  rep(i, n) { cout << boss[i] << endl; }
}


Error: -6
double free or corruption (out)


Fixed submission:

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

int gcd(int p, int q) {
  if (p % q == 0) {
    return q;
  }
  return gcd(q, p % q);
}

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

  rep(i, n) { cout << boss[i] << endl; }
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

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

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

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

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

  return 0;
}

Error: 0

Fixed submission:

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

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

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

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

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

#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

  vector<int> list(N, 0);

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

  rep(i, list.size()) { cout << list.at(i) << endl; }
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int return_num(vector<int> &list, int x) {
  int num = 0;
  for (int i = x + 1; i < (int)(list.size()); i++) {
    if (list.at(i) == x) {
      num++;
    }
  }
  return num;
}

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

  vector<int> list(N);

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

  rep(i, list.size()) { cout << return_num(list, i) << endl; }
}
Problem p02707 (C++) — buggy submission, verdict: 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[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);
}


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

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

#define loop(i, a, b) for (int i = a; i < b; i++)
int main() {
  int n;
  cin >> n;
  vector<int> ans(n);
  loop(i, 1, n) {
    int a;
    cin >> a;
    ans[a - 1]++;
  }
  for (int c : ans)
    cout << c << "\\n";
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define loop(i, a, b) for (int i = a; i < b; i++)

typedef long long ll;
typedef string str;

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

  int n;
  cin >> n;

  vector<int> arr(n);
  loop(i, 0, n - 1) { cin >> arr[i]; }

  loop(i, 1, n + 1) { cout << count(arr.begin(), arr.end(), i) << "\\n"; }
  return 0;
}
Problem p02707 (C++) — buggy submission, verdict: 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[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; }
}

Error: 0

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

#include <bits/stdc++.h>
#include <iomanip>
#define ll long long

using namespace std;

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

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <iomanip>
#define ll long long

using namespace std;

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

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

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

  return 0;
}

Error: -6
double free or corruption (out)


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

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

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

  return 0;
}