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

#include <cmath>
#include <iostream>
using namespace std;
int main() {
  long long n, x, y, z, s = 0, i, l, m, b[100000] = {0};
  cin >> n;
  for (x = 1; x <= sqrt(n); x++) {
    for (y = 1; y <= sqrt(n); y++) {
      for (z = 1; z <= sqrt(n); z++) {
        l = (x * x) + (y * y) + (z * z) + (z * x) + (x * y) + (y * z);
        b[l] = b[l] + 1;
      }
    }
  }
  for (i = 1; i <= n; i++) {
    cout << b[i] << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
using namespace std;
int main() {
  long long n, x, y, z, s = 0, i, l, m;
  cin >> n;
  for (i = 1; i <= n; i++) {
    s = 0;
    for (x = 1; x <= sqrt(i); x++) {
      for (y = 1; y <= sqrt(i); y++) {
        l = (x * x) + (y * y) + (x * y);
        if (l < i) {

          for (z = 1; z <= sqrt(i); z++) {
            if ((l + (z * z) + (z * x) + (z * y)) == i) {
              s++;
            }
          }
        }
      }
    }
    cout << s << endl;
  }

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

#include <bits/stdc++.h>
using namespace std;
#define square(a) a *a
#define ssquare(a, b) (a + b) * (a + b)
#define dsquare(a, b) (a + b) * (a - b)
typedef long long ll;
int n;
int cnt[105000] = {0};

int main() {
  for (int x = 1; x < 105; x++) {
    for (int y = 1; y < 105; y++) {
      for (int z = 1; z < 105; z++) {
        cnt[x * x + y * y + z * z + x * y + x * z + y * z]++;
      }
    }
  }
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    printf("%d\\n", cnt[i]);
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define square(a) a *a
#define ssquare(a, b) (a + b) * (a + b)
#define dsquare(a, b) (a + b) * (a - b)
typedef long long ll;
int n;

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    ll cnt = 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 + x * z + y * z == i) {
            cnt++;
          } else if (x * x + y * y + z * z + x * y + x * z + y * z > n) {
            break;
          }
        }
        if (x * x + y * y + x * y >= n)
          break;
      }
      if (x * x >= n)
        break;
    }
    printf("%d\\n", cnt);
  }
  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)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  int data[101][101][101];

  for (int x = 0; x <= 100; x++) {
    for (int y = 0; y <= 100; y++) {
      for (int z = 0; z <= 100; z++) {
        data[x][y][z] = -1;
      }
    }
  }

  // n = 10000;
  for (int i = 1; i <= n; i++) {
    int max = sqrt(i);
    int cnt = 0;
    for (int x = 1; x <= max; x++) {
      for (int y = 1; y <= max; y++) {
        for (int z = 1; z <= max; z++) {
          int temp = 0;
          if (data[x][y][z] == -1) {
            temp = (x * x + y * y + z * z + x * y + y * z + z * x);
            data[x][y][z] = temp;
          } else {
            temp = data[x][y][z];
          }
          if (temp == i) {
            cnt++;
          } else if (temp > i) {
            break;
          }
        }
      }
    }
    cout << cnt << endl;
  }
}

Error: TLE

Fixed submission:

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

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

#include <bits/stdc++.h>
using namespace std;
long long ans[100005], n;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; n >= i * i; i++) {
    for (int j = 1; n >= j * j; j++) {
      for (int k = 1; n >= k * k; k++) {
        ans[i * i + j * j + k * k + i * j + i * k + j * k]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << ans[i] << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
long long ans[10004], n;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; n >= i * i; i++) {
    for (int j = 1; n >= j * j; j++) {
      for (int k = 1; n >= k * k; k++) {
        ans[i * i + j * j + k * k + i * j + i * k + j * k]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << ans[i] << endl;
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
double pie = 3.14159265358979;
long long mod = 1000000007;
//
int main() {
  int n = 0;
  cin >> n;
  int ans[100001] = {};
  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 + k * i <= n) {
          ans[i * i + j * j + k * k + i * j + j * k + k * i]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
double pie = 3.14159265358979;
long long mod = 1000000007;
//
int main() {
  int n = 0;
  cin >> n;
  int ans[1001] = {};
  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 + k * i <= n) {
          ans[i * i + j * j + k * k + i * j + j * k + k * i]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n + 1);
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        int ans = i * i + j * j + k * k + i * j + j * k + k * i;
        if (ans <= n)
          vec[ans]++;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << vec[i] << endl;
}


Error: TLE

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n + 1);
  for (int l = 1; l <= n; l++) {
    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 + k * i == l && i == j &&
              j == k && k == i) {
            vec[l] = 1;
            break;
          } else if (i * i + j * j + k * k + i * j + j * k + k * i == l &&
                     i != j && j != k && k != i) {
            vec[l] = 6;
            break;
          } else if (i * i + j * j + k * k + i * j + j * k + k * i == l) {
            vec[l] = 3;
            break;
          }
        }
      }
    }
    cout << vec[l] << endl;
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define ll long long

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

  ll n;
  cin >> n;
  vector<int> v(n, 0);
  for (int x = 1; x < 101; x++) {
    for (int y = 1; y < 101; y++) {
      for (int z = 1; z < 101; z++) {
        ll m = x * x + y * y + z * z + x * z + z * y + x * y;
        if (m <= n)
          v[m - 1]++;
      }
    }
  }
  for (int i = 0; i < n; i++)
    cout << v[i] << '\\n';
}


Error: TLE

Fixed submission:

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

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

  int n;
  cin >> n;
  int a, b, c;

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

    for (int x = 1; x * x <= i; x++) {
      for (int y = 1; y * y <= i; y++) {
        for (int z = 1; z * z <= i; z++) {
          a = (x + y) * (x + y);
          b = (z + y) * (z + y);
          c = (x + z) * (x + z);
          if (a + b + c == 2 * i)
            ans++;
        }
      }
    }
    cout << ans << '\\n';
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for (ll i = 0; i < (n); i++)
#define rep2(i, n) for (ll i = 0; i < (n); i++)
#define rep3(i, a, b) for (ll i = (a); i < (b); i++)
#define rep4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for (ll i = (n)-1; i >= 0; i--)
#define rrep2(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rrep3(i, a, b) for (ll i = (a)-1; i >= (b); i--)
#define rrep4(i, a, b, c) for (ll i = (a)-1; i >= (b); i -= (c))
#define rrep(...)                                                              \\
  overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
const ll INF = 1e18, MOD = 1e9 + 7;
const int iINF = 1e9;

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

  int n;
  cin >> n;

  //(x+y+z)^2 - (xy+yz+zx) == n
  rep(i, 1, n + 1) {

    int ans = 0;
    int sq = sqrt(i);
    rep(a, 1, sq + 1) rep(b, 1, a + 1) rep(c, 1, b + 1) {
      if ((pow(a + b + c, 2) - (a * b + b * c + c * a)) == i) {
        if (a == b && b == c)
          ans++;
        else if (a == b || b == c || c == a)
          ans += 3;
        else
          ans += 6;
      }
    }
    cout << ans << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for (ll i = 0; i < (n); i++)
#define rep2(i, n) for (ll i = 0; i < (n); i++)
#define rep3(i, a, b) for (ll i = (a); i < (b); i++)
#define rep4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for (ll i = (n)-1; i >= 0; i--)
#define rrep2(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rrep3(i, a, b) for (ll i = (a)-1; i >= (b); i--)
#define rrep4(i, a, b, c) for (ll i = (a)-1; i >= (b); i -= (c))
#define rrep(...)                                                              \\
  overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
const ll INF = 1e18, MOD = 1e9 + 7;
const int iINF = 1e9;

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

  int n;
  cin >> n;

  //(x+y+z)^2 - (xy+yz+zx) == n
  rep(i, 1, n + 1) {

    int ans = 0;
    int sq = sqrt(i);
    rep(a, 1, sq + 1) rep(b, 1, sq + 1) rep(c, 1, sq + 1) {
      if ((pow(a + b + c, 2) - (a * b + b * c + c * a)) == i)
        ans++;
    }
    cout << ans << endl;
  }

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

#include <bits/stdc++.h>
using namespace std;
int n;
int ch(int i) {
  int x = 0;
  for (int j = 1; j <= i / 2; ++j) {
    if (j * j + 2 * j > i)
      break;
    for (int k = 1; k <= i / 2; ++k) {
      if (k * k + j * j + k * j > i)
        break;
      for (int l = 1; l <= i / 2; ++l) {
        if (j * j + k * k + l * l + j * k + j * l + l * k > i)
          break;
        if (j * j + k * k + l * l + j * k + j * l + l * k == i) {
          x++;
        }
      }
    }
  }
  return x;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    printf("%d\\n", ch(i));
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int n;
int ch(int i) {
  for (int j = 1; j < i / 3; ++j) {
    for (int k = 1; k < i / 3; ++k) {
      for (int l = 1; l < i / 3; ++l) {
        if (j * j + k * k + l * l + j * k + j * l + l * k == i) {
          if (j == k && k == l) { /*printf("jkl:%d %d %d ",j,k,l);*/
            return 1;
          } else if (j == k || j == l ||
                     k == l) { /*printf("jkl:%d %d %d ",j,k,l);*/
            return 3;
          }
          if (k != j && j != l) { /*printf("jkl:%d %d %d ",j,k,l);*/
            return 6;
          }
        }
        if (j * j + k * k + l * l > i)
          break;
      }
    }
  }
  return 0;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    printf("%d\\n", ch(i));
  }
}
Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int N;
  cin >> N;
  int m = floor(sqrt((4 * N + 1) - 1) / 2);
  for (int n = 1; n <= N; n++) {
    int cnt = 0;
    for (int x = 1; x <= m; 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) {
              cnt++;
            } else if (x != y && y != z && z != x) {
              cnt += 6;
            } else {
              cnt += 3;
            }
          }
        }
      }
    }
    cout << cnt << endl;
  }
}


Error: TLE

Fixed submission:

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

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

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

int main() {
  int N;
  cin >> N;
  vector<int> ans(N + 1);
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int a = x * x + y * y + z * z + x * y + y * z + z * x;
        if (a <= N)
          ans[a]++;
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    cout << ans[i] << endl;
  }
}


Error: -11

Fixed submission:

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

int main() {
  int N;
  cin >> N;
  vector<int> ans(N);
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        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: Runtime Error

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

int main(void) {
  int n;
  cin >> n;
  vector<long long> ans(100001);
  for (long x = 1; n >= x * x * 3; x++) {
    ans[x * x * 6 - 1] += 1;
  }

  for (long x = 1; n >= x * x * 3; x++) {
    for (long y = x + 1; n >= x * x * 3 + y * y + x * y * 2; y++) {
      ans[x * x * 3 + y * y + x * y * 2 - 1] += 3;

      ans[y * y * 3 + x * x + x * y * 2 - 1] += 3;
    }
  }

  for (long x = 1; n >= x * x * 3; x++) {
    for (long y = x + 1; n >= x * x * 3 + y * y + x * y * 2; y++) {
      for (long z = y + 1; n >= x * x + y * y + z * z + x * y + y * z + z * x;
           z++) {
        ans[x * x + y * y + z * z + x * y + y * z + z * x - 1] += 6;
      }
    }
  }

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


Error: -6
malloc(): corrupted top size


Fixed submission:

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

int main(void) {
  int n;
  cin >> n;
  vector<int> ans(n);
  for (int x = 1; n >= x * x * 3; x++) {
    ans[x * x * 6 - 1] += 1;
  }

  for (int x = 1; n >= x * x * 3; x++) {
    for (int y = x + 1; n >= x * x * 3 + y * y + x * y * 2; y++) {
      ans[x * x * 3 + y * y + x * y * 2 - 1] += 3;

      ans[y * y * 3 + x * x + x * y * 2 - 1] += 3;
    }
  }

  for (int x = 1; n >= x * x * 3; x++) {
    for (int y = x + 1; n >= x * x * 3 + y * y + x * y * 2; y++) {
      for (int z = y + 1; n >= x * x + y * y + z * z + x * y + y * z + z * x;
           z++) {
        ans[x * x + y * y + z * z + x * y + y * z + z * x - 1] += 3;
      }
    }
  }

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

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <math.h>
#include <set>
#define pai arccos(-1);
#define keta(n) cout << fixed << setprecision((n));
#define ll long long;
int main() {
  int n;
  cin >> n;
  vector<int> ans(n + 1);
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int s = x * x + y * y + z * z + x * y + y * z + z * x;
        if (s > n)
          break;
        ans[s]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <math.h>
#include <set>
#define pai arccos(-1);
#define keta(n) cout << fixed << setprecision((n));
#define ll long long;

long int func(int N) {

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

#include <bits/stdc++.h>
#include <iostream>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, n) for (int i = n - 1; i >= 0; --i)
#define yesno(flg)                                                             \\
  if (flg) {                                                                   \\
    cout << "YES" << endl;                                                     \\
  } else {                                                                     \\
    cout << "NO" << endl;                                                      \\
  }
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P1;
typedef pair<int, int> Pi;
typedef pair<double, Pi> Pdi;
typedef pair<ll, int> Pli;
typedef pair<P1, ll> P2;
typedef pair<string, string> Ps;
const ll INF = 1000000000000000001;
struct edge {
  int to, cost;
};
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
struct Road {
  double cost;
  int a, b;
};
struct pos {
  // 1 変数を入れる;
  int x, y, sx, sy, cost;
};
int f[10001] = {};

int main() {

  int n;
  cin >> n;
  for (int i = 1; i < 101; i++) {
    for (int j = 1; j < 101; j++) {
      for (int k = 1; k < 101; k++) {
        ll t = i * i + j * j + k * k + i * j + j * k + k * i;
        if (t > n)
          break;
        f[t]++;
      }
    }
  }
  rep(i, n) cout << f[i + 1] << endl;

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#include <iostream>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, n) for (int i = n - 1; i >= 0; --i)
#define yesno(flg)                                                             \\
  if (flg) {                                                                   \\
    cout << "YES" << endl;                                                     \\
  } else {                                                                     \\
    cout << "NO" << endl;                                                      \\
  }
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P1;
typedef pair<int, int> Pi;
typedef pair<double, Pi> Pdi;
typedef pair<ll, int> Pli;
typedef pair<P1, ll> P2;
typedef pair<string, string> Ps;
const ll INF = 1000000000000000001;
struct edge {
  int to, cost;
};
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
struct Road {
  double cost;
  int a, b;
};
struct pos {
  // 1 変数を入れる;
  int x, y, sx, sy, cost;
};
int f[101] = {};

int main() {

  int n;
  cin >> n;
  for (int i = 1; i < 101; i++) {
    for (int j = 1; j < 101; j++) {
      for (int k = 1; k < 101; k++) {
        ll t = i * i + j * j + k * k + i * j + j * k + k * i;
        if (t > n)
          break;
        f[t]++;
      }
    }
  }
  rep(i, n) cout << f[i + 1] << endl;

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

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

int main() {
  cin.tie(0)->sync_with_stdio(false);

  int n;
  cin >> n;

  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    for (int x = 1; x <= sqrt(n); x++) {
      for (int y = 1; y <= sqrt(n); y++) {
        double d = sqrt(-2 * x * y - 3 * pow(x, 2) - 3 * pow(y, 2) + 4 * i);
        if (floor(d) == d) {
          double z = (-x - y + d) / 2;
          if (floor(z) == z && z > 0) {
            if (pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x == i)
              cnt++;
          }
        }
      }
    }
    cout << cnt << '\\n';
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  cin.tie(0)->sync_with_stdio(false);

  int n;
  cin >> n;

  for (int i = 1; i <= n; i++) {
    int cnt = 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 (pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x == i)
            cnt++;
        }
      }
    }
    cout << cnt << '\\n';
  }
  return 0;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> ans(10050, 0);
  for (int i = 1; i < 105; i++) {
    for (int j = 1; j < 105; j++) {
      for (int k = 1; k < 105; k++) {
        int v = i * i + j * j + k * k + i * j + j * k + i * k;
        if (v < 10050)
          ans.at(v)++;
      }
    }
  }
  for (int i = 1; i <= N; i++)
    cout << ans.at(i) << endl;
}

Error: 0

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> ans(10000, 0);
  for (int i = 1; i < 100; i++) {
    for (int j = 1; j < 100; j++) {
      for (int k = 1; k < 100; k++) {
        int v = i * i + j * j + k * k + i * j + j * k + i * k;
        if (v < 10000)
          ans.at(v)++;
      }
    }
  }
  for (int i = 1; i <= N; i++)
    cout << ans.at(i) << endl;
}
Problem p02608 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N;
  cin >> N;
  vector<int> answer(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)
          answer[x * x + y * y + z * z + x * y + y * z + z * x]++;
      }
    }
  }
  for (int i = 1; i <= N; i++)
    cout << answer[i] << endl;
}

Error: -11

Fixed submission:

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

int main() {
  int N;
  cin >> N;
  vector<int> answer(N, 0);
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        answer[x * x + y * y + z * z + x * y + y * z + z * x]++;
      }
    }
  }
  for (int i = 0; i < N; i++)
    cout << answer[i] << endl;
}