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

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define ll long long

int arr[10001];

int main(void) {
  int x, y, z, k, n, temp;
  scanf("%d", &n);
  k = sqrt(n);
  for (x = 1; x <= k; x++)
    for (y = 1; y <= k; y++)
      for (z = 1; z <= k; z++) {
        temp = x * x + y * y + z * z + x * y + y * z + z * x;
        if (temp <= n)
          arr[temp]++;
      }
  for (int i = 1; i <= n; i++)
    printf("%d\\n", arr[i]);
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define ll long long

int arr[10001];

int main(void) {
  int x, y, z, n, temp;
  scanf("%d", &n);
  for (x = 1; x < n; x++)
    for (y = 1; y < n; y++)
      for (z = 1; z < n; z++) {
        temp = x * x + y * y + z * z + x * y + y * z + z * x;
        if (temp <= n)
          arr[temp]++;
      }
  for (int i = 1; i <= n; i++)
    printf("%d\\n", arr[i]);
  return 0;
}
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;

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

  vector<int> ans(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 calc = x * x + y * y + z * z + x * y + y * z + z * x;
        if (calc <= N) {
          ans[calc - 1]++;
        }
      }
    }
  }
  rep(i, N) cout << ans[i] << endl;
  return 0;
}

Error: -6
malloc(): corrupted top size


Fixed submission:

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

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

  vector<int> ans(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++) {
        ans[x * x + y * y + z * z + x * y + y * z + z * x - 1]++;
      }
    }
  }
  rep(i, N) cout << ans[i] << endl;
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define M 1000000007

void solve() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int count = 0;
    for (int j = 1; j * j <= i; j++) {
      for (int k = j; k * k <= i; k++) {
        for (int l = k; l * l <= i; l++) {
          if (j * j + k * k + l * l + j * l + j * k + k * l == i) {
            if (j == k && k == l)
              count++;
            else if (j == k || k == l || j == l)
              count += 3;
            else
              count += 6;
          }
        }
      }
    }
    cout << count << "\\n";
  }
}

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

  solve();
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define M 1000000007

void solve() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int count = 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 * l + j * k + k * l == i)
            count++;
        }
      }
    }
    cout << count << "\\n";
  }
}

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

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

#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1 << 30;
const ll INF64 = 1LL << 60;

void solve() {
  int n;
  cin >> n;
  vector<int> a(2e5, 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++)
        a[x * x + y * y + z * z + x * y + y * z + x * z]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << endl;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1 << 30;
const ll INF64 = 1LL << 60;

void solve() {
  int n;
  cin >> n;
  vector<int> a(4e4, 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++)
        a[x * x + y * y + z * z + x * y + y * z + x * z]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << endl;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N;
  cin >> N;
  int f[10001]{};
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int t = x * x + y * y + z * z + x * y + y * z + z * x;
        if (t > 10001)
          break;
        f[t]++;
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    cout << f[i] << "\\n";
  }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N;
  cin >> N;
  int f[1001]{};
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int t = x * x + y * y + z * z + x * y + y * z + z * x;
        if (t > 1000)
          continue;
        f[t]++;
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    cout << f[i] << "\\n";
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;

int main() {
  int n;
  cin >> n;
  int a[100001];
  for (int x = 1; x < 101; ++x) {
    for (int y = 1; y < 101; ++y) {
      for (int z = 1; z < 101; ++z) {
        ll sum = (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x);
        if (sum <= n) {
          a[sum]++;
        }
      }
    }
  }
  for (int i = 1; i < n + 1; ++i) {
    cout << a[i] << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;

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

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

int main() {
  int n;
  cin >> n;
  vector<ll> ans(1e4 + 1, 0);
  rep(z, 1, sqrt(n) + 1) {
    rep(y, 1, z + 1) {
      rep(x, 1, y + 1) {
        ll f = x * x + y * y + z * z + x * y + y * z + z * x;
        if (f >= ans.size())
          continue;
        if (y == z && y == x)
          ans[f] += 1;
        else if (y == z || y == x)
          ans[f] += 3;
        else
          ans[f] += 6;
      }
    }
  }
  rep(i, 1, n + 1) cout << ans[i] << endl;
}

Error: 0

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  vector<int> ans(1e4 + 1, 0);
  rep(z, 1, sqrt(n) + 1) {
    rep(y, 1, z + 1) {
      rep(x, 1, y + 1) {
        int f = x * x + y * y + z * z + x * y + y * z + z * x;
        if (y == z && y == x)
          ans[f] = 1;
        else if (y == z || y == x)
          ans[f] = 3;
        else
          ans[f] = 6;
      }
    }
  }
  rep(i, 1, n + 1) cout << ans[i] << endl;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <math.h>
#include <string.h>
#include <string>
using namespace std;

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

  for (int i = 1; i <= n; i++) {
    if (i < 6) {
      cout << 0 << endl;
      continue;
    }
    int max = (i + 3) / 6;
    int cnt = 0;
    for (int a = 1; a <= max; a++) {
      if (a * a > i)
        break;
      for (int b = 1; b <= max; b++) {
        if ((a * a + b * b) > i)
          break;
        // for (int c = 1; c <= max; c++) {
        //	if (a *a + b*b + c*c + a * b + b * c + c * a == i) {
        //		cnt++;
        //		break;
        //	}
        // }
        int remain = i - a * a - a * b - b * b;
        if (remain < 0)
          break;
        int l = int(sqrt(double(remain)));
        for (int c = 1; c <= l; c++) {
          if (c * c + a * c + b * c == remain) {
            cnt++;
            break;
          }
        }
      }
    }
    cout << cnt << endl;
  }
}

int main() {
  c_xys_triplets();
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <math.h>
#include <string.h>
#include <string>
using namespace std;

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

  for (int i = 1; i <= n; i++) {
    if (i < 6) {
      cout << 0 << endl;
      continue;
    }
    int max = (i + 3) / 6;
    int cnt = 0;
    for (int a = 1; a <= max; a++) {
      if (a * a > i)
        break;
      for (int b = 1; b <= max; b++) {
        if ((a * a + b * b) > i)
          break;
        for (int c = 1; c <= max; c++) {
          if (a * a + b * b + c * c + a * b + b * c + c * a == i) {
            cnt++;
            break;
          }
        }
      }
    }
    cout << cnt << endl;
  }
}

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

#include <bits/stdc++.h>
using namespace std;
int ans[1000200];
int main() {
  int n;
  scanf("%d", &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 t;
        t = i * i + j * j + k * k + i * j + i * k + j * k;
        ans[t]++;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    printf("%d\\n", ans[i]);
  }
  return 0;
}

Error: TLE

Fixed submission:

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

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

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

  for (long i = 1; i < N + 1; i++) {
    long count = 0;
    long n = sqrt(i);
    for (long j = 1; j < n; j++) {
      for (long k = j; k < n; k++) {
        for (long l = k; l < n; l++) {
          if (j * j + k * k + l * l + j * k + k * l + l * j == i && j == k &&
              k == l) {
            count += 1;
          } else if (j * j + k * k + l * l + j * k + k * l + l * j == i &&
                     j == k && k != l) {
            count += 3;
          } else if (j * j + k * k + l * l + j * k + k * l + l * j == i &&
                     j != k && k == l) {
            count += 3;
          } else if (j * j + k * k + l * l + j * k + k * l + l * j == i &&
                     j != k && k != l) {
            count += 6;
          }
        }
      }
    }
    cout << count << endl;
  }
}

Error: TLE

Fixed submission:

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

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

  for (long i = 1; i < N + 1; i++) {
    long count = 0;
    long n = sqrt(i);
    for (long j = 1; j < n; j++) {
      for (long k = 1; k < n; k++) {
        for (long l = 1; l < n; l++) {
          if (j * j + k * k + l * l + j * k + k * l + l * j == i) {
            count += 1;
          }
        }
      }
    }
    cout << count << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
// エイシングプロコン2020
// C問題
int main() {
  int n;
  cin >> n;
  int ans[10050] = {0};
  int v;
  for (int i = 1; i <= 105; i++) {
    for (int j = 1; j <= 105; j++) {
      for (int k = 1; k <= 105; k++) {
        v = i * i + j * j + k * k + i * j + j * k + k * i;
        if (v < 10050) {
          ans[v] += 1;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
// エイシングプロコン2020
// C問題
int main() {
  int n;
  cin >> n;
  int ans[10050] = {0};
  for (int i = 1; i <= n; i++) {
    int v;
    for (int j = 1; j * j <= n; j++) {
      for (int k = 1; k * k <= n; k++) {
        for (int l = 1; l * l <= n; l++) {
          v = j * j + k * k + l * l + j * k + k * l + l * j;
          if (v == i) {
            ans[v] += 1;
          }
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for (int i = (l), i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define pb push_back

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                  'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                  's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main() {
  int n;
  cin >> n;
  vector<int> lis(100010, 0);
  int key = pow(10010, 0.5);
  REP(x, 1, key + 10) {
    REP(y, 1, key + 10) {
      REP(z, 1, key + 10) {
        int mid = x * x + y * y + z * z + x * y + y * z + z * x;
        lis[mid]++;
      }
    }
  }
  REP(i, 1, n + 1) { cout << lis[i] << endl; }
}

Error: TLE

Fixed submission:

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for (int i = (l), i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define pb push_back

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                  'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                  's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main() {
  int n;
  cin >> n;
  REP(i, 1, n + 1) {
    int key = pow(i, 0.5);
    int count = 0;
    REP(a, 1, key + 2) {
      REP(b, 1, key + 2) {
        REP(c, 1, key + 2) {
          if ((a * a + b * b + c * c + a * b + b * c + c * a) == i) {
            count++;
          }
        }
      }
    }
    cout << count << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9 + 7;
int inf = 1000000000; // 10e9

int calc(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;

  vector<int> count(n);
  rep(i, n) count[i] = 0;

  for (int x = 1; x < sqrt(n); x++) {
    for (int y = 1; y < sqrt(n); y++) {
      for (int z = 1; z < sqrt(n); z++) {
        if (calc(x, y, z) <= 10000) {
          count[calc(x, y, z) - 1]++;
        }
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    cout << count[i - 1] << '\\n';
  }

  return 0;
}

Error: 0

Fixed submission:

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9 + 7;
int inf = 1000000000; // 10e9

int calc(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;

  vector<int> sum;

  for (int x = 1; x < sqrt(n); x++) {
    for (int y = 1; y < sqrt(n); y++) {
      for (int z = 1; z < sqrt(n); z++) {
        sum.push_back(calc(x, y, z));
      }
    }
  }

  int size = sum.size();
  sort(sum.begin(), sum.end());

  for (int i = 1; i <= n; i++) {
    int counteach = 0;
    for (int j = 0; j < n;) {
      if (sum[j] == i) {
        counteach++;
        j++;
      } else if (sum[j] < i) {
        j++;
      } else {
        cout << counteach << '\\n';
        break;
      }
    }
  }

  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 rng(a) a.begin(), a.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int j = 1; j * j < i; j++) {
      for (int k = j; j * j + k * k < i; k++) {
        for (int m = k; j * j + k * k + m * m < i; m++) {
          int num = j * j + k * k + m * m + j * k + k * m + m * j;
          if (num == i && j != k && k != m)
            ans += 6;
          else if (num == i && j == k && k == m)
            ans++;
          else if (num == i && j == k)
            ans += 3;
          else if (num == i && k == m)
            ans += 3;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

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

#include <bits/stdc++.h>
using namespace std;
int a[10005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n, cnt = 0;
  cin >> n;
  for (int i = 1; i <= 150; i++) {
    for (int j = 1; j <= 150; j++) {
      for (int k = 1; k <= 150; k++) {
        int x = (i + j) * (i + j) + (k + j) * (k + j) + (i + k) * (i + k);
        if (!(x & 1) && x / 2 <= 10000)
          a[x / 2]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d\\n", a[i]);
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 5, mod = 1e9 + 7;
int n, m;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int rnd = 1; rnd <= n; rnd++) {
    int ans = 0;
    for (int i = 1; i <= 150; i++) {
      for (int j = i; j <= 150; j++) {
        for (int k = j; k <= 150; k++) {
          if (i * i + j * j + k * k + i * j + j * k + k * i == rnd) {
            if (i == j && j == k)
              ans++;
            else if (i == j && j != k || i != j && j == k)
              ans += 3;
            else
              ans += 6;
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

ll solve(const ll n) {
  ll ans = 0;

  for (ll a = 1; a <= n; a++) {
    ll x = a * a;
    if (x > n) {
      break;
    }
    for (ll b = 1; b <= n; b++) {
      ll y = b * b + a * b;
      if (x + y > n) {
        break;
      }
      for (ll c = 1; c <= n; c++) {
        ll z = c * c + b * c + c * a;

        if (z > n) {
          break;
        }

        if (x + y + z == n) {
          ans++;
        }
      }
    }
  }

  return ans;
}

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

  for (int i = 1; i <= N; i++) {
    printf("%lld\\n", solve(i));
    // solve(i);
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

ll solve(const ll n) {
  ll ans = 0;

  for (ll a = 1; a <= n; a++) {
    if (a * a > n) {
      break;
    }
    ll x = a * a;
    for (ll b = 1; b <= n; b++) {
      if (b * b > n || a * b > n) {
        break;
      }
      ll y = b * b + a * b;
      for (ll c = 1; c <= n; c++) {
        if (c * c > n || b * c > n || c * a > n) {
          break;
        }

        ll z = c * c + b * c + c * a;

        if (x + y + z == n) {
          ans++;
        }
      }
    }
  }

  return ans;
}

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

  for (int i = 1; i <= N; i++) {
    printf("%lld\\n", solve(i));
    // solve(i);
  }

  return 0;
}