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

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

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

  int x, y, z, xx;
  int f_n = 0;
  int cnt = 0;

  for (int i = 1; i < n + 1; i++) {
    // 1～Nまでforループし、計算式とNが一致する数をcntでカウント
    cnt = 0;

    for (x = 1; x < i; x++) {
      if ((x * x) > i)
        break; // 計算量削減

      for (y = 1; y < i; y++) {
        if ((x * x + y * y + x * y) > i)
          break; // 計算量削減

        for (z = 1; z < i; z++) {
          if ((x * x + y * y + z * z + x * y + y * z + z * x) > i)
            break; // 計算量削減

          f_n = x * x + y * y + z * z + x * y + y * z + z * x;
          // cout << "debug n:" << i << ", f_n:" << f_n << endl;
          if (f_n == i) {
            cnt = cnt + 1;
            // cout << "debug x:y:z - " << x << ":" << y << ":" << z << endl;
            // cout << "debug f_n - " << f_n << endl;
          }
        }
      }
    } // for x

    cout << cnt << endl;
  } // for i
}

Error: TLE

Fixed submission:

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

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

  int x, y, z;
  int f_n = 0;
  int cnt = 0;

  for (int i = 1; i < n + 1; i++) {
    // 1～Nまでforループし、計算式とNが一致する数をcntでカウント
    cnt = 0;

    for (x = 1; x < i; x++) {
      if ((x * x) > i)
        break;

      for (y = 1; y < i; y++) {
        if ((y * y) > i)
          break;

        for (z = 1; z < i; z++) {
          if ((z * z) > i)
            break;

          f_n = x * x + y * y + z * z + x * y + y * z + z * x;
          // cout << "debug n:" << i << ", f_n:" << f_n << endl;
          if (f_n == i) {
            cnt = cnt + 1;
            // cout << "debug x:y:z - " << x << ":" << y << ":" << z << endl;
            // cout << "debug f_n - " << f_n << endl;
          }
        }
      }
    } // for x

    cout << cnt << endl;
  } // for i
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) (x.begin()), (x.end())
#define sz(x) ((ll)x.size())
#define FAST_IO                                                                \\
  ios_base ::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
using namespace std;
#ifdef LOCAL
#include "uj.h"
#endif
void tokenize(string str, const char delim, vector<string> &res) {
  stringstream p(str);
  string token;
  while (getline(p, token, delim)) {
    res.push_back(token);
  }
  return;
}

// Your workSpace ...

ll N;
ll f(ll a, ll b, ll c) { return a * a + b * b + c * c + a * b + a * c + b * c; }

const int maxn = 1e5;
vector<int> v(maxn);

void search(int x) {
  for (int i = 1; i <= sqrt(x); i++) {
    for (int j = 1; j <= sqrt(x); ++j)
      for (int k = 1; k <= sqrt(x); ++k) {
        ll val = f(i, j, k);
        v[val]++;
      }
  }
}

void test_case() {
  cin >> N;
  search(N);
  for (int i = 1; i <= N; ++i) {
    cout << v[i] << endl;
  }
}

int main() {
  FAST_IO;
  int tt;
  // cin>>tt;
  tt = 1;
  while (tt--) {
    test_case();
  }
#ifndef ONLINE_JUDGE
  cerr << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\\n";
#endif
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) (x.begin()), (x.end())
#define sz(x) ((ll)x.size())
#define FAST_IO                                                                \\
  ios_base ::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
using namespace std;
#ifdef LOCAL
#include "uj.h"
#endif
void tokenize(string str, const char delim, vector<string> &res) {
  stringstream p(str);
  string token;
  while (getline(p, token, delim)) {
    res.push_back(token);
  }
  return;
}

// Your workSpace ...

ll N;
ll f(ll a, ll b, ll c) { return a * a + b * b + c * c + a * b + a * c + b * c; }

ll func(ll a, ll b, ll c) {
  if (a == b && b == c && c == a)
    return 1;
  if (a == b || b == c || c == a)
    return 3;
  else
    return 6;
}

map<vector<int>, bool> used;

ll search(int x) {
  ll res = 0;
  for (int i = 1; i <= sqrt(x); i++) {
    if (f(i, 1, 1) > x)
      break;
    for (int j = 1; j <= sqrt(x); ++j) {
      if (f(i, j, 1) > x)
        break;
      for (int k = 1; k <= sqrt(x); ++k) {
        if (f(i, j, k) > x)
          break;
        vector<int> v = {i, j, k};
        sort(all(v));
        if (f(i, j, k) == x && used[v] == false)
          res += func(i, j, k), used[v] = true;
      }
    }
  }
  return res;
}

void test_case() {
  cin >> N;
  for (int i = 1; i <= N; ++i) {
    ll res = search(i);
    cout << res << endl;
  }
}

int main() {
  FAST_IO;
  int tt;
  // cin>>tt;
  tt = 1;
  while (tt--) {
    test_case();
  }
#ifndef ONLINE_JUDGE
  cerr << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\\n";
#endif
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error


#include "math.h"
#include <algorithm>
#include <cmath>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

int t;
const int N = 10001;
int arr[N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 0; i < N; i++) {
    arr[i] = 0;
  }
  for (int x = 1; x <= 100; x++) {

    for (int y = x; y <= int(sqrt(10001 - x * x)); y++) {
      for (int z = y; z <= int(sqrt(10001 - x * x - y * y)); z++) {
        long long s = x * x + y * y + z * z + x * y + x * z + y * z;
        int k = 6;
        if (x == y && x == z) {
          k = 1;
        } else if (x == y) {
          k = 3;
        } else if (x == z) {
          k = 3;
        } else if (y == z) {
          k = 3;
        }
        if (s < N)
          arr[s - 1] += k;
      }
    }
  }
  cin >> t;
  for (int i = 0; i < t; i++) {
    cout << arr[i] << endl;
  }
  return 0;
}


Error: 0

Fixed submission:


#include "math.h"
#include <algorithm>
#include <cmath>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

int t;
const int N = 1000;
int arr[N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 0; i < N; i++) {
    arr[i] = 0;
  }
  for (int x = 1; x <= 100; x++) {

    for (int y = x; y <= int(sqrt(10000 - x * x)); y++) {
      for (int z = y; z <= int(sqrt(10000 - x * x - y * y)); z++) {
        long long s = x * x + y * y + z * z + x * y + x * z + y * z;
        int k = 6;
        if (x == y && x == z) {
          k = 1;
        } else if (x == y) {
          k = 3;
        } else if (x == z) {
          k = 3;
        } else if (y == z) {
          k = 3;
        }
        if (s < N)
          arr[s - 1] += k;
      }
    }
  }
  cin >> t;
  for (int i = 0; i < t; i++) {
    cout << arr[i] << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define N (1000000000 + 7)
#define M 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int, int> P;

const int inf = (int)1e9;

ll A(ll x) {
  if (x >= 0)
    return x;
  else
    return -x;
}

ll gcd(ll a, ll b) {
  if (b > a) {
    ll tmp = b;
    b = a;
    a = tmp;
  }
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}

ll cnt[10010];

int main(void) {
  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++) {
        if (x * x + y * y + z * z + x * y + y * z + z * x > 10000)
          continue;
        cnt[x * x + y * y + z * z + x * y + y * z + z * x]++;
        // cout<<x*x+y*y+z*z+x*y+y*z+z*x<<endl;
        // if(x*x+y*y+z*z+x*y+y*z+z*x==n)ans++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << cnt[i] << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define N (1000000000 + 7)
#define M 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int, int> P;

const int inf = (int)1e9;

ll A(ll x) {
  if (x >= 0)
    return x;
  else
    return -x;
}

ll gcd(ll a, ll b) {
  if (b > a) {
    ll tmp = b;
    b = a;
    a = tmp;
  }
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}

ll cnt[10010];

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

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
  int N, x, y, z, i, j, k, l, ans = 0;
  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    for (j = 0; j < (N / 6); j++) {
      x = j + 1;
      for (k = j; k < (N - x * x) / 6; k++) {
        y = k + 1;
        for (l = k; l < (N - x * x - y * y) / 6; l++) {
          z = l + 1;
          if ((x * x + y * y + z * z + x * y + y * z + z * x) > (i + 1)) {
            break;
            break;
            break;
          }
          if ((x * x + y * y + z * z + x * y + y * z + z * x) == (i + 1)) {
            if (x != y && y != z && z != x) {
              ans += 6;
            } else {
              if (x == y && y == z) {
                ans++;
              } else {
                ans += 3;
              }
            }
          }
        }
      }
    }
    printf("%d\\n", ans);
    ans = 0;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
  int N, x, y, z, i, j, k, l, ans = 0;
  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    for (j = 0; j < (N / 6); j++) {
      x = j + 1;
      for (k = j; k < (N - x * x) / 6; k++) {
        y = k + 1;
        for (l = k; l < (N - x * x - y * y) / 6; l++) {
          z = l + 1;
          if ((x * x + y * y + z * z + x * y + y * z + z * x) == (i + 1)) {
            if (x != y && y != z && z != x) {
              ans += 6;
            } else {
              if (x == y && y == z) {
                ans++;
              } else {
                ans += 3;
              }
            }
          }
        }
      }
    }
    printf("%d\\n", ans);
    ans = 0;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using ll = long long;
using namespace std;
const int INFint = 1e9 + 1;
const ll INFll = (ll)1e18 + 1;
ll MOD = 1e9 + 7;

int main() {
  int N;
  cin >> N;
  int cnt[10001] = {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 <= N) {
          cnt[x]++;
        }
      }
    }
  }
  for (int i(1); i <= N; i++) {
    cout << cnt[i] << endl;
  }
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

using ll = long long;
using namespace std;
const int INFint = 1e9 + 1;
const ll INFll = (ll)1e18 + 1;
ll MOD = 1e9 + 7;

int main() {
  int N;
  cin >> N;
  int cnt[1001] = {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 <= N) {
          cnt[x]++;
        }
      }
    }
  }
  for (int i(1); i <= N; i++) {
    cout << cnt[i] << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> ans(n, 0);
  for (int i = 1; i * i <= n; i++)
    for (int j = 1; j * j <= n; j++)
      for (int k = 1; k * k <= n; k++) {
        long long f = i * i + j * j + k * k + i * j + j * k + k * i;
        if (f <= n)
          ans[f - 1]++;
      }

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

Error: -6
malloc(): corrupted top size


Fixed submission:

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> ans(n, 0);
  for (int i = 1; i * i <= n; i++)
    for (int j = 1; j * j <= n; j++)
      for (int k = 1; k * k <= n; k++) {
        int f = i * i + j * j + k * k + i * j + j * k + k * i;
        ans[f - 1]++;
      }

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

#include <bits/stdc++.h>
#define ll long long
#define endl '\\n'
#define pii pair<ll, ll>
using namespace std;
#define N 100007
#define pb push_back;
vector<ll> g[N];
#define FAST                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);

int main() {
  FAST;
  ll n;
  cin >> n;
  ll i, j, k, l, cnt = 0;
  for (i = 1; i <= n; i++) {
    cnt = 0;
    for (j = 1; j <= 100; j++) {
      for (k = 1; k <= 100; k++) {
        ll b = -(k + j);
        ll x = b * b - 4 * (k * k + j * j + k * j - i);
        if (x < 0) {
          continue;
        }
        ll sqrtt = sqrt(x);
        if (sqrtt * sqrtt == x) {
          x = b + sqrtt;
          //  cout<<j<<" "<<k<<" "<<x<<" "<<sqrtt<<" "<<i<<endl;
          if (x % 2 == 0 && (x / 2) >= 1) {
            cnt++;
          }
        }
      }
    }
    cout << cnt << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define endl '\\n'
#define pii pair<ll, ll>
using namespace std;
#define N 100007
#define pb push_back;
vector<ll> g[N];
#define FAST                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);

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

// include
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

// pow(10, 15) 10の15乗

//  多倍長整数
#include <boost/multiprecision/cpp_int.hpp>
using big_int = boost::multiprecision::cpp_int;

std::uint64_t f(std::uint64_t x, std::uint64_t y, std::uint64_t z) {
  return (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x);
}

// ============================================
int main() {
  int N;
  std::cin >> N;
  std::vector<int> v(N);

  int limit = std::numeric_limits<int>::max();
  ;
  for (int x = 1; x <= N; x++) {
    for (int y = 1; y <= N; y++) {
      for (int z = 1; z <= N; z++) {
        if (x + y + z > limit) {
          break;
        }
        std::uint64_t a = f(x, y, z);
        // std::cout << "x:" << x << " y:" << y << "z:" << z << " n=" << a <<
        // std::endl;
        if (a > N) {
          //            std::cout << "b" << std::endl;
          limit = x + y + z + 1;
          break;
        }
        a = a - 1;
        v[a] += 1;
      }
    }
  }
  for (int i = 0; i < N; ++i) {
    std::cout << v[i] << std::endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

// include
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

// pow(10, 15) 10の15乗

//  多倍長整数
#include <boost/multiprecision/cpp_int.hpp>
using big_int = boost::multiprecision::cpp_int;

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

// ============================================
int main() {
  int N;
  std::cin >> N;
  std::vector<int> v(N);
  for (int x = 1; x < N; x++) {
    for (int y = 1; y < N; y++) {
      for (int z = 1; z < N; z++) {
        int a = f(x, y, z);
        // std::cout << "x:" << x << " y:" << y << "z:" << z << " n=" << a <<
        // std::endl;
        a = a - 1;
        if (a >= N) {
          continue;
        }
        v[a] += 1;
      }
    }
  }

  for (int i = 0; i < N; ++i) {
    std::cout << v[i] << std::endl;
  }

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

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

int main() {
  int n, cnt = 0, res;
  int xx, yy, zz;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cnt = 0;
    for (int x = 1; x <= 100; x++) {
      xx = x * x;
      if (xx >= i)
        break;
      for (int y = 1; y <= 100; y++) {
        yy = y * y;
        if (xx + yy >= i)
          break;
        for (int z = 1; z <= 100; z++) {
          zz = z * z;
          if (xx + yy + zz >= i)
            break;
          res = xx + yy + zz + x * y + y * z + z * x;
          if (res > i)
            break;
          if (res == i)
            cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
}

Error: TLE

Fixed submission:

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

int main() {
  int n, cnt = 0, res;
  bool flag = false;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cnt = 0;
    flag = false;
    for (int x = 1; x <= 100; x++) {
      if (x * x >= i)
        break;
      for (int y = 1; y <= 100; y++) {
        if (y * y >= i)
          break;
        for (int z = 1; z <= 100; z++) {
          if (z * z >= i)
            break;
          res = x * x + y * y + z * z + x * y + y * z + z * x;
          if (res == i)
            cnt++;
        }
      }
    }
    cout << cnt << 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 ans = 0;
    for (int x = 1; x * x <= i; x++) {
      for (int y = 1; y * y <= i; y++) {
        int b = x + y;
        int c = x * x + x * y + y * y - i;
        int r = b * b - 4 * c;
        if (r < 0)
          continue;
        double sr = sqrt(r);
        if (sr != floor(sr))
          continue;
        int rr = sr;
        int z1 = (-b + rr) / 2;
        if (z1 >= 1) {
          ans++;
        }
        int z2 = (-b - rr) / 2;
        if (z2 >= 1) {
          ans++;
        }
      }
    }
    cout << ans << endl;
  }
}


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 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 <bits/stdc++.h>
using namespace std;
int trips(int n) {
  int m, i, j, k, sum, ans = 0;
  m = sqrt(n - 5) + 1;
  for (i = 1; i < m; i++) {
    for (j = i; j < m; j++) {
      for (k = j; k < m; k++) {
        sum = pow(i, 2) + pow(j, 2) + pow(k, 2) + i * j + j * k + i * k;
        if (sum == n) {
          if (i != j && j != k)
            ans += 6;
          else if ((i == j && j != k) || (k == j && j != i) ||
                   (i == k && j != k))
            ans += 3;
          else if (i == j && j == k)
            ans++;
        }
      }
    }
  }
  return ans;
}
int main() {
  int n, i;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cout << trips(i) << endl;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int trips(int n) {
  int m, i, j, k, sum, ans = 0;
  m = sqrt(n - 5) + 1;
  for (i = 1; i < m; i++) {
    for (j = 1; j < m; j++) {
      for (k = 1; k < m; k++) {
        sum = pow(i, 2) + pow(j, 2) + pow(k, 2) + i * j + j * k + i * k;
        if (sum == n)
          ans++;
      }
    }
  }
  return ans;
}
int main() {
  int n, i;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cout << trips(i) << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int N;
  cin >> N;
  vector<int> f(N, 0);
  for (int i = 0; i < N; i++) {
    for (int x = 1; x < 100; x++) {
      for (int y = x; y < 100; y++) {
        if (i + 1 > x * x + y * y + x * y + x + y) {
          for (int z = y; z < 100; z++) {
            int tmp = x * x + y * y + z * z + x * y + y * z + z * x;
            if (tmp == i + 1) {
              if (x == y || y == z) {
                if (x == z)
                  f[i]++;
                else
                  f[i] += 3;
              } else
                f[i] += 6;
            }
          }
        }
      }
    }
  }
  for (int i = 0; i < N; i++)
    cout << f[i] << endl;
}


Error: TLE

Fixed submission:

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

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

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

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

  int c[N];
  rep(i, N) { c[i] = 0; }
  int M = sqrt(N);
  rep(i, M) {
    int x = i + 1;
    int xx = x * x;
    if (xx > N)
      break;
    rep(j, M) {
      int y = j + 1;
      int yy = y * y;
      int xy = x * y;
      if (xx + yy + xy > N)
        break;
      rep(k, M) {
        int z = k + 1;
        int n = xx + yy + z * z + xy + y * z + z * x;
        if (n > n)
          break;
        rep(l, N) {
          if (l + 1 == n)
            c[l]++;
        }
      }
    }
  }
  rep(i, N) { cout << c[i] << endl; }
}


Error: TLE

Fixed submission:

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

int main() {
  int N;
  cin >> N;
  int M = sqrt(N);
  int c[N];
  rep(i, N) { c[i] = 0; }
  rep(i, M) {
    int x = i + 1;
    int O = sqrt(N - x * x);
    rep(j, O) {
      int y = j + 1;
      int P = sqrt(N - x * x - y * y - x * y);
      rep(k, P) {
        int z = k + 1;
        int n = x * x + y * y + z * z + x * y + y * z + z * x;
        rep(l, N) {
          if (l + 1 == n)
            c[l]++;
        }
      }
    }
  }
  rep(i, N) { cout << c[i] << endl; }
}