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;
  vector<int> count(N, 0);

  for (int x = 1; x < sqrt(N); x++) {
    for (int y = x; y < sqrt(N); y++) {
      for (int z = y; z < sqrt(N); z++) {
        for (int i = 0; i < N; i++)
          if ((pow(x + y + z, 2) - (x * y + y * z + z * x)) == i + 1)
            if (x == y && y == z)
              count.at(i) += 1;
            else if (x == y || y == z)
              count.at(i) += 3;
            else
              count.at(i) += 6;
      }
    }
  }
  for (int i = 0; i < N; i++)
    cout << count.at(i) << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  int N;
  cin >> N;
  vector<int> count(N, 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++) {
        for (int i = 0; i < N; i++)
          if ((pow(x + y + z, 2) - (x * y + y * z + z * x)) == i + 1)
            count.at(i)++;
      }
    }
  }
  for (int i = 0; i < N; i++)
    cout << count.at(i) << endl;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define INF 1e8
typedef long long int ll;
const double PI = acos(-1);

using Graph = vector<vector<int>>;
int main() {
  int hoge;
  cin >> hoge;
  int ans[10050] = {0};

  for (int x = 1; x * x <= 10050; ++x) {
    for (int y = 1; y * y <= 10050; ++y) {
      for (int z = 1; z * z <= 10050; ++z) {
        int a = pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x;
        if (a <= 10010)
          ans[a]++;
      }
    }
  }

  for (int i = 1; i <= hoge; ++i)
    cout << ans[i] << endl;
  // cout << i << " " << ans[i] << endl;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define INF 1e8
typedef long long int ll;
const double PI = acos(-1);

using Graph = vector<vector<int>>;

int f(int n) {
  int count = 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++) {
        if (pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x == n) {
          if (x == y && y == z && z == x)
            count++;
          else
            count += 3;
        }
      }
    }
  }
}

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

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

int main() {
  int n;
  cin >> n;
  long int f[10010] = {0};
  int i, j, k;
  long int v;

  for (i = 1; i < 110; i++) {
    for (j = 1; j <= i; j++) {
      for (k = 1; k <= j; k++) {
        v = i * i + j * j + k * k + i * j + j * k + k * i;
        if (v > n)
          break;
        if (i == j && j == k)
          f[v] += 1;
        else if (i == j || j == k)
          f[v] += 3;
        else if (i != j && i != k && j != k)
          f[v] += 6;
      }
    }
  }

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

Error: 0

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  long int f[200] = {0};
  int i, j, k;
  long long int v;

  for (i = 1; i < 100; i++) {
    for (j = 1; j <= i; j++) {
      for (k = 1; k <= j; k++) {
        v = i * i + j * j + k + k + i * j + j * k + k * i;
        if (v > n)
          break;
        if (i == j && j == k)
          f[v - 1] += 1;
        else if (i == j || j == k)
          f[v - 1] += 3;
        else
          f[v - 1]++;
      }
    }
  }

  for (i = 1; i <= n; i++) {
    cout << f[i] << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int c[105][105];
  int n;
  cin >> n;
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      c[i][j] = (i + j) * (i + j);
    }
  }
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    for (int x = 1; x <= sqrt(i); x++) {
      for (int y = x; y <= sqrt(i); y++) {
        for (int z = y; z <= sqrt(i); z++) {
          if (c[x][y] + c[x][z] + c[y][z] == i * 2) {
            if (x == y && y == z)
              cnt++;
            else if (x != y && y != z && x != z)
              cnt += 6;
            else
              cnt += 3;
          }
        }
      }
    }
    cout << cnt << 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 a, b, c, cnt = 0;
    for (a = 1; a <= sqrt(i); a++)
      for (b = 1; b <= sqrt(i); b++) {
        if ((a * a + b * b + a * b) > i)
          break;
        for (c = 1; c <= sqrt(i); c++)
          if ((a * a + b * b + c * c + a * b + a * c + b * c) == i)
            cnt++;
      }
    cout << cnt << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> ans(1000000, 0);
  for (int x = 1; x * x <= n; x++) {
    for (int y = 1; y * y <= n; y++) {
      for (int z = 1; z * z <= n; z++) {
        int num = x * x + y * y + z * z + x * y + y * z + z * x;
        ans[num]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> ans(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++) {
        int num = x * x + y * y + z * z + x * y + y * z + z * x;
        ans[num]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>

int main() {
  int n;
  scanf("%d", &n);

  int array[10001] = {0};
  int counter = 0;
  for (int x = 1; x * x < 10001; x++) {
    for (int y = 1; y * y < 10001; y++) {
      for (int z = 1; z * z < 10001; z++) {
        int value = ((x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x));
        if (value < 10001) {
          array[value]++;
        }
      }
    }
  }
  array[6] = 1;
  for (int i = 1; i <= n; i++) {
    printf("%d\\n", array[i]);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>

int main() {
  int n;
  scanf("%d", &n);

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

#include <bits/stdc++.h>

using namespace std;

const int N = 10010;

int n;
int ans[N];

int main() {
  cin >> n;
  int ceil = sqrt(n);
  for (int x = 1; x <= ceil; x++)
    for (int y = 1; y <= ceil; y++)
      for (int z = 1; z <= ceil; z++) {
        int tmp = x * x + y * y + z * z + x * y + x * z + y * z;
        if (tmp < N)
          ans[tmp]++;
      }

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

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int n;

int main() {
  cin >> n;
  for (int q = 1; q <= n; q++) {
    int ans = 0;
    int tmp = sqrt(q);
    for (int i = 1; i <= tmp; i++)
      for (int k = 1; k <= tmp; k++)
        for (int j = 1; j <= tmp; j++)
          if (i * i + k * k + j * j + i * k + i * j + k * j == q)
            ans++;

    cout << ans << 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;
using P = pair<int, int>;

int n;
vector<int> ans;

void dfs(vector<int> A) {
  if (A.size() == 3) {
    int x = A[0], y = A[1], z = A[2];
    int i = x * x + y * y + z * z + x * y + y * z + z * x;
    if (i > 0 && (i - 1) < n) {
      i -= 1;
      if (x == y && y == z)
        ans[i]++;
      else if (x != y && y != z)
        ans[i] += 6;
      else
        ans[i] += 3;
    }
    return;
  }
  A.push_back(A.back());
  while (A.back() < sqrt(n)) {
    dfs(A);
    A.back()++;
  }
}

int main() {
  cin >> n;
  ans = vector<int>(n, 0);
  rep(i, n) {
    vector<int> A(1, i + 1);
    dfs(A);
  }
  rep(i, n) cout << ans[i] << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

int ans = 0;

void dfs(vector<int> A, int n) {
  if (A.size() == 3) {
    int x = A[0], y = A[1], z = A[2];
    if (x * x + y * y + z * z + x * y + y * z + z * x == n) {
      if (x == y && y == z)
        ans++;
      else if (x != y && y != z)
        ans += 6;
      else
        ans += 3;
    }
    return;
  }
  A.push_back(A.back());
  while (A.back() < sqrt(n)) {
    dfs(A, n);
    A.back()++;
  }
}

int main() {
  int n;
  cin >> n;
  rep(i, n) {
    ans = 0;
    // vector<int> A(1, 1);
    rep(j, sqrt(i + 1)) {
      vector<int> A(1, j + 1);
      dfs(A, i + 1);
    }
    // dfs(A, i+1);
    cout << ans << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int N;
  cin >> N;
  for (int i = 1; i < N + 1; i++) {
    int ANS = 0;
    for (int j = 1; j * j <= i; j++) {
      for (int k = 1; (j + k) * (j + k) - j * k <= i; k++) {
        for (int l = 1; (j + k + l) * (j + k + l) - j * k - k * l - j * l <= i;
             l++) {
          if ((j + k + l) * (j + k + l) - j * k - k * l - j * l == i) {
            ANS++;
          }
        }
      }
    }
    cout << ANS << endl;
  }
}


Error: TLE

Fixed submission:

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

int main() {
  int N;
  cin >> N;
  for (int i = 1; i < N + 1; i++) {
    int ANS = 0;
    for (int j = 1; pow(j, 2) < i; j++) {
      for (int k = 1; pow(k, 2) < i; k++) {
        if (pow(j + k, 2) - j * k > i) {
          break;
        }
        for (int l = 1; pow(l, 2) < i; l++) {
          if (pow(j + k + l, 2) - j * k - k * l - j * l > i) {
            break;
          }
          if (pow(j + k + l, 2) - j * k - k * l - j * l == i) {
            ANS++;
          }
        }
      }
    }
    cout << ANS << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
  ll l, r, i, j, k, n, m, x;
  cin >> n;
  ll ar[10005] = {0};
  for (i = 1; i <= 100; i++) {
    for (j = 1; j <= 100; j++) {
      for (k = 1; k <= 100; k++) {
        //				cout<<i<<' '<<j<<' '<<k<<endl;
        ll x = i * i + j * j + k * k + i * j + j * k + k * i;
        if (x <= n)
          ar[x]++;
      }
    }
  }
  for (i = 1; i <= n; i++)
    cout << ar[i] << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
  ll l, r, i, j, k, n, m, x;
  cin >> n;
  ll ar[1005] = {0};
  for (i = 1; i <= 100; i++) {
    for (j = 1; j <= 100; j++) {
      for (k = 1; k <= 100; k++) {
        //				cout<<i<<' '<<j<<' '<<k<<endl;
        ll x = i * i + j * j + k * k + i * j + j * k + k * i;
        if (x <= n)
          ar[x]++;
      }
    }
  }
  for (i = 1; i <= n; i++)
    cout << ar[i] << endl;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
int mod = 998244353;
int mul(int a, int b) { return ((a % mod) * (b % mod)) % mod; }
int power(int a, int b) {
  int z = 1;
  int x = a;
  while (b > 0) {
    if (b & 1)
      z = mul(z, x);
    x = mul(x, x);
    b >>= 1;
  }
  return z;
}
int check(int x, int y, int z) {
  return (x + y + z) * (x + y + z) - (x * y + y * z + z * x);
}
int32_t main() {
  int N;
  cin >> N;
  vector<int> ans(10005);
  // ans[6] = 1, ans[11] = 3, ans[17] = 3, ans[18] = 3;
  for (int x = 1; x * x <= 10005; x++) {
    for (int y = 1; y * y <= 10005; y++) {
      for (int z = 1; z * z <= 10005; z++) {
        int k = check(x, y, z);
        if (k < 10005)
          ans[k]++;
      }
    }
  }

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


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
int mod = 998244353;
int mul(int a, int b) { return ((a % mod) * (b % mod)) % mod; }
int power(int a, int b) {
  int z = 1;
  int x = a;
  while (b > 0) {
    if (b & 1)
      z = mul(z, x);
    x = mul(x, x);
    b >>= 1;
  }
  return z;
}
int check(int x, int y, int z, int n) {
  if ((x + y + z) * (x + y + z) - (x * y + y * z + z * x) == n)
    return 1;
  return 0;
}
int32_t main() {
  int N;
  cin >> N;
  vector<int> ans(10005);
  ans[6] = 1, ans[11] = 3, ans[17] = 3, ans[18] = 3;
  for (int n = 21; n <= N; n++) {
    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 (check(x, y, z, n))
            cnt++;
      }
    }
    ans[n] = cnt;
  }
  for (int i = 1; i <= N; i++)
    cout << ans[i] << endl;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

int n, f[10100];

int main() {
  for (int i = 1; i <= 100; ++i) {
    for (int j = 1; j <= 100; ++j) {
      for (int k = 1; k <= 100; ++k) {
        int ans = i * i + j * j + k * k + i * k + j * k + i * j;
        if (ans <= 10000)
          f[ans] += 1;
      }
    }
  }
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i)
    cout << f[i] << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int n, f[1010];

int main() {
  for (int i = 1; i <= 45; ++i) {
    for (int j = 1; j <= 45; ++j) {
      for (int k = 1; k <= 45; ++k) {
        int ans = i * i + j * j + k * k + i * k + j * k + i * j;
        if (ans <= 1000)
          f[ans] += 1;
      }
    }
  }
  int n;
  cin >> n;
  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;

#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << "\\t|";
  __f(comma + 1, args...);
}

#define print(x)                                                               \\
  for (auto it : x)                                                            \\
    cout << it << ' ';                                                         \\
  cout << '\\n';
typedef long long ll;
typedef unsigned long long ull;

const int MOD = 1e9 + 7;
ll mod(ll a) { return (ll)(a % MOD + MOD) % MOD; }
ll mul(ll a, ll b) { return (ll)mod(mod(a) * mod(b)); }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> ans(n + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        ll a = i * i + j * j + k * k + i * j + j * k + k * i;
        if (a <= n) {
          ans[a]++;
        } else {
          break;
        }
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    cout << ans[i] << '\\n';
  }
  return 0;
}


Error: TLE

Fixed submission:

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

#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << "\\t|";
  __f(comma + 1, args...);
}

#define print(x)                                                               \\
  for (auto it : x)                                                            \\
    cout << it << ' ';                                                         \\
  cout << '\\n';
typedef long long ll;
typedef unsigned long long ull;

const int MOD = 1e9 + 7;
ll mod(ll a) { return (ll)(a % MOD + MOD) % MOD; }
ll mul(ll a, ll b) { return (ll)mod(mod(a) * mod(b)); }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> ans(n + 1);
  for (int N = 1; N <= n; N++) {
    for (int i = 1; i <= n; i++) {
      for (int j = i; j <= n; j++) {
        for (int k = j; k <= n; k++) {
          ll a = i * i + j * j + k * k + i * j + j * k + k * i;
          if (a == n) {
            ans[N]++;
          } else if (a > n) {
            break;
          }
        }
      }
    }
  }

  for (int N = 1; N <= n; n++) {
    cout << ans[N] << '\\n';
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int Ull;
typedef pair<int, int> PII;
template <typename T> inline T read() {
  char c = getchar();
  T x = 0, f = 1;
  while (!isdigit(c)) {
    if (c == '-')
      f = -1;
    c = getchar();
  }
  while (isdigit(c))
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  return x * f;
}
template <typename T> inline void write(T x) {
  if (x < 0)
    x = (~x) + 1, putchar('-');
  if (x / 10)
    write(x / 10);
  putchar(x % 10 | 48);
}
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
ll f(int x) {
  ll ans = 0;
  for (int i = 1; i <= 110; i++) {
    for (int j = i; j <= 110; j++) {
      for (int s = j; s <= 110; s++) {
        if (i * i + j * j + s * s + i * j + i * s + j * s == x) {
          if (i == j && j == s)
            ans += 1;
          else if (i == j || j == s)
            ans += 3;
          else
            ans += 6;
        }
        if (s * s > x)
          break;
      }
      if (j * j > x)
        break;
    }
    if (i * i > x)
      break;
  }
  return ans;
}
int main() {
  // ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

  int n = read<int>();
  for (int i = 1; i <= n; i++) {
    cout << f(i) << endl;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int Ull;
typedef pair<int, int> PII;
template <typename T> inline T read() {
  char c = getchar();
  T x = 0, f = 1;
  while (!isdigit(c)) {
    if (c == '-')
      f = -1;
    c = getchar();
  }
  while (isdigit(c))
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  return x * f;
}
template <typename T> inline void write(T x) {
  if (x < 0)
    x = (~x) + 1, putchar('-');
  if (x / 10)
    write(x / 10);
  putchar(x % 10 | 48);
}
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
ll f(int x) {
  ll ans = 0;
  for (int i = 1; i <= 110; i++) {
    for (int j = 1; j <= 110; j++) {
      for (int s = 1; s <= 110; s++) {
        if (i * i + j * j + s * s + i * j + i * s + j * s == x)
          ans++;
        if (s * s > x)
          break;
      }
      if (j * j > x)
        break;
    }
    if (i * i > x)
      break;
  }
  return ans;
}
int main() {
  // ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

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

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

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

Error: TLE

Fixed submission:

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

int main() {
  int n, ans;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    ans = 0;
    for (int x = 1; x < 100 && x * x < i; x++) {
      for (int y = 1; y < 100 && x * x + y * y + x * y < i; y++) {
        for (int z = 1; z < 100; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i)
            ans++;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;
int t, n;
int d[10001];

int main() {
  cin >> n;
  for (int x = 1; x * x <= n; x++)
    for (int y = 1; y * y <= n; y++)
      for (int z = 1; z * z <= n; z++) {
        t = x * x + y * y + z * z + x * y + y * z + z * x;
        if (t > n)
          break;
        d[t]++;
      }
  for (int i = 1; i <= n; i++)
    cout << d[i] << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>

using namespace std;
int t, n;
int d[10001];

int main() {
  cin >> n;
  for (int x = 1; x * x <= n; x++)
    for (int y = 1; y * y <= n; y++)
      for (int z = 1; z * z <= n; z++) {
        t = x * x + y * y + z * z + x * y + y * z + z * x;
        d[t]++;
      }
  for (int i = 1; i <= n; i++)
    cout << d[i] << endl;

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

#include <iostream>
#include <math.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  for (int n = 1; n <= N; n++) {
    int ans = 0;
    for (int i = 2; i * i < 2 * n; i++) {
      for (int j = 2; (i * i + j * j) < 2 * n; j++) {
        int k = sqrt(2 * n - i * i - j * j);
        if (i * i + j * j + k * k == 2 * n && i + j - k >= 2 &&
            i + k - j >= 2 && k + j - i >= 2)
          ans++;
      }
    }
    cout << ans << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int N;
  cin >> N;
  int ans;
  for (int n = 1; n <= N; n++) {
    int ans = 0;
    for (int i = 1; i * i < n; i++) {
      for (int j = 1; (i * i + j * j) < n; j++) {
        for (int k = 1; (i * i + j * j + k * k) < n; k++) {
          if (i * i + j * j + k * k + i * j + i * k + j * k == n)
            ans++;
        }
      }
    }
    cout << ans << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<int, int>;
const int INF = 1e9 + 7;

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

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


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<int, int>;
const int INF = 1e9 + 7;

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

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