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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 // 10^14
template <typename T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  ll N;
  cin >> N;
  vector<ll> f(N, 0);
  rep2(i, 1, N + 1) {
    rep2(j, 1, min(100, (int)(sqrt(i) + 1))) {
      rep2(k, j, min(100, (int)(sqrt(i) + 1))) {
        rep2(l, k, min(100, (int)(sqrt(i) + 1))) {
          if (j * j + k * k + l * l + j * k + k * l + l * j == i) {
            if (j == k && k == l) {
              f.at(i - 1)++;
            } else if (j == k && k < l) {
              f.at(i - 1) += 3;
            } else if (j < k && k == l) {
              f.at(i - 1) += 3;
            } else {
              f.at(i - 1) += 6;
            }
          }
        }
      }
    }
  }
  rep(i, N) { cout << f.at(i) << endl; }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 // 10^14
template <typename T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  ll N;
  cin >> N;
  vector<ll> f(N, 0);
  rep2(i, 1, N + 1) {
    rep2(j, 1, 100) {
      rep2(k, 1, 100) {
        rep2(l, 1, 100) {
          if (j * j + k * k + l * l + j * k + k * l + l * j == i) {
            f.at(i - 1)++;
          }
        }
      }
    }
  }
  rep(i, N) { cout << f.at(i) << endl; }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#include <iomanip>
#include <math.h>
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int INF = 1001001001;
vector<pair<int64_t, int64_t>> prime_factorize(int64_t x) {
  vector<pair<int64_t, int64_t>> p;
  for (int64_t i = 2; i * i <= x; i++) {
    int cnt = 0;
    if (x % i == 0) {
      while (x % i == 0) {
        cnt++;
        x /= i;
      }
      p.push_back(make_pair(i, cnt));
    }
  }
  if (x != 1) {
    p.push_back(make_pair(x, 1));
  }
  return p;
}

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

  vector<int> ans(100000);
  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 n = i * i + j * j + k * k + i * j + j * k + k * i;
        ans[n]++;
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#include <iomanip>
#include <math.h>
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int INF = 1001001001;
vector<pair<int64_t, int64_t>> prime_factorize(int64_t x) {
  vector<pair<int64_t, int64_t>> p;
  for (int64_t i = 2; i * i <= x; i++) {
    int cnt = 0;
    if (x % i == 0) {
      while (x % i == 0) {
        cnt++;
        x /= i;
      }
      p.push_back(make_pair(i, cnt));
    }
  }
  if (x != 1) {
    p.push_back(make_pair(x, 1));
  }
  return p;
}

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

  for (int n = 1; n <= N; n++) {
    int cnt = 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++) {
          if (i * i + j * j + k * k + i * j + j * k + k * i == n) {
            cnt++;
          }
        }
      }
    }
    cout << cnt << endl;
  }

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

#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

const vector<LLONG> Comp(const LLONG n) {
  vector<LLONG> ret(n, 0);
  for (LLONG x = 1; x * x < n; ++x) {
    for (LLONG y = 1; x * x + y * y < n; ++y) {
      for (LLONG z = 1; x * x + y * y + z * z < n; ++z) {
        LLONG val = x * x + y * y + z * z + x * y + y * z + z * x;
        if (val <= n) {
          ++ret[val - 1];
        }
      }
    }
  }
  return ret;
}

int main() {
  LLONG N;
  cin >> N;
  auto ans = Comp(N);
  for (auto i : ans) {
    cout << i << endl;
  }
}

Error: TLE

Fixed submission:

#pragma GCC optimize("Ofast")
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

const LLONG f(const LLONG n) {
  LLONG ret = 0;
  for (LLONG x = 1; x * x < n; ++x) {
    for (LLONG y = 1; x * x + y * y < n; ++y) {
      for (LLONG z = 1; x * x + y * y + z * z < n; ++z) {
        if (x * x + y * y + z * z + x * y + y * z + z * x == n) {
          ++ret;
        }
      }
    }
  }
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  LLONG N;
  cin >> N;
  for (LLONG n = 1; n <= N; ++n) {
    cout << f(n) << '\\n';
  }
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N = 10010;
  vector<int> vec(N);
  int n;
  cin >> n;
  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 a = i * i + j * j + k * k;
        int b = i * j + j * k + k * i;
        if (a + b >= N)
          break;

        vec.at(a + b)++;
      }
    }
  }

  for (int i = 1; i < n + 1; i++) {
    cout << vec.at(i) << endl;
  }
}


Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 10010) >= this->size() (which is 10010)


Fixed submission:

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

int main() {
  int N = 10010;
  vector<int> vec(N);
  int n;
  cin >> n;
  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 a = i * i + j * j + k * k;
        int b = i * j + j * k + k * i;
        if (a + b > N)
          break;

        vec.at(a + b)++;
      }
    }
  }

  for (int i = 1; i < n + 1; i++) {
    cout << vec.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++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
int main() {
  int n;
  cin >> n;
  ll ans[10005] = {};
  for (ll x = 1; x * x <= n; x++) {
    for (ll y = 1; y * y <= n; y++) {
      for (ll z = 1; z * z <= n; z++) {
        ll value = x * x + y * y + z * z + x * y + y * z + z * x;
        if (value <= n) {
          ans[value]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

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

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1, 0);

  for (int x = 1; x <= n; ++x) {
    for (int y = 1; y <= n; ++y) {
      for (int z = 1; z <= n; ++z) {
        if (x * x + y * y + z * z + x * y + y * z + z * x <= n) {
          a[x * x + y * y + z * z + x * y + y * z + z * x]++;
        } else {
          break;
        }
      }
    }
  }

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

  return 0;
}

Error: TLE

Fixed submission:

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

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

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

int main() {

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

Error: TLE

Fixed submission:

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

int main() {

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

#include <cstdio>
int n, f[11000], data[101][101][101];
void check(int x, int y, int z) {
  int tmp = x * x + y * y + z * z + x * y + y * z + z * x;
  if (tmp > n)
    return;
  data[x][y][z] = 1;
  if (!data[x + 1][y][z])
    check(x + 1, y, z);
  if (!data[x][y + 1][z])
    check(x, y + 1, z);
  if (!data[x][y][z + 1])
    check(x, y, z + 1);
}
int main() {
  scanf("%d", &n);
  check(1, 1, 1);
  for (int i = 1; i <= 100; ++i)
    for (int j = 1; j <= 100; ++j)
      for (int k = 1; k <= 100; ++k)
        if (data[i][j][k])
          f[i * i + j * j + k * k + i * j + j * k + k * i]++;
  for (int i = 1; i <= n; ++i)
    printf("%d\\n", f[i]);
  return 0;
}

Error: 0

Fixed submission:

#include <cstdio>
int n, f[1100], data[101][101][101];
void check(int x, int y, int z) {
  int tmp = x * x + y * y + z * z + x * y + y * z + z * x;
  if (tmp > n)
    return;
  data[x][y][z] = 1;
  if (!data[x + 1][y][z])
    check(x + 1, y, z);
  if (!data[x][y + 1][z])
    check(x, y + 1, z);
  if (!data[x][y][z + 1])
    check(x, y, z + 1);
}
int main() {
  scanf("%d", &n);
  check(1, 1, 1);
  for (int i = 1; i <= 100; ++i)
    for (int j = 1; j <= 100; ++j)
      for (int k = 1; k <= 100; ++k)
        if (data[i][j][k])
          f[i * i + j * j + k * k + i * j + j * k + k * i]++;
  for (int i = 1; i <= n; ++i)
    printf("%d\\n", f[i]);
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

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

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

  vector<int> count(N, 0);

  int max;
  for (int i = 0; i < N; i++) {
    if (i * i > N) {
      max = i - 1;
      break;
    }
  }
  if (N == 1) {
    max = 1;
  }

  // これでmax求まった

  int value;

  for (int i = 1; i <= max; i++) {
    for (int j = 1; j <= max; j++) {
      if (i * i + j * j + i * j + i + j + 1 > N)
        break;
      for (int k = 1; k <= max; k++) {
        value = i * i + j * j + k * k + i * j + j * k + k * i;
        if (value > N)
          break;
        count.at(value - 1)++;
      }
    }
  }

  for (int i = 0; i < N; i++) {
    cout << count.at(i) << endl;
  }
}


Error: WA

Fixed submission:

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

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

  vector<int> count(N, 0);

  int max;
  for (int i = 0; i < N; i++) {
    if (i * i > N) {
      max = i - 1;
      break;
    }
  }
  if (N == 1) {
    max = 1;
  }

  // これでmax求まった

  int value;

  for (int i = 1; i <= max; i++) {
    for (int j = 1; j <= max; j++) {
      if (i * i + j * j + i * j + i + j + 1 > N)
        break;
      for (int k = 1; k <= max; k++) {
        value = i * i + j * j + k * k + i * j + j * k + k * i;
        if (value > N)
          break;
        count.at(value)++;
      }
    }
  }

  for (int i = 0; i < N; i++) {
    cout << count.at(i) << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

void solve(int n) {
  int ans[100050] = {};
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        int l = i * i + j * j + k * k + i * j + j * k + k * i;
        ans[l - 1]++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
}

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

Error: TLE

Fixed submission:

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

int f(int a);

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

int f(int a) {
  int ans = 0;
  for (int p = 1; p < sqrt(a); p++) {
    for (int q = 1; q < sqrt(a); q++) {
      for (int r = 1; r < sqrt(a); r++) {
        if ((p * p + q * q + r * r + p * q + q * r + p * r) == a) {
          ans++;
        }
      }
    }
  }
  return ans;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

bool is_integer(double x) { return floor(x) == x; }

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

  for (int i = 1; i <= N; i++) {
    int sum = 0;
    for (int j = 1; j < sqrt(i); j++) {
      for (int k = 1; k < sqrt((i - pow(j, 2) - j - 1)); k++) {
        double sq =
            sqrt(pow((k + j), 2) + 4 * (i - pow(j, 2) - pow(k, 2) - k * j));
        if (!is_integer(sq)) {
          continue;
        }
        int la = (-(k + j) + sq) / 2, lb = (-(k + j) - sq) / 2;
        if (j >= k && k >= la && la >= 1) {
          if (j == k && k == la && la == j) {
            sum += 1;
          } else if (j == k || k == la || la == j) {
            sum += 3;
          } else {
            sum += 6;
          }
        }
        if (j >= k && k >= lb && lb >= 1) {
          if (j == k && k == lb && lb == j) {
            sum += 1;
          } else if (j == k || k == lb || lb == j) {
            sum += 3;
          } else {
            sum += 6;
          }
        }
      }
    }
    cout << sum << 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 sum = 0;
    for (int j = 1; j < sqrt(i); j++) {
      for (int k = 1; k < sqrt((i - pow(j, 2) - j - 1)); k++) {
        if (pow((k + j), 2) + 4 * (i - pow(j, 2) - pow(k, 2) - k * j) < 0) {
          continue;
        }
        for (int l = 1; l < sqrt((i - pow(j, 2) - pow(k, 2) - k * j)); l++) {
          if (pow(l, 2) + (k + j) * l == i - pow(j, 2) - pow(k, 2) - k * j) {
            if (j >= k && k >= l) {
              if (j == k && k == l && l == j) {
                sum += 1;
              } else if (j == k || k == l || l == j) {
                sum += 3;
              } else {
                sum += 6;
              }
            }
          }
        }
      }
    }
    cout << sum << endl;
  }
}
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(10001);
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int tmp = x * x + y * y + z * z + x * y + y * z + x * z;
        if (tmp <= 10000)
          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 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 + x * z == i)
            ans++;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

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

long long a[20005] = {0};

int main() {
  long long n, ans = 0, t;
  scanf("%lld", &n);
  for (long long i = 1; i < 105 && i <= n; i++) {
    // printf("hhh");
    for (long long j = 1; j < 105 && j <= n; j++) {
      for (long long k = 1; k < 105 && k <= n; k++) {
        t = i * i + j * j + k * k + i * j + i * k + j * k;
        if (t < 10005)
          a[t]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%lld\\n", a[i]);
  }
}


Error: -11

Fixed submission:

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

int a[2005] = {0};

int main() {
  long long n, ans = 0, t;
  scanf("%lld", &n);
  for (int i = 1; i < 105 && i <= n; i++) {
    // printf("hhh");
    for (int j = 1; j < 105 && j <= n; j++) {
      for (int k = 1; k < 105 && k <= n; k++) {
        t = i * i + j * j + k * k + i * j + i * k + j * k;
        a[t]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d\\n", a[i]);
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  t = 1;
  while (t--) {
    long long n, i, c = 0, x, j, k;
    map<long long, long long> m;
    cin >> n;
    for (i = 1; i <= 1000; i++) {
      for (j = 1; j <= 1000; j++) {
        for (k = 1; k <= 1000; k++) {
          x = i * i + j * j + k * k + (i * j) + (j * k) + (k * i);
          if (x <= 10000) {
            m[x]++;
          }
        }
      }
    }
    for (i = 1; i <= n; i++) {
      cout << m[i] << endl;
    }
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  t = 1;
  while (t--) {
    long long n, i, c = 0, x, j, k;
    map<long long, long long> m;
    cin >> n;
    for (i = 1; i <= 1000; i++) {
      for (j = 1; j <= 1000; j++) {
        for (k = 1; k <= 1000; k++) {
          x = i * i + j * j + k * k + (i * j) + (j * k) + (k * i);

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

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

int main() {
  ll n;
  cin >> n;
  map<ll, ll> m;
  ll x, y, z, a;
  for (ll x = 1; x <= 100; x++) {
    for (ll y = 1; y <= 100; y++) {
      for (ll z = 1; z <= 100; z++) {
        a = x * x + y * y + z * z + x * y + x * z + y * z;
        m[a]++;
      }
    }
  }

  for (ll i = 1; i <= n; i++) {

    cout << m[i] << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll func(ll n) {
  ll x, y, z, a, c = 0;
  // for(ll x=1,y=1,z=1;x<=n,y<=n,z<=n;x++,y++,z++)
  for (ll x = 1; x <= n; x++) {
    for (ll y = 1; y <= n; y++) {
      for (ll z = 1; z <= n; z++) {
        a = x * x + y * y + z * z + x * y + x * z + y * z;
        if (a == n)
          c++;
      }
    }
  }
  return c;
}

int main() {
  ll n;
  cin >> n;
  ll x, y, z;
  for (ll i = 1; i <= n; i++) {

    ll a = func(i);
    cout << a << endl;
  }

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

#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10005;
int res[MAXN];
int main() {
  int n;
  scanf("%d", &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++) {
        int t = x * x + y * y + z * z + x * y + y * z + z * x;
        if (t < MAXN)
          res[t]++;
      }
  for (int i = 1; i <= n; i++)
    printf("%d\\n", res[i]);
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int res[10005];
int main() {
  int n;
  scanf("%d", &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++)
        res[x * x + y * y + z * z + x * y + y * z + z * x]++;
  for (int i = 1; i <= n; i++)
    printf("%d\\n", res[i]);
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  vector<int> ans(n);

  int max = sqrt(n);
  // bool over_x, over_y, over_z;
  int tmp = 0;

  for (int i = 6; i <= n; i++) {

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

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

        for (int z = 1; z <= max; z++) {
          tmp = x * x + y * y + z * z + x * y + y * z + z * x;
          if (tmp > i)
            break;
          if (tmp == i)
            ans.at(i - 1)++;
        }
      }
    }
  }

  arep(x, ans) cout << x << endl;
}

Error: TLE

Fixed submission:

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

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

  vector<int> ans(n);

  int max = sqrt(n);
  // bool over_x, over_y, over_z;
  int tmp = 0;

  for (int i = 6; i <= n; i++) {

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

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

        for (int z = 1; z <= max; z++) {
          tmp = x * x + y * y + z * z + x * y + y * z + z * x;

          if (tmp == i)
            ans.at(i - 1)++;
        }
      }
    }
  }

  arep(x, ans) cout << x << endl;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n;
  cin >> n;
  vector<int> ans(100000000);
  for (int i = 1; i <= sqrt(n); i++) {
    for (int j = 1; j <= sqrt(n); j++) {
      for (int k = 1; k <= sqrt(n); k++) {
        ans[i * i + j * j + k * k + i * j + j * k + k * i]++;
      }
    }
  }
  for (int i = 1; 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 <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;
  vector<int> ans(1000000000);
  for (int i = 1; i < n; i++) {
    for (int j = 1; j < n; j++) {
      for (int k = 1; k < n; k++) {
        ans[i * i + j * j + k * k + i * j + j * k + k * i]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << ans[i] << endl;
  return 0;
}