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


Error: TLE

Fixed submission:

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

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll, ll>
#define tii tuple<ll, ll, ll>
#define all(v) (v).begin(), (v).end()
#define ll long long
#define ull unsigned long long
#define fastio                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
#define endl "\\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

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

  map<int, int> mp;
  for (ll j = 1; j * j <= n; ++j) {
    for (ll k = 1; k * k <= n; ++k) {
      for (ll l = 1; l * l <= n; ++l) {
        mp[j * j + k * k + l * l + j * k + j * l + l * k] += 1;
      }
    }
  }

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

int32_t main() {
  fastio int t;
  t = 1; // cin>>t;
  while (t--) {
    solve();
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll, ll>
#define tii tuple<ll, ll, ll>
#define all(v) (v).begin(), (v).end()
#define ll long long
#define ull unsigned long long
#define fastio                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
#define endl "\\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

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

  for (int i = 1; i <= n; ++i) {
    ll ans = 0;
    for (ll j = 1; j * j <= i; ++j) {
      if (j * j > i)
        break;
      for (ll k = 1; k * k <= i; ++k) {
        if (k * k > i)
          break;
        for (ll l = 1; l * l <= i; ++l) {
          if (l * l > i)
            break;
          if (j * j + k * k + l * l + j * k + j * l + l * k == i) {
            ans++;
          }
        }
      }
    }

    cout << ans << endl;
  }
}

int32_t main() {
  fastio int t;
  t = 1; // cin>>t;
  while (t--) {
    solve();
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  for (int n = 1; n <= N; n++) {
    int ans = 0;
    int n2 = (int)sqrt(N);
    for (int x = 1; x <= n2; x++) {
      if (x >= n)
        break;
      for (int y = 1; y <= n2; y++) {
        if (y >= n)
          break;
        const int c = n - x * x - y * y - x * y;
        int lb = 0;
        int ub = n2;
        while (ub - lb > 1) {
          int mid = (lb + ub) / 2;
          int tmp = mid * mid + (y + x) * mid;
          if (tmp == c) {
            ans++;
            break;
          } else if (tmp > c) {
            ub = mid;
          } else {
            lb = mid;
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  for (int n = 1; n <= N; n++) {
    int ans = 0;
    int n2 = (int)sqrt(N);
    for (int x = 1; x <= n2; x++) {
      for (int y = 1; y <= n2; y++) {
        const int c = n - x * x - y * y - x * y;
        int lb = 0;
        int ub = 10000;
        while (ub - lb > 1) {
          int mid = (lb + ub) / 2;
          int tmp = mid * mid + (y + x) * mid;
          if (tmp == c) {
            ans++;
            break;
          } else if (tmp > c) {
            ub = mid;
          } else {
            lb = mid;
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 1; i <= n; ++i)
#define INF (1ll << 60)
#define mod 1000000007
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  ll n;
  cin >> n;

  for (ll n2 = 1; n2 <= n; n2++) {
    ll ans = 0;
    for (ll x = 1; x * x <= n2 / 6; x++) {
      for (ll y = 1; y * y <= n2 / 3; y++) {

        ll z = 1, ng = n2;
        while (ng - z > 1) {
          ll mid = (z + ng) / 2;
          if (x * x + y * y + mid * mid + x * y + y * mid + mid * x <= n2) {
            z = mid;
          } else {
            ng = mid;
          }
        }

        // cout<<x<<" "<<y<<" "<<z<<endl;
        if (x * x + y * y + z * z + x * y + y * z + z * x != n2)
          continue;

        if (x < y && y < z)
          ans += 6;
        if (x == y && y < z) {
          ans += 3;
        }
        if (x < y && y == z) {
          ans += 3;
        }
        if (x == y && y == z) {
          ans++;
        }
      }
    }

    cout << ans << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 1; i <= n; ++i)
#define INF (1ll << 60)
#define mod 1000000007
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  ll n;
  cin >> n;

  for (ll n2 = 1; n2 <= n; n2++) {
    ll ans = 0;
    for (ll x = 1; x * x <= n / 6; x++) {
      for (ll y = 1; y * y <= (n - 3 * x * x) / 3; y++) {
        for (ll z = 1; z * z <= n - 3 * x * x - y * y - x * y; z++) {
          while ((x + y) * (x + y) + (y + z) * (y + z) + (z + x) * (z + x) <=
                 2 * n2) {
            if (x < y && y < z)
              ans += 6;
            if (x == y && y < z) {
              ans += 3;
            }
            if (x < y && y == z) {
              ans += 3;
            }
            if (x == y && y == z) {
              ans++;
            }
          }
        }
      }
    }

    cout << ans << endl;
  }

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

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define int long long int
#define double long double
#define inf (int)(1e15)
#define all(x) (x).begin(), (x).end()
#define pair pair<int, int>
typedef vector<int> vi;   // Vector of long long
typedef vector<vi> vvi;   // Vector of vi
typedef vector<pair> vii; // Vector of pairs
typedef vector<vii> vvii; // Vector of Vector of pairs
typedef vector<bool> vb;  // Vector of bool
#define pq                                                                     \\
  priority_queue // Max heap (To convert to min heap, use negative sign before
                 // every value)
#define ff first // For pairs
#define ss second
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1},
          dy8[] = {1, -1, 1, 0, -1, 1, -0, -1};
#define testcases(t)                                                           \\
  int(t);                                                                      \\
  cin >> (t);                                                                  \\
  while ((t)--)
vi f;
int n;
signed main() {
  cin >> n;
  f.resize(n + 1, 0);
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        int val = (i + j) * (i + j) + (j + k) * (j + k) + (k + i) * (k + i);
        val /= 2;
        if (val <= n)
          f[val]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << f[i] << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define int long long int
#define double long double
#define inf (int)(1e15)
#define all(x) (x).begin(), (x).end()
#define pair pair<int, int>
typedef vector<int> vi;   // Vector of long long
typedef vector<vi> vvi;   // Vector of vi
typedef vector<pair> vii; // Vector of pairs
typedef vector<vii> vvii; // Vector of Vector of pairs
typedef vector<bool> vb;  // Vector of bool
#define pq                                                                     \\
  priority_queue // Max heap (To convert to min heap, use negative sign before
                 // every value)
#define ff first // For pairs
#define ss second
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1},
          dy8[] = {1, -1, 1, 0, -1, 1, -0, -1};
#define testcases(t)                                                           \\
  int(t);                                                                      \\
  cin >> (t);                                                                  \\
  while ((t)--)
vi f(1000, 0);
int n;
signed main() {
  cin >> n;
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        int val = (i + j) * (i + j) + (j + k) * (j + k) + (k + i) * (k + i);
        val /= 2;
        if (val <= n)
          f[val]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << f[i] << endl;
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#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 < (int)(n); i++)
const int INF = 1001001001;

int num[10005];

void f(int n) {
  int m = sqrt(n);
  rep(i, m) rep(j, m) rep(k, m) {
    int x = i + 1;
    int y = j + 1;
    int z = k + 1;
    int index = x * x + y * y + z * z + x * y + y * z + z * x;
    if (index < 10005)
      num[index]++;
  }
}

int main() {
  int n;
  cin >> n;
  f(n);
  rep(i, n) cout << num[i + 1] << endl;
  return 0;
}


Error: 0

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 < (int)(n); i++)
const int INF = 1001001001;

int num[10005];

void f(int n) {
  int m = sqrt(n);
  rep(i, m) rep(j, m) rep(k, m) {
    int x = i + 1;
    int y = j + 1;
    int z = k + 1;
    num[x * x + y * y + z * z + x * y + y * z + z * x]++;
  }
}

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

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

long f(long x, long y, long z) {
  return pow(x + y + z, 2) - x * y - y * z - z * x;
}

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

  for (int i = 1; i <= N; i++) {
    long cnt = 0;
    long max = sqrt(i);
    for (long x = 1; x <= max; x++) {
      for (long y = 1; y <= x; y++) {
        for (long z = 1; z <= y; z++) {
          if (f(x, y, z) == i) {
            if (x == y) {
              if (y == z) {
                cnt++;
              } else {
                cnt = cnt + 3;
              }
            } else if (y == z) {
              if (z == x) {
                cnt++;
              } else {
                cnt = cnt + 3;
              }
            } else if (z == x) {
              if (x == y) {
                cnt++;
              } else {
                cnt = cnt + 3;
              }
            } else {
              cnt = cnt + 6;
            }
          }
        }
      }
    }
    cout << cnt << endl;
  }
}


Error: TLE

Fixed submission:

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

long f(long x, long y, long z) {
  return pow(x + y + z, 2) - x * y - y * z - z * x;
}

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

  for (int i = 1; i <= N; i++) {
    long cnt = 0;
    long max = sqrt(i);
    for (long x = 1; x <= max; x++) {
      for (long y = 1; y <= max; y++) {
        for (long z = 1; z <= max; z++) {
          if (f(x, y, z) == i)
            cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

typedef long long ll;
const int inf = 1e9;

int n, u, k;

vector<int> cnt(10001, 0);

int main() {
  cin >> k;
  for (int i = 1; i <= 100; ++i) {
    for (int j = 1; j <= 100; ++j) {
      for (int k = 1; k <= 100; ++k) {
        ll ans = i * i + j * j + k * k + i * j + i * k + j * k;
        if (ans <= 10000)
          cnt[ans]++;
      }
    }
  }
  for (int i = 1; i <= k; ++i)
    cout << cnt[i] << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

typedef long long ll;
const int inf = 1e9;

int n, u, k;

vector<int> cnt(1001, 0);

int main() {
  cin >> k;
  for (int n = 1; n <= k; ++n) {
    for (int x = 1; x < sqrt(n); ++x) {
      for (int y = 1; y < sqrt(n); ++y) {
        for (int z = 1; z < sqrt(n); ++z) {
          if ((x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (x * z) == n) {
            cnt[n]++;
          }
        }
      }
    }
  }
  for (int i = 1; i <= k; ++i)
    cout << cnt[i] << endl;
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

int arr[10050];

int main(void) {
  int n;
  cin >> n;
  for (int i = 1; i <= 105; i++) {
    for (int j = 1; j <= 105; j++) {
      for (int k = 1; k <= 105; k++) {
        int com = (i * i + j * j + k * k + i * j + j * k + k * i);
        if (com < 10050)
          arr[com]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << arr[i] << endl;
}


Error: -11

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int arr[11000];

int main(void) {
  int n;
  cin >> n;
  for (int i = 1; i <= 105; i++) {
    for (int j = 1; j <= 105; j++) {
      for (int k = 1; k <= 105; k++) {
        int com = (i * i + j * j + k * k + i * j + j * k + k * i);
        if (i == j && j == k)
          arr[com] = 1;
        else if (i == j || j == k)
          arr[com] = 3;
        else
          arr[com] = 6;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << arr[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++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()    // 昇順ソート
#define rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define FastIO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
typedef long long ll;
typedef long long int lli;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};

int solve(int a, int b, int c) {
  double d = sqrt(b * b - 4 * a * c);
  if (d < 0)
    return 0;
  if (floor(d != d))
    return 0;
  double x = (-b + d) / 2 * a;
  double y = (-b - d) / 2 * a;
  int ans = 0;
  if (floor(x) == x && x > 0)
    ans++;
  if (floor(y) == y && y > 0)
    ans++;
  return ans;
}

int f(int n) {
  int ans = 0;
  for (int i = 1; i * i <= n; i++) {
    for (int j = 1; j * j <= n; j++) {
      ans += solve(1, i + j, (i * i + j * j + i * j - n));
    }
  }
  return ans;
}

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cout << f(i) << 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++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()    // 昇順ソート
#define rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define FastIO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
typedef long long ll;
typedef long long int lli;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};

int f(int n) {
  int ans = 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++) {
        if ((i * i + j * j + k * k + i * j + j * k + i * k) == n)
          ans++;
      }
    }
  }
  return ans;
}

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

#include <cstdio>

using namespace std;

bool s(int x, int y, int z, int n) {
  return ((x * x + y * y + z * z + x * y + x * z + y * z) == n);
}

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

int main() {
  int n;
  scanf("%d", &n);
  for (int t = 1; t <= n; t++) {
    int count = 0;
    for (int i = 1; i * i <= t; i++) {
      for (int j = i; j * j <= t; j++) {
        for (int k = j; k * k <= t; k++) {
          if (s(i, j, k, t)) {
            count += permutation(i, j, k);
          }
        }
      }
    }
    printf("%d\\n", count);
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
using namespace std;

int f(int n) {}

bool s(int x, int y, int z, int n) {
  return ((x * x + y * y + z * z + x * y + x * z + y * z) == n);
}

int main() {
  int n;
  scanf("%d", &n);
  for (int t = 1; t <= n; t++) {
    int count = 0;

    for (int i = 1; i * i <= t; i++) {
      for (int j = 1; j * j <= t; j++) {
        for (int k = 1; k * k <= t; k++) {
          if (s(i, j, k, t)) {
            count++;
          }
        }
      }
    }
    printf("%d\\n", count);
  }

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200000005];
char s[100][8];
int main() {
  ll n, m, k, i, j, l, ans = 0, K, x = 1, y = 1, r, d, z, flag = 1;
  scanf("%lld", &n);
  for (x = 1; x * x <= n; x++) {
    for (y = 1; y * y <= n; y++) {
      for (z = 1; z * z <= n; z++) {
        a[x * x + y * y + z * z + x * y + y * z + z * x]++;
        if (x * x + y * y + z * z + x * y + y * z + z * x > n) {
          flag = 0;
          break;
        }
      }
      // if(flag==0)break;
    }
    //  if(flag==0)break;
  }
  for (x = 1; x <= n; x++)
    printf("%lld\\n", a[x]);

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200000005];
char s[100][8];
int main() {
  ll n, m, k, i, j, l, ans = 0, K, x = 1, y = 1, r, d, z, flag = 1;
  scanf("%lld", &n);
  for (x = 1; x <= n; x++) {
    for (y = 1; y <= n; y++) {
      for (z = 1; z <= n; z++) {
        a[x * x + y * y + z * z + x * y + y * z + z * x]++;
        if (x * x + y * y + z * z + x * y + y * z + z * x > n) {
          flag = 0;
          break;
        }
      }
      // if(flag==0)break;
    }
    //  if(flag==0)break;
  }
  for (x = 1; x <= n; x++)
    printf("%lld\\n", a[x]);

  return 0;
}
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, s, n) for (int i = (s); i < (int)(n); i++)
#define _GLIBCXX_DEBUG

int n, ans;

int max_n(double t) {
  if (t < 5)
    return t;
  t = sqrt(t);
  return t;
}
int main() {
  cin >> n;
  rep2(i, 1, n + 1) {
    double mn = max_n(i);

    ans = 0;
    rep2(x, 1, mn) rep2(y, x, mn) rep2(z, y, mn) {
      if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
        if (x != y && y != z)
          ans += 6;
        else if (x == y && y == z)
          ans += 1;
        else
          ans += 3;
      }
    }
    cout << ans << endl;
  }
}

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, s, n) for (int i = (s); i < (int)(n); i++)
#define _GLIBCXX_DEBUG

int n, ans;

int max_n(double t) {
  if (t < 5)
    return t;
  t = sqrt(t);
  return t;
}
int main() {
  cin >> n;
  rep2(i, 1, n + 1) {
    double mn = max_n(i);

    ans = 0;
    rep2(x, 1, mn) rep2(y, 1, mn) rep2(z, 1, mn) {
      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>
typedef long long int lli;
using namespace std;
#define MOD 1000000007
#define MAX 500005
lli p[MAX];
lli arr[MAX];
bool square[100000];
lli n;
lli a, b;
bool check(lli a, lli b, lli c) {
  if ((a - b + c) % 2 == 0 && (c + b - a) % 2 == 0 && (a + b - c) % 2 == 0) {
    if ((a - b + c) / 2 >= 1 && (c + b - a) / 2 >= 1 && (a + b - c) / 2 >= 1)
      return true;
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  lli n;
  cin >> n;
  for (lli i = 1; i <= n; i++) {
    if (i * i < 1e5)
      square[i * i] = true;
    else {
      break;
    }
  }
  lli ans = 0;
  for (lli N = 1; N <= n; N++) {
    ans = 0;
    for (int i = 1; (i * i) <= (2 * N); i++) {
      for (int j = 1; (j * j) <= (2 * N); j++) {
        if (((2 * N - i * i - j * j) >= 0) && square[2 * N - i * i - j * j]) {
          if (check(i, j, (long long)sqrt(2 * N - i * i - j * j)))
            ans++;
        }
      }
    }
    cout << ans << endl;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
typedef long long int lli;
using namespace std;
#define MOD 1000000007
#define MAX 500005
lli p[MAX];
lli arr[MAX];
lli n;
lli a, b;
bool check(lli a, lli b, lli c) {
  if ((a - b + c) % 2 == 0 && (c + b - a) % 2 == 0 && (a + b - c) % 2 == 0) {
    if ((a - b + c) / 2 >= 1 && (c + b - a) / 2 >= 1 && (a + b - c) / 2 >= 1)
      return true;
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  lli n;
  cin >> n;
  map<lli, lli> s;
  for (lli i = 1; i <= n; i++) {
    s[i * i] = i;
  }
  lli ans = 0;
  for (lli N = 1; N <= n; N++) {
    ans = 0;
    for (int i = 1; (i * i) <= N; i++) {
      for (int j = 1; (j * j) <= N; j++) {
        if (((2 * N - i * i - j * j) >= 0) && s[2 * N - i * i - j * j]) {
          if (check(i, j, s[2 * N - i * i - j * j]))
            ans++;
        }
      }
    }
    cout << ans << endl;
  }
}