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

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <unordered_set>
#include <valarray>
#include <vector>

#include <utility>

#include <deque>
#include <queue>

using namespace std;
long long a[10001];
int main() {
  long long n;
  cin >> n;
  long long x, y, z;
  long long counter;
  set<long long> numbers;
  for (int i = 1; i <= n; i++) {

    numbers.insert(i);
  }

  for (x = 1; x <= 98; x++) {

    for (y = 1; y <= 98; y++) {
      for (z = 1; z <= 98; z++) {
        long long c = (x * x) + (y * y) + (z * z) + (x * y) + (z * x) + (z * y);

        auto it = numbers.find(c);
        if (it != numbers.end()) {
          a[c]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int d(long long x) {
  int c = 0;
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        if (i * i + j * j + k * k + i * j + j * k + i * k == x) {
          c++;
        }
      }
    }
  }
  return c;
}
int main() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cout << d(i) << endl;
  }

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

/*
 *         ****FOX****
 */
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
// freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#include <algorithm>
#include <cstdio>
#include <forward_list>
#include <list>
#include <string>
#include <utility>
#define Omar_Hafez                                                             \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define pi 3.1415926536
#define ll long long
#define ull unsigned long long
#define lli long long int
using namespace std;
int main() {
  Omar_Hafez int n;
  cin >> n;
  vector<int> v(n, 0);
  for (int i = 1; i < 100; i++) {
    for (int j = 1; j < 100; j++) {
      for (int z = 1; z < 100; z++) {
        int res = (i * i) + (j * j) + (z * z) + (i * j) + (j * z) + (i * z);
        if (res <= n)
          v[--res]++;
        else
          break;
      }
    }
  }
  for (int i = 0; i < v.size(); i++)
    cout << v[i] << "\\n";
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
/*
int main(){
int n ,m ,k, x;
cin>>n>>m>>k;
int times = 0, total = 0 , best;
list<int>A;
for(int i = 0; i < n+m; i++){
    cin>>x;
    A.push_back(x);
}
for(list<int>::iterator it = A.begin(); it != A.end(); it++){
    total += *max_element(A.begin(),A.end());
    A.erase(max_element(A.begin(),A.end()));
    if(total <= k ){
        times++;
    }
    else{
        break;
    }

}
cout<<times<<endl;
    return 0;
}*/

bool check(int x, int y, int z, int n);
int main() {
  int n;
  cin >> n;
  vector<int> v(n, 0);
  int mo = 1;
  while (mo <= n) {
    for (int i = 1; i <= sqrt(mo); i++) {
      for (int j = 1; j <= sqrt(mo); j++) {
        for (int k = 1; k <= sqrt(mo); k++) {
          if (check(i, j, k, mo)) {
            v[mo - 1]++;
          }
        }
      }
    }
    mo++;
  }
  for (int i = 0; i < n; i++) {
    cout << v[i] << endl;
  }

  return 0;
}

bool check(int x, int y, int z, int n) {
  int q = x * x + y * y + z * z + x * y + y * z + z * x;
  return x >= 1 && y >= 1 && z >= 1 && q == n;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

/*
"اله السماء يعطينا النجاح ونحن عبيده نقوم ونبني"
"تكفيك نعمتي لان قوتي في الضعف تكمل"
created by shady rafet
my face book : https://www.facebook.com/profile.php?id=100019579575853
never give up
one day i will do it ':(

*/
#include <bits/stdc++.h>
using namespace std;
#define io                                                                     \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ul;
const ll oo = 1e18;
const ll N = 1e6;
const ll mod = 1e9 + 7;
#define point complex<double>
const double pi = acos(-1);
double dot(point a, point b) { return (conj(a) * b).real(); }
double cross(point a, point b) { return (conj(a) * b).imag(); }
ll inv[N], fact[N];
ll fb(ll x, ll y) {
  if (y == 0)
    return 1;
  ll ans = fb(x, y / 2);
  ans = (ans * ans) % mod;
  if (y % 2 != 0) {
    ans = (ans * (x % mod)) % mod;
  }
  return ans;
}
void pre(ll n) {
  fact[0] = 1;
  inv[0] = 1;
  for (int i = 1; i <= n; i++) {
    fact[i] = (i * fact[i - 1]) % mod;
    inv[i] = fb(fact[i], mod - 2);
  }
}
ll ncr(ll n, ll r) { return (((fact[n] * inv[n - r]) % mod) * inv[r]) % mod; }
ll npr(ll n, ll r) { return (fact[n] * inv[n - r]) % mod; }

int main() {
  io;
  map<int, int> me;
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        int x = (i * i) + (j * j) + (k * k) + (i * j) + (i * k) + (k * j);
        me[x]++;
      }
    }
  }
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++)
    cout << me[i] << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <iterator>
#include <math.h>
#include <set>
#include <vector>

#define lp(i, a, n) for (ll i = a; i < n; ++i)
#define rep(i, a, n) for (ll i = a; i <= n; ++i)
#define all(v) v.begin(), v.end()
#define clr(n, a) memset(n, a, sizeof(n))
#define vi vector<int>
#define sc set<char>
#define si set<int>
#define pb push_back
#define vb vector<bool>
#define pi(n) printf("%d\\n", n)
#define ln "\\n"
#define mahmoud_abdelsamie                                                     \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
bool check(ll a, ll b) { return (a >= 0 && b >= 0) || (a <= 0 && b <= 0); }

int main() {
  mahmoud_abdelsamie int n;
  cin >> n;
  rep(i, 1, n) {
    int cnt = 0;
    rep(x, 1, i) {
      rep(y, 1, i) {
        rep(z, 1, i) {
          if (((x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (x * z)) == i)
            ++cnt;
        }
      }
    }
    cout << cnt << ln;
  }
  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 ans[100000] = {0};
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        ans[((i + j) * (i + j) + (i + k) * (i + k) + (j + k) * (j + k)) / 2]++;
      }
    }
  }
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++)
    cout << ans[i] << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
#include <string.h>

int main() {
  int num;
  scanf("%d", &num);
  for (int i = 1; i <= num; i++) {
    int count = 0;
    for (int x = 1; x < 80; x++) {
      for (int y = 1; y < 80; y++) {
        for (int z = 1; z < 80; z++) {
          if ((x * x) + (y * y) + (z * z) + (x * y) + (x * z) + (y * z) == i) {
            count++;
          }
        }
      }
    }
    printf("%d\\n", count);
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

#define PI 3.14159265359
#define rep(i, a, n) for (int i = a; i < (int)n; ++i)
#define SZ(x) ((int)(x).size()) // size() unsigned -> int
#define descSort(a) sort(a.begin(), a.end(), std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

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

  rep(i, 1, n + 1) {
    int cnt = 0;
    for (int a = 1; a * a <= i; a++) {
      for (int b = 1; b * b <= i; b++) {
        for (int c = 1; c * c <= i; c++) {
          if (a * a + b * b + c * c + a * b + b * c + c * a > i)
            break;
          if (a * a + b * b + c * c + a * b + b * c + c * a == i)
            cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define PI 3.14159265359
#define rep(i, a, n) for (int i = a; i < (int)n; ++i)
#define SZ(x) ((int)(x).size()) // size() unsigned -> int
#define descSort(a) sort(a.begin(), a.end(), std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

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

  rep(i, 1, n + 1) {
    int cnt = 0;
    rep(a, 1, i + 1) {
      rep(b, 1, i + 1) {
        rep(c, 1, i + 1) {
          if (a * a + b * b + c * c + a * b + b * c + c * a > i)
            continue;
          if (a * a + b * b + c * c + a * b + b * c + c * a == i)
            cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
  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> A(N + 1, 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 <= N) {
          A.at(X * X + Y * Y + Z * Z + X * Y + Y * Z + Z * X)++;
        }
      }
    }
  }
  for (int i = 1; i <= N; i++)
    cout << A.at(i) << endl;
}

Error: 0

Fixed submission:

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N + 1, 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 <= N) {
          A.at(X * X + Y * Y + Z * Z + X * Y + Y * Z + Z * X)++;
        }
      }
    }
  }
  for (int i = 1; i <= N; i++)
    cout << A.at(i) << endl;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int s[10005];
void trip() {
  for (int i = 1; i <= 10000; i++) {
    int x, y, z, num = 0;
    for (x = 1; x <= sqrt(i); x++) {
      if (x * x + 3 + 2 * x > i)
        break;
      for (y = 1; y <= sqrt(i); y++) {
        if (x * x + y * y + x * y + 1 + x + y > i)
          break;
        for (z = 1; z <= sqrt(i); z++) {
          if (x * x + y * y + z * z + x * y + y * z + x * z > i)
            break;
          if (x * x + y * y + z * z + x * y + y * z + x * z == i)
            num++;
        }
      }
    }
    s[i] = num;
  }
}

int main() {
  int n;
  trip();
  while (~scanf("%d", &n))
    for (int i = 1; i <= n; i++)
      printf("%d\\n", s[i]);
  return 0;
}


Error: TLE

Fixed submission:

#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int s[10005];
void trip() {
  for (int i = 1; i <= 10000; i++) {
    int x, y, z, num = 0;
    for (x = 1; x <= sqrt(i); x++) {
      if (x * x + 3 + 2 * x > i)
        continue;
      for (y = 1; y <= sqrt(i); y++) {
        if (x * x + y * y + x * y + 1 + x + y > i)
          continue;
        for (z = 1; z <= sqrt(i); z++) {
          if (x * x + y * y + z * z + x * y + y * z + x * z > i)
            continue;
          if (x * x + y * y + z * z + x * y + y * z + x * z == i)
            num++;
        }
      }
    }
    s[i] = num;
  }
}

int main() {
  int n;
  trip();
  while (~scanf("%d", &n))
    for (int i = 1; i <= n; i++)
      printf("%d\\n", s[i]);
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;

/*define*/
#define rep(i, n) for (int i = 0; i < n; ++i)
#define endl "\\n"
typedef long long ll;
// typedef pair<int, int> P;
// vector<long long> v(max_n);
// 多次元配列
// vector<int> v[max_n];
// vector<vector<int>> v(max_n);
// map<int, int> m;
static const int max_n = 1e5 + 2, max_m = 52;
static const ll INF = 1000000000;
const long long mod = 1e18;
int ci;

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

Error: 0

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;

/*define*/
#define rep(i, n) for (int i = 0; i < n; ++i)
#define endl "\\n"
typedef long long ll;
// typedef pair<int, int> P;
// vector<long long> v(max_n);
// 多次元配列
// vector<int> v[max_n];
// vector<vector<int>> v(max_n);
// map<int, int> m;
static const int max_n = 1e4 + 2, max_m = 52;
static const ll INF = 1000000000;
const long long mod = 1e18;
int ci;

int main() {
  int n;
  cin >> n;
  int ans[max_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) {
        if (x == y && x == z && y == z)
          ans[6 * x * x]++;
        if (x != y && x == z)
          ans[3 * x * x + 2 * x * y + y * y] += 3;
        if (x != y && x != z && y != z)
          ans[x * x + y * y + z * z + x * y + x * z + y * z] += 6;
      }
    }
  }
  for (int i = 1; i <= n; ++i)
    cout << ans[i] << endl;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int N;
  cin >> N;
  int ans[10100];
  for (int i = 1; i <= N; i++) {
    ans[i] = 0;
  }
  for (int x = 1; x <= 105; x++) {
    for (int y = 1; y <= 105; y++) {
      for (int z = 1; z <= 105; z++) {
        if ((x * x + y * y + z * z + x * y + y * z + z * x) <= N) {
          ans[x * x + y * y + z * z + x * y + y * z + z * x]++;
        }
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    cout << ans[i] << endl;
  }
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int N;
  cin >> N;
  int ans[10100];
  for (int i = 1; i <= N; i++) {
    ans[i] = 0;
  }
  int l = 0;
  for (int i = 0; i <= N; i++) {
    l = i;
  }

  for (int x = 1; x <= l; x++) {
    for (int y = 1; y <= l; y++) {
      for (int z = 1; z <= l; z++) {
        if ((x * x + y * y + z * z + x * y + y * z + z * x) <= N) {
          ans[x * x + y * y + z * z + x * y + y * z + z * x]++;
        }
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    cout << ans[i] << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;
int main(void) {
  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 = x; y * y < n; y++) {
        for (int z = y; z * z < n; z++) {
          long long ans = x * x + y * y + z * z + x * y + y * z + z * x;
          if (ans == n) {
            set<int> st{x, y, z};
            if (st.size() == 3)
              cnt += 6;
            if (st.size() == 2)
              cnt += 3;
            if (st.size() == 1)
              cnt++;
          }
        }
      }
    }
    cout << cnt << endl;
  }
}


Error: TLE

Fixed submission:

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

using namespace std;
int main(void) {
  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 <= n; y++) {
        for (int z = 1; z * z <= n; z++) {
          long long ans = x * x + y * y + z * z + x * y + y * z + z * x;
          if (ans == n) {
            cnt++;
            // cout<<x<<" "<<y<<" "<<z<<" "<<endl;
          }
        }
      }
    }
    cout << cnt << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

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

  vector<int> ans(n + 1, 0);
  for (ll x = 1; x * x <= n; ++x) {
    for (ll y = 1; y * y <= n; ++y) {
      for (ll z = 1; z * z <= n; ++z) {
        if (x * x + y * y + z * z + x * y + y * z + z * x <= n) {
          ans[x * x + y * y + z * z + x * y + y * z + z * x]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; ++i)
    cout << ans[i] << "\\n";
  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

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

  vector<int> ans(n + 1, 0);
  for (ll x = 1; x * x <= n; ++x) {
    for (ll y = 1; y * y <= n; ++y) {
      for (ll z = 1; z * z <= n; ++z) {
        ans[x * x + y * y + z * z + x * y + y * z + z * x]++;
      }
    }
  }
  for (int i = 1; i <= n; ++i)
    cout << ans[i] << "\\n";
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
// typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
// define
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)

int main() {
  ll a, n;
  // vi c;
  cin >> n;
  vi d(100000, 0);
  for (int x = 1; x < 101; x++) {
    for (int y = 1; y < 101; y++) {
      for (int z = 1; z < 101; z++) {
        a = x * x + y * y + z * z + x * y + y * z + z * x;
        d[a]++;
      }
    }
  }
  // sort(c.begin(),c.end());
  //  rep(i,200000){
  //    cout << c[i] << endl;
  //  }
  for (int i = 1; i < n + 1; i++) {
    cout << d[i] << endl;
  }
  return 0;
}


Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
// typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
// define
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)

int main() {
  int a, n;
  // vi c;
  cin >> n;
  vi d(50000, 0);
  for (int x = 1; x < 101; x++) {
    for (int y = 1; y < 101; y++) {
      for (int z = 1; z < 101; z++) {
        a = x * x + y * y + z * z + x * y + y * z + z * x;
        d[a]++;
      }
    }
  }
  // sort(c.begin(),c.end());
  //  rep(i,200000){
  //    cout << c[i] << endl;
  //  }
  for (int i = 1; i < n + 1; i++) {
    cout << d[i] << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

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

  rep(n, 1, N + 1) {
    ll ans = 0;
    rep(i, 1, n / 3 + 1) {
      rep(j, i, n / 3 + 1) {
        int x = i;
        int y = j;
        int k = 4 * n - 2 * x * y - 3 * (x * x + y * y);
        if (k < 0)
          break;
        int rk = sqrt(k);
        if (rk * rk != k)
          continue;
        if (rk - (x + y) < 2)
          continue;
        int m = rk - (x + y);
        int mdiv2 = m / 2;
        if (mdiv2 * 2 != m)
          continue;

        int z = mdiv2;
        if (z < y)
          break;

        if (x != y && y != z && z != x)
          ans += 6;
        else if (x == y && y != z && z != x)
          ans += 3;
        else if (x != y && y == z && z != x)
          ans += 3;
        else if (x == y && y == z && z == x)
          ans += 1;
      }
    }
    printf("%d\\n", ans);
  }
  return 0;
}

Error: TLE

Fixed submission:

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define ALL(v) (v).begin(), (v).end()
ll MOD = 1000000007;
ll mod = 998244353;
int inf = 1000001000;
ll INF = 1e18 + 5;

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

  rep(n, 1, N + 1) {
    ll ans = 0;
    rep(i, 1, n + 1) {
      rep(j, i, n + 1) {
        ll x = i;
        ll y = j;
        ll k = 4 * n - 2 * x * y - 3 * (x * x + y * y);
        ll rk = sqrt(k);
        if (rk * rk != k)
          continue;
        if (rk - (x + y) < 2)
          continue;
        ll m = rk - (x + y);
        ll mdiv2 = m / 2;
        if (mdiv2 * 2 != m)
          continue;

        ll z = mdiv2;
        // cout << x <<" "<< y <<" "<<z<<" ";
        if (z < y)
          continue;

        if (x != y && y != z && z != x)
          ans += 6;
        else if (x == y && y != z && z != x)
          ans += 3;
        else if (x != y && y == z && z != x)
          ans += 3;
        else if (x == y && y == z && z == x)
          ans += 1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (i = 1; i <= n; ++i)
#define rrep(xyz, n) for (xyz = 1; xyz * xyz < n; ++xyz)
using namespace std;
int main(void) {
  int N;
  cin >> N;
  int i, score, n, x, y, z;
  rep(i, N) {
    score = 0;
    rrep(x, i) rrep(y, i) rrep(z, i) {
      n = (x * x + y * y + z * z + x * y + y * z + z * x);
      if (n == i) {
        ++score;
        break;
      } else if (n > i)
        break;
    }
    cout << score << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (i = 1; i <= n; ++i)
#define rrep(xyz, n) for (xyz = 1; xyz < n; ++xyz)
using namespace std;
int main(void) {
  int N;
  cin >> N;
  int i, score, n, x, y, z;
  rep(i, N) {
    score = 0;
    rrep(x, i) rrep(y, i) rrep(z, i) {
      n = (x * x + y * y + z * z + x * y + y * z + z * x);
      if (n == i) {
        ++score;
        break;
      } else if (n > i)
        break;
    }
    cout << score << endl;
  }

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

#include <bits/stdc++.h>
#define rep(i, n) for (i = 1; i <= n; ++i)
using namespace std;
int main(void) {
  int N;
  cin >> N;
  int i, score, n, x, y, z, max;
  rep(i, N) {
    max = N;
    score = 0;
    for (x = 1; x <= max; ++x)
      for (y = 1; y <= max; ++y)
        for (z = 1; z <= max; ++z) {
          n = (x * x + y * y + z * z + x * y + y * z + z * x);
          if (n == i) {
            ++score;
            if (max == N)
              max = z;
            break;
          } else if (n > i) {
            if (max == N)
              max = z;
            break;
          }
        }
    cout << score << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (i = 1; i <= n; ++i)
using namespace std;
int main(void) {
  int N;
  cin >> N;
  int i, score, n, x, y, z, max, max2, max3;
  rep(i, N) {
    max = 2;
    max2 = 2;
    max3 = N;
    score = 0;
    for (x = 1; x <= max; ++x)
      for (y = 1; y <= N; ++y) {
        for (z = 1; z <= max3; ++z) {
          n = (x * x + y * y + z * z + x * y + y * z + z * x);
          if (n == i) {
            ++score;
            if (max3 == N)
              max = z;
            max3 = z;
            break;
          } else if (n > i) {
            if (max3 == N)
              max = z;
            break;
          }
        }
        max2 = max - x + 2;
      }
    cout << score << endl;
  }

  return 0;
}