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

/*! at-abc163c.cc
 *  2020-04-30
 *  GCC+17
 *  Type (opt):
 *  Notes (opt):
 */
#include <cstdio>
using llu = long long unsigned;
using ll = long long;

int main(void) {
  int co[1000000];

  llu n, i, a;
  scanf("%llu", &n);
  for (i = 1; i < n; i++) {
    //        printf("%d", i);
    scanf("%llu", &a);
    co[a]++;
  }
  for (i = 1; i < n + 1; i++)
    printf("%i\\n", co[i]);

  return 0;
}


Error: 0

Fixed submission:

/*! at-abc163c.cc
 *  2020-04-30
 *  GCC+17
 *  Type (opt):
 *  Notes (opt):
 */
#include <cstdio>
using llu = long long unsigned;
using ll = long long;

int main(void) {
  int co[100001];

  llu n, i, a;
  scanf("%llu", &n);
  for (i = 1; i < n; i++) {
    //        printf("%d", i);
    scanf("%llu", &a);
    co[a]++;
  }
  for (i = 1; i < n + 1; i++)
    printf("%i\\n", co[i]);

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

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

int main() {
  long long N;
  cin >> N;
  vector<int> A(N);
  A.at(0) = 0;
  for (int i = 1; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  vector<long long> B(1000000);
  for (int i = 1; i < N; i++) {
    B.at(A.at(i) - 1) += 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() {
  long long N;
  cin >> N;
  vector<int> A(N);
  A.at(0) = 0;
  for (int i = 1; i < N; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < N; i++) {
    long long sum = 0;
    for (int j = 1; j < N; j++) {
      if (A.at(j) == i + 1)
        sum++;
    }
    cout << sum << endl;
  }
}
Problem p02707 (C++) — buggy submission, verdict: 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);
  REP(i, n - 1) {
    int a;
    cin >> a;
    data[a - 1]++;
  }
  REP(i, n) { cout << data.at(i) << endl; }
}


Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 4) >= this->size() (which is 4)


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 - 1, 0);
  REP(i, n - 1) {
    int a;
    cin >> a;
    data[a - 1]++;
  }
  REP(i, n) { cout << data.at(i) << endl; }
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

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

Error: 0

Fixed submission:

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

Error: TLE

Fixed submission:

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N - 1);
  for (int i = 0; i < N - 1; i++) {
    cin >> vec.at(i);
  }
  for (int i = 1; i < N; i++) {
    int X = 0;
    for (int j = 0; j < N - 1; j++) {
      if (i == vec.at(j)) {
        X++;
      }
    }
    cout << X << endl;
  }
  cout << "0" << endl;
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

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

using namespace std;

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

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

Error: 0

Fixed submission:

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

using namespace std;

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

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

#include <bits/stdc++.h>
using namespace std;
const int maxn = 2 * 1e5 + 5;
int a, n, boss[maxn] = {0};
int main() {
  cin >> n;
  for (int i = 2; i <= n; i++) {
    cin >> a;
    boss[a]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << boss[i] << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5;
int a, n, boss[maxn] = {0};
int main() {
  cin >> n;
  for (int i = 2; i <= n; i++) {
    cin >> a;
    boss[a]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << boss[i] << endl;
  }
  return 0;
}
Problem p02707 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define fix(n) cout << fixed << setprecision((int)n)

void absll(ll &x) {
  if (x >= 0)
    return;
  else
    x = -x;
  return;
}

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

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

const ll INF = 1LL << 60;

int N;

// DPテーブル
vector<ll> dp(100010);

int main() {
  cin >> N;
  vi a(N - 1), b(N, 0);
  rep(i, N - 1) cin >> a.at(i);
  rep(i, N - 1) b.at(a.at(i) - 1)++;
  rep(i, N) cout << b.at(i) << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define fix(n) cout << fixed << setprecision((int)n)

void absll(ll &x) {
  if (x >= 0)
    return;
  else
    x = -x;
  return;
}

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

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

const ll INF = 1LL << 60;

int N;

// DPテーブル
vector<ll> dp(100010);

int main() {
  cin >> N;
  vi a(N - 1);
  rep(i, N - 1) cin >> a.at(i);
  rep1(j, 1, N + 1) {
    int sum = 0;
    rep(i, N - 1) {
      if (a.at(i) == j)
        sum++;
    }
    cout << sum << 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> boss_list(N);
  for (int i = 1; i < N; i++) {
    cin >> boss_list.at(i);
  }

  map<int, int> list;
  for (int i = 1; i <= N; i++) {
    list[i] = 0;
  }

  for (int i = 1; i < N; i++) {
    list[boss_list.at(i)]++;
  }

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

Error: TLE

Fixed submission:

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

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

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

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

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

int main() {
  int N;
  // int count = 0;
  cin >> N;

  vector<int> sub(N - 1);
  vector<int> out(N);
  // vector<vector<int>> path(M, vector<int>(2));

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

  for (int i = 0; i < N; i++) {
    out.at(i) = 0;
  }

  for (int i = 0; i < N - 1; i++) {
    out.at(sub.at(i) - 1)++;
  }

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


Error: TLE

Fixed submission:

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

int main() {
  int N;
  // int count = 0;
  cin >> N;

  vector<int> sub(N - 1);
  vector<int> out(N);
  // vector<vector<int>> path(M, vector<int>(2));

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

  for (int i = 1; i < N - 1; i++) {
    out.at(sub.at(i - 1) - 1)++;
    if (sub.at(i) == sub.at(i - 1)) {
      out.at(sub.at(i - 1) - 1)++;
    }
    if (i = N - 2)
      out.at(sub.at(i))++;
  }

  for (int i = 0; i < N; i++)
    cout << out.at(i) << endl;
}
Problem p02707 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define rep(i, a, b) for (int i = a; i < (ll)b; ++i)
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

const long long MOD = 1e9 + 7;

int root_tree(vector<int> &v, int i) {
  if (v[i] == i)
    return i;
  return root_tree(v, v[i]);
}
void union_tree(vector<int> &v, vector<int> &rank, int i, int j) {
  int x = root_tree(v, i);
  int y = root_tree(v, y);
  if (rank[x] < rank[y])
    v[x] = y;
  else
    v[y] = x;
  if (rank[x] == rank[y])
    rank[x]++;
}
bool check_tree(vector<int> &v, int i, int j) {
  if (root_tree(v, i) == root_tree(v, j))
    return true;
  return false;
}
int main(void) {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> v(n, 0);
  rep(i, 0, n - 1) {
    int temp;
    cin >> temp;
    v[--temp]++;
  }
  rep(i, 0, n) cout << v[i] << endl;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main(void) {
  long long N;
  cin >> N;
  vector<long long> vec(N);
  for (long long i = 0; i < N - 1; ++i)
    cin >> vec[i];
  for (long long i = 1; i <= N; ++i)
    cout << count(vec.begin(), vec.end(), i) << "\\n";
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#include <cstring>

#define pi 2 * acos(0.00)
#define ll long long
#define fastio                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define nl '\\n'
#define null '\\0'

using namespace std;

int main() {
  fastio;

  int n;
  cin >> n;
  int sbo[n] = {0}, x;
  for (int i = 0; i < n - 1; i++) {
    cin >> x;
    sbo[x - 1]++;
  }
  for (int i = 0; i < n; i++)
    cout << sbo[i] << nl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int num;
  int n;
  int ans[100000] = {0};

  cin >> n;
  for (int i = 2; i <= n; i++) {
    scanf("%d", &num);

    ans[num]++;
  }
  for (int i = 1; i <= n; i++) {
    printf("%d\\n", ans[i]);
  }
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

#include <cstring>
#include <iostream>
#include <set>
using namespace std;
int b[200010];
int main() {
  int n, a;
  while (cin >> n) {
    memset(b, 0, sizeof(b));
    n--;
    for (int i = 0; i < n; i++) {
      cin >> a;
      b[a]++;
    }
    for (int i = 1; i <= n + 1; i++)
      cout << b[i] << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

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

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

  for (int j = 0; j < n; j++) {
    cout << cnt[j] << endl;
  }
  return 0;
}
Problem p02707 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  unsigned long int n, num[200000] = {0}, i, value;
  cin >> n;
  for (i = 1; i < n; i++) {
    cin >> value;
    num[value - 1]++;
  }
  for (i = 0; i < n; i++) {
    cout << num[i] << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
vector<long long> so;
int main() {
  long long n, p;
  cin >> n;
  p = n - 1;
  while (p--) {
    long long p;
    cin >> p;
    so.push_back(p);
  }
  int s = 1;
  while (s <= n) {
    int count = 0;
    for (int i = 0; i < so.size(); i++) {
      if (s == so[i])
        count++;
    }
    cout << count << endl;
    s++;
  }

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

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

Error: 0

Fixed submission:

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

// Author: A_S_M_M@sud_P@rvez
#include <bits/stdc++.h>
using namespace std;
#define MP                                                                     \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define for0(i, n) for (int i = 0; i < n; i++)
#define forn(i, n) for (int i = 1; i <= n; i++)
#define fors(i, s) for (int i = 0; i < s.size(); i++)
#define Sort(s) sort(s.begin(), s.end())
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * (b / __gcd(a, b)))
#define nl "\\n"
#define End return 0
#define gt greater<int>()
#define ll long long
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define mod 1000000007
#define sp(n) fixed << setprecision(n)
#define pi acos(-1)

int main() {
  MP;

  int n;
  cin >> n;
  int a[n];
  vi p(n + 1);
  for (int i = 0; i < n - 1; i++) {
    cin >> a[i];
    p[a[i]]++;
  }
  forn(i, n) { cout << p[i] << nl; }

  End;
}


Error: WA

Fixed submission:

// Author: A_S_M_M@sud_P@rvez
#include <bits/stdc++.h>
using namespace std;
#define MP                                                                     \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define for0(i, n) for (int i = 0; i < n; i++)
#define forn(i, n) for (int i = 1; i <= n; i++)
#define fors(i, s) for (int i = 0; i < s.size(); i++)
#define Sort(s) sort(s.begin(), s.end())
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * (b / __gcd(a, b)))
#define nl "\\n"
#define End return 0
#define gt greater<int>()
#define ll long long
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define mod 1000000007
#define sp(n) fixed << setprecision(n)
#define pi acos(-1)

int main() {
  MP;

  int n;
  cin >> n;
  int a[n], p[100000];
  for0(i, n - 1) {
    cin >> a[i];
    p[a[i]]++;
  }
  forn(i, n - 1) { cout << p[i] << " "; }

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

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

int main() {
  int N;
  cin >> N;
  vector<int> boss(N + 1);
  vector<int> sub(N + 1);
  vector<int> n(N + 1);

  int i = 0;
  for (i = 2; i < N + 1; i++) {
    cin >> boss[i];
    sub[boss[i]]++;
  }

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

Error: TLE

Fixed submission:

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

int employee(int emp, int N, vector<int> boss) {
  int sum = 0;
  for (int i = 2; i < N + 1; i++) {
    if (boss[i] == emp) {
      sum++;
      employee(i, N, boss);
    }
  }
  return sum;
}

int main() {
  int N;
  cin >> N;
  vector<int> boss(N + 1);

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

  for (i = 1; i < N + 1; i++) {
    cout << employee(i, N, boss) << endl;
  }
}
Problem p02707 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  int n;
  cin >> n;
  vector<int> t(n);
  for (int i = 1; i < n; i++) {
    int m;
    cin >> m;
    t[m - 1]++;
  }

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


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define ll long long
int main() {
  ll t, cnt = 0, bnt = 0;
  cin >> t;
  ll m[t + 5];
  for (int i = 1; i < t; i++) {
    cin >> m[i];
  }
  m[0] = 1;
  for (ll i = 0; i < t; i++) {
    for (ll j = i + 1; j < t; j++) {
      if (m[j] == 1)
        cnt++;
      if (i + 1 == m[j])
        bnt++;
    }
    if (i == 0) {
      cout << cnt << endl;
      cnt = 0;
    } else {
      cout << bnt << endl;
    }
    bnt = 0;
  }
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

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


Error: 0

Fixed submission:

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

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

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

Error: TLE

Fixed submission:

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

int main() {
  int N = 0;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end()); // 並び順を小さい順にした
  int start = 0;
  for (int i = 0; i < N; i++) {
    int num = 0;
    for (int j = start; j < N; j++) {
      if (vec.at(j) == i + 1) {
        num++;
      } else if (vec.at(j) > i + 1) {
        start = j;
        break;
      }
    }
    cout << num << endl;
  }
}
Problem p02707 (C++) — buggy submission, verdict: Runtime Error

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

Error: 0

Fixed submission:

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