Problem p02608 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// ---------- PBDS -----------------

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
// slow but fast ORZ :)
// ----------------------------------

using namespace std;
using namespace __gnu_pbds;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define ALL(a) a.begin(), a.end()
#define MP(a, b) make_pair(a, b)
#define PB(a) push_back(a)
#define EB(a) emplace_back(a) // care when use
#define boost                                                                  \\
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0),                       \\
      cout << fixed << setprecision(10);
// #define ll long long int
#define int long long int

#define DEBUG

#ifdef DEBUG

#define debug(args...) (Debugger()), args

class Debugger {
public:
  Debugger(const std::string &_separator = " | ")
      : first(true), separator(_separator) {}

  template <typename ObjectType> Debugger &operator,(const ObjectType &v) {
    if (!first)
      std::cerr << separator;
    std::cerr << v;
    first = false;
    return *this;
  }
  ~Debugger() { std::cerr << std::endl; }

private:
  bool first;
  std::string separator;
};

#else
#define debug(args...)
#endif

void solve() {

  int N;
  cin >> N;

  std::vector<int> v(N + 1);

  int ans = 0;
  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 temp = x * x + y * y + z * z + x * y + x * z + y * z;

        if (temp <= N) {
          v[temp]++;
        }
      }
    }
  }

  for (int i = 1; i <= N; ++i) {
    cout << v[i] << "\\n";
  }
}

int32_t main() {

  boost;

  int T;

  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// ---------- PBDS -----------------

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
// slow but fast ORZ :)
// ----------------------------------

using namespace std;
using namespace __gnu_pbds;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define ALL(a) a.begin(), a.end()
#define MP(a, b) make_pair(a, b)
#define PB(a) push_back(a)
#define EB(a) emplace_back(a) // care when use
#define boost                                                                  \\
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0),                       \\
      cout << fixed << setprecision(10);
// #define ll long long int
#define int long long int

#define DEBUG

#ifdef DEBUG

#define debug(args...) (Debugger()), args

class Debugger {
public:
  Debugger(const std::string &_separator = " | ")
      : first(true), separator(_separator) {}

  template <typename ObjectType> Debugger &operator,(const ObjectType &v) {
    if (!first)
      std::cerr << separator;
    std::cerr << v;
    first = false;
    return *this;
  }
  ~Debugger() { std::cerr << std::endl; }

private:
  bool first;
  std::string separator;
};

#else
#define debug(args...)
#endif

int f(int n) {
  int ans = 0;
  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 temp = x * x + y * y + z * z + x * y + x * z + y * z;
        if (temp == n)
          ans++;
      }
    }
  }

  return ans;
}

void solve() {

  int N;
  cin >> N;

  for (int n = 1; n <= N; ++n) {
    cout << f(n) << "\\n";
  }
}

int32_t main() {

  boost;

  int T;

  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}