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

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

const ll mod = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void) {
  ll n;
  cin >> n;
  vector<ll> s(10050, 0);
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        ll x = i * i + j * j + k * k + i * j + j * k + k * i;
        if (x <= n)
          s[x]++;
      }
    }
  }
  rep(i, n) cout << s[i + 1] << endl;
  return 0;
}

Error: -11

Fixed submission:

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

const ll mod = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void) {
  ll n;
  cin >> n;
  vector<ll> s(10050, 0);
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        ll x = i * i + j * j + k * k + i * j + j * k + k * i;
        // if(x > n) continue;
        s[x]++;
      }
    }
  }
  rep(i, n) cout << s[i + 1] << endl;
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define debug(x) cout << x
#define pb push_back
#include <string.h>
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll T = 1;
  // cin>>T;
  while (T--) {
    ll n, cnt = 0;
    cin >> n;
    ll arr[n + 1];
    for (int i = 0; i <= n; i++)
      arr[i] = 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)
            arr[(x * x + y * y + z * z + x * y + y * z + z * x)]++;
        }
      }
    }
    for (int i = 1; i <= n; i++)
      cout << arr[i] << endl;
  }
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define debug(x) cout << x
#define pb push_back
#include <string.h>
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll T = 1;
  // cin>>T;
  while (T--) {
    ll n, cnt = 0;
    cin >> n;
    ll arr[n + 1];
    for (int i = 0; i <= n; i++)
      arr[i] = 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++) {
          arr[(x * x + y * y + z * z + x * y + y * z + z * x)]++;
        }
      }
    }
    for (int i = 1; i <= n; i++)
      cout << arr[i] << endl;
    return 0;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <stdio.h>
#include <vector>

using ll = long long int;
const int INF = (1 << 30);
const ll INFLL = (1ll << 60);
const ll MOD = (ll)(1e9 + 7);

#define l_ength size

void mul_mod(ll &a, ll b) {
  a *= b;
  a %= MOD;
}

void add_mod(ll &a, ll b) {
  a = (a < MOD) ? a : (a - MOD);
  b = (b < MOD) ? b : (b - MOD);
  a += b;
  a = (a < MOD) ? a : (a - MOD);
}

ll ans[11111];

int main(void) {
  ll n, x, y, z, i;
  std::cin >> n;
  for (x = 1ll; x <= 200ll; ++x) {
    for (y = 1ll; y <= 200ll; ++y) {
      for (z = 1ll; z <= 200ll; ++z) {
        i = x * x + y * y + z * z + x * y + y * z + z * x;
        if (i <= n) {
          ++ans[i];
        }
      }
    }
  }
  for (i = 1ll; i <= n; ++i) {
    std::cout << ans[i] << std::endl;
  }
  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <stdio.h>
#include <vector>

using ll = long long int;
const int INF = (1 << 30);
const ll INFLL = (1ll << 60);
const ll MOD = (ll)(1e9 + 7);

#define l_ength size

void mul_mod(ll &a, ll b) {
  a *= b;
  a %= MOD;
}

void add_mod(ll &a, ll b) {
  a = (a < MOD) ? a : (a - MOD);
  b = (b < MOD) ? b : (b - MOD);
  a += b;
  a = (a < MOD) ? a : (a - MOD);
}

ll ans[1111];

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

#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  int total[100000];
  fill_n(total, 100000, 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++) {
        int num = x * x + y * y + z * z + x * y + y * z + z * x;
        total[num]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << total[i] << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  int total[10001];
  fill(total, total + 10001, 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++) {
        int num = x * x + y * y + z * z + x * y + y * z + z * x;
        total[num]++;
      }
    }
  }

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

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

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

  map<int, int> p;

  for (int x = 1; x < 100; x++) {
    int x2 = x * x;
    for (int y = 1; y < 100; y++) {
      int y2 = y * y;
      for (int z = 1; z < 100; z++) {
        int z2 = z * z;
        int n = x2 + y2 + z2 + x * y + y * z + z * x;
        p[n] += 1;
      }
    }
  }

  for (int n = 1; n <= N; n++) {
    if (p.count(n)) {
      cout << p[n] << endl;
    } else {
      cout << "0" << endl;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

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

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

  int n, x, y, z, r;
  int x2, y2, z2;
  int X, Y, Z;
  for (n = 1; n <= N; n++) {
    r = 0;
    X = (int)sqrt(n) + 1;
    for (x = 1; x <= X; x++) {
      x2 = x * x;
      if (x2 > n) {
        break;
      }
      Y = (int)sqrt(n - x2) + 1;
      for (y = 1; y <= Y; y++) {
        y2 = y * y;
        if ((x2 + y2) > n) {
          break;
        }
        Z = (int)sqrt(n - x2 - y2) + 1;
        for (z = 1; z <= Z; z++) {
          z2 = z * z;
          if ((x2 + y2 + z2) > n) {
            break;
          }
          int t1 = x2 + y2 + z2;
          int t2 = x * y + y * z + z * x;
          if ((t1 + t2) == n) {
            r++;
          }
        }
      }
    }
    cout << r << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

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

  vector<int> ans(n + 1);

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

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

  return 0;
}

Error: WA

Fixed submission:

#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

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++) {
        int e = x * x + y * y + z * z + x * y + y * z + z * x;
        ans[e]++;
      }
    }
  }

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

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

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

long ans(long n) {
  int cnt1 = 0, cnt2 = 0, cnt3 = 0, i, j, k;
  for (i = 1; i <= 100; i++) {
    for (j = i; j <= 100; j++) {
      for (k = j; k <= 100; k++) {
        long sum = i * i + j * j + k * k + i * j + j * k + k * i;
        if (sum == n) {
          if (i == j && j == k)
            cnt1++;
          else if (i == j || j == k || k == i)
            cnt2++;
          if (i != j && i != k && j != k)
            cnt3++;
        }
        if (sum > n)
          break;
      }
    }
  }
  return cnt1 + cnt2 * 3 + cnt3 * 6;
}

int main() {
  long n, cnt = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cout << ans(i) << endl;
  }
}

Error: TLE

Fixed submission:

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

long ans(long n) {
  int cnt1 = 0, cnt2 = 0, cnt3 = 0, i, j, k;
  for (i = 1; i <= n; i++) {
    for (j = i; j <= n; j++) {
      for (k = j; k <= n; k++) {
        long sum = i * i + j * j + k * k + i * j + j * k + k * i;
        if (sum == n) {
          if (i == j && j == k)
            cnt1++;
          else if (i == j || j == k || k == i)
            cnt2++;
          if (i != j && i != k && j != k)
            cnt3++;
        }
        if (sum > n)
          break;
      }
    }
  }
  return cnt1 + cnt2 * 3 + cnt3 * 6;
}

int main() {
  long n, cnt = 0;
  cin >> n;
  for (int i = 1; i <= n; i++)
    cout << ans(i) << 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 RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()

#define uint8_t unsigned char
#define uint16_t unsigned short
#define uint32_t unsigned int
#define uint64_t unsigned long long

#define int8_t signed char
#define int16_t signed short
#define int32_t signed int
#define int64_t signed long long

using namespace std;
// #define PI 3.14159265358979323846
// cout << fixed << setprecision(20);

int main(int argc, char const *argv[]) {
  int N = 0;
  int f[10001] = {};

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

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

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()

#define uint8_t unsigned char
#define uint16_t unsigned short
#define uint32_t unsigned int
#define uint64_t unsigned long long

#define int8_t signed char
#define int16_t signed short
#define int32_t signed int
#define int64_t signed long long

using namespace std;
// #define PI 3.14159265358979323846
// cout << fixed << setprecision(20);

int main(int argc, char const *argv[]) {
  int N = 0;
  int f[10001] = {};

  cin >> 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++) {
        f[x * x + y * y + z * z + x * y + y * z + z * x] += 1;
      }
    }
  }

  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 int long long
const int N = 1e5 + 5;
signed main() {
  int n;
  cin >> n;
  int sb[200005];
  int num = 0;
  memset(sb, 0, sizeof(sb));
  for (int j = 1; j <= 150; j++) {
    for (int z = 1; z <= 150; z++) {
      for (int y = 1; y <= 150; y++) {
        int t = pow(j, 2) + pow(z, 2) + pow(y, 2) + j * z + j * y + z * y;
        sb[t]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << sb[i] << '\\n';
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 5;
signed main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int num = 0;
    for (int j = 1; j <= sqrt(2 * i); j++) {
      for (int z = 1; z <= sqrt(2 * i); z++) {
        for (int y = 1; y <= sqrt(2 * i); y++) {
          if (pow(z + j, 2) + pow(z + y, 2) + pow(j + y, 2) == 2 * i)
            num++;
        }
      }
    }
    cout << num << "\\n";
  }
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array) / sizeof(array[0]))
using ll = long long;
using namespace std;
using Graph = vector<vector<int>>;
using Field = vector<vector<int>>;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  int n;
  cin >> n;
  vector<int> ans(10005, 0);
  for (int x = 1; x * x < 10000; ++x) {
    for (int y = 1; y * y < 10000; ++y) {
      for (int z = 1; z * z < 10000; ++z) {
        ll w = x * x + x * y + y * y + y * z + z * z + x * z;
        if (w <= n) {
          ++ans[w];
        }
      }
    }
  }
  for (ll i = 1; i <= n; ++i) {
    cout << ans[i] << endl;
  }
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array) / sizeof(array[0]))
using ll = long long;
using namespace std;
using Graph = vector<vector<int>>;
using Field = vector<vector<int>>;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  int n;
  cin >> n;
  vector<int> ans(10005, 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) {
        ll w = x * x + x * y + y * y + y * z + z * z + x * z;
        ans[w]++;
      }
    }
  }
  for (ll i = 1; i <= n; ++i) {
    cout << ans[i] << endl;
  }
}
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 (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end() // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   // 最大値を求める
#define MIN(x) *min_element(ALL(x))   // 最小値を求める

int main() {
  int N;
  cin >> N;
  FOR(i, 1, N) {
    int ans = 0;
    FOR(z, 1, sqrt((double)i / 6)) {
      FOR(y, z, sqrt((double)(i - z * z) / 3)) {
        FOR(x, y, sqrt(i - z * z - y * y - 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 || z == x)
              ans += 3;
            else
              ans += 6;
          }
        }
      }
    }
    printf("%d\\n", ans);
  }
  return 0;
}


Error: TLE

Fixed submission:

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

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end() // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   // 最大値を求める
#define MIN(x) *min_element(ALL(x))   // 最小値を求める

int main() {
  int N;
  cin >> N;
  FOR(i, 1, N) {
    int ans = 0;
    FOR(x, 1, sqrt(i)) {
      FOR(y, 1, sqrt(i - x * x)) {
        FOR(z, 1, sqrt(i - x * x - y * y)) {
          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: Time Limit Exceeded

#include <bits/stdc++.h>
#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 arr[n];
  for (int i = 0; i < n; i++)
    arr[i] = 0;
  for (int x = 1; (x * x) <= n; x++) {
    for (int y = 1; ((x * x) + (y * y) + (x * y)) <= n; y++) {
      for (int z = 1; f(x, y, z) <= n; z++) {
        int result = f(x, y, z);
        if (result <= n)
          arr[result - 1]++;
      }
    }
  }
  for (int i = 0; i < n; i++)
    cout << arr[i] << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

using namespace std;

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

#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <unordered_set>
#include <vector>
using namespace std;

int main(void) {
  long long N;

  cin >> N;

  for (long long i = 1; i <= N; ++i) {
    long long sum = 0;
    for (long long x = 1; x <= i - 4 - x * x; ++x) {
      for (long long y = 1; y <= i - 4 - y * y; ++y) {
        double d_z_1 = (-(x + y) + sqrt((x + y) * (x + y) -
                                        4 * (i - x * x - y * y - x * y))) /
                       2;
        double d_z_2 = (-(x + y) + sqrt((x + y) * (x + y) +
                                        4 * (i - x * x - y * y - x * y))) /
                       2;
        long long z = 0;
        if (d_z_1 < 1 || d_z_1 > i - 4 || d_z_1 - (long long)d_z_1 != 0.0) {
          if (d_z_2 < 1 || d_z_2 > i - 4 || d_z_2 - (long long)d_z_2 != 0.0) {
            continue;
          } else {
            z = (long long)d_z_2;
          }

        } else {
          z = (long long)d_z_1;
        }
        if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
          sum++;
        }
      }
    }
    cout << sum << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <functional>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <unordered_set>
#include <vector>
using namespace std;

int main(void) {
  long long N;

  cin >> N;

  for (long long i = 1; i <= N; ++i) {
    long long sum = 0;
    for (long long x = 1; x <= N - 4 - x * x; ++x) {
      for (long long y = 1; y <= N - 4 - y * y; ++y) {
        for (long long z = 1; z <= N - 4 - z * z; ++z) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            if (x == y && y == z) {
              sum = 1;
              break;
            }
            if (x != y && y != z && z != x) {
              sum = 6;
              break;
            } else {
              sum = 3;
              break;
            }
          }
        }
        if (sum != 0) {
          break;
        }
      }
      if (sum != 0) {
        break;
      }
    }
    cout << sum << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int Binary_Search(ll first, ll last, vector<ll> v, ll search_value) {
  int pos = -1;
  while (first <= last) {
    ll mid = first + ((last - first) / 2);
    if (v[mid] == search_value) {
      pos = mid;
      break;
    } else if (search_value > v[mid]) {
      first = mid + 1;
    } else {
      last = mid - 1;
    }
  }
  return pos;
}
ll gcd(ll a, ll b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

int main() {
  ll arr[10005] = {0};
  ll n;
  cin >> n;
  for (int i = 1; i <= 105; i++) {
    for (int j = 1; j <= 105; j++) {
      for (int k = 1; k <= 105; k++) {
        ll ans = (i * i) + (j * j) + (k * k) + (i * j) + (i * k) + (j * k);
        if (ans < 10005) {
          arr[ans] += 1;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << arr[i] << endl;
  }
  return 0;
}


Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int Binary_Search(ll first, ll last, vector<ll> v, ll search_value) {
  int pos = -1;
  while (first <= last) {
    ll mid = first + ((last - first) / 2);
    if (v[mid] == search_value) {
      pos = mid;
      break;
    } else if (search_value > v[mid]) {
      first = mid + 1;
    } else {
      last = mid - 1;
    }
  }
  return pos;
}
ll gcd(ll a, ll b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

int main() {
  ll arr[10005];
  for (int i = 1; i <= 10005; i++) {
    arr[i] = 0;
  }
  ll n;
  cin >> n;
  for (int i = 1; i <= 102; i++) {
    for (int j = 1; j <= 102; j++) {
      for (int k = 1; k <= 102; k++) {
        ll ans = (i * i) + (j * j) + (k * k) + (i * j) + (i * k) + (j * k);
        if (ans < n) {
          arr[ans] += 1;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << arr[i] << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  vector<int> ans(10010, 0);

  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int v = x * x + y * y + z * z + x * y + y * z + z * x;
        if (v <= 10000)
          ans[v]++;
      }
    }
  }

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

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 ans = 0;

    for (int x = 1; x <= 100; x++) {
      for (int y = 1; y <= 100; y++) {
        for (int z = 1; z <= 100; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i)
            ans++;
        }
      }
    }

    cout << ans << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int Cnt[1001000];
int main() {
  int N;
  cin >> N;
  for (int i = 1; i <= 100; i++)
    for (int j = 1; j <= 100; j++)
      for (int k = 1; k <= 100; k++)
        Cnt[i * i + j * j + k * k + i * j + j * k + i * k]++;
  for (int i = 1; i <= N; i++)
    cout << Cnt[i] << 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 Cnt = 0;
    int Tmp = i;
    for (int i1 = 1; i1 <= sqrt(Tmp); i1++) {
      int Tmp2 = Tmp - i1 * i1;
      for (int i2 = 1; i2 <= sqrt(Tmp2); i2++) {
        int Tmp3 = Tmp2 - i2 * i2;
        for (int i3 = 1; i3 <= sqrt(Tmp3); i3++)
          if (i1 * i1 + i2 * i2 + i3 * i3 + i1 * i2 + i2 * i3 + i3 * i1 == i)
            Cnt++;
      }
    }
    cout << Cnt << endl;
  }
  return 0;
}