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

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

using namespace std;
using ll = long long;

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

  for (ll i = 1; i <= n; i++) {
    ll sum = 0;
    for (ll j = 1; j * j <= n; j++) {
      for (ll k = 1; k * k <= n; k++) {
        for (ll l = 1; l * l <= n; l++) {
          if (l * l + j * j + k * k + l * k + l * j + k * j == i) {
            sum++;
          }
        }
      }
    }
    cout << sum << endl;
  }
  return 0;
}

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

using namespace std;
using ll = long long;

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

  for (ll i = 1; i <= n; i++) {
    ll sum = 0;
    for (ll j = 1; j * j <= n; j++) {
      for (ll k = 1; k * k <= n; k++) {
        if ((j + k) * (j + k) < (4 * (j * j + k * k + j * k - i))) {
          continue;
        }
        if (sqrt(((j + k) * (j + k)) - (4 * (j * j + k * k + j * k - i))) -
                    (j + k) >=
                1 &&
            (sqrt(((j + k) * (j + k)) - (4 * (j * j + k * k + j * k - i))) -
             (j + k)) -
                    floor(sqrt(((j + k) * (j + k)) -
                               (4 * (j * j + k * k + j * k - i))) -
                          (j + k)) ==
                0) {
          // cout << i << j << k << endl;
          // cout << sqrt( ((j + k) * (j + k)) - (4 * (j * j + k * k + j * k -
          // i) ) ) - (j + k) << endl;
          sum++;
        }
      }
    }
    cout << sum << endl;
  }
  return 0;
}
Problem p02608 (C++)

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

int main(int argc, char *argv[]) {
  int64_t N;
  std::cin >> N;
  const int64_t maxXYZ = int64_t(std::sqrt(double(N + 1)));

  for (int64_t n = 1; n <= N; ++n) {
    int cnt = 0;
    for (int64_t x = 1; x <= maxXYZ; ++x) {
      int64_t x2 = x * x;
      if (x2 > n) {
        continue;
      }
      for (int64_t y = 1; y <= maxXYZ; ++y) {
        int64_t y2 = y * y;
        int64_t xy = x * y;
        if (x2 + y2 + xy > n) {
          break;
        }
        for (int64_t z = 1; z <= maxXYZ; ++z) {
          int64_t z2 = z * z;
          if (x2 + y2 + xy + z2 > n) {
            break;
          }

          if (x2 + y2 + z2 + xy + y * z + z * x == n) {
            ++cnt;
          }
        }
      }
    }
    std::cout << cnt << std::endl;
  }
}


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

int main(int argc, char *argv[]) {
  int64_t N;
  std::cin >> N;
  const int64_t maxXYZ = int64_t(std::sqrt(double(N + 1)));

  for (int64_t n = 1; n <= N; ++n) {
    int cnt = 0;
    for (int64_t x = 1; x <= maxXYZ; ++x) {
      int64_t x2 = x * x;
      if (x2 > n) {
        break;
      }
      for (int64_t y = 1; y <= maxXYZ; ++y) {
        int64_t y2 = y * y;
        int64_t xy = x * y;
        if (x2 + y2 + xy > n) {
          break;
        }
        for (int64_t z = 1; z <= maxXYZ; ++z) {
          int64_t z2 = z * z;
          if (x2 + y2 + xy + z2 > n) {
            break;
          }

          if (x2 + y2 + z2 + xy + y * z + z * x == n) {
            ++cnt;
          }
        }
      }
    }
    std::cout << cnt << std::endl;
  }
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <array>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <unordered_map>
#include <utility>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[]) {
  ll n;
  cin >> n;

  for (ll i = 1; i <= n; i++) {
    ll ans = 0;

    for (ll x = 1; x * x < i; x++) {
      for (ll y = 1; y * y < i; y++) {
        for (ll 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 <algorithm>
#include <array>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <unordered_map>
#include <utility>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[]) {
  ll n;
  cin >> n;

  for (ll i = 1; i <= n; i++) {
    ll ans = 0;

    for (ll x = 1; x * x < i; x++) {
      for (ll y = 1; y * y + x * y + x * x < 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) {
            ans++;
          }
        }
      }
    }

    cout << ans << endl;
  }
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<int, int>;
const int INF = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vec f(n + 1, 0);

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

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


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<int, int>;
const int INF = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vec f(n + 1, 0);

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

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

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

using namespace std;
int t, n;
int d[10001];

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

  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;
int t, n;
int d[10001];

int main() {
  cin >> n;
  for (int x = 1; x * x <= n; x++)
    for (int y = 1; y * y <= n; y++)
      for (int z = 1; z * z <= n; z++) {
        t = x * x + y * y + z * z + x * y + y * z + z * x;
        if (t > n)
          break;
        d[t]++;
      }
  for (int i = 1; i <= n; i++)
    cout << d[i] << endl;

  return 0;
}
Problem p02608 (C++)

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

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

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

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int Ull;
typedef pair<int, int> PII;
template <typename T> inline T read() {
  char c = getchar();
  T x = 0, f = 1;
  while (!isdigit(c)) {
    if (c == '-')
      f = -1;
    c = getchar();
  }
  while (isdigit(c))
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  return x * f;
}
template <typename T> inline void write(T x) {
  if (x < 0)
    x = (~x) + 1, putchar('-');
  if (x / 10)
    write(x / 10);
  putchar(x % 10 | 48);
}
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
ll f(int x) {
  ll ans = 0;
  for (int i = 1; i <= 110; i++) {
    for (int j = 1; j <= 110; j++) {
      for (int s = 1; s <= 110; s++) {
        if (i * i + j * j + s * s + i * j + i * s + j * s == x)
          ans++;
        if (s * s > x)
          break;
      }
      if (j * j > x)
        break;
    }
    if (i * i > x)
      break;
  }
  return ans;
}
int main() {
  // ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

  int n = read<int>();
  for (int i = 1; i <= n; i++) {
    cout << f(i) << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int Ull;
typedef pair<int, int> PII;
template <typename T> inline T read() {
  char c = getchar();
  T x = 0, f = 1;
  while (!isdigit(c)) {
    if (c == '-')
      f = -1;
    c = getchar();
  }
  while (isdigit(c))
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  return x * f;
}
template <typename T> inline void write(T x) {
  if (x < 0)
    x = (~x) + 1, putchar('-');
  if (x / 10)
    write(x / 10);
  putchar(x % 10 | 48);
}
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
ll f(int x) {
  ll ans = 0;
  for (int i = 1; i <= 110; i++) {
    for (int j = i; j <= 110; j++) {
      for (int s = j; s <= 110; s++) {
        if (i * i + j * j + s * s + i * j + i * s + j * s == x) {
          if (i == j && j == s)
            ans += 1;
          else if (i == j || j == s)
            ans += 3;
          else
            ans += 6;
        }
        if (s * s > x)
          break;
      }
      if (j * j > x)
        break;
    }
    if (i * i > x)
      break;
  }
  return ans;
}
int main() {
  // ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
  ll l, r, i, j, k, n, m, x;
  cin >> n;
  ll ar[1005] = {0};
  for (i = 1; i <= 100; i++) {
    for (j = 1; j <= 100; j++) {
      for (k = 1; k <= 100; k++) {
        //				cout<<i<<' '<<j<<' '<<k<<endl;
        ll x = i * i + j * j + k * k + i * j + j * k + k * i;
        if (x <= n)
          ar[x]++;
      }
    }
  }
  for (i = 1; i <= n; i++)
    cout << ar[i] << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
  ll l, r, i, j, k, n, m, x;
  cin >> n;
  ll ar[10005] = {0};
  for (i = 1; i <= 100; i++) {
    for (j = 1; j <= 100; j++) {
      for (k = 1; k <= 100; k++) {
        //				cout<<i<<' '<<j<<' '<<k<<endl;
        ll x = i * i + j * j + k * k + i * j + j * k + k * i;
        if (x <= n)
          ar[x]++;
      }
    }
  }
  for (i = 1; i <= n; i++)
    cout << ar[i] << endl;
}
Problem p02608 (C++)

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

int main() {
  int N;
  cin >> N;
  for (int i = 1; i < N + 1; i++) {
    int ANS = 0;
    for (int j = 1; pow(j, 2) < i; j++) {
      for (int k = 1; pow(k, 2) < i; k++) {
        if (pow(j + k, 2) - j * k > i) {
          break;
        }
        for (int l = 1; pow(l, 2) < i; l++) {
          if (pow(j + k + l, 2) - j * k - k * l - j * l > i) {
            break;
          }
          if (pow(j + k + l, 2) - j * k - k * l - j * l == i) {
            ANS++;
          }
        }
      }
    }
    cout << ANS << endl;
  }
}


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

int main() {
  int N;
  cin >> N;
  for (int i = 1; i < N + 1; i++) {
    int ANS = 0;
    for (int j = 1; j * j <= i; j++) {
      for (int k = 1; (j + k) * (j + k) - j * k <= i; k++) {
        for (int l = 1; (j + k + l) * (j + k + l) - j * k - k * l - j * l <= i;
             l++) {
          if ((j + k + l) * (j + k + l) - j * k - k * l - j * l == i) {
            ANS++;
          }
        }
      }
    }
    cout << ANS << endl;
  }
}
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, 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 num = x * x + y * y + z * z + x * y + y * z + z * x;
        ans[num]++;
      }
    }
  }
  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(1000000, 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 num = x * x + y * y + z * z + x * y + y * z + z * x;
        ans[num]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <stdio.h>
#pragma warning(disable : 4996)

// prototype
int counter(int);

int main() {
  // input
  int N;
  (void)scanf("%d", &N);

  // output
  for (int i = 1; i <= N; i++) {
    printf("%d\n", counter(i));
  }
}

int counter(int i) {
  int count = 0;
  for (int x = 1; x * x < i; x++) {
    for (int y = 1; y * y < i - (x * x); y++) {
      for (int z = 1; z * z < i - (x * x) - (y * y); z++) {
        if (((x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x)) == i)
          count++;
      }
    }
  }
  return count;
}

Fixed submission:
#include <stdio.h>
#pragma warning(disable : 4996)

// prototype
int counter(int);

int main() {
  // input
  int N;
  (void)scanf("%d", &N);

  // output
  for (int i = 1; i <= N; i++) {
    printf("%d\n", counter(i));
  }
}

int counter(int i) {
  int count = 0;
  for (int x = 1; x * (x + 2) <= (i - 3); x++) {
    for (int y = 1; y * (x + y + 1) <= i - ((x * x) + x + 1); y++) {
      for (int z = 1;
           ((x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x)) <= i;
           z++) {
        if (((x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x)) == i)
          count++;
      }
    }
  }
  return count;
}
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 - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

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

  int N;
  cin >> N;
  int n = sqrt(N);
  vector<int> f(N + 1);
  FOR(i, 1, N + 1) {
    FOR(j, 1, N + 1) {
      FOR(k, 1, N + 1) {
        int v = g(i, j, k);
        if (v <= N) {
          f[v]++;
        }
      }
    }
  }
  FOR(i, 1, N + 1) { cout << f[i] << 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 - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

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

  int N;
  cin >> N;
  int n = sqrt(N);
  vector<int> f(N + 1);
  FOR(i, 1, n + 1) {
    FOR(j, 1, n + 1) {
      FOR(k, 1, n + 1) {
        int v = g(i, j, k);
        if (v <= N) {
          f[v]++;
        }
      }
    }
  }
  FOR(i, 1, N + 1) { cout << f[i] << endl; }

  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n;
  cin >> n;
  int a[10001] = {0};
  for (int i = 1; i * i <= 10050; i++) {
    for (int j = 1; j * j <= 10050; j++) {
      for (int k = 1; k * k <= 10050; k++) {
        ll x = i * i + j * j + k * k + i * j + j * k + k * i;
        if (x <= 10050) {
          a[x]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n;
  cin >> n;
  int a[10001] = {0};
  for (int i = 1; i * i <= 10050; i++) {
    for (int j = 1; j * j <= 10050; j++) {
      for (int k = 1; k * k <= 10050; k++) {
        ll x = i * i + j * j + k * k + i * j + j * k + k * i;
        if (x <= 10000) {
          a[x]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << endl;
  }
}
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;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> ans(1000000000);
  for (int i = 1; i < n; i++) {
    for (int j = 1; j < n; j++) {
      for (int k = 1; k < n; k++) {
        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 <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> ans(100000000);
  for (int i = 1; i <= sqrt(n); i++) {
    for (int j = 1; j <= sqrt(n); j++) {
      for (int k = 1; k <= sqrt(n); k++) {
        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: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define arep(x, n) for (int x : n)
using namespace std;

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

  vector<int> ans(n);

  int max = sqrt(n);
  // bool over_x, over_y, over_z;
  int tmp = 0;

  for (int i = 6; i <= n; i++) {

    for (int x = 1; x <= max; x++) {

      for (int y = 1; y <= max; y++) {

        for (int z = 1; z <= max; z++) {
          tmp = x * x + y * y + z * z + x * y + y * z + z * x;

          if (tmp == i)
            ans.at(i - 1)++;
        }
      }
    }
  }

  arep(x, ans) cout << x << endl;
}

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

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

  vector<int> ans(n);

  int max = sqrt(n);
  // bool over_x, over_y, over_z;
  int tmp = 0;

  for (int i = 6; i <= n; i++) {

    for (int x = 1; x <= max; x++) {

      for (int y = 1; y <= max; y++) {

        for (int z = 1; z <= max; z++) {
          tmp = x * x + y * y + z * z + x * y + y * z + z * x;
          if (tmp > i)
            break;
          if (tmp == i)
            ans.at(i - 1)++;
        }
      }
    }
  }

  arep(x, ans) cout << x << endl;
}
Problem p02608 (C++)

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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int c = 0;
    for (int x = 1; x <= i; x++) {
      for (int y = 1; y <= i; y++) {
        // cout << (y + x) * (y + x) - 4 * (-i + x * x + y * y + x * y) << "\n";
        int tmp = pow(x + y, 2) - 4 * (pow(x, 2) + pow(y, 2) + x * y - i);
        if (tmp == 0) {
          int z = (-1 * (x + y) + sqrt(tmp)) / 2;
          if (z >= 1 &&
              pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x == i) {
            c++;
          }
        } else if (tmp > 0) {
          int z = (-1 * (x + y) + sqrt(tmp)) / 2;
          if (z >= 1 &&
              pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x == i) {
            c++;
          }
          z = (-1 * (x + y) - sqrt(tmp)) / 2;
          if (z >= 1 &&
              pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x == i) {
            c++;
          }
        }
      }
    }
    cout << c << " \n";
  }
}

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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int c = 0;
    for (int x = 1; x <= sqrt(i); x++) {
      for (int y = 1; y <= sqrt(i); y++) {
        // cout << (y + x) * (y + x) - 4 * (-i + x * x + y * y + x * y) << "\n";
        int tmp = pow(x + y, 2) - 4 * (pow(x, 2) + pow(y, 2) + x * y - i);
        if (tmp == 0) {
          int z = (-1 * (x + y) + sqrt(tmp)) / 2;
          if (z >= 1 &&
              pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x == i) {
            c++;
          }
        } else if (tmp > 0) {
          int z = (-1 * (x + y) + sqrt(tmp)) / 2;
          if (z >= 1 &&
              pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x == i) {
            c++;
          }
          z = (-1 * (x + y) - sqrt(tmp)) / 2;
          if (z >= 1 &&
              pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x == i) {
            c++;
          }
        }
      }
    }
    cout << c << " \n";
  }
}
Problem p02608 (C++)

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

constexpr llong mod = 1e9 + 7;
constexpr llong inf = mod * mod;

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

  for (llong i = 1; i <= N; ++i) {
    llong cnt = 0;
    for (llong x = 1; x <= 1000; x++) {
      for (llong y = x; y <= 1000; y++) {
        for (llong z = y; z <= 1000; z++) {
          llong sum = x * x + y * y + z * z + x * y + x * z + y * z - i;
          if (sum == 0) {
            if (x == y && y == z) {
              cnt += 1;
            } else if (x == y || y == z || x == z) {
              cnt += 3;
            } else {
              cnt += 6;
            }
          }
          if (sum > i) {
            break;
          }
        }
      }
    }

    cout << cnt << endl;
  }

  return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

constexpr llong mod = 1e9 + 7;
constexpr llong inf = mod * mod;

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

  for (llong i = 1; i <= N; ++i) {
    llong cnt = 0;
    for (llong x = 1; x <= 1000; x++) {
      for (llong y = 1; y <= 1000; y++) {
        if (x * x + y * y + x * y > i) {
          break;
        }

        llong d = (x + y) * (x + y) - 4 * (x * x + y * y + x * y - i);
        llong sqrt_d = sqrtl(d);
        if (sqrt_d * sqrt_d == d && sqrt_d - (x + y) > 0 &&
            (sqrt_d - (x + y)) % 2 == 0) {
          cnt++;
        }
      }
    }

    cout << cnt << endl;
  }

  return 0;
}
Problem p02608 (C++)

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

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

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


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

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

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

            else if (x == y || y == z || z == x) {
              cnt += 3;
            }

            else {
              cnt += 6;
            }
          }
        }
      }
    }
    cout << cnt << endl;
  }
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll long long
#define INF 10000000000000000LL
#define pll pair<long long, long long>
const int MAX = 1e7 + 9;
const ll MOD = 1e9 + 7;
const int TOT_PRIMES = 19;
const int MAX_A = 70;
using namespace std;
int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int cnt = 0;
  int arr[n + 1];
  memset(arr, 0, sizeof(arr));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        int now = (i * i) + (j * j) + (k * k) + (i * k) + (i * j) + (j * k);
        if (now > n)
          continue;
        arr[now] = arr[now] + 1;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << arr[i] << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll long long
#define INF 10000000000000000LL
#define pll pair<long long, long long>
const int MAX = 1e7 + 9;
const ll MOD = 1e9 + 7;
const int TOT_PRIMES = 19;
const int MAX_A = 70;
using namespace std;
int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int cnt = 0;
  int arr[n + 1];
  memset(arr, 0, sizeof(arr));
  for (int i = 1; i <= sqrt(n); i++) {
    for (int j = 1; j <= sqrt(n); j++) {
      for (int k = 1; k <= sqrt(n); k++) {
        int now = (i * i) + (j * j) + (k * k) + (i * k) + (i * j) + (j * k);
        if (now > n)
          continue;
        arr[now] = arr[now] + 1;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << arr[i] << endl;
}
Problem p02608 (C++)

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


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll ans[10001] = {};
int main() {
  int n_max;
  cin >> n_max;
  for (int x = 1; x * x <= n_max; ++x) {
    for (int y = 1; x * x + y * y + x * y <= n_max; ++y) {
      for (int z = 1; x * x + y * (x + y) + z * (x + y + z) <= n_max; ++z) {
        ans[x * x + y * (x + y) + z * (x + y + z)]++;
      }
    }
  }
  for (int i = 1; i <= n_max; ++i) {
    cout << ans[i] << 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 X = N / 6 + 1;
  int F;

  for (int l = 1; l <= N; l++) {
    F = 0;
    for (int i = 1; i <= X; i++) {
      for (int j = i; j <= X; j++) {
        for (int k = j; k <= X; k++) {
          if (i * i + j * j + k * k + i * j + j * k + k * i == l) {
            if (i == j && j == k) {
              F++;
            } else if (i != j && j != k && k != i) {
              F += 6;
            } else {
              F += 3;
            }
          }
        }
      }
    }
    cout << F << endl;
  }
}

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

int main() {
  int N;
  cin >> N;
  int X = sqrt(N) + 1;
  int F;

  for (int l = 1; l <= N; l++) {
    F = 0;
    for (int i = 1; i <= X; i++) {
      for (int j = i; j <= X; j++) {
        for (int k = j; k <= X; k++) {
          if (i * i + j * j + k * k + i * j + j * k + k * i == l) {
            if (i == j && j == k) {
              F++;
            } else if (i != j && j != k && k != i) {
              F += 6;
            } else {
              F += 3;
            }
          }
        }
      }
    }
    cout << F << 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 < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
const int dx[] = {0, 1, -1, 0};
const int dy[] = {1, 0, 0, -1};
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //////////////////////////////////////
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int x = 1; x <= sqrt(n); x++) {
      for (int y = x; y <= sqrt(n); y++) {
        for (int z = y; z <= sqrt(n); z++)
          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            map<int, int> mp;
            mp[x]++;
            mp[y]++;
            mp[z]++;
            if (mp.size() == 1)
              ans++;
            if (mp.size() == 2)
              ans += 3;
            if (mp.size() == 3)
              ans += 6;
          }
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
const int dx[] = {0, 1, -1, 0};
const int dy[] = {1, 0, 0, -1};
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //////////////////////////////////////
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int x = 1; x <= sqrt(n); x++) {
      for (int y = x; y <= sqrt(n); y++) {
        for (int z = y; z * (z + x + y) <= i - x * x - y * y - x * y; z++)
          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            map<int, int> mp;
            mp[x]++;
            mp[y]++;
            mp[z]++;
            if (mp.size() == 1)
              ans++;
            if (mp.size() == 2)
              ans += 3;
            if (mp.size() == 3)
              ans += 6;
          }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
#define PI 3.14159265359

using namespace std;
const int64_t mod = 1000000007;
const int64_t tmpMod = 998244353;

int main() {

  int64_t N;
  cin >> N;
  vector<int64_t> A(N, 0);
  // for(int i=0; i<N; i++){cin>>A[i];}
  // vector<vector<int> > A(N,vector<int>(M));
  for (int i = 1; i < 100; i++) {
    for (int j = 1; j < 100; j++) {
      for (int k = 1; k < 100; k++) {
        A[(i * i) + (j * j) + k * k + i * j + j * k + k * i - 1]++;
      }
    }
  }
  // sort(A.begin(),A.end());
  // for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  for (int i = 0; i < N; i++) {
    cout << A[i] << endl;
  }
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
#define PI 3.14159265359

using namespace std;
const int64_t mod = 1000000007;
const int64_t tmpMod = 998244353;

int main() {

  int64_t N;
  cin >> N;
  vector<int64_t> A(N, 0);
  // for(int i=0; i<N; i++){cin>>A[i];}
  // vector<vector<int> > A(N,vector<int>(M));
  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 - 1 < N)
          A[(i * i) + (j * j) + k * k + i * j + j * k + k * i - 1]++;
      }
    }
  }
  // sort(A.begin(),A.end());
  // for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  for (int i = 0; i < N; i++) {
    cout << A[i] << endl;
  }
}
Problem p02608 (C++)

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

int main() {
  int N = 10010;
  vector<int> vec(N);
  int n;
  cin >> n;
  for (int i = 1; i * i < N; i++) {
    for (int j = 1; j * j < N; j++) {
      for (int k = 1; k * k < N; k++) {
        int a = i * i + j * j + k * k;
        int b = i * j + j * k + k * i;
        if (a + b > N)
          break;

        vec.at(a + b)++;
      }
    }
  }

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


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

int main() {
  int N = 10010;
  vector<int> vec(N);
  int n;
  cin >> n;
  for (int i = 1; i * i < N; i++) {
    for (int j = 1; j * j < N; j++) {
      for (int k = 1; k * k < N; k++) {
        int a = i * i + j * j + k * k;
        int b = i * j + j * k + k * i;
        if (a + b >= N)
          break;

        vec.at(a + b)++;
      }
    }
  }

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

Buggy submission (status: Runtime Error):
#include <cstdio>
int n, f[1100], data[101][101][101];
void check(int x, int y, int z) {
  int tmp = x * x + y * y + z * z + x * y + y * z + z * x;
  if (tmp > n)
    return;
  data[x][y][z] = 1;
  if (!data[x + 1][y][z])
    check(x + 1, y, z);
  if (!data[x][y + 1][z])
    check(x, y + 1, z);
  if (!data[x][y][z + 1])
    check(x, y, z + 1);
}
int main() {
  scanf("%d", &n);
  check(1, 1, 1);
  for (int i = 1; i <= 100; ++i)
    for (int j = 1; j <= 100; ++j)
      for (int k = 1; k <= 100; ++k)
        if (data[i][j][k])
          f[i * i + j * j + k * k + i * j + j * k + k * i]++;
  for (int i = 1; i <= n; ++i)
    printf("%d\n", f[i]);
  return 0;
}

Fixed submission:
#include <cstdio>
int n, f[11000], data[101][101][101];
void check(int x, int y, int z) {
  int tmp = x * x + y * y + z * z + x * y + y * z + z * x;
  if (tmp > n)
    return;
  data[x][y][z] = 1;
  if (!data[x + 1][y][z])
    check(x + 1, y, z);
  if (!data[x][y + 1][z])
    check(x, y + 1, z);
  if (!data[x][y][z + 1])
    check(x, y, z + 1);
}
int main() {
  scanf("%d", &n);
  check(1, 1, 1);
  for (int i = 1; i <= 100; ++i)
    for (int j = 1; j <= 100; ++j)
      for (int k = 1; k <= 100; ++k)
        if (data[i][j][k])
          f[i * i + j * j + k * k + i * j + j * k + k * i]++;
  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> count(N, 0);

  int max;
  for (int i = 0; i < N; i++) {
    if (i * i > N) {
      max = i - 1;
      break;
    }
  }
  if (N == 1) {
    max = 1;
  }

  // これでmax求まった

  int value;

  for (int i = 1; i <= max; i++) {
    for (int j = 1; j <= max; j++) {
      if (i * i + j * j + i * j + i + j + 1 > N)
        break;
      for (int k = 1; k <= max; k++) {
        value = i * i + j * j + k * k + i * j + j * k + k * i;
        if (value > N)
          break;
        count.at(value)++;
      }
    }
  }

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


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

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

  vector<int> count(N, 0);

  int max;
  for (int i = 0; i < N; i++) {
    if (i * i > N) {
      max = i - 1;
      break;
    }
  }
  if (N == 1) {
    max = 1;
  }

  // これでmax求まった

  int value;

  for (int i = 1; i <= max; i++) {
    for (int j = 1; j <= max; j++) {
      if (i * i + j * j + i * j + i + j + 1 > N)
        break;
      for (int k = 1; k <= max; k++) {
        value = i * i + j * j + k * k + i * j + j * k + k * i;
        if (value > N)
          break;
        count.at(value - 1)++;
      }
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  t = 1;
  while (t--) {
    long long n, i, c = 0, x, j, k;
    map<long long, long long> m;
    cin >> n;
    for (i = 1; i <= 1000; i++) {
      for (j = 1; j <= 1000; j++) {
        for (k = 1; k <= 1000; k++) {
          x = i * i + j * j + k * k + (i * j) + (j * k) + (k * i);

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  t = 1;
  while (t--) {
    long long n, i, c = 0, x, j, k;
    map<long long, long long> m;
    cin >> n;
    for (i = 1; i <= 1000; i++) {
      for (j = 1; j <= 1000; j++) {
        for (k = 1; k <= 1000; k++) {
          x = i * i + j * j + k * k + (i * j) + (j * k) + (k * i);
          if (x <= 10000) {
            m[x]++;
          }
        }
      }
    }
    for (i = 1; i <= n; i++) {
      cout << m[i] << endl;
    }
  }
}
Problem p02608 (C++)

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

bool f(int val, int rhs) {
  bool ok = false;
  for (int i = 1; i < 100; i++) {
    if (i * (i + val) == rhs)
      ok = true;
  }
  return ok;
}

int main() {
  int N;
  cin >> N;
  vector<int> ans(N);
  vector<vector<bool>> table(200, vector<bool>(10000));
  for (int i = 0; i < 300; i++) {
    for (int j = 0; j < 1000; j++) {
      table[i][j] = f(i, j);
    }
  }

  for (int x = 1; x <= N; x++) {
    int num = 0;
    for (int i = 1; i * i < x; i++) {
      for (int j = 1; j * j < x; j++) {
        int rhs = x - i * i - j * j - i * j;
        if (rhs <= 0)
          continue;
        else {
          int val = i + j;
          if (table[val][rhs])
            num++;
        }
      }
    }
    ans[x - 1] = num;
  }
  for (int i = 0; i < N; i++) {
    cout << ans[i] << endl;
  }
}

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

bool f(int val, int rhs) {
  bool ok = false;
  for (int i = 1; i < 100; i++) {
    if (i * (i + val) == rhs)
      ok = true;
  }
  return ok;
}

int main() {
  int N;
  cin >> N;
  vector<int> ans(N);
  vector<vector<bool>> table(200, vector<bool>(10000));
  for (int i = 0; i < 200; i++) {
    for (int j = 0; j < 10000; j++) {
      table[i][j] = f(i, j);
    }
  }

  for (int x = 1; x <= N; x++) {
    int num = 0;
    for (int i = 1; i * i < x; i++) {
      for (int j = 1; j * j < x; j++) {
        int rhs = x - i * i - j * j - i * j;
        if (rhs <= 0)
          continue;
        else {
          int val = i + j;
          if (table[val][rhs])
            num++;
        }
      }
    }
    ans[x - 1] = num;
  }
  for (int i = 0; i < N; i++) {
    cout << ans[i] << endl;
  }
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(), (v).end()
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const ll INF = 1LL << 60;
const int inf = (1 << 30) - 1;
const int mod = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, -1, -1, 1, 1};
int dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> res(n + 1);
  FOR(i, 1, 101) {
    FOR(j, 1, 101) {
      FOR(k, 1, 101) {
        if (i * i + j * j + k * k > n) {
          continue;
        }
        res[i * i + j * j + k * k + i * j + j * k + k * i]++;
      }
    }
  }
  FOR(i, 1, n + 1) { cout << res[i] << endl; }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(), (v).end()
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const ll INF = 1LL << 60;
const int inf = (1 << 30) - 1;
const int mod = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, -1, -1, 1, 1};
int dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> res(n + 1);
  FOR(i, 1, 101) {
    FOR(j, 1, 101) {
      FOR(k, 1, 101) {
        if (i * i + j * j + k * k + i * j + j * k + k * i > n) {
          continue;
        }
        res[i * i + j * j + k * k + i * j + j * k + k * i]++;
      }
    }
  }
  FOR(i, 1, n + 1) { cout << res[i] << endl; }
}
Problem p02608 (C++)

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

ll fact(int x) {
  if (x == 1)
    return 1;
  else
    return x * fact(x - 1);
}

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


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

ll fact(int x) {
  if (x == 1)
    return 1;
  else
    return x * fact(x - 1);
}

int main() {
  int n;
  cin >> n;
  int rt = sqrt(n) + 1;
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    for (int x = 1; x <= rt; x++) {
      for (int y = 1; y <= rt; y++) {
        for (int z = 1; z <= rt; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            cnt++;
          } else if (x * x + y * y + z * z + x * y + y * z + z * x > i)
            break;
        }
      }
    }
    cout << cnt << endl;
  }
}
Problem p02608 (C++)

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

#define ll long long
#define dd double
#define scl(n) scanf("%lld", &n)
#define scd(n) scanf("%lf", &n)
#define ptl(n) printf("%lld", n)
#define ptd(n) printf("%lf", n)
#define nline printf("\n")
#define vld vector<ll>
#define vbd vector<bool>
#define eb emplace_back
#define FOR(i, n) for (ll i = 0; i < n; i++)
#define FOR1(i, n) for (ll i = 1; i <= n; i++)
#define pi 2 * acos(0.0)

using namespace std;

int main() {
  ll n, l, i, j, k, eq[10004] = {0}, cnt = 0;
  scl(n);
  for (i = 1; i * i + 2 * i + 3 <= n; i++) {
    for (j = 1; j * j + 2 * j + 3 <= n; j++) {
      for (k = 1; k * k + 2 * k + 3 <= n; k++) {
        eq[i * i + j * j + k * k + i * j + j * k + k * i]++;
      }
    }
  }
  FOR1(i, n) {
    ptl(eq[i]);
    nline;
  }
  return 0;
}


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

#define ll long long
#define dd double
#define scl(n) scanf("%lld", &n)
#define scd(n) scanf("%lf", &n)
#define ptl(n) printf("%lld", n)
#define ptd(n) printf("%lf", n)
#define nline printf("\n")
#define vld vector<ll>
#define vbd vector<bool>
#define eb emplace_back
#define FOR(i, n) for (ll i = 0; i < n; i++)
#define FOR1(i, n) for (ll i = 1; i <= n; i++)
#define pi 2 * acos(0.0)

using namespace std;

int main() {
  ll n, l, i, j, k, eq[100000] = {0}, cnt = 0;
  scl(n);
  for (i = 1; i * i + 2 * i + 3 <= n; i++) {
    for (j = 1; j * j + 2 * j + 3 <= n; j++) {
      for (k = 1; k * k + 2 * k + 3 <= n; k++) {
        eq[i * i + j * j + k * k + i * j + j * k + k * i]++;
      }
    }
  }
  FOR1(i, n) {
    ptl(eq[i]);
    nline;
  }
  return 0;
}
Problem p02608 (C++)

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

int main() {
  cin.tie(0)->sync_with_stdio(false);

  int n;
  cin >> n;

  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    for (int x = 1; x <= sqrt(n); x++) {
      for (int y = 1; y <= sqrt(n); y++) {
        for (int z = 1; z <= sqrt(n); z++) {
          if (pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x == i)
            cnt++;
        }
      }
    }
    cout << cnt << '\n';
  }
  return 0;
}

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

int main() {
  cin.tie(0)->sync_with_stdio(false);

  int n;
  cin >> n;

  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    for (int x = 1; x <= sqrt(n); x++) {
      for (int y = 1; y <= sqrt(n); y++) {
        double d = sqrt(-2 * x * y - 3 * pow(x, 2) - 3 * pow(y, 2) + 4 * i);
        if (floor(d) == d) {
          double z = (-x - y + d) / 2;
          if (floor(z) == z && z > 0) {
            if (pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x == i)
              cnt++;
          }
        }
      }
    }
    cout << cnt << '\n';
  }
  return 0;
}