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

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

// #define int long long
typedef long long ll;
// const int INF = 2e9;
// const ll INF = 9e18;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> f(N + 1);
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int p = x * x + y * y + z * z + x * y + y * z + z * x;
        if (p <= N)
          f[p]++;
      }
    }
  }
  for (int n = 1; n <= N; n++) {
    cout << f[n] << "\\n";
  }
}

Error: TLE

Fixed submission:

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

// #define int long long
typedef long long ll;
// const int INF = 2e9;
// const ll INF = 9e18;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> f(N + 1);
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        for (int n = 1; n <= N; n++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == n) {
            f[n]++;
          }
        }
      }
    }
  }
  for (int n = 1; n <= N; n++) {
    cout << f[n] << "\\n";
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define IO std::ios::sync_with_stdio(false), cin.tie(0)

using namespace std;

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

int a[10001];
int main() {
  int n;
  memset(a, 0, sizeof(a));
  cin >> n;
  for (int j = 1; j <= 100; j++) {
    for (int k = 1; k <= 100; k++) {
      for (int l = 1; l <= 100; l++) {
        int t = fun(j, k, l);
        if (t <= 10000)
          a[t]++;
      }
    }
  }

  for (int i = 1; i <= n; i++)
    cout << a[i] << "\\n";
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define IO std::ios::sync_with_stdio(false), cin.tie(0)

using namespace std;

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

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    for (int j = 1; j <= 60; j++) {
      for (int k = 1; k <= 60; k++) {
        for (int l = 1; l <= 60; l++) {
          if (i == fun(j, k, l))
            cnt++;
        }
      }
    }
    cout << cnt << endl;
  }

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

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

typedef long long ll;
#define rep(i, n) for (int i = 1; i * i <= (int)(n); i++)

int main() {
  int MAX_N = 10002;

  int s[MAX_N];
  for (int i = 0; i < MAX_N; ++i)
    s[i] = 0;

  for (int i = 0; i < MAX_N; ++i) {
    rep(j, i) {
      rep(k, i) {
        rep(l, i - j * j - k * k - j * k) {
          if (j * j + k * k + l * l + j * k + k * l + l * j == i)
            ++s[i];
        }
      }
    }
  }
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i)
    cout << s[i] << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

typedef long long ll;
#define rep(i, n) for (int i = 1; i * i <= (int)(n); i++)

int main() {
  int MAX_N = 10002;

  int s[MAX_N];
  for (int i = 0; i < MAX_N; ++i)
    s[i] = 0;

  for (int i = 0; i < MAX_N; ++i) {
    rep(j, i) {
      rep(k, i) {
        rep(l, i) {
          if (j * j + k * k + l * l + j * k + k * l + l * j == i)
            ++s[i];
        }
      }
    }
  }
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i)
    cout << s[i] << endl;
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iostream>

using namespace std;

bool is_square(int n) {
  long long r = (long long)floor(sqrt((long double)n));
  return (r * r) == n;
}

int counter(int n) {
  int count = 0;
  int x_range = ceil(sqrt((long double)n));
  for (int x = 1; x <= x_range; x++) {
    int y_range = ceil(sqrt((long double)n - x * x));
    for (int y = 1; y <= y_range; y++) {
      int tmp = 4 * n - 3 * x * x - 2 * x * y - 3 * y * y;
      if (is_square(tmp)) {
        tmp = sqrt(tmp) - x - y;
        if (tmp % 2 == 0 && tmp > 0) {
          count++;
        }
      }

      //                      for (int z = 1; z <= n - x*x - y*y - x*y; z++) {
      //                              int f = x * x + y * y + z * z + x * y + y
      //                              * z + z * x; if (f == n)
      //                                      count++;
      //                      }
    }
  }
  return count;
}

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

  for (int i = 1; i <= n; i++) {
    cout << counter(i) << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int counter(int n) {
  int count = 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++) {
        int f = x * x + y * y + z * z + x * y + y * z + z * x;
        if (f == n)
          count++;
      }
    }
  }
  return count;
}

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

  for (int i = 1; i <= n; i++) {
    cout << counter(i) << endl;
  }

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

#include <bits/stdc++.h>
#include <string>

using namespace std;
long long ans(int x, int y, int z) {
  long long ans;
  ans = x * x;
  ans += y * y;
  ans += z * z;
  ans += y * x;
  ans += z * x;
  ans += y * z;
  return ans;
}

int main() {
  int N;
  int A[1000000];
  cin >> N;
  for (int l = 1; l <= N; l++) {
    A[l] = 0;
  }
  for (int i = 1; i < N; i++) {
    for (int j = i; j < N; j++) {
      for (int k = j; k < N; k++) {
        long long l = ans(i, j, k);
        if (l > 10000)
          break;
        if (i == j && i == k) {
          A[l]++;
        } else if (i == j || i == k || k == j) {
          A[l] += 3;
        } else {
          A[l] += 6;
        }
      }
    }
  }
  for (int l = 1; l <= N; l++) {
    cout << A[l] << "\\n";
  }
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#include <string>

using namespace std;
int ans(int x, int y, int z) {
  int ans;
  ans = x * x;
  ans += y * y;
  ans += z * z;
  ans += y * x;
  ans += z * x;
  ans += y * z;
  return ans;
}

int main() {
  int N;
  int A[1000];

  int count = 0;
  cin >> N;
  for (int l = 1; l <= N; l++) {
    A[l] = 0;
  }
  for (int i = 1; i < 100; i++) {
    for (int j = i; j < 100; j++) {
      for (int k = j; k < 100; k++) {
        for (int l = 1; l <= N; l++) {
          if (ans(i, j, k) == l) {

            if (i == j && i == k) {
              A[l]++;
            } else if (i == j || i == k || k == j) {
              A[l] += 3;
            } else {
              A[l] += 6;
            }
          }
        }
      }
    }
  }
  for (int l = 1; l <= N; l++) {
    cout << A[l] << "\\n";
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<int> cnt(n + 1);
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int w = x * x + y * y + z * z + x * y + y * z + z * x;
        if (w <= n)
          cnt[w]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << cnt[i] << endl;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;

int func(int n) {
  int cnt = 0;
  for (ll x = 1; x <= 100; x++) {
    for (ll y = 1; y <= 100; y++) {
      for (ll z = 1; z <= 100; z++) {
        if (x * x + y * y + z * z + x * y + y * z + z * x == n) {
          cnt++;
          break;
        }
      }
    }
  }
  return cnt;
}

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

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  long long int n, x;
  cin >> n;
  long long int a[n + 1] = {0};
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        x = i * i + j * j + k * k + i * j + k * j + i * k;
        if (x <= n)
          a[x]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << a[i] << "\\n";
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  long long int n, x;
  cin >> n;
  long long int a[100] = {0};
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        x = i * i + j * j + k * k + i * j + k * j + i * k;
        if (x <= n)
          a[x]++;
      }
    }
  }
  for (int i = 0; i < n; i++)
    cout << a[i] << "\\n";
}
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 + 1; i++) {
    int sum = 0;
    for (int x = 1; x < sqrt(i) + 1; x++) {
      for (int y = x; y < sqrt(i) + 1; y++) {
        for (int z = y; z < sqrt(i) + 1; z++) {
          if ((x + y + z) * (x + y + z) - ((x * y) + (y * z) + (x * z)) == i &&
              x == y && y == z) {
            sum++;
          } else if ((x + y + z) * (x + y + z) -
                             ((x * y) + (y * z) + (x * z)) ==
                         i &&
                     x != y && x != z && y != z) {
            sum = sum + 6;
          } else if ((x + y + z) * (x + y + z) -
                         ((x * y) + (y * z) + (x * z)) ==
                     i) {
            sum = sum + 3;
          }
        }
      }
    }
    cout << sum << endl;
  }
}

Error: TLE

Fixed submission:

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

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

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

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

void make_result_array(int &n, vector<int> &result_array) {
  int up = sqrt(n);
  for (int i = 1; i <= up; i++) {
    for (int j = 1; j <= up; j++) {
      for (int k = 1; k <= up; k++) {
        int result = calculate_f(i, j, k);
        if (result <= n) {
          result_array.at(result - 1) += 1;
        }
      }
    }
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> array(n);
  make_result_array(n, array);
  for (int i = 0; i < n; i++) {
    cout << array.at(i) << endl;
  }
}


Error: TLE

Fixed submission:

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

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

void make_result_array(int &n, vector<int> &result_array) {
  int up = n;
  for (int i = 1; i <= up; i++) {
    for (int j = 1; j <= up; j++) {
      for (int k = 1; k <= up; k++) {
        int result = calculate_f(i, j, k);
        if (result < n) {
          result_array.at(result - 1) += 1;
        }
      }
    }
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> array(n);
  make_result_array(n, array);
  for (int i = 0; i < n; i++) {
    cout << array.at(i) << endl;
  }
}
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 < (int)(n); i++)
#define ll long long
#define P pair<int, int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> a(100000);
  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]++;
      }
    }
  }
  rep(i, n) { cout << a[i + 1] << endl; }
}


Error: TLE

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
#define P pair<int, int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(ni, n + 1) {
    if (ni == 0)
      continue;
    int ans = 0;
    for (int i = 1; i * i <= n; i++) {
      for (int j = 1; j * j <= n - i * i; j++) {
        for (int k = 1; k * k <= n - i * i - j * j - i * j; k++) {
          if (i * i + j * j + k * k + i * j + j * k + k * i == ni)
            ans++;
        }
      }
    }
    a[ni - 1] = ans;
  }
  rep(i, n) cout << a[i] << endl;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
using namespace std;
int n, m, ans, f[10005];
int coun(int x, int y, int z) {
  if (x == y && y == z)
    return 1;
  if (x == y || y == z)
    return 3;
  return 6;
}
int main() {
  // freopen("a.in","r",stdin);
  // freopen("a.out","w",stdout);
  scanf("%d", &n);
  m = sqrt(n);
  for (int i = 1; i <= m; i++)
    for (int j = i; j <= m; j++)
      for (int k = j; k <= m; k++) {
        int p = i * i + j * j + k * k + i * j + i * k + j * k;
        if (p > n)
          continue;
        f[p] += coun(i, j, k);
      }
  for (int i = 1; i <= n; i++)
    printf("%d\\n", f[i]);
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
using namespace std;
int n, m, ans, f[1005];
int coun(int x, int y, int z) { return x == y && y == z ? 1 : 3; }
int main() {
  // freopen("a.in","r",stdin);
  // freopen("a.out","w",stdout);
  scanf("%d", &n);
  m = sqrt(n);
  for (int i = 1; i <= m; i++)
    for (int j = i; j <= m; j++)
      for (int k = j; k <= m; k++) {
        int p = i * i + j * j + k * k + i * j + i * k + j * k;
        if (p > n)
          continue;
        f[p] += coun(i, j, k);
      }
  for (int i = 1; i <= n; i++)
    printf("%d\\n", f[i]);
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

/**
 *  author: Behradm
 *  Created: 2020.07.11 15:27:05
 *  In The Name Of God
 **/
#include <bits/stdc++.h>

using namespace std;

int f(int n) {
  long long res = 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 + x * z + y * z > n)
          break;
        if (x * x + y * y + z * z + x * y + x * z + y * z == n)
          res += 1;
      }
    }
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    printf("%d\\n", f(i));

  cerr << clock() << '\\n';
  return 0;
}


Error: TLE

Fixed submission:

/**
 *  author: Behradm
 *  Created: 2020.07.11 15:27:05
 *  In The Name Of God
 **/
#include <bits/stdc++.h>

using namespace std;

int f(int n) {
  int res = 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 + x * z + y * z == n)
          res += 1;
      }
    }
  }
  return res;
}

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

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
using Int = int64_t;
const Int INF = 1 << 30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << p.first << " " << p.second;
  return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
  for (Int i = 0; i < (Int)v.size(); i++)
    os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}

Int func(Int n) {
  Int res = 0;
  for (Int x = 1; x <= sqrt(n); x++) {
    if (x * x > n)
      break;
    for (Int y = 1; y <= sqrt(n); y++) {
      if (x * x + y * y > n)
        break;
      for (Int z = 1; z <= sqrt(n); z++) {
        Int tmp = x * x + y * y + z * z + x * y + y * z + z * x;
        if (tmp > n)
          break;
        if (tmp == n)
          res++;
      }
    }
  }
  return res;
}

void solve() {
  Int n;
  cin >> n;
  for (Int i = 1; i <= n; i++) {
    cout << func(i) << "\\n";
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
using Int = int64_t;
const Int INF = 1 << 30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << p.first << " " << p.second;
  return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
  for (Int i = 0; i < (Int)v.size(); i++)
    os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}

Int func(Int n) {
  Int res = 0;
  for (Int x = 1; x <= sqrt(n) + 5; x++) {
    Int A = x * x;
    if (A > n)
      break;
    for (Int y = 1; y <= sqrt(n) + 5; y++) {
      Int B = A + y * y;
      if (B > n)
        break;
      for (Int z = 1; z <= sqrt(n) + 5; z++) {
        Int C = B + z * z;
        C += x * y + y * z + z * x;
        if (C > n)
          break;
        if (C == n)
          res++;
      }
    }
  }
  return res;
}

void solve() {
  Int n;
  cin >> n;
  for (Int i = 1; i <= n; i++) {
    cout << func(i) << "\\n";
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

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

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;
}

const ll MOD = 1000000007;
const int INF = 1 << 30;
// const ll INF = (ll)1e18 + 1;

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

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


Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

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

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;
}

const ll MOD = 1000000007;
const int INF = 1 << 30;
// const ll INF = (ll)1e18 + 1;

// 素因数分解
template <typename T> map<T, T> prime_factor(T n) {
  map<T, T> ret;
  for (T i = 2; i * i <= n; i++) {
    T tmp = 0;
    while (n % i == 0) {
      tmp++;
      n /= i;
    }
    ret[i] = tmp;
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

// 約数の個数を求める
template <typename T> T divisor_num(T N) {
  map<T, T> pf = prime_factor(N);
  T ret = 1;
  for (auto p : pf) {
    ret *= (p.second + 1);
  }
  return ret;
}

// 平方数かどうかの判定
bool is_squere(long long N) { return divisor_num(N) % 2 == 1; }

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

  int ans = 0;
  int z1, z2;
  int disc;
  for (int n = 1; n <= N; ++n) {
    ans = 0;
    for (int x = 1; x <= 100; ++x) {
      for (int y = 1; y <= 100; ++y) {
        if (x * x + y * y + x * y >= n)
          continue;
        disc = (y + x) * (y + x) - 4 * (x * x + y * y + x * y - n);
        if (is_squere(disc)) {
          z1 = (-(y + x) + sqrt(disc)) / 2;
          z2 = (-(y + x) - sqrt(disc)) / 2;
          if (z1 > 0)
            ans++;
          if (z2 > 0)
            ans++;
        }
      }
    }
    cout << ans << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int hash[10001] = {};
  int sum = 0;
  for (int i = 1; i < 100; i++) {
    for (int j = 1; j < 100; j++) {
      for (int k = 1; k < 100; k++) {
        sum = i * i + j * j + k * k + i * j + j * k + i * k;
        if (sum > 10000) {
          break;
        }
        hash[sum]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << hash[i] << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {

  int N = 0;
  int Np = 100;
  int count1 = 0;
  int count2 = 0;

  cin >> N;

  while (count1 < N) {

    for (int x = 1; x < Np; x++) {

      for (int y = 1; y < Np; y++) {

        for (int z = 1; z < Np; z++) {

          if (count1 + 1 ==
              pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x) {
            count2++;
          }
          if (pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x >
              10000) {
            break;
          }
        }
      }
    }

    cout << count2 << endl;

    count1++;

    count2 = 0;
  }
}