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

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

// wierd debugging stuff
#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                 \\
  sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(    \\
            c i) {
sim > struct rge {
  c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) cerr << boolalpha << i;
  ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
  sim dor(const c &) { ris; }
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// end of weird debugging stuff
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
#define FASTER                                                                 \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0)
#define invec(v)                                                               \\
  for (auto &x : v)                                                            \\
    cin >> x;
#define Test                                                                   \\
  int T;                                                                       \\
  cin >> T;                                                                    \\
  while (T--)
#define REP(i, j, k) for (int i = (j); (i) < (k); (i)++)
#define Time() cerr << '\\n' << clock() * 1000 / CLOCKS_PER_SEC << "ms\\n"
#define SZ(x) (int)x.size();
#define all(x) x.begin, x.end()
// no change

// const int MxN = 1e9+5;

int main() {
  ll x;
  ll a, b, a5, b5;
  cin >> x;
  for (int i = -500; i <= 500; i++) {
    for (int j = -500; j <= 500; j++) {
      a = i;
      b = j;
      ll f = a - b;
      if (!f)
        continue;
      if (x % f == 0) {
        a5 = (ll)(a * a * a * a * a);
        b5 = (ll)(b * b * b * b * b);
        f = a5 - b5;
        // debug()<<imie(f);
        if (x == f) {
          cout << a << " " << b;
          exit(0);
        }
      }
    }
  }
  Time();
}


Error: TLE

Fixed submission:

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

// wierd debugging stuff
#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                 \\
  sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(    \\
            c i) {
sim > struct rge {
  c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) cerr << boolalpha << i;
  ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
  sim dor(const c &) { ris; }
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// end of weird debugging stuff
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
#define FASTER                                                                 \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0)
#define invec(v)                                                               \\
  for (auto &x : v)                                                            \\
    cin >> x;
#define Test                                                                   \\
  int T;                                                                       \\
  cin >> T;                                                                    \\
  while (T--)
#define REP(i, j, k) for (int i = (j); (i) < (k); (i)++)
#define Time() cerr << '\\n' << clock() * 1000 / CLOCKS_PER_SEC << "ms\\n"
#define SZ(x) (int)x.size();
#define all(x) x.begin, x.end()
// no change

// const int MxN = 1e9+5;

int main() {
  int x;
  int_fast64_t a, b, a5, b5;
  cin >> x;
  for (int i = 1; i <= x; i++) {
    for (int j = -x; j < i; j++) {
      a = i;
      b = j;
      int f = a - b;
      if (x % f == 0) {
        a5 = pow(a, 5);
        b5 = pow(b, 5);
        f = a5 - b5;
        // debug()<<imie(f);
        if (x == f) {
          cout << a << " " << b;
          exit(0);
        }
      }
    }
  }
}