Problem p02608 (C++) — buggy submission, verdict: Runtime Error

#pragma GCC optimze("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
// inbuilt function in c++
// abs(-2)=2 , __gcd(2,3)=1 , swap(a,b) ,
// string/array s = "aba"; sort(s.begin(), s.end());  do {  cout << s << '\\n';
// } while(next_permutation(s.begin(), s.end())); for all permutation of s.
// priority_queue stores the values in descending order q.front() returns
// maximum element. ".size() works for priority_queue."
#include <bits/stdc++.h>
#define int long long int
#define double long double
#define get(a, n)                                                              \\
  for (int i = 0; i < n; i++) {                                                \\
    cin >> a[i];                                                               \\
  }
#define maxm(a)                                                                \\
  int maxi = LLONG_MIN;                                                        \\
  int index;                                                                   \\
  for (int i = 0; i < n; i++) {                                                \\
    if (maxi < a[i]) {                                                         \\
      maxi = a[i];                                                             \\
      index = i;                                                               \\
    }                                                                          \\
  }
#define minm(a)                                                                \\
  int mini = LLONG_MAX;                                                        \\
  int index;                                                                   \\
  for (int i = 0; i < n; i++) {                                                \\
    if (mini > a[i]) {                                                         \\
      mini = a[i];                                                             \\
      index = i;                                                               \\
    }                                                                          \\
  }
#define db(x) cout << "[" << x << "]" << endl;
#define endl "\\n"
#define PI acos(-1)
#define half(a) a % 2 ? (a / 2 + 1) : a / 2
#define array                                                                  \\
  int a[n];                                                                    \\
  for (int i = 0; i < n; i++) {                                                \\
    cin >> a[i];                                                               \\
  }
#define pb push_back
#define all(a) a.begin(), a.end()
#define mod 1000000007
using namespace std;
int por(int x, int y, int p) {
  int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1)
      res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int modInverse(int n, int p) { return por(n, p - 2, p); }
int nCrModPFermat(int n, int r, int p) {
  if (r == 0)
    return 1;
  int fac[n + 1];
  fac[0] = 1;
  for (int i = 1; i <= n; i++)
    fac[i] = (fac[i - 1] * i) % p;
  return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %
         p;
}
template <typename T> void printvec(vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++)
    cout << vec[i] << " ";
  cout << endl;
}
bool cmp(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
vector<int> p;
int fprime = 0;
void seiveprime(int n) {
  fprime = 123;
  bool pr[n + 1];
  memset(pr, true, sizeof(pr));
  for (int p = 2; p * p <= n; p++) {
    if (pr[p] == true) {
      for (int i = p * p; i <= n; i += p)
        pr[i] = false;
    }
  }
  for (int p0 = 2; p0 <= n; p0++)
    if (pr[p0])
      p.pb(p0);
}
void show(int *a) {
  int size = (*(&a + 1) - a) - 1;
  for (int i = 0; i < size; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
}
int binary_search(int *a, int n, int e) {
  int f, l, m;
  f = 0;
  l = n - 1;
  while (f <= l) { // returns index of that value.
    m = (f + l) / 2;
    if (e == a[m])
      return (m);
    else if (e > a[m])
      f = m + 1;
    else
      l = m - 1;
  }
  return -1;
}
vector<int> pf;
void primefactors(int n) {
  while (n % 2 == 0)
    pf.push_back(2), n = n / 2;
  for (int i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      pf.push_back(i);
      n = n / i;
    }
  }
  if (n > 2)
    pf.push_back(n);
  // dont forgot to clear pf vector.
}
// vector<int,greater<int>>fac;
vector<int> fac;
void factors(int n) {
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i)
        fac.push_back(i);
      else
        fac.push_back(i), fac.push_back(n / i);
    }
  }
  // dont forgot to clear fac vector.
}
void solve() {
  int n;
  cin >> n;
  int f[10001];
  int k = sqrt(n - 2);
  for (int i = 0; i <= 10000; i++) {
    f[i] = 0;
  }
  int y = 0;
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= k; j++) {
      for (int w = 1; w <= k; w++) {
        y = i * i + j * j + w * w + i * j + j * w + w * i;
        if (y < 10001)
          f[y]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << f[i] << endl;
  }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  int t = 1;
  //  cin>>t;
  // seiveprime(1000);
  while (t--) {
    solve();
  }
}

Error: 0

Fixed submission:

#pragma GCC optimze("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
// inbuilt function in c++
// abs(-2)=2 , __gcd(2,3)=1 , swap(a,b) ,
// string/array s = "aba"; sort(s.begin(), s.end());  do {  cout << s << '\\n';
// } while(next_permutation(s.begin(), s.end())); for all permutation of s.
// priority_queue stores the values in descending order q.front() returns
// maximum element. ".size() works for priority_queue."
#include <bits/stdc++.h>
#define int long long int
#define double long double
#define get(a, n)                                                              \\
  for (int i = 0; i < n; i++) {                                                \\
    cin >> a[i];                                                               \\
  }
#define maxm(a)                                                                \\
  int maxi = LLONG_MIN;                                                        \\
  int index;                                                                   \\
  for (int i = 0; i < n; i++) {                                                \\
    if (maxi < a[i]) {                                                         \\
      maxi = a[i];                                                             \\
      index = i;                                                               \\
    }                                                                          \\
  }
#define minm(a)                                                                \\
  int mini = LLONG_MAX;                                                        \\
  int index;                                                                   \\
  for (int i = 0; i < n; i++) {                                                \\
    if (mini > a[i]) {                                                         \\
      mini = a[i];                                                             \\
      index = i;                                                               \\
    }                                                                          \\
  }
#define db(x) cout << "[" << x << "]" << endl;
#define endl "\\n"
#define PI acos(-1)
#define half(a) a % 2 ? (a / 2 + 1) : a / 2
#define array                                                                  \\
  int a[n];                                                                    \\
  for (int i = 0; i < n; i++) {                                                \\
    cin >> a[i];                                                               \\
  }
#define pb push_back
#define all(a) a.begin(), a.end()
#define mod 1000000007
using namespace std;
int por(int x, int y, int p) {
  int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1)
      res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int modInverse(int n, int p) { return por(n, p - 2, p); }
int nCrModPFermat(int n, int r, int p) {
  if (r == 0)
    return 1;
  int fac[n + 1];
  fac[0] = 1;
  for (int i = 1; i <= n; i++)
    fac[i] = (fac[i - 1] * i) % p;
  return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %
         p;
}
template <typename T> void printvec(vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++)
    cout << vec[i] << " ";
  cout << endl;
}
bool cmp(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
vector<int> p;
int fprime = 0;
void seiveprime(int n) {
  fprime = 123;
  bool pr[n + 1];
  memset(pr, true, sizeof(pr));
  for (int p = 2; p * p <= n; p++) {
    if (pr[p] == true) {
      for (int i = p * p; i <= n; i += p)
        pr[i] = false;
    }
  }
  for (int p0 = 2; p0 <= n; p0++)
    if (pr[p0])
      p.pb(p0);
}
void show(int *a) {
  int size = (*(&a + 1) - a) - 1;
  for (int i = 0; i < size; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
}
int binary_search(int *a, int n, int e) {
  int f, l, m;
  f = 0;
  l = n - 1;
  while (f <= l) { // returns index of that value.
    m = (f + l) / 2;
    if (e == a[m])
      return (m);
    else if (e > a[m])
      f = m + 1;
    else
      l = m - 1;
  }
  return -1;
}
vector<int> pf;
void primefactors(int n) {
  while (n % 2 == 0)
    pf.push_back(2), n = n / 2;
  for (int i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      pf.push_back(i);
      n = n / i;
    }
  }
  if (n > 2)
    pf.push_back(n);
  // dont forgot to clear pf vector.
}
// vector<int,greater<int>>fac;
vector<int> fac;
void factors(int n) {
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i)
        fac.push_back(i);
      else
        fac.push_back(i), fac.push_back(n / i);
    }
  }
  // dont forgot to clear fac vector.
}
void solve() {
  int n;
  cin >> n;
  int f[10001];
  int k = sqrt(n - 2);
  for (int i = 0; i <= 10000; i++) {
    f[i] = 0;
  }
  int y = 0;
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= k; j++) {
      for (int w = 1; w <= k; w++) {
        y = i * i + j * j + w * w + i * j + j * w + w * i;
        f[y]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << f[i] << endl;
  }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  int t = 1;
  //  cin>>t;
  // seiveprime(1000);
  while (t--) {
    solve();
  }
}