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

#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <cstdint>  // int64_t, int*_t
#include <cstdio>   // printf
#include <deque>    // deque
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <queue>    // queue, priority_queue
#include <set>      // set
#include <stack>    // stack
#include <string>   // string, to_string, stoi
#include <time.h>
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int main() {
  int N;
  cin >> N;
  int f = 1;
  vector<int> kekka(10005);
  // clock_t start = clock();
  //   int n = sqrt(i) ;
  for (int x = 1; x <= 100; ++x) {

    for (int y = 1; y <= 100; ++y) {

      for (int z = 1; z <= 100; ++z) {
        f = x * x + y * y + z * z + x * y + y * z + z * x;
        if (f <= N) {
          kekka.at(f)++;
        }
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    cout << kekka.at(i) << endl;
  }
  // clock_t end = clock();
  // cout << (double)(end - start) / CLOCKS_PER_SEC << endl;
}
/*int main(){
  int N;
  cin >> N;
  for(int i = 1;i <= N;i++){
    int count = 0;
    for(int x = 1; x < sqrt(N) + 1;x++){
      for(int y = x;y < sqrt(N) + 1;y++){
        for(int z = y;z < sqrt(N) + 1;z++){
          int judge = x*x + y*y + z*z + x*y + y*z + z*x;
          if(judge > i){
            break;
          }else if(judge == i){
            if(x == y && y == z){
              count++;
            }else if(x != y && y != z && z != x){
              count += 6;
            }else{
              count += 3;
            }
          }
        }
      }
    }
    cout << count << endl;
  }
}*/


Error: TLE

Fixed submission:

#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <cstdint>  // int64_t, int*_t
#include <cstdio>   // printf
#include <deque>    // deque
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <queue>    // queue, priority_queue
#include <set>      // set
#include <stack>    // stack
#include <string>   // string, to_string, stoi
#include <time.h>
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int main() {
  int N;
  cin >> N;
  int f = 1;
  // clock_t start = clock();
  for (int i = 1; i <= N; i++) {
    if (i >= pow(5, f + 1)) {
      f++;
    }
    int n = sqrt(i) - f;
    int count = 0;
    for (int x = 1; x <= n; x++) {
      if (x * x <= i) {
        for (int y = 1; y <= n; y++) {
          if (x * x + y * y + x * y <= i) {
            for (int z = 1; z <= n; z++) {
              if ((x * x + y * y + z * z + x * y + y * z + z * x) == i) {
                count++;
              }
            }
          }
        }
      }
    }
    cout << count << endl;
  }
  // clock_t end = clock();
  // cout << (double)(end - start) / CLOCKS_PER_SEC << endl;
}