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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
double pie = 3.14159265358979;
long long mod = 1000000007;
//
int main() {
  int n = 0;
  cin >> n;
  int ans[1001] = {};
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        if (i * i + j * j + k * k + i * j + j * k + k * i <= n) {
          ans[i * i + j * j + k * k + i * j + j * k + k * i]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
double pie = 3.14159265358979;
long long mod = 1000000007;
//
int main() {
  int n = 0;
  cin >> n;
  int ans[100001] = {};
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        if (i * i + j * j + k * k + i * j + j * k + k * i <= n) {
          ans[i * i + j * j + k * k + i * j + j * k + k * i]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
long long ans[10004], n;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; n >= i * i; i++) {
    for (int j = 1; n >= j * j; j++) {
      for (int k = 1; n >= k * k; k++) {
        ans[i * i + j * j + k * k + i * j + i * k + j * k]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << ans[i] << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
long long ans[100005], n;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; n >= i * i; i++) {
    for (int j = 1; n >= j * j; j++) {
      for (int k = 1; n >= k * k; k++) {
        ans[i * i + j * j + k * k + i * j + i * k + j * k]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << ans[i] << endl;
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i, n)                                                              \
  ;                                                                            \
  for (long long i = 0; i < (n); i++)
using ll = long long;
using P = pair<long long, long long>;
template <class T> using vec = vector<T>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  ll f[1005];
  for (ll i = 1; i <= n; i++) {
    for (ll j = i; j <= n; j++) {
      for (ll k = j; k <= n; k++) {
        ll r = i * i + j * j + k * k + i * j + j * k + k * i;
        if (r > n)
          break;
        if (i == j && i == k)
          f[r]++;
        else if (i == j || j == k || k == i)
          f[r] += 3;
        else
          f[r] += 6;
      }
    }
  }
  rep(i, n) cout << f[i + 1] << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i, n)                                                              \
  ;                                                                            \
  for (long long i = 0; i < (n); i++)
using ll = long long;
using P = pair<long long, long long>;
template <class T> using vec = vector<T>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  ll f[100005];
  for (ll i = 1; i <= n; i++) {
    for (ll j = i; j <= n; j++) {
      for (ll k = j; k <= n; k++) {
        ll r = i * i + j * j + k * k + i * j + j * k + k * i;
        if (r > n)
          break;
        if (i == j && i == k)
          f[r]++;
        else if (i == j || j == k || k == i)
          f[r] += 3;
        else
          f[r] += 6;
      }
    }
  }
  rep(i, n) cout << f[i + 1] << endl;
}
Problem p02608 (C++)

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

int f[10010];

int main() {
  int N;
  cin >> N;
  rep(i, 10010) f[i] = 0;

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

  rep(i, N) { cout << f[i + 1] << endl; }
  return 0;
}

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

int f[10010];

int main() {
  int N;
  cin >> N;
  rep(i, 10010) f[i] = 0;

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

  rep(i, N) { cout << f[i + 1] << endl; }
  return 0;
}
Problem p02608 (C++)

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

using namespace std;

int main(void) {
  int N;
  cin >> N;
  vector<int> count(N, 0);
  int max = sqrt(N);
  for (int x = 1; x <= max; x++) {
    for (int y = 1; y <= max; y++) {
      for (int z = 1; z <= max; z++) {
        int t = x * x + y * y + z * z + x * y + y * z + z * x;
        count[t - 1]++;
      }
    }
  }
  for (int ct : count) {
    cout << ct << endl;
  }

  return 0;
}

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

using namespace std;

int main(void) {
  int N;
  cin >> N;
  vector<int> count(N, 0);
  int max = sqrt(N);
  for (int x = 1; x <= max; x++) {
    for (int y = 1; y <= max; y++) {
      for (int z = 1; z <= max; z++) {
        int t = x * x + y * y + z * z + x * y + y * z + z * x;
        if (t - 1 < N)
          count[t - 1]++;
      }
    }
  }
  for (int ct : count) {
    cout << ct << endl;
  }

  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 count = 0;
  for (int n = 1; n <= N; n++) {
    count = 0;
    for (int x = 1; x < sqrt(n); x++) {
      for (int y = 1; y < n - x * x; y++) {
        for (int z = 1; z < n - x * x - y * y; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == n) {
            count++;
          }
        }
      }
    }
    cout << count << endl;
  }

  return 0;
}

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

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

  int count = 0;
  for (int n = 1; n <= N; n++) {
    count = 0;
    for (int x = 1; x < n; x++) {
      if (x * x + 2 * x + 3 > n) {
        break;
      }
      for (int y = 1; y < n; y++) {
        if (x * x + y * y + 1 + x * y + y + x > n) {
          break;
        }
        for (int z = 1; z < n; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x > n) {
            break;
          }
          if (x * x + y * y + z * z + x * y + y * z + z * x == n) {
            count++;
          }
        }
      }
    }
    cout << count << endl;
  }

  return 0;
}
Problem p02608 (C++)

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

int n;

int main() {
  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;
  return 0;
}

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

int n;

int main() {
  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++) {
        int idx = x * x + y * y + z * z + x * y + y * z + z * x;
        if (idx <= n)
          ans[idx]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << ans[i] << endl;
  return 0;
}
Problem p02608 (C++)

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

using namespace std;
using ll = long long;
using ld = long double;

// #define int long long
// signed main(){
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    for (int x = 1; x <= 100; x++) {
      for (int y = 1; y <= 100; y++) {
        for (int z = 1; z <= 100; z++) {
          int tmp = x * x + y * y + z * z + x * y + y * z + z * x;
          if (tmp > n)
            break;
          if (i == tmp)
            cnt++;
        }
      }
    }
    cout << cnt << "\n";
  }

  return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

// #define int long long
// signed main(){
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    for (int x = 1; x <= 100; x++) {
      for (int y = 1; y <= 100; y++) {
        for (int z = 1; z <= 100; z++) {
          int tmp = x * x + y * y + z * z + x * y + y * z + z * x;
          if (tmp > i)
            break;
          if (i == tmp)
            cnt++;
        }
      }
    }
    cout << cnt << "\n";
  }

  return 0;
}
Problem p02608 (C++)

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

using namespace std;

const int N = 1e4 + 2;

int res[N];

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

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

  int n;
  cin >> n;

  int m = (int)sqrt(n) + 1;
  for (int x = 1; x <= m; ++x) {
    for (int y = 1; y <= m; ++y) {
      for (int z = 1; z <= m; ++z) {
        res[f(x, y, z)]++;
      }
    }
  }

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

  return 0;
}

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

using namespace std;

const int N = 1e6 + 2;

int res[N];

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

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

  int n;
  cin >> n;

  int m = (int)sqrt(n) + 1;
  for (int x = 1; x <= m; ++x) {
    for (int y = 1; y <= m; ++y) {
      for (int z = 1; z <= m; ++z) {
        res[f(x, y, z)]++;
      }
    }
  }

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

  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;

#define INF 1e+9
#define MAX_V 300

struct edge {
  int to;
  int cost;
};
using P = pair<ll, ll>;

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

Fixed submission:
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;

#define INF 1e+9
#define MAX_V 300

struct edge {
  int to;
  int cost;
};
using P = pair<ll, ll>;

ll func(ll s) {
  ll ans = 0;
  for (ll x = 1; x < 102; x++) {
    for (ll y = 1; y < 102; y++) {
      for (ll z = 1; z < 102; z++) {
        ll tmp = x * x + y * y + z * z + x * z + y * z + x * y;
        if (tmp == s) {
          ans++;
          break;
        }
        if (tmp > s) {
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
int main() {
  ll n;
  cin >> n;
  for (ll i = 1; i <= n; i++) {
    func(i);
  }
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):

#include <algorithm>
#include <iomanip> // std::setprecision()
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b) {
  if (a % b == 0)
    return (b);
  else
    return (gcd(b, a % b));
}
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */

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

Fixed submission:

#include <algorithm>
#include <iomanip> // std::setprecision()
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b) {
  if (a % b == 0)
    return (b);
  else
    return (gcd(b, a % b));
}
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */

int main() {
  int n;
  cin >> n;
  vector<ll> a(100 * 100 * 100, 0);
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int tmp = x * x + y * y + z * z + x * y + y * z + z * x;
        a[tmp]++;
      }
    }
  }
  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 rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n + 1; i++) {
    int ans = 0;
    for (int x = 1; x < 45; x++) {
      for (int y = x; y < 99; y++) {
        for (int z = y; z < 101; z++) {
          if (pow(x + y, 2) + pow(y + z, 2) + pow(z + x, 2) == 2 * i) {
            if (x < y && y < z)
              ans += 6;
            if (x < y && y == z)
              ans += 3;
            if (x == y && y < z)
              ans += 3;
            if (x == y && y == z)
              ans += 1;
          }
        }
      }
    }
    cout << ans << endl;
  }
}

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

int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n + 1; i++) {
    int ans = 0;
    for (int x = 1; x < 45; x++) {
      for (int y = x; y < 60; y++) {
        for (int z = y; z < 101; z++) {
          if (pow(x + y, 2) + pow(y + z, 2) + pow(z + x, 2) == 2 * i) {
            if (x < y && y < z)
              ans += 6;
            if (x < y && y == z)
              ans += 3;
            if (x == y && y < z)
              ans += 3;
            if (x == y && y == z)
              ans += 1;
          }
        }
      }
    }
    cout << ans << endl;
  }
}
Problem p02608 (C++)

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long double ld;
typedef long long ll;
const int MOD = 1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;

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

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

  return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long double ld;
typedef long long ll;
const int MOD = 1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;

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

  for (int i = 1; i <= n; i++) {
    int cnt = 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;
          if (sum > i)
            break;
          if (i == sum)
            cnt++;
        }
      }
    }
    cout << cnt << endl;
  }

  return 0;
}
Problem p02608 (C++)

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long

const int MOD = 1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;

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

  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int j = 1; j <= i; j++) {
      for (int k = 1; k <= i; k++) {
        for (int l = 1; l <= i; l++) {
          int sum = j * j + k * k + l * l + j * k + k * l + l * j;
          if (sum > i)
            break;
          if (sum == i)
            ans++;
        }
      }
    }
    cout << ans << endl;
  }

  return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long

const int MOD = 1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;

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

  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int j = 1; j * j <= i; j++) {
      for (int k = 1; k * k <= i; k++) {
        for (int l = 1; l * l <= i; l++) {
          int sum = j * j + k * k + l * l + j * k + k * l + l * j;
          if (sum > i)
            break;
          if (sum == i)
            ans++;
        }
      }
    }
    cout << ans << endl;
  }

  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> vect;
  int k = 3;
  int product = 1, j = 1, a, b, c, i = 1;
  while (product <= ((N + 10) * (N + 10))) {
    product = j * j;
    vect.push_back(product);
    j++;
  }
  //	cout<<vect.size()<<"\n";

  vector<int> vect1(N, 0);

  for (i = 0; i < vect.size(); i++) {
    for (a = 1; a <= i + 1; a++) {
      for (b = 1; b <= i + 1; b++) {
        c = i + 1 - (a + b);
        if (c > 0) {
          j = vect[i] - (a * b + b * c + c * a) - 1;
          if ((j < N) && (j > 0))
            vect1[j]++;
        }
      }
    }
  }
  for (i = 0; i < N; i++)
    cout << vect1[i] << "\n";
  return 0;
}

Fixed submission:
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> vect;
  int k = 3;
  int product = 1, j = 1, a, b, c, i = 1;
  while (product <= 10 * N) {
    product = j * j;
    vect.push_back(product);
    j++;
  }
  //	cout<<vect.size()<<"\n";

  vector<int> vect1(N, 0);

  for (i = 0; i < vect.size(); i++) {
    for (a = 1; a <= i + 1; a++) {
      for (b = 1; b <= i + 1; b++) {
        c = i + 1 - (a + b);
        if (c > 0) {
          j = vect[i] - (a * b + b * c + c * a) - 1;
          if ((j < N) && (j > 0))
            vect1[j]++;
        }
      }
    }
  }
  for (i = 0; i < N; i++)
    cout << vect1[i] << "\n";
  return 0;
}
Problem p02608 (C++)

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

int func(int n) {
  int cnt = 0;
  for (int i = 1; i <= sqrt(n); i++) {
    for (int j = 1; j <= sqrt(n); j++) {
      for (int k = 1; k <= sqrt(n); k++) {
        if (i * i + j * j + k * k + i * j + j * k + k * i == n)
          cnt++;
      }
    }
  }

  return cnt;
}

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

  return 0;
}


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

int func(int n) {
  int cnt = 0;
  for (int i = 1; i <= sqrt(n); i++) {
    for (int j = 1; j <= i; j++) {
      for (int k = 1; k <= j; k++) {
        if (i * i + j * j + k * k + i * j + j * k + k * i == n) {
          if (i > j && j > k)
            cnt += 6;
          else if (i > j && j == k)
            cnt += 3;
          else if (i == j && j > k)
            cnt += 3;
          else
            cnt++;
        }
      }
    }
  }

  return cnt;
}

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

  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
// エイシングプロコン2020
// C問題
int main() {
  int n;
  cin >> n;
  int ans[10050] = {0};
  for (int i = 1; i <= n; i++) {
    int v;
    for (int j = 1; j * j <= n; j++) {
      for (int k = 1; k * k <= n; k++) {
        for (int l = 1; l * l <= n; l++) {
          v = j * j + k * k + l * l + j * k + k * l + l * j;
          if (v == i) {
            ans[v] += 1;
          }
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
// エイシングプロコン2020
// C問題
int main() {
  int n;
  cin >> n;
  int ans[10050] = {0};
  int v;
  for (int i = 1; i <= 105; i++) {
    for (int j = 1; j <= 105; j++) {
      for (int k = 1; k <= 105; k++) {
        v = i * i + j * j + k * k + i * j + j * k + k * i;
        if (v < 10050) {
          ans[v] += 1;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string.h>
#include <string>
using namespace std;

void c_xys_triplets(void) {
  int n;
  cin >> n;

  for (int i = 1; i <= n; i++) {
    if (i < 6) {
      cout << 0 << endl;
      continue;
    }
    int max = (i + 3) / 6;
    int cnt = 0;
    for (int a = 1; a <= max; a++) {
      if (a * a > i)
        break;
      for (int b = 1; b <= max; b++) {
        if ((a * a + b * b) > i)
          break;
        for (int c = 1; c <= max; c++) {
          if (a * a + b * b + c * c + a * b + b * c + c * a == i) {
            cnt++;
            break;
          }
        }
      }
    }
    cout << cnt << endl;
  }
}

int main() {
  c_xys_triplets();
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string.h>
#include <string>
using namespace std;

void c_xys_triplets(void) {
  int n;
  cin >> n;

  for (int i = 1; i <= n; i++) {
    if (i < 6) {
      cout << 0 << endl;
      continue;
    }
    int max = (i + 3) / 6;
    int cnt = 0;
    for (int a = 1; a <= max; a++) {
      if (a * a > i)
        break;
      for (int b = 1; b <= max; b++) {
        if ((a * a + b * b) > i)
          break;
        // for (int c = 1; c <= max; c++) {
        //	if (a *a + b*b + c*c + a * b + b * c + c * a == i) {
        //		cnt++;
        //		break;
        //	}
        // }
        int remain = i - a * a - a * b - b * b;
        if (remain < 0)
          break;
        int l = int(sqrt(double(remain)));
        for (int c = 1; c <= l; c++) {
          if (c * c + a * c + b * c == remain) {
            cnt++;
            break;
          }
        }
      }
    }
    cout << cnt << endl;
  }
}

int main() {
  c_xys_triplets();
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
/// in the name of ALLAH
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n;
  cin >> n;
  /// pre calculate
  int ar[10005];
  int mx = 10000;
  memset(ar, 0, sizeof(ar));
  for (int i = 1; i <= sqrt(n); i++) {
    for (int j = 1; j <= sqrt(n); j++) {
      for (int k = 1; k <= sqrt(n); k++) {
        ll p = i * i + j * j + k * k + i * j + j * k + k * i;
        ar[p]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << ar[i] << endl;
}


Fixed submission:
/// in the name of ALLAH
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n;
  cin >> n;
  /// pre calculate
  int ar[10005];
  int mx = 10000;
  memset(ar, 0, sizeof(ar));
  for (int i = 1; i <= sqrt(n); i++) {
    for (int j = 1; j <= sqrt(n); j++) {
      for (int k = 1; k <= sqrt(n); k++) {
        ll p = i * i + j * j + k * k + i * j + j * k + k * i;
        if (p <= n)
          ar[p]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << ar[i] << endl;
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1 << 30;
const ll INF64 = 1LL << 60;

void solve() {
  int n;
  cin >> n;
  vector<int> a(4e4, 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++)
        a[x * x + y * y + z * z + x * y + y * z + x * z]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << endl;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1 << 30;
const ll INF64 = 1LL << 60;

void solve() {
  int n;
  cin >> n;
  vector<int> a(2e5, 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++)
        a[x * x + y * y + z * z + x * y + y * z + x * z]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << endl;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  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++)
using namespace std;
using ll = long long;

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

  vector<int> ans(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++) {
        ans[x * x + y * y + z * z + x * y + y * z + z * x - 1]++;
      }
    }
  }
  rep(i, N) cout << ans[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 main() {
  int N;
  cin >> N;

  vector<int> ans(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 calc = x * x + y * y + z * z + x * y + y * z + z * x;
        if (calc <= N) {
          ans[calc - 1]++;
        }
      }
    }
  }
  rep(i, N) cout << ans[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 < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
vector<int> x(10000);
int main() {
  int n, a = 0;
  cin >> n;
  if (n % 3 == 0) {
    a = n / 3;
  } else {
    a = n / 3 + 1;
  }
  int z = sqrt(a) + 1;
  for (int i = 1; i <= a; i++) {
    for (int j = 1; j <= a; ++j) {
      for (int k = 1; k <= a; ++k) {
        if (i * i + j * j + k * k + i * j + i * k + j * k <= n) {
          x[i * i + j * j + k * k + i * j + i * k + j * k - 1]++;
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << x[i] << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
vector<int> x(10000);
int main() {
  int n, a = 0;
  cin >> n;
  for (int i = 1; i <= 99; i++) {
    for (int j = 1; j <= 99; ++j) {
      for (int k = 1; k <= 99; ++k) {
        if (i * i + j * j + k * k + i * j + i * k + j * k <= n) {
          x[i * i + j * j + k * k + i * j + i * k + j * k - 1]++;
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << x[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 s = 1; s <= n; s++) {
    int count = 0;
    for (int i = 1; i <= sqrt(s); i++) {
      for (int j = 1; j < sqrt(s); j++) {
        for (int k = 1; k < sqrt(s); k++) {
          if ((i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i) == s) {
            count++;
          }
        }
      }
    }
    cout << count << endl;
  }
  return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  for (int s = 1; s <= n; s++) {
    int count = 0;
    for (int i = 1; i <= sqrt(s); i++) {
      for (int j = 1; j < sqrt(s); j++) {
        for (int k = 1; k < sqrt(s); k++) {
          if ((i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i) == s) {
            count++;
          } else if ((i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i) >
                     s) {
            break;
          }
        }
      }
    }
    cout << count << endl;
  }
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, n) for (int i = (a); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define FOR(it, c)                                                             \
  for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

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

  vector<ll> ret(N + 1, 0);

  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 res = x * x + y * y + z * z + x * y + y * z + z * x;

        ret[res]++;
      }
    }
  }

  REP(i, 1, N + 1) { cout << ret[i] << endl; }

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, n) for (int i = (a); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define FOR(it, c)                                                             \
  for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

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

  vector<ll> ret(N + 1, 0);

  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 res = x * x + y * y + z * z + x * y + y * z + z * x;

        if (res <= N)
          ret[res]++;
      }
    }
  }

  REP(i, 1, N + 1) { cout << ret[i] << endl; }

  return 0;
}
Problem p02608 (C++)

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

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int N;
  std::cin >> N;

  int f;

  for (int n = 1; n <= N; ++n) {
    f = 0;
    for (int x = 1; x * x < N; ++x) {
      for (int y = 1; y * y < N - x * x; ++y) {
        for (int z = 1; z * z < N - x * x - y * y; ++z) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == n) {
            ++f;
          }
        }
      }
    }
    std::cout << f << std::endl;
  }

  return 0;
}


Fixed submission:
#include <iostream>

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int N;
  std::cin >> N;

  int f;

  for (int n = 1; n <= N; ++n) {
    f = 0;
    for (int x = 1; x * x < n; ++x) {
      for (int y = 1; y * y < n - x * x - x * y; ++y) {
        for (int z = 1; z * z <= n - x * x - y * y - x * y - y * z - z * x;
             ++z) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == n) {
            ++f;
          }
        }
      }
    }
    std::cout << f << std::endl;
  }

  return 0;
}
Problem p02608 (C++)

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

int main(void) {
  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; x * x + y * y <= i; y++) {
        for (int z = 1; x * x + y * y + 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;

int main(void) {
  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; x * x + y * y <= i; y++) {
        // for (int z = 1; x * x + y * y + z * z <= i; z++) {
        //     if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
        //       ans++;
        //     }
        //   }
        int D = (x + y) * (x + y) - 4 * (-i + x * x + y * y + x * y);
        if (D == 0) {
          double z = -(x + y) / 2.0;
          ans += floor(z) == ceil(z) && z > 0 ? 1 : 0;
        } else if (D > 0) {
          double z = (-(x + y) + sqrt(D)) / 2.0;
          ans += floor(z) == ceil(z) && z > 0 ? 1 : 0;
          z = (-(x + y) - sqrt(D)) / 2.0;
          ans += floor(z) == ceil(z) && z > 0 ? 1 : 0;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define M 1000000007

void solve() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int count = 0;
    for (int j = 1; j * j <= i; j++) {
      for (int k = 1; k * k <= i; k++) {
        for (int l = 1; l * l <= i; l++) {
          if (j * j + k * k + l * l + j * l + j * k + k * l == i)
            count++;
        }
      }
    }
    cout << count << "\n";
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  solve();
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define M 1000000007

void solve() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int count = 0;
    for (int j = 1; j * j <= i; j++) {
      for (int k = j; k * k <= i; k++) {
        for (int l = k; l * l <= i; l++) {
          if (j * j + k * k + l * l + j * l + j * k + k * l == i) {
            if (j == k && k == l)
              count++;
            else if (j == k || k == l || j == l)
              count += 3;
            else
              count += 6;
          }
        }
      }
    }
    cout << count << "\n";
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  solve();
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
signed main() {
  int n, ans, date[10000] = {};
  int x = 1, y = 1, z = 1;
  cin >> n;
  for (int i = 1; i <= (int)sqrt(n); i++) {
    for (int j = 1; j <= (int)sqrt(n); j++) {
      for (int k = 1; k <= (int)sqrt(n); k++) {
        date[i * i + j * j + k * k + (i * j) + (i * k) + (j * k)]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << date[i] << "\n";
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
signed main() {
  int n, ans, date[100000] = {};
  int x = 1, y = 1, z = 1;
  cin >> n;
  for (int i = 1; i <= (int)sqrt(n); i++) {
    for (int j = 1; j <= (int)sqrt(n); j++) {
      for (int k = 1; k <= (int)sqrt(n); k++) {
        date[i * i + j * j + k * k + (i * j) + (i * k) + (j * k)]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << date[i] << "\n";
  }
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <stdio.h>
#include <string>
#include <vector>

int main(void) {
  int n;
  long long s;
  std::cin >> n;
  std::vector<int> f(10100);
  for (int x = 1; x <= 110; x++) {
    for (int y = 1; y <= 110; y++) {
      for (int z = 1; z <= 110; z++) {
        s = x * x + y * y + z * z + x * y + y * z + z * x;
        f.at(s - 1) += 1;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    std::cout << f.at(i) << std::endl;
  }
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <stdio.h>
#include <string>
#include <vector>

int main(void) {
  int n;
  long long s;
  std::cin >> n;
  std::vector<int> f(1000500);
  for (int x = 1; x <= 102; x++) {
    for (int y = 1; y <= 102; y++) {
      for (int z = 1; z <= 102; z++) {
        s = x * x + y * y + z * z + x * y + y * z + z * x;
        f.at(s - 1) += 1;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    std::cout << f.at(i) << std::endl;
  }
  return 0;
}
Problem p02608 (Python)

Buggy submission (status: Runtime Error):
import sys

input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def checker():
    ans = [0] * 10000
    for a in range(1, 101):
        for b in range(1, 101):
            for c in range(1, 101):
                n = a * a + b * b + c * c + a * b + b * c + c * a
                if n > 10000:
                    continue
                else:
                    ans[n] += 1
    return ans


def main():
    N = int(input().strip())
    ans = checker()
    for n in range(1, N + 1):
        print(ans[n])
    return


if __name__ == "__main__":
    main()


Fixed submission:
import sys

input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def checker():
    ans = [0] * 10001
    for a in range(1, 101):
        for b in range(1, 101):
            for c in range(1, 101):
                n = a * a + b * b + c * c + a * b + b * c + c * a
                if n > 10000:
                    continue
                else:
                    ans[n] += 1
    return ans


def main():
    N = int(input().strip())
    ans = checker()
    for n in range(1, N + 1):
        print(ans[n])
    return


if __name__ == "__main__":
    main()
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int x = 1; x * x <= n; x++) {
      for (int y = x; y * y <= n; y++) {
        for (int z = y; z * z <= n; z++) {
          int res = x * x + y * y + z * z + x * y + y * z + z * x;
          if (res == i) {
            if (x == y && y == z)
              ans++;
            else if (x != y && y != z && z != x)
              ans += 6;
            else
              ans += 3;
          }
        }
      }
    }
    cout << ans << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

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

Buggy submission (status: Time Limit Exceeded):
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1001001001
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
int main() {
  int n;
  cin >> n;
  REP(i, n) {
    int cnt = 0;
    //        for(int x=0; x<100; x++) for(int y=0; y<100; y++) for(int z=0;
    //        z<100; z++){
    REP(x, n) REP(y, n) REP(z, n) {
      int reg = (x + 1) * (x + 1) + (y + 1) * (y + 1) + (z + 1) * (z + 1) +
                (x + 1) * (y + 1) + (y + 1) * (z + 1) + (z + 1) * (x + 1);
      if (reg > i + 1)
        break;
      if (reg == (i + 1))
        cnt++;
    }

    cout << cnt << endl;
  }
}

Fixed submission:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1001001001
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
int main() {
  int n;
  cin >> n;
  REP(i, n) {
    int cnt = 0;
    for (int x = 0; x < 100; x++)
      for (int y = x; y < 100; y++)
        for (int z = y; z < 100; z++) {
          int reg = (x + 1) * (x + 1) + (y + 1) * (y + 1) + (z + 1) * (z + 1) +
                    (x + 1) * (y + 1) + (y + 1) * (z + 1) + (z + 1) * (x + 1);
          if (reg > i + 1)
            break;
          if (reg == i + 1) {
            if ((x == y) && (y == z) && (z == x))
              cnt++;
            else if ((x != y) && (y != z) && (z != x))
              cnt += 6;
            else
              cnt += 3;
          }
        }
    cout << cnt << endl;
  }
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const int INF = 1e9;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
int a[10010];

int main() {
  cin >> N;

  rep2(i, 1, N / 3) rep2(j, 1, N / 3) rep2(k, 1, N / 3) {
    A = i * (i + j);
    B = j * (j + k);
    C = k * (k + i);

    A += B + C;
    if (A <= 10000)
      a[A]++;
  }
  rep2(i, 1, N + 1) { cout << a[i] << endl; }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const int INF = 1e9;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
int a[10010];

int main() {
  cin >> N;

  rep2(i, 1, N / 3) rep2(j, 1, N / 3) rep2(k, 1, N / 3) {
    A = i * (i + j);
    B = j * (j + k);
    C = k * (k + i);

    A += B + C;
    if (A <= 10000)
      a[A]++;
    else
      break;
  }
  rep2(i, 1, N + 1) { cout << a[i] << endl; }
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 220000
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld", &s);
#define sout(s) printf("%lld\n", s);
#define in(s) cin >> s
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define sp ' '
#define gear_change ios_base::sync_with_stdio(false), cin.tie(0)
#define nfl(i, n) for (i = 0; i < n; i++)
#define sfl(i, s, e) for (i = s; i < e; i++)
#define ufl(i, n) for (i = n - 1; i >= 0; i--)
ll power(ll x, ll y) {
  ll ret = 1;
  while (y > 0) {
    if (y & 1)
      ret = (ret * x);
    y /= 2;
    x = (x * x);
  }
  return ret;
}
vector<ll> divs(ll n) {
  vector<ll> ret;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      if (i * i == n) {
        ret.push_back(i);
      } else {
        ret.push_back(i);
        ret.push_back(n / i);
      }
    }
  }
  return ret;
}
unordered_map<ll, ll> m;
inline ll val(ll x, ll y, ll z) {
  return x * x + y * y + z * z + x * y + y * z + z * x;
}
void pre() {
  ll i, j, k;
  sfl(i, 1, 1000) {
    sfl(j, 1, 1000) {
      sfl(k, 1, 1000) { m[val(i, j, k)]++; }
    }
  }
}
void solve() {
  ll n, i, x;
  cin >> n;
  sfl(i, 1, n + 1) { cout << m[i] << endl; }
}
int main() {
  gear_change;
  ll test = 1;
  pre();
  // in(test);
  while (test--) {
    solve();
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 220000
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld", &s);
#define sout(s) printf("%lld\n", s);
#define in(s) cin >> s
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define sp ' '
#define gear_change ios_base::sync_with_stdio(false), cin.tie(0)
#define nfl(i, n) for (i = 0; i < n; i++)
#define sfl(i, s, e) for (i = s; i < e; i++)
#define ufl(i, n) for (i = n - 1; i >= 0; i--)
ll power(ll x, ll y) {
  ll ret = 1;
  while (y > 0) {
    if (y & 1)
      ret = (ret * x);
    y /= 2;
    x = (x * x);
  }
  return ret;
}
vector<ll> divs(ll n) {
  vector<ll> ret;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      if (i * i == n) {
        ret.push_back(i);
      } else {
        ret.push_back(i);
        ret.push_back(n / i);
      }
    }
  }
  return ret;
}
unordered_map<ll, ll> m;
inline ll val(ll x, ll y, ll z) {
  return x * x + y * y + z * z + x * y + y * z + z * x;
}
void pre() {
  ll i, j, k;
  sfl(i, 1, 1000) {
    sfl(j, 1, 1000) {
      sfl(k, 1, 1000) {
        m[val(i, j, k)]++;
        if (val(i, j, k) > 11000) {
          break;
        }
      }
    }
  }
}
void solve() {
  ll n, i, x;
  cin >> n;
  sfl(i, 1, n + 1) { cout << m[i] << endl; }
}
int main() {
  gear_change;
  ll test = 1;
  pre();
  // in(test);
  while (test--) {
    solve();
  }
}