alexjercan/bugnet huggingface dataset:
Problem p02608 (C++) — buggy submission, verdict: 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 <= 10000) {
          a[x]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << endl;
  }
}

Error: -6
*** stack smashing detected ***: terminated


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 <= 10050) {
          a[x]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define SIZ 1000000000
#define mod 10000007

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

  ll n;
  cin >> n;

  unordered_map<ll, ll> mp;
  for (ll i = 1; i <= 100; i++) {
    for (ll j = 1; j <= 100; j++) {
      for (ll k = 1; k <= 100; k++) {
        ll z = i * i + j * j + k * k + i * j + j * k + i * k;
        if (!mp.count(z))
          mp[z] = 1;
        else
          mp[z]++;

        if (z >= 10004) {
          break;
        }
      }
    }
  }

  ll cnt = 0;
  for (ll i = 1; i <= n; i++) {
    if (mp.count(i))
      cout << mp[i] << "\\n";
    else
      cout << 0 << "\\n";
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define SIZ 1000000000

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

  ll n;
  cin >> n;

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

    for (ll j = 1; j * j <= i; j++) {
      for (ll k = 1; k * k <= i; k++) {
        for (ll m = 1; m * m <= i; m++) {
          ll x = j + k + m;
          if ((pow(x, 2) - (j * k + k * m + j * m)) == i) {
            cnt++;
          }
        }
      }
    }

    cout << cnt << "\\n";
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {

  int N;
  cin >> N;
  int i;
  int count = 0;
  int x;
  int y;
  int z;
  for (i = 1; i <= N; i++) {

    count = 0;
    for (x = 1; x * x < i; x++) {

      for (y = x; y * y < i; y++) {

        for (z = y; z * z < i; z++) {

          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {

            if (x == y) {

              if (y == z) {

                count += 1;
              } else {

                count += 3;
              }
            } else if (y == z) {

              count += 3;
            } else {

              count += 6;
            }
            // cout<<x<<","<<y<<","<<z<<endl;
          }
        }
      }
    }
    cout << count << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#include <math.h>
using namespace std;
int main() {
  int x;
  int y;
  int z;
  int N;
  int count = 0;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    count = 0;
    int max = sqrt((double)i);
    for (x = 1; x <= max; x++) {
      for (y = 1; y <= max; y++) {
        for (z = 1; z <= max; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i)
            count++;
        }
      }
      // (x+y+z)(x*x+y*y+z*z+xy+yz+zx)=x^3*y^3+z^3-3xyz
    }
    cout << count << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int a(0), b, c, ans(0), tmp(0);
  string s;
  cin >> a;
  int x[a];
  for (int i = 0; i < a; i++)
    x[i] = 0;

  for (int i = 5; i < a + 1; i++) {
    for (int h = 1; h < i; h++) {
      for (int j = 1; j < i - h; j++) {
        if (h * h + j * j + 1 * 1 + h * j + j * 1 + h * 1 > i)
          break;
        for (int k = 1; k < i - h - j; k++) {
          if (h * h + j * j + k * k + h * j + j * k + h * k == i) {
            x[i - 1] += 1;
          } else if (h * h + j * j + k * k + h * j + j * k + h * k > i)
            break;
        }
      }
    }
  }
  for (int i = 0; i < a; i++)
    cout << x[i] << endl;
}


Error: TLE

Fixed submission:

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

int main() {
  int a(0), b, c, ans(0), tmp(0);
  string s;
  cin >> a;
  int x[a];
  for (int i = 0; i < a; i++)
    x[i] = 0;

  for (int i = 1; i < a; i++) {
    for (int h = 1; h < i; h++) {
      for (int j = 1; j < i - h; j++) {
        for (int k = 1; k < i - h - j; k++) {
          if (h * h + j * j + k * k + h * j + j * k + h * k == i) {
            x[i - 1] += 1;
          }
        }
      }
    }
  }
  for (int i = 0; i < a; i++)
    cout << x[i] << endl;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n, cnt1 = 0, cnt2 = 0, cnt3 = 0;
  cin >> n;
  for (int l = 1; l <= n; l++) {
    cnt1 = 0, cnt2 = 0;
    // 処理
    int m = sqrt(n);
    for (int i = 1; i <= m; i++) {
      for (int j = i; j <= m; j++) {
        for (int k = j; k <= m; k++) {
          if ((i * i + j * j + k * k + i * j + j * k + k * i) == l) {
            cnt1++;
            if (i == j || j == k || k == i)
              cnt2++;
          }
        }
      }
    }
    cnt3 = 0;
    bool check = 0;
    for (int i = 1; i < 100; i++) {
      if (l == 6 * i * i) {
        check = 1;
        break;
      }
      if (l < 6 * i * i)
        break;
    }
    if (check == 1)
      cnt3 = 1;

    // 処理　　
    cout << (cnt1 - cnt2) * 6 + (cnt2 - cnt3) * 3 + cnt3 << endl;
  }
}


Error: TLE

Fixed submission:

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

int main() {
  int n, cnt1 = 0, cnt2 = 0, cnt3 = 0;
  cin >> n;
  for (int l = 1; l <= n; l++) {
    cnt1 = 0, cnt2 = 0;
    // 処理
    int m = sqrt(n);
    for (int i = 1; i <= m; i++) {
      for (int j = i; j <= m; j++) {
        for (int k = j; k <= m; k++) {
          if ((i * i + j * j + k * k + i * j + j * k + k * i) == l)
            cnt1++;
        }
      }
    }
    for (int i = 1; i < m - 1; i++) {
      for (int j = i + 1; j < m; j++) {
        for (int k = j + 1; k <= m; k++) {
          if ((i * i + j * j + k * k + i * j + j * k + k * i) == l)
            cnt2++;
        }
      }
    }
    cnt3 = 0;
    bool check = 0;
    for (int i = 1; i < 100; i++) {
      if (l == 6 * i * i) {
        check = 1;
        break;
      }
      if (l < 6 * i * i)
        break;
    }
    if (check == 1)
      cnt3 = 1;

    // 処理　　
    cout << cnt2 * 6 + (cnt1 - cnt2 - cnt3) * 3 + cnt3 << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
#ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
#endif
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    long long ans = 0, v1 = 0, v2 = 0, v3 = 0;
    for (long long x = 1; x <= n; x++) {
      v1 = x * x;
      if (v1 >= i)
        break;
      for (long long y = 1; y <= n; y++) {
        v2 = v1 + y * y + x * y;
        if (v2 >= i)
          break;
        for (long long z = 1; z <= n; z++) {
          long long v3 = v2 + z * z + y * z + z * x;
          if (v3 == i)
            ans++;
          if (v3 > i)
            break;
        }
      }
    }
    cout << ans << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
#ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
#endif
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    long long ans = 0;
    for (long long x = 1; x <= n; x++)
      for (long long y = 1; y <= n; y++)
        for (long long z = 1; z <= n; z++) {
          long long v = x * x + y * y + z * z + x * y + y * z + z * x;
          if (v == i)
            ans++;
          if (v > i)
            break;
        }
    cout << ans << endl;
  }

  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define MAX 100000

int ans[MAX];

void func() {
  int l = sqrt(MAX) + 1;
  for (int x = 1; x <= l; x++) {
    for (int y = 1; y <= l; y++) {
      for (int z = 1; z <= l; z++) {
        int v = x * x + y * y + z * z + x * y + y * z + z * x;
        if (v < MAX) {
          ans[v] += 1;
        }
      }
    }
  }
}

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


Error: TLE

Fixed submission:

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

void func(int n) {
  int ans = 0;
  int l = sqrt(n) + 1;
  for (int x = 1; x <= l; x++) {
    for (int y = 1; y <= l; y++) {
      for (int z = 1; z <= l; z++) {
        if (n == x * x + y * y + z * z + x * y + y * z + z * x)
          ans++;
      }
    }
  }
  cout << ans << endl;
}

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++)
    func(i);
}
Problem p02608 (C++) — buggy submission, verdict: 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) {
        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;
  }
}


Error: TLE

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) {
        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;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n + 1; i++) {
    int ans = 0;
    int x = 1;
    float g1;
    g1 = sqrt(n / 6.00);
    while (x <= g1) {
      int y = x;
      // cout<<x<<endl;
      float g2;
      g2 = (sqrt(3.00 * i - 2.00 * x * x) - x) / 3.00;
      while (y <= g2) {
        int z;
        z = (sqrt(4 * i - 3 * x * x - 3 * y * y - 2 * x * y) - x - y) / 2;
        int g4;
        g4 = x * x + y * y + z * z + x * y + y * z + z * x;
        // cout<<x<<y<<z<<endl;
        if (g4 == i) {
          if (x == y && y == z)
            ans += 1;
          else if (x == y || y == z || z == x)
            ans += 3;
          else
            ans += 6;
        }
        y += 1;
      }
      x += 1;
    }
    cout << ans << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n + 1; i++) {
    int ans = 0;
    int x = 1;
    while (x <= sqrt(n / 6.00)) {
      int y = x;
      // cout<<x<<endl;
      while (y <= (sqrt(3.00 * i - 2 * x * x) - x) / 3) {
        int z = y;
        while (z < i) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            if (x == y && y == z)
              ans += 1;
            else if (x == y || y == z || z == x)
              ans += 3;
            else
              ans += 6;
          }
          z += 1;
        }
        y += 1;
      }
      x += 1;
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  for (int X = 1; X * X <= n; X++) {     // Xを１からnまで回す
    for (int Y = 1; Y * Y <= n; Y++) {   // Yを１からnまで回す
      for (int Z = 1; Z * Z <= n; Z++) { // Zを１からnまで回す
        int A = X * X + Y * Y + Z * Z + X * Y + Y * Z + Z * X;
        if (A > n)
          break;
        f[A]++;
      }
    }
  }

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


Error: TLE

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  int count = 0;
  //   int X;
  //   int Y;
  //   int Z;
  // int A = X*X+Y*Y+Z*Z+X*Y+Y*Z+Z*X;
  for (int i = 1; i <= n; i++) { // iを１からnまで回す
    count = 0;
    for (int X = 1; X <= sqrt(n); X++) { // Xを１からnまで回す

      for (int Y = 1; Y <= sqrt(n); Y++) {   // Yを１からnまで回す
        for (int Z = 1; Z <= sqrt(n); Z++) { // Zを１からnまで回す
          int A = X * X + Y * Y + Z * Z + X * Y + Y * Z + Z * X;
          if (A == i) {
            count++;
          }
        }
      }
    }
    cout << count << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: 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 = 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;
}

Error: TLE

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 = 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;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)                                                              \\
  ;                                                                            \\
  for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
int main() {
  int n;
  cin >> n;
  rep(i, n) {
    int ans = 0;
    int x = sqrt(i + 1);
    for (int j = 1; j <= x; j++) {
      for (int k = j; k <= x; k++) {
        for (int l = k; l <= x; l++) {
          if (j * j + k * k + l * l + j * k + k * l + l * j == i + 1) {
            if (j == k && k == l)
              ans++;
            else if (j != k && k != l && l != j)
              ans += 6;
            else
              ans += 3;
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Error: -6
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)                                                              \\
  ;                                                                            \\
  for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
int main() {
  int n;
  cin >> n;
  vector<int> ans(100000000, 0);
  // for(int i = 1;i <= n;i++){
  // int ans = 0;
  for (int j = 1; j <= n; j++) {
    for (int k = j; k <= n; k++) {
      for (int l = k; l <= n; l++) {
        int a = j * j + k * k + l * l + j * k + k * l + l * j - 1;
        if (j == k && k == l)
          ans[a]++;
        else if (j != k && k != l)
          ans[a] += 6;
        else
          ans[a] += 3;
      }
    }
  }
  // cout << ans << endl;
  //}
  rep(i, n) cout << ans[i] << endl;
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iostream>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

bool is_integer(double x) { return std::floor(x) == x; }

int main() {
  int N, cnt = 0;
  cin >> N;
  for (int n = 1; n <= N; ++n) {
    cnt = 0;

    for (int x = 1; x * x <= n; ++x) {
      for (int y = 1; y * y <= n; ++y) {
        double zz = (-(x + y) + sqrt(-3 * (x * x + y * y) - 2 * x * y + 4 * n));

        if (zz > 0 && is_integer(zz) && int(zz) % 2 == 0) {
          cnt++;
        }
      }
    }

    printf("%d\\n", cnt);
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
  int N, cnt = 0;
  cin >> N;
  for (int n = 1; n <= N; ++n) {
    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 ((x + y) * (x + y) + (z + y) * (z + y) + (x + z) * (x + z) ==
              2 * n) {
            cnt++;
          }
        }
      }
    }

    printf("%d\\n", cnt);
  }

  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#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;
  }
}

Error: TLE

Fixed submission:

#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;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <math.h>
using namespace std;
int main() {
  int n, i, x, y, z, ans;
  cin >> n;
  for (i = 1; i <= n; i++) {
    ans = 0;
    for (x = 1; x <= floor(sqrt(i)); x++)
      for (y = 1; y <= floor(sqrt(i - x * x)); y++) {
        if (x * x - y * y - x * y > i)
          break;
        for (z = 1; z <= floor(sqrt(abs(i - x * x - y * y - x * y))); z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x > i)
            break;
          if (x * x + y * y + z * z + x * y + y * z + z * x == i)
            ans++;
        }
      }
    cout << ans << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <math.h>
using namespace std;
int main() {
  int n, i, x, y, z, ans;
  cin >> n;
  for (i = 1; i <= n; i++) {
    ans = 0;
    for (x = 1; x <= floor(sqrt(i)); x++)
      for (y = 1; y <= floor(sqrt(i - x * x)); y++)
        for (z = 1; z <= floor(sqrt(abs(i - x * x - y * y - x * y))); z++)
          if (x * x + y * y + z * z + x * y + y * z + z * x == i)
            ans++;
    cout << ans << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  int N;
  cin >> N;
  int ans;
  ans = 0;
  int AK[1000001];
  for (int i = 0; i < 1000001; i++) {
    AK[i] = 0;
  }
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        AK[i * i + j * j + k * k + i * k + j * k + i * j]++;
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    cout << AK[i] << endl;
  }
}

Error: 0

Fixed submission:

#include <cmath>
#include <iostream>
using namespace std;
int main() {
  int N;
  cin >> N;
  int ans;
  ans = 0;
  int AK[10001];
  double fg;
  fg = sqrt(N);
  for (int i = 0; i < 10001; i++) {
    AK[i] = 0;
  }
  for (int i = 1; i <= fg; i++) {
    for (int j = 1; j <= fg; j++) {
      for (int k = 1; k <= fg; k++) {
        AK[i * i + j * j + k * k + i * k + j * k + i * j]++;
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    cout << AK[i] << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#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;
}


Error: 0

Fixed submission:

#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;
}