alexjercan/bugnet huggingface dataset:
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

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

int n;
int m;
vector<int> buf(3);
vector<int> ans;

void dfs(int i, const int range_start, const int range_end) {
  if (i == 3) {
    // ここで所望の作業を行う
    if (buf[0] + buf[1] + buf[2] <= m + 2) {
      int t = buf[0] * buf[0] + buf[1] * buf[1] + buf[2] * buf[2] +
              buf[0] * buf[1] + buf[1] * buf[2] + buf[2] * buf[0];
      if (t < n + 1)
        ++ans[t];
    }
  } else {
    for (int j = range_start; j <= range_end; ++j) {
      buf[i] = j;
      dfs(i + 1, range_start, range_end);
    }
  }
}

int main(void) {
  cin >> n;
  m = sqrt(n / 6) * 3 - 2;
  int range_start = 1;
  int range_end = m;
  ans.resize(n + 1);
  dfs(0, range_start, range_end);

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

  return 0;
}

Error: 0

Fixed submission:

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

int m;
vector<int> buf;
vector<int> ans;

void dfs(int i, const int size, const int range_start, const int range_end) {
  if (i == size) {
    // ここで所望の作業を行う
    if (buf[0] + buf[1] + buf[2] <= m + 2) {
      int t = buf[0] * buf[0] + buf[1] * buf[1] + buf[2] * buf[2] +
              buf[0] * buf[1] + buf[1] * buf[2] + buf[2] * buf[0];
      ++ans[t];
    }
  } else {
    for (int j = range_start; j <= range_end; ++j) {
      buf[i] = j;
      dfs(i + 1, size, range_start, range_end);
    }
  }
}

int main(void) {
  int n;

  cin >> n;
  m = sqrt(n / 6) * 3 - 2;
  int size = 3;
  int range_start = 1;
  int range_end = m;
  ans.resize(n + 1);
  buf.resize(size);
  dfs(0, size, range_start, range_end);

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

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

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
long long int arr[10005];
int main() {
  ll n;
  cin >> n;

  for (long long int i = 1; i <= 100; i++) {
    for (long long int j = 1; j <= 100; j++) {
      for (long long int k = 1; k <= 100; k++) {
        ll val = i * i + j * j + k * k + i * j + j * k + k * i;
        if (val <= n) {

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


Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
long long int arr[10005];
int main() {
  ll n;
  cin >> n;

  for (long long int i = 1; i <= 50; i++) {
    for (long long int j = 1; j <= 50; j++) {
      for (long long int k = 1; k <= 50; k++) {
        ll val = i * i + j * j + k * k + i * j + j * k + k * i;
        arr[val]++;
      }
    }
  }
  for (long long int i = 1; i <= n; i++) {
    cout << arr[i] << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

#define PI 3.14159265358979323846264338327950L

int main(void) {

  long long x, y, z, N, tmp;

  // map<long long, long long> mp;

  cin >> N;

  vector<long long> mp(N + 5, 0);

  for (x = 1; x <= N; x++) {
    for (y = 1; y <= N; y++) {
      if (x * y > N)
        break;
      for (z = 1; z <= N; z++) {
        tmp = x * x + y * y + z * z + x * y + y * z + z * x;
        if (tmp > N)
          break;
        mp[tmp]++;
      }
    }
  }

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

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define PI 3.14159265358979323846264338327950L

int main(void) {

  long long x, y, z, N, tmp;

  map<long long, long long> mp;

  cin >> N;

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

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

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

#include <algorithm>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define PI 3.14159265358979323846264338327950L

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

  double N;
  cin >> N;
  vector<double> ans(N + 1, 0);

  for (double z = 1; z * z < N; z++) {
    // double x = 1,y = 1,z=1;
    for (double y = 1; y * y < N; y++) {

      for (double x = 1; x * x < N; x++) {
        double n = pow(x + y, 2) + pow(y + z, 2) + pow(z + x, 2);
        // cout << "(" << x << "," << y << "," << z << ")" << endl;
        // cout << n/2 << endl;
        if (n < 2 * (N + 1)) {
          ans[n / 2 - 1] += 1;
        }
      }
    }
  }
  // cout << "" << endl;
  for (double i = 0; i < N; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

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


Fixed submission:

#include <algorithm>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define PI 3.14159265358979323846264338327950L

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

  double N;
  cin >> N;
  vector<double> ans(1000000000, 0);

  for (double z = 1; z * z < N; z++) {
    // double x = 1,y = 1,z=1;
    for (double y = 1; y * y < N; y++) {

      for (double x = 1; x * x < N; x++) {
        double n = pow(x + y, 2) + pow(y + z, 2) + pow(z + x, 2);
        // cout << "(" << x << "," << y << "," << z << ")" << endl;
        // cout << n/2 << endl;
        if (x == y && y == z) {
          ans[n / 2 - 1] = 1;
        } else if ((x == y || y == z || z == x)) {
          ans[n / 2 - 1] = 3;
        } else {
          ans[n / 2 - 1] = 6;
        }
      }
    }
  }
  // cout << "" << endl;
  for (double i = 0; i < N; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <stack>
#include <string>
#include <unordered_map>

using namespace std;
typedef long long ll;
const ll INF = 1000000007;
const ll mod = 998244353;

int main() {
  ll n;
  cin >> n;
  for (ll N = 1; N <= n; N++) {
    ll ans = 0;
    for (ll x = 1; x * x <= N; x++) {
      for (ll y = 1; y * y + x * x + x * y <= N; y++) {
        for (ll 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 << "\\n";
  }
  cout << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <stack>
#include <string>
#include <unordered_map>

using namespace std;
typedef long long ll;
const ll INF = 1000000007;
const ll mod = 998244353;

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

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define rep(i, n) for (i = 0; i < n; i++)
#define repl(k, n) for (k = 0; k < n; ++k)

int main() {
  int N;
  cin >> N;
  int i;
  int x;
  int y;
  int z;
  int count = 0;
  int stop = 0;
  double a;
  int limit;
  for (i = 1; i < N + 1; i++) {
    count = 0;
    a = sqrt(i);
    limit = a;
    for (x = 1; x < limit; x++) {
      for (y = x; y < limit; y++) {
        for (z = y; z < limit; z++) {
          if (x * x + x * y + x * z + y * y + z * z + y * z == i) {
            if (x == y && y == z)
              count = count + 1;
            else if (x == y || y == z || z == x)
              count = count + 3;
            else
              count = count + 6;
            stop = stop + 1;
          }
          if (stop == 2)
            z = i / 6 + 2;
        }
      }
    }
    cout << count << "\\n";
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define rep(i, n) for (i = 0; i < n; i++)
#define repl(k, n) for (k = 0; k < n; ++k)

int main() {
  int N;
  cin >> N;
  int i;
  int x;
  int y;
  int z;
  int count = 0;
  int stop = 0;
  for (i = 1; i < N + 1; i++) {
    count = 0;
    for (x = 1; x < i / 6 + 2; x++) {
      for (y = x; y < i / 6 + 2; y++) {
        for (z = y; z < i / 6 + 2; z++) {
          if (x * x + x * y + x * z + y * y + z * z + y * z == i) {
            if (x == y && y == z)
              count = count + 1;
            else if (x == y || y == z || z == x)
              count = count + 3;
            else
              count = count + 6;
            stop = stop + 1;
          }
          if (stop == 2)
            z = i / 6 + 2;
        }
      }
    }
    cout << count << "\\n";
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

#define FAST()                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL)

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

int main() {
  FAST();
  int i, j, k, n, x, cnt[10002] = {0};
  cin >> n;
  for (i = 1; i < 101; i++) {
    for (j = 1; j < 101; j++) {
      for (k = 1; k < 101; k++) {
        x = Check(i, j, k);
        if (x <= n)
          ++cnt[x];
      }
    }
  }
  for (i = 1; i <= n; i++)
    cout << cnt[i] << '\\n';
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define FAST()                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL)

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

int main() {
  FAST();
  int i, j, k, n, x, cnt[1002] = {0};
  cin >> n;
  for (i = 1; i < 101; i++) {
    for (j = 1; j < 101; j++) {
      for (k = 1; k < 101; k++) {
        x = Check(i, j, k);
        if (x <= n)
          ++cnt[x];
      }
    }
  }
  for (i = 1; i <= n; i++)
    cout << cnt[i] << '\\n';
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output14.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    // t sq = sqrt(i) ;
    long ans = 0;
    long temp = 0;
    for (int j = 1;; j++) {
      if (j * j > i)
        break;
      for (int k = 1;; k++) {
        if ((k * k + j * j + k * j) > i)
          break;
        for (int z = 1;; z++) {
          temp = j * j + k * k + z * z + j * k + j * z + k * z;
          if (temp == i)
            ans++;
          if (temp > i)
            break;
        }
      }
    }
    cout << ans << "\\n";
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output14.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int sq = sqrt(i);
    long ans = 0;
    if (sq >= 1) {
      long temp = 0;
      for (int j = 1; j <= sq; j++) {
        for (int k = 1; k <= sq; k++) {
          for (int z = 1; z <= sq; z++) {
            temp = j * j + k * k + z * z + j * k + j * z + k * z;
            if (temp == i)
              ans++;
          }
        }
      }
    }
    cout << ans << "\\n";
  }
}
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 ull;
typedef double db;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
#define fi first
#define sc second
#define w(n) while (n--)
#define f(i, n) for (ll i = 1; i <= n; i++)
#define fr(i, n) for (ll i = 0; i < n; i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define mod 1000000007
db pie = 3.141592653589793238;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll t;
  t = 1;
  // cin>>t;
  w(t) {
    ll n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      if (i == 1 || i == 2 || i == 3 || i == 4 || i == 5)
        cout << 0 << "\\n";
      else if (i == 6)
        cout << 1 << "\\n";
    }
    unordered_map<int, int> m;
    for (int x = 1; x <= sqrt(n); x++) {
      for (int j = 1; j <= sqrt(n); j++) {
        for (int k = 1; k <= sqrt(n); k++) {

          int n1 = x * x + j * j + k * k + x * j + j * k + k * x;
          m[n1]++;
        }
      }
    }

    for (int i = 7; i <= n; i++) {
      cout << m[i] << "\\n";
    }
  }
}

Error: TLE

Fixed submission:

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

typedef long long int ll;
typedef unsigned long long ull;
typedef double db;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
#define fi first
#define sc second
#define w(n) while (n--)
#define f(i, n) for (ll i = 1; i <= n; i++)
#define fr(i, n) for (ll i = 0; i < n; i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define mod 1000000007
db pie = 3.141592653589793238;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll t;
  t = 1;
  // cin>>t;
  w(t) {
    ll n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      if (i == 1 || i == 2 || i == 3 || i == 4 || i == 5)
        cout << 0 << "\\n";
      else if (i == 6)
        cout << 1 << "\\n";
      else {
        ll cnt = 0;
        for (int x = 1; x <= sqrt(i); x++) {
          for (int j = 1; j <= sqrt(i); j++) {
            for (int k = 1; k <= sqrt(i); k++) {

              int n1 = x * x + j * j + k * k + x * j + j * k + k * x;
              if (n1 == i)
                cnt++;
            }
          }
        }
        cout << cnt << "\\n";
      }
    }
  }
}
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 main() {
  int n;
  cin >> n;

  for (int i = 1; i < n + 1; i++) {
    int count = 0;
    for (int x = 1; x < 101; x++) {
      for (int y = 1; y < x + 1; y++) {
        for (int z = 1; z < y + 1; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x > i)
            break;
          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            if (x == y && y == z && z == x)
              count++;
            else if (x != y && y != z && z != x)
              count += 6;
            else
              count += 3;
          }
        }
      }
    }
    cout << count << 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 main() {
  int n;
  cin >> n;

  for (int i = 1; i < n + 1; i++) {
    int count = 0;
    for (int x = 1; x < 101; x++) {
      for (int y = 1; y < x + 1; y++) {
        for (int z = 1; z < y + 1; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            if (x == y && y == z && z == x)
              count++;
            else
              count += 3;
          }
        }
      }
    }
    cout << count << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#define ll long long int

#include <bits/stdc++.h>

using namespace std;

int main() {

  int N;
  cin >> N;
  map<ll, int> mp;

  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++) {

        mp[((x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x))]++;
      }
    }
  }
  for (int i = 1; i <= N; i++)
    cout << mp[i] << endl;

  return 0;
}

Error: TLE

Fixed submission:

#define ll long long int

#include <bits/stdc++.h>

using namespace std;

int main() {

  int N;
  cin >> N;
  for (int i = 1; i <= N; i++) {

    ll cnt = 0;
    for (int x = 1; x * x <= i; x++) {

      for (int y = 1; y * y <= i - (x * x); y++) {

        for (int z = 1; z * z <= i - ((x * x) + (y * y)); z++) {

          if (((x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x)) == i)
            cnt++;
        }
      }
    }

    cout << cnt << "\\n";
  }

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

#include <cmath>
#include <iostream>

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

int f(int n) {
  int num = 0;
  for (int x = 1; x < sqrt(n); x++)
    for (int y = 1; calc(x, y, 1) <= n; y++)
      for (int z = 1; calc(x, y, z) <= n; z++)
        if (calc(x, y, z) == n) {
          // std::cout << "(" << x << "," << y << "," << z << ")" << std::endl;
          num++;
        }

  return num;
}

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

  for (int i = 1; i <= N; i++)
    std::cout << f(i) << std::endl;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>

int f(int n) {
  int num = 0;
  for (int x = 1; x < sqrt(n); x++)
    for (int y = 1; y < sqrt(n); y++)
      for (int z = 1; z < sqrt(n); z++)
        if (x * x + y * y + z * z + x * y + y * z + z * x == n) {
          // std::cout << "(" << x << "," << y << "," << z << ")" << std::endl;
          num++;
        }

  return num;
}

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

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

//
//  main.cpp
//  AISING2020C
#include <cmath>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;
ll ans[11234] = {};
void f(int n) {
  ll sums = 0;
  for (int x = 1; x < (int)sqrt(n); x++) {
    for (int y = 1; y < (int)sqrt(n); y++) {
      for (int z = 1; z < (int)sqrt(n); z++) {
        sums = x * x + y * y + z * z + x * y + y * z + z * x;
        if (sums > n)
          break;
        ans[sums]++;
      }
    }
  }
}
int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  f(n);
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

//
//  main.cpp
//  AISING2020C
#include <cmath>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;
ll f(int n) {
  ll sums = 0;
  ll ans = 0;
  for (int x = 1; x < (int)sqrt(n); x++) {
    for (int y = 1; y < (int)sqrt(n); y++) {
      for (int z = 1; z < (n - x * x - y * y); z++) {
        sums = x * x + y * y + z * z + x * y + y * z + z * x;
        if (sums == n)
          ans++;
      }
    }
  }
  return ans;
}
int main(int argc, const char *argv[]) {
  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;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
#define int long long

signed main() {
  int N;
  cin >> N;
  for (int n = 1; n <= N; n++) {
    int cnt = 0;
    for (int x = 1; x * x <= n; x++) {
      for (int y = 1; y * y + x * x + x * y <= n; y++) {
        int b = x + y;
        int c = x * x + y * y + x * y - n;
        int tmp = sqrt(b * b - 4 * c) + 0.05;
        int z = (-b + tmp) / 2;
        for (int p = z - 10; p <= z + 10; p++) {
          if (p < 1)
            continue;
          ll sum = x * x + y * y + p * p + x * y + y * p + p * x;
          if (sum == n)
            cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
#define int long long

signed main() {
  int N;
  cin >> N;
  for (int n = 1; n <= N; n++) {
    int cnt = 0;
    for (int x = 1; x * x <= n; x++) {
      for (int y = 1; y * y + x * x + x * y <= n; y++) {
        int b = x + y;
        int c = x * x + y * y - n;
        int tmp = sqrt(b * b - 4 * c) + 0.05;
        int z = (-b + tmp) / 2;
        for (int p = z - 1000; p <= z + 1000; p++) {
          if (p < 1)
            continue;
          ll sum = x * x + y * y + p * p + x * y + y * p + p * x;
          if (sum == n)
            cnt++;
        }
      }
    }
    cout << cnt << 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 < (n); i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

signed main() {
  int N;
  cin >> N;
  vector<int> ans(N + 1);
  for (int i = 1; i * i <= N; i++) {
    for (int j = 1; j * j <= N; j++) {
      for (int k = 1; k * k <= N; k++) {
        int sum = i * i + j * j + k * k + i * j + i * k + k * j;
        if (sum <= N)
          ans[sum]++;
      }
    }
  }
  for (int i = 1; i <= N; i++)
    cout << ans[i] << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

signed main() {
  int N;
  cin >> N;
  vector<int> ans(N + 1, 0);
  for (int i = 1; i * i <= N; i++) {
    for (int j = 1; j * j <= N; j++) {
      for (int k = 1; k * k <= N; k++) {
        int sum = i * i + j * j + k * k + i * j + i * k + k * j;
        ans[sum]++;
      }
    }
  }
  for (int i = 1; i <= N; i++)
    cout << ans[i] << endl;
}