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 s = 1; s <= n; s++) {
    int count = 0;
    for (int i = 1; i <= sqrt(s); i++) {
      for (int j = 1; j < sqrt(s); j++) {
        for (int k = 1; k < sqrt(s); k++) {
          if ((i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i) == s) {
            count++;
          } else if ((i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i) >
                     s) {
            break;
          }
        }
      }
    }
    cout << count << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  for (int s = 1; s <= n; s++) {
    int count = 0;
    for (int i = 1; i <= sqrt(s); i++) {
      for (int j = 1; j < sqrt(s); j++) {
        for (int k = 1; k < sqrt(s); k++) {
          if ((i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i) == s) {
            count++;
          }
        }
      }
    }
    cout << count << 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 INF 1e9;
using namespace std;
using ll = long long;
vector<int> x(10000);
int main() {
  int n, a = 0;
  cin >> n;
  for (int i = 1; i <= 99; i++) {
    for (int j = 1; j <= 99; ++j) {
      for (int k = 1; k <= 99; ++k) {
        if (i * i + j * j + k * k + i * j + i * k + j * k <= n) {
          x[i * i + j * j + k * k + i * j + i * k + j * k - 1]++;
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << x[i] << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
vector<int> x(10000);
int main() {
  int n, a = 0;
  cin >> n;
  if (n % 3 == 0) {
    a = n / 3;
  } else {
    a = n / 3 + 1;
  }
  int z = sqrt(a) + 1;
  for (int i = 1; i <= a; i++) {
    for (int j = 1; j <= a; ++j) {
      for (int k = 1; k <= a; ++k) {
        if (i * i + j * j + k * k + i * j + i * k + j * k <= n) {
          x[i * i + j * j + k * k + i * j + i * k + j * k - 1]++;
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << x[i] << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <vector>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> vect;
  int k = 3;
  int product = 1, j = 1, a, b, c, i = 1;
  while (product <= 10 * N) {
    product = j * j;
    vect.push_back(product);
    j++;
  }
  //	cout<<vect.size()<<"\\n";

  vector<int> vect1(N, 0);

  for (i = 0; i < vect.size(); i++) {
    for (a = 1; a <= i + 1; a++) {
      for (b = 1; b <= i + 1; b++) {
        c = i + 1 - (a + b);
        if (c > 0) {
          j = vect[i] - (a * b + b * c + c * a) - 1;
          if ((j < N) && (j > 0))
            vect1[j]++;
        }
      }
    }
  }
  for (i = 0; i < N; i++)
    cout << vect1[i] << "\\n";
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> vect;
  int k = 3;
  int product = 1, j = 1, a, b, c, i = 1;
  while (product <= ((N + 10) * (N + 10))) {
    product = j * j;
    vect.push_back(product);
    j++;
  }
  //	cout<<vect.size()<<"\\n";

  vector<int> vect1(N, 0);

  for (i = 0; i < vect.size(); i++) {
    for (a = 1; a <= i + 1; a++) {
      for (b = 1; b <= i + 1; b++) {
        c = i + 1 - (a + b);
        if (c > 0) {
          j = vect[i] - (a * b + b * c + c * a) - 1;
          if ((j < N) && (j > 0))
            vect1[j]++;
        }
      }
    }
  }
  for (i = 0; i < N; i++)
    cout << vect1[i] << "\\n";
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
struct iofix {
  ios_base::Init i;
  iofix() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.sync_with_stdio(0);
    cout.tie(0);
    cout.precision(10);
    cout << fixed;
  }
} iofix;
const int64_t M = 10008;
int64_t N;
std::vector<int64_t> v(M);
void solve() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      if (i * i + j * j + i * j >= N)
        continue;
      for (int k = 1; k <= N; k++) {
        if (i * i + j * j + k * k + i * j + i * k + j * k <= N)
          v[i * i + j * j + k * k + i * j + i * k + j * k]++;
      }
    }
  }
  for (int i = 1; i <= N; i++)
    cout << v[i] << "\\n";
}

int main() {
  solve();

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
struct iofix {
  ios_base::Init i;
  iofix() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.sync_with_stdio(0);
    cout.tie(0);
    cout.precision(10);
    cout << fixed;
  }
} iofix;
const int64_t M = 10008;
int64_t N;
std::vector<int64_t> v(M);
void solve() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      for (int k = 1; k <= N; k++) {
        v[i * i + j * j + k * k + i * j + i * k + j * k]++;
      }
    }
  }
  for (int i = 1; i <= N; i++)
    cout << v[i] << "\\n";
}

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

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long

const int MOD = 1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;

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

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

  return 0;
}


Error: TLE

Fixed submission:

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long

const int MOD = 1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;

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

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

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

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long double ld;
typedef long long ll;
const int MOD = 1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;

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

  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    for (int x = 1; x <= 100; x++) {
      for (int y = 1; y <= 100; y++) {
        for (int z = 1; z <= 100; z++) {
          int sum = x * x + y * y + z * z + x * y + y * z + z * x;
          if (sum > i)
            break;
          if (i == sum)
            cnt++;
        }
      }
    }
    cout << cnt << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long double ld;
typedef long long ll;
const int MOD = 1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;

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

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

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

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

typedef long long ll;

int A[40000] = {0};

int main() {
  int N;
  cin >> N;
  for (int i = 1; i < 110; ++i) {
    for (int j = 1; j < 110; ++j) {
      for (int k = 1; k < 110; ++k) {

        int temp = i * i + j * j + k * k + i * j + j * k + k * i;
        if (temp <= 10010) {
          ++A[temp];
        }
        // cout << temp << " " << i << j << k << endl;
      }
    }
  }
  for (int i = 1; i <= N; ++i) {
    cout << A[i] << endl;
  }
}


Error: -11

Fixed submission:

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

typedef long long ll;

int A[40000] = {0};

int main() {
  int N;
  cin >> N;
  for (int i = 1; i < 110; ++i) {
    for (int j = 1; j < 110; ++j) {
      for (int k = 1; k < 110; ++k) {

        int temp = i * i + j * j + k * k + i * j + j * k + k * i;
        ++A[temp];
        // cout << temp << " " << i << j << k << endl;
      }
    }
  }
  for (int i = 1; i <= N; ++i) {
    cout << A[i] << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

bool isprime(int n) {
  double rootn = sqrt(n);
  if (n < 2) {
    return false;
  } else if (n == 2) {
    return true;
  } else if (n % 2 == 0) {
    return false;
  } else {
    for (int i = 3; i <= rootn; i += 2) {
      if (n % i == 0) {
        return false;
      }
    }
    return true;
  }
}

int main() {
  int N;
  cin >> N;
  int c[N + 1] = {0};
  for (int x = 1; x <= sqrt(N); x++) {
    for (int y = 1; y <= sqrt(N) && x * x + y * y + 1 + x + y + x * y <= N;
         y++) {
      for (int z = 1;
           z <= sqrt(N) && x * x + y * y + z * z + x * y + y * z + x * z <= N;
           z++) {
        if (x * x + y * y + z * z + x * y + y * z + x * z <= N) {
          c[x * x + y * y + z * z + x * y + y * z + x * z]++;
        }
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    cout << c[i] << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

bool isprime(int n) {
  double rootn = sqrt(n);
  if (n < 2) {
    return false;
  } else if (n == 2) {
    return true;
  } else if (n % 2 == 0) {
    return false;
  } else {
    for (int i = 3; i <= rootn; i += 2) {
      if (n % i == 0) {
        return false;
      }
    }
    return true;
  }
}

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

#include <stdio.h>

int main(void) {
  long long x, y, z, N;
  long long tmp, count[10000];
  scanf("%lld", &N);
  for (int i = 0; i < N; i++)
    count[i] = 0;
  for (z = 1; z < 100; z++) {
    for (y = 1; y <= z; y++) {
      for (x = 1; x <= y; x++) {

        tmp = x * x + y * y + z * z + x * y + y * z + z * x;

        if (tmp <= N) {
          if (x == y && y == z) {
            count[tmp - 1]++;
          } else if (x == y || y == z || z == x) {
            count[tmp - 1] += 3;
          } else {
            count[tmp - 1] += 6;
          }
        }
      }
    }
  }

  for (int i = 0; i < N; i++) {
    printf("%lld\\n", count[i]);
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int flag = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n / 4; j++) {
      for (int k = 1; k <= n / 4; k++) {
        if (j * j + k * k + k * k + j * k + k * k + k * j == i) {
          if (j == 1 && k == 1) {
            printf("1\\n");
            flag = 1;
          } else {
            printf("3\\n");
            flag = 1;
          }
          break;
        }
      }
    }
    if (flag == 0)
      printf("0\\n");
    flag = 0;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A)) / (sizeof(A[0]))
#define odd(x) ((x) % (2))
#define fastio ios_base::sync_with_stdio(false), cin.tie(0);
#define fileio                                                                 \\
  freopen("template.in", "r", stdin), freopen("template.out", "w", stdout);
typedef long long ll;
const ll MOD = 1e9 + 7;

ll f(int x) {
  int max = sqrt(x);
  ll answer = 0;
  FOR(i, 1, max) {
    FOR(j, i, max) {
      FOR(k, j, max) {
        int number = i * i + j * j + k * k + i * j + j * k + i * k;
        if (number == x) {
          if (i != j && j != k && i != k) {
            answer += 6;
          } else if (i == j && j == k) {
            answer++;
          } else if (i == j || j == k || i == k) {
            answer += 3;
          }
        }
      }
    }
  }
  return answer;
}
int main() {
  fastio;
  // fileio;

  int n;
  cin >> n;
  FOR(i, 1, n + 1) { cout << f(i) << "\\n"; }
  return 0;
}


Error: TLE

Fixed submission:

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

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A)) / (sizeof(A[0]))
#define odd(x) ((x) % (2))
#define fastio ios_base::sync_with_stdio(false), cin.tie(0);
#define fileio                                                                 \\
  freopen("template.in", "r", stdin), freopen("template.out", "w", stdout);
typedef long long ll;
const ll MOD = 1e9 + 7;

int f(int x) {
  int max = sqrt(x);
  ll answer = 0;
  FOR(i, 1, max) {
    FOR(j, 1, max) {
      FOR(k, 1, max) {
        int number = i * i + j * j + k * k + i * j + j * k + i * k;
        if (number == x) {
          answer++;
        }
      }
    }
  }
  return answer;
}
int main() {
  fastio;
  // fileio;

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

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

typedef long long ll;
#define rep(i, x) for (int i = 0; i < x; i++)
#define put(ans) cout << ans << endl;

int main() {
  map<ll, int> mp;

  int ans(0);
  for (int i = 1; i < 101; i++) {
    for (int j = 1; j < 101; j++) {
      for (int k = 1; k < 101; k++) {
        mp[i * i + j * j + k * k + i * j + j * k + k * i]++;
      }
    }
  }

  int n;
  cin >> n;
  rep(i, n) { cout << mp[i + 1] << endl; }

  return 0;
}

Error: TLE

Fixed submission:

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

typedef long long ll;
#define rep(i, x) for (int i = 0; i < x; i++)
#define put(ans) cout << ans << endl;

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

  int ans(0);
  bool c(true);
  for (int t = 1; t <= n; t++) {
    for (int i = 1; i < 100; i++) {
      for (int j = 1; j < 100; j++) {
        for (int k = j; k < 100; k++) {
          if ((1 + k) * (1 + j) + j * j + k * k == t) {
            if (1 == j && j == k)
              ans += 1;
            else
              ans += 3;

            c = false;
            break;
          }
        }
        if (!c)
          break;
      }
      if (!c)
        break;
    }
    cout << ans << endl;
    c = true;
    ans = 0;
  }

  return 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++)
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define INF (1 << 30) - 1
using ll = long long;
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
/*
int main(){
  int n; cin >> n;
  for(int i = 1; i <= n; i++){
    int ans = 0;
    for(int x = 1; x <= sqrt(n); x++){
      for(int y = 1; y <= sqrt(n); y++){
        double d = (x+y)*(x+y)-4*(x*x+y*y+x*y-i);
        if(0 <= d){
          if(1 <= (-(x+y)+sqrt(d)/2.0)){
            if(-(x+y)+sqrt(d)/2.0 == floor(-(x+y)+sqrt(d)/2.0)) ans++;
          }
          if(1 <= (-(x+y)-sqrt(d)/2.0)){
            if(-(x+y)-sqrt(d)/2.0 == floor(-(x+y)-sqrt(d)/2.0)) ans++;
          }
        }
      }
    }
    cout << ans << "\\n";
  }
  return 0;
}
*/
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int x = 1; x <= sqrt(n); x++) {
      for (int y = 1; y <= sqrt(n); 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 << "\\n";
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define INF (1 << 30) - 1
using ll = long long;
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    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 + z * x == i)
            ans++;
        }
      }
    }
    cout << ans << "\\n";
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

/*Author - sambhu show(jgec) */
#include <bits/stdc++.h>
using namespace std;
#define fio                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define itc                                                                    \\
  ll t;                                                                        \\
  cin >> t;                                                                    \\
  while (t--)
#define PI 3.141592653589793238
// ang=(PI*ang)/180.0 in radian
#define Max(a, b, c) max(a, max(b, c));
#define Min(a, b, c) min(a, min(b, c));
#define all(v) v.begin(), v.end()
#define ll long long int
#define ld long double
#define pb push_back
#define eb emplace_back
#define gcd(a, b) __gcd(a, b)
#define fi first
#define se second
#define endl "\\n"
int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};
int XX[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int YY[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
int solve(int num) {
  int c = 0;
  for (int i = 1; i <= sqrt(num); i++) {
    for (int j = 1; j <= sqrt(num); j++) {
      for (int k = 1; k <= sqrt(num); k++) {
        int v = i * i + j * j + k * k + i * j + j * k + k * i;
        if (v == num)
          c++;
        if (v > num)
          break;
      }
    }
  }
  return c;
}
int main() {
  fio int n;
  cin >> n;
  vector<int> ans;

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

Error: TLE

Fixed submission:

/*Author - sambhu show(jgec) */
#include <bits/stdc++.h>
using namespace std;
#define fio                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define itc                                                                    \\
  ll t;                                                                        \\
  cin >> t;                                                                    \\
  while (t--)
#define PI 3.141592653589793238
// ang=(PI*ang)/180.0 in radian
#define Max(a, b, c) max(a, max(b, c));
#define Min(a, b, c) min(a, min(b, c));
#define all(v) v.begin(), v.end()
#define ll long long int
#define ld long double
#define pb push_back
#define eb emplace_back
#define gcd(a, b) __gcd(a, b)
#define fi first
#define se second
#define endl "\\n"
int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};
int XX[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int YY[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
int solve(int num) {
  int c = 0;
  for (int i = 1; i <= sqrt(num); i++) {
    for (int j = 1; j <= sqrt(num); j++) {
      for (int k = 1; k <= sqrt(num); k++) {
        int v = i * i + j * j + k * k + i * j + j * k + k * i;
        if (v == num)
          c++;
      }
    }
  }
  return c;
}
int main() {
  fio int n;
  cin >> n;

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

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

int func(int n) {
  int cnt = 0;
  for (int i = 1; i <= sqrt(n); i++) {
    for (int j = 1; j <= i; j++) {
      for (int k = 1; k <= j; k++) {
        if (i * i + j * j + k * k + i * j + j * k + k * i == n) {
          if (i > j && j > k)
            cnt += 6;
          else if (i > j && j == k)
            cnt += 3;
          else if (i == j && j > k)
            cnt += 3;
          else
            cnt++;
        }
      }
    }
  }

  return cnt;
}

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cout << func(i) << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

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

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

  return cnt;
}

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cout << func(i) << endl;
  }

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

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
  int n;
  cin >> n;
  int root = pow(n, 0.5);
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int x = 1; x < root; x++) {
      for (int y = x; y < root; y++) {
        for (int z = y; z < root; z++) {
          ll rel = x * x + y * y + z * z + x * y + y * z + z * x;
          if (rel > i)
            break;
          else if (rel == i) {
            if (x == y && y == z) {
              ans++;
            } else if (x == y && y != z) {
              ans += 3;
            } else if (y == z && x != y) {
              ans += 3;
            } else
              ans += 6;
          }
        }
      }
    }
    cout << ans << endl;
  }
}

Error: TLE

Fixed submission:

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
  int n;
  cin >> n;
  int root = pow(n, 0.5);
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int x = 1; x < root; x++) {
      for (int y = 1; y < root; y++) {
        for (int z = 1; z < root; z++) {
          ll rel = x * x + y * y + z * z + x * y + y * z + z * x;
          if (rel > i)
            break;
          else if (rel == i)
            ans++;
        }
      }
    }
    cout << ans << endl;
  }
}