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

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

int main() {
  int N = 0;
  vector<int> A;
  vector<int> answer;

  cin >> N;

  rep(i, N) {
    A.push_back(0);
    answer.push_back(0);
    if (i >= 1) {
      cin >> A[i];
    }
  }

  rep(i, N) {
    if (i >= 1) {
      answer[A[i] - 1]++;
    }
  }

  rep(i, N) { cout << answer[i] << endl; }
}

Error: -6
double free or corruption (out)


Fixed submission:

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

int main() {
  int N = 0;
  vector<int> A;
  vector<int> answer;

  cin >> N;

  rep(i, N) {
    A.push_back(0);
    answer.push_back(0);
    if (i >= 1) {
      cin >> A[i];
    }
  }

  rep(i, N) { answer[A[i] - 1]++; }

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

Error: 0

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

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

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

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


Error: TLE

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>;
const double PI = acos(-1);

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  a[0] = 0;
  for (int i = 1; i < n; ++i) {
    cin >> a[i];
  }
  rep(i, n) { cout << count(a.begin(), a.end(), i + 1) << endl; }

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

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

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

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

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

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

  j = 0;
  sum = 0;

  for (i = 0; i < N; i++) {

    if (sum != N - 1) {
      n[i] = 1;
      sum += 1;

      while ((A[j] == A[j + 1]) && (j < N - 1)) {
        n[i] += 1;
        sum += 1;
        j += 1;
      }
    } else {
      while (i < N) {
        n[i] = 0;
        cout << endl;
      }

      return 0;
    }
    cout << 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> M;
  int num;
  for (int i = 0; i < n - 1; i++) {
    cin >> num;
    M[num]++;
  }

  for (int i = 1; i <= n; i++)
    cout << M[i] << "\\n";

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> num(n);
  for (int i = 0; i < n - 1; i++)
    cin >> num[i];
  int cont;
  for (int i = 1; i <= n; i++) {
    cont = count(num.begin(), num.end(), i);
    cout << cont << "\\n";
  }
  return 0;
}
Problem p02707 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;
int main() {
  long long n;
  cin >> n;

  long long a[200010];
  long long ans[200010] = {0};

  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: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;
int main() {
  long long 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++) {
    cout << count(a.begin(), a.end(), i) << endl;
  }
  return 0;
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

int main() {
  int a, n;
  int sl[200010];

  for (int i = 0; i <= 200005; i++)
    sl[i] = 0;

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

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

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int a, n;
  int sl[100010];

  for (int i = 0; i <= 100005; i++)
    sl[i] = 0;

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

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

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

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

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

Error: TLE

Fixed submission:

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

int main() {
  int n, i, cnt, num, cnt1;
  cnt1 = 0;
  cin >> n;
  vector<int> a(n);
  for (i = 0; i < n - 1; i++) {
    cin >> a[i];
  }

  for (num = 1; num <= n; num++) {
    cnt = 0;
    if (cnt1 < n - 1) {
      for (i = 0; i < n; i++) {
        if (a[i] == num) {
          cnt++;
          cnt1++;
        }
      }
    }
    cout << cnt << endl;
  }
}
Problem p02707 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

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

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int boss[n];
  int nums[n];
  for (int i = 0; i < n; i++)
    nums[i] = 0;
  for (int i = 0; i < n - 1; i++)
    scanf("%d", &boss[i]);

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

  for (int i = 0; i < n; i++)
    cout << nums[i] << "\\n";
}
Problem p02707 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, i, j;
  cin >> n;
  vector<int> a(n);
  vector<int> ans(n + 1, 0);
  for (i = 1; i < n; i++) {
    cin >> a.at(i);
    ans.at(a.at(i))++;
  }
  for (i = 1; i <= n; i++) {
    cout << ans.at(i) << endl;
  }
}


Error: TLE

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, i, j;
  cin >> n;
  vector<int> a(n);
  vector<int> ans(n);
  for (i = 1; i < n; i++) {
    cin >> a.at(i);
  }
  for (i = 0; i < n; i++) {
    ans.at(i) = 0;
    for (j = i + 1; j < n; j++) {
      if (a.at(j) == i + 1) {
        ans.at(i)++;
      }
    }
  }
  for (i = 0; i < n; i++) {
    cout << ans.at(i) << endl;
  }
}
Problem p02707 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

const int N = (int)2e5 + 7;
int n, f[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    int x;
    cin >> x;
    f[x]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << f[i] << "\\n";
  }
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> ninzuu(n); // xは社員番号、yは部下の人数
  vector<int> data(n - 1);          // 入力を受け取る
  for (int i = 0; i < n - 1; i++) {
    cin >> data.at(i);
  }
  for (int i = 0; i < n; i++) {
    ninzuu.at(i).first = i + 1;
    ninzuu.at(i).second = 0;
  }
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < n; j++) {
      if (data.at(i) == j) {
        ninzuu.at(j - 1).second++;
        break;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ninzuu.at(i).second << endl;
  }
}
Problem p02707 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

Error: TLE

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

#include <bits/stdc++.h>
#include <string.h>
#define ll long long
#define Start ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define fr first
#define sc second
#define M_PI 3.14159265358979323846
using namespace std;
int n, x, Cnt[300300];

int main() {

  scanf("%d", &n);
  for (int i = 2; i <= n; i++)
    scanf("%d", &x), Cnt[x]++;
  for (int i = 1; i <= n; i++) {
    printf("%d\\n", Cnt[i]);
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <string.h>
#define ll long long
#define Start ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define fr first
#define sc second
#define M_PI 3.14159265358979323846
using namespace std;
int Cnt[200200];
char c;
string s;
int main() {
  Start;

  int n;
  cin >> n;

  while ((c = getchar()) != '\\n')
    Cnt[c - '0']++;
  for (int i = 1; i <= n; i++)
    cout << Cnt[i] << "\\n";
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

// Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
using namespace std;
int ar[1000001];
int main() {
  // freopen("a.txt","r",stdin);
  for (int i = 0; i < 1000001; i++)
    ar[i] = 0;
  int n, x;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> x;
    ar[x]++;
  }

  for (int i = 1; i <= n; i++) {

    cout << ar[i] << endl;
  }
}


Error: 0

Fixed submission:

// Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
using namespace std;
int ar[100001];
int main() {
  // freopen("a.txt","r",stdin);
  for (int i = 0; i < 100001; i++)
    ar[i] = 0;
  int n, x;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> x;
    ar[x]++;
  }

  for (int i = 1; i <= n; i++) {

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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << (x) << '\\n'

int main() {
  int n;
  cin >> n;
  vector<ll> a(200010, 0);
  ll t;
  REP(i, n - 1) {
    cin >> t;
    a[t]++;
  }
  FOR(i, 1, n + 1) { COUT(a[i]); }
  return 0;
}

Error: 0

Fixed submission:

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

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << (x) << '\\n'

int main() {
  int n;
  cin >> n;
  int a[100010];
  int t;
  REP(i, n - 1) {
    cin >> t;
    a[t]++;
  }
  for (int i = 1; i < n + 1; i++) {
    COUT(a[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;
  int arr[n - 1], ans[n + 1] = {0};
  for (int i = 0; i < n - 1; i++) {
    cin >> arr[i];
    ans[arr[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

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

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define forr(i, a, b) for (ll i = (a); i <= (b); i++)
#define ford(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(x) (x).begin(), (x).end() // sortなどの引数を省略したい
#define size(x) ((ll)(x).size())      // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 // 10^12
#define MOD 10000007      // 10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 // 10^5:最大のrange(素数列挙などで使用)

int main(void) {
  long int N, i, j;
  cin >> N;
  long int n[2000000];
  long int m[2000000];
  for (i = 0; i < N - 1; ++i) {
    cin >> n[i];
  }
  for (i = 0; i < N - 1; ++i) {

    m[n[i] - 1]++;
  }
  for (j = 0; j < N; ++j) {

    cout << m[j] << "\\n";
  }

  return 0;
}

Error: TLE

Fixed submission:

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define forr(i, a, b) for (ll i = (a); i <= (b); i++)
#define ford(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(x) (x).begin(), (x).end() // sortなどの引数を省略したい
#define size(x) ((ll)(x).size())      // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 // 10^12
#define MOD 10000007      // 10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 // 10^5:最大のrange(素数列挙などで使用)

int main(void) {
  long int N, ans = 0, i, j;
  cin >> N;
  int n[200000];
  for (i = 0; i < N - 1; ++i) {
    cin >> n[i];
  }
  for (j = 1; j < N + 1; ++j) {
    for (i = 0; i < N - 1; ++i) {
      if (j == n[i]) {
        ans = ans + 1;
      }
    }
    cout << ans << "\\n";
    ans = 0;
  }
  return 0;
}
Problem p02707 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

#define line "\\n"
#define loop(i, a, n) for (ll i = a; i < n; i++)
#define ll long long int
#define lb long double
#define ull unsigned long long int
#define pb push_back
#define vi vector<int>
#define vs vector<string>
#define vb vector<bool>

#define pii pair<int, int>
#define pll pair<ll, ll>
#define pld pair<ld, ld>
#define pDD pair<D, D>

#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
using namespace std;
void solve() {
  ll n;
  cin >> n;
  vi b(n + 1);
  vi v(n + 1);
  loop(i, 2, n + 1) {

    cin >> v[i];
    b[v[i]]++;
  }
  v[1] = 1;
  cout << count(v.begin(), v.end(), v[1]) - 1 << line;
  loop(i, 2, n + 1) { cout << b[i] << line; }
}

int main() {
  fast
  // int t;
  // cin>>t;
  // while(t--)
  {
    solve();
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define line "\\n"
#define loop(i, a, n) for (ll i = a; i < n; i++)
#define ll long long int
#define lb long double
#define ull unsigned long long int
#define pb push_back
#define vi vector<int>
#define vs vector<string>
#define vb vector<bool>

#define pii pair<int, int>
#define pll pair<ll, ll>
#define pld pair<ld, ld>
#define pDD pair<D, D>

#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
using namespace std;
void solve() {
  ll n;
  cin >> n;
  vi v(n + 1);
  loop(i, 2, n + 1) { cin >> v[i]; }
  v[1] = 1;
  cout << count(v.begin(), v.end(), v[1]) - 1 << line;
  loop(i, 2, n + 1) { cout << count(v.begin(), v.end(), i) << line; }
}

int main() {
  fast
  // int t;
  // cin>>t;
  // while(t--)
  {
    solve();
  }
}
Problem p02707 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

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

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

Error: TLE

Fixed submission:

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

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

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

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

int a[200005];
int b[200005];

int main() {
  int i, j, n, v, ck = 0, sum = 0;

  cin >> n;

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

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

  return 0;
}


Error: TLE

Fixed submission:

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

int a[200005];

int main() {
  int i, j, n, ck = 0, sum = 0;

  cin >> n;

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

  for (i = 1; i <= n; i++) {
    ck = 0;
    for (j = 0; j < n - 1; j++) {
      if (a[j] == i) {
        ck++;
        sum++;

        if (sum == n - 1)
          break;
      }
    }
    cout << ck << endl;
  }

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

#include <bits/stdc++.h>

using namespace std;
using vi = vector<int>;
using vvi = vector<vector<int>>;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i > 0; i--)
#define all(v) v.begin(), v.end()
#define debug(x) cout << x << endl
#define vout(v) rep(i, v.size()) cout << v[i] << " ";
#define INF INT_MAX

int N;

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


Error: -6
double free or corruption (out)


Fixed submission:

#include <bits/stdc++.h>

using namespace std;
using vi = vector<int>;
using vvi = vector<vector<int>>;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i > 0; i--)
#define all(v) v.begin(), v.end()
#define debug(x) cout << x << endl
#define vout(v) rep(i, v.size()) cout << v[i] << " ";
#define INF INT_MAX

int N;

int main() {
  cin >> N;
  vi a(N, 0);
  rep(i, N - 1) { cin >> a[i + 1]; }
  vi ans(N, 0);
  rep(i, N) { ans[a[i] - 1]++; }
  rep(i, N) { 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 = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, n) for (int i = 2; i <= (int)(n); i++)
typedef int64_t Int;

int main() {
  Int N;
  cin >> N;
  vector<Int> A(N + 1);
  rep2(i, N) cin >> A[i];

  vector<vector<int>> PS(N + 1);

  rep2(i, N) { PS[A[i]].push_back(i); }

  rep1(i, N) { cout << PS[i].size() << endl; }
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, n) for (int i = 2; i <= (int)(n); i++)
typedef int64_t Int;

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

  rep2(i, N) cin >> A[i];

  vector<vector<int>> PS(20010);

  rep2(i, N) { PS[A[i]].push_back(i); }

  rep1(i, N) { cout << PS[i].size() << endl; }
}