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

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define m0(x) memset(x, 0, sizeof(x))

int dx4[4] = {1, 0, -1, 0}, dy4[4] = {0, 1, 0, -1};

int main() {
  int nn;
  cin >> nn;
  for (int n = 1; n <= nn; n++) {
    int ans = 0;
    for (int x = 1; x * x + 2 * x + 3 <= n; x++) {
      for (int y = 1; x * x + y * y + 1 + x * y + y + x <= n; y++) {
        int b = x + y;
        int c = x * x + y * y + x * y - n;
        int zz = (-b + sqrt(b * b - 4 * c)) / 2.0;
        // if(z<=1e-3) break;
        for (int z = zz - 1; z <= zz + 1; z++) {
          if (z < 1)
            continue;
          if (x * x + y * y + z * z + x * y + y * z + z * x == n) {
            // cout << n << " " << x << " " << y << " " << z << " " << endl;//
            ans++;
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define m0(x) memset(x, 0, sizeof(x))

int dx4[4] = {1, 0, -1, 0}, dy4[4] = {0, 1, 0, -1};

int main() {
  int nn;
  cin >> nn;
  for (int n = 1; n <= nn; n++) {
    int ans = 0;
    for (int x = 1; x <= n - 5; x++) {
      for (int y = 1; y <= n - 5; y++) {
        int zz = sqrt(n - (x * x + y * y) / 2.0) - (x + y) / 2.0;
        // if(z<=1e-3) break;
        for (int z = zz - 1; z < zz + 1; z++) {
          if (z < 1)
            continue;
          if (x * x + y * y + z * z + x * y + y * z + z * x == n) {
            // cout << n << " " << x << " " << y << " " << z << " " << endl;//
            ans++;
          }
        }
      }
    }
    cout << ans << endl;
  }

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll n;
  cin >> n;
  ll N = sqrt(n), ans[100010] = {};
  for (int x = 1; x <= N; x++) {
    for (int y = 1; y <= N; y++) {
      for (int z = 1; z <= N; z++) {
        ans[x * x + y * y + z * z + x * y + x * z + y * z]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << ans[i] << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[214514];
int main() {
  ll n;
  cin >> n;
  ll N = sqrt(n), ans[10010] = {};
  for (int x = 1; x <= N; x++) {
    for (int y = 1; y <= N; y++) {
      for (int z = 1; z <= N; z++) {
        ans[x * x + y * y + z * z + x * y + x * z + y * z]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << ans[i] << endl;
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <assert.h>
#include <climits>
#include <cmath>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  int32_t x, y, z;
  int32_t N;
  cin >> N;
  vector<int32_t> cnt(N, 0);
  for (x = 1; x * x < N; x++) {
    if (x * x + x + 4 > N)
      continue;
    for (y = 1; y * y < N; y++) {
      if (x * x + y * y + x + y + x * y + 1 > N)
        continue;
      for (z = 1; z * z < N; z++) {
        int32_t sum = x * x + y * y + z * z + x * y + y * z + z * x;
        if (sum > N)
          continue;
        cnt[sum - 1]++;
      }
    }
  }
  for (auto c : cnt) {
    cout << c << endl;
  }
  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <assert.h>
#include <climits>
#include <cmath>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  int32_t x, y, z;
  int32_t N;
  cin >> N;
  vector<int32_t> cnt(N, 0);
  for (x = 1; x * x < N; x++) {
    if (x * x + x + 4 > N)
      continue;
    for (y = 1; y * y < N; y++) {
      if (x * x + y * y + x + y + x * y + 1 > N)
        continue;
      for (z = 1; z * z < N; z++) {
        int32_t sum = x * x + y * y + z * z + x * y + y * z + z * x;
        cnt[sum - 1]++;
      }
    }
  }
  for (auto c : cnt) {
    cout << c << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[10005] = {0};
  int i, j, k;
  for (i = 1;; i++) {
    if (i * i * 6 > 10000)
      break;
    for (j = i;; j++) {
      if (i * i + j * j * 3 + i * j * 2 > 10000)
        break;
      for (k = j;; k++) {
        if (i * i + j * j + k * k + i * j + j * k + k * i > 10000)
          break;
        if (i == j && k == j)
          a[i * i + j * j + k * k + i * j + j * k + k * i] += 1;
        else if (i != k && k != j && i != j)
          a[i * i + j * j + k * k + i * j + j * k + k * i] += 6;
        else
          a[i * i + j * j + k * k + i * j + j * k + k * i] += 3;
      }
    }
  }
  int n;
  cin >> n;
  for (i = 1; i <= n; i++)
    cout << a[i] << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int i, j, k, l, count = 0, sum = 0, cum = 0;
  if (n <= 5) {
    for (j = 1; j <= n; j++)
      cout << "0" << endl;
  } else
    for (i = 1; i <= n; i++) {
      count = 0, sum = 0, cum = 0;
      int flag = 0;
      for (j = 1; j < i; j++) {
        for (k = j; k < i; k++) {
          for (l = k; l < i; l++) {
            if (j * j + k * k + l * l + j * k + k * l + l * j == i) {
              if (j == k && k == l)
                sum++;
              else if (j != k && k != l && l != j)
                count++;
              else
                cum++;
            } else if (j * j + k * k + l * l + j * k + k * l + l * j > i) {
              // flag=1;
              break;
            }
          }
          if (flag == 1)
            break;
        }
        if (flag == 1)
          break;
      }
      int t = sum + count * 6 + cum * 3;
      // cout<<sum<<" "<<count<<" "<<cum<<endl;
      cout << t << 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++)
using namespace std;
typedef long long ll;

int main() {

  int n;
  cin >> n;
  vector<int> f(n + 10);

  for (int i = 1; i <= n; i++) {
    // int cnt=0;
    for (int x = 1; x * x <= i; x++) {
      for (int y = x; y * y <= i; y++) {
        for (int z = y; z * z <= i; z++) {
          int l = x * x + y * y + z * z + x * y + y * z + z * x;
          if (l == i) {
            if (x < y && y < z)
              f[i] += 6;
            else if (x == y && y == z)
              f[i]++;
            else
              f[i] += 3;
          }
        }
      }
    }
  }
  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 < int(n); i++)
using namespace std;
typedef long long ll;

int main() {

  int n;
  cin >> n;
  // vector<int> f(n+10);

  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 l = x * x + y * y + z * z + x * y + y * z + z * x;
          if (l == i)
            cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;

int main() {
  int N;
  cin >> N;
  vi f(N + 1, 0);
  int v = 1000;
  for (int j = 1; j <= v; j++) {
    for (int k = 1; k <= v - j; k++) {
      for (int l = 1; l <= v - j - k; l++) {
        int c = j * j + k * k + l * l + j * k + k * l + l * j;
        if (c <= N) {
          f[c]++;
        }
      }
    }
  }

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

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;

int main() {
  int N;
  cin >> N;
  vi f(N + 1, 0);

  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= 120; j++) {
      for (int k = 1; k <= 120 - j; k++) {
        for (int l = 1; l <= 120 - j - k; l++) {
          if (j * j + k * k + l * l + j * k + k * l + l * j == i) {
            f[i]++;
          }
        }
      }
    }
  }

  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;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

  vector<ll> ans;

  for (int n = 1; n <= N; n++) {
    int a = 0;
    for (int x = 1; x * x < n; x++) {
      for (int y = x; x * x + y * y < n; y++) {
        for (int z = y; x * x + y * y + z * z < n; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == n) {
            if (x == y && y == z)
              a++;
            else if (x == y || y == z || z == x) {
              a += 3;
            } else {
              a += 6;
            }
          }
        }
      }
    }
    ans.push_back(a);
  }

  for (int a : ans) {
    cout << a << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:


//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

  vector<int> ans;

  for (int n = 1; n <= N; n++) {
    int a = 0;
    for (int x = 1; x * x < n; x++) {
      for (int y = 1; x * x + y * y < n; y++) {
        for (int z = 1; x * x + y * y + z * z < n; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == n)
            a++;
        }
      }
    }
    ans.push_back(a);
  }

  for (int a : ans) {
    cout << a << endl;
  }

  return 0;
}
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 = long long;

constexpr ll INF = ll(1e+18) + 1;

int main() {
  int N;

  cin >> N;
  vector<int> ans(N + 1);

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

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


Error: WA

Fixed submission:

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

constexpr ll INF = ll(1e+18) + 1;

int count_one(int N, string X) {
  int ret = 0;
  rep(i, N) {
    if (X[i] == '1') {
      ret++;
    }
  }
  return ret;
}

int to_dec(int N, string X) {
  int ret = 0;
  rep(i, N - 1) {
    if (X[i] == '1') {
      ret += 1;
    }
    ret *= 2;
  }
  if (X[N - 1] == '1') {
    ret += 1;
  }
  return ret;
}

string to_bin(int num, int N) {
  string ret = "";
  int tmp;

  for (int i = N - 1; i >= 0; i--) {
    tmp = num >> i & 0b1;
    if (tmp == 0b0) {
      ret += "0";
    } else {
      ret += "1";
    }
  }

  return ret;
}

map<int, int> dp;

int main() {
  int N;

  cin >> N;
  vector<int> ans(N);

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

  rep(i, N) { cout << ans[i] << endl; }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n;
  cin >> n;
  int a[6 * n];

  memset(a, 0, sizeof(a));

  for (int i = 1; i <= int(sqrt(n)); ++i)
    for (int j = 1; j <= n; ++j)
      for (int k = 1; k <= int(sqrt(n)); ++k) {
        int v = i * i + j * j + k * k + i * j + j * k + i * k;
        if (v <= n)
          a[v]++;
      }
  for (int i = 1; i <= n; ++i)
    cout << a[i] << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  int a[10050];

  memset(a, 0, sizeof(a));

  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      for (int k = 1; k <= n; ++k) {
        int v = i * i + j * j + k * k + i * j + j * k + i * k;
        if (v <= n)
          a[v]++;
      }
  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;
typedef long long ll;
const ll inf = 1e9;
#define sz 3000005
#define Fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);

int arr[10004];

int cal(int x, int y, int z) {

  return (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x);
}

int main() {
  Fast;
  int n, cnt = 0;
  cin >> n;
  for (int i = 1; i * i <= n; i++) {
    for (int j = 1; (i * i) + (j * j) + (i * j) <= n; j++) {
      for (int k = 1; cal(i, j, k) <= n; k++) {
        arr[cal(i, j, k)]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << arr[i] << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e9;
#define sz 3000005
#define Fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);

int cal(int x, int y, int z) {

  return (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x);
}

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

#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
  void solve() {
    int N;
    cin >> N;

    vector<int> a(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) {
          int t = x * x + y * y + z * z + x * y + y * z + z * x;
          if (t <= N) {
            a[t] += 1;
          }
        }
      }
    }

    for (int i = 1; i <= N; ++i) {
      cout << a[i] << '\\n';
    }
  }
};

int main() {
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  Solver().solve();
  return 0;
}


Error: TLE

Fixed submission:

#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
  void solve() {
    int N;
    cin >> N;

    for (int i = 1; i <= N; ++i) {
      cout << f(i) << '\\n';
    }
  }

  int f(int n) {
    int r = 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) {
            r += 1;
          }
        }
      }
    }

    return r;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  Solver().solve();
  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 ll long long
using namespace std;

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

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

  for (int n = 1; n <= N; n++) {
    int ans = 0;
    int intn = (int)sqrt(n) + 1;
    for (int x = 1; x <= intn; x++) {
      for (int y = 1; y <= x && f(x, y, 1) <= n; y++) {
        for (int z = 1; z <= y && f(x, y, z) <= n; z++) {
          if (f(x, y, z) == n) {
            // cout<<"x "<<x<<" y "<<y<<" z "<<z<<endl;
            if (x == y && y == z)
              ans++;
            else if ((x == y) || (y == z))
              ans += 3;
            else
              ans += 6;
          }
        }
      }
    }
    cout << ans << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

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

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

  for (int n = 1; n <= N; n++) {
    int ans = 0;
    int intn = (int)sqrt(n) + 1;
    for (int x = 1; x <= intn; x++) {
      for (int y = 1; y <= x; y++) {
        for (int z = 1; z <= y; z++) {
          if (f(x, y, z) == n) {
            // cout<<"x "<<x<<" y "<<y<<" z "<<z<<endl;
            if (x == y && y == z)
              ans++;
            else if ((x == y) || (y == z))
              ans += 3;
            else
              ans += 6;
          }
        }
      }
    }
    cout << ans << endl;
  }

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

#include <cmath>
#include <iostream>
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;
  int tmp_count = 0;

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

    for (int x = 1; x < limit + 1; x++) {
      if (f(x, x, x) == i) {
        count += 1;
      }
    }

    tmp_count = 0;
    for (int x = 1; x < limit + 1; x++) {
      for (int z = 1; z < limit + 1; z++) {
        if (x != z && f(x, x, z) == i) {
          tmp_count += 1;
        }
      }
    }

    count += tmp_count * 3;
    tmp_count = 0;
    for (int x = 1; x < limit + 1; x++) {
      for (int y = 1; y < x; y++) {
        for (int z = 1; z < y; z++) {
          if (f(x, y, z) == i) {
            tmp_count += 1;
          }
        }
      }
    }
    count += tmp_count * 6;
    cout << count << endl;
  }
}


Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
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 i = 1; i < n + 1; i++) {
    int limit = sqrt(i);
    int count = 0;
    for (int x = 1; x < limit + 1; x++) {
      for (int y = 1; y < limit + 1; y++) {
        for (int z = 1; z < limit + 1; z++) {
          if (f(x, y, z) == i) {
            count += 1;
          }
        }
      }
    }
    cout << count << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG

int main() {
  ll N;
  cin >> N;
  vector<ll> ans(10007);
  // vector<vector<int>> data(3, vector<int>(4));

  // int x, y, z;

  for (int x = 1; x <= 99; x++) {
    for (int y = 1; y <= 99; y++) {
      for (int z = 1; z <= 99; z++) {
        int tmp = x * x + y * y + z * z + x * y + y * z + z * x;
        if (tmp > 10000)
          continue;
        ans[tmp]++;
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG

int main() {
  ll N;
  cin >> N;
  vector<ll> ans(1001, 0);
  // vector<vector<int>> data(3, vector<int>(4));

  // int x, y, z;

  for (int x = 1; x <= 30; x++) {
    for (int y = 1; y <= 30; y++) {
      for (int z = 1; z <= 30; z++) {
        int tmp = x * x + y * y + z * z + x * y + y * z + z * x;
        if (tmp > 1000)
          continue;

        if (x == y && y == z) {
          ans[tmp] = 1;
        } else if (x == y || y == z || x == z) {
          ans[tmp] = 3;
        } else {
          ans[tmp] = 6;
        }
      }
    }
  }
  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)
#define REP2(i, x, n) for (int i = x; i < (n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
static const double PI = acos(-1);

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

  REP2(i, 1, n + 1) {
    int cnt = 0;

    for (int x = 1; x * x <= n; x++) {
      for (int y = x; y * y <= n - x * x; y++) {
        for (int z = y; z * z <= n - x * x - y * y; z++) {
          int f = 0;
          f = x * x + y * y + z * z + x * y + y * z + z * x;
          if (f == i) {
            if (x == y && y == z)
              ++cnt;
            else if (x == y || y == z)
              cnt += 3;
            else
              cnt += 6;
            break;
          }
        }
      }
    }
    printf("%d\\n", cnt);
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REP2(i, x, n) for (int i = x; i < (n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
static const double PI = acos(-1);

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

  REP2(i, 1, n + 1) {
    int cnt = 0;

    for (int x = 1; x * x <= n; x++) {
      for (int y = 1; y * y <= n - x * x; y++) {
        for (int z = 1; z * z <= n - x * x - y * y; z++) {
          int f = 0;
          f = x * x + y * y + z * z + x * y + y * z + z * x;
          if (f == i)
            ++cnt;
        }
      }
    }
    printf("%d\\n", cnt);
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <math.h>
using namespace std;
int main(void) {
  // Your code here!
  int N;
  int count = 0;
  cin >> N;

  for (int i = 1; i <= N; i++) {
    double ore;
    ore = sqrt(i);
    int A = ore;
    for (int a = 1; a <= A; a++) {
      for (int b = a; b <= A; b++) {
        for (int c = b; c <= A; c++) {
          if (a * a + b * b + c * c + a * b + b * c + c * a == i) {
            if (a != b && b != c && c != a) {
              count += 6;
            } else if (a == b && b != c || b == c && c != a ||
                       c == a && a != b) {
              count += 3;
            } else {
              count++;
            }
          }
        }
      }
    }
    cout << count << endl;
    count = 0;
  }
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main(void) {
  // Your code here!
  int N;
  int count = 0;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    for (int a = 1; a <= 100; a++) {
      for (int b = a; b <= 100; b++) {
        for (int c = b; c <= 100; c++) {
          if (a * a + b * b + c * c + a * b + b * c + c * a == i) {
            if (a != b && b != c && c != a) {
              count += 6;
            } else if (a == b && b != c || b == c && c != a ||
                       c == a && a != b) {
              count += 3;
            } else {
              count++;
            }
          }
        }
      }
    }
    cout << count << endl;
    count = 0;
  }
}