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

#include <bits/stdc++.h>

using namespace std;

typedef tuple<int, int, int> ti;

int main() {
  int n, x, y, z;

  cin >> n;

  int limit = sqrt(n);
  map<int, int> mp;
  for (x = 1; x <= limit; x++) {
    for (y = 1; y <= limit; y++) {
      for (z = 1; z <= limit; z++) {
        int p = x * x + y * y + z * z + x * y + y * z + z * x;
        mp[p]++;
      }
    }
  }

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

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, x, y, z;

  cin >> n;

  for (int i = 1; i <= n; i++) {
    int count = 0;

    for (x = 1; x < i / 2; x++) {
      for (y = 1; y < i / 2; y++) {
        for (z = 1; z < i / 2; z++) {
          if ((x * x + y * y + z * z + x * y + y * z + z * x) == i)
            count++;
          else if ((x * x + y * y + z * z + x * y + y * z + z * x) > n)
            break;
        }
      }
    }

    cout << count << endl;
  }

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

#include <cmath>
#include <iostream>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int pp = 0;
    int as = sqrt(i);
    for (int a = 1; a < as; a++) {
      for (int b = 1; b < as; b++) {
        double ji = (-1 * (a + b) + sqrt(1.0 * (a + b) * (a + b) -
                                         4.0 * (a * a + b * b + a * b - i))) /
                    2;
        double jii = (-1 * (a + b) - sqrt(1.0 * (a + b) * (a + b) -
                                          4.0 * (a * a + b * b + a * b - i))) /
                     2;
        if (ji - (int)ji == 0 && ji > 0 || jii - (int)jii == 0 && jii > 0) {
          pp++;
          // break;
        }
      }
    }
    cout << pp << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int pp = 0;
    int as = sqrt(i);
    for (int a = 1; a < as; a++) {
      for (int b = 1; b < as; b++) {
        for (int c = 1; c < as; c++) {
          if (a * a + b * b + c * c + a * b + a * c + b * c == i) {
            pp++;
            break;
          }
        }
      }
    }
    cout << pp << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iostream>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_set>

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; ++i)

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
  seen[v] = true; // v を訪問済にする

  // v から行ける各頂点 next_v について
  for (auto next_v : G[v]) {
    if (seen[next_v])
      continue;     // next_v が探索済だったらスルー
    dfs(G, next_v); // 再帰的に探索
  }
}

bool IsPrime(int num) {
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false; // 偶数はあらかじめ除く

  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0) {
      // 素数ではない
      return false;
    }
  }

  // 素数である
  return true;
}

int main() {
  ll N;
  cin >> N;
  ll a[60010] = {};

  FOR(x, 1, 100) {
    FOR(y, 1, 100) {
      FOR(z, 1, 100) { a[x * x + y * y + z * z + x * y + y * z + z * x]++; }
    }
  }

  FOR(i, 1, N + 1) { cout << a[i] << endl; }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_set>

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; ++i)

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
  seen[v] = true; // v を訪問済にする

  // v から行ける各頂点 next_v について
  for (auto next_v : G[v]) {
    if (seen[next_v])
      continue;     // next_v が探索済だったらスルー
    dfs(G, next_v); // 再帰的に探索
  }
}

bool IsPrime(int num) {
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false; // 偶数はあらかじめ除く

  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0) {
      // 素数ではない
      return false;
    }
  }

  // 素数である
  return true;
}

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

  ll cnt;
  FOR(i, 1, N + 1) {
    cnt = 0;
    FOR(x, 1, 100) {
      FOR(y, 1, 100) {
        FOR(z, 1, 100) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i)
            cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
}
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;
using P = pair<int, int>;

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

  vector<int> ans(n + 1);
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int s = x * x + y * y + z * z + x * y + y * z + z * x;
        if (s > n)
          continue;
        ans[s]++;
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    cout << ans[i] << 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;
using P = pair<int, int>;

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

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= min(n, 5); i++) {
    cout << 0 << "\\n";
  }
  for (int p = 6; p <= n; p++) {
    int y = 1;
    int z = sqrt(p) - 1;
    int sum = 0;
    int l = sqrt(p / 6);
    for (int i = y; i <= l; i++) {
      for (int j = i; j <= z; j++) {
        for (int k = j; k <= z; k++) {
          if (i * i + j * j + k * k + i * j + i * k + j * k == p) {
            if (i == j && j == k) {
              sum += 1;
            }
            if ((i == j && j != k) || (j == k && i != k) ||
                (i == k && i != j)) {
              sum += 3;
            }
            if (i != j && j != k && i != k) {
              sum += 6;
            }
          }
        }
      }
    }

    cout << sum << "\\n";
  }
}


Error: TLE

Fixed submission:

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= min(n, 5); i++) {
    cout << 0 << "\\n";
  }
  for (int p = 6; p <= n; p++) {
    int y = 1;
    int z = sqrt(p) - 1;
    int sum = 0;
    for (int i = y; i <= z; i++) {
      for (int j = y; j <= z; j++) {
        for (int k = y; k <= z; k++) {
          if (i * i + j * j + k * k + i * j + i * k + j * k == p) {
            if (i == j && j == k) {
              sum += 1;
            }
            if ((i == j && j != k) || (j == k && i != k) ||
                (i == k && i != j)) {
              sum += 3;
            }
            if (i != j && j != k && i != k) {
              sum += 6;
            }

            i = max({i, j, k}) + 1;
            j = i;
            k = i;
          }
        }
      }
    }

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

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

int main() {
  int n;
  std::cin >> n;
  std::vector<int> a(n + 1, 0);
  for (int x = 1; x < 100; x++) {
    for (int y = 1; y < 100; y++) {
      for (int z = 1; z < 100; z++) {
        int value = x * x + y * y + z * z + x * y + y * z + z * x;
        if (value <= n)
          ++a[value];
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    std::cout << a[i] << '\\n';
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int n;
  std::cin >> n;
  std::vector<int> a(n + 1, 0);
  for (int x = 1; x < n / 2; x++) {
    for (int y = 1; y < n / 2; y++) {
      for (int z = 1; z < n / 2; z++) {
        int value = x * x + y * y + z * z + x * y + y * z + z * x;
        if (value <= n)
          ++a[value];
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    std::cout << a[i] << '\\n';
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  ll N;
  cin >> N;
  ll n = 100;
  vector<int> counter(10001);
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      for (int k = j; k < n; k++) {
        int x = i + 1, y = j + 1, z = k + 1;
        // cout << x << "," << y << "," << z << " ";
        ll num = x * x + y * y + z * z + x * y + y * z + z * x;
        if (num <= 10000) {
          int plus;
          if (i == j && j == k) {
            plus = 1;
          } else if (i == j or j == k) {
            plus = 3;
          } else {
            plus = 6;
          }
          counter.at(num) += plus;
        }
        // cout << num << endl;
      }
    }
  }

  rep(i, N) { cout << counter.at(i + 1) << endl; }

  return 0;
}


Error: 0

Fixed submission:

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

int main() {
  ll N;
  cin >> N;
  ll n = 31;
  vector<int> counter(1001);
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      for (int k = j; k < n; k++) {
        int x = i + 1, y = j + 1, z = k + 1;
        // cout << x << "," << y << "," << z << " ";
        ll num = x * x + y * y + z * z + x * y + y * z + z * x;
        if (num <= 1000) {
          int plus;
          if (i == j && j == k) {
            plus = 1;
          } else if (i == j or j == k) {
            plus = 3;
          } else {
            plus = 6;
          }
          counter.at(num) += plus;
        }
        // cout << num << endl;
      }
    }
  }
  rep(i, N) { cout << counter.at(i + 1) << endl; }

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

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = int(a); i < (int)b; ++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll, ll>>
#define pb push_back

using namespace std;
using ll = long long;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(void) {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> ans(n);
  for (int k = 1; k <= n; k++) {

    for (int i = 2; i * i < 2 * k; i++) {
      int les = 2 * k - i * i;
      if (les % 4 == 3)
        continue;
      for (int j = 2; j * j < les; j++) {
        int les2 = les - j * j;
        double r = sqrt(les2);
        int intr = int(r);
        if (intr * intr == les2) {
          if (i + j - r > 1 && i + r - j > 1 && j + r - i > 1)
            ans[k - 1]++;
        }
      }
    }
    cout << ans[k - 1] << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = int(a); i < (int)b; ++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll, ll>>
#define pb push_back

using namespace std;
using ll = long long;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(void) {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> ans(n);
  for (int k = 1; k <= n; k++) {
    for (int i = 2; i * i <= 2 * k; i++) {
      int les = 2 * k - i * i;
      for (int j = 2; j * j < les; j++) {
        int les2 = les - j * j;
        for (int t = 2; t * t <= les2; t++) {
          if (t * t == les2) {
            if (i + j - t > 0 && i + t - j > 0 && j + t - i > 0)
              ans[k - 1]++;
          }
        }
      }
    }
  }
  rep(i, n) cout << ans[i] << endl;

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

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

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

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


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

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

  for (int n = 1; n <= N; n++) {
    int ans = 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)
            ++ans;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
// Begin Header {{{
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 < n; i++)
#define loop(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const long double PI = acos(-1);
// }}} End Header
int main() {
  ll n;
  cin >> n;
  vector<ll> a(n + 1);
  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 cnt = x * x + y * y + z * z + x * y + y * z + z * x;
        if (cnt > n)
          continue;
        a[cnt]++;
      }
    }
  }
  loop(i, 1, n + 1) { cout << a[i] << endl; }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
// Begin Header {{{
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 < n; i++)
#define loop(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const long double PI = acos(-1);
// }}} End Header
int main() {
  ll n;
  cin >> n;
  vector<ll> a(n + 1);
  loop(x, 1, n) {
    loop(y, 1, n) {
      loop(z, 1, n) {
        ll cnt;
        cnt = x * x + y * y + z * z + x * y + y * z + z * x;
        if (cnt > n)
          continue;
        a[cnt]++;
      }
    }
  }
  loop(i, 1, n + 1) { cout << a[i] << endl; }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

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

  vector<int> ans(N + 1, 0);

  int mx = N;
  for (int x = 1; x <= mx; x++) {
    for (int y = x; y <= mx; y++) {
      for (int z = y; z <= mx; z++) {
        int a = match(x, y, z);
        if (a > N) {
          break;
        }
        if (x == y && y == z) {
          ans.at(a)++;
        } else if (x == y || y == z || x == z) {
          ans.at(a) += 3;
        } else {
          ans.at(a) += 6;
        }
      }
    }
  }

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

  return 0;
}


Error: TLE

Fixed submission:

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

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

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

  vector<int> ans(N + 1, 0);

  int mx = N / 6 + (N % 6 != 0 ? 1 : 0);
  for (int x = 1; x <= mx; x++) {
    for (int y = 1; y <= mx; y++) {
      for (int z = 1; z <= mx; z++) {
        int a = match(x, y, z);
        if (a > N) {
          continue;
        }
        ans.at(a)++;
      }
    }
  }

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

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

#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
using ll = long long;
using P = pair<ll, ll>;
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }

int main() {
  int n;
  cin >> n;
  vector<int> cnt(n * 10, 0);
  int limit = sqrt(n) + 1;
  for (int x = 1; x < limit; ++x) {
    for (int y = 1; y < limit; ++y) {
      for (int z = 1; z < limit; ++z) {
        int sum = pow(x, 2) + pow(y, 2) + pow(z, 2);
        sum += (x * y + y * z + z * x);
        cnt.at(sum)++;
      }
    }
  }

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

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
using ll = long long;
using P = pair<ll, ll>;
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }

ll n;

int main() {
  cin >> n;
  if (n < 6) {
    for (int i = 0; i < n; ++i) {
      cout << 0 << endl;
    }
    return 0;
  }

  for (int i = 1; i <= n; ++i) {
    if (i < 6) {
      cout << 0 << endl;
    } else if (i == 6) {
      cout << 1 << endl;
    } else {
      int cnt = 0;
      int limit = sqrt(i) + 1;
      for (int x = 1; x < limit; ++x) {
        for (int y = 1; y < limit; ++y) {
          int sum = pow(x, 2) + pow(y, 2) + x * y;
          if (i - sum <= 0)
            break;
          int check = i - sum;
          int xy = x + y;
          int zlimit = sqrt(check) + 1;
          for (int z = 1; z < zlimit; ++z) {
            if (check % z == 0) {
              if (check / z == (z + xy))
                cnt++;
            }
          }
        }
      }
      cout << cnt << endl;
    }
  }
}
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;

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

int count(int n) {
  int res = 0;
  for (int x = 1; x <= 100; x++) {
    for (int y = x; y <= 100; y++) {
      for (int z = y; z <= 100; z++) {
        if (f(x, y, z) == n) {
          if (x == y && y == z)
            res++;
          if (x != y && y != z && z != x)
            res += 6;
          if (x == y && y != z)
            res += 3;
          if (y == z && x != z)
            res += 3;
          if (x == z && x != y)
            res += 3;
        }
      }
    }
  }
  return res;
}

int main() {
  int N;
  cin >> N;
  for (int i = 1; i <= N; i++)
    cout << count(i) << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

using namespace std;
using ll = long long;

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

int count(int n) {
  int res = 0;
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        if (f(x, y, z) == n)
          res++;
      }
    }
  }
  return res;
}

int main() {
  int N;
  cin >> N;
  for (int i = 1; i <= N; i++)
    cout << count(i) << endl;
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <array>
#include <cmath>
#include <iostream>

using namespace std;
const int maxn = 10005;

void solve(const int &n) {
  std::array<int, maxn> res{};
  int nsq = floor(sqrt(n));
  for (int i = nsq; i >= 1; i--) {
    for (int j = nsq; j >= 1; j--) {
      for (int k = nsq; k >= 1; k--) {
        int s = pow(i, 2) + pow(j, 2) + pow(k, 2) + i * j + i * k + j * k;
        if (s < maxn)
          res[s] += 1;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << res[i] << endl;
  }
}

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

  return 0;
}

Error: 0

Fixed submission:

#include <array>
#include <cmath>
#include <iostream>

using namespace std;

void solve(const int &n) {
  std::array<int, 10005> res{};
  int nsq = floor(sqrt(n));
  for (int i = nsq; i >= 1; i--) {
    for (int j = nsq; j >= 1; j--) {
      for (int k = nsq; k >= 1; k--) {
        int s = pow(i, 2) + pow(j, 2) + pow(k, 2) + i * j + i * k + j * k;
        res[s] += 1;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << res[i] << endl;
  }
}

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

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

#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> 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 f = x * x + y * y + z * z + x * y + y * z + z * x;
        if (f <= n)
          ++ans[f - 1];
      }
    }
  }

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


Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>
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) {
      int x_ = i - x * x;
      for (int y = 1; y <= x_; ++y) {
        int y_ = x_ - y * y - x * y;
        for (int z = 1; z <= y_; ++z) {
          int z_ = y_ - z * z - x * z - y * z;
          if (z_ <= 0) {
            ans += z_ == 0;
            break;
          }
        }
      }
    }
    cout << ans << endl;
  }
}