Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x)                                                      \\
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \\
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll x;
  cin >> x;

  vll tbl;
  rep(i, 121) tbl.push_back(i * i * i * i * i);

  ll n = tbl.size();
  rep(i, n) rep(j, n) {
    ll a5 = tbl[i], b5 = tbl[j];
    if (a5 - b5 == x) {
      cout << i << " " << j << endl;
      return 0;
    }
    if (a5 + b5 == x) {
      cout << i << " " << -j << endl;
      return 0;
    }
  }

  return 0;
}


Error: 0

Fixed submission:

#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x)                                                      \\
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \\
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll x;
  cin >> x;
  for (ll i = 0; abs(i * i * i * i * i) <= x; i++) {
    ll b5 = i * i * i * i * i;
    for (ll j = 0; abs(j * j * j * j * j) <= abs(x - b5); j++) {
      ll a5 = j * j * j * j * j;
      if (a5 - b5 == x) {
        cout << j << " " << i << endl;
        return 0;
      }
    }
    for (ll j = 0; abs(j * j * j * j * j) <= abs(x - b5); j--) {
      ll a5 = j * j * j * j * j;
      if (a5 - b5 == x) {
        cout << j << " " << i << endl;
        return 0;
      }
    }
  }

  for (ll i = 0; abs(i * i * i * i * i) <= x; i--) {
    ll b5 = i * i * i * i * i;
    for (ll j = 0; abs(j * j * j * j * j) <= abs(x - b5); j--) {
      ll a5 = j * j * j * j * j;
      if (a5 - b5 == x) {
        cout << j << " " << i << endl;
        return 0;
      }
    }
    for (ll j = 0; abs(j * j * j * j * j) <= abs(x - b5); j++) {
      ll a5 = j * j * j * j * j;
      if (a5 - b5 == x) {
        cout << j << " " << i << endl;
        return 0;
      }
    }
  }
  assert(false);

  return 0;
}