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() {
  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 tmp = x * x + y * y + z * z + x * y + z * y + x * z;
        if (tmp > n)
          continue;
        if (x == y && y == z && z == x) {
          ans[tmp] = ans[tmp] + 1;
        } else if (x != y && x != z && z != y) {
          ans[tmp] = ans[tmp] + 1;
        } else {
          ans[tmp] = ans[tmp] + 1;
        }
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    cout << ans[i] << endl;
  }
  return 0;
}


Error: WA

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  vector<int> ans(n + 1, 0);
  for (int x = 1; x * x <= n; ++x) {
    for (int y = 1; x * x + y * y <= n; ++y) {
      for (int z = 1; z * z + x * x + y * y <= n; ++z) {
        int tmp = x * x + y * y + z * z + x * y + z * y + x * z;
        if (x == y && y == z && z == x) {
          ans[tmp] = ans[tmp] + 1;
        } else if (x != y && x != z && z != y) {
          ans[tmp] = ans[tmp] + 6;
        } else {
          ans[tmp] = ans[tmp] + 3;
        }
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    cout << ans[i] << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

  double n;
  cin >> n;
  vector<int> cou(10001);

  for (int i = 1; i <= 101; ++i) {
    for (int j = 1; j <= 101; ++j) {
      for (int k = 1; k <= 101; ++k) {
        int mo = i * i + j * j + k * k + i * j + i * k + j * k;
        if (mo < 10001)
          ++cou[mo];
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    cout << cou[i] << endl;
  }
}

Error: TLE

Fixed submission:

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

  double n, m;
  cin >> n;
  m = 1;
  for (int a = 1; a <= n; ++a) {
    int ans = 0;
    for (int i = 1; i <= sqrt(a); ++i) {
      for (int j = 1; j <= sqrt(a); ++j) {
        for (int k = 1; k <= sqrt(a); ++k) {
          if (i * i + j * j + k * k + i * j + i * k + j * k == a)
            ++ans;
        }
      }
    }
    cout << ans << 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++)
#define REP2(i, x, n) for (int i = x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
// struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;

int main() {
  int n;
  scanf("%d", &n);

  int x = 1;
  int y = 1;
  int z = 1;
  int num;
  int max;
  int ans;
  for (int i = 1; i <= n; ++i) {
    max = (int)sqrtf(n - 5) + 2;
    num = 0;

    for (x = 1; x <= max; ++x) {
      for (y = 1; y <= x; ++y) {
        for (z = 1; z <= y; ++z) {
          ans = x * x + y * y + z * z + x * y + y * z + z * x;
          if (ans == i) {
            if (x == y && y == z) {
              ++num;
            } else if (x == y && y != z) {
              num += 3;
            } else if (x != y && y == z) {
              num += 3;
            } else {
              num += 6;
            }
          } else if (ans > i) {
            break;
          }
        }
      }
    }
    printf("%d\\n", num);
  }
  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++)
#define REP2(i, x, n) for (int i = x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
// struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;

int main() {
  int n;
  scanf("%d", &n);

  int x = 1;
  int y = 1;
  int z = 1;
  int num;
  int max;
  int ans;
  for (int i = 1; i <= n; ++i) {
    max = (int)sqrtf(n - 5) + 2;
    num = 0;

    for (x = 1; x <= max; ++x) {
      for (y = 1; y <= x; ++y) {
        for (z = 1; z <= y; ++z) {
          ans = x * x + y * y + z * z + x * y + y * z + z * x;
          if (ans == i) {
            if (x == y && y == z) {
              ++num;
            } else if (x == y && y != z) {
              num += 3;
            } else if (x != y && y == z) {
              num += 3;
            } else {
              num += 6;
            }
          } else if (ans > i) {
            continue;
          }
        }
      }
    }
    printf("%d\\n", num);
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int N;
map<long long, long long> cacheResult;

// 計算
long long f(int x, int y, int z) {
  return (pow(x, 2) + pow(y, 2) + pow(z, 2)) + (x * y + y * z + z * x);
}

// 無理やりだけど
void calcLoop(int end) {
  long long result;
  // -- 1つendパターン --
  // iが固定(これを3回繰り返すから3つプラスする)
  for (int j = 1; j < end; j++) {
    for (int k = 1; k < end; k++) {
      result = f(end, j, k);
      if (result > N)
        break;
      cacheResult[result] += 3;
    }
  }

  // -- 2つendパターン --
  // i,jが固定(これを3回繰り返すから3つプラスする)
  for (int k = 1; k < end; k++) {
    result = f(end, end, k);
    if (result > N)
      break;
    cacheResult[result] += 3;
  }

  // -- 3つendパターン --
  result = f(end, end, end);
  cacheResult[result]++;
}

int main() {
  cin >> N;

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


Error: TLE

Fixed submission:

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

int N;
map<long long, long long> cacheResult;

// 計算
long long f(int x, int y, int z) {
  return (pow(x, 2) + pow(y, 2) + pow(z, 2)) + (x * y + y * z + z * x);
}

// 無理やりだけど
void calcLoop(int end) {
  long long result;
  // -- 1つendパターン --
  // iが固定(これを3回繰り返すから3つプラスする)
  for (int j = 1; j < end; j++) {
    for (int k = 1; k < end; k++) {
      result = f(end, j, k);
      cacheResult[result] += 3;
    }
  }

  // -- 2つendパターン --
  // i,jが固定(これを3回繰り返すから3つプラスする)
  for (int k = 1; k < end; k++) {
    result = f(end, end, k);
    cacheResult[result] += 3;
  }

  // -- 3つendパターン --
  result = f(end, end, end);
  cacheResult[result]++;
}

int main() {
  cin >> N;

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[10051] = {0};
  for (int j = 1; j <= 105; j++) {
    for (int k = 1; k <= 105; k++) {
      for (int l = 1; l <= 105; l++) {
        if (j * j + k * k + l * l + j * k + k * l + l * j <= 10050)
          a[j * j + k * k + l * l + j * k + k * l + l * j]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << a[i] << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long int co = 0;
  for (int i = 1; i <= n; i++) {
    if (i <= 5)
      cout << 0 << endl;
    else {
      co = 0;
      for (int j = 1; j <= sqrt(i); j++) {
        for (int k = 1; k <= sqrt(i); k++) {
          for (int l = 1; l <= sqrt(i); l++) {
            if (j * j + k * k + l * l + j * k + k * l + l * j == i)
              co++;
          }
        }
      }
      cout << co << endl;
    }
  }
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define ll long long
#define eps 1e-7
#define all(x) ((x).begin()), ((x).end())
#define usecppio                                                               \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
using namespace std;
#define int ll
using pii = pair<int, int>;

int ans[100101];
int32_t main() {
  int n;
  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++) {
        int u = x * x + y * y + z * z + x * y + y * z + z * x;
        ans[u]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << ans[i] << '\\n';
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define ll long long
#define eps 1e-7
#define all(x) ((x).begin()), ((x).end())
#define usecppio                                                               \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
using namespace std;
#define int ll
using pii = pair<int, int>;

int ans[10101];
int32_t main() {
  int n;
  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++) {
        int u = x * x + y * y + z * z + x * y + y * z + z * x;
        ans[u]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << ans[i] << '\\n';
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
  vector<int> f(60000);
  int N;
  cin >> N;
  int n = sqrt(N);
  for (int x = 1; x <= n; x++) {
    for (int y = 1; y <= n; y++) {
      for (int z = 1; z <= n; z++) {
        int F = x * x + y * y + z * z + x * y + y * z + z * x;
        f[F - 1]++;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    cout << f[i] << endl;
  }
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
  vector<int> f(10000);
  int N;
  cin >> N;
  int n = sqrt(N);
  for (int x = 1; x <= n; x++) {
    for (int y = 1; y <= n; y++) {
      for (int z = 1; z <= n; z++) {
        int F = x * x + y * y + z * z + x * y + y * z + z * x;
        f[F - 1]++;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    cout << f[i] << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

int main(void) {

  long long N;
  cin >> N;

  vector<long long> f(N);

  for (long long n = 1; n <= N; n++) {
    if (n == 6) {
      cout << 1 << endl;
      continue;
    }
    long long count = 0;
    long long sqrtn = sqrt(n);
    for (long long x = 1; x <= sqrtn; x++) {
      for (long long y = x; y <= sqrtn; y++) {
        for (long long z = y; z <= sqrtn; z++) {
          long long add = 0;
          if (x * x + y * y + z * z + x * y + y * z + z * x == n) {
            add = 1;
            if (x == y && y == z) {
              add = add * 1;
            } else if (x == y || y == z) {
              add = add * 3;
            } else {
              add = add * 6;
            }
          }
          count += add;
        }
      }
    }
    cout << count << endl;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main(void) {

  long long N;
  cin >> N;

  vector<long long> f(N);

  for (long long n = 1; n <= N; n++) {
    long long count = 0;
    long long sqrtn = sqrt(n);
    for (long long x = 1; x <= sqrtn; x++) {
      for (long long y = 1; y <= sqrtn; y++) {
        for (long long z = 1; z <= sqrtn; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == n) {
            count++;
          }
        }
      }
    }
    cout << count << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for (ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl ans(n + 1, 0);
  rep2(x, 1, 101) rep2(y, 1, 101) rep2(z, 1, 101) {
    ll now = x * x + y * y + z * z + x * y + y * z + z * x;
    if (now <= n)
      ans[now]++;
  }
  rep2(i, 1, n + 1) cout << ans[i] << '\\n';
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for (ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl ans(n + 1, 0);
  rep2(x, 1, 101) rep2(y, 1, 101) rep2(z, 1, 101) {
    ll now = x * x + y * y + z * z + x * y + y * z + z * x;
    ans[now]++;
  }
  rep2(i, 1, n + 1) cout << ans[i] << '\\n';
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PLL;
typedef pair<P, P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P, VECP, greater<P>> PQP;
typedef priority_queue<ll, VECLL, greater<ll>> PQll;

#define rep(i, a, n) for (ll i = a; i < n; i++)
#define rrep(i, a, n) for (ll i = n; i >= a; i--)
#define index_check(i, n)                                                      \\
  if (i > n - 1 || i < 0)                                                      \\
    continue;
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

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

int main() {
  ll n;
  cin >> n;
  ll cnt[n + 1] = {};

  rep(j, 1, 101) {
    rep(k, 1, 101) {
      rep(l, 1, 101) {
        if (j * j + k * k + l * l + j * k + k * l + l * j > n)
          continue;
        cnt[j * j + k * k + l * l + j * k + k * l + l * j]++;
      }
    }
  }

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


Error: TLE

Fixed submission:

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

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PLL;
typedef pair<P, P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P, VECP, greater<P>> PQP;
typedef priority_queue<ll, VECLL, greater<ll>> PQll;

#define rep(i, a, n) for (ll i = a; i < n; i++)
#define rrep(i, a, n) for (ll i = n; i >= a; i--)
#define index_check(i, n)                                                      \\
  if (i > n - 1 || i < 0)                                                      \\
    continue;
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

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

int main() {
  ll n;
  scanf("%lld", &n);

  rep(i, 1, n + 1) {
    ll cnt = 0;
    rep(j, 1, 101) {
      rep(k, 1, 101) {
        rep(l, 1, 101) {
          if (j * j + k * k + l * l + j * k + k * l + l * j == i)
            cnt++;
        }
      }
    }
    printf("%lld\\n", cnt);
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int ans[10050] = {0};
  for (int x = 1; x < 105; x++) {
    for (int y = 1; y < 105; y++) {
      for (int z = 1; z < 105; z++) {
        int value = x * x + y * y + z * z + x * y + y * z + z * x;
        if (value < 10050) {
          ++ans[value];
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i + 1] << '\\n';
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    if (i < 6) {
      cout << 0 << '\\n';
      continue;
    }
    int cnt = 0;
    for (int x = 1; x <= (n / 2); x++) {
      for (int y = 1; y <= (n / 2) - x; y++) {
        for (int z = 1; z <= (n / 2) - x - y; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            ++cnt;
          }
        }
      }
    }
    cout << cnt << '\\n';
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  vector<int> answer(10000);
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        int l = i * i + j * j + k * k + i * j + j * k + k * i;
        if (l <= 10000)
          answer.at(l - 1)++;
      }
    }
  }

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

Error: TLE

Fixed submission:

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

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

  for (int i = 1; i <= N; i++) {
    int answer = 0;
    int n = floor(sqrt(i + 1));
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        for (int l = 1; l <= n; l++) {
          if (j * j + k * k + l * l + j * k + k * l + l * j == i)
            answer++;
        }
      }
    }
    cout << answer << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n;
  cin >> n;
  rep2(x, 1, n + 1) {
    int res = 0;
    rep2(i, 1, sqrt(n) + 1) {
      if (i * i > x)
        break;
      rep2(j, i, sqrt(n) + 1) {
        if (i * i + j * j > x)
          break;
        rep2(k, j, sqrt(n) + 1) {
          int p = i * i + j * j + k * k + i * k + j * k + i * j;
          if (p > x)
            break;
          if (p == x) {
            if (i == j && j == k)
              res++;
            else if (i != j && i != k && j != k)
              res += 6;
            else
              res += 3;
          }
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  rep2(x, 1, n + 1) {
    int res = 0;
    rep2(i, 1, sqrt(n) + 1) {
      if (i * i > x)
        break;
      rep2(j, 1, sqrt(n) + 1) {
        if (i * i + j * j > x)
          break;
        rep2(k, 1, sqrt(n) + 1) {
          int p = i * i + j * j + k * k + i * k + j * k + i * j;
          if (p > x)
            break;
          if (p == x) {
            res++;
          }
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define printfloat(x) cout << fixed << setprecision(7) << (x) << endl;
#define printbit(x) cout << bitset<15>(x) << endl;
using ll = long long int;

long double pi = 3.14159265359;

int n, x, y, z;
int Y, ii;
int ans;

int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int x = 1; 3 * x * x <= 4 * i; x++) {
      for (int y = x; 3 * y * y <= 4 * i; y++) {
        ii = -3 * x * x - 3 * y * y - 2 * x * y + 4 * i;
        // int flag = 0;
        // if(ii < 0 || flag) continue;
        for (int X = x + 3 * y; 9 * X * X <= 50 * i; X++) {
          Y = -y - x + X;
          // cout << i << " " << x << " " << y << " " << Y << endl;
          if (ii == X * X && Y % 2 == 0 && Y / 2 > 0) {
            // cout << i << " " << x << " " << y << " " << Y << endl;
            if (x == y && y == Y / 2) {
              ans += 1;
            } else if (x != y && y != Y / 2 && x != Y / 2) {
              // cout << x << " " << y << " " << Y << endl;
              ans += 6;
              // flag = 1;
              // break;
            } else {
              ans += 3;
              // flag = 1;
              // break;
            }
          }
        }
      }
    }
    cout << ans << endl;
    ans = 0;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define printfloat(x) cout << fixed << setprecision(7) << (x) << endl;
#define printbit(x) cout << bitset<15>(x) << endl;
using ll = long long int;

long double pi = 3.14159265359;

int n, x, y, z;
int Y, ii;
int ans;

int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int x = 1; 3 * x * x <= 4 * n; x++) {
      if (6 * x * x == i) {
        ans++;
        break;
      }
      for (int y = x; 3 * y * y <= 4 * n; y++) {
        ii = -3 * x * x - 3 * y * y - 2 * x * y + 4 * i;
        if (ii < 0)
          continue;
        for (int X = x + y; 9 * X * X <= 32 * n; X++) {
          Y = -y - x + X;
          if (ii == X * X && Y % 2 == 0 && Y / 2 > 0) {
            if (x == y && y == Y / 2) {
              ans = 8;
              break;
            } else {
              ans = 3;
              break;
            }
          }
        }
      }
    }
    cout << ans << endl;
    ans = 0;
  }

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

#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  int flag[10001] = {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 + z * x + x * y + z * y;
        if (s <= 10000)
          flag[s]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << flag[i] << endl;

  return 0;
}


Error: -11

Fixed submission:

#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  int flag[10001] = {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 + z * x + x * y + z * y;
        flag[s]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << flag[i] << endl;

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

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

int main() {
  int n;
  cin >> n;
  int m = sqrt(n) + 5;
  map<int, int> c;
  for (int x = 1; x < m; ++x) {
    for (int y = 1; y < m; ++y) {
      for (int z = 1; z < m; ++z) {
        if (c.count(x * x + y * y + z * z + x * y + y * z + z * x)) {
          ++c[x * x + y * y + z * z + x * y + y * z + z * x];
        } else
          c.insert(make_pair(x * x + y * y + z * z + x * y + y * z + z * x, 1));
      }
    }
  }
  rep(i, n) { cout << c[i + 1] << endl; }
  return 0;
}

Error: MLE

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  int m = sqrt(n) + 5;
  vector<ll> c(300000007, 0);
  for (int x = 1; x < m; ++x) {
    for (int y = 1; y < m; ++y) {
      for (int z = 1; z < m; ++z) {
        ++c[x * x + y * y + z * z + x * y + y * z + z * x];
      }
    }
  }
  rep(i, n) { cout << c[i + 1] << endl; }
  return 0;
}