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

#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int ary[10005];
int main() {
  int n;
  int m = 0;
  scanf("%d", &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++) {
        m = x * x + y * y + z * z + z * x + x * y + y * z;
        if (m <= 10000) {
          ary[m]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d\\n", ary[i]);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int triplet(int n) {
  int m = 0;
  int count = 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++) {
        m = x * x + y * y + z * z + z * x + x * y + y * z;
        if (n == m) {
          count++;
        }
      }
    }
  }
  return count;
}

int main() {
  int n;
  // int m = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    printf("%d\\n", triplet(i));
  }
  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++)
typedef long long ll;

int main() {
  int n;

  cin >> n;

  vector<int> ans(n);

  int total = 0;

  for (int i = 1; i < sqrt(n); i++) {
    for (int j = 1; j < sqrt(n); j++) {
      for (int k = 1; k < sqrt(n); k++) {
        total = i * i + j * j + k * k + i * j + j * k + i * k;
        if (n >= total)
          ans.at(total - 1)++;
      }
    }
  }
  rep(i, n) cout << ans.at(i) << endl;
}


Error: TLE

Fixed submission:

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

int main() {
  int n;

  cin >> n;

  int ans = 0;

  int max = ceil(sqrt(n) - sqrt(3));

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= max; j++) {
      for (int k = 1; k <= max; k++) {
        for (int l = 1; l <= max; l++) {
          if (j * j + k * k + l * l + j * k + k * l + j * l == i)
            ans++;
        }
      }
    }

    cout << ans << endl;
    ans = 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++)
using namespace std;
using ll = long long;

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

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

  for (int n = 1; n <= N; n++) {
    ll m = sqrt(n);

    int ans = 0;

    int ans1 = 0;
    for (int x = 1; x <= m; x++)
      for (int y = x + 1; y <= m; y++)
        for (int z = y + 1; z <= m; z++) {
          if (x == 0 || y == 0 || z == 0)
            continue;
          ll res = f(x, y, z);
          if (res > n)
            break;
          if (res == n)
            ans1++;
        }
    ans += 6 * ans1;

    int ans2 = 0;
    for (int x = 1; x <= m; x++)
      for (int y = 1; y <= m; y++) {
        if (x == y)
          continue;
        ll res = x * x + 3 * y * y + 2 * x * y;
        if (res > n)
          break;
        if (res == n)
          ans2++;
      }
    ans += 3 * ans2;

    if (n % 6 == 0) {
      int ans3 = 0;
      for (int x = 1; x <= m; x++) {
        if (x * x == n / 6)
          ans3++;
      }
      ans += ans3;
    }

    cout << ans << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

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

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

  for (int n = 1; n <= N; n++) {
    ll m = sqrt(n);

    int ans = 0;
    rep(x, m) rep(y, m) rep(z, m) {
      if (x == 0 || y == 0 || z == 0)
        continue;
      if (f(x, y, z) == n)
        ans++;
    }

    cout << ans << endl;
  }

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

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

int f(int n) {
  int cnt = 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++) {
        if (x * x + y * y + z * z + x * y + y * z + z * x > n)
          break;
        if (x * x + y * y + z * z + x * y + y * z + z * x == n) {
          cnt++;
          break;
        }
      }
    }
  }
  return cnt;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cout << f(i) << endl;
  }
}

Error: TLE

Fixed submission:

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

int f(int n) {
  int cnt = 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++) {
        if (x * x + y * y + z * z + x * y + y * z + z * x == n) {
          cnt++;
        }
      }
    }
  }
  return cnt;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cout << f(i) << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define rep(i, ini, n) for (int i = ini; i < n; i++)
#define _rep(i, ini, n) for (int i = ini; i >= n; i--)
#define ToEnd(a) a.begin(), a.end()
uint64_t MOD = 1000000007;

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

  vector<int64_t> Ans(100000, 0);
  rep(x, 1, 101) {
    rep(y, 1, 101) {
      rep(z, 1, 101) {
        int64_t v = x * x + y * y + z * z + x * y + y * z + z * x;
        if (v < Ans.size())
          Ans.at(v)++;
      }
    }
  }
  rep(i, 1, N + 1) cout << Ans.at(i) << endl;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, ini, n) for (int i = ini; i < n; i++)
#define _rep(i, ini, n) for (int i = ini; i >= n; i--)
#define ToEnd(a) a.begin(), a.end()
uint64_t MOD = 1000000007;

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

  vector<int64_t> Ans(1001, 0);
  rep(x, 1, 101) {
    rep(y, 1, 101) {
      rep(z, 1, 101) {
        int64_t v = x * x + y * y + z * z + x * y + y * z + z * x;
        if (v <= 1000)
          Ans.at(v)++;
      }
    }
  }
  rep(i, 1, N) cout << Ans.at(i) << endl;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define VI vector<int>
#define PII pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define db double
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
#define out(x) cout << (#x) << " = " << x << endl
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x) { return mrand() % x; }
clock_t ac;
double TLE() { return (double)(clock() - ac) / CLOCKS_PER_SEC; }

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  ll u = 0;
  for (ll i = 1; i <= n; i++) {
    ll c = 0;
    int h = (int)sqrt(i);
    for (int j = 1; j <= h; j++) {
      for (int k = j; k <= h; k++) {
        for (int m = k; m <= h; m++) {
          u = (k * k) + (m * m) + (j * j) + (j * m) + (j * k) + (k * m);
          if (u == i) {
            if (k == j && k == m && m == j) {
              c++;
            } else if (k == j || k == m || m == j) {
              c += 3;
            } else {
              c += 6;
            }
          }
        }
      }
    }
    cout << c << "\\n";
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define VI vector<int>
#define PII pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define db double
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
#define out(x) cout << (#x) << " = " << x << endl
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x) { return mrand() % x; }
clock_t ac;
double TLE() { return (double)(clock() - ac) / CLOCKS_PER_SEC; }

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  ll u = 0;
  for (ll i = 1; i <= n; i++) {
    ll c = 0;
    ll h = i / 3;
    for (int j = 1; j <= h; j++) {
      for (int k = j; k <= h; k++) {
        for (int m = k; m <= h; m++) {
          u = (k * k) + (m * m) + (j * j) + (j * m) + (j * k) + (k * m);
          if (u == i) {
            if (k == j && k == m && m == j) {
              c++;
            } else {
              c += 3;
            }
          }
        }
      }
    }
    cout << c << "\\n";
  }
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define speed                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#pragma GCC optimize "trapv"
#define _GLIBCXX_DEBUG
#define ll long long int
#define ld long double
#define ull unsigned long long int // ranges from (0 - twice of long long int)
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define per(i, a, n) for (ll i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define MOD 1000000007LL
#define llpair pair<ll, ll>
#define INF 1000000000000000000ll // this is 1e18 long long
#define np next_permutation
#define PI acos(-1)
#define DEB(x) cout << #x << " " << x << endl;
#define rotate_left(vec, amt) rotate(vec.begin(), vec.begin() + amt, vec.end());
#define rotate_right(vec, amt)                                                 \\
  rotate(vec.begin(), vec.begin() + vec.size() - amt, vec.end());
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define clr(x) memset(x, 0, sizeof(x))
using namespace std;
ll a[10004];
int main() {
  speed;
  ll n;
  cin >> n;
  rep(i, 1, 102) rep(j, 1, 102) rep(k, 1, 102) {
    ll x;
    x = i * i + j * j + k * k + j * k + k * i + j * i;
    if (x < 10004)
      a[x]++;
  }
  rep(i, 1, n + 1) { cout << a[i] << endl; }

  return 0;
}


Error: -11

Fixed submission:

#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define speed                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#pragma GCC optimize "trapv"
#define _GLIBCXX_DEBUG
#define ll long long int
#define ld long double
#define ull unsigned long long int // ranges from (0 - twice of long long int)
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define per(i, a, n) for (ll i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define MOD 1000000007LL
#define llpair pair<ll, ll>
#define INF 1000000000000000000ll // this is 1e18 long long
#define np next_permutation
#define PI acos(-1)
#define DEB(x) cout << #x << " " << x << endl;
#define rotate_left(vec, amt) rotate(vec.begin(), vec.begin() + amt, vec.end());
#define rotate_right(vec, amt)                                                 \\
  rotate(vec.begin(), vec.begin() + vec.size() - amt, vec.end());
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define clr(x) memset(x, 0, sizeof(x))
using namespace std;
ll a[10004];
int main() {
  speed;
  ll n;
  cin >> n;
  rep(i, 1, 102) rep(j, 1, 102) rep(k, 1, 102) {
    a[i * i + j * j + k * k + j * k + k * i + j * i]++;
  }
  rep(i, 1, n + 1) { cout << a[i] << endl; }

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

#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll long long
#define INF 10000000000000000LL
#define pll pair<long long, long long>
const int MAX = 1e7 + 9;
const ll MOD = 1e9 + 7;
const int TOT_PRIMES = 19;
const int MAX_A = 70;
using namespace std;
int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int cnt = 0;
  int arr[n + 1];
  memset(arr, 0, sizeof(arr));
  for (int i = 1; i <= sqrt(n); i++) {
    for (int j = 1; j <= sqrt(n); j++) {
      for (int k = 1; k <= sqrt(n); k++) {
        int now = (i * i) + (j * j) + (k * k) + (i * k) + (i * j) + (j * k);
        if (now > n)
          continue;
        arr[now] = arr[now] + 1;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << arr[i] << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll long long
#define INF 10000000000000000LL
#define pll pair<long long, long long>
const int MAX = 1e7 + 9;
const ll MOD = 1e9 + 7;
const int TOT_PRIMES = 19;
const int MAX_A = 70;
using namespace std;
int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int cnt = 0;
  int arr[n + 1];
  memset(arr, 0, sizeof(arr));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        int now = (i * i) + (j * j) + (k * k) + (i * k) + (i * j) + (j * k);
        if (now > n)
          continue;
        arr[now] = arr[now] + 1;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << arr[i] << endl;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded



#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string.h>
#include <vector>
using namespace std;
const int N = 105;
int arr[N];

int main() {
  int number;
  cin >> number;
  int x, y, z;
  int count = 0;
  for (int i = 1; i <= number; i++) {
    count = 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 + x * z + y * z > i)
            break;
          if ((x * x + y * y + z * z + x * y + x * z + y * z) == i)
            count++;
        }
      }
    }
    cout << count << endl;
  }
}


Error: TLE

Fixed submission:



#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string.h>
#include <vector>
using namespace std;
const int N = 105;
int arr[N];

int main() {
  int number;
  cin >> number;
  int x, y, z;
  int count = 0;
  for (int i = 1; i <= number; i++) {
    count = 0;
    for (x = 1; x <= i; x++) {
      for (y = 1; y <= i; y++) {
        for (z = 1; z <= i; z++) {
          if ((x * x + y * y + z * z + x * y + x * z + y * z) == i)
            count++;
        }
      }
    }
    cout << count << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
int dp[10005] = {0};
int main() {
  int n;
  cin >> n;

  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 num = i * i + j * j + k * k + i * j + j * k + k * i;
        if (num <= n) {
          dp[num]++;
        }
      }
    }
  for (int i = 1; i <= n; i++) {
    cout << dp[i] << endl;
  }
  return 0;
}


Error: WA

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
int dp[1005] = {0};
int main() {
  int n;
  cin >> n;

  for (int i = 1; i * i <= n; i++)
    for (int j = 1; j * j + i * i <= n; ++j) {
      for (int k = 1; k * k <= n; ++k) {
        int num = i * i + j * j + k * k + i * j + j * k + k * i;
        if (num <= n) {
          dp[num]++;
        }
      }
    }
  for (int i = 0; i <= n; i++) {
    cout << dp[i] << endl;
  }
  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++)
using ll = long long;
using P = pair<string, int>;
const double PI = acos(-1);
int main() {
  int n;
  cin >> n;
  map<int, int> mp;
  for (int x = 1; x <= pow(10, 2); x++)
    for (int y = 1; y <= pow(10, 2); y++)
      for (int z = 1; z <= pow(10, 2); z++) {
        int A = x * x + y * y + z * z + x * y + y * z + z * x;
        if (A <= n)
          mp[A]++;
      }
  for (int i = 1; i <= n; i++) {
    cout << mp[i] << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string, int>;
const double PI = acos(-1);
ll f(int n) {
  int cnt = 0;
  for (int x = 1; x <= pow(10, 2); x++)
    for (int y = 1; y <= pow(10, 2); y++)
      for (int z = 1; z <= pow(10, 2); z++) {
        if (x * x + y * y + z * z + x * y + y * z + z * x == n)
          cnt++;
      }

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

#include <bits/stdc++.h>
#define all(X) (X).begin(), (X).end()
#define rall(X) (X).rbegin(), (X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)
#define CASET                                                                  \\
  int ___T;                                                                    \\
  scanf("%d", &___T);                                                          \\
  for (int cs = 1; cs <= ___T; cs++)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

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

  vi ans(n, 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 calc = (x * x + y * y + z * z + x * y + y * z + z * x);
        if (calc <= n)
          ans[calc]++;
      }
    }
  }

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

int main() {
#define MULTITEST 0
#if MULTITEST

  CASET { solve(); }

#else

  solve();

#endif

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define all(X) (X).begin(), (X).end()
#define rall(X) (X).rbegin(), (X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)
#define CASET                                                                  \\
  int ___T;                                                                    \\
  scanf("%d", &___T);                                                          \\
  for (int cs = 1; cs <= ___T; cs++)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
  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;
  }
}

int main() {
#define MULTITEST 0
#if MULTITEST

  CASET { solve(); }

#else

  solve();

#endif

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

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, m, n) for (ll i = m; i < (ll)(n); i++)
#define rrep(i, n, m) for (ll i = n; i >= (ll)(m); i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

vector<ll> divisor(ll N) {
  vector<ll> res;
  for (ll i = 1L; i * i <= N; ++i) {
    if (N % i == 0) {
      res.push_back(i);
      ll j = N / i;
      if (j != i) {
        res.push_back(j);
      }
    }
  }
  sort(res.begin(), res.end());
  return res;
}

void solve() {
  ll N;
  cin >> N;
  vector<ll> ans(N + 1, 0);
  for (ll x = 1; x * x <= N; x++) {
    for (ll y = 1; y * y <= N; y++) {
      for (ll z = 1; z * z <= N; z++) {
        ll v = x * x + y * y + z * z + x * y + y * z + x * z;
        if (v <= N) {
          ans[v]++;
        }
      }
    }
  }
  rep(i, N) { cout << ans[i + 1] << '\\n'; }
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  solve();
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, m, n) for (ll i = m; i < (ll)(n); i++)
#define rrep(i, n, m) for (ll i = n; i >= (ll)(m); i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

vector<ll> divisor(ll N) {
  vector<ll> res;
  for (ll i = 1L; i * i <= N; ++i) {
    if (N % i == 0) {
      res.push_back(i);
      ll j = N / i;
      if (j != i) {
        res.push_back(j);
      }
    }
  }
  sort(res.begin(), res.end());
  return res;
}

void solve() {
  ll N;
  cin >> N;
  vector<ll> ans;
  rep(i, N) {
    ll t = i + 1;
    ll cnt = 0;
    for (ll x = 1; x * x <= t; x++) {
      ll r = t - x * x;
      for (ll y = 1; y * y <= r; y++) {
        ll r2 = r - y * y - x * y;
        if (r2 <= 0)
          break;
        auto D = divisor(r2);
        for (ll d : D) {
          if (d * (d + x + y) == r2) {
            //                        print(x, y, t);
            //                        print(d, (d + x + y), r2);
            cnt++;
          }
        }
      }
    }
    ans.push_back(cnt);
  }
  rep(i, N) { cout << ans[i] << '\\n'; }
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  solve();
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

vector<int> map(10000);
int solve(int n) {
  int res = 0;
  for (int i = 1; i * (i + 2) <= n; i++) {
    for (int j = 1; j * (j + 2) <= n; j++) {
      int s = i + j;
      int t = n - i * i - j * j - i * j;
      for (int k = 1; k * (k + s) <= t; k++) {
        if (k * (k + s) == t) {
          res++;
        }
      }
    }
  }
  return res;
}

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

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

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int solve(int n) {
  int res = 0;
  for (int i = 1; i * (i + 2) <= n; i++) {
    for (int j = 1; j * (j + 2) <= n; j++) {
      for (int k = 1; k * (k + 2) <= n; k++) {
        if (i * i + j * j + k * k + i * j + j * k + k * i == n) {
          res++;
        }
      }
    }
  }
  return res;
}

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

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

  return 0;
}