prithivMLmods/Coder-Stat huggingface dataset:
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long int ll;
typedef pair<int, int> P;

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    int num = i;
    for (int x = 1; x * x <= num; x++) {
      for (int y = 1; y * y <= num - x * x; y++) {
        for (int z = 1; z * z <= num - x * x - y * y - x * y; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == num)
            ans++;
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    int num = i;
    for (int x = 1; x * x < num; x++) {
      for (int y = 1; x * x + y * y + x * y < num; y++) {
        for (int z = 1; x * x + y * y + z * z + x * y + y * z + z * x <= num;
             z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == num)
            ans++;
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i <= (b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int f(int n) {
  int cnt = 0;
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        if (x * x + y * y + z * z + x * y + y * z + z * x == n)
          cnt++;
      }
    }
  }
  return cnt;
}

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cout << f(i) << "\n";
  }
  return 0;
}


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

int f(int n) {
  int cnt = 0;
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      int a = (x + y);
      int b = 4 * (x * x + y * y + x * y - n);
      double c = sqrt(a * a - b);
      if ((c - a) >= 2 && int(c) == c && (int(c) - a) % 2 == 0)
        cnt++;
    }
  }
  return cnt;
}

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cout << f(i) << "\n";
  }
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

int main() {
  int n, ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int x = 1; x <= n; x++) {
      if (x * x + 2 * x + 3 > i)
        break;
      int xx = x * x;
      for (int y = x; y <= n; y++) {
        int xy = xx + y * (x + y);
        if (xy + x + y + 1 > i)
          break;
        for (int z = y; z <= n; z++) {
          if (i == xy + z * (x + y + z)) {
            // if(i == x*x+x*y+x*z+y*y+z*z+z*y) {
            if (x == y && y == z)
              ans++;
            else if (x != y && y != z && z != x)
              ans += 6;
            else
              ans += 3;
          }
          // if(i < (x+y+z)*(x+y+z)-z*y-z*x-x*y) break;
        }
      }
    }
    cout << ans << endl;
    ans = 0;
  }
}

Fixed submission:
#include <iostream>
using namespace std;

int main() {
  int n, ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int x = 1; x <= n; x++) {
      if (x * x + 2 * x + 3 > i)
        break;
      int xx = x * x;
      for (int y = x; y <= n; y++) {
        int xy = xx + y * (x + y);
        if (xy + x + y + 1 > i)
          break;
        for (int z = y; z <= n; z++) {
          if (i == xy + z * (x + y + z)) {
            // if(i == x*x+x*y+x*z+y*y+z*z+z*y) {
            if (x == y && y == z)
              ans++;
            else if (x != y && y != z && z != x)
              ans += 6;
            else
              ans += 3;
          }
          if (i < (x + y + z) * (x + y + z) - z * y - z * x - x * y)
            break;
        }
      }
    }
    cout << ans << endl;
    ans = 0;
  }
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

#define FAST()                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL)

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

int main() {
  FAST();
  int i, j, k, n, x, cnt[1002] = {0};
  cin >> n;
  for (i = 1; i < 101; i++) {
    for (j = 1; j < 101; j++) {
      for (k = 1; k < 101; k++) {
        x = Check(i, j, k);
        if (x <= n)
          ++cnt[x];
      }
    }
  }
  for (i = 1; i <= n; i++)
    cout << cnt[i] << '\n';
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;

#define FAST()                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL)

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

int main() {
  FAST();
  int i, j, k, n, x, cnt[10002] = {0};
  cin >> n;
  for (i = 1; i < 101; i++) {
    for (j = 1; j < 101; j++) {
      for (k = 1; k < 101; k++) {
        x = Check(i, j, k);
        if (x <= n)
          ++cnt[x];
      }
    }
  }
  for (i = 1; i <= n; i++)
    cout << cnt[i] << '\n';
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <stack>
#include <string>
#include <unordered_map>

using namespace std;
typedef long long ll;
const ll INF = 1000000007;
const ll mod = 998244353;

int main() {
  ll n;
  cin >> n;
  for (ll N = 1; N <= n; N++) {
    ll ans = 0;
    for (ll x = 1; x * x <= N; x++) {
      for (ll y = 1; y * y + x * x <= N; y++) {
        for (ll z = 1; x * x + y * y + z * z <= N; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == N) {
            ans++;
          }
        }
      }
    }
    cout << ans << "\n";
  }
  cout << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <stack>
#include <string>
#include <unordered_map>

using namespace std;
typedef long long ll;
const ll INF = 1000000007;
const ll mod = 998244353;

int main() {
  ll n;
  cin >> n;
  for (ll N = 1; N <= n; N++) {
    ll ans = 0;
    for (ll x = 1; x * x <= N; x++) {
      for (ll y = 1; y * y + x * x + x * y <= N; y++) {
        for (ll z = 1; x * x + y * y + z * z + x * y + y * z + z * x <= N;
             z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == N) {
            ans++;
          }
        }
      }
    }
    cout << ans << "\n";
  }
  cout << endl;
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

ll N;
ll ans[10101];

int main() {
  //
  cin >> N;
  for (ll i = 1; i * i <= N; ++i) {
    for (ll j = 1; j * j <= N; ++j) {
      for (ll k = 1; k * k <= N; ++k) {
        ll sum = i * i + j * j + k * k + i * j + j * k + k * i;
        ++ans[sum];
      }
    }
  }
  repe(i, 1, N) { cout << ans[i] << "\n"; }
}


Fixed submission:
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

ll N;
ll ans[10101];

int main() {
  //
  cin >> N;
  for (ll i = 1; i * i <= N; ++i) {
    for (ll j = 1; j * j <= N; ++j) {
      for (ll k = 1; k * k <= N; ++k) {
        ll sum = i * i + j * j + k * k + i * j + j * k + k * i;
        if (sum > N)
          continue;
        ++ans[sum];
      }
    }
  }
  repe(i, 1, N) { cout << ans[i] << "\n"; }
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  int a[10010] = {0};
  for (int x = 1; x < 100; x++) {
    for (int y = 1; y < 100; y++) {
      for (int z = 1; z < 100; z++) {
        a[x * x + y * y + z * z + x * y + y * z + z * x]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << endl;
  }
}


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

int main() {
  int n;
  cin >> n;
  int a[100000];
  for (int i = 1; i < 100000; i++)
    a[i] == 0;
  for (int x = 1; x < 100; x++) {
    for (int y = 1; y < 100; y++) {
      for (int z = 1; z < 100; z++) {
        a[x * x + y * y + z * z + x * y + y * z + z * x]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << endl;
  }
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define rreps(i, n, s) for (int i = s; i >= n; i--)
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  reps(n, N + 1, 1) {
    ll r = sqrt(2 * n);
    int cnt = 0;
    reps(x, r + 1, 1) {
      reps(y, r + 1 - x, 1) {
        for (int z = 1; z < r + 1 - x && z < r + 1 - y; z++) {
          int S = (x + y) * (x + y) + (z + y) * (z + y) + (x + z) * (x + z);
          if (S == 2 * n) {
            cnt++;
          }
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define rreps(i, n, s) for (int i = s; i >= n; i--)
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  reps(n, N + 1, 1) {
    ll r = sqrt(2 * n);
    int cnt = 0;
    reps(x, r + 1, 1) {
      reps(y, r + 1 - x, 1) {
        ll b = x + y;
        ll c = x * x + y * y + x * y - n;
        ll d = b * b - 4 * c;

        if (d > 0 && ceil(sqrt(d)) == floor(sqrt(d)) && (-b + sqrt(d)) >= 1) {
          cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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;
}

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll << 61;
double pi = 3.141592653589793238;

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

  reps1(i, n + 1) {
    ll ans = 0;
    reps1(x, i) {
      reps1(y, i) {
        ll judge = (x + y) * (x + y) - 4 * (x * x + y * y + x * y - i);
        // cout << i << " " << x << " " << y << " " << judge << endl;
        if (ll(sqrt(judge)) * ll(sqrt(judge)) != judge)
          continue;
        // cout << "a";
        if (-(x + y) * (x + y) + judge <= 0)
          continue;
        // cout << "b";
        // cout << -(x+y)*(x+y) + judge << endl;
        if ((-(x + y) * (x + y) + judge) % 2 != 0)
          continue;
        // cout << "c" << endl;
        ans++;
      }
    }
    cout << ans << endl;
  }

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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;
}

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll << 61;
double pi = 3.141592653589793238;

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

  reps1(i, n + 1) {
    ll ans = 0;
    reps1(x, ll(sqrt(i))) {
      reps1(y, ll(sqrt(i))) {
        ll judge = (x + y) * (x + y) - 4 * (x * x + y * y + x * y - i);
        // cout << i << " " << x << " " << y << " " << judge << endl;
        if (ll(sqrt(judge)) * ll(sqrt(judge)) != judge)
          continue;
        // cout << "a";
        if (-(x + y) * (x + y) + judge <= 0)
          continue;
        // cout << "b";
        // cout << -(x+y)*(x+y) + judge << endl;
        if ((-(x + y) * (x + y) + judge) % 2 != 0)
          continue;
        // cout << "c" << endl;
        ans++;
      }
    }
    cout << ans << endl;
  }

  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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;
}

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll << 61;
double pi = 3.141592653589793238;

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

  vector<ll> ans(n);

  reps1(x, ll(sqrt(n))) {
    reps1(y, ll(sqrt(n))) {
      reps1(z, ll(sqrt(n))) {
        ans[x * x + y * y + z * z + x * y + y * z + z * x]++;
      }
    }
  }

  reps1(i, n + 1) cout << ans[i] << endl;

  /*

  reps1(i, n+1) {
    ll ans = 0;
    reps1(x, ll(sqrt(i))) {
      reps1(y, ll(sqrt(i))) {
        ll judge = (x+y)*(x+y) - 4 * (x*x + y*y + x*y - i);
        // cout << i << " " << x << " " << y << " " << judge << endl;
        if (ll(sqrt(judge)) * ll(sqrt(judge)) != judge) continue;
        // cout << "a";
        if (-(x+y)*(x+y) + judge <= 0) continue;
        // cout << "b";
        // cout << -(x+y)*(x+y) + judge << endl;
        if ((-(x+y)*(x+y) + judge) % 2 != 0) continue;
        // cout << "c" << endl;
        ans++;

      }
    }
    cout << ans << endl;
  }
  */

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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;
}

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll << 61;
double pi = 3.141592653589793238;

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

  vector<ll> ans(n);

  reps1(x, ll(sqrt(n))) {
    reps1(y, ll(sqrt(n))) {
      reps1(z, ll(sqrt(n))) {
        ll tmp = x * x + y * y + z * z + x * y + y * z + z * x;
        if (tmp > n)
          continue;
        ans[tmp]++;
      }
    }
  }

  reps1(i, n + 1) cout << ans[i] << endl;

  /*

  reps1(i, n+1) {
    ll ans = 0;
    reps1(x, ll(sqrt(i))) {
      reps1(y, ll(sqrt(i))) {
        ll judge = (x+y)*(x+y) - 4 * (x*x + y*y + x*y - i);
        // cout << i << " " << x << " " << y << " " << judge << endl;
        if (ll(sqrt(judge)) * ll(sqrt(judge)) != judge) continue;
        // cout << "a";
        if (-(x+y)*(x+y) + judge <= 0) continue;
        // cout << "b";
        // cout << -(x+y)*(x+y) + judge << endl;
        if ((-(x+y)*(x+y) + judge) % 2 != 0) continue;
        // cout << "c" << endl;
        ans++;

      }
    }
    cout << ans << endl;
  }
  */

  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()

#define uint8_t unsigned char
#define uint16_t unsigned short
#define uint32_t unsigned int
#define uint64_t unsigned long long

#define int8_t signed char
#define int16_t signed short
#define int32_t signed int
#define int64_t signed long long

using namespace std;
// #define PI 3.14159265358979323846
// cout << fixed << setprecision(20);

int main(int argc, char const *argv[]) {
  int N = 0;
  int f[10001] = {};

  cin >> N;
  for (int x = 1; x <= sqrt(N); x++) {
    for (int y = 1; y <= sqrt(N); y++) {
      for (int z = 1; z <= sqrt(N); z++) {
        f[x * x + y * y + z * z + x * y + y * z + z * x] += 1;
      }
    }
  }

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

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()

#define uint8_t unsigned char
#define uint16_t unsigned short
#define uint32_t unsigned int
#define uint64_t unsigned long long

#define int8_t signed char
#define int16_t signed short
#define int32_t signed int
#define int64_t signed long long

using namespace std;
// #define PI 3.14159265358979323846
// cout << fixed << setprecision(20);

int main(int argc, char const *argv[]) {
  int N = 0;
  int f[10001] = {};

  cin >> N;
  for (int x = 1; x <= sqrt(N); x++) {
    for (int y = 1; y <= sqrt(N); y++) {
      for (int z = 1; z <= sqrt(N); z++) {
        int a = x * x + y * y + z * z + x * y + y * z + z * x;
        if (a <= N) {
          f[x * x + y * y + z * z + x * y + y * z + z * x] += 1;
        }
      }
    }
  }

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

  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define vii vector<ll>
#define pb push_back
#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
using namespace std;
const int MOD = 1e9 + 7, N = 1e4 + 3;

int main() {
  fast;
  ll n, k = 6;
  cin >> n;
  for (int i = 1; i <= 5; ++i) {
    cout << "0\n";
    if (i == n)
      break;
  }
  for (int i = 6; i <= n; ++i) {
    ll ans = 0;
    for (int j = 1; j <= sqrt(i); ++j) {
      for (int k = 1; k <= sqrt(i); ++k) {
        for (int l = 1; l <= sqrt(i); ++l) {
          int a = (l * l) + (k * k) + (j * j) + (l * k) + (l * j) + (k * j);
          if (a == i)
            ++ans;
        }
      }
    }
    cout << ans << "\n";
  }
  cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define vii vector<ll>
#define pb push_back
#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
using namespace std;
const int MOD = 1e9 + 7, N = 1e4 + 3;

int main() {
  fast;
  ll n, k = 6;
  cin >> n;
  for (int i = 1; i <= 5; ++i) {
    cout << "0\n";
    if (i == n)
      break;
  }
  for (int i = 6; i <= n; ++i) {
    ll ans = 0;
    for (int j = 1; j <= sqrt(i); ++j) {
      for (int k = 1; k <= sqrt(i); ++k) {
        for (int l = 1; l <= sqrt(i); ++l) {
          int a = (l * l) + (k * k) + (j * j) + (l * k) + (l * j) + (k * j);
          if (a == i)
            ++ans;
          if (a > i)
            break;
        }
      }
    }
    cout << ans << "\n";
  }
  cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<int>;
using vec2 = vector<vector<int>>;
ll inf = pow(2, 62);
// x2 + y2 + z2 + xy+yz+zx = x2 + x(y + z) + zy + y2+z2
//(x + y)2 + (y + z)2 + (y + z)2 = 2n
int main() {
  ll n;
  cin >> n;
  for (int p = 1; p <= n; p++) {
    ll count = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = i; j <= n; j++) {
        for (int k = j; k <= n; k++) {
          if (i * i + j * j + k * k + i * j + j * k + k * i == p) {
            if (i == j && j == k) {
              count++;
            } else if ((i == j && j != k) || (j == k && k != i) ||
                       (k == i && i != j)) {
              count += 3;
            } else {
              count += 6;
            }
          }
        }
      }
    }
    cout << count << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<int>;
using vec2 = vector<vector<int>>;
ll inf = pow(2, 62);
// x2 + y2 + z2 + xy+yz+zx = x2 + x(y + z) + zy + y2+z2
//(x + y)2 + (y + z)2 + (y + z)2 = 2n
int main() {
  ll n;
  cin >> n;
  for (int p = 1; p <= n; p++) {
    ll count = 0;
    for (int i = 1; i * i <= n; i++) {
      for (int j = i; j * j + i * i <= n; j++) {
        for (int k = j; k * k + i * i + j * j <= n; k++) {
          if (i * i + j * j + k * k + i * j + j * k + k * i == p) {
            if (i == j && j == k) {
              count++;
            } else if ((i == j && j != k) || (j == k && k != i) ||
                       (k == i && i != j)) {
              count += 3;
            } else {
              count += 6;
            }
          }
        }
      }
    }
    cout << count << endl;
  }
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  long long n;
  std::cin >> n;

  vector<long long> answers(n + 1, 0);

  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        long long val =
            pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x;
        answers[val] += 1;
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    std::cout << answers[i] << '\n';
  }

  return 0;
}


Fixed submission:
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  long long n;
  std::cin >> n;

  vector<long long> answers(n + 1, 0);

  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        long long val =
            pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x;
        if (n < val)
          continue;
        answers[val] += 1;
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    std::cout << answers[i] << '\n';
  }

  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[50005] = {0};
int main() {
  ios ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= sqrt(n); i++) {
    for (int j = 1; j <= sqrt(n); j++) {
      for (int k = 1; k <= sqrt(n); k++) {
        int x = i * i + j * j + k * k + i * j + i * k + j * k;
        a[x]++;
      }
    }
  }

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


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[60005] = {0};
int main() {
  ios ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= sqrt(n); i++) {
    for (int j = 1; j <= sqrt(n); j++) {
      for (int k = 1; k <= sqrt(n); k++) {
        int x = i * i + j * j + k * k + i * j + i * k + j * k;
        a[x]++;
      }
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <unordered_set>
#include <valarray>
#include <vector>

#include <utility>

#include <deque>
#include <queue>

using namespace std;
long long a[10001];
int main() {
  long long n;
  cin >> n;
  long long x, y, z;
  long long counter;
  set<long long> numbers;
  for (int i = 1; i <= n; i++) {

    numbers.insert(i);
  }

  for (x = 1; x <= n; x++) {
    counter = 0;
    for (y = 1; y <= 98; y++) {
      for (z = 1; z <= 98; z++) {
        long long c = (x * x) + (y * y) + (z * z) + (x * y) + (z * x) + (z * y);

        auto it = numbers.find(c);
        if (it != numbers.end()) {
          a[c]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << endl;
  }

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <unordered_set>
#include <valarray>
#include <vector>

#include <utility>

#include <deque>
#include <queue>

using namespace std;
long long a[10001];
int main() {
  long long n;
  cin >> n;
  long long x, y, z;
  long long counter;
  set<long long> numbers;
  for (int i = 1; i <= n; i++) {

    numbers.insert(i);
  }

  for (x = 1; x <= 98; x++) {

    for (y = 1; y <= 98; y++) {
      for (z = 1; z <= 98; z++) {
        long long c = (x * x) + (y * y) + (z * z) + (x * y) + (z * x) + (z * y);

        auto it = numbers.find(c);
        if (it != numbers.end()) {
          a[c]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << endl;
  }

  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define _GLIBCXX_DEBUG

int n, ans;

int max_n(double t) {
  if (t < 5)
    return t;
  t = sqrt(t);
  return t;
}
int main() {
  cin >> n;
  rep2(i, 1, n + 1) {
    double mn = max_n(i);

    ans = 0;
    rep2(x, 1, mn) rep2(y, 1, mn) rep2(z, 1, mn) {
      if (x * x + y * y + z * z + x * y + y * z + z * x == i)
        ans++;
    }
    cout << ans << endl;
  }
}

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

int n, ans;

int max_n(double t) {
  if (t < 5)
    return t;
  t = sqrt(t);
  return t;
}
int main() {
  cin >> n;
  rep2(i, 1, n + 1) {
    double mn = max_n(i);

    ans = 0;
    rep2(x, 1, mn) rep2(y, x, mn) rep2(z, y, mn) {
      if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
        if (x != y && y != z)
          ans += 6;
        else if (x == y && y == z)
          ans += 1;
        else
          ans += 3;
      }
    }
    cout << ans << endl;
  }
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> ans(N + 1);
  int n = sqrt(N);
  for (int x = 1; x < n; x++) {
    for (int y = 1; y < n; y++) {
      for (int z = 1; z < n; z++) {
        int a = (x + y + z) * (x + y + z) - (x * y + y * z + z * x);
        ans[a]++;
      }
    }
  }

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

Fixed submission:
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> ans(N + 1);
  int n = sqrt(N);
  for (int x = 1; x < n; x++) {
    for (int y = 1; y < n; y++) {
      for (int z = 1; z < n; z++) {
        int a = (x + y + z) * (x + y + z) - (x * y + y * z + z * x);
        if (a >= 1 && a <= N)
          ans[a]++;
      }
    }
  }

  for (int i = 1; i <= N; i++) {
    cout << ans[i] << endl;
  }
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i < i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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 MRINF = 5000000000000000;

int main() {

  ll N;
  cin >> N;
  vector<ll> ans(N + 10);
  REP1(x, 101) {
    REP1(y, 101) {
      REP1(z, 101) { ans[x * x + y * y + z * z + x * y + y * z + z * x]++; }
    }
  }
  REP(i, N) { cout << ans[i + 1] << endl; }
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

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

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i < i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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 MRINF = 5000000000000000;

int main() {

  ll N;
  cin >> N;
  vector<ll> ans(100000000);
  REP1(x, 101) {
    REP1(y, 101) {
      REP1(z, 101) { ans[x * x + y * y + z * z + x * y + y * z + z * x]++; }
    }
  }
  REP(i, N) { cout << ans[i + 1] << endl; }
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  int flag[10001] = {0};
  for (int x = 1; x < 100; x++) {
    for (int y = 1; y < 100; y++) {
      for (int z = 1; z < 100; z++) {
        int s = x * x + y * y + z * z + z * x + x * y + z * y;
        flag[s]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << flag[i] << endl;

  return 0;
}


Fixed submission:
#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  int flag[10001] = {0};
  for (int x = 1; x < 100; x++) {
    for (int y = 1; y < 100; y++) {
      for (int z = 1; z < 100; z++) {
        int s = x * x + y * y + z * z + z * x + x * y + z * y;
        if (s <= 10000)
          flag[s]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << flag[i] << endl;

  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> cnt(n + 1, 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++) {
        int res = x * x + y * y + z * z + x * y + y * z + z * x;
        cnt[res]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << cnt[i] << endl;

  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> cnt(n + 1, 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++) {
        int res = x * x + y * y + z * z + x * y + y * z + z * x;
        if (res > n)
          break;
        cnt[res]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << cnt[i] << endl;

  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define speed                                                                  \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#pragma GCC optimize "trapv"
#define _GLIBCXX_DEBUG
#define ll long long int
#define ld long double
#define ull unsigned long long int // ranges from (0 - twice of long long int)
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define per(i, a, n) for (ll i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define MOD 1000000007LL
#define llpair pair<ll, ll>
#define INF 1000000000000000000ll // this is 1e18 long long
#define np next_permutation
#define PI acos(-1)
#define DEB(x) cout << #x << " " << x << endl;
#define rotate_left(vec, amt) rotate(vec.begin(), vec.begin() + amt, vec.end());
#define rotate_right(vec, amt)                                                 \
  rotate(vec.begin(), vec.begin() + vec.size() - amt, vec.end());
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define clr(x) memset(x, 0, sizeof(x))
using namespace std;
ll a[10004];
int main() {
  speed;
  ll n;
  cin >> n;
  rep(i, 1, 102) rep(j, 1, 102) rep(k, 1, 102) {
    a[i * i + j * j + k * k + j * k + k * i + j * i]++;
  }
  rep(i, 1, n + 1) { cout << a[i] << endl; }

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define speed                                                                  \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#pragma GCC optimize "trapv"
#define _GLIBCXX_DEBUG
#define ll long long int
#define ld long double
#define ull unsigned long long int // ranges from (0 - twice of long long int)
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define per(i, a, n) for (ll i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define MOD 1000000007LL
#define llpair pair<ll, ll>
#define INF 1000000000000000000ll // this is 1e18 long long
#define np next_permutation
#define PI acos(-1)
#define DEB(x) cout << #x << " " << x << endl;
#define rotate_left(vec, amt) rotate(vec.begin(), vec.begin() + amt, vec.end());
#define rotate_right(vec, amt)                                                 \
  rotate(vec.begin(), vec.begin() + vec.size() - amt, vec.end());
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define clr(x) memset(x, 0, sizeof(x))
using namespace std;
ll a[10004];
int main() {
  speed;
  ll n;
  cin >> n;
  rep(i, 1, 102) rep(j, 1, 102) rep(k, 1, 102) {
    ll x;
    x = i * i + j * j + k * k + j * k + k * i + j * i;
    if (x < 10004)
      a[x]++;
  }
  rep(i, 1, n + 1) { cout << a[i] << endl; }

  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define ss cout << " ";
#define ct(x) cout << x;
#define nn cout << "\n";
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define qr queries();
void solve();
void YN(bool b) {
  if (b) {
    ctn("YES");
  } else {
    ctn("NO");
  }
};
void yn(bool b) {
  if (b) {
    ctn("Yes");
  } else {
    ctn("No");
  }
};
void queries() {
  int n;
  cin >> n;
  while (n--)
    solve();
}
// // // // // // // // // // // // // // // // // // // // // //
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
int64 q, n;

void solve() { return; }

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vec arr(n);
  for (int i = 1; i <= 110; i++) {
    for (int j = 1; j <= 110; j++) {
      for (int k = 1; k <= 110; k++) {
        int64 l = i * i + j * j + k * k + i * j + j * k + k * i;
        if (l <= 10100) {
          arr[l]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    ctn(arr[i]);
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define ss cout << " ";
#define ct(x) cout << x;
#define nn cout << "\n";
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define qr queries();
void solve();
void YN(bool b) {
  if (b) {
    ctn("YES");
  } else {
    ctn("NO");
  }
};
void yn(bool b) {
  if (b) {
    ctn("Yes");
  } else {
    ctn("No");
  }
};
void queries() {
  int n;
  cin >> n;
  while (n--)
    solve();
}
// // // // // // // // // // // // // // // // // // // // // //
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
int64 q, n;

void solve() { return; }

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vec arr(100500);
  for (int i = 1; i <= 110; i++) {
    for (int j = 1; j <= 110; j++) {
      for (int k = 1; k <= 110; k++) {
        int64 l = i * i + j * j + k * k + i * j + j * k + k * i;
        if (l <= 10100) {
          arr[l]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    ctn(arr[i]);
  }
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<long long, long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

vecl f(10001);

int main() {
  int N;
  cin >> N;
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        ll ret = x * x + y * y + z * z + x * y + y * z + x * z;
        if (ret <= 10001)
          f[ret]++;
      }
    }
  }
  for (int i = 1; i <= N; i++)
    cout << f[i] << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<long long, long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

vecl f(10001);

int main() {
  int N;
  cin >> N;
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        ll ret = x * x + y * y + z * z + x * y + y * z + x * z;
        if (ret <= 10000)
          f[ret]++;
      }
    }
  }
  for (int i = 1; i <= N; i++)
    cout << f[i] << endl;
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cmath>
#include <cstdio>
using namespace std;

int main() {
  int n, cnt = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x, y, z;
    for (x = 1; x <= sqrt(i); x++) {
      for (y = 1; y <= sqrt(i); y++) {
        for (z = 1; z <= sqrt(i); z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            cnt++;
          }
        }
      }
    }
    printf("%d\n", cnt);
    cnt = 0;
  }

  return 0;
}

Fixed submission:
#include <cmath>
#include <cstdio>
using namespace std;

int main() {
  int n, cnt = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int a, b, c;
    for (a = -sqrt(2 * i); a <= sqrt(2 * i); a++) {
      for (b = -sqrt(2 * i); b <= sqrt(2 * i); b++) {
        if ((int)sqrt(2 * i - a * a - b * b) == sqrt(2 * i - a * a - b * b)) {
          c = sqrt(2 * i - a * a - b * b);
          if ((a - b) + c >= 2 && (b - c) + a >= 2 && (b - a) + c >= 2) {
            cnt++;
          }
        }
      }
    }
    printf("%d\n", cnt);
    cnt = 0;
  }

  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (i = 1; i <= n; i++)
// 2D::rep(i,j)rep(j,j)cin>>bin[i][j];
// vector<int> a(n)
#define Graph vector<vector<int>>
#define A1 cout << "No" << endl
#define A2 cout << "Yes" << endl
#define A3 cout << ans <<
#define AA(i) cout << i << endl;
const int U = 2e5 + 5;
const ll MOD = 1000000007;
const int INF = 1001001001;

int main() {
  int N;
  cin >> N;
  int i, j, k;
  vector<int> a(N + 1);
  rep(i, N) {
    rep(j, N) {
      rep(k, N) {
        int b = (i + j) * (i + j) + (j + k) * (j + k) + (k + i) * (k + i);
        if (b / 2 <= N)
          a[b / 2]++;
      }
    }
  }
  rep(i, N) AA(a[i]);
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (i = 1; i <= n; i++)
// 2D::rep(i,j)rep(j,j)cin>>bin[i][j];
// vector<int> a(n)
#define Graph vector<vector<int>>
#define A1 cout << "No" << endl
#define A2 cout << "Yes" << endl
#define A3 cout << ans <<
#define AA(i) cout << i << endl;
const int U = 2e5 + 5;
const ll MOD = 1000000007;
const int INF = 1001001001;

int main() {
  int N;
  cin >> N;
  int i, j, k;
  vector<int> a(N + 1);
  rep(i, 150) {
    rep(j, 150) {
      rep(k, 150) {
        int b = (i + j) * (i + j) + (j + k) * (j + k) + (k + i) * (k + i);
        if (b / 2 <= N)
          a[b / 2]++;
      }
    }
  }
  rep(i, N) AA(a[i]);
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):

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

typedef pair<int, int> P;
struct edge {
  int to, id;
};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007

using graph = vector<vector<ll>>;

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = 0;
    for (int j = 1; j < 100; j++) {
      for (int k = j; k < 100; k++) {
        for (int l = k; l < 100; l++) {
          if (((j + k) * (j + k) + (k + l) * (k + l) + (j + l) * (j + l)) /
                  2.0 ==
              i) {
            int x, y, z;
            int temp = j + k + l;
            x = temp / 2 - (k + l);
            y = temp / 2 - (j + l);
            z = temp / 2 - (k + j);
            if (x == y && y == z)
              ans++;
            else if (x == y && y != z)
              ans += 3;
            else if (x == z && y != z)
              ans += 3;
            else if (y == z && x != z)
              ans += 3;
            else
              ans += 6;
          }
        }
      }
    }
    cout << ans << endl;
  }
}

Fixed submission:

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

typedef pair<int, int> P;
struct edge {
  int to, id;
};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007

using graph = vector<vector<ll>>;

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = 0;
    for (int j = 1; j <= (int)sqrt(i); j++) {
      for (int k = j; k <= (int)sqrt(i); k++) {
        for (int l = k; l <= (int)sqrt(i); l++) {
          if (((j + k) * (j + k) + (k + l) * (k + l) + (j + l) * (j + l)) /
                  2.0 ==
              i) {
            int x, y, z;
            int temp = j + k + l;
            x = temp / 2 - (k + l);
            y = temp / 2 - (j + l);
            z = temp / 2 - (k + j);
            if (x == y && y == z)
              ans++;
            else if (x == y && y != z)
              ans += 3;
            else if (x == z && y != z)
              ans += 3;
            else if (y == z && x != z)
              ans += 3;
            else
              ans += 6;
          }
        }
      }
    }
    cout << ans << endl;
  }
}