alexjercan/bugnet huggingface dataset:
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 all(x) (x).begin(), (x).end()
using ll = long long;
using P = pair<int, int>;

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

int combi(int x, int y, int z) {
  int cnt = 0;
  if (x == y)
    cnt++;
  if (y == z)
    cnt++;
  if (x == z)
    cnt++;
  if (cnt == 0)
    return 6;
  if (cnt == 1)
    return 3;
  else
    return 1;
}

int main() {

  int n;
  cin >> n;
  // int ans = 0;

  vector<int> a(2 * n);

  for (int x = 1; x * x <= n; x++) {
    for (int y = x; x * x + y * y + x * y <= n; y++) {
      for (int z = y; x * x + y * y + z * z <= n; z++) {
        a[f(x, y, z)] += combi(x, y, z);
      }
    }
  }

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

  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 all(x) (x).begin(), (x).end()
using ll = long long;
using P = pair<int, int>;

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

int combi(int x, int y, int z) {
  int cnt = 0;
  if (x == y)
    cnt++;
  if (y == z)
    cnt++;
  if (x == z)
    cnt++;
  if (cnt == 0)
    return 6;
  if (cnt == 1)
    return 3;
  else
    return 1;
}

int main() {

  int n;
  cin >> n;
  // int ans = 0;

  vector<int> a(n + 1);

  for (int x = 1; x * x < n; x++) {
    for (int y = x; x * x + y * y + x * y < n; y++) {
      for (int z = y; x * x + y * y + z * z < n; z++) {
        a[f(x, y, z)] += combi(x, y, z);
      }
    }
  }

  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;

int main() {
  int N;
  cin >> N;
  vector<int> Ans(10100);
  for (int x = 1; x < 105; x++) {
    for (int y = 1; y < 105; y++) {
      for (int z = 1; z < 105; z++) {
        int A = x * x + y * y + z * z + x * y + y * z + z * x;
        if (A < 10100)
          Ans.at(A - 1)++;
      }
    }
  }
  for (int i = 0; i < N; i++)
    cout << Ans.at(i) << endl;
}


Error: TLE

Fixed submission:

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

int main() {
  int N;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    int count = 0;
    int Mx = sqrt(i);
    for (int x = 1; x <= Mx; x++) {
      int My = sqrt(i - x * x);
      if (My == 0)
        break;
      else {
        for (int y = 1; y <= My; y++) {
          int Mz = sqrt(i - x * x - y * y);
          if (Mz == 0)
            break;
          else {
            for (int z = 1; z <= Mz; z++) {
              if (x * x + y * y + z * z + x * y + y * z + z * x == i)
                count++;
            }
          }
        }
      }
    }
    cout << count << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define endl "\\n"
#define pb push_back
#define SZ(x) ((int)(x.size()))
#define FOR(i, s, n) for (ll i = (s); (i) < (n); ++i)
#define FORD(i, s, l) for (ll i = (s); (i) >= l; --i)
#define F first
#define S second
#define TC                                                                     \\
  int __tc;                                                                    \\
  cin >> __tc;                                                                 \\
  FOR(case_num, 1, __tc + 1)
#define TEST(x, i) ((x) & (1ll << (i)))
#define SET(x, i) ((x) | (1ll << (i)))
#define FLIP(x, i) ((x) ^ (1ll << (i)))
#define CLEAR(x, i) ((x) & ~(1ll << (i)))

const double pi = 4 * atan(1);
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
const int MAXN = 200005;

bool isSq(ll x) { return roundl(sqrtl(x)) * roundl(sqrtl(x)) == x; }

int solvable(ll a, ll b, ll c) {
  ll disc = b * b - 4 * a * c;
  if (disc < 0)
    return 0;
  if (!isSq(disc))
    return 0;
  if (((ll)(-b + sqrtl(disc))) % 2)
    return 0;
  return b != sqrtl(disc);
}

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

  ll n;
  cin >> n;

  for (ll t = 1; t <= n; t++) {
    ll ans = 0;
    for (ll x = 1; x * x < t; x++) {
      for (ll y = 1; x * x + y * y + x * y < t; y++) {
        ll a = 1;
        ll b = x + y;
        ll c = x * x + y * y + x * y - t;
        ans += solvable(a, b, c);
      }
    }
    cout << ans << "\\n";
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define endl "\\n"
#define pb push_back
#define SZ(x) ((int)(x.size()))
#define FOR(i, s, n) for (ll i = (s); (i) < (n); ++i)
#define FORD(i, s, l) for (ll i = (s); (i) >= l; --i)
#define F first
#define S second
#define TC                                                                     \\
  int __tc;                                                                    \\
  cin >> __tc;                                                                 \\
  FOR(case_num, 1, __tc + 1)
#define TEST(x, i) ((x) & (1ll << (i)))
#define SET(x, i) ((x) | (1ll << (i)))
#define FLIP(x, i) ((x) ^ (1ll << (i)))
#define CLEAR(x, i) ((x) & ~(1ll << (i)))

const double pi = 4 * atan(1);
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
const int MAXN = 200005;

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

  ll n;
  cin >> n;

  for (ll t = 1; t <= n; t++) {
    ll ans = 0;
    for (ll x = 1; x * x < t; x++) {
      for (ll y = 1; y * y < t - x * x; y++) {
        for (ll z = 1; z < t - x * x - y * y; z++) {
          if (x * x + y * y + z * z + x * y + x * z + y * z == t) {
            ans++;
          }
        }
      }
    }
    cout << ans << "\\n";
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int cnt[10004];
int main() {
  int n;
  cin >> n;

  for (double j = 1; j <= 100; j++) {
    for (double k = 1; k <= 100; k++) {
      for (double l = 1; l <= 100; l++) {
        int sm = j * j + k * k + l * l + j * k + k * l + j * l;
        if (sm > n)
          continue;
        cnt[sm]++;
      }
    }
  }

  for (int i = 1; i <= n; i++)
    cout << cnt[i] << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int cnt[10004];
int main() {
  int n;
  cin >> n;

  for (double i = 1; i <= n; i++) {
    for (double j = 1; j <= 100; j++) {
      for (double k = 1; k <= 100; k++) {
        for (double l = 1; l <= 100; l++) {
          if ((j + k + l) == sqrt(i + j * k + l * k + l * j))
            cnt[(int)i]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << cnt[i] << endl;
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  for (int i = 1; i < 105; i++) {
    for (int j = 1; j < 105; j++) {
      for (int k = 1; k < 105; k++) {
        int count = i * i + j * j + k * k + i * j + j * k + k * i;
        ;
        if (count <= N)
          a.at(count)++;
      }
    }
  }
  for (int i = 1; i <= N; i++)
    cout << a[i] << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
long long fn(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> a(N + 1, 0);

  for (int i = 1; i < N; i++) {
    for (int j = 1; j < N; j++) {
      for (int k = 1; k < N; k++) {
        long long count = fn(i, j, k);
        if (count <= N)
          a[count]++;
      }
    }
  }
  for (int i = 1; i <= N; i++)
    cout << a[i] << endl;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {

  ll n;
  cin >> n;
  vector<ll> v(n + 1, 0);

  for (ll x = 1; x <= sqrt(n - 2) - 1; x++) {

    for (ll y = 1; y <= sqrt(n - 2) - 1; y++) {
      for (ll z = 1; z <= sqrt(n - 2) - 1; z++) {

        if (x * x + y * y + z * z + x * y + y * z + z * x <= n) {
          v[x * x + y * y + z * z + x * y + y * z + z * x]++;
        }
      }
    }
  }

  for (ll i = 1; i < v.size(); i++) {
    cout << v[i] << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {

  ll n;
  cin >> n;
  vector<ll> v;
  for (ll i = 1; i <= n; i++) {

    ll ctr = 0;
    for (ll x = 1; x <= sqrt(i - 2) - 1; x++) {

      for (ll y = 1; y <= sqrt(i - 2) - 1; y++) {
        for (ll z = 1; z <= sqrt(i - 2) - 1; z++) {

          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            ctr++;
          }
        }
      }
    }
    v.push_back(ctr);
  }
  for (ll i = 0; i < v.size(); i++) {
    cout << v[i] << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

typedef long long ll;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, n) for (int i = 0; i <= (n); i++)
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define FORS(i, a, b) for (int i = a; i <= (b); i++)
// for container x
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define LB(v, x) distance((v).begin(), lower_bound(ALL(v), (x)))
#define UB(v, x) distance((v).begin(), upper_bound(ALL(v), (x)))

struct cww {
  cww() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
} star;
#pragma endregion

int main() {
  int N;
  cin >> N;
  FORS(n, 1, N) {
    int ans = 0;
    for (int x = 1; x * x < n; x++) {
      for (int y = 1; y <= x; y++) {
        for (int z = 1; z <= y; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == n) {
            if (x == y && y == z && x == z)
              ans++;
            else if ((x == y && y != z) || (x == z && x != y) ||
                     (y == z && z != x))
              ans += 3;
            else
              ans += 6;
          }
        }
      }
    }
    cout << ans << "\\n";
  }
  return 0;
}

Error: TLE

Fixed submission:

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

typedef long long ll;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, n) for (int i = 0; i <= (n); i++)
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define FORS(i, a, b) for (int i = a; i <= (b); i++)
// for container x
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define LB(v, x) distance((v).begin(), lower_bound(ALL(v), (x)))
#define UB(v, x) distance((v).begin(), upper_bound(ALL(v), (x)))

struct cww {
  cww() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
} star;
#pragma endregion

int main() {
  int N;
  cin >> N;
  FORS(n, 1, N) {
    int ans = 0;
    for (int x = 1; x * x < n; x++) {
      for (int y = 1; y * y <= (n - x * x); y++) {
        // if (x*x+y*y+z*z+x*y+y*z+z*x==n) ans++;
        for (int z = 1; z * z <= (n - x * x - y * y - x * y); z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == n)
            ans++;
        }
      }
    }
    cout << ans << "\\n";
  }
  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 repr(i, n) for (int i = n; i >= 0; i--) // 逆ループ

// 型名省略
typedef long long ll;
// 値
static const ll MX = 100005;
static const ll MX_ll = 1e18;

using namespace std;

// ソート
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

// #include "./lib/generic/search.h"

int main() {
  int n, x, y, z, ans = 0, max = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    ans = 0;
    max = 0;
    if (i <= 5) {
      cout << "0" << endl;
      continue;
    }
    x = 1;
    while (1) {
      if (x * x + x - i + 4 <= 0) {
        x++;
      }
      if (x * x + x - i + 4 > 0) {
        max = x - 1;
        break;
      }
    }
    for (x = 1; x <= max; x++) {
      for (y = x; y <= max; y++) {
        for (z = y; z <= max; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            if (x == y && y == z)
              ans++;
            else if (x == y && y != z)
              ans += 3;
            else if (x != y && y == z)
              ans += 3;
            else if (x == z && y != z)
              ans += 3;
            else
              ans += 6;
          }
        }
      }
    }
    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 repr(i, n) for (int i = n; i >= 0; i--) // 逆ループ

// 型名省略
typedef long long ll;
// 値
static const ll MX = 100005;
static const ll MX_ll = 1e18;

using namespace std;

// ソート
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

// #include "./lib/generic/search.h"

int main() {
  int n, x, y, z, ans = 0, max = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    ans = 0;
    max = 0;
    if (i <= 5) {
      cout << "0" << endl;
      continue;
    }
    x = 1;
    while (1) {
      if (x * x + x - i + 4 <= 0) {
        x++;
      }
      if (x * x + x - i + 4 > 0) {
        max = x - 1;
        break;
      }
    }
    for (x = 1; x <= max; x++) {
      for (y = 1; y <= max; y++) {
        for (z = 1; z <= max; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i)
            ans++;
        }
      }
    }
    cout << ans << endl;
  }

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

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

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int ans = 0;
    for (int x = 1; x * x <= i; ++x) {
      int rest = i - x * x;
      for (int y = 1; y * y <= rest; ++y) {
        int rest2 = rest - y * y;
        for (int z = 1; z * z <= rest2; ++z) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            ans++;
          } else if (x * x + y * y + z * z + x * y + y * z + z * x > i) {
            break;
          }
        }
      }
    }
    printf("%d\\n", ans);
  }
}


Error: TLE

Fixed submission:

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int ans = 0;
    for (int x = 1; x * x <= i; ++x) {
      int rest = i - x * x;
      for (int y = 1; y * y <= rest; ++y) {
        int rest2 = rest - y * y;
        for (int z = 1; z * z <= rest2; ++z) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            ans++;
          }
        }
      }
    }
    cout << ans << "\\n";
  }
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

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

using ll = long long int;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define fore(i, a) for (auto &i : a)
#define all(x) (x).begin(), (x).end()

#define pi 3.14159265358979323846

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

const int MAX = 42;

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

  vector<ll> a(60000, 0);

  for (ll i = 1; i <= 100; i++) {
    for (ll j = 1; j <= 100; j++) {
      for (ll k = 1; k <= 100; k++) {
        ll f = i * i + j * j + k * k + i * j + j * k + k * i;
        a[f]++;
      }
    }
  }

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

  // cout << setprecision(8) << ans << endl;  // For double
}


Error: -11

Fixed submission:

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

using ll = long long int;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define fore(i, a) for (auto &i : a)
#define all(x) (x).begin(), (x).end()

#define pi 3.14159265358979323846

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

const int MAX = 42;

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

  vector<ll> a(20000, 0);

  for (ll i = 1; i <= 100; i++) {
    for (ll j = 1; j <= 100; j++) {
      for (ll k = 1; k <= 100; k++) {
        ll f = i * i + j * j + k * k + i * j + j * k + k * i;
        a[f]++;
      }
    }
  }

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

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

#include <iostream>
using namespace std;

int main(void) {
  int cnt[10001] = {};
  int N, sum;
  cin >> N;

  for (int i = 1; i < 100; i++) {
    for (int j = 1; j < 100; j++) {
      for (int k = 1; k < 100; k++) {
        sum = (i + j + k) * (i + j + k) - i * (j + k) - j * k;
        if (sum <= 10000)
          cnt[sum]++;
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    cout << cnt[i] << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

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

int N;
int cnt[10001];

void checkNum(int x, int y, int z) {
  int sum = (x + y + z) * (x + y + z) - x * (y + z) - y * z;

  if (sum > N)
    cnt[0] += 0;
  else {
    if (x != y && y != z && z != x)
      cnt[sum] += 6;
    else if (x == y && y == z && z == x)
      cnt[sum] += 1;
    else
      cnt[sum] += 3;
    checkNum(x + 1, y, z);
    checkNum(x + 1, y + 1, z);
    checkNum(x + 1, y + 1, z + 1);
  }
}

int main(void) {
  for (int i = 0; i <= 10000; i++) {
    cnt[i] = 0;
  }
  cin >> N;

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

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

#include <bits/stdc++.h>

#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define rreps(i, n, s) for (int i = s; i >= n; i--)
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  reps(n, N + 1, 1) {
    ll r = sqrt(2 * n);
    int cnt = 0;
    reps(x, r + 1, 1) {
      reps(y, r + 1 - x, 1) {
        ll b = x + y;
        ll c = x * x + y * y + x * y - n;
        ll d = b * b - 4 * c;

        if (d > 0 && ceil(sqrt(d)) == floor(sqrt(d)) && (-b + sqrt(d)) >= 1) {
          cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define rreps(i, n, s) for (int i = s; i >= n; i--)
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  reps(n, N + 1, 1) {
    ll r = sqrt(2 * n);
    int cnt = 0;
    reps(x, r + 1, 1) {
      reps(y, r + 1 - x, 1) {
        for (int z = 1; z < r + 1 - x && z < r + 1 - y; z++) {
          int S = (x + y) * (x + y) + (z + y) * (z + y) + (x + z) * (x + z);
          if (S == 2 * n) {
            cnt++;
          }
        }
      }
    }
    cout << cnt << endl;
  }
  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 repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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;
}

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll << 61;
double pi = 3.141592653589793238;

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

  reps1(i, n + 1) {
    ll ans = 0;
    reps1(x, ll(sqrt(i))) {
      reps1(y, ll(sqrt(i))) {
        ll judge = (x + y) * (x + y) - 4 * (x * x + y * y + x * y - i);
        // cout << i << " " << x << " " << y << " " << judge << endl;
        if (ll(sqrt(judge)) * ll(sqrt(judge)) != judge)
          continue;
        // cout << "a";
        if (-(x + y) * (x + y) + judge <= 0)
          continue;
        // cout << "b";
        // cout << -(x+y)*(x+y) + judge << endl;
        if ((-(x + y) * (x + y) + judge) % 2 != 0)
          continue;
        // cout << "c" << endl;
        ans++;
      }
    }
    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 repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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;
}

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll << 61;
double pi = 3.141592653589793238;

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

  reps1(i, n + 1) {
    ll ans = 0;
    reps1(x, i) {
      reps1(y, i) {
        ll judge = (x + y) * (x + y) - 4 * (x * x + y * y + x * y - i);
        // cout << i << " " << x << " " << y << " " << judge << endl;
        if (ll(sqrt(judge)) * ll(sqrt(judge)) != judge)
          continue;
        // cout << "a";
        if (-(x + y) * (x + y) + judge <= 0)
          continue;
        // cout << "b";
        // cout << -(x+y)*(x+y) + judge << endl;
        if ((-(x + y) * (x + y) + judge) % 2 != 0)
          continue;
        // cout << "c" << endl;
        ans++;
      }
    }
    cout << ans << endl;
  }

  return 0;
}