Problem p02690 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ul = unsigned long;
using ull = unsigned long long;
#define vec vector
#define rep(_i, _n) for (ll _i = 0; _i < _n; _i++)
#define rep2(_i, _s, _n) for (ll _i = _s; _i < _n; _i++)
#define elif else if
#define push(_a) push_back(_a)
#define fullSort(_a) sort(_a.begin(), _a.end())
#define inputVecI(_name, _n)                                                   \
  vec<int> _name(_n);                                                          \
  rep(_i, _n) cin >> _name[_i];
#define inputVecL(_name, _n)                                                   \
  vec<long> _name(_n);                                                         \
  rep(_i, _n) cin >> _name[_i];
#define inputVecLL(_name, _n)                                                  \
  vec<ll> _name(_n);                                                           \
  rep(_i, _n) cin >> _name[_i];
#define inputVecS(_name, _n)                                                   \
  vec<string> _name(_n);                                                       \
  rep(_i, _n) cin >> _name[_i];
#define findMaxIdx(_name)                                                      \
  distance(_name.begin(), max_element(_name.begin(), _name.end()))
#define printVec(_vec)                                                         \
  cout << "{";                                                                 \
  rep(i, _vec.size() - 1) cout << _vec[i] << ",";                              \
  cout << _vec[_vec.size() - 1];                                               \
  cout << "}\n";
#define append(_x) push_back(_x)
#define mapLoop(_i, _name) for (auto i = _name.begin(); i != _name.end(); i++)

#define pow5(_a) _a *_a *_a *_a *_a

int main() {
  ll X;
  cin >> X;
  vec<ll> mylist(0);
  ll buf = X;
  rep2(i, 1, X + 1) {
    if (X % i == 0) {
      mylist.push_back(i);
    }
  }
  int size = mylist.size();
  rep(i, size) {
    rep2(A, -119, 120) {
      if (pow5(A) - pow5((A - mylist[i])) == X) {
        cout << A << " " << (A - mylist[i]) << endl;
        return 0;
      }
    }
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ul = unsigned long;
using ull = unsigned long long;
#define vec vector
#define rep(_i, _n) for (ll _i = 0; _i < _n; _i++)
#define rep2(_i, _s, _n) for (ll _i = _s; _i < _n; _i++)
#define elif else if
#define push(_a) push_back(_a)
#define fullSort(_a) sort(_a.begin(), _a.end())
#define inputVecI(_name, _n)                                                   \
  vec<int> _name(_n);                                                          \
  rep(_i, _n) cin >> _name[_i];
#define inputVecL(_name, _n)                                                   \
  vec<long> _name(_n);                                                         \
  rep(_i, _n) cin >> _name[_i];
#define inputVecLL(_name, _n)                                                  \
  vec<ll> _name(_n);                                                           \
  rep(_i, _n) cin >> _name[_i];
#define inputVecS(_name, _n)                                                   \
  vec<string> _name(_n);                                                       \
  rep(_i, _n) cin >> _name[_i];
#define findMaxIdx(_name)                                                      \
  distance(_name.begin(), max_element(_name.begin(), _name.end()))
#define printVec(_vec)                                                         \
  cout << "{";                                                                 \
  rep(i, _vec.size() - 1) cout << _vec[i] << ",";                              \
  cout << _vec[_vec.size() - 1];                                               \
  cout << "}\n";
#define append(_x) push_back(_x)
#define mapLoop(_i, _name) for (auto i = _name.begin(); i != _name.end(); i++)

#define pow5(_a) _a *_a *_a *_a *_a

int main() {
  ll X;
  cin >> X;
  ll buf1;
  rep2(A, -119, 120) {
    buf1 = pow5(A);
    rep2(B, -119, A) {
      if (buf1 - pow5(B) == X) {
        cout << A << " " << B << endl;
        return 0;
      }
    }
  }
  return 0;
}