alexjercan/bugnet huggingface dataset:
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

vector<ll> d(1000000);
void prep() {
  for (int x = 1; x <= 200; x++) {
    for (int y = 1; y <= 200; y++) {
      for (int z = 1; z <= 200; z++) {
        ll v = x * x + y * y + z * z + x * y + y * z + z * x;
        if (v > 1000000)
          continue;
        d[v]++;
      }
    }
  }
}

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

  ll n;
  cin >> n;

  prep();

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

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

vector<ll> d(1000000);
ll prep() {
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        ll v = x * x + y * y + z * z + x * y + y * z + z * x;
        if (v > 2000)
          continue;
        d[v]++;
      }
    }
  }
}

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

  ll n;
  cin >> n;

  prep();

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

  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

// Delete the dynamically allocated memory

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

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

Error: 0

Fixed submission:

// Delete the dynamically allocated memory

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

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

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

int f(int x, int y, int z);

signed main() {
  int n, ans[10001] = {};

  cin >> n;

  for (int x = 1; x <= 10000; x++) {
    for (int y = 1; y <= 10000; y++) {
      if (x * x + y * y + x * y + y + x > 10000) {
        goto YEND;
      } else {
        for (int z = 1; z <= 10000; z++) {
          if (f(x, y, z) <= 10000) {
            ans[f(x, y, z)]++;
          } else {
            goto ZEND;
          }
        }
      }
    ZEND:;
    }
  YEND:;
  }

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

  return (0);
}

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

Error: TLE

Fixed submission:

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

int f(int x, int y, int z);

signed main() {
  int n, ans[1001] = {};

  cin >> n;

  for (int x = 1; x <= 1000; x++) {
    for (int y = 1; y <= 1000; y++) {
      for (int z = 1; z <= 1000; z++) {
        if (f(x, y, z) <= 1000) {
          ans[f(x, y, z)]++;
        }
      }
    }
  }

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

  return (0);
}

int f(int x, int y, int z) {
  return (x * x + y * y + z * z + x * y + x * z + y * z);
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

const int N = 10000 + 10;
int ans[N];

int main() {
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        int t = i * i + j * j + k * k + i * j + j * k + i * k;
        if (t <= 10000) {
          ans[t]++;
        }
      }
    }
  }
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << '\\n';
  }
#ifndef ONLINE_JUDGE
  system("pause");
#endif
  return 0;
}

Error: 0
sh: 1: pause: not found


Fixed submission:

#include <bits/stdc++.h>

using namespace std;

const int N = 1000 + 10;
int ans[N];

int main() {
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        int t = i * i + j * j + k * k + i * j + j * k + i * k;
        if (t <= 1000) {
          ans[t]++;
        }
      }
    }
  }
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << '\\n';
  }
#ifndef ONLINE_JUDGE
  system("pause");
#endif
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error


#include <iostream>
using namespace std;

int math(int x, int y, int z) {
  return x * x + y * y + z * z + x * y + x * z + y * z;
}
int main() {
  int N;
  cin >> N;
  int a[10050] = {0};
  int i, ii, iii;
  i = 1;
  int maxi = i;
  int maxii = 10000000;
  int maxiii = 100000000;
  for (i = 1; i < 100; i++) {
    for (ii = 1; ii < 100; ii++) {
      for (iii = 1; iii < 100; iii++) {
        int temp = math(i, ii, iii);
        if (temp <= N) {
          a[temp - 1]++;
        }
      }
    }
  }
  for (int i = 0; i < N; i++) {
    cout << a[i] << endl;
  }
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;

int math(int x, int y, int z) {
  return x * x + y * y + z * z + x * y + x * z + y * z;
}
int main() {
  int N;
  cin >> N;
  int a[1000] = {0};
  int i, ii, iii;
  i = 1;
  for (i = 1; i < 13; i++) {
  }
  int maxi = i;
  int maxii = 10000000;
  int maxiii = 100000000;
  for (i = 1; i < 100; i++) {
    for (ii = 1; ii < 100; ii++) {
      for (iii = 1; iii < 100; iii++) {
        int temp = math(i, ii, iii);
        if (temp <= N) {
          a[temp - 1]++;
        }
      }
    }
  }
  for (int i = 0; i < N; i++) {
    cout << a[i] << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int f(int n) {
  int t = sqrt(n);
  int count = 0;
  for (int i = 1; i <= t; i++) {
    for (int j = i; j <= t; j++) {
      for (int k = j; k <= t; k++) {
        if ((i * i + j * j + k * k + i * j + j * k + k * i) == n) {
          if (i == j && j == k && k == i) {
            count++;
          } else if (i != j && j != k && k != i) {
            count += 6;
          } else {
            count += 3;
          }
        }
      }
    }
  }
  rep(j, t) rep(k, t) {}
  return count;
}

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

  rep(i, n) { cout << f(i + 1) << endl; }

  return 0;
}

Error: TLE

Fixed submission:

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

int f(int n) {
  int t = sqrt(n);
  int count = 0;
  rep(i, t) rep(j, t) rep(k, t) {
    int x = i + 1;
    int y = j + 1;
    int z = k + 1;
    if ((x * x + y * y + z * z + x * y + y * z + z * x) == n) {
      count++;
    }
  }
  return count;
}

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

  rep(i, n) { cout << f(i + 1) << endl; }

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

#include <bits/stdc++.h>
typedef long long lint;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define repr(i, n) for (int i = 1, i##_len = (n); i < i##_len; ++i)
vector<int> f(int n) {
  int sqrn = sqrt(n) + 1;
  vector<int> res;
  res.resize(1000000);
  repr(x, sqrn) {
    repr(y, sqrn) {
      repr(z, sqrn) { res[x * x + y * y + z * z + x * y + y * z + z * x]++; }
    }
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  auto v = f(n);
  repr(i, n + 1) { cout << v[i] << endl; }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
typedef long long lint;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define repr(i, n) for (int i = 1, i##_len = (n); i < i##_len; ++i)
int f(int n) {
  int sqrn = sqrt(n) + 1;
  int res = 0;
  repr(x, sqrn) {
    repr(y, sqrn) {
      repr(z, sqrn) {
        if (x * x + y * y + z * z + x * y + y * z + z * x == n)
          res++;
      }
    }
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  repr(i, n + 1) { cout << f(i) << endl; }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

// int func(int x, int y, int n){
//     double sq = sqrt( (x+y)*(x+y) - 4 * (x*x + y*y + x*y - n));
//     if(ceil(sq) != floor(sq) || sq <= 0){
//         return -1;
//     }
//     else{
//         return (-(x + y) + int(sq)) / 2;
//     }
// }

int judge(int x, int y, int z) {
  if (x == y && y == z) {
    return 1;
  } else if (x != y && y != z && z != x) {
    return 6;
  } else {
    return 3;
  }
}

int main() {

  int N;
  cin >> N;
  int x, y, z;
  int tmp;
  vector<int> count(N + 1);

  for (x = 1; x <= 100; x++) {
    for (y = 1; y <= 100; y++) {
      for (z = 1; z <= 100; z++) {
        tmp = x * x + y * y + z * z + x * y + y * z + z * x;
        if (tmp <= N) {
          count.at(tmp)++;
        }
      }
    }
  }

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

  return 0;
}


Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

// int func(int x, int y, int n){
//     double sq = sqrt( (x+y)*(x+y) - 4 * (x*x + y*y + x*y - n));
//     if(ceil(sq) != floor(sq) || sq <= 0){
//         return -1;
//     }
//     else{
//         return (-(x + y) + int(sq)) / 2;
//     }
// }

int judge(int x, int y, int z) {
  if (x == y && y == z) {
    return 1;
  } else if (x != y && y != z && z != x) {
    return 6;
  } else {
    return 3;
  }
}

int main() {

  int N;
  cin >> N;
  int x, y, z;
  int tmp;
  vector<int> count(N + 1);

  for (x = 1; x <= N; x++) {
    for (y = 1; y <= N; y++) {
      for (z = 1; z <= N; z++) {
        tmp = x * x + y * y + z * z + x * y + y * z + z * x;
        if (tmp <= N) {
          count.at(tmp)++;
        }
      }
    }
  }

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

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int long long
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

signed main() {
  int n;
  cin >> n;
  rep(i, 1, n + 1) {
    int ans = 0;
    for (int x = 1; x * x <= i; x++) {
      for (int y = x; y * y <= i; y++) {
        for (int z = y; z * z <= i; z++) {
          int sum = x * x + y * y + z * z + x * y + y * z + z * x;
          if (sum == i) {
            if (x == y && y == z)
              ans++;
            else if (x == y || y == z || z == x)
              ans += 3;
            else
              ans += 6;
          }
        }
      }
    }
    cout << ans << "\\n";
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int long long
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

signed main() {
  int n;
  cin >> n;
  rep(i, 1, n + 1) {
    int ans = 0;
    for (int x = 1; x * x <= i; x++) {
      for (int y = 1; y * y <= i; y++) {
        for (int z = 1; z * z <= i; z++) {
          int sum = x * x + y * y + z * z + x * y + y * z + z * x;
          if (sum == i)
            ans++;
        }
      }
    }
    cout << ans << "\\n";
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define per(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18 + 99);
static const int INF = 1e9 + 99;

int ans[100005];

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

  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 <= 10005)
          ans[sum]++;
      }
    }
  }

  rep(i, 1, N + 1) cout << ans[i] << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define per(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18 + 99);
static const int INF = 1e9 + 99;

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

  for (int n = 1; n <= N; n++) {
    int sum = 0;
    for (int x = 1; x * x <= n; x++) {
      for (int y = 1; y * y <= n; y++) {
        if (x * x + y * y + x * y >= n)
          break;
        ;
        for (int z = 1; z * z <= n; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == n)
            sum++;
        }
      }
    }
    printf("%d\\n", sum);
  }

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

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

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

int count(int x, int y, int z) {
  if (x == y && y == z) {
    return 1;
  } else if ((x != y && y == z) || (y != z && z == x) || (z != x && x == y)) {
    return 3;
  } else {
    return 6;
  }
}

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

  vector<int> num(N, 0);

  for (int i = 1; i <= sqrt(N); i++) {
    for (int j = i; j <= sqrt(N); j++) {
      for (int k = j; k <= sqrt(N); k++) {
        int ans = answer(i, j, k);
        if (ans <= N) {
          num.at(ans - 1) += count(i, j, k);
        }
      }
    }
  }

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


Error: TLE

Fixed submission:

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

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

int count(int x, int y, int z) {
  if (x == y && y == z) {
    return 1;
  } else if ((x != y && y == z) || (y != z && z == x) || (z != x && x == y)) {
    return 3;
  } else {
    return 6;
  }
}

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

  for (int a = 1; a <= N; a++) {
    f = 0;

    for (int i = 1; i <= sqrt(N); i++) {
      for (int j = i; j <= sqrt(N); j++) {
        for (int k = j; k <= sqrt(N); k++) {
          int ans = answer(i, j, k);
          if (ans == a) {
            f += count(i, j, k);
          }
        }
      }
    }

    cout << f << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

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

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

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

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


Error: 0

Fixed submission:

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

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

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

  for (int i = 1; i <= N; ++i) {
    cout << ans[i] << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

int main() {
  i64 n;
  cin >> n;
  RANGE(i, 1, n + 1) {
    i64 ans = 0;
    RANGE(x, 1, 99) {
      RANGE(y, x, 99) {
        RANGE(z, y, 99) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            if (x == y && y == z)
              ans++;
            else if (x == y || y == z)
              ans += 3;
            else
              ans += 6;
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

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

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

int main() {
  i64 n;
  cin >> n;
  RANGE(i, 1, n + 1) {
    i64 ans = 0;
    RANGE(x, 1, 100) {
      RANGE(y, 1, 100) {
        RANGE(z, 1, 100) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i)
            ans++;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  int A[10100];
  rep(i, 10010) A[i] = 0;
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int s = x * x + y * y + z * z + x * y + y * z + z * x;
        if (s <= 10000)
          A[s]++;
      }
    }
  }

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


Error: TLE

Fixed submission:

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

/* 繰り返し自乗法. */
int modPow(long long a, long long n, long long p) {
  if (n == 0)
    return 1; // 0乗にも対応する場合.
  if (n == 1)
    return a % p;
  if (n % 2 == 1)
    return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}

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

  for (int N = 1; N <= NN; N++) {
    int cnt = 0;
    for (int x = 1; x <= N; x++) {
      if (N < ((x * (x + 2)) + 2))
        break;
      for (int y = 1; y <= N; y++) {
        if (N < ((x * x) + (y * y) + (x * y) + x + y))
          break;
        for (int z = 1; z <= N; z++) {
          int a = x * y;
          int b = y * z;
          int c = z * x;
          if (N == ((x * x) + (y * y) + (z * z) + a + b + c))
            cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n, m;
  cin >> n;
  int sqn = sqrt(n);
  vector<int> v(n + 1, 0);
  for (int i = 1; i <= sqn; i++) {
    for (int j = 1; j <= sqn; j++) {
      for (int k = 1; k <= sqn; k++) {
        m = i * i + j * j + k * k + i * j + j * k + k * i;
        if (m <= n)
          v[m]++;
      }
    }
  }
  for (int i = 1; i < n + 1; i++)
    cout << v[i] << endl;
}

Error: 0

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  int sqn = sqrt(n);
  vector<int> v(n + 1);
  for (int i = 1; i <= sqn; i++) {
    for (int j = 1; j <= sqn; j++) {
      for (int k = 1; k <= sqn; k++) {
        v[i * i + j * j + k * k + i * j + j * k + k * i]++;
      }
    }
  }
  for (int i = 1; i < n + 1; i++)
    cout << v[i] << endl;
}