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

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

int main() {
  int N, ans;
  cin >> N;
  ans = 0;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  if (N % 2 == 0) {
    for (int j = 0; j < N / 2; j++) {
      if (a.at(2 * j) % 2 == 1) {
        ans = ans + 1;
      }
    }
  } else {
    for (int k = 0; k < (N + 1) / 2; k++) {
      if (a.at(2 * k) % 2 == 1) {
        ans = ans + 1;
      }
    }
  }
  cout << ans << endl;
}


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


Fixed submission:

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

int main() {
  int N, ans;
  cin >> N;
  ans = 0;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(N);
  }
  if (N % 2 == 0) {
    for (int j = 0; j < N / 2; j++) {
      if (a.at(2 * j) % 2 == 1) {
        ans = ans + 1;
      }
    }
  } else {
    for (int k = 0; k < (N + 1) / 2; k++) {
      if (a.at(2 * k) % 2 == 1) {
        ans = ans + 1;
      }
    }
  }
  cout << ans << endl;
}
Problem p02607 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N, count;
  count = 0;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    if (vec.at(i) % 2 == 1 && (i + 1) % 2 == 1) {
      ++count;
    }
  }
  cout << count << endl;

  return 0;
}

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


Fixed submission:

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

int main() {
  int N, count;
  count = 0;
  cin >> N;
  vector<int> vec(N);
  for (int i = 1; i <= N; i++) {
    cin >> vec.at(i);
    if (vec.at(i) % 2 == 1 && i % 2 == 1) {
      ++count;
    }
  }
  cout << count << endl;

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

#pragma GCC optimize("Ofast", 3, "inline")
#include <bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int>> min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int mon[20] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
ll gcd(ll x, ll y) { return ((y == 0) ? x : gcd(y, x % y)); }
inline int read() {
  int x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9')
    ch = getchar();
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}
int n, x, cnt;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  //	freopen(".in","r",stdin);
  //	freopen(".out","w",stdout);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    if ((x & 1) && (i & 1))
      cnt++;
  }
  cout << cnt;
  return 0;
}


Error: WA

Fixed submission:

#pragma GCC optimize("Ofast", 3, "inline")
#include <bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int>> min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int mon[20] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
ll gcd(ll x, ll y) { return ((y == 0) ? x : gcd(y, x % y)); }
inline int read() {
  int x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9')
    ch = getchar();
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}
int l, r;
int d;
int cnt;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  //	freopen(".in","r",stdin);
  //	freopen(".out","w",stdout);
  cin >> l >> r >> d;
  while (r >= l) {
    if (r % d == 0)
      cnt++;
    r--;
  }
  cout << cnt;
  return 0;
}
Problem p02607 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N, cnt = 0;
  cin >> N;
  vector<int> N_a(N);
  for (int i = 0; i < N; i++) {
    cin >> N_a.at(i);
  }
  for (int i = 0; i < N; i++) {
    if ((i + 1) % 2 == 1 && N_a.at(i) % 2 == 1) {
      cnt++;
    }
  }
  cout << cnt << endl;
}


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


Fixed submission:

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

int main() {
  int N, cnt = 0;
  cin >> N;
  vector<int> N_a(N);
  for (int i = 0; i < N; i++) {
    cin >> N_a.at(i);
  }
  for (int i = 0; N; i++) {
    if ((i + 1) % 2 == 1 && N_a.at(i) % 2 == 0) {
      cnt++;
    }
  }
  cout << cnt << endl;
}
Problem p02607 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<int> a(N + 1);
  int count = 0;
  for (int i = 1; i < N + 1; i++) {
    cin >> a.at(i);
    if (i % 2 == 1 && a.at(i) % 2 == 1)
      count++;
  }

  cout << count << endl;
  return 0;
}

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


Fixed submission:

#include <bits/stdc++.h>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  int count = 0;
  for (int i = 1; i < N + 1; i++) {
    cin >> a.at(i);
    if (i % 2 == 1 && a.at(i) % 2 == 1)
      count++;
  }

  cout << count << endl;
  return 0;
}
Problem p02607 (C++) — buggy submission, verdict: Runtime Error

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

int main(void) {
  int N;
  vector<int> a(N);
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> a.at(i);
  }
  int m = 0;
  for (int i = 1; i <= N; i++) {
    if (i % 2 == 1 && a.at(i) % 2 == 1) {
      m++;
    }
  }
  cout << m << endl;
  return 0;
}


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


Fixed submission:

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

int main(void) {
  int N;
  vector<int> a;
  cin >> N;
  for (int i = 0; i <= N; i++) {
    cin >> a.at(i);
  }
  int m = 0;
  for (int i = 0; i <= N; i++) {
    if (i % 2 == 1 && a.at(i) % 2 == 1) {
      m++;
    }
  }
  cout << m << endl;
  return 0;
}
Problem p02607 (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; i++) {
    cin >> a.at(i);
  }
  int count = 0;
  int M;
  if (N % 2 == 0) {
    M == N / 2;
  } else if (!(N % 2 == 0)) {
    M == N / 2 + 1;
  }
  if (N % 2 == 0) {
    for (int i = 0; i < N / 2; i++) {
      if (!(a.at(2 * i) % 2 == 0)) {
        count++;
      }
    }
  } else if (!(N % 2 == 0)) {
    for (int i = 0; i <= (N - 1) / 2; i++) {
      if (!(a.at(i * 2) % 2 == 0)) {
        count++;
      }
    }
  }
  cout << count << endl;
}

Error: 0

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.at(i);
  }
  int count = 0;
  int M;
  if (N % 2 == 0) {
    M == N / 2;
  } else if (!(N % 2 == 0)) {
    M == N / 2 + 1;
  }
  if (N % 2 == 0) {
    for (int i = 0; i <= N / 2; i++) {
      if (!(a.at(2 * i) % 2 == 0)) {
        count++;
      }
    }
  } else if (!(N % 2 == 0)) {
    for (int i = 0; i <= (N - 1) / 2; i++) {
      if (!(a.at(i * 2) % 2 == 0)) {
        count++;
      }
    }
  }
  cout << count << endl;
}
Problem p02607 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n, i, sum = 0;
  cin >> n;
  int arr[n];
  for (i = 0; i < n; i++)
    cin >> arr[i];
  for (i = 0; i < n; i += 2) {
    if (arr[i] % 2 != 0)
      sum++;
  }
  cout << sum << endl;
  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int i;
  int arr[5];

  int N;
  int a = 0;

  cin >> N;

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

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

    if (i % 2 != 0 && arr[i] % 2 != 0) {
      a++;
    }
  }

  cout << a;
}
Problem p02607 (C++) — buggy submission, verdict: Runtime Error

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

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

  for (auto &x : a) {
    cin >> x;
  }

  int t = n - 1;

  int ans = 0;

  for (int i = 0; i <= t; i += 2) {
    if (a.at(i) % 2 == 1) {
      ans++;
    }
  }

  cout << ans << endl;
}


Error: 0

Fixed submission:

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

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

  for (auto &x : a) {
    cin >> x;
  }

  int t = n;
  if (t % 2 == 1) {
    t--;
  }

  int ans = 0;

  for (int i = 0; i <= t; i += 2) {
    if (a.at(i) % 2 == 1) {
      ans++;
    }
  }

  cout << ans << endl;
}
Problem p02607 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N, n = 0;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  for (int i = 1; i <= N; i++) {
    if (i % 2 != 0 && a.at(i - 1) % 2 != 0)
      n++;
  }
  cout << n;
  return 0;
}


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


Fixed submission:

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

int main() {
  int N, n = 0;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  for (int i = 1; i <= N; i++) {
    if (i % 2 != 0 && a.at(i) % 2 != 0)
      n++;
  }
  cout << n;
  return 0;
}
Problem p02607 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  int i, n;
  cin >> n;
  int a[n], c = 0;
  for (i = 0; i < n; i++)
    cin >> a[i];
  for (i = 0; i < n; i++) {
    if (i % 2 == 0 && a[i] % 2 != 0)
      c++;
  }
  cout << c << endl;
}


Error: -11

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int i, n;
  cin >> n;
  int a[i], c = 0;
  for (i = 0; i < n; i++)
    cin >> a[i];
  for (i = 0; i < n; i++) {
    if (i % 2 == 0 && a[i] % 2 != 0)
      c++;
  }
  cout << c << endl;
}
Problem p02607 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define IOS                                                                    \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);

int main() {
  IOS;
  int n, c = 0;
  cin >> n;
  int a[n];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (i % 2 != 0 && a[i] % 2 != 0) {
      c++;
    }
  }
  cout << c;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define IOS                                                                    \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
#define w(t)                                                                   \\
  int t;                                                                       \\
  cin >> t;                                                                    \\
  while (t--)
int solve() {
  int n, c = 0;
  cin >> n;
  int a[n];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (i % 2 != 0 && a[i] % 2 != 0) {
      c++;
    }
  }
  cout << c;
}

int main() {
  IOS;
  { solve(); }

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

#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define mod 998244353
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  LL N;
  cin >> N;
  LL x;
  LL count = 0;
  x = 1;
  while (x <= N) {
    LL y;
    cin >> y;
    if (x % 2 and y % 2)
      count++;
    x++;
  }
  cout << count;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define mod 998244353
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  LL N;
  cin >> N;
  LL x;
  LL count = 0;
  x = 1;
  while (x <= N) {
    LL y;
    cin >> y;
    if (x % 2 and y % 2)
      count++;
    x++;
  }
  cout << count;
}
Problem p02607 (C++) — buggy submission, verdict: Runtime Error

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

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

  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (((i + 1) % 2 == 1) && (vec.at(i) % 2 == 1))
      ans++;
  }
  cout << ans;
}


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


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; i++) {
    cin >> vec.at(i);
  }

  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if ((i % 2 == 1) && (vec.at(i) % 2 == 1))
      ans++;
  }
  cout << ans;
}
Problem p02607 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
#define FIO                                                                    \\
  freopen("input.txt", "r", stdin);                                            \\
  freopen("output.txt", "w", stdout);
int main() {
  // FIO;
  int n;
  cin >> n;
  int i = 1;
  int cnt = 0;
  while (i <= n) {
    int temp;
    cin >> temp;
    if (i & 1 && temp & 1)
      cnt++;
    i++;
  }
  cout << cnt << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  int i = 1, cnt = 0;
  while (i <= n) {
    int temp;
    cin >> temp;
    if (i & 1 && temp & 1)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}
Problem p02607 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n, c;
  c = 0;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  for (int i = 0; i < n; i++) {
    if (i % 2 == 1) {
      continue;
    }
    if (vec.at(i) % 2 == 1) {
      c++;
    }
  }
  cout << c << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  int n, c;
  c = 0;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  for (int i = 0; i < n; i + 2) {
    if (vec.at(i) % 2 == 1) {
      c++;
    }
  }
  cout << c << endl;
}
Problem p02607 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {

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

    if (a[i] % 2 == 1)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    if (i % 2 == 1 && a[i] % 2 == 1)
      ans++;
  }
  cout << ans;
  return 0;
}
Problem p02607 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {

  int n, count = 0;
  cin >> n;
  int a[n];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    if ((i & 1) && (a[i] & 1))
      count++;
  }
  cout << count << endl;

  return 0;
}

Error: -6
Fatal glibc error: malloc assertion failure in sysmalloc: (old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {

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

  cout << count << endl;

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

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <stdio.h>
#include <vector>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

int main() {
  ll N;
  cin >> N;
  ll A[N + 1];
  rep(i, N + 1) A[i] = 0;
  rep(i, 100) {
    rep(j, 100) {
      rep(k, 100) {
        ll n = (i + 1) * (i + 1) + (j + 1) * (j + 1) + (k + 1) * (k + 1) +
               (i + 1) * (j + 1) + (j + 1) * (k + 1) + (k + 1) * (i + 1);
        if (n <= N)
          A[n]++;
      }
    }
  }
  rep(i, N) { cout << A[i + 1] << endl; }
  return 0;
}


Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <stdio.h>
#include <vector>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

int main() {
  ll N;
  cin >> N;
  ll A[10001];
  rep(i, 10001) A[i] = 0;
  rep(i, 100) {
    rep(j, 100) {
      rep(k, 100) {
        ll n = (i + 1) * (i + 1) + (j + 1) * (j + 1) + (k + 1) * (k + 1) +
               (i + 1) * (j + 1) + (j + 1) * (k + 1) + (k + 1) * (i + 1);
        if (n <= 10001)
          A[n]++;
      }
    }
  }
  rep(i, N) { cout << A[i + 1] << endl; }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int g(int x, int y, int z) {
  int k = x + y + z;
  return k * k - x * y - y * z - z * x;
}

int main(void) {
  int N;
  cin >> N;
  vector<int> ans(N + 1, 0);
  int a = 6;
  int n = 5;
  int k = 3;
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int t = g(x, y, z);
        if (t <= N)
          ans[t]++;
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

/*Author- Soumak Poddar*/

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

#define ll long long int
#define sll signed long long int
#define ull unsigned long long int
#define um unordered_map
#define us unordered_set
#define mm multimap
#define mp make_pair
#define pb push_back
#define M 1000000007

bool comp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }

void solve();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("error.txt", "w", stderr);
  freopen("output.txt", "w", stdout);
#endif

  int t = 1;
  // cin>>t;
  while (t--) {
    solve();
    cout << "\\n";
  }
  cerr << "Time Taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
  return 0;
}
void solve() {
  int n;
  cin >> n;
  int c = 0;
  for (int a = 1; a <= n; a++) {
    c = 0;
    for (int i = 1; i <= a; i++) {
      for (int j = 1; j <= a; j++) {
        for (int k = 1; k <= a; k++) {
          if ((i * i + j * j + k * k + i * j + i * k + j * k) == a)
            c++;
        }
      }
    }
    cout << c << "\\n";
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n;
  cin >> n;
  vector<int> v(10001);
  for (int x = 1; x < 101; x++) {
    for (int y = 1; y < 101; y++) {
      for (int z = 1; z < 101; z++) {
        int a = x * x + y * y + z * z + x * y + y * z + z * x;
        if (a < 10001)
          v[a] += 1;
      }
    }
  }
  rep(i, n) cout << v[i + 1] << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    for (int x = 1; x < 70; x++) {
      for (int y = 1; y < 70; y++) {
        for (int z = 1; z < 70; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i)
            cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

#define rep(x, n) for (int i = x; i < (n); ++i)

using namespace std;
using ll = long long;

int calc(int x, int y, int z) {
  return x * x + y * y + z * z + x * y + y * z + z * x;
}

int main(void) {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int res = 0;
    for (int x = 1; x * x <= n; ++x) {
      for (int y = 1; y * y <= n; ++y) {
        for (int z = 1; z * z <= n; ++z) {
          if (calc(x, y, z) < i)
            continue;
          if (calc(x, y, z) == i)
            ++res;
          break;
        }
      }
    }
    cout << res << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define rep(x, n) for (int i = x; i < (n); ++i)

using namespace std;
using ll = long long;

int calc(int x, int y, int z) {
  return x * x + y * y + z * z + x * y + y * z + z * x;
}

int main(void) {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int res = 0;
    for (int x = 1; x * x <= n; ++x) {
      for (int y = 1; y * y <= n; ++y) {
        for (int z = 1; z * z <= n; ++z) {
          if (calc(x, y, z) < i)
            continue;
          if (calc(x, y, z) == i) {
            ++res;
            break;
          }
        }
      }
    }
    cout << res << endl;
  }
}
Problem p02608 (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;
  map<int, int> ans;
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int n = x * x + y * y + z * z + x * y + y * z + z * x;
        ans[n]++;
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    cout << ans[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>;

int main() {
  int n;
  cin >> n;
  map<int, int> ans;
  for (int x = 1; x <= n; x++) {
    for (int y = 1; y <= n; y++) {
      for (int z = 1; z <= n; z++) {
        int n = x * x + y * y + z * z + x * y + y * z + z * x;
        ans[n]++;
      }
    }
  }

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