Problem p02690 (C++)

Buggy submission (status: Runtime Error):
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx")
// #pragma comment(linker, "/stack:200000000"]

#include <algorithm>
#include <bitset>
#include <chrono>
#include <cmath>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define hm unordered_map
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define cinv(v)                                                                \
  for (auto &x : v)                                                            \
  cin >> x
#define fr(i, n) for (int i = 0; i < n; ++i)
#define fl(i, l, n) for (int i = l; i < n; ++i)

#define int ll

using namespace std;

#ifdef __LOCAL
#define dbg(x) cerr << #x << " : " << x << '\n'
const int maxn = 20;
#else
#define dbg(x)
const int maxn = 2e5 + 20;
#endif

// tg: @galebickosikasa

const ll inf = (ll)2e9;
const ld pi = asin(1) * 2;
const ld eps = 1e-8;
const ll mod = (ll)1e9 + 7;
const ll ns = 97;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int BS(int x) {
  int l = -5300, r = 5300;
  while (r - l > 1) {
    int m = (r + l) / 2;
    if (m * m * m * m * m >= x)
      r = m;
    else
      l = m;
  }
  return r;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int x;
  cin >> x;
  for (int i = -5300; i <= 5300; ++i) {
    int a = i * i * i * i * i;
    int b = a - x;
    int t = BS(b);
    if (t * t * t * t * t == b) {
      cout << i << ' ' << t;
      break;
    }
  }
  exit(1);
}

Fixed submission:
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx")
// #pragma comment(linker, "/stack:200000000"]

#include <algorithm>
#include <bitset>
#include <chrono>
#include <cmath>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define hm unordered_map
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define cinv(v)                                                                \
  for (auto &x : v)                                                            \
  cin >> x
#define fr(i, n) for (int i = 0; i < n; ++i)
#define fl(i, l, n) for (int i = l; i < n; ++i)

#define int ll

using namespace std;

#ifdef __LOCAL
#define dbg(x) cerr << #x << " : " << x << '\n'
const int maxn = 20;
#else
#define dbg(x)
const int maxn = 2e5 + 20;
#endif

// tg: @galebickosikasa

const ll inf = (ll)2e9;
const ld pi = asin(1) * 2;
const ld eps = 1e-8;
const ll mod = (ll)1e9 + 7;
const ll ns = 97;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int BS(int x) {
  int l = -5300, r = 5300;
  while (r - l > 1) {
    int m = (r + l) / 2;
    if (m * m * m * m * m >= x)
      r = m;
    else
      l = m;
  }
  return r;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int x;
  cin >> x;
  for (int i = -5300; i <= 5300; ++i) {
    int a = i * i * i * i * i;
    int b = a - x;
    int t = BS(b);
    if (t * t * t * t * t == b) {
      cout << i << ' ' << t;
      exit(0);
    }
  }
  exit(1);
}