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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int c[105][105];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      c[i][j] = (i + j) * (i + j);
    }
  }
  for (int i = 1; i <= n; i++) {
    int d = i << 1;
    int cnt = 0;
    for (int x = 1; x <= sqrt(i); x++) {
      for (int y = 1; y <= sqrt(i); y++) {
        for (int z = 1; z <= sqrt(i); z++) {
          if (c[x][y] + c[x][z] + c[y][z] == d)
            cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int c[105][105];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      c[i][j] = (i + j) * (i + j);
    }
  }
  for (int i = 1; i <= n; i++) {
    int d = i << 1;
    int cnt = 0;
    for (int x = 1; x <= sqrt(i); x++) {
      for (int y = x; y <= sqrt(i); y++) {
        for (int z = y; z <= sqrt(i); z++) {
          if (c[x][y] + c[x][z] + c[y][z] == d) {
            if (x == y && y == z)
              cnt++;
            else if (x != y && y != z && x != z)
              cnt += 6;
            else
              cnt += 3;
          }
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
Problem p02608 (C++)

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

using ll = long long;
using namespace std;
const int INFint = 1e9 + 1;
const ll INFll = (ll)1e18 + 1;
ll MOD = 1e9 + 7;

int main() {
  int N;
  cin >> N;
  int cnt[1001] = {0};
  for (int i(1); i <= 100; i++) {
    for (int j(1); j <= 100; j++) {
      for (int k(1); k <= 100; k++) {
        int x = i * i + j * j + k * k + i * j + j * k + k * i;
        if (x <= N) {
          cnt[x]++;
        }
      }
    }
  }
  for (int i(1); i <= N; i++) {
    cout << cnt[i] << endl;
  }
  return 0;
}


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

using ll = long long;
using namespace std;
const int INFint = 1e9 + 1;
const ll INFll = (ll)1e18 + 1;
ll MOD = 1e9 + 7;

int main() {
  int N;
  cin >> N;
  int cnt[10001] = {0};
  for (int i(1); i <= 100; i++) {
    for (int j(1); j <= 100; j++) {
      for (int k(1); k <= 100; k++) {
        int x = i * i + j * j + k * k + i * j + j * k + k * i;
        if (x <= N) {
          cnt[x]++;
        }
      }
    }
  }
  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>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll, ll>
#define all(v) (v).begin(), (v).end()

const ll mod = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void) {
  ll n;
  cin >> n;
  vector<ll> s(10050, 0);
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        ll x = i * i + j * j + k * k + i * j + j * k + k * i;
        // if(x > n) continue;
        s[x]++;
      }
    }
  }
  rep(i, n) cout << s[i + 1] << endl;
  return 0;
}

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

const ll mod = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void) {
  ll n;
  cin >> n;
  vector<ll> s(10050, 0);
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        ll x = i * i + j * j + k * k + i * j + j * k + k * i;
        if (x <= n)
          s[x]++;
      }
    }
  }
  rep(i, n) cout << s[i + 1] << endl;
  return 0;
}
Problem p02608 (C++)

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

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define rep3(i, m, n) for (int(i) = m; (i) <= (n); (i)++)
#define rep3rev(i, m, n) for (int(i) = m; (i) >= (n); (i)--)
#define all(a) (a.begin()), (a.end())
#define rall(a) (a.rbegin()), (a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

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

void Main() {
  int n;
  cin >> n;
  int m = sqrt(n + 1);
  vi ans(n + 1, 0);

  rep3(i, 1, m) rep3(j, 1, m) rep3(k, 1, m) {
    int now = f(i, j, k);
    ans[now]++;
  }

  rep3(i, 1, n) cout << ans[i] << endl;
  return;
}

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

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

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define rep3(i, m, n) for (int(i) = m; (i) <= (n); (i)++)
#define rep3rev(i, m, n) for (int(i) = m; (i) >= (n); (i)--)
#define all(a) (a.begin()), (a.end())
#define rall(a) (a.rbegin()), (a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

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

void Main() {
  int n;
  cin >> n;
  int m = sqrt(n + 1);
  vi ans(n + 1, 0);

  rep3(i, 1, m) rep3(j, 1, m) rep3(k, 1, m) {
    int now = f(i, j, k);
    if (0 < now && now <= n)
      ans[now]++;
  }

  rep3(i, 1, n) cout << ans[i] << endl;
  return;
}

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}
Problem p02608 (C++)

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

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

  vector<int> A(N);
  for (int x = 1; x * x < N; ++x) {
    for (int y = 1; x * x + y * y < N; ++y) {
      for (int z = 1; x + x + y * y + z * z < N; ++z) {
        int v = x * x + y * y + z * z + x * y + y * z + z * x;
        ++A[v - 1];
      }
    }
  }
  for (auto e : A)
    cout << e << "\n";
}


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

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

  vector<int> A(N);
  for (int x = 1; x * x < N; ++x) {
    for (int y = 1; x * x + y * y < N; ++y) {
      for (int z = 1; x + x + y * y + z * z < N; ++z) {
        int v = x * x + y * y + z * z + x * y + y * z + z * x;
        if (v > N)
          continue;
        ++A[v - 1];
      }
    }
  }
  for (auto e : A)
    cout << e << "\n";
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(), x.end()
#define rep(i, j, n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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;
}
//(a+b-1)/b

signed main() {
  ll n;
  cin >> n;
  vl v(1e7);
  for (ll i = 1; i <= n; i++) {
    for (ll j = 1; j <= n; j++) {
      for (ll k = 1; k <= n; k++) {
        ll h = (i + j + k);
        h *= h;
        h -= (i * j) + (j * k) + (i * k);
        if (h <= n)
          v[h]++;
      }
    }
  }
  rep(i, 1, n + 1) { cout << v[i] << endl; }

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(), x.end()
#define rep(i, j, n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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;
}
//(a+b-1)/b

signed main() {
  ll n;
  cin >> n;
  vl v(1e7);
  for (ll i = 1; i <= 100; i++) {
    for (ll j = 1; j <= 100; j++) {
      for (ll k = 1; k <= 100; k++) {
        ll h = (i + j + k);
        h *= h;
        h -= (i * j) + (j * k) + (i * k);
        if (h <= n)
          v[h]++;
      }
    }
  }
  rep(i, 1, n + 1) { cout << v[i] << endl; }

  return 0;
}
Problem p02608 (C++)

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

int main() {
  int n;
  cin >> n;
  vi cnt(n, 0);
  int c = sqrt(n) + 1;
  for (int x = 1; x <= c + 1; x++) {
    for (int y = 1; y <= c + 1; y++) {
      for (int z = 1; z <= c + 1; z++) {
        if (x * x + y * y + z * z + x * y + y * z + z * x <= n)
          cnt.at(x * x + y * y + z * z + x * y + y * z + z * x)++;
      }
    }
  }
  for (int x : cnt)
    cout << x << endl;
}

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

int main() {
  int n;
  cin >> n;
  vi cnt(n, 0);
  int c = sqrt(n) + 1;
  for (int x = 1; x <= c + 1; x++) {
    for (int y = 1; y <= c + 1; y++) {
      for (int z = 1; z <= c + 1; z++) {
        if (x * x + y * y + z * z + x * y + y * z + z * x <= n)
          cnt.at(x * x + y * y + z * z + x * y + y * z + z * x - 1)++;
      }
    }
  }
  for (int x : cnt)
    cout << x << endl;
}
Problem p02608 (C++)

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

int main() {
  ll n;
  cin >> n;
  map<ll, ll> mp;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        mp[i * i + j * j + k * k + i * j + j * k + k * i]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << mp[i] << endl;
  }
}

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

int main() {
  ll n;
  cin >> n;
  map<ll, ll> mp;
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        mp[i * i + j * j + k * k + i * j + j * k + k * i]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << mp[i] << endl;
  }
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n;
  vector<int> ans(10004, 0);
  cin >> n;
  for (int i = 1; i * i <= n; ++i) {
    for (int j = 1; j * j <= n; ++j) {
      for (int k = 1; k * k <= n; ++k) {
        int sum = i * i + j * j + k * k + i * j + j * k + k * i;
        ans[sum]++;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    cout << ans[i] << '\n';
  }

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n;
  vector<int> ans(10004, 0);
  cin >> n;
  for (int i = 1; i * i <= n; ++i) {
    for (int j = 1; j * j <= n; ++j) {
      for (int k = 1; k * k <= n; ++k) {
        int sum = i * i + j * j + k * k + i * j + j * k + k * i;
        if (sum <= 10000)
          ans[sum]++;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    cout << ans[i] << '\n';
  }

  return 0;
}
Problem p02608 (C++)

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

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

  int f[10001];
  for (int i = 1; i <= n; i++)
    f[i] = 0;

  for (int i = 0; i < 5; i++) {
    cout << 0 << endl;
    if (i + 1 >= n)
      break;
  }
  for (int i = 6; i <= n; i++) {
    for (int x = 1; x * x <= i; x++) {
      for (int y = 1; y * y <= i; y++) {
        for (int z = 1; z * z <= i; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i)
            f[i]++;
        }
      }
    }
    cout << f[i] << endl;
  }
}

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

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

  int f[10001];
  for (int i = 1; i <= n; i++)
    f[i] = 0;

  for (int i = 0; i < 5; i++) {
    cout << 0 << endl;
    if (i + 1 >= n)
      break;
  }
  for (int i = 6; i <= n; i++) {
    for (int x = 1; x * x < i; x++) {
      for (int y = 1; y * y <= i - x * x; y++) {
        double z =
            (-1 * (x + y) + sqrt(-3 * x * x - 3 * y * y - 2 * x * y + 4 * i)) /
            2;
        if (floor(z) == z && z > 0)
          f[i]++;
      }
    }
    cout << f[i] << endl;
  }
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for (ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl ans(n + 1, 0);
  rep2(x, 1, 101) rep2(y, 1, 101) rep2(z, 1, 101) {
    ll now = x * x + y * y + z * z + x * y + y * z + z * x;
    ans[now]++;
  }
  rep2(i, 1, n + 1) cout << ans[i] << '\n';
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for (ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl ans(n + 1, 0);
  rep2(x, 1, 101) rep2(y, 1, 101) rep2(z, 1, 101) {
    ll now = x * x + y * y + z * z + x * y + y * z + z * x;
    if (now <= n)
      ans[now]++;
  }
  rep2(i, 1, n + 1) cout << ans[i] << '\n';
}
Problem p02608 (C++)

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

int main() {
  vector<int> f(10000);
  int N;
  cin >> N;
  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 F = x * x + y * y + z * z + x * y + y * z + z * x;
        f[F - 1]++;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    cout << f[i] << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
  vector<int> f(60000);
  int N;
  cin >> N;
  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 F = x * x + y * y + z * z + x * y + y * z + z * x;
        f[F - 1]++;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    cout << f[i] << endl;
  }
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
//
// Created by 10940 on 2020/7/11.
//

#include <bits/stdc++.h>

using namespace std;
// #define LOCAL
int a[10005];

int fun(int num) {
  int ans = 0;
  for (int i = 1; i * i <= num; i++) {
    for (int j = 1; j * j <= num; j++) {
      for (int k = 1; k * k <= num; k++) {
        int re = i * i + j * j + k * k + i * j + j * k + i * k;
        if (re <= num) {
          a[re]++;
        }
      }
    }
  }
}

int main() {
  /*#ifdef LOCAL
      freopen("in.txt", "r", stdin);
      freopen("out.txt", "w", stdout);
  #endif*/
  int N;
  cin >> N;
  fun(N);
  for (int i = 1; i <= N; i++) {
    cout << a[i] << endl;
  }
  /*printf("Time used = %.3fs\n", (double) clock() / CLOCKS_PER_SEC);
  printf("Time used = %dms", clock());*/
  return 0;
}


Fixed submission:
//
// Created by 10940 on 2020/7/11.
//

#include <bits/stdc++.h>

using namespace std;
// #define LOCAL
int a[10005];

void fun(int num) {
  int ans = 0;
  for (int i = 1; i * i <= num; i++) {
    for (int j = 1; j * j <= num; j++) {
      for (int k = 1; k * k <= num; k++) {
        int re = i * i + j * j + k * k + i * j + j * k + i * k;
        if (re <= num) {
          a[re]++;
        }
      }
    }
  }
}

int main() {
  /*#ifdef LOCAL
      freopen("in.txt", "r", stdin);
      freopen("out.txt", "w", stdout);
  #endif*/
  int N;
  cin >> N;
  fun(N);
  for (int i = 1; i <= N; i++) {
    cout << a[i] << endl;
  }
  /*printf("Time used = %.3fs\n", (double) clock() / CLOCKS_PER_SEC);
  printf("Time used = %dms", clock());*/
  return 0;
}
Problem p02608 (C++)

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

int main() {
  int N, x, y, z, i;
  cin >> N;
  int count[1000000];
  for (i = 1; i <= N; i++) {
    count[i] = 0;
  }
  for (x = 1; x <= N; ++x) {
    for (y = 1; y <= N; ++y) {
      for (z = 1; z <= N; ++z) {
        count[x * x + y * y + z * z + x * y + x * z + y * z]++;
      }
    }
  }
  for (i = 1; i <= N; ++i) {
    cout << count[i] << endl;
  }
  return 0;
}


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

int main() {
  int N, x, y, z, i;
  cin >> N;
  int count[1000000];
  for (i = 1; i <= N; i++) {
    count[i] = 0;
  }
  for (x = 1; x <= 100; ++x) {
    for (y = 1; y <= 100; ++y) {
      for (z = 1; z <= 100; ++z) {
        count[x * x + y * y + z * z + x * y + x * z + y * z]++;
      }
    }
  }
  for (i = 1; i <= N; ++i) {
    cout << count[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) < (n); ++(i))

const int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  vector<int> vec1(n);
  int temp;
  int count = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      for (int k = j; k <= n; k++) {
        temp = i * i + j * j + k * k + i * j + j * k + i * k;
        if (i <= j && j <= k) {
          if (temp <= n) {
            if (i == j && j == k) {
              vec1[temp - 1]++;
            } else if (i == j || j == k || k == i) {
              vec1[temp - 1] += 3;
            } else {
              vec1[temp - 1] += 6;
            }
          }
        }
      }
    }
  }
  rep(i, n) cout << vec1[i] << endl;

  return 0;
}


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

const int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  vector<int> vec1(n);
  int temp;
  int count = 0;
  double sn = sqrt(n);
  for (int i = 1; i < sn; i++) {
    for (int j = i; j < sn; j++) {
      for (int k = j; k < sn; k++) {
        temp = i * i + j * j + k * k + i * j + j * k + i * k;
        if (i <= j && j <= k) {
          if (temp <= n) {
            if (i == j && j == k) {
              vec1[temp - 1]++;
            } else if (i == j || j == k || k == i) {
              vec1[temp - 1] += 3;
            } else {
              vec1[temp - 1] += 6;
            }
          }
        }
      }
    }
  }
  rep(i, n) cout << vec1[i] << endl;

  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int i, n, k, j, u;
int a[1010];
int main() {
  cin >> n;
  for (i = 1; i < sqrt(n); i++) {
    for (j = 1; j < sqrt(n); j++) {
      for (k = 1; k < sqrt(n); k++) {
        u = pow(i, 2) + pow(j, 2) + pow(k, 2) + i * j + i * k + j * k;
        if (u <= n)
          a[u]++;
      }
    }
  }
  for (i = 1; i <= n; i++)
    cout << a[i] << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int i, n, k, j, u;
int a[10010];
int main() {
  cin >> n;
  for (i = 1; i < sqrt(n); i++) {
    for (j = 1; j < sqrt(n); j++) {
      for (k = 1; k < sqrt(n); k++) {
        u = pow(i, 2) + pow(j, 2) + pow(k, 2) + i * j + i * k + j * k;
        if (u <= n)
          a[u]++;
      }
    }
  }
  for (i = 1; i <= n; i++)
    cout << a[i] << endl;
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define ll long long
#define eps 1e-7
#define all(x) ((x).begin()), ((x).end())
#define usecppio                                                               \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0);
using namespace std;
#define int ll
using pii = pair<int, int>;

int ans[10101];
int32_t main() {
  int n;
  cin >> n;
  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 u = x * x + y * y + z * z + x * y + y * z + z * x;
        ans[u]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << ans[i] << '\n';
}

Fixed submission:
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define ll long long
#define eps 1e-7
#define all(x) ((x).begin()), ((x).end())
#define usecppio                                                               \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0);
using namespace std;
#define int ll
using pii = pair<int, int>;

int ans[100101];
int32_t main() {
  int n;
  cin >> n;
  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 u = x * x + y * y + z * z + x * y + y * z + z * x;
        ans[u]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << ans[i] << '\n';
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;
int f[1010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        long long sum = i * i + j * j + k * k + i * j + i * k + j * k;
        if (sum <= n)
          f[(int)sum]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    printf("%d\n", f[i]);
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;
int f[10010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        long long sum = i * i + j * j + k * k + i * j + i * k + j * k;
        if (sum <= n)
          f[(int)sum]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    printf("%d\n", f[i]);
  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 < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww {
  cww() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
} star;
const long long INF = numeric_limits<long long>::max();
int main() {
  int N;
  cin >> N;
  // 愚直に探す
  // N<10000よりx<=y<=zとするとxは最高でも100

  int ans = 0;

  for (int i = 1; i <= N; i++) {
    ans = 0;
    for (int x = 1; x <= 100; x++) {
      for (int y = x; y <= 100; y++) {

        for (int z = y; z <= 100; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            if (x == y && y == z) {
              ans++;
            } else if (x != y && y == z) {
              ans += 3;
            } else if (x == y && y != z) {
              ans += 3;
            } else {
              ans += 6;
            }
          } else if (x * x + y * y + z * z + x * y + y * z + z * x > i) {
            continue;
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww {
  cww() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
} star;
const long long INF = numeric_limits<long long>::max();
int main() {
  int N;
  cin >> N;
  // 愚直に探す
  // N<10000よりx<=y<=zとするとxは最高でも100

  int ans = 0;

  for (int i = 1; i <= N; i++) {
    ans = 0;
    for (int x = 1; x <= 100; x++) {
      for (int y = x; y <= 100; y++) {

        for (int z = y; z <= 100; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            if (x == y && y == z) {
              ans++;
            } else if (x != y && y == z) {
              ans += 3;
            } else if (x == y && y != z) {
              ans += 3;
            } else {
              ans += 6;
            }
          } else if (x * x + y * y + z * z + x * y + y * z + z * x > i) {
            break;
          }
        }
      }
    }
    cout << ans << 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, x, n) for (int i = x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
// struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;

int main() {
  int n;
  scanf("%d", &n);

  int x = 1;
  int y = 1;
  int z = 1;
  int num;
  int max;
  int ans;
  for (int i = 1; i <= n; ++i) {
    max = (int)sqrtf(n - 5) + 2;
    num = 0;

    for (x = 1; x <= max; ++x) {
      for (y = 1; y <= x; ++y) {
        for (z = 1; z <= y; ++z) {
          ans = x * x + y * y + z * z + x * y + y * z + z * x;
          if (ans == i) {
            if (x == y && y == z) {
              ++num;
            } else if (x == y && y != z) {
              num += 3;
            } else if (x != y && y == z) {
              num += 3;
            } else {
              num += 6;
            }
          } else if (ans > i) {
            continue;
          }
        }
      }
    }
    printf("%d\n", num);
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, x, n) for (int i = x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
// struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;

int main() {
  int n;
  scanf("%d", &n);

  int x = 1;
  int y = 1;
  int z = 1;
  int num;
  int max;
  int ans;
  for (int i = 1; i <= n; ++i) {
    max = (int)sqrtf(n - 5) + 2;
    num = 0;

    for (x = 1; x <= max; ++x) {
      for (y = 1; y <= x; ++y) {
        for (z = 1; z <= y; ++z) {
          ans = x * x + y * y + z * z + x * y + y * z + z * x;
          if (ans == i) {
            if (x == y && y == z) {
              ++num;
            } else if (x == y && y != z) {
              num += 3;
            } else if (x != y && y == z) {
              num += 3;
            } else {
              num += 6;
            }
          } else if (ans > i) {
            break;
          }
        }
      }
    }
    printf("%d\n", num);
  }
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
// It doesn't matter as long as you rise to the top - Katsuki Bakugo
#include <bits/stdc++.h>
using namespace std;

#define Fast_as_duck                                                           \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define forn(i, st, n) for (int i = st; i < n; i++)
#define rev(i, st, n) for (int i = st; i >= n; i--)
#define ss second
#define ff first
#define ll long long

typedef pair<int, int> pii;

const int N = 1e5 + 10, mod = 1000000007;

void solve() {

  int num;
  cin >> num;

  forn(n, 1, num + 1) {

    int ans = 0;

    forn(x, 1, n) {
      forn(y, 1, n) {

        ll c = (ll)n - x * x - y * y - x * y;
        ll b = (x + y);
        ll d = b * b + 4 * c;
        ll rootd = sqrt(d);
        if (rootd * rootd != d) {
          continue;
        }
        if (rootd > b && (rootd - b) % 2 == 0)
          ans++;
        // forn(z,1,n){
        //     if(x*x + y*y + z*z + x*y + y*z + z*x == n ){
        //         ans++;
        //     }
        //     if(x*x + y*y + z*z + x*y + y*z + z*x > n ){
        //         break;
        //     }

        // }
      }
    }

    cout << ans << "\n";
  }
}

int main() {
  Fast_as_duck;

  /*
      #ifndef ONLINE_JUDGE
          freopen("input.txt", "r", stdin);
          freopen("output.txt", "w", stdout);
      #endif
  */
  int t = 1;

  // cin >> t;

  while (t--) {
    solve();
  }

  return 0;
}


Fixed submission:
// It doesn't matter as long as you rise to the top - Katsuki Bakugo
#include <bits/stdc++.h>
using namespace std;

#define Fast_as_duck                                                           \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define forn(i, st, n) for (int i = st; i < n; i++)
#define rev(i, st, n) for (int i = st; i >= n; i--)
#define ss second
#define ff first
#define ll long long

typedef pair<int, int> pii;

const int N = 1e5 + 10, mod = 1000000007;

void solve() {

  int num;
  cin >> num;

  forn(n, 1, num + 1) {

    int ans = 0;

    forn(x, 1, sqrt(n)) {
      forn(y, 1, sqrt(n)) {

        ll c = (ll)n - x * x - y * y - x * y;
        ll b = (x + y);
        ll d = b * b + 4 * c;
        ll rootd = sqrt(d);
        if (rootd * rootd != d) {
          continue;
        }
        if (rootd > b && (rootd - b) % 2 == 0)
          ans++;
        // forn(z,1,n){
        //     if(x*x + y*y + z*z + x*y + y*z + z*x == n ){
        //         ans++;
        //     }
        //     if(x*x + y*y + z*z + x*y + y*z + z*x > n ){
        //         break;
        //     }

        // }
      }
    }

    cout << ans << "\n";
  }
}

int main() {
  Fast_as_duck;

  /*
      #ifndef ONLINE_JUDGE
          freopen("input.txt", "r", stdin);
          freopen("output.txt", "w", stdout);
      #endif
  */
  int t = 1;

  // cin >> t;

  while (t--) {
    solve();
  }

  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int x = 1; x <= floor(sqrt(n)); x++) {
      for (int y = 1; y <= floor(sqrt(n - x * x)); y++) {
        for (int z = 1; z <= floor(sqrt(n - x * x - y * y - x * y)); z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i)
            ans++;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int x = 1; x * x + 2 * x + 3 <= i; x++) {
      for (int y = 1; x * x + y * y + 1 + x * y + y + x <= i; y++) {
        for (int z = 1; x * x + y * y + z * z + x * y + y * z + z * x <= i;
             z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i)
            ans++;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p02608 (C++)

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

int main() {
  int N;
  cin >> N;
  vector<int64_t> f(N);
  for (int i = 0; i < N; i++) {
    f.at(i) = 0;
  }
  for (int j = 1; j < 101; j++) {
    for (int k = 1; k < 101; k++) {
      for (int l = 1; l < 101; l++) {
        if (j * j + k * k + l * l + j * k + k * l + l * j <= N) {
          f.at(j * j + k * k + l * l + j * k + k * l + l * j) =
              f.at(j * j + k * k + l * l + j * k + k * l + l * j) + 1;
        }
      }
    }
  }
  for (int n = 0; n < N; n++) {
    cout << f.at(n) << endl;
  }
}


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

int main() {
  int N;
  cin >> N;
  vector<int64_t> f(N);
  for (int i = 0; i < N; i++) {
    f.at(i) = 0;
  }
  for (int j = 1; j < 101; j++) {
    for (int k = 1; k < 101; k++) {
      for (int l = 1; l < 101; l++) {
        if (j * j + k * k + l * l + j * k + k * l + l * j <= N) {
          f.at(j * j + k * k + l * l + j * k + k * l + l * j - 1) =
              f.at(j * j + k * k + l * l + j * k + k * l + l * j - 1) + 1;
        }
      }
    }
  }
  for (int n = 0; n < N; n++) {
    cout << f.at(n) << endl;
  }
}
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 < n; i++)
#define REP(i, n) for (int i = 1; i <= n; i++)
typedef long long ll;

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

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = 1; i <= n; i++)
typedef long long ll;

int main() {
  ll n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    ll ans = 0;
    for (int x = 1; x * x <= i; ++x) {
      for (int y = x; y * y <= i; ++y) {
        for (int z = y; z * z <= i; ++z) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            if (x == y && z == y) {
              ans++;
            } else if (x != y && z != y && x != z) {
              ans += 6;
            } else {
              ans += 3;
            }
          }
        }
      }
    }
    cout << ans << 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> vec(n + 1, 0);

  for (int i = 1; i <= 100; ++i) {
    for (int j = 1; j <= 100; ++j) {
      for (int k = 1; k <= 100; ++k) {
        int tmp = pow(i, 2) + pow(j, 2) + pow(k, 2) + i * j + j * k + k * i;
        if (n <= 10001)
          ++vec[tmp];
      }
    }
  }

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

  return 0;
}


Fixed submission:

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

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

  vector<int> vec(n + 1, 0);

  for (int i = 1; i <= 100; ++i) {
    for (int j = 1; j <= 100; ++j) {
      for (int k = 1; k <= 100; ++k) {
        int tmp = pow(i, 2) + pow(j, 2) + pow(k, 2) + i * j + j * k + k * i;
        if (tmp <= 10000)
          ++vec[tmp];
      }
    }
  }

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

  return 0;
}
Problem p02608 (C++)

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

int main() {
  int N;

  cin >> N;

  int ans[10001];

  for (int i = 0; i < 10100; i++) {
    ans[i] = 0;
  }

  int v;

  for (int x = 1; x <= 101; x++) {
    for (int y = 1; y <= 101; y++) {
      for (int z = 1; z <= 101; z++) {
        v = x * x + y * y + z * z + x * y + y * z + z * x;

        if (v < 10100) {
          ans[v] += 1;
        }
      }
    }
  }

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

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

int main() {
  int N;

  cin >> N;

  int ans[10100];

  for (int i = 0; i < 10100; i++) {
    ans[i] = 0;
  }

  int v;

  for (int x = 1; x <= 101; x++) {
    for (int y = 1; y <= 101; y++) {
      for (int z = 1; z <= 101; z++) {
        v = x * x + y * y + z * z + x * y + y * z + z * x;

        if (v < 10100) {
          ans[v] += 1;
        }
      }
    }
  }

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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x)                                                             \
  for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
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 long long INFLL = 1LL << 60;
const int INF = 1 << 30;
const double PI = acos(-1);
int main() {
  int n;
  cin >> n;
  Vi ans(n + 2, 0);
  for (int x = 1; x <= sqrt(n); x++) {
    for (int y = 1; y <= sqrt(n); y++) {
      for (int z = 1; z <= sqrt(n); z++) {
        ans[x * x + y * y + z * z + z * y + y * x + z * x]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
  // cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x)                                                             \
  for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
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 long long INFLL = 1LL << 60;
const int INF = 1 << 30;
const double PI = acos(-1);
int main() {
  int n;
  cin >> n;
  Vi ans(n + 2, 0);
  for (int x = 1; x <= sqrt(n); x++) {
    for (int y = 1; y <= sqrt(n); y++) {
      for (int z = 1; z <= sqrt(n); z++) {
        if (x * x + y * y + z * z + z * y + y * x + z * x > n) {
          continue;
        }
        ans[x * x + y * y + z * z + z * y + y * x + z * x]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
  // cout << ans << endl;
}
Problem p02608 (C++)

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

int n, ans[10001];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i * i <= n; i++)
    for (int j = 1; j * j <= n; j++)
      for (int k = 1; k * k <= n; k++)
        ans[i * i + j * j + k * k + i * j + j * k + i * k]++;
  for (int i = 1; i <= n; i++)
    cout << ans[i] << '\n';
  return 0;
}


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

int n, ans[10001];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i * i <= n; i++)
    for (int j = 1; j * j <= n; j++)
      for (int k = 1; k * k <= n; k++) {
        int val = i * i + j * j + k * k + i * j + j * k + i * k;
        if (val <= n)
          ans[val]++;
      }
  for (int i = 1; i <= n; i++)
    cout << ans[i] << '\n';
  return 0;
}
Problem p02608 (C++)

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

int main() {
  int x, y, z;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int counter = 0;

    for (x = 1; x < 100; x++) {
      for (y = x; y < 100; y++) {
        for (z = y; z < 100; z++) {
          if (i == x * x + y * y + z * z + x * y + y * z + z * x && x == y &&
              y == z)
            counter = counter + 1;
          else if (i == x * x + y * y + z * z + x * y + y * z + z * x &&
                   x == y && y != z)
            counter = counter + 3;
          else if (i == x * x + y * y + z * z + x * y + y * z + z * x &&
                   x != y && y == z)
            counter = counter + 3;
          else if (i == x * x + y * y + z * z + x * y + y * z + z * x)
            counter = counter + 6;
        }
      }
    }
    cout << counter << endl;
  }
}


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

int main() {
  int x, y, z;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int counter = 0;

    for (x = 1; x <= 41; x++) {
      for (y = x; y < 100; y++) {
        for (z = y; z < 100; z++) {
          if (i == x * x + y * y + z * z + x * y + y * z + z * x && x == y &&
              y == z)
            counter = counter + 1;
          else if (i == x * x + y * y + z * z + x * y + y * z + z * x &&
                   x == y && y != z)
            counter = counter + 3;
          else if (i == x * x + y * y + z * z + x * y + y * z + z * x &&
                   x != y && y == z)
            counter = counter + 3;
          else if (i == x * x + y * y + z * z + x * y + y * z + z * x)
            counter = counter + 6;
        }
      }
    }
    cout << counter << endl;
  }
}
Problem p02608 (C++)

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

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

  // f(n)の個数を調べる
  for (int i = 1; i <= n; i++) {
    int count = 0;
    // x, y, z全探索してnと合致しているか調べる
    for (int j = 1; j <= i; j++) {
      for (int k = 1; k <= i; k++) {
        for (int l = 1; l <= i; l++) {
          int a = j * j + k * k + l * l + j * k + k * l + l * j;
          if (a == i) {
            // cout << a << n << j << k << l << endl;
            count++;
          } else if (a > i)
            break;
        }
      }
    }
    cout << count << endl;
  }
}

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

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

  // f(n)の個数を調べる
  for (int i = 1; i <= n; i++) {
    int count = 0;
    // x, y, z全探索してnと合致しているか調べる
    for (int j = 1; j <= 105; j++) {
      for (int k = 1; k <= 105; k++) {
        for (int l = 1; l <= 105; l++) {
          int a = j * j + k * k + l * l + j * k + k * l + l * j;
          if (a == i) {
            // cout << a << n << j << k << l << endl;
            count++;
          } else if (a > i)
            break;
        }
      }
    }
    cout << count << endl;
  }
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mp make_pair
#define S second
#define F first
ll mod = 1e9 + 7;
#define fastIO                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);
#define input_from_file freopen("input.txt", "r", stdin);
using namespace std::chrono;

int main() {
  // input_from_file
  fastIO ll n;
  cin >> n;
  vector<ll> vec(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        ll x = i * i + j * j + k * k + i * j + j * k + k * i;
        if (x > n)
          continue;
        vec[x]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << vec[i] << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mp make_pair
#define S second
#define F first
ll mod = 1e9 + 7;
#define fastIO                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);
#define input_from_file freopen("input.txt", "r", stdin);
using namespace std::chrono;

int main() {
  // input_from_file
  fastIO ll n;
  cin >> n;
  vector<ll> vec(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        ll x = i * i + j * j + k * k + i * j + j * k + k * i;
        if (x > n)
          break;
        vec[x]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << vec[i] << 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)
using namespace std;
using ll = long long;
using vi = vector<int>;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int x = 1; x <= n; ++x) {
    int cnt = 0;
    for (int i = 1; i <= x; ++i) {
      for (int j = 1; j <= x; ++j) {
        if (((i * i) + (j * j) + 1 + (i * j) + j + i) > x)
          break;
        for (int k = 1; k <= x; ++k) {
          if (((i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i)) > x)
            break;
          if (((i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i)) == x)
            ++cnt;
        }
      }
    }
    cout << cnt << "\n";
  }
  return 0;
}

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 vi = vector<int>;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int x = 1; x <= n; ++x) {
    int cnt = 0;
    for (int i = 1; i <= x; ++i) {
      if (((i * i) + 1 + 1 + i + 1 + i) > x)
        break;
      for (int j = 1; j <= x; ++j) {
        if (((i * i) + (j * j) + 1 + (i * j) + j + i) > x)
          break;
        for (int k = 1; k <= x; ++k) {
          if (((i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i)) > x)
            break;
          if (((i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i)) == x)
            ++cnt;
        }
      }
    }
    cout << cnt << "\n";
  }
  return 0;
}
Problem p02608 (C++)

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

int main() {
  int a, b, c, d, e, x, y, z = 0;
  cin >> a;
  if (a <= 5) {
    for (int i = 0; i < a; i++) {
      cout << 0 << endl;
    }
  } else {
    for (int i = 0; i < 5; i++) {
      cout << 0 << endl;
    }
    for (int i = 6; i <= a; i++) {
      c = 96;
      for (x = 1; x <= c; x++) {
        for (y = 1; y <= x; y++) {
          for (z = 1; z <= y; z++) {
            if (x * x + y * y + z * z + x * y + y * z + x * z == i) {
              if (x == y && y == z) {
                e++;
              } else if (x != y && y != z) {
                e += 6;
              } else {
                e += 3;
              }
            }
          }
        }
      }
      cout << e << endl;
      e = 0;
    }
  }
}

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

int main() {
  int a, b, c, d, e, x, y, z = 0;
  cin >> a;
  if (a <= 5) {
    for (int i = 0; i < a; i++) {
      cout << 0 << endl;
    }
  } else {
    for (int i = 0; i < 5; i++) {
      cout << 0 << endl;
    }
    for (int i = 6; i <= a; i++) {
      c = sqrt(i);
      for (x = 1; x <= c; x++) {
        for (y = 1; y <= x; y++) {
          for (z = 1; z <= y; z++) {
            if (x * x + y * y + z * z + x * y + y * z + x * z == i) {
              if (x == y && y == z) {
                e++;
              } else if (x != y && y != z) {
                e += 6;
              } else {
                e += 3;
              }
            }
          }
        }
      }
      cout << e << endl;
      e = 0;
    }
  }
}