alexjercan/bugnet huggingface dataset:
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {

  long X;
  cin >> X;

  // for (int i = 0; i <= X; i++) {
  //	int A = pow(i,5);

  //	bool br1 = false;
  //	if (br1 == false) {
  //    	for (int j = 0; j <= X; j++) {
  //			if (A < X) {
  //				br1 = true;
  //				break;
  //			}
  //    		int B = pow(j,5);
  //    		if (A < B) break;
  //			if (A < X + B) break;
  //    		if (A == X + B) {
  //    			cout << i << " " << j << endl;
  //    		}
  //    	}
  //	}

  //	for (int j = 0; j <= X; j++) {
  //		if (A > X) {
  //			br = true;
  //			break;
  //		}
  //		int mj = -1 * j;
  //		int B = pow(mj,5);
  //		if (A > X or (-1 * B) > X) break;
  //    	if (A == X + B) {
  //			cout << i << " " << mj << endl;
  //			return 0;
  //		}
  //	}
  //	if (
  //}

  for (int i = -120; i <= 120; i++) {
    for (int j = -120; j <= 120; j++) {
      if (pow(i, 5) - pow(j, 5) == X) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {

  long X;
  cin >> X;

  for (int i = 0; i <= X; i++) {
    int A = pow(i, 5);
    for (int j = 0; j <= X; j++) {
      if (A < X)
        break;
      int B = pow(j, 5);
      if (A < B)
        break;
      if (A < X + B)
        break;
      if (A == X + B) {
        cout << i << " " << j << endl;
      }
    }

    for (int j = 0; j <= X; j++) {
      if (A > X)
        break;
      int mj = -1 * j;
      int B = pow(mj, 5);
      if (A > X or (-1 * B) > X)
        break;
      if (A == X + B) {
        cout << i << " " << mj << endl;
        return 0;
      }
    }
  }

  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)

int main() {
  ll x;
  cin >> x;

  for (ll a = -150; a <= 150; a++) {
    for (ll b = -150; b <= 150; b++) {
      if (pow(a, 5.0) - pow(b, 5.0) == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)

int main() {
  ll x;
  cin >> x;
  long double a;
  ll i = 200;
  while (1) {
    a = pow((x + (i * i * i * i * i)), 0.2);
    if (ceil(a) == floor(a)) {
      cout << a << " " << i << endl;
      return 0;
    }
    i--;
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int X;
  cin >> X;

  for (int A = -200; A < 200; ++A) {
    for (int B = -200; B < A; ++B) {
      if (pow(A, 5) - pow(B, 5) == X) {
        cout << A << " " << B << endl;
        return 0;
      }
    }
  }
}

Error: TLE

Fixed submission:

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

int f(int a, int b) {
  auto ret = pow(a + b, 4) + pow(a + b, 3) * b + pow((a + b) * b, 2) +
             (a + b) * pow(b, 3) + pow(b, 4);
  return ret;
}

int main() {
  int X;
  cin >> X;

  vector<pair<int, int>> v;
  int z = 1;
  while (z * z <= X) {
    if (X % z == 0) {
      v.push_back(make_pair(z, X / z));
      v.push_back(make_pair(X / z, z));
    }
    ++z;
  }
  for (const auto &x : v) {
    const int a = x.first;
    // b >= 0;
    for (int b = 0; b < a; ++b) {
      if (f(a, b) == x.second) {
        cout << a + b << " " << b << endl;
        return 0;
      }
    }
    // b < 0;
    for (int c = 1; pow(c, 5) < X; ++c) {
      int b = -c;
      if (f(a, b) == x.second) {
        cout << a + b << " " << b << endl;
        return 0;
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long int;

int main() {
  ll X;
  cin >> X;

  for (int i = -200; i <= 200; i++) {
    for (int j = -200; j <= 200; j++) {
      if (pow(i, 5) - pow(j, 5) == X) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int MOD = 1000000007;

long long pow(long long x, long long n) {
  long long ret = 1;
  while (n > 0) {
    if (n & 1)
      ret = ret * x % MOD; // n の最下位bitが 1 ならば x^(2^i) をかける
    x = x * x % MOD;
    n >>= 1; // n を1bit 左にずらす
  }
  return ret;
}

int main() {
  int X;
  cin >> X;

  for (int Bp = 0, Bm = 0;; Bp++, Bm--) {
    double A = X + pow(Bp, 5);
    double judge = pow(A, 0.2);
    if (ceil(judge) == floor(judge)) {
      cout << (int)judge << " " << Bp;
      return 0;
    }
    A = X + pow(Bm, 5);
    judge = pow(A, 0.2);
    if (ceil(judge) == floor(judge)) {
      cout << (int)judge << " " << Bm;
      return 0;
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, m, n) for (ll i = m; i < (ll)(n); i++)
#define rrep(i, n, m) for (ll i = n; i >= (ll)(m); i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll f(ll a, ll b) {
  return (a * a * a * a) + (a * a * a * b) + (a * a * b * b) + (a * b * b * b) +
         (b * b * b * b);
}

vector<ll> divisor(ll N) {
  vector<ll> res;
  for (ll i = 1L; i * i <= N; ++i) {
    if (N % i == 0) {
      res.push_back(i);
      ll j = N / i;
      if (j != i) {
        res.push_back(j);
      }
    }
  }
  sort(res.begin(), res.end());
  return res;
}

void solve() {
  ll X;
  cin >> X;
  auto divisors = divisor(X);
  for (ll d : divisors) {
    ll ano = X / d;
    rep2(a, -140, 140 + 1) {
      ll b = a - d;
      if (f(a, b) == ano) {
        cout << a << " " << b << '\\n';
        return;
      }
    }
  }
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  solve();
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, m, n) for (ll i = m; i < (ll)(n); i++)
#define rrep(i, n, m) for (ll i = n; i >= (ll)(m); i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll f(ll a, ll b) {
  return (a * a * a * a) + (a * a * a * b) + (a * a * b * b) + (a * b * b * b) +
         (b * b * b * b);
}

vector<ll> divisor(ll N) {
  vector<ll> res;
  for (ll i = 1L; i * i <= N; ++i) {
    if (N % i == 0) {
      res.push_back(i);
      ll j = N / i;
      if (j != i) {
        res.push_back(j);
      }
    }
  }
  sort(res.begin(), res.end());
  return res;
}

void solve() {
  ll X;
  cin >> X;
  auto divisors = divisor(X);
  for (ll d : divisors) {
    ll ano = X / d;
    rep2(a, -d, d + 1) {
      ll b = a - d;
      if (f(a, b) == ano) {
        cout << a << " " << b << '\\n';
        return;
      }
    }
  }
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  solve();
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, c = -404, cnt = 0, tmp;
  long int a = -404, b = -404;
  vector<int> y = {1};
  cin >> x;
  for (int i = 2; i < pow(x, 0.5); i++) {
    if (x % i == 0) {
      y.push_back(i);
      cnt++;
      if (cnt > 4) {
        break;
      }
    }
  }
  tmp = y.size();
  for (int i = 0; i < tmp; i++) {
    y.push_back(x / y.at(i));
  }
  for (int j = 0; j < int(y.size()); j++) {
    for (int i = 0; i < 10000; i++) {
      c = pow(i + y.at(j), 5) - pow(i, 5);
      if (c == x) {
        a = i + y.at(j);
        b = i;
        break;
      }
      c = pow(i, 5) - pow(i - y.at(j), 5);
      if (c == x) {
        a = i;
        b = i - y.at(j);
        break;
      }
    }
  }
  cout << a << ' ' << b << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, c = -404, y = 1;
  long int a = -404, b = -404;
  cin >> x;
  for (int i = 2; i < x; i++) {
    if (x % i == 0) {
      y = i;
      break;
    }
  }
  for (int i = 0; i < 10000000; i++) {
    c = pow(i + y, 5) - pow(i, 5);
    if (c == x) {
      a = i + y;
      b = i;
      break;
    }
    c = pow(i, 5) - pow(i - y, 5);
    if (c == x) {
      a = i;
      b = i - y;
      break;
    }
  }
  cout << a << ' ' << b << endl;
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

#define fr first
#define se second

using namespace std;

const long long N = 1e3 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

long long x;
long long pw(long long x) { return (x * x * x * x * x); }
int main() {
  ios_base::sync_with_stdio(false);

  cin >> x;
  for (long long i = -N; i <= N; i++) {
    for (long long j = -N; j <= N; j++) {
      if (pw(i) - pw(j) == x) {
        cout << i << " " << j << "\\n";
        return 0;
      }
    }
  }
  assert(0);
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

long long x;
int main() {
  ios_base::sync_with_stdio(false);

  cin >> x;
  for (long long a = -3980; a <= 3980; a++) {
    long long b = (a * a * a * a * a) - x;
    if ((a * a * a * a * a) - (b * b * b * b * b) == x) {
      cout << a << " " << b << "\\n";
      return 0;
    }
  }
  assert(0);
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll f(ll n) { return n * n * n * n * n; }
int main() {
  ll x;
  cin >> x;
  for (ll i = -200; i <= 200; i++) {
    for (ll j = -200; j <= 200; j++) {
      if (f(i) - f(j) == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll kai(ll x) { return x * x * x * x * x; }
int main() {
  ll X;
  cin >> X;
  ll ans_x;
  for (ll i = 1; i <= X; i++) {
    if (kai(i) >= X) {
      ans_x = i - 1;
      X = kai(i - 1) - X;
      break;
    }
  }
  // cout<<X<<endl;
  if (X == 0) {
    cout << ans_x << " " << 0 << endl;
    return 0;
  } else if (X < 0) {
    ll i = -1;
    while (true) {
      if (kai(i) == X) {
        cout << ans_x << "  " << i << endl;
        return 0;
      }
      i--;
    }
  } else {
    ll j = 1;
    while (true) {
      if (kai(j) == X) {
        cout << ans_x << " " << j << endl;
        return 0;
      }
      j++;
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
int main() {
  ll n;
  cin >> n;
  for (int i = -120; i <= 120; i++) {
    for (int j = -120; j <= 120; j++) {
      ll x = (i * i * i * i * i) - (j * j * j * j * j);
      if (x == n) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}


Error: 1

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
int main() {
  ll n;
  cin >> n;
  for (int i = -120; i <= 120; i++) {
    for (int j = -120; j <= 120; j++) {
      if (n == (i * i * i * i * i) - (j * j * j * j * j)) {
        cout << i << " " << j << endl;
        return 1;
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
int main() {
  ll n;
  cin >> n;
  for (int i = -120; i <= 120; i++) {
    for (int j = -120; j <= 120; j++) {
      if (n == (i * i * i * i * i) - (j * j * j * j * j)) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}


Error: 1

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
int main() {
  ll n;
  cin >> n;
  for (int i = -120; i <= 120; i++) {
    for (int j = -120; j <= 120; j++) {
      ll x = (i * i * i * i * i) - (j * j * j * j * j);
      if (x == n) {
        cout << i << " " << j << endl;
        return 1;
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  ll x;
  cin >> x;
  vector<ll> ab(400);
  vector<ll> num(400);
  for (ll i = 0; i <= 200; i++) {
    ab[i] = i * i * i * i * i;
    num[i] = i;
    ab[i + 200] = -i * i * i * i * i;
    num[i + 200] = -i;
  }

  for (int i = 0; i < 400; i++) {
    for (int j = 0; j < 400; j++) {
      if ((ab[i] - ab[j]) == x) {
        cout << num[i] << ' ' << num[j] << endl;
        // cout << i << ' ' << j << endl;
        return 0;
      }
    }
  }
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  ll x;
  cin >> x;
  vector<pair<ll, ll>> ab(200);
  for (ll i = 0; i <= 99; i++) {
    ab[i].first = i * i * i * i * i;
    ab[i].second = i;
    ab[i + 99].first = -i * i * i * i * i;
    ab[i + 99].second = -i;
  }

  for (int i = 0; i < 200; i++) {
    for (int j = 0; i < 200; j++) {
      if ((ab[i].first - ab[j].first) == x) {
        cout << ab[i].second << ' ' << ab[j].second << endl;
        return 0;
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

int main() {
  llong X;
  cin >> X;
  for (llong A = -200; A <= 200; A++) {
    for (llong B = 0; B >= -200; B--) {
      llong lhs = A * A * A * A * A;
      llong rhs = B * B * B * B * B + X;
      if (lhs == rhs) {
        cout << A << " " << B << endl;
        return 0;
      }
    }
  }
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

bool isExist(llong rhs, llong &A) {
  A = 0;
  llong lhs = 0;
  while (lhs < rhs) {
    lhs = A * A * A * A * A;
    ++A;
  }
  if (lhs == rhs) {
    --A;
    return true;
  }
  return false;
}

int main() {
  llong X;
  cin >> X;
  llong A;
  llong B = 0;
  while (true) {
    llong rhs = B * B * B * B * B + X;
    bool exist = isExist(rhs, A);
    if (exist)
      break;
    B -= 1;
  }
  cout << A << ' ' << B << endl;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  ll x;
  cin >> x;
  for (ll a = -200; a <= 200; a++) {
    for (ll b = -200; b <= 200; b++) {
      if (a * a * a * a * a - b * b * b * b * b == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  ll x;
  cin >> x;
  for (ll a = 0;; a++) {
    ll b5 = abs(a * a * a * a * a - x);
    double b = pow(b5, 0.2);
    if ((ll)b == b) {
      if (a * a * a * a * a - b * b * b * b * b == x) {
        cout << a << " " << b << endl;
        break;
      } else if (a * a * a * a * a + b * b * b * b * b == x) {
        cout << a << " " << -b << endl;
        break;
      }
    }
    b5 = abs(-a * a * a * a * a - x);
    b = pow(b5, 0.2);
    if ((ll)b == b) {
      if (a * a * a * a * a - b * b * b * b * b == x) {
        cout << -a << " " << b << endl;
        break;
      } else if (a * a * a * a * a + b * b * b * b * b == x) {
        cout << -a << " " << -b << endl;
        break;
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define MOD 1000000007
#define sc(a) scanf("%lld", &a)
#define f0(n) for (ll i = 0; i < n; i++)
#define f1(n) for (ll i = 1; i <= n; i++)
#define pb(v, a) v.push_back(a)
#define pbp(v, a, i) v.push_back(make_pair(a, i))
#define srt(v) sort(v.begin(), v.end());

ll floorRoot5(ll n) {
  ll ans;
  double nn = (double)n;
  double a = pow(n, (1.0 / 5.0));
  ans = (ll)a;
  return ans;
}

int main() {
  ll x;
  cin >> x;
  ll y = floorRoot5(x);
  y = (y + 1) * 2;
  // cout<<y<<endl;
  for (ll i = -y; i <= y; i++) {
    for (ll j = -y; j <= y; j++) {
      ll a = 1;
      ll b = 1;
      // cout<<i<<" "<<j<<" ";
      for (ll it = 1; it <= 5; it++) {
        a = a * i;
        b = b * j;
      }
      // cout<<a<<" "<<b<<endl;1
      if (a - b == x) {
        cout << i << " " << j << endl;
        return 0;
      } else if (b - a == x) {
        cout << j << " " << i << endl;
        return 0;
      }
    }
  }
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define MOD 1000000007
#define sc(a) scanf("%lld", &a)
#define f0(n) for (ll i = 0; i < n; i++)
#define f1(n) for (ll i = 1; i <= n; i++)
#define pb(v, a) v.push_back(a)
#define pbp(v, a, i) v.push_back(make_pair(a, i))
#define srt(v) sort(v.begin(), v.end());

ll floorRoot5(ll n) {
  // Base cases
  if (n == 0 || n == 1)
    return n;

  // Do Binary Search for floor of 5th square root
  ll low = 1, high = n, ans = 0;
  while (low <= high) {
    // Find the middle point and its power 5
    ll mid = (low + high) / 2;
    ll mid5 = mid * mid * mid * mid * mid;

    // If mid is the required root
    if (mid5 == n)
      return mid;

    // Since we need floor, we update answer when
    // mid5 is smaller than n, and move closer to
    // 5'th root
    if (mid5 < n) {
      low = mid + 1;
      ans = mid;
    } else // If mid^5 is greater than n
      high = mid - 1;
  }
  return ans;
}

int main() {
  ll x;
  cin >> x;
  ll y = floorRoot5(x);
  y = y + 1;
  for (ll i = -y; i <= y; i++) {
    for (ll j = -y; j <= y; j++) {
      ll a = 1;
      ll b = 1;
      // cout<<i<<" "<<j<<" ";
      for (ll it = 1; it <= 5; it++) {
        a = a * i;
        b = b * j;
      }
      // cout<<a<<" "<<b<<endl;
      if (a - b == x) {
        cout << i << " " << j << endl;
        return 0;
      } else if (b - a == x) {
        cout << j << " " << i << endl;
        return 0;
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <tuple>
#include <vector>

long fffff(long x) { return x * x * x * x * x; }

std::tuple<long, long> solve2(long x, long aa, long bb) {
  long a = aa;
  long b = bb;
  long a5 = fffff(aa);
  long b5 = fffff(bb);
  do {
    if (a5 - b5 == x)
      return {a, b};
    a += 1;
    b += 1;
    a5 = fffff(a);
    b5 = fffff(b);
  } while (a5 - b5 <= x);

  a = aa - 1;
  b = bb - 1;
  a5 = fffff(a);
  b5 = fffff(b);
  bool flag = false;
  do {
    if (a5 - b5 == x)
      return {a, b};
    if (!flag && a5 - b5 <= x)
      flag = true;
    a -= 1;
    b -= 1;
    a5 = fffff(a);
    b5 = fffff(b);
  } while (!flag || a5 - b5 <= x);

  return {0, 0};
}

std::tuple<long, long> solve(long x) {
  if (x == 1)
    return {0, -1};
  for (long i = 1; i < std::ceil(std::sqrt(x)); ++i) {
    if (x % i)
      continue;

    long a, b;
    std::tie(a, b) = solve2(x, i, 0);
    if (a != 0)
      return {a, b};

    std::tie(a, b) = solve2(x, x / i, 0);
    if (a != 0)
      return {a, b};
  }

  throw 1;
}

int main() {
  long x;
  std::cin >> x;

  long a, b;
  std::tie(a, b) = solve(x);

  std::cout << std::setprecision(20);
  std::cout << a << " " << b << std::endl;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <tuple>
#include <vector>

long fffff(long x) { return x * x * x * x * x; }

std::tuple<long, long> solve(long x) {
  if (x == 1)
    return {0, -1};
  for (long i = 1; i < x; ++i) {
    if (x % i)
      continue;

    long a = i;
    long b = 0;
    long a5 = fffff(a);
    long b5 = fffff(b);
    do {
      if (a5 - b5 == x)
        return {a, b};
      a += 1;
      b += 1;
      a5 = fffff(a);
      b5 = fffff(b);
    } while (a5 - b5 <= x);

    a = i - 1;
    b = -1;
    a5 = fffff(a);
    b5 = fffff(b);
    do {
      if (a5 - b5 == x)
        return {a, b};
      a -= 1;
      b -= 1;
      a5 = fffff(a);
      b5 = fffff(b);
    } while (a5 - b5 <= x);
  }

  throw 1;
}

int main() {
  long x;
  std::cin >> x;

  long a, b;
  std::tie(a, b) = solve(x);

  std::cout << std::setprecision(20);
  std::cout << a << " " << b << std::endl;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> pii;

typedef queue<int> qi;
typedef queue<string> qs;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = (a); i <= (b); i++)
#define repm(i, a, b) for (int i = (a); i >= (b); i--)

#define all(v) v.begin(), v.end()
// sort( all(v) )　などと使える

int main() {
  ll x;
  cin >> x;

  ll aa, bb;
  for (ll a = 0; a < 1000; a++)
    for (ll b = -1000; b < 1000; b++) {
      if (pow(a, 5) - pow(b, 5) == x) {
        aa = a, bb = b;
        break;
      }
    }

  cout << aa << " " << bb << endl;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> pii;

typedef queue<int> qi;
typedef queue<string> qs;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = (a); i <= (b); i++)
#define repm(i, a, b) for (int i = (a); i >= (b); i--)

#define all(v) v.begin(), v.end()
// sort( all(v) )　などと使える

int main() {
  ll x;
  cin >> x;

  ll aa, bb;
  for (ll a = 0; a < 5000; a++)
    for (ll b = -5000; b < 5000; b++) {
      if (pow(a, 5) - pow(b, 5) == x) {
        aa = a, bb = b;
        break;
      }
    }

  cout << aa << " " << bb << endl;
}