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

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <list>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  int cou = 0;
  for (int n = 1; n <= N; n++) {
    for (int x = 1; x < n; x++) {
      if (n < x * x)
        break;
      for (int y = 1; y < n - x; y++) {
        if (n < x * x + y * y + x * y || n < x * x)
          break;
        for (int z = 1; z < n - x - y; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x > n || n < x * x ||
              n < x * x + y * y + x * y) {
            break;
          }
          if (x * x + y * y + z * z + x * y + y * z + z * x == n) {
            cou++;
          }
        }
      }
    }
    cout << cou << endl;
    cou = 0;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <list>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  int cou = 0;
  for (int n = 1; n <= N; n++) {
    for (int x = 1; x < n; x++) {
      if (n < x * x)
        break;
      for (int y = 1; y < n - x; y++) {
        if (n < x * x + y * y + x * y)
          break;
        for (int z = 1; z < n - x - y; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x > n) {
            break;
          }
          if (x * x + y * y + z * z + x * y + y * z + z * x == n) {
            cou++;
          }
        }
      }
    }
    cout << cou << endl;
    cou = 0;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PP;
#define MOD 1000000007
// #define MOD 998244353
#define INF 1145141919810893364
// #define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define OREP(i, n) for (ll i = 1; i <= (n); ++i)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; --i)
#define GOODBYE                                                                \\
  do {                                                                         \\
    cout << "0" << endl;                                                       \\
    return 0;                                                                  \\
  } while (false)
#define MM << " " <<
#define Endl endl
#define debug false
#define debug2 false

int main(void) {
  ll N;
  cin >> N;
  vector<ll> Ans(N + 10, 0);

  for (ll x = 1; x <= N; x++) {
    for (ll y = 1; y <= N; y++) {
      if ((x + y) * (x + y) > 2 * N)
        break;
      for (ll z = 1; z <= N; z++) {
        if ((x + z) * (x + z) > 2 * N)
          break;
        if ((z + y) * (z + y) > 2 * N)
          break;

        ll R = (x + y) * (x + y) + (z + y) * (z + y) + (x + z) * (x + z);
        if (R % 2 == 1)
          continue;
        if (R / 2 > N + 5)
          continue;
        Ans[R / 2]++;
      }
    }
  }

  REP(i, N) { cout << Ans[i + 1] << endl; }

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PP;
#define MOD 1000000007
// #define MOD 998244353
#define INF 1145141919810893364
// #define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define OREP(i, n) for (ll i = 1; i <= (n); ++i)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; --i)
#define GOODBYE                                                                \\
  do {                                                                         \\
    cout << "0" << endl;                                                       \\
    return 0;                                                                  \\
  } while (false)
#define MM << " " <<
#define Endl endl
#define debug false
#define debug2 false

int main(void) {
  ll N;
  cin >> N;
  vector<ll> Ans(N + 1, 0);

  for (ll x = 1; x <= N; x++) {
    for (ll y = 1; y <= N; y++) {
      if ((x + y) * (x + y) > 2 * N)
        break;
      for (ll z = 1; z <= N; z++) {
        if ((x + z) * (x + z) > 2 * N)
          break;
        if ((z + y) * (z + y) > 2 * N)
          break;

        ll R = (x + y) * (x + y) + (z + y) * (z + y) + (x + z) * (x + z);
        if (R % 2 == 1)
          continue;
        Ans[R / 2]++;
      }
    }
  }

  REP(i, N) { cout << Ans[i + 1] << endl; }

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

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;

#define INF 1e+9
#define MAX_V 300

struct edge {
  int to;
  int cost;
};
using P = pair<ll, ll>;

ll func(ll s) {
  ll ans = 0;
  for (ll x = 1; x < 102; x++) {
    for (ll y = 1; y < 102; y++) {
      for (ll z = 1; z < 102; z++) {
        ll tmp = x * x + y * y + z * z + x * z + y * z + x * y;
        if (tmp == s) {
          ans++;
          break;
        }
        if (tmp > s) {
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
int main() {
  ll n;
  cin >> n;
  for (ll i = 1; i <= n; i++) {
    func(i);
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;

#define INF 1e+9
#define MAX_V 300

struct edge {
  int to;
  int cost;
};
using P = pair<ll, ll>;

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

#include <algorithm>
#include <cmath>
#include <ctype.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rep(i, n) for (int i = 1; i <= n; i++)
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;

int main() {
  /*int l, r, d;
  cin >> l >> r >> d;
  cout << r / d - (l - 1) / d;*/

  /*int n;
  cin >> n;
  int a;
  int ans = 0;
  rep(i, n){
          cin >> a;
          if (i % 2 == 0 && a % 2 == 1)ans++;
  }
  cout << ans;*/

  int n;
  cin >> n;
  int rn = (int)sqrt(n) + 1;
  for (int i = 1; i <= n; i++) {
    ll ans = 0;
    rep(x, rn) rep(y, x) rep(z, y) {
      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 += 6;
        else
          ans += 3;
        break;
      }
    }
    cout << ans << "\\n";
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <ctype.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rep(i, n) for (int i = 1; i <= n; i++)
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;

int main() {
  /*int l, r, d;
  cin >> l >> r >> d;
  cout << r / d - (l - 1) / d;*/

  /*int n;
  cin >> n;
  int a;
  int ans = 0;
  rep(i, n){
          cin >> a;
          if (i % 2 == 0 && a % 2 == 1)ans++;
  }
  cout << ans;*/

  int n;
  cin >> n;
  int rn = (int)sqrt(n) + 1;
  for (int i = 1; i <= n; i++) {
    ll ans = 0;
    rep(x, rn) rep(y, rn) rep(z, rn) {
      if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
        ans++;
        break;
      }
    }
    cout << ans << "\\n";
  }

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

#include <iostream>
#include <stdio.h>
using namespace std;
int i, j, k, n;
static int a[60001];
int main() {
  for (i = 1; i < 100; i++)
    for (j = 1; j < 100; j++)
      for (k = 1; k < 100; k++)
        a[i * i + j * j + k * k + i * j + i * k + k * j]++;
  scanf("%d", &n);
  for (i = 1; i <= n; i++)
    printf("%d\\n", a[i]);
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
#include <stdio.h>
using namespace std;
long long int m, i, j, k, n, c = 0;
int main() {
  scanf("%d", &n);
  for (m = 1; m <= n; m++) {
    c = 0;
    for (i = 1; i < 100; i++)
      for (j = 1; j < 100; j++)
        for (k = 1; k < 100; k++)
          if (i * i + j * j + k * k + i * j + j * k + k * i == m)
            c++;
    printf("%d\\n", c);
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll n, counter = 0, a[100000] = {0};
  cin >> n;
  for (int j = 1; j * j <= n; j++) {
    for (int k = 1; k * k <= n; k++) {
      for (int l = 1; l * l <= n; l++) {
        a[j * j + k * k + l * l + j * k + k * l + l * j]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << '\\n';
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll n, counter = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    counter = 0;
    for (int j = 1; j * j <= i; j++) {
      for (int k = 1; k * k <= i; k++) {
        for (int l = 1; l * l <= i; l++) {
          if (j * j + k * k + l * l + j * k + k * l + l * j == i) {
            counter++;
          }
        }
      }
    }
    cout << counter << '\\n';
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  int n;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  unordered_map<int, int> um;
  int c = 0;
  int x = 100;
  for (int i = 1; i <= x; i++) {
    for (int j = 1; j <= (x); j++) {
      for (int k = 1; k <= (x); k++) {
        int val = i * i + j * j + k * k + i * j + j * k + k * i;
        um[val]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << um[i] << endl;
  }
}


Error: TLE

Fixed submission:

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

int make_result(int n) {
  int c = 0;
  int x = n;
  n = 55;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= (n); j++) {
      for (int k = 1; k <= (n); k++) {
        int val = i * i + j * j + k * k + i * j + j * k + k * i;
        if (val == x) {
          c++;
        }
      }
    }
  }
  return c;
}
int main() {
  int n;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cout << make_result(i) << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int N;
  int count;
  int root;
  int f;
  int xx, yy, xy;
  cin >> N;
  root = (int)sqrt(N);
  for (int n = 1; n <= N; n++) {
    count = 0;
    for (int x = 1; x <= root; x++) {
      xx = x * x;
      if (xx > n)
        break;
      for (int y = 1; y <= root; y++) {
        yy = y * y;
        xy = x * y;
        if ((xx + yy + xy) > n)
          break;
        for (int z = 1; z <= root; z++) {
          f = xx + yy + xy + (x + y + z) * z;
          if (f > n)
            break;
          if (f == n) {
            count++;
          }
        }
      }
    }
    cout << count << endl;
  }
  return (0);
}


Error: TLE

Fixed submission:

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

int main() {
  int N;
  int count;
  int root;
  int f;
  int xx, yy, xy;
  cin >> N;
  root = (int)sqrt(N);
  for (int n = 1; n <= N; n++) {
    count = 0;
    for (int x = 1; x <= root; x++) {
      xx = x * x;
      for (int y = 1; y <= root; y++) {
        yy = y * y;
        xy = x * y;
        for (int z = 1; z <= root; z++) {
          f = xx + yy + xy + (x + y + z) * z;
          if (f == n) {
            count++;
          }
        }
      }
    }
    cout << count << endl;
  }
  return (0);
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

/*input
20
*/
#include <bits/stdc++.h>

using namespace std;

const int N = 1e6 + 2;

int res[N];

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int n;
  cin >> n;

  int m = (int)sqrt(n) + 1;
  for (int x = 1; x <= m; ++x) {
    for (int y = 1; y <= m; ++y) {
      for (int z = 1; z <= m; ++z) {
        res[f(x, y, z)]++;
      }
    }
  }

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

  return 0;
}

Error: 0

Fixed submission:

/*input
20
*/
#include <bits/stdc++.h>

using namespace std;

const int N = 1e4 + 2;

int res[N];

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int n;
  cin >> n;

  int m = (int)sqrt(n) + 1;
  for (int x = 1; x <= m; ++x) {
    for (int y = 1; y <= m; ++y) {
      for (int z = 1; z <= m; ++z) {
        res[f(x, y, z)]++;
      }
    }
  }

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

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

#include <bits/stdc++.h>

typedef long long ll;

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout << i << endl;
#define AS(i) cout << i << " ";

const int INF = 1001001001;
const double PI = 3.14159;

using namespace std;

int main() {

  int n;
  cin >> n;

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

    int ans = 0;

    int MM = (int)sqrt(i);

    for (int j = 1; j < MM; j++) {
      for (int k = j; k < MM; k++) {
        for (int l = k; l < MM; l++) {

          if (pow(j + k + l, 2) - j * k - j * l - k * l == i) {

            if (j == k && j == l && k == l)
              ans++;
            else if (j == k || j == l || k == l)
              ans += 3;
            else
              ans += 6;
          }
        }
      }
    }

    AA(ans);
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

typedef long long ll;

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout << i << endl;
#define AS(i) cout << i << " ";

const int INF = 1001001001;
const double PI = 3.14159;

using namespace std;

int main() {

  int n;
  cin >> n;

  int MM = (int)sqrt(n);

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

    int ans = 0;

    for (int j = 1; j < MM; j++) {
      for (int k = j; k < MM; k++) {
        for (int l = k; l < MM; l++) {

          if (pow(j + k + l, 2) - j * k - j * l - k * l == i) {

            if (j == k && j == l && k == l)
              ans++;
            else if (j == k || j == l || k == l)
              ans += 3;
            else
              ans += 6;
          }
        }
      }
    }

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

#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  int ctr[10001] = {0};
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        int temp = i * i + j * j + k * k + i * j + j * k + i * k;
        if (temp <= 10000) {
          ctr[temp]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d\\n", ctr[i]);
  }
  return 0;
}

Error: 0

Fixed submission:

#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  int ctr[1001] = {0};
  for (int i = 1; i <= 50; i++) {
    for (int j = 1; j <= 50; j++) {
      for (int k = 1; k <= 50; k++) {
        int temp = i * i + j * j + k * k + i * j + j * k + i * k;
        if (temp <= 1000) {
          ctr[temp]++;
        }
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    printf("%d\\n", ctr[i]);
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

// #define int long long
// signed main(){
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    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 + z * x;
          if (tmp > i)
            break;
          if (i == tmp)
            cnt++;
        }
      }
    }
    cout << cnt << "\\n";
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

// #define int long long
// signed main(){
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    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 + z * x;
          if (tmp > n)
            break;
          if (i == tmp)
            cnt++;
        }
      }
    }
    cout << cnt << "\\n";
  }

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

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

using ll = long long;

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

  for (ll n = 1; n <= N; n++) {
    ll ans = 0;
    for (ll x = 1; x <= n; x++) {
      for (ll y = 1; n - (x * x + y * y + x * y) > 0; y++) {

        ll pre = x * x + y * y + x * y;
        ll ok = n;
        ll ng = 0;
        while (ok - ng > 1) {
          ll z = (ng + ok) / 2;

          if (n - pre <= z * z + y * z + z * x)
            ok = z;
          else
            ng = z;
        }
        ll z = ok;
        if (n - pre == z * z + y * z + z * x) {
          ans++;
        }
      }
    }
    cout << ans << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

using ll = long long;

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

  for (ll n = 1; n <= N; n++) {
    ll ans = 0;
    for (ll x = 1; x <= n; x++) {
      for (ll y = 1; y <= n; y++) {

        ll pre = x * x + y * y + x * y;
        if (n - pre <= 0) {
          continue;
        }

        ll ok = n;
        ll ng = 0;
        while (ok - ng > 1) {
          ll z = (ng + ok) / 2;

          if (n - pre <= z * z + y * z + z * x)
            ok = z;
          else
            ng = z;
        }
        ll z = ok;
        if (n - pre == z * z + y * z + z * x) {
          ans++;
        }
      }
    }
    cout << ans << endl;
  }

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

/*
QUESTION    :

RULE        :

INPUT       :

OUTPUT      :
*/
/*
    int     :10^9
long long   :10^19
*/
// kotatsugameさん解答
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < (n); ++i)
#define repeq(i, a, n) for (int i = a; i <= (n); ++i)
using namespace std;
using ll = long long int;
using P = pair<int, int>;
const long double PI = (acos(-1));

int cnt[10001];
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) {
        int t = i * i + j * j + k * k + i * j + j * k + k * i;
        if (t <= n)
          cnt[t]++;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    cout << cnt[i] << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

/*
QUESTION    :

RULE        :

INPUT       :

OUTPUT      :
*/
/*
    int     :10^9
long long   :10^19
*/
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < (n); ++i)
#define repeq(i, a, n) for (int i = a; i <= (n); ++i)
using namespace std;
using ll = long long int;
using P = pair<int, int>;
const long double PI = (acos(-1));

ll f(ll n) {
  ll ans = 0;
  ll tmp = sqrt(n);
  for (int i = 1; i < tmp; ++i) {
    if (i * i > n)
      break;
    for (int j = 1; j < tmp; ++j) {
      if (i * i + j * j + i * j > n)
        break;
      for (int k = 1; k < tmp; ++k) {
        ll a = i * i + j * j + k * k + i * j + j * k + i * k;
        if (a == n)
          ans++;
      }
    }
  }
  return ans;
}

int main() {
  int n;
  cin >> n;
  repeq(i, 1, n) { cout << f(i) << endl; }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {

  long long N;
  cin >> N;
  vector<long long> a(N);
  int i = 0;
  for (i = 0; i < N; i++) {
    a[i] = 0;
  }
  int j = 0;
  int v = 1

      ;
  int ans = 0;
  for (i = 1; i < sqrt(N); i++) {
    for (j = 1; j < sqrt(N); j++) {
      for (v = 1; v < sqrt(N); v++) {
        ans = i * i + j * j + v * v + i * j + j * v + i * v;
        if (ans <= N) {
          a[ans - 1]++;
        }
      }
    }
  }

  for (i = 0; i < N; i++) {
    cout << a[i] << endl;
  }
}

Error: TLE

Fixed submission:

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

int main() {

  long long N;
  cin >> N;
  vector<long long> a(N);
  int i = 0;
  for (i = 0; i < N; i++) {
    a[i] = 0;
  }
  int j = 0;
  int v = 0;
  int ans = 0;
  for (i = 1; i < N / 2; i++) {
    for (j = 1; j < N / 2; j++) {
      for (v = 1; v < N / 2; v++) {
        ans = i * i + j * j + v * v + i * j + j * v + i * v;
        if (ans <= N) {
          a[ans - 1]++;
        }
      }
    }
  }

  for (i = 0; i < N; i++) {
    cout << a[i] << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
int ans[10007];
int main() {
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int a = x + y, b = y + z, c = x + z;
        int t = a * a + b * b + c * c;
        if (t <= 20000 && t % 2 == 0)
          ans[t / 2]++;
      }
    }
  }
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    printf("%d\\n", ans[i]);
}


Error: 0

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
int ans[1007];
int main() {
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int a = x + y, b = y + z, c = x + z;
        int t = a * a + b * b + c * c;
        if (t <= 2000 && t % 2 == 0)
          ans[t / 2]++;
      }
    }
  }
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    printf("%d\\n", ans[i]);
}