alexjercan/bugnet huggingface dataset:
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define ll long long
#define dot cout << setprecision(20) << endl;
#define vsor(x) sort(x.begin(), x.end());
#define vrev(x) reverse(x.begin(), x.end());
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define bit(b, n) for (int b = 0; b < (1 << (ll)(n)); b++)

using namespace std;

ll n;

int main() {
  cin >> n;
  cout << 0 << endl;
  for (int i = 2; i <= n; i++) {
    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++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i && x == y &&
              y == z)
            ans++;
          if (x * x + y * y + z * z + x * y + y * z + z * x == i &&
              ((x == y && y != z) || (y == z && z != x) || (z == x && x != y)))
            ans += 3;
          if (x * x + y * y + z * z + x * y + y * z + z * x == i &&
              (x != y && y != z))
            ans += 6;
        }
    cout << ans << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define dot cout << setprecision(20) << endl;
#define vsor(x) sort(x.begin(), x.end());
#define vrev(x) reverse(x.begin(), x.end());
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define bit(b, n) for (int b = 0; b < (1 << (ll)(n)); b++)

using namespace std;

ll n;

int main() {
  cin >> n;
  cout << 0 << endl;
  for (int i = 2; i <= n; i++) {
    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++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i)
            ans++;
        }
    cout << ans << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <set>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <vector>
#define N 10050
using namespace std;
int main() {
  int n, a[N] = {0};
  scanf("%d", &n);
  int v;
  //	printf("%d",m);

  for (int x = 1; x < 105; x++)
    for (int y = 1; y < 105; y++)
      for (int z = 1; z < 105; z++) {
        v = pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x;
        if (v < 10050)
          a[v]++;
      }

  for (int i = 1; i <= n; i++)
    printf("%d\\n", a[i]);
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <set>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <vector>
#define N 10005
using namespace std;
int main() {
  int n, a[N] = {0};
  scanf("%d", &n);
  int m = sqrt(n);
  //	printf("%d",m);
  for (int i = 6; i <= n; i++) {
    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 (pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x == i)
            a[i]++;
        }
  }

  for (int i = 1; i <= n; i++)
    printf("%d\\n", a[i]);
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>

bool pf[233333];

int main() {
  for (int i = 1; i <= 100; i++)
    pf[i * i] = true;
  int n, k, a;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int sum = 0;
    for (int x = 1; x * x < i; x++)
      for (int y = 1; y * y < i; y++) {
        int p = i - x * x - y * y - x * y, k = (x + y) * (x + y) + 4 * p;
        if (p <= 0)
          continue;
        for (int j = x + y; j * j <= k; j += 2)
          if (j * j == k) {
            sum++;
            break;
          }
      }
    printf("%d\\n", sum);
  }
  return 0;
}

Error: 0

Fixed submission:

#include <cstdio>

bool pf[23333];

int main() {
  for (int i = 1; i <= 100; i++)
    pf[i * i] = true;
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int sum = 0;
    for (int x = 1; x * x < i; x++)
      for (int y = 1; y * y < i; y++) {
        int p = i - x * x - y * y - x * y;
        if (p <= 0 || pf[(x + y) * (x + y) + 4 * p] == false)
          continue;
        sum++;
      }
    printf("%d\\n", sum);
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

#define rep(pp, nn) for (int ii = pp; ii < nn; ++ii)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>

string int_to_string(int x) {
  stringstream ss;
  ss << x;
  string ni = ss.str();
  return ni;
}
constexpr int mod = 1e9 + 7;
ll POW(ll a, ll b) {
  ll ans = 1;
  while (b) {
    if (b & 1) {
      ans = ans * a;
    }
    a = a * a;
    b /= 2;
  }
  return ans;
}

ll power(ll a, ll b) {
  ll ans = 1;
  while (b) {
    if (b & 1) {
      ans = (ans * a) % mod;
    }
    a = (a * a) % mod;
    b /= 2;
  }
  return ans;
}
ll gcd(ll a, ll b) {
  if (a == 0) {
    return b;
  }
  return gcd(b % a, a);
}
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
bool isprime(ll n) {
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      return 0;
    }
  }
  return 1;
}

ll power_mod(ll a, ll b, ll mo) {
  ll ans = 1;
  while (b) {
    if (b & 1) {
      ans = (ans * a) % mo;
    }
    a = (a * a) % mo;
    b /= 2;
  }
  return ans;
}

int main() {
  int n;
  cin >> n;
  // int cnt = 0;
  vector<int> v(n + 1);
  // for (int e = 1; e <= n; ++e) {
  // int cnt = 0;
  for (ll i = 1; i <= sqrt(n) + 1; ++i) {
    for (ll j = 1; j <= sqrt(n) + 1; ++j) {
      for (ll k = 1; k <= sqrt(n) + 1; ++k) {
        ll x = i * i + j * j + k * k + i * j + j * k + k * i;
        if (x <= n) {
          v[x]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    cout << v[i] << endl;
  }
}


Error: TLE

Fixed submission:

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

#define rep(pp, nn) for (int ii = pp; ii < nn; ++ii)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>

string int_to_string(int x) {
  stringstream ss;
  ss << x;
  string ni = ss.str();
  return ni;
}
constexpr int mod = 1e9 + 7;
ll POW(ll a, ll b) {
  ll ans = 1;
  while (b) {
    if (b & 1) {
      ans = ans * a;
    }
    a = a * a;
    b /= 2;
  }
  return ans;
}

ll power(ll a, ll b) {
  ll ans = 1;
  while (b) {
    if (b & 1) {
      ans = (ans * a) % mod;
    }
    a = (a * a) % mod;
    b /= 2;
  }
  return ans;
}
ll gcd(ll a, ll b) {
  if (a == 0) {
    return b;
  }
  return gcd(b % a, a);
}
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
bool isprime(ll n) {
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      return 0;
    }
  }
  return 1;
}

ll power_mod(ll a, ll b, ll mo) {
  ll ans = 1;
  while (b) {
    if (b & 1) {
      ans = (ans * a) % mo;
    }
    a = (a * a) % mo;
    b /= 2;
  }
  return ans;
}

int main() {
  int n;
  cin >> n;
  // int cnt = 0;
  for (int e = 1; e <= n; ++e) {
    int cnt = 0;
    for (int i = 1; i <= sqrt(e) + 1; ++i) {
      for (int j = 1; j <= sqrt(e) + 1; ++j) {
        for (int k = 1; k <= sqrt(e) + 1; ++k) {
          if ((i + j + k) * (i + j + k) + i * i + j * j + k * k == 2 * e) {
            cnt++;
          }
        }
      }
    }
    // if (cnt > 0) {
    // cout << "ans is " << e << endl;
    //}
    cout << cnt << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int maxn = 100;
int cnt[10001];
int main() {
  int n;
  cin >> n;
  for (int x = 1; x <= maxn; x++) {
    for (int y = 1; y <= maxn; y++) {
      for (int z = 1; z <= maxn; z++) {
        int num = x * x + y * y + z * z + x * y + y * z + x * z;
        if (num <= n)
          cnt[num]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << cnt[i] << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int maxn = 100;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int count = 0;
    for (int x = 1; x <= maxn; x++) {
      for (int y = 1; y <= maxn; y++) {
        for (int z = 1; z <= maxn; z++) {
          if (x * x + y * y + z * z + x * y + y * z + x * z == i)
            count++;
        }
      }
    }
    printf("%d\\n", count);
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
using namespace std;
int main(void) {
  int N;
  cin >> N;

  int ans = 0;

  for (int i = 1; i <= N; i++) {
    ans = 0;
    for (int a = 1; a < sqrt(N); a++) {
      for (int b = 1; b <= min(a, int(sqrt(i - a * a))); b++) {
        for (int c = 1; c <= min(b, int(sqrt(i - a * a - b * b))); c++) {
          if (a * a + b * b + c * c + a * b + b * c + c * a == i) {
            if (a != b && b != c && c != a)
              ans += 6;
            else if ((a == b && a != c) || (b == c && b != a) ||
                     (c == a && c != b))
              ans += 3;
            else
              ans++;
          }
        }
      }
    }
    cout << ans << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

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

  int ans = 0;

  for (int i = 1; i <= N; i++) {
    ans = 0;
    for (int a = 1; a < 100; a++) {
      for (int b = 1; b <= a; b++) {
        for (int c = 1; c <= b; c++) {
          if (a * a + b * b + c * c + a * b + b * c + c * a == i) {
            if (a != b && b != c && c != a)
              ans += 6;
            else if ((a == b && a != c) || (b == c && b != a) ||
                     (c == a && c != b))
              ans += 3;
            else
              ans++;
          }
        }
      }
    }
    cout << ans << endl;
  }

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

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

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

int main() {
  int N, x = 1, y = 1, z = 1;
  cin >> N;
  vector<int> ans(100000);
  for (z = 1; z < y + 1; z++) {
    for (y = z; y < x + 1; y++) {
      for (x = y; x < sqrt(N - 1) + 1; x++) {
        if (x == y && y == z) {
          ++ans.at(Triplets(x, y, z));
        } else if (x != y && y != z && z != x) {
          ans.at((Triplets(x, y, z))) += 6;
        } else {
          ans.at((Triplets(x, y, z))) += 3;
        }
      }
    }
  }

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

Error: 0

Fixed submission:

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

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

int main() {
  int N, x = 1, y = 1, z = 1;
  cin >> N;
  vector<int> ans(10001);
  for (z = 1; z < y + 1; z++) {
    for (y = z; y < x + 1; y++) {
      for (x = y; x < sqrt(N - 1) + 1; x++) {
        if (x == y && y == z) {
          ++ans.at(Triplets(x, y, z));
        } else if (x != y && y != z && z != x) {
          ans.at((Triplets(x, y, z))) += 6;
        } else {
          ans.at((Triplets(x, y, z))) += 3;
        }
      }
    }
  }

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

#include <bits/stdc++.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64, i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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

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

  for (int k = 1; k <= n; k++) {
    int cnt = 0;
    for (int i = 1; i * i <= k; i++) {
      for (int j = 1; j * j <= k; j++) {
        int ans = i * i + j * j + i * j;
        if (ans >= k)
          break;
        int m = k - ans;
        int l = 0, r = m;
        while (r - l > 1) {
          int c = (l + r) / 2;
          int C = c * c + c * i + c * j;
          if (C == m) {
            cnt++;
            break;
          } else if (C > m) {
            r = c;
          } else
            l = c;
        }
      }
    }
    cout << cnt << endl;
  }
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64, i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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

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

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

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }

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

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

typedef pair<int, int> pii;
typedef vector<int> vec;
typedef unordered_map<int, int> hash;
#define long long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define sz(x) (int)x.size()
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a, v) memset(a, v, sizeof(a))
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define INF 0x3f3f3f3f // infinity for integers
#define JJ                                                                     \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0) // input fast
#define MOD 1000000007

int main() {
  JJ;
  int n;
  cin >> n;
  int arr[10050] = {0};
  // FOR(a,1,n+1){
  int ans = 0;
  FOR(i, 1, 105) {
    FOR(j, 1, 105) {
      FOR(k, 1, 105) {
        int num = i * i + j * j + k * k + (i * j + j * k + k * i);
        if (num < 10050)
          // {
          arr[num]++;
        // dp[num]++;
        // break;
        // }
      }
    }
  }
  // cout<<ans<<endl;
  FOR(i, 1, n + 1) { cout << arr[i] << endl; }
  // }

  return 0;
}


Error: TLE

Fixed submission:

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

typedef pair<int, int> pii;
typedef vector<int> vec;
typedef unordered_map<int, int> hash;
#define long long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define sz(x) (int)x.size()
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a, v) memset(a, v, sizeof(a))
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define INF 0x3f3f3f3f // infinity for integers
#define JJ                                                                     \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0) // input fast
#define MOD 1000000007

int main() {
  JJ;
  int n;
  cin >> n;
  // long dp[n+1]={0};
  FOR(a, 1, n + 1) {
    int ans = 0;
    FOR(i, 1, sqrt(a) + 1) {
      FOR(j, 1, sqrt(a) + 1) {
        FOR(k, 1, sqrt(a) + 1) {
          long num = i * i + j * j + k * k + (i * j + j * k + k * i);
          if (num == a) {
            ans++;
            // dp[num]++;
            // break;
          }
        }
      }
    }
    // cout<<ans<<endl;
    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;

  for (int h = 1; h <= n; h++) {
    int count = 0;
    for (int i = 1; i <= 100; i++) {
      if (i * i >= h)
        break;

      for (int j = i; j <= 100; j++) {
        for (int k = j; k <= 100; k++) {
          int x = (i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i);
          if (x == h) {
            if (i == j && j == k && k == i) {
              count++;
            } else if (i != j && j != k & k != i) {
              count += 6;
            } else {
              count += 3;
            }
          }
        }
      }
    }
    cout << count << endl;
  }
}

Error: TLE

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  int i, j, k;

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int cnt = 0;
    int N = i;
    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 cal = x * x + y * y + z * z + x * y + y * z + z * x;
          if (cal < N)
            continue;
          if (cal == N)
            ++cnt;
          break;
        }
      }
    }
    cout << cnt << '\\n';
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int cnt = 0;
    int N = i;
    for (int x = 1; x <= n; ++x) {
      for (int y = 1; y <= n; ++y) {
        for (int z = 1; z <= n; ++z) {
          int cal = x * x + y * y + z * z + x * y + y * z + z * x;
          if (cal < N)
            continue;
          if (cal == N)
            ++cnt;
          break;
        }
      }
    }
    cout << cnt << '\\n';
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void) {
  int N;
  cin >> N;
  int cnt[10050];
  fill(cnt, cnt + N + 1, 0);
  int tmp = 0;
  for (int x = 1; x <= 105; x++) {
    for (int y = 1; y <= 105; y++) {
      for (int z = 1; z <= 105; z++) {
        tmp = x * x + y * y + z * z + x * y + y * z + z * x;
        if (tmp < 10050) {
          cnt[tmp]++;
        }
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    cout << cnt[i] << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void) {
  int N;
  cin >> N;
  int cnt[N + 1];
  fill(cnt, cnt + N + 1, 0);
  for (int i = 1; i <= N; i++) {
    for (int x = 1; x <= 100; x++) {
      for (int y = 1; y <= 100; y++) {
        for (int z = 1; z <= 100; z++) {
          if ((x + y + z) * (x + y + z) == i + (x * y + y * z + z * x)) {
            cnt[i]++;
          }
        }
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    cout << cnt[i] << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

// 短縮
#define rep(i, n) for (int i = 0; i < (n); ++i)
// sort()用
#define all(v) v.begin(), v.end()

#define PB(N) push_back(N)

using namespace std;

using Graph = vector<vector<int>>;

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

  vector<int> count(N);
  for (int n = 1; n <= N; n++) {
    double buffer = pow(n, 0.5);
    for (int x = 1; x < buffer; x++) {
      for (int y = x; y < buffer; y++) {
        double z =
            pow(n - (double)3.0 * (x * x + y * y) / 4.0 - (double)x * y / 2.0,
                0.5) -
            (double)(x + y) / 2;
        if (floor(z) == z && (z >= 1)) {
          if (x == y)
            count[n - 1]++;
          else
            count[n - 1] += 2;
          // count[n-1]++;
        }
      }
    }
  }

  rep(i, N) cout << count[i] << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

// 短縮
#define rep(i, n) for (int i = 0; i < (n); ++i)
// sort()用
#define all(v) v.begin(), v.end()

#define PB(N) push_back(N)

using namespace std;

using Graph = vector<vector<int>>;

int main() {
  int N;
  cin >> N;
  vector<int> count(N);
  for (int n = 1; n <= N; n++) {
    double buffer = pow(n, 0.5);
    for (int x = 1; x < buffer; x++) {
      for (int y = 1; y < buffer; y++) {
        double z =
            pow(n - (double)3.0 * (x * x + y * y) / 4.0 - (double)x * y / 2.0,
                0.5) -
            (double)(x + y) / 2;
        if (floor(z) == z && (z >= 1)) {
          count[n - 1] += 1;
          // count[n-1]++;
        }
      }
    }
  }

  rep(i, N) cout << count[i] << endl;
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int n, ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int x = 1; x <= n; x++) {
      if (x * x + 2 * x + 3 > i)
        break;
      int xx = x * x;
      for (int y = x; y <= n; y++) {
        int xy = xx + y * (x + y);
        if (xy + x + y + 1 > i)
          break;
        for (int z = y; z <= n; z++) {
          if (i == xy + z * (x + y + z)) {
            // if(i == x*x+x*y+x*z+y*y+z*z+z*y) {
            if (x == y && y == z)
              ans++;
            else if (x != y && y != z && z != x)
              ans += 6;
            else
              ans += 3;
          }
          if (i < (x + y + z) * (x + y + z) - z * y - z * x - x * y)
            break;
        }
      }
    }
    cout << ans << endl;
    ans = 0;
  }
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int n, ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int x = 1; x <= n; x++) {
      if (x * x + 2 * x + 3 > i)
        break;
      int xx = x * x;
      for (int y = x; y <= n; y++) {
        int xy = xx + y * (x + y);
        if (xy + x + y + 1 > i)
          break;
        for (int z = y; z <= n; z++) {
          if (i == xy + z * (x + y + z)) {
            // if(i == x*x+x*y+x*z+y*y+z*z+z*y) {
            if (x == y && y == z)
              ans++;
            else if (x != y && y != z && z != x)
              ans += 6;
            else
              ans += 3;
          }
          // if(i < (x+y+z)*(x+y+z)-z*y-z*x-x*y) break;
        }
      }
    }
    cout << ans << endl;
    ans = 0;
  }
}