Problem p02690 (C++)

Buggy submission (status: Time Limit Exceeded):
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define mod 1000000007
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define repc(i, a, b, c)                                                       \
  for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
// #define mp make_pair
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n + 1) ft.pb((ft[i - 1] * i) % mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r)                                                              \
  (n >= r ? ((ft[n] * mod_in((ft[r] * ft[(n) - (r)]) % mod)) % mod) : 0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'
#define int ll
vector<ll> ft(1, 1LL);

/*======================================================================*/
vector<int> graph[100005];
int arr[100005];
void solve() {
  int n, m;
  cin >> n;
  for (int i = 0;; i++) {
    for (int b = 0; b < 3982; b++)
      if (i * i * i * i * i == n - b * b * b * b * b) {
        cout << i << " " << -b;
        return;
      }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
}

Fixed submission:
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define mod 1000000007
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define repc(i, a, b, c)                                                       \
  for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
// #define mp make_pair
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n + 1) ft.pb((ft[i - 1] * i) % mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r)                                                              \
  (n >= r ? ((ft[n] * mod_in((ft[r] * ft[(n) - (r)]) % mod)) % mod) : 0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'
#define int ll
vector<ll> ft(1, 1LL);

/*======================================================================*/
vector<int> graph[100005];
int arr[100005];
void solve() {
  int n, m;
  cin >> n;
  for (int i = 0;; i++) {
    for (int b = 0; b < 3982; b++)
      if (i * i * i * i * i == n - b * b * b * b * b) {
        cout << i << " " << -b;
        return;
      } else if (i * i * i * i * i == n + b * b * b * b * b) {
        cout << i << " " << b;
        return;
      }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
}