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

#include <bits/stdc++.h>
#define ll long long
#define MAX 100000
#define INF 1000000
#define M 1000000007
#define fast_io                                                                \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
using namespace std;
int main() {
  fast_io ll n;
  cin >> n;
  map<ll, ll> mp;
  for (ll x = 1; x <= 100; x++) {
    for (ll y = 1; y <= 100; y++) {
      for (ll z = 1; z <= 100; z++) {
        ll r = pow(x, 2) + pow(y, 2) + pow(z, 2) + (x * y) + (y * z) + (z * x);
        mp[r]++;
      }
    }
  }
  for (ll i = 1; i <= n; i++) {
    cout << mp[i] << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define MAX 100000
#define INF 1000000
#define M 1000000007
#define fast_io                                                                \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
using namespace std;
int main() {
  fast_io ll n;
  cin >> n;
  map<ll, ll> mp;
  for (ll x = 1; x <= n; x++) {
    for (ll y = 1; y <= n; y++) {
      for (ll z = 1; z <= n; z++) {
        ll r = pow(x, 2) + pow(y, 2) + pow(z, 2) + (x * y) + (y * z) + (z * x);
        mp[r]++;
      }
    }
  }
  for (ll i = 1; i <= n; i++) {
    cout << mp[i] << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main(void) {
  int n;
  int cnts[100001] = {0};

  cin >> 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++) {
        int calc = x * x + y * y + z * z + x * y + y * z + z * x;
        if (calc <= 100000) {
          cnts[calc] += 1;
        }
      }
    }
  }

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

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main(void) {
  int n;

  cin >> n;

  for (int i = 1; i <= n; i++) {
    int cnt = 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++) {
          int calc = x * x + y * y + z * z + x * y + y * z + z * x;
          if (calc == i) {
            cnt += 1;
          }
        }
      }
    }

    cout << cnt << endl;
  }

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define fi first
#define se second
#define pi pair<ll, ll>
#define pii pair<ll, pi>
#define pb push_back
#define mk make_pair
int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin >> n;
  vector<int> v(10007, 0);
  for (ll j = 1; j * j <= n; j++) {
    for (ll k = 1; k * k <= n; k++) {
      for (ll r = 1; r * r <= n; r++) {
        if (j * j + k * k + r * r + j * k + k * r + r * j <= n) {
          v[j * j + k * k + r * r + j * k + k * r + r * j]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << v[i] << endl;
  }
  cout << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define fi first
#define se second
#define pi pair<ll, ll>
#define pii pair<ll, pi>
#define pb push_back
#define mk make_pair
int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin >> n;
  for (ll i = 1; i <= n; i++) {
    int ans = 0;
    for (ll j = 1; j * j <= i; j++) {
      for (ll k = 1; k * k <= i; k++) {
        for (ll r = 1; r * r <= i; r++) {
          if (j * j + k * k + r * r + j * k + k * r + r * j == i)
            ans++;
        }
      }
    }
    cout << ans << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

/*
 Sarthak Jain
*/
#include <bits/stdc++.h>
using namespace std;
#define endl "\\n"
#define int long long
int mod = 1e9 + 7;
int min(int a, int b) { return (a < b) ? a : b; }
int max(int a, int b) { return (a > b) ? a : b; }
int fp(int a, int b) {
  if (b == 0)
    return 1;
  int x = fp(a, b / 2);
  x = (x * x) % mod;
  if (b & 1)
    x = (x * a) % mod;
  return x;
}
const int N = 10005;
int f[N] = {0};

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  for (int i = 1; i * i < N; i++) {
    for (int j = 1; j < N && (i * i + j * j) < N; j++) {
      for (int k = 1; k < N && k < N; k++) {
        int x = i * i + j * j + k * k + i * j + j * k + k * i;
        if (x >= N)
          break;
        f[x]++;
      }
    }
  }

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

Error: 0

Fixed submission:

/*
 Sarthak Jain
*/
#include <bits/stdc++.h>
using namespace std;
#define endl "\\n"
#define int long long
int mod = 1e9 + 7;
int min(int a, int b) { return (a < b) ? a : b; }
int max(int a, int b) { return (a > b) ? a : b; }
int fp(int a, int b) {
  if (b == 0)
    return 1;
  int x = fp(a, b / 2);
  x = (x * x) % mod;
  if (b & 1)
    x = (x * a) % mod;
  return x;
}
const int N = 1005;
int f[N] = {0};

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  for (int i = 1; i < N; i++) {
    for (int j = 1; j < N; j++) {
      for (int k = 1; k < N; k++) {
        int x = i * i + j * j + k * k + i * j + j * k + k * i;
        if (x >= N)
          break;
        f[x]++;
      }
    }
  }

  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>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using pint = pair<int, int>;

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

  vector<int> ans(n + 1, 0);
  for (int x = 1; x <= sqrt(n); ++x) {
    int x2 = x * x;
    for (int y = 1; y <= sqrt(n); ++y) {
      int y2 = y * y;
      for (int z = 1; z <= sqrt(n); ++z) {
        if (x2 + y2 + z * z + x * y + y * z + z * x <= n)
          ans[x2 + y2 + z * z + x * y + y * z + z * x]++;
      }
    }
  }
  for (int i = 1; i <= n; ++i)
    cout << ans[i] << endl;
}

Error: 0

Fixed submission:

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

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

  vector<int> ans(n + 1, 0);
  for (int x = 1; x <= sqrt(n); ++x) {
    int x2 = x * x;
    for (int y = 1; y <= sqrt(n); ++y) {
      int y2 = y * y;
      for (int z = 1; z <= sqrt(n); ++z) {
        ans[x2 + y2 + z * z + x * y + y * z + z * x]++;
      }
    }
  }
  for (int i = 1; i <= n; ++i)
    cout << ans[i] << endl;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

int main() {
  ll N;
  cin >> N;
  for (ll n = 1; n <= N; ++n) {
    // cerr << ":" << n << ":" << endl;
    ll ans = 0;
    for (ll i = 1;; ++i) {
      bool jf = true;
      for (ll j = 1;; ++j) {
        bool kf = true;
        for (ll k = 1;; ++k) {
          if (f(i, j, k) < n) {
            jf = false;
            kf = false;
          } else if (f(i, j, k) == n) {
            ++ans;
            // cerr << i << " " << j << " " << k << endl;
          } else
            break;
        }
        if (kf)
          break;
      }
      if (jf)
        break;
    }
    cout << ans << endl;
  }
}


Error: TLE

Fixed submission:

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

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

int main() {
  ll N;
  cin >> N;
  for (ll n = 1; n <= N; ++n) {
    cerr << ":" << n << ":" << endl;
    ll ans = 0;
    for (ll i = 1;; ++i) {
      bool jf = true;
      for (ll j = 1;; ++j) {
        bool kf = true;
        for (ll k = 1;; ++k) {
          if (f(i, j, k) < n) {
            jf = false;
            kf = false;
          } else if (f(i, j, k) == n) {
            ++ans;
            cerr << i << " " << j << " " << k << endl;
          } else
            break;
        }
        if (kf)
          break;
      }
      if (jf)
        break;
    }
    cout << ans << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

#define eval() (x * x + y * y + z * z + x * y + y * z + z * x)

static large count(large n) {
  auto cnt = 0LL;
  for (auto x = 1LL; x <= 100; ++x) {
    for (auto y = 1LL; y <= 100; ++y) {
      auto m = x * x + y * y + x * y;
      if (m >= n)
        break;

      for (auto z = 1LL; z <= 100; ++z) {
        auto k = eval();
        if (k >= n) {
          cnt += (k == n);
          break;
        }
      }
    }
  }
  return cnt;
}

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

  auto a = string{};
  for (auto k = 1; k <= n; ++k) {
    a += to_string(count(k)) + "\\n";
  }

  cout << a;
  return 0;
}


Error: TLE

Fixed submission:

#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

#define eval() (x * x + y * y + z * z + x * y + y * z + z * x)

static large count(large n) {
  auto cnt = 0LL;
  for (auto x = 1LL; x <= 100; ++x) {
    for (auto y = 1LL; y <= 100; ++y) {
      for (auto z = 1LL; z <= 100; ++z) {
        if (eval() == n)
          ++cnt;
      }
    }
  }
  return cnt;
}

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

  auto a = string{};
  for (auto k = 1; k <= n; ++k) {
    a += to_string(count(k)) + "\\n";
  }

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

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> f(1000000);
  for (int x = 1; x <= 100; ++x) {
    for (int y = 1; y <= 100; ++y) {
      for (int z = 1; z <= 100; ++z) {
        f[x * x + y * y + z * z + x * y + y * z + z * x]++;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    cout << f[i] << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

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

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

int n;

int binary_search(int l, int r, int v) {
  while (r - l > 1) {
    int mid = l + (r - l) / 2;
    if (mid * mid >= v) {
      r = mid;
    } else {
      l = mid;
    }
  }
  return r;
}

int main(void) {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int res = 0;
    for (int u = 2; u * u <= 2 * i; u++) {
      for (int v = 2; v * v <= 2 * i; v++) {
        if (2 * i - u * u - v * v <= 0)
          continue;
        int w = binary_search(0, 2 * i - u * u - v * v, 2 * i - u * u - v * v);
        if (u * u + v * v + w * w != 2 * i)
          continue;
        int a, b, c;
        a = u - v + w;
        b = u + v - w;
        c = -u + v + w;
        if (a < 1 || b < 1 || c < 1)
          continue;
        if (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
          res++;
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

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

int n;

int main(void) {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int res = 0;
    for (int u = 2; u * u <= 2 * i; u++) {
      for (int v = 2; v * v <= 2 * i; v++) {
        for (int w = 2; w * w <= 2 * i; w++) {
          int f = u * u + v * v + w * w;
          int a, b, c;
          a = u - v + w;
          b = u + v - w;
          c = -u + v + w;
          if (a < 1 || b < 1 || c < 1)
            continue;
          if (f == 2 * i && a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
            res++;
          }
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll, ll> pll;
const ll mod = 1e9 + 7;
// const ll mod=998244353;
const ll inf = 1LL << 61;

int main() {
  ll n;
  cin >> n;
  for (ll i = 1; i <= n; i++) {
    ll ans = 0;
    for (ll j = 1; 6 * j * j <= i; j++) {
      for (ll k = j; j * j + k * k + 2 * j * k + 2 * k * k <= i; k++) {
        for (ll l = k; j * j + k * k + l * l + j * k + k * l + l * j <= i;
             l++) {
          if (j * j + k * k + l * l + j * k + k * l + l * j == i) {
            if (j == l)
              ans++;
            else if (j == k || k == l) {
              ans += 3;
            } else {
              ans += 6;
            }
          }
        }
      }
    }
    cout << ans << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll, ll> pll;
const ll mod = 1e9 + 7;
// const ll mod=998244353;
const ll inf = 1LL << 61;

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

#define IO                                                                     \\
  ios::sync_with_stdio(false);                                                 \\
  cin.tie();                                                                   \\
  cout.tie(0)
#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
typedef long long ll;
const int N = 10010;
const double eps = 1e-6;
int n, f[N];
double calc1(int x, int y, int n) {
  double delta = (x + y) * (x + y) - 4 * (x * x + y * y + x * y - n);
  if ((x + y) * (x + y) <= 4 * (x * x + y * y + x * y - n))
    return -1;
  return (sqrt(delta) - (x + y)) / 2.0;
}
int calc2(int x, int y, int n) {
  int delta = (x + y) * (x + y) - 4 * (x * x + y * y + x * y - n);
  if (delta <= 0)
    return -2;
  return (sqrt(delta) - (x + y)) / 2;
}
int main() {
  IO;
  cin >> n;
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= k / i; i++)
      for (int j = 1; j <= k / j; j++) {
        double x = calc1(i, j, k);
        int y = calc2(i, j, k);
        if (x < eps)
          continue;
        if (abs(x - y) < eps)
          f[k]++;
      }
  for (int i = 1; i <= n; i++)
    cout << f[i] << endl;
  return 0;
}

Error: TLE

Fixed submission:

#define IO                                                                     \\
  ios::sync_with_stdio(false);                                                 \\
  cin.tie();                                                                   \\
  cout.tie(0)
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
const int N = 10010;
int n, f[N];
int main() {
  IO;
  cin >> n;
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= k / i; i++)
      for (int j = 1; j <= k / j; j++)
        for (int l = 1; l <= k / l; l++) {
          int x = i * i + j * j + l * l + i * l + i * j + l * j;
          if (x == k)
            f[k]++;
        }
  for (int i = 1; i <= n; i++)
    cout << f[i] << endl;
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <math.h>

int main() {
  int n;
  std::cin >> n;
  int a[100000];
  int end = sqrt(n);

  for (int x = 1; x < end; x++) {
    for (int y = 1; y <= x; y++) {
      if (x * x + y * y + x * y + x + y + 1 <= n) {
        for (int z = 1; z <= y; z++) {
          int result = x * x + y * y + z * z + x * y + y * z + z * x - 1;
          if (x == y || y == z || z == x) {
            if (x == y && y == z) {
              a[result] += 1;
            } else {
              a[result] += 3;
            }
          } else {
            a[result] += 6;
          }
        }
      }
    }
  }

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

  return 0;
}


Error: 0

Fixed submission:

#include <iostream>
#include <math.h>

int main() {
  int n;
  std::cin >> n;
  int a[10000];
  int end = sqrt(n);

  for (int x = 1; x < end; x++) {
    for (int y = 1; y < end; y++) {
      for (int z = 1; z < end; z++) {
        int result = x * x + y * y + z * z + x * y + y * z + z * x - 1;
        a[result]++;
      }
    }
  }

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

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

#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i{0}; i < n; ++i)
#define rep1(i, n) for (int i{1}; i <= n; ++i)

using namespace std;

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

  vector<int> ans(N);
  rep1(i_x, sqrt(N - 1)) rep1(i_y, sqrt(N - 1)) rep1(i_z, sqrt(N - 1)) {
    n = i_x * i_x + i_y * i_y + i_z * i_z + i_x * i_y + i_y * i_z + i_z * i_x;
    if (n <= N)
      ans.at(n - 1)++;
  }

  for (const auto &a : ans)
    cout << a << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i{0}; i < n; ++i)
#define rep1(i, n) for (int i{1}; i <= n; ++i)

using namespace std;

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

  rep1(i, N) {
    int cnt{0};
    int n;
    rep1(i_x, sqrt(N - 1)) rep1(i_y, sqrt(N - 1)) rep1(i_z, sqrt(N - 1)) {
      n = i_x * i_x + i_y * i_y + i_z * i_z + i_x * i_y + i_y * i_z + i_z * i_x;
      if (n == i) {
        cnt++;
      }
    }
    cout << cnt << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

  int n;
  cin >> n;

  vector<int> cnt(n + 10, 0);
  for (int x = 1; x <= 110; ++x) {
    for (int y = 1; y <= 110; ++y) {
      for (int z = 1; z <= 110; ++z) {
        int s = x * x + y * y + z * z + x * y + y * z + z * x;
        if (s <= n) {
          cnt[s]++;
        }
      }
    }
  }

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

Error: -11

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

  int n;
  cin >> n;

  vector<int> cnt(n + 10, 0);
  for (int x = 1; x <= 110; ++x) {
    for (int y = 1; y <= 110; ++y) {
      for (int z = 1; z <= 110; ++z) {
        int s = x * x + y * y + z * z + x * y + y * z + z * x;
        cnt[s]++;
      }
    }
  }

  for (int i = 1; i <= n; ++i) {
    cout << cnt[i] << 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;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

  ll n;
  cin >> n;

  for (ll i = 1; i <= n; ++i) {
    ll sum = 0;

    for (ll x = 1; x * x <= i; ++x) {
      for (ll y = x; x * x + y * y <= i; ++y) {
        for (ll z = y; x * x + y * y + z * z <= i; ++z) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            set<ll> se;
            se.insert(x);
            se.insert(y);
            se.insert(z);

            if (se.size() == 1) {
              sum += 1;
            } else if (se.size() == 2) {
              sum += 3;
            } else {
              sum += 6;
            }
          }
        }
      }
    }

    cout << sum << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

vector<ll> calc_divisor(ll n) {
  vector<ll> res;

  for (ll i = 1; 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;
}

int main() {

  ll n;
  cin >> n;

  for (ll i = 1; i <= n; ++i) {
    ll sum = 0;

    for (ll x = 1; x * x <= i; ++x) {
      for (ll y = x; y * y <= i; ++y) {
        ll t = i - x * x - y * y - x * y;
        ll s = x + y;

        if (t <= 0)
          break;
        if (s > t)
          break;
        auto divisor = calc_divisor(t);

        for (auto d : divisor) {
          if (d * (d + s) > t)
            break;

          if (d * (d + s) == t) {
            if (y <= d) {
              set<int> se;
              se.insert(x);
              se.insert(y);
              se.insert(d);

              if (se.size() == 1) {
                sum++;
              } else if (se.size() == 2) {
                sum += 3;
              } else {
                sum += 6;
              }
            }
          }
        }
      }
    }

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

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

int main() {
  ll N;
  cin >> N;
  vector<ll> ans(N, 0);
  map<ll, ll> m;
  ll maxv = sqrt(N);

  for (int i = 1; i < maxv; ++i) {
    for (int j = 1; j < maxv; ++j) {
      for (int k = 1; k < maxv; ++k) {

        ll tmp = i * i + j * j + k * k + i * j + j * k + k * i;
        // cout << tmp << endl;
        if (tmp <= N) {
          m[tmp]++;
        }
      }
    }
  }
#if 1
  for (int i = 1; i <= N; ++i) {
    cout << m[i] << endl;
  }
#endif
}


Error: TLE

Fixed submission:

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

int main() {
  ll N;
  cin >> N;
  vector<ll> ans(N, 0);
  map<ll, ll> m;

  for (int i = 1; i < N; ++i) {
    for (int j = 1; j < N; ++j) {
      for (int k = 1; k < N; ++k) {

        ll tmp = i * i + j * j + k * k + i * j + j * k + k * i;
        // cout << tmp << endl;
        if (tmp <= N) {
          m[tmp]++;
        }
      }
    }
  }
#if 1
  for (int i = 1; i <= N; ++i) {
    cout << m[i] << endl;
  }
#endif
}