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

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

#define INF ((i64)(1e18))
#define MOD ((i64)(1e9 + 7))
#define REP(i, n) for (i64 i = 0; i < (n); i++)
#define RREP(i, n) for (i64 i = (n)-1; i >= 0; i--)
#define RANGE(i, a, b) for (i64 i = (a); i < (b); i++)
#define RRANGE(i, a, b) for (i64 i = (b)-1; i >= (a); i--)
#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) ((i64)(v).size())
template <class T> inline void chmax(T &a, const T &b) {
  if (a < b)
    a = b;
}
template <class T> inline void chmin(T &a, const T &b) {
  if (a > b)
    a = b;
}

int main() {
  i64 n;
  cin >> n;
  RANGE(i, 1, n + 1) {
    i64 ans = 0;
    RANGE(x, 1, 100) {
      RANGE(y, 1, 100) {
        RANGE(z, 1, 100) {
          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;
using i64 = int_fast64_t;

#define INF ((i64)(1e18))
#define MOD ((i64)(1e9 + 7))
#define REP(i, n) for (i64 i = 0; i < (n); i++)
#define RREP(i, n) for (i64 i = (n)-1; i >= 0; i--)
#define RANGE(i, a, b) for (i64 i = (a); i < (b); i++)
#define RRANGE(i, a, b) for (i64 i = (b)-1; i >= (a); i--)
#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) ((i64)(v).size())
template <class T> inline void chmax(T &a, const T &b) {
  if (a < b)
    a = b;
}
template <class T> inline void chmin(T &a, const T &b) {
  if (a > b)
    a = b;
}

int main() {
  i64 n;
  cin >> n;
  RANGE(i, 1, n + 1) {
    i64 ans = 0;
    RANGE(x, 1, 99) {
      RANGE(y, x, 99) {
        RANGE(z, y, 99) {
          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
              ans += 6;
          }
        }
      }
    }
    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> ans(N + 1);
  for (int x = 1; x * x <= N; ++x) {
    for (int y = 1; y * y <= N; ++y) {
      for (int z = 1; z * z <= N; ++z) {
        ++ans[x * x + y * y + z * z + x * y + y * z + z * x];
      }
    }
  }

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


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

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

  vector<int> ans(N + 1);
  for (long long x = 1; x * x <= N; ++x) {
    for (long long y = 1; y * y <= N; ++y) {
      for (long long z = 1; z * z <= N; ++z) {
        if (1 <= x * x + y * y + z * z + x * y + y * z + z * x &&
            x * x + y * y + z * z + x * y + y * z + z * x <= N) {
          ++ans[x * x + y * y + z * z + x * y + y * z + z * x];
        }
      }
    }
  }

  for (int i = 1; i <= N; ++i) {
    cout << ans[i] << endl;
  }
}
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 * 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;
  }
}


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 <= i; x++) {
      for (int y = 1; y * y <= i; y++) {
        int b = x + y;
        int c = x * x + x * y + y * y - i;
        int r = b * b - 4 * c;
        if (r < 0)
          continue;
        double sr = sqrt(r);
        if (sr != floor(sr))
          continue;
        int rr = sr;
        int z1 = (-b + rr) / 2;
        if (z1 >= 1) {
          ans++;
        }
        int z2 = (-b - rr) / 2;
        if (z2 >= 1) {
          ans++;
        }
      }
    }
    cout << ans << endl;
  }
}
Problem p02608 (Python)

Buggy submission (status: Runtime Error):
N = int(input())

cnt = [0] * 6 * 10000 + 1

for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            cnt[x**2 + y**2 + z**2 + x * y + y * z + z * x] += 1

for i in range(1, N + 1):
    print(cnt[i])


Fixed submission:
N = int(input())

cnt = [0] * (6 * 10000 + 1)

for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            cnt[x**2 + y**2 + z**2 + x * y + y * z + z * x] += 1

for i in range(1, N + 1):
    print(cnt[i])
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define pii pair<ll, ll>
using namespace std;
#define N 100007
#define pb push_back;
vector<ll> g[N];
#define FAST                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);

int main() {
  FAST;
  ll n;
  cin >> n;
  ll i, j, k, l, cnt = 0;
  for (i = 1; i <= n; i++) {
    cnt = 0;
    for (j = 1; j <= sqrt(i); j++) {
      for (k = 1; k <= sqrt(i); k++) {
        for (l = 1; l <= sqrt(i); l++) {
          //  cout<<j<<" "<<k<<" "<<l<<" "<<(j*j+k*k+l*l+j*k+k*l+j*l)<<endl;
          if ((j * j + k * k + l * l + j * k + k * l + j * l) == i) {
            cnt++;
          }
        }
      }
    }
    cout << cnt << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define pii pair<ll, ll>
using namespace std;
#define N 100007
#define pb push_back;
vector<ll> g[N];
#define FAST                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);

int main() {
  FAST;
  ll n;
  cin >> n;
  ll i, j, k, l, cnt = 0;
  for (i = 1; i <= n; i++) {
    cnt = 0;
    for (j = 1; j <= 100; j++) {
      for (k = 1; k <= 100; k++) {
        ll b = -(k + j);
        ll x = b * b - 4 * (k * k + j * j + k * j - i);
        if (x < 0) {
          continue;
        }
        ll sqrtt = sqrt(x);
        if (sqrtt * sqrtt == x) {
          x = b + sqrtt;
          //  cout<<j<<" "<<k<<" "<<x<<" "<<sqrtt<<" "<<i<<endl;
          if (x % 2 == 0 && (x / 2) >= 1) {
            cnt++;
          }
        }
      }
    }
    cout << cnt << endl;
  }
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
  int N, x, y, z, i, j, k, l, ans = 0;
  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    for (j = 0; j < (N / 6); j++) {
      x = j + 1;
      for (k = j; k < (N - x * x) / 6; k++) {
        y = k + 1;
        for (l = k; l < (N - x * x - y * y) / 6; l++) {
          z = l + 1;
          if ((x * x + y * y + z * z + x * y + y * z + z * x) == (i + 1)) {
            if (x != y && y != z && z != x) {
              ans += 6;
            } else {
              if (x == y && y == z) {
                ans++;
              } else {
                ans += 3;
              }
            }
          }
        }
      }
    }
    printf("%d\n", ans);
    ans = 0;
  }
  return 0;
}


Fixed submission:
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
  int N, x, y, z, i, j, k, l, ans = 0;
  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    for (j = 0; j < (N / 6); j++) {
      x = j + 1;
      for (k = j; k < (N - x * x) / 6; k++) {
        y = k + 1;
        for (l = k; l < (N - x * x - y * y) / 6; l++) {
          z = l + 1;
          if ((x * x + y * y + z * z + x * y + y * z + z * x) > (i + 1)) {
            break;
            break;
            break;
          }
          if ((x * x + y * y + z * z + x * y + y * z + z * x) == (i + 1)) {
            if (x != y && y != z && z != x) {
              ans += 6;
            } else {
              if (x == y && y == z) {
                ans++;
              } else {
                ans += 3;
              }
            }
          }
        }
      }
    }
    printf("%d\n", ans);
    ans = 0;
  }
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
// Delete the dynamically allocated memory

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

#define ff first
#define ss second
#define pb push_back
#define pr pair<long long, long long>
#define mp(a, b) make_pair(a, b)
#define vr vector<long long>
#define mod1 1000000007
#define mod2 998244353
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define fill(a, b) memset(a, b, sizeof(a))
#define mk(arr, n, type) type *arr = new type[n];
#define ll long long
#define ld long double
#define w(x)                                                                   \
  int x;                                                                       \
  cin >> x;                                                                    \
  while (x--)
ll power(ll base, ll exp) {
  ll res = 1;
  while (exp > 0) {
    if (exp % 2 == 1)
      res = (res * base);
    base = (base * base);
    exp /= 2;
  }
  return res;
}
int main() {
  ll n;
  cin >> n;
  mk(arr, n, ll) for (ll i = 0; i < n; i++) { arr[i] = 0; }
  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 v = (i + j) * (i + j) + (i + k) * (i + k) + (j + k) * (j + k);
        if (v % 2 == 0) {
          v = v / 2;
          arr[v - 1]++;
        }
      }
    }
  }
  for (ll i = 0; i < n; i++) {
    cout << arr[i] << "\n";
  }
  delete[] arr;
  return 0;
}

Fixed submission:
// Delete the dynamically allocated memory

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

#define ff first
#define ss second
#define pb push_back
#define pr pair<long long, long long>
#define mp(a, b) make_pair(a, b)
#define vr vector<long long>
#define mod1 1000000007
#define mod2 998244353
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define fill(a, b) memset(a, b, sizeof(a))
#define mk(arr, n, type) type *arr = new type[n];
#define ll long long
#define ld long double
#define w(x)                                                                   \
  int x;                                                                       \
  cin >> x;                                                                    \
  while (x--)
ll power(ll base, ll exp) {
  ll res = 1;
  while (exp > 0) {
    if (exp % 2 == 1)
      res = (res * base);
    base = (base * base);
    exp /= 2;
  }
  return res;
}
int main() {
  ll n;
  cin >> n;
  mk(arr, n, ll) for (ll i = 0; i < n; i++) { arr[i] = 0; }
  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 v = (i + j) * (i + j) + (i + k) * (i + k) + (j + k) * (j + k);
        if (v % 2 == 0) {
          v = v / 2;
          if (v <= n) {
            arr[v - 1]++;
          }
        }
      }
    }
  }
  for (ll i = 0; i < n; i++) {
    cout << arr[i] << "\n";
  }
  delete[] arr;
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
// C++ program to demonstrate __builtin_popcount()
#include <iostream>
#include <math.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  int ans[60000] = {0};
  for (int i = 1; i <= (n ^ (1 / 2)); i++) {
    for (int j = 1; j <= (n ^ (1 / 2)); j++) {
      for (int k = 1; k <= (n ^ (1 / 2)); k++) {
        ans[i * i + j * j + k * k + i * j + j * k + k * i]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << ans[i] << "\n";
  return 0;
}


Fixed submission:
// C++ program to demonstrate __builtin_popcount()
#include <iostream>
#include <math.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  int ans[60000] = {0};
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        ans[i * i + j * j + k * k + i * j + j * k + k * i]++;
      }
    }
  }
  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;

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

// #define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int f(int n) {
  int count = 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) {
          count++;
        }
      }
    }
  }

  return count;
}

int main() {
  std::cout << std::fixed << std::setprecision(10);

  ll N;

  cin >> N;

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


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

// #define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int f(int n) {
  int count = 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) {
          count++;
        } else if ((x * x + y * y + z * z + x * y + y * z + z * x) > n) {
          break;
        }
      }
    }
  }

  return count;
}

int main() {
  std::cout << std::fixed << std::setprecision(10);

  ll N;

  cin >> N;

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
typedef long long int ll;
typedef unsigned long long ull;
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;
}
typedef pair<ll, ll> P;
const long long MOD = 1e9 + 7;
const ll INF = 1LL << 60;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int triplets(int x) {
  int cnt = 0;
  for (int i = 1; i <= (int)(1e2); i++) {
    for (int j = 1; j <= (int)(1e2); j++) {
      for (int k = 1; k <= (int)(1e2); k++) {
        if (i * i + j * j + k * k + i * j + j * k + k * i == x)
          cnt++;
      }
    }
  }
  return cnt;
}

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

  for (int i = 1; i <= n; i++) {
    cout << triplets(i) << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
typedef long long int ll;
typedef unsigned long long ull;
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;
}
typedef pair<ll, ll> P;
const long long MOD = 1e9 + 7;
const ll INF = 1LL << 60;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int triplets(int x) {
  int cnt = 0;
  for (int i = 1; i <= (int)(1e2); i++) {
    for (int j = 1; j <= (int)(1e2); j++) {
      for (int k = 1; k <= (int)(1e2); 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++;
      }
    }
  }
  return cnt;
}

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

  for (int i = 1; i <= n; i++) {
    cout << triplets(i) << endl;
  }
}
Problem p02608 (C++)

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

int main() {
  ll n;
  cin >> n;
  ll sum = 0;
  vector<ll> ans(n, 0);
  for (int x = 1; x <= n; x++) {
    for (int y = 1; y <= n; y++) {
      for (int z = 1; z <= n; z++) {
        sum = (x + y + z) * (x + y + z) - (x * y + y * z + z * x);
        if (sum > n)
          continue;
        ans[sum - 1]++;
      }
    }
  }
  rep(i, n) { cout << ans[i] << endl; }
  return 0;
}

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

int main() {
  ll n;
  cin >> n;
  ll sum = 0;
  vector<ll> ans(n, 0);
  for (int x = 1; x <= n; x++) {
    for (int y = 1; y <= n; y++) {
      for (int z = 1; z <= n; z++) {
        sum = (x + y + z) * (x + y + z) - (x * y + y * z + z * x);
        if (sum > n)
          break;
        ans[sum - 1]++;
      }
    }
  }
  rep(i, n) { cout << ans[i] << endl; }
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> ans(n, 0);
  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 f = i * i + j * j + k * k + i * j + j * k + k * i;
        ans[f - 1]++;
      }

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

Fixed submission:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> ans(n, 0);
  for (int i = 1; i * i <= n; i++)
    for (int j = 1; j * j <= n; j++)
      for (int k = 1; k * k <= n; k++) {
        long long f = i * i + j * j + k * k + i * j + j * k + k * i;
        if (f <= n)
          ans[f - 1]++;
      }

  for (int i = 0; i < n; i++)
    cout << ans[i] << endl;
}
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;

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

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

  for (int n = 1; n <= N; n++) {
    ll m = sqrt(n);

    int ans = 0;
    rep(x, m) rep(y, m) rep(z, m) {
      if (x == 0 || y == 0 || z == 0)
        continue;
      if (f(x, y, z) == n)
        ans++;
    }

    cout << ans << endl;
  }

  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;

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

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

  for (int n = 1; n <= N; n++) {
    ll m = sqrt(n);

    int ans = 0;

    int ans1 = 0;
    for (int x = 1; x <= m; x++)
      for (int y = x + 1; y <= m; y++)
        for (int z = y + 1; z <= m; z++) {
          if (x == 0 || y == 0 || z == 0)
            continue;
          ll res = f(x, y, z);
          if (res > n)
            break;
          if (res == n)
            ans1++;
        }
    ans += 6 * ans1;

    int ans2 = 0;
    for (int x = 1; x <= m; x++)
      for (int y = 1; y <= m; y++) {
        if (x == y)
          continue;
        ll res = x * x + 3 * y * y + 2 * x * y;
        if (res > n)
          break;
        if (res == n)
          ans2++;
      }
    ans += 3 * ans2;

    if (n % 6 == 0) {
      int ans3 = 0;
      for (int x = 1; x <= m; x++) {
        if (x * x == n / 6)
          ans3++;
      }
      ans += ans3;
    }

    cout << ans << endl;
  }

  return 0;
}
Problem p02608 (Python)

Buggy submission (status: Time Limit Exceeded):
import math

N = int(input())

for n in range(1, N + 1):
    count = 0
    ub = int(math.sqrt(n))
    for x in range(1, ub + 1):
        for y in range(x, ub + 1):
            for z in range(y, ub + 1):
                if x * x + y * y + z * z + x * y + y * z + z * x == n:
                    s = len(set([x, y, z]))
                    if s == 1:
                        count += 1
                    elif s == 2:
                        count += 3
                    else:
                        count += 6
                    break
    print(count)


Fixed submission:
import math

N = int(input())

for n in range(1, N + 1):
    count = 0
    ub = int(math.sqrt(n))
    for x in range(1, ub + 1):
        for y in range(x, ub + 1):
            r = 4 * n - 3 * x * x - 2 * x * y - 3 * y * y
            if r < 0:
                break
            z = (math.sqrt(r) - x - y) / 2
            if z - int(z) < 1e-9:
                z = int(z)
            elif z - int(z + 1) < 1e-9:
                z = int(z + 1)
            else:
                break

            if y > z or z > ub:
                break
            if abs(x * x + y * y + z * z + x * y + y * z + z * x - n) < 1e-9:
                # print(x, y, round(z), z)
                s = len(set([x, y, round(z)]))
                if s == 1:
                    count += 1
                elif s == 2:
                    count += 3
                else:
                    count += 6

    print(count)
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int, int>;

int main(void) {
  int N;
  cin >> N;
  vector<int> ans(N + 1);
  for (int x = 1; x <= 101; x++) {
    for (int y = 1; y <= 101; y++) {
      for (int z = 1; z <= 101; z++) {
        int tmp = x * x + y * y + z * z + x * y + y * z + z * x;
        ans[tmp]++;
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int, int>;

int main(void) {
  int N;
  cin >> N;
  vector<int> ans(200000);
  for (int x = 1; x <= 101; x++) {
    for (int y = 1; y <= 101; y++) {
      for (int z = 1; z <= 101; z++) {
        int tmp = x * x + y * y + z * z + x * y + y * z + z * x;
        ans[tmp]++;
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cmath>
#include <iostream>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int pp = 0;
    int as = sqrt(i);
    for (int a = 1; a < as; a++) {
      for (int b = 1; b < as; b++) {
        for (int c = 1; c < as; c++) {
          if (a * a + b * b + c * c + a * b + a * c + b * c == i) {
            pp++;
            break;
          }
        }
      }
    }
    cout << pp << endl;
  }
  return 0;
}

Fixed submission:
#include <cmath>
#include <iostream>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int pp = 0;
    int as = sqrt(i);
    for (int a = 1; a < as; a++) {
      for (int b = 1; b < as; b++) {
        double ji = (-1 * (a + b) + sqrt(1.0 * (a + b) * (a + b) -
                                         4.0 * (a * a + b * b + a * b - i))) /
                    2;
        double jii = (-1 * (a + b) - sqrt(1.0 * (a + b) * (a + b) -
                                          4.0 * (a * a + b * b + a * b - i))) /
                     2;
        if (ji - (int)ji == 0 && ji > 0 || jii - (int)jii == 0 && jii > 0) {
          pp++;
          // break;
        }
      }
    }
    cout << pp << endl;
  }
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int main() {
  int n;
  std::cin >> n;
  std::vector<int> a(n + 1, 0);
  for (int x = 1; x < n / 2; x++) {
    for (int y = 1; y < n / 2; y++) {
      for (int z = 1; z < n / 2; z++) {
        int value = x * x + y * y + z * z + x * y + y * z + z * x;
        if (value <= n)
          ++a[value];
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    std::cout << a[i] << '\n';
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int main() {
  int n;
  std::cin >> n;
  std::vector<int> a(n + 1, 0);
  for (int x = 1; x < 100; x++) {
    for (int y = 1; y < 100; y++) {
      for (int z = 1; z < 100; z++) {
        int value = x * x + y * y + z * z + x * y + y * z + z * x;
        if (value <= n)
          ++a[value];
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    std::cout << a[i] << '\n';
  }
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define loop(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const long double PI = acos(-1);
// }}} End Header
int main() {
  ll n;
  cin >> n;
  vector<ll> a(n + 1);
  loop(x, 1, n) {
    loop(y, 1, n) {
      loop(z, 1, n) {
        ll cnt;
        cnt = x * x + y * y + z * z + x * y + y * z + z * x;
        if (cnt > n)
          continue;
        a[cnt]++;
      }
    }
  }
  loop(i, 1, n + 1) { cout << a[i] << endl; }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define loop(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const long double PI = acos(-1);
// }}} End Header
int main() {
  ll n;
  cin >> n;
  vector<ll> a(n + 1);
  for (ll x = 1; x * x <= n; x++) {
    for (ll y = 1; y * y <= n; y++) {
      for (ll z = 1; z * z <= n; z++) {
        ll cnt = x * x + y * y + z * z + x * y + y * z + z * x;
        if (cnt > n)
          continue;
        a[cnt]++;
      }
    }
  }
  loop(i, 1, n + 1) { cout << a[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;

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

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

int main() {
  int N;
  cin >> N;
  for (int i = 1; i <= N; i++)
    cout << count(i) << endl;
  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;

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

int count(int n) {
  int res = 0;
  for (int x = 1; x <= 100; x++) {
    for (int y = x; y <= 100; y++) {
      for (int z = y; z <= 100; z++) {
        if (f(x, y, z) == n) {
          if (x == y && y == z)
            res++;
          if (x != y && y != z && z != x)
            res += 6;
          if (x == y && y != z)
            res += 3;
          if (y == z && x != z)
            res += 3;
          if (x == z && x != y)
            res += 3;
        }
      }
    }
  }
  return res;
}

int main() {
  int N;
  cin >> N;
  for (int i = 1; i <= N; i++)
    cout << count(i) << endl;
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
using namespace std;
int n, m, ans, f[1005];
int coun(int x, int y, int z) { return x == y && y == z ? 1 : 3; }
int main() {
  // freopen("a.in","r",stdin);
  // freopen("a.out","w",stdout);
  scanf("%d", &n);
  m = sqrt(n);
  for (int i = 1; i <= m; i++)
    for (int j = i; j <= m; j++)
      for (int k = j; k <= m; k++) {
        int p = i * i + j * j + k * k + i * j + i * k + j * k;
        if (p > n)
          continue;
        f[p] += coun(i, j, k);
      }
  for (int i = 1; i <= n; i++)
    printf("%d\n", f[i]);
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
using namespace std;
int n, m, ans, f[10005];
int coun(int x, int y, int z) {
  if (x == y && y == z)
    return 1;
  if (x == y || y == z)
    return 3;
  return 6;
}
int main() {
  // freopen("a.in","r",stdin);
  // freopen("a.out","w",stdout);
  scanf("%d", &n);
  m = sqrt(n);
  for (int i = 1; i <= m; i++)
    for (int j = i; j <= m; j++)
      for (int k = j; k <= m; k++) {
        int p = i * i + j * j + k * k + i * j + i * k + j * k;
        if (p > n)
          continue;
        f[p] += coun(i, j, k);
      }
  for (int i = 1; i <= n; i++)
    printf("%d\n", f[i]);
  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> a(N);

  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        int b = i * i + j * j + k * k + i * j + j * k + k * i;
        if (b <= N) {
          a.at(b)++;
        }
      }
    }
  }

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

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

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

  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        int b = i * i + j * j + k * k + i * j + j * k + k * i;
        if (b <= N) {
          a.at(b)++;
        }
      }
    }
  }

  for (int i = 1; i <= N; i++) {
    cout << a.at(i) << endl;
  }
}
Problem p02608 (C++)

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

int fun(int N) {
  int count = 0;
  int m = N / 2;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= i; j++) {
      for (int k = 1; k <= j; k++) {
        int A = i + j + k;
        if (A * A - i * j - j * k - k * i == N) {
          int t = 0;
          if (i == j) {
            t += 1;
          }
          if (i == k) {
            t += 1;
          }
          if (j == k) {
            t += 1;
          }
          if (t == 0) {
            count += 6;
          } else if (t == 1) {
            count += 3;
          } else {
            count += 1;
          }
        }
      }
    }
  }
  return count;
}

int main() {
  int N;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cout << fun(i) << endl;
  }
}

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

int fun(int N) {
  int count = 0;
  int m = int(sqrt(N)) + 1;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= i; j++) {
      for (int k = 1; k <= j; k++) {
        int A = i + j + k;
        if (A * A - i * j - j * k - k * i == N) {
          int t = 0;
          if (i == j) {
            t += 1;
          }
          if (i == k) {
            t += 1;
          }
          if (j == k) {
            t += 1;
          }
          if (t == 0) {
            count += 6;
          } else if (t == 1) {
            count += 3;
          } else {
            count += 1;
          }
        }
      }
    }
  }
  return count;
}

int main() {
  int N;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cout << fun(i) << endl;
  }
}
Problem p02608 (C++)

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

using namespace std;
int n, tmp, Ans[1010];
int main() {
  scanf("%d", &n);
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int k = (x * x) + (y * y) + (z * z) + (x * y) + (x * z) + (y * z);
        if (k <= n)
          Ans[k]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d\n", Ans[i]);
  }
  return 0;
}

Fixed submission:
#include <cstdio>

using namespace std;
int n, tmp, Ans[10010];
int main() {
  scanf("%d", &n);
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int k = (x * x) + (y * y) + (z * z) + (x * y) + (x * z) + (y * z);
        if (k <= n)
          Ans[k]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d\n", Ans[i]);
  }
  return 0;
}
Problem p02608 (C++)

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

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define reps(i, n) for (ll i = 1; i <= (n); ++i)
#define _rep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define _reps(i, n) for (ll i = n; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define _all(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

  reps(i, n) {
    ll cnt = 0;
    for (ll x = 1; x * x < i; x++) {
      for (ll y = 1; ((x * x) + (y * y)) < i; y++) {
        for (ll z = 1; ((x * x) + (y * y) + (z * z)) < i; z++) {
          if (((x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x)) ==
              i) {
            cnt++;
          }
        }
      }
    }
    cout << cnt << endl;
  }

  return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define reps(i, n) for (ll i = 1; i <= (n); ++i)
#define _rep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define _reps(i, n) for (ll i = n; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define _all(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

  reps(i, n) {
    ll cnt = 0;
    for (ll x = 1; x * x < i; x++) {
      for (ll y = 1; ((x * x) + (y * y) + (x * y)) < i; y++) {

        for (ll 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) {
            cnt++;
          }
        }
      }
    }
    cout << cnt << 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 FOR(i, a, b) for (int i = a; i < (b + a); i++)
#define W1 while (1)
#define COUT(x) cout << x << endl
using namespace std;
using ll = long long;
using ld = long double;
#define ALL(x) x.begin(), x.end()
#define P pair<int, int>
#define mod 1000000007
#define PB push_back
#define F first
#define S second

int main() {
  int n;
  cin >> n;
  vector<int> f(n + 1, 0);
  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 num = i * i + j * j + k * k + i * j + j * k + k * i;
        f[num]++;
      }
    }
  }
  FOR(i, 1, n) { COUT(f[i]); }

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = a; i < (b + a); i++)
#define W1 while (1)
#define COUT(x) cout << x << endl
using namespace std;
using ll = long long;
using ld = long double;
#define ALL(x) x.begin(), x.end()
#define P pair<int, int>
#define mod 1000000007
#define PB push_back
#define F first
#define S second

int main() {
  int n;
  cin >> n;
  vector<int> f(n + 1, 0);
  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 num = i * i + j * j + k * k + i * j + j * k + k * i;
        if (f.size() - 1 < num)
          continue;
        f[num]++;
      }
    }
  }
  FOR(i, 1, n) { COUT(f[i]); }

  return 0;
}
Problem p02608 (C++)

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

typedef long long ll;
#define rep(i, n) for (int i = 1; i * i <= (int)(n); i++)

int main() {
  int MAX_N = 10002;

  int s[MAX_N];
  for (int i = 0; i < MAX_N; ++i)
    s[i] = 0;

  for (int i = 0; i < MAX_N; ++i) {
    rep(j, i) {
      rep(k, i) {
        rep(l, i) {
          if (j * j + k * k + l * l + j * k + k * l + l * j == i)
            ++s[i];
        }
      }
    }
  }
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i)
    cout << s[i] << endl;
  return 0;
}

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

typedef long long ll;
#define rep(i, n) for (int i = 1; i * i <= (int)(n); i++)

int main() {
  int MAX_N = 10002;

  int s[MAX_N];
  for (int i = 0; i < MAX_N; ++i)
    s[i] = 0;

  for (int i = 0; i < MAX_N; ++i) {
    rep(j, i) {
      rep(k, i) {
        rep(l, i - j * j - k * k - j * k) {
          if (j * j + k * k + l * l + j * k + k * l + l * j == i)
            ++s[i];
        }
      }
    }
  }
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i)
    cout << s[i] << endl;
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;

void solve() {}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n + 1);
  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 m = i * i + j * j + k * k + i * j + j * k + i * k;
        a[m]++;
      }
    }
  }
  rep(i, n) { cout << a[i + 1] << endl; }

  return 0;
}

Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;

void solve() {}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n + 1);
  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 m = i * i + j * j + k * k + i * j + j * k + i * k;
        if (m <= n) {
          a[m]++;
        }
      }
    }
  }
  rep(i, n) { cout << a[i + 1] << 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 REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  ll N;
  cin >> N;
  FOR(i, 1, N + 1) {
    ll cnt = 0;
    FOR(j, 1, 100) {
      FOR(k, 1, 100) {
        FOR(l, 1, 100) {
          if (j * j + k * k + l * l + j * k + k * l + l * j == i) {
            cnt++;
          }
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  ll N;
  cin >> N;
  FOR(i, 1, N + 1) {
    ll cnt = 0;
    FOR(j, 1, 100) {
      FOR(k, 1, 100) {
        FOR(l, 1, 100) {
          if (j * j + k * k + l * l + j * k + k * l + l * j == i) {
            cnt++;
          } else if (j * j + k * k + l * l + j * k + k * l + l * j > i) {
            break;
          }
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; // 10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main() {
  //  以降 cin の入力元が 'input.txt' になる
  // std::ifstream in("input.txt");
  // std::cin.rdbuf(in.rdbuf());
  int n;
  cin >> n;
  vi ans(n + 1);
  rep(i, n + 1) { ans[i] == 0; }
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        ans[x * x + y * y + z * z + x * y + y * z + z * x]++;
      }
    }
  }
  rep(i, n) { cout << ans[i + 1] << endl; }

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; // 10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main() {
  //  以降 cin の入力元が 'input.txt' になる
  // std::ifstream in("input.txt");
  // std::cin.rdbuf(in.rdbuf());
  int n;
  cin >> n;
  vi ans(n + 1);
  rep(i, n + 1) { ans[i] == 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)
          ans[x * x + y * y + z * z + x * y + y * z + z * x]++;
      }
    }
  }
  rep(i, n) { cout << ans[i + 1] << endl; }

  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int ans[30000];
int main() {
  int n;
  scanf("%d", &n);
  int t = (int)sqrt(n) + 1;
  for (int i = 1; i <= t; i++) {
    for (int j = 1; j <= t; j++) {
      for (int z = 1; z <= t; z++) {
        ans[i * i + j * j + z * z + i * j + j * z + i * z]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    printf("%d\n", ans[i]);
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int ans[30000];
int main() {
  int n;
  scanf("%d", &n);
  int t = (int)sqrt(n) + 1;
  for (int i = 1; i <= t; i++) {
    for (int j = 1; j <= t; j++) {
      for (int z = 1; z <= t; z++) {
        if (i * i + j * j + z * z + i * j + j * z + i * z <= n)
          ans[i * i + j * j + z * z + i * j + j * z + i * z]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    printf("%d\n", ans[i]);
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>

using namespace std;

int main() {
  int n, ans;
  cin >> n;
  for (int index = 0; index < n; index++) {
    ans = 0;
    for (int i = 1; i < 75; i++) {
      for (int j = 1; j < 75; j++) {
        for (int k = 1; k < 75; k++) {
          if (i * i + j * j + k * k + i * j + j * k + k * i == index + 1)
            ans++;
        }
      }
    }
    printf("%d\n", ans);
  }

  return 0;
}


Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int n, ans;
  cin >> n;
  for (int index = 0; index < n; index++) {
    ans = 0;
    for (int i = 1; i < 100; i++) {
      for (int j = i; j < 100; j++) {
        for (int k = j; k < 100; k++) {
          if (i * i + j * j + k * k + i * j + j * k + k * i == index + 1) {
            if (i != j && j != k)
              ans += 6;
            else if ((i == j || i == k || j == k) && !(i == j && i == k))
              ans += 3;
            else if (i == j && i == k)
              ans++;
          }
        }
      }
    }
    printf("%d\n", ans);
  }

  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <assert.h>
#include <bits/stdc++.h>
#include <bits/stdtr1c++.h>
#include <bitset>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
const int N = 100005;
const int MOD = 1000000007;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int a[n + 1];
  for (int i = 0; i <= n; i++)
    a[i] = 0;
  for (int i = 1; i <= n - 1; i++) {
    for (int j = 1; j <= n - 1; j++) {
      for (int k = 1; k <= n - 1; k++) {
        int sum = i * i + j * j + k * k + i * j + j * k + k * i;
        if (sum <= n)
          a[sum]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << a[i] << endl;
}

Fixed submission:
#include <algorithm>
#include <assert.h>
#include <bits/stdc++.h>
#include <bits/stdtr1c++.h>
#include <bitset>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
const int N = 100005;
const int MOD = 1000000007;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int a[n + 1];
  for (int i = 0; i <= n; i++)
    a[i] = 0;
  for (int i = 1; i * i <= n - 1; i++) {
    for (int j = 1; j * j <= n - 1; j++) {
      for (int k = 1; k * k <= n - 1; k++) {
        int sum = i * i + j * j + k * k + i * j + j * k + k * i;
        if (sum <= n)
          a[sum]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << a[i] << endl;
}
Problem p02608 (C++)

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

// #define int long long
typedef long long ll;
// const int INF = 2e9;
// const ll INF = 9e18;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> f(N + 1);
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        for (int n = 1; n <= N; n++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == n) {
            f[n]++;
          }
        }
      }
    }
  }
  for (int n = 1; n <= N; n++) {
    cout << f[n] << "\n";
  }
}

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

// #define int long long
typedef long long ll;
// const int INF = 2e9;
// const ll INF = 9e18;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> f(N + 1);
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int p = x * x + y * y + z * z + x * y + y * z + z * x;
        if (p <= N)
          f[p]++;
      }
    }
  }
  for (int n = 1; n <= N; n++) {
    cout << f[n] << "\n";
  }
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main() {
  int n;
  cin >> n;
  vector<int> ans(n + 1, 0);
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int sum = x * x + y * y + z * z + x * y + y * z + z * x;
        ans[sum]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << ans[i] << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main() {
  int n;
  cin >> n;
  vector<int> ans(1e5, 0);
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int sum = x * x + y * y + z * z + x * y + y * z + z * x;
        ans[sum]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << ans[i] << endl;
}