Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
// AUTHOR: RAVAN_2070
// PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
      I ♥ CLARICE STARLING...
        EXPLAINATION BELOW->
*/
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vii;
typedef pair<ll, ll> pii;
typedef map<ll, ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases                                                             \
  ll TC;                                                                       \
  cin >> TC;                                                                   \
  while (TC--)
#define fastio                                                                 \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed << setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i, a, b) for (i = a; i < b; i++)
#define foe(i, a, b) for (i = a; i <= b; i++)
const ll INF = (ll)2e18 + 77;
/*void solve()
{
    int n,x,y,i,b,c;cin>>n;
    int cnt;
    foe(i,1,n)
    {
        cnt=0;
        for(x=1;x<i*i;x++)
        {
            for(y=1;y<i*i;y++)
            {
                b=x+y;c=(x*x+y*y+x*y)-i;
                int d=b*b-4*c;
                if(d<=0)break;
                int sd=sqrt(d);
                if(d>0&&d==sd*sd&&(sd-b>0)&&((sd-b)%2==0))cnt+=2;
            }
        }
        cout<<cnt/2<<"\n";
    }
}*/
void solve() {
  int x, y, z, n;
  cin >> n;
  map<int, int> M;
  for (x = 1; x < n * n; x++) {
    for (y = 1; y < n * n; y++) {
      int d2 = x * x + y * y + x * y;
      if (d2 > n)
        break;
      for (z = 1; z < n * n; z++) {
        int d = x * x + y * y + z * z + x * y + y * z + z * x;
        if (d > n)
          break;
        M[d]++;
      }
    }
  }
  int i;
  foe(i, 1, n) cout << M[i] << "\n";
}
int main() {
  fastio
  // Test_cases
  solve();
  return 0;
}
// map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration
// no greater<int> if you want to apply lowerbound on set use
// s.lower_bound(key),not the one used for vector
//  Syntax to create a min heap for priority queue priority_queue <int,
//  vector<int>, greater<int>>;
// for modinverse use modularexponention(x,M-2,M);
// for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
// vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of
// vector If wrong on pretest 2 means logically wrong

/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
 */


Fixed submission:
// AUTHOR: RAVAN_2070
// PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
      I ♥ CLARICE STARLING...
        EXPLAINATION BELOW->
*/
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vii;
typedef pair<ll, ll> pii;
typedef map<ll, ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases                                                             \
  ll TC;                                                                       \
  cin >> TC;                                                                   \
  while (TC--)
#define fastio                                                                 \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed << setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i, a, b) for (i = a; i < b; i++)
#define foe(i, a, b) for (i = a; i <= b; i++)
const ll INF = (ll)2e18 + 77;
/*void solve()
{
    int n,x,y,i,b,c;cin>>n;
    int cnt;
    foe(i,1,n)
    {
        cnt=0;
        for(x=1;x<i*i;x++)
        {
            for(y=1;y<i*i;y++)
            {
                b=x+y;c=(x*x+y*y+x*y)-i;
                int d=b*b-4*c;
                if(d<=0)break;
                int sd=sqrt(d);
                if(d>0&&d==sd*sd&&(sd-b>0)&&((sd-b)%2==0))cnt+=2;
            }
        }
        cout<<cnt/2<<"\n";
    }
}*/
void solve() {
  int x, y, z, n;
  cin >> n;
  map<int, int> M;
  for (x = 1; x * x < n; x++) {
    for (y = 1; x * x + y * y + x * y < n; y++) {
      for (z = 1; z < n * n; z++) {
        int d = x * x + y * y + z * z + x * y + y * z + z * x;
        if (d > n)
          break;
        M[d]++;
      }
    }
  }
  int i;
  foe(i, 1, n) cout << M[i] << "\n";
}
int main() {
  fastio
  // Test_cases
  solve();
  return 0;
}
// map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration
// no greater<int> if you want to apply lowerbound on set use
// s.lower_bound(key),not the one used for vector
//  Syntax to create a min heap for priority queue priority_queue <int,
//  vector<int>, greater<int>>;
// for modinverse use modularexponention(x,M-2,M);
// for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
// vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of
// vector If wrong on pretest 2 means logically wrong

/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
 */