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

#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int fn(long long x, long long y, long long z) {
  return x * x + y * y + z * z + x * y + y * z + z * x;
}
int main() {
  long long N;
  cin >> N;
  int n = sqrt(N);
  int x, y, z;
  vector<int> ans(10001);
  for (int i = 1; i < n; i++) {
    for (int j = 1; j < n; j++) {
      for (int k = 1; k < n; k++) {
        if (fn(i, j, k) <= 10000)
          ans.at(fn(i, j, k) - 1)++;
      }
    }
  }
  rep(i, N) cout << ans.at(i) << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int fn(long long x, long long y, long long z) {
  return x * x + y * y + z * z + x * y + y * z + z * x;
}
int main() {
  long long N;
  cin >> N;
  int n = sqrt(N);
  int x, y, z;
  vector<int> ans(N);
  for (int i = 1; i < n; i++) {
    for (int j = 1; j < n; j++) {
      for (int k = 1; k < n; k++) {
        for (int l = 0; l < N; l++) {
          if (l + 1 == fn(i, j, k))
            ans.at(l)++;
        }
      }
    }
  }
  rep(i, N) cout << ans.at(i) << endl;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

void solve(long long N) {
  for (long long i = 1; i <= N; i++) {
    long long cnt = 0;
    for (long long j = 1; j <= N; j++) {
      if (j * j > N)
        break;

      for (long long k = 1; k <= N; k++) {
        if (j * j + k * k + j * k > N)
          break;

        for (long long l = 1; l <= N; l++) {
          long long f = j * j + k * k + l * l + j * k + j * l + k * l;
          if (f == i)
            cnt++;
          else if (f > i)
            break;
        }
      }
    }
    cout << cnt << endl;
  }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips:
// You use the default template now. You can remove this line by using your
// custom template)
int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Error: TLE

Fixed submission:

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

void solve(long long N) {
  for (long long i = 1; i <= N; i++) {
    long long cnt = 0;
    for (long long j = 1; j <= N; j++) {
      for (long long k = 1; k <= N; k++) {
        for (long long l = 1; l <= N; l++) {
          long long f = j * j + k * k + l * l + j * k + j * l + k * l;
          if (f == i)
            cnt++;
          else if (f > i)
            break;
        }
      }
    }
    cout << cnt << endl;
  }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips:
// You use the default template now. You can remove this line by using your
// custom template)
int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

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


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int x = 1; x * x <= n; x++) {
      for (int y = x; y * y <= n; y++) {
        for (int z = y; z * z <= n; z++) {
          int res = x * x + y * y + z * z + x * y + y * z + z * x;
          if (res == i) {
            if (x == y && y == z)
              ans++;
            else if (x != y && y != z && z != x)
              ans += 6;
            else
              ans += 3;
          }
        }
      }
    }
    cout << ans << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
  int n;
  cin >> n;
  vector<int> res(n, 0);
  for (int x = 1; x < 105; ++x) {
    for (int y = 1; y < 105; ++y) {
      for (int z = 1; z < 105; ++z) {
        ll v = x * x + y * y + z * z + x * y + y * z + z * x;
        if (v < 10050)
          res[v]++;
      }
    }
  }
  for (int i = 1; i <= n; ++i)
    cout << res[i] << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

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

#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define compress(v) sort(all(v)), v.erase(unique(all(v)), v.end())
using namespace std;

typedef long long ll;

vector<int> fac[10101];

int f(int x) {
  int cnt = 0;
  for (int i = 1; i * i <= x; i++)
    for (int j = 1; j * j <= x; j++) {
      if (i * i + j * j > x)
        break;
      ll t = x - i * i - j * j - i * j;
      ll a = 1, b = i + j, c = -t;
      for (auto k : fac[abs(c)]) {
        if (a * k * k + b * k + c == 0)
          cnt++;
      }
    }
  return cnt;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j * j <= i; j++)
      if (i % j == 0) {
        fac[i].push_back(j);
        if (i / j != j)
          fac[i].push_back(i / j);
      }
  }
  for (int i = 1; i <= n; i++)
    cout << f(i) << "\\n";
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define compress(v) sort(all(v)), v.erase(unique(all(v)), v.end())
using namespace std;

typedef long long ll;

int f(int x) {
  int cnt = 0;
  for (int i = 1; i * i <= x; i++)
    for (int j = 1; j * j <= x; j++) {
      if (i * i + j * j > x)
        break;
      ll t = x - i * i - j * j - i * j;
      ll a = 1, b = i + j, c = -t;
      for (int k = 1; k * k <= x; k++) {
        if (a * k * k + b * k + c == 0)
          cnt++;
        if (x % k == 0 && x / k != k) {
          ll kk = x / k;
          if (a * kk * kk + b * kk + c == 0)
            cnt++;
        }
      }
    }
  return cnt;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++)
    cout << f(i) << "\\n";
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <cstdio>
using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    float lim = sqrt((float)2 / 3 * i);
    int max = (int)(sqrt((float)2 * i));
    int lim_up = (int)lim + 1;
    if (lim == (float)((int)lim))
      lim_up--;
    for (int x = lim_up; x <= max + 1; x++) {
      for (int z = 1; z <= (int)lim; z++) {
        for (int y = z; y <= x; y++) {

          int det = x * x + y * y + z * z;
          if (x + y > z && y + z > x && z + x > y && det == 2 * i) {
            if (x == y && y == z)
              ans++;
            else if (x == y || y == z)
              ans += 3;
            else
              ans += 6;
          }
        }
      }
    }
    printf("%d\\n", ans);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <cstdio>
using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    float lim = sqrt((float)2 / 3 * i);
    int lim_up = (int)lim + 1;
    if (lim == (float)((int)lim))
      lim_up--;
    for (int x = lim_up; x < 2 * i - 1; x++) {
      for (int z = 1; z <= (int)lim; z++) {
        for (int y = z; y <= x; y++) {

          int det = x * x + y * y + z * z;
          if (x + y > z && y + z > x && z + x > y && det == 2 * i) {
            if (x == y && y == z)
              ans++;
            else if (x == y || y == z)
              ans += 3;
            else
              ans++;
          }
        }
      }
    }
    printf("%d\\n", ans);
  }
  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 < n; i++)
#define rrep(i, n) for (int i = 1; i < n; i++)
using vi = vector<int>;

int main() {
  int n;
  cin >> n;
  int count = 0, sum = 0, m;
  vector<int> vec(10001);
  m = sqrt(n);
  for (int a = 1; a <= m; a++) {
    for (int b = a; b <= m; b++) {
      for (int c = b; c <= m; c++) {
        sum = (a + b + c) * (a + b + c) - (a * b + b * c + a * c);
        if (sum < 10001) {
          set<int> sets = {a, b, c};
          if (sets.size() == 3)
            count = 6;
          else if (sets.size() == 2)
            count = 3;
          else
            count = 1;
          vec.at(sum) += count;
        }
      }
    }
  }

  rep(i, n) { cout << vec.at(i + 1) << endl; }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i < n; i++)
using vi = vector<int>;
int f(int n) {
  int x, y, z, count = 0, sum = 0;
  for (int a = 1; a < n; a++) {
    for (int b = a; b < n; b++) {
      for (int c = b; c < n; c++) {
        sum = (a + b + c) * (a + b + c) - (a * b + b * c + a * c);
        if (sum > n)
          break;
        else if (sum == n) {
          set<int> sets = {a, b, c};
          if (sets.size() == 3)
            count += 6;
          else if (sets.size() == 2)
            count += 3;
          else
            count += 1;
        }
      }
    }
  }
  return count;
}

int main() {
  int n;
  cin >> n;
  rep(i, n) { cout << f(i + 1) << endl; }
  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++)
using ll = long long;
int main() {
  vector<int> a(1000000);
  int n;
  cin >> n;
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        a[x * x + y * y + z * z + x * y + y * z + z * x]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << endl;
  }
}

Error: -6
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc


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;
int main() {
  vector<int> a(1000000000);
  int n;
  cin >> n;
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        a[x * x + y * y + z * z + x * y + y * z + z * x]++;
      }
    }
  }
  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;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int c = 0;
    for (int j = 1; j < int(sqrt(i)); j++) {
      for (int k = 1; k <= j; k++) {
        for (int p = 1; p <= k; p++) {
          int a = j + k;
          int b = k + p;
          int d = j + p;
          if ((pow(a, 2) + pow(b, 2) + pow(d, 2)) == 2 * i) {
            if (j == p && k == p) {
              c++;
            } else if ((j == p && k != p) || (j == k && j != p) ||
                       (p == k && p != j)) {
              c += 3;
            } else
              c += 6;
          }
          if ((pow(a, 2) + pow(b, 2) + pow(d, 2)) > 2 * i)
            break;
        }
      }
    }
    cout << c << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int c = 0;
    for (int j = 1; j < int(sqrt(i)); j++) {
      for (int k = 1; k < int(sqrt(i)); k++) {
        for (int p = 1; p < int(sqrt(i)); p++) {
          int a = j + k;
          int b = k + p;
          int d = j + p;
          if ((pow(a, 2) + pow(b, 2) + pow(d, 2)) == 2 * i) {
            c++;
          }
          if ((pow(a, 2) + pow(b, 2) + pow(d, 2)) > 2 * i)
            break;
        }
      }
    }
    cout << c << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

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

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

  int nn = sqrt(n);

  for (int x = 1; x <= nn; ++x) {
    for (int y = 1; y <= nn; ++y) {
      for (int z = 1; z <= nn; ++z) {
        int f = x * x + y * y + z * z + x * y + y * z + z * x;
        if (f <= n) {
          ans[f]++;
        }
      }
    }
  }

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

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

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

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

  int nn = sqrt(n);

  for (int x = 1; x <= nn; ++x) {
    for (int y = 1; y <= nn; ++y) {
      for (int z = 1; z <= nn; ++z) {
        int f = x * x + y * y + z * z + x * y + y * z + z * x;
        ans[f]++;
      }
    }
  }

  for (int i = 1; i <= n; ++i) {
    cout << ans[i] << 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 < (n); i++)
using namespace std;
using ll = long long;

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

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

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


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 main() {
  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;
  }
}
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 main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> vec(N + 1);
  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;
        vec[x * x + y * y + z * z + x * y + y * z + z * x]++;
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    cout << vec[i] << endl;
  }
}


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 main() {
  ios::sync_with_stdio(false);

  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;
  }
}
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 main() {
  int n;
  cin >> n;
  vector<int> cnt(n + 1);
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        int t = i * i + j * j + k * k + i * j + j * k + k * i;
        if (t > n)
          continue;
        cnt[t]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << cnt[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 n) {
  int ret = 0;
  for (int x = 1; x * x <= n; x++) {
    for (int y = 1; y * y <= n; 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 == n)
          ret++;
      }
    }
  }
  return ret;
}

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

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

int main() {
  // 入力
  double n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    // x
    rep(x, n) {
      // y
      if (x * x + x + 4 > i)
        break;
      rep(y, n) {
        if (x * x + y * y + x * y + x + y + 1 > i)
          break;
        else if ((double)i - 3 * (x * x + y * y) / 4 - x * y / 2 <= 0)
          break;
        // z
        double z = -(x + y) / 2 +
                   sqrt((double)i - 3 * (x * x + y * y) / 4 - x * y / 2);
        if (z == (int)z)
          ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  // 入力
  double n;
  int ans[1010] = {0};
  cin >> n;
  for (int i = 1; i <= n; i++) {
    // x
    rep(x, n) {
      // y
      if (x * x + x + 4 > i)
        break;
      rep(y, n) {
        if (x * x + y * y + x * y + x + y + 1 > i)
          break;
        else if ((double)i - 3 * (x * x + y * y) / 4 - x * y / 2 <= 0)
          break;
        // z
        double z = -(x + y) / 2 +
                   sqrt((double)i - 3 * (x * x + y * y) / 4 - x * y / 2);
        if (z == (int)z)
          ans[i]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << ans[i] << endl;
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  int fs[N];
  for (int i = 0; i <= N; i++) {
    fs[i] = 0;
  }
  for (int x = 1; x <= 110; x++) {
    for (int y = 1; y <= 110; y++) {
      for (int z = 1; z <= 110; z++) {
        int n = x * x + y * y + z * z + x * y + y * z + z * x;
        if (n <= N) {
          fs[n]++;
        }
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    cout << fs[i] << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

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

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

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

int main() {
  int n;
  cin >> n;
  for (int x = 1; x <= n; x++) {
    int cnt = 0;
    for (int i = 1; i < sqrt(n); i++) {
      if (f(i, 1, 1) > x)
        break;
      for (int j = 1; j < sqrt(n); j++) {
        if (f(i, j, 1) > x)
          break;
        for (int k = 1; j < sqrt(n); k++) {
          if (f(i, j, k) == x)
            cnt++;
          if (f(i, j, k) >= x)
            break;
        }
      }
    }
    cout << cnt << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

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

int main() {
  int n;
  cin >> n;
  for (int x = 1; x <= n; x++) {
    int cnt = 0;
    for (int i = 1; i < sqrt(n); i++) {
      if (f(i, 1, 1) > x)
        break;
      for (int j = 1; j < sqrt(n); j++) {
        if (f(i, j, 1) > x)
          break;
        for (int k = 1; k < sqrt(n); k++) {
          if (f(i, j, k) == x)
            cnt++;
          if (f(i, j, k) >= x)
            break;
        }
      }
    }
    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 < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
  ll n;
  cin >> n;
  vector<ll> f(n + 1, 0);

  for (ll i = 1; i * i <= n; i++) {
    if (i * i > n)
      continue;
    for (ll j = 1; j * j <= n; j++) {
      ll tmp = i * i + j * j + i * j;
      if (tmp > n)
        continue;
      for (ll k = 1; k * k <= n; k++) {
        ll t = i * i + j * j + k * k + i * j + j * k + k * i;
        // cout <<"t = "<< t << endl;
        // if (t > n) break;
        if (1 <= t && t <= n) {
          f[t]++;
        }
      }
    }
  }

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

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

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

int main() {
  ll n;
  cin >> n;
  vector<ll> f(n + 1, 0);

  for (ll i = 1; i < n * n; i++) {
    if (i * i > n)
      continue;
    for (ll j = 1; j < n * n; j++) {
      ll tmp = i * i + j * j + i * j;
      if (tmp > n)
        continue;
      for (ll k = 1; k < n * n; k++) {
        ll t = i * i + j * j + k * k + i * j + j * k + k * i;
        // cout <<"t = "<< t << endl;
        if (t > n)
          break;
        if (1 <= t && t <= n) {
          f[t]++;
        }
      }
    }
  }

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

  return 0;
}