alexjercan/bugnet huggingface dataset:
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define __ << ' ' <<
#define ___ << ' '
#define bash push_back
#define ALL(x) x.begin(), x.end()
// #define int long long

struct IoSetup {
  IoSetup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
} IoSetup;

using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1, -1, 1, -1, 1};

inline bool inside(int x, int y, int w, int h) {
  return (x >= 0 && y >= 0 && x < w && y < h);
}
template <class T> bool chmax(T &a, const T &b) {
  return (a < b ? a = b, true : false);
}
template <class T> bool chmin(T &a, const T &b) {
  return (a > b ? a = b, true : false);
}
inline int qp(int a, ll b, int mo) {
  ll ans = 1;
  do {
    if (b & 1)
      ans = 1ll * ans * a % mo;
    a = 1ll * a * a % mo;
  } while (b >>= 1);
  return ans;
}

signed main() {

  ll x;

  cin >> x;

  ll s = 0, i = 0;
  vector<pair<ll, int>> v;
  while (abs(s) < 1e18) {
    s = i * i * i * i * i;
    v.bash({s, i});
    v.bash({-s, -i});
    ++i;
  }

  sort(ALL(v));

  for (auto &&a : v) {
    auto p = *lower_bound(ALL(v), pair<ll, int>(a.first - x, -INF));
    if (a.first - p.first == x) {
      cout << a.second __ p.second << endl;
      return 0;
    }
  }

  return 1;

  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define __ << ' ' <<
#define ___ << ' '
#define bash push_back
#define ALL(x) x.begin(), x.end()
// #define int long long

struct IoSetup {
  IoSetup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
} IoSetup;

using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1, -1, 1, -1, 1};

inline bool inside(int x, int y, int w, int h) {
  return (x >= 0 && y >= 0 && x < w && y < h);
}
template <class T> bool chmax(T &a, const T &b) {
  return (a < b ? a = b, true : false);
}
template <class T> bool chmin(T &a, const T &b) {
  return (a > b ? a = b, true : false);
}
inline int qp(int a, ll b, int mo) {
  ll ans = 1;
  do {
    if (b & 1)
      ans = 1ll * ans * a % mo;
    a = 1ll * a * a % mo;
  } while (b >>= 1);
  return ans;
}

signed main() {

  ll x;

  cin >> x;

  ll s = 0, i = 0;
  vector<pair<ll, int>> v;
  while (abs(s) < 1e9) {
    s = i * i * i * i * i;
    v.bash({s, i});
    v.bash({-s, -i});
    ++i;
  }

  sort(ALL(v));

  for (auto &&a : v) {
    auto p = *lower_bound(ALL(v), pair<ll, int>(a.first - x, -INF));
    if (a.first - p.first == x) {
      cout << a.second __ p.second << endl;
      return 0;
    }
  }

  return 1;

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

#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int main(void) {
  ll X;
  cin >> X;
  for (ll A = -1000LL; A < 1000LL; A++) {
    for (ll B = -1000LL; B < 1000LL; B++) {
      if (pow(A, 5LL) - pow(B, 5LL) == X) {
        cout << A << " " << B << endl;
        return (0);
      }
    }
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int main(void) {
  ll X;
  cin >> X;
  ll A = 0;
  ll B = -10000;
  while (pow(A, 5LL) < X)
    A++;
  while (B < 10000 && pow(A, 5LL) - pow(B, 5LL) != X)
    B++;
  if (B != 10000)
    cout << A << " " << B << endl;
  else {
    A--;
    B = -10000;
    while (pow(A, 5LL) - pow(B, 5LL) != X)
      B++;
    cout << A << " " << B << endl;
  }
}
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++)
#define SP << " "

using namespace std;

void PV(vector<int> pvv) {
  rep(i, pvv.size()) cout << pvv[i] SP;
  cout << endl;
}

int main() {

  long long int x, t = 0;
  vector<long long int> v;

  cin >> x;

  while (t * t * t * t * t / t / t / t / t / t == 1) {
    v.push_back(t * t * t * t * t);
    // cout << t * t*t*t*t << endl;
    auto itr = lower_bound(v.begin(), v.end(), x - t * t * t * t * t);
    if (*itr == x - t * t * t * t * t) {
      cout << t SP << -1 * (itr - v.begin()) << endl;
      return 0;
    }
    auto itr2 = lower_bound(v.begin(), v.end(), t * t * t * t * t - x);
    if (*itr2 == t * t * t * t * t - x) {
      cout << t SP << itr2 - v.begin() << endl;
      return 0;
    }
    t++;
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SP << " "

using namespace std;

void PV(vector<int> pvv) {
  rep(i, pvv.size()) cout << pvv[i] SP;
  cout << endl;
}

int main() {

  long long int x, t = 0;
  vector<int> v;

  cin >> x;

  while (t * t * t * t * t / t / t / t / t / t == 1) {
    v.push_back(t * t * t * t * t);
    // cout << t * t*t*t*t << endl;
    auto itr = lower_bound(v.begin(), v.end(), x - t * t * t * t * t);
    if (*itr == x - t * t * t * t * t) {
      cout << t SP << -1 * (itr - v.begin()) << endl;
      return 0;
    }
    auto itr2 = lower_bound(v.begin(), v.end(), t * t * t * t * t - x);
    if (*itr2 == t * t * t * t * t - x) {
      cout << t SP << itr2 - v.begin() << endl;
      return 0;
    }
    t++;
  }

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

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);

  int X;
  cin >> X;

  set<ll> s{0};

  ll i5_prev = 0;
  for (ll i = 1;; ++i) {
    ll i5 = i * i * i * i * i;
    if (i5 - i5_prev > X) {
      break;
    }
    s.insert(i5);
    i5_prev = i5;
  }

  for (ll A = 0;; ++A) {
    ll A5 = A * A * A * A * A;
    ll abs_B5 = abs(A5 - X);
    if (s.count(abs_B5)) {
      for (ll abs_B = 0;; ++abs_B) {
        if (abs_B * abs_B * abs_B * abs_B * abs_B == abs_B5) {
          ll B;
          if (A5 - X >= 0) {
            B = abs_B;
          } else {
            B = -abs_B;
          }
          cout << A << " " << B << endl;
          return 0;
        }
      }
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int X;
  cin >> X;

  set<ll> s{0};

  ll i5_prev = 0;
  for (ll i = 1;; ++i) {
    ll i5 = i * i * i * i * i;
    if (i5 - i5_prev > X) {
      break;
    }
    s.insert(i5);
  }

  for (ll A = 0;; ++A) {
    ll A5 = A * A * A * A * A;
    ll abs_B5 = abs(A5 - X);
    if (s.count(abs_B5)) {
      for (ll abs_B = 0;; ++abs_B) {
        if (abs_B * abs_B * abs_B * abs_B * abs_B == abs_B5) {
          ll B;
          if (A5 - X >= 0) {
            B = abs_B;
          } else {
            B = -abs_B;
          }
          cout << A << " " << B << endl;
          return 0;
        }
      }
    }
  }

  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define f(i, j, k) for (int i = j; i < k; i++)
using namespace std;
int main() {
  long long n, a = 0, b, sum;
  cin >> n;
  vector<long long> y;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      y.push_back(i);
    }
  }
  while (1) {
    f(i, 0, y.size()) {
      b = a - y[i];
      sum = a * a * a * a + a * a * a * b + a * a * b * b + a * b * b * b +
            b * b * b * b;
      if (sum == n / y[i]) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
    a++;
  }
}


Error: -8

Fixed submission:

#include <bits/stdc++.h>
#define f(i, j, k) for (int i = j; i <= k; i++)
using namespace std;
int main() {
  long long n, a = 0, b, sum;
  cin >> n;
  vector<long long> y;
  f(i, 1, sqrt(n)) {
    if (n % i == 0) {
      y.push_back(i);
    }
  }
  while (1) {
    f(i, 0, y.size()) {
      b = a - y[i];
      sum = a * a * a * a + a * a * a * b + a * a * b * b + a * b * b * b +
            b * b * b * b;
      if (sum == n / y[i]) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
    a++;
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int X;
  cin >> X;
  queue<int> A, B;
  A.push(1);
  B.push(0);
  A.push(0);
  B.push(0);
  A.push(2);
  B.push(0);
  while (true) {
    int a = A.front();
    int b = B.front();
    A.pop();
    B.pop();
    if (pow(a, 5) - pow(b, 5) == X) {
      cout << a << " " << b << endl;
      break;
    }
    if (a >= 1 && a == b + 1) {
      A.push(a + 1);
      B.push(b + 1);
    }
    if (a < 1 && a == b + 1) {
      A.push(a - 1);
      B.push(b - 1);
    }
    A.push(a);
    B.push(b - 1);
  }
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  int X;
  cin >> X;
  queue<int> A, B;
  A.push(1);
  B.push(0);
  while (true) {
    int a = A.front();
    int b = B.front();
    A.pop();
    B.pop();
    if (pow(a, 5) - pow(b, 5) == X) {
      cout << a << " " << b << endl;
    }
    if (a > 1 && a == b + 1) {
      A.push(a + 1);
      B.push(b + 1);
    }
    if (a < 1 && a == b + 1) {
      A.push(a - 1);
      B.push(b - 1);
    }
    A.push(a);
    B.push(b - 1);
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using ll = long long;
#define rep(i, n) for (ll i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()

using namespace std;
using Graph = vector<vector<int>>;

int main() {
  ll x;
  cin >> x;
  ll a, b;
  ll y = sqrt(x);
  // cout <<y<<endl;
  rep(i, y) {
    if (x % i == 0) {

      for (ll j = 0; j <= pow(x, 0.6); j++) {
        //  cout<<pow(x,0.2)<<endl;
        if (j * j * j * j + j * j * j * (j - i) + j * j * (j - i) * (j - i) +
                j * (j - i) * (j - i) * (j - i) +
                (j - i) * (j - i) * (j - i) * (j - i) ==
            x / i) {
          a = j;
          b = j - i;
          break;
        }
      }
      if (!(a == 0 && b == 0))
        break;
    }
  }

  cout << a << " " << b << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using ll = long long;
#define rep(i, n) for (ll i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()

using namespace std;
using Graph = vector<vector<int>>;

int main() {
  ll x;
  cin >> x;
  ll a, b;
  ll y = sqrt(x);
  // cout <<y<<endl;
  rep(i, y) {
    if (x % i == 0) {

      for (ll j = 0; j <= pow(x, 0.8); j++) {
        //  cout<<pow(x,0.2)<<endl;
        if (j * j * j * j + j * j * j * (j - i) + j * j * (j - i) * (j - i) +
                j * (j - i) * (j - i) * (j - i) +
                (j - i) * (j - i) * (j - i) * (j - i) ==
            x / i) {
          a = j;
          b = j - i;
          break;
        }
      }
      if (!(a == 0 && b == 0))
        break;
    }
  }

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

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x;
  cin >> x;
  map<ll, ll> mp;
  mp[0] = 0;
  for (ll i = 1; i * i * i * i * i <= 100 * x; i++) {
    ll cur = i * i * i * i * i;
    mp[cur] = i;
    mp[-cur] = -i;
    if (mp.count(cur - x) != 0) {
      cout << i << " " << mp[cur - x] << endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x;
  cin >> x;
  for (ll i = 0; i < 100000; ++i) {
    for (ll j = 0; j < 100000; ++j) {
      if (i * i * i * i * i + j * j * j * j * j == x) {
        cout << i << " " << 0 - j << endl;
        return 0;
      }
    }
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

// 2020-05-03 21:21:37
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
ll f(ll x) { return x * x * x * x * x; }
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll X;
  cin >> X;
  int A = 1;
  while (f(A) - f(A - 1) < 1000000000) {
    for (int B = -200; B < 200; B++) {
      if (f(A) - f(B) == X) {
        cout << A << " " << B << endl;
        return 0;
      }
    }
    A++;
  }
}

Error: TLE

Fixed submission:

// 2020-05-03 21:21:37
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
ll f(ll x) { return x * x * x * x * x; }
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll X;
  cin >> X;
  while (true) {
    ll A = -1000;
    for (ll B = -1000; B < 1000; B++) {
      if (f(A) - f(B) == X) {
        cout << A << " " << B << endl;
        return 0;
      }
    }
    A++;
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  long long x;
  cin >> x;
  int a = 0, b = -63;
  bool ok = true;
  while (true) {
    long long tmp = a * a * a * a * a - b * b * b * b * b;
    if (tmp == x) {
      ok = false;
      cout << a << " " << b << endl;
      break;
    }
    b++;
    if (b == 1) {
      a++;
      if (a == 64)
        break;
      b = -63;
    }
  }
  if (ok) {
    for (int i = 1; i <= 120; i++) {
      bool aa = false;
      for (int j = 0; j < i; j++) {
        if (i * i * i * i * i - j * j * j * j * j == x) {
          aa = true;
          cout << i << " " << j << endl;
          break;
        }
      }
      if (aa)
        break;
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  long long x;
  cin >> x;
  /*long long i=1;
  while(true){
      if(i*i*i*i*i>1000000000){cout << i << endl;break;}
      i++;
  }*/
  int a = 0, b = -63;
  bool ok = true;
  while (true) {
    long long tmp = a * a * a * a * a - b * b * b * b * b;
    if (tmp == x) {
      ok = false;
      cout << a << " " << b << endl;
      break;
    }
    b++;
    if (b == 1) {
      a++;
      if (a == 64)
        break;
      b = -63;
    }
  }
  long long B = 1, maxB = 0;
  if (ok) {
    // cout << "+" << endl;
    while (true) {
      if (B >= sqrt(x))
        break;
      if (x % B == 0) {
        maxB = B;
      }
      B++;
    }
    // cout << maxB << endl;
    long long aee = pow(x, 0.2) + 1;
    while (true) {
      long long bee = aee - maxB;
      if (aee * aee * aee * aee * aee - bee * bee * bee * bee * bee == x) {
        cout << aee << " " << bee << endl;
        break;
      }
      aee++;
    }
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

// 素数と個数を求める
vector<pair<ll, ll>> factorize(ll n) {
  vector<pair<ll, ll>> res;
  for (ll i = 2L; i * i <= n; ++i) {
    if (n % i)
      continue;
    res.emplace_back(i, 0);
    while (n % i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1)
    res.emplace_back(n, 1L);
  return res;
}

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

  rp(a, -200, 200 + 1) { // [-200,200]
    ll a5 = (ll)a * a * a * a * a;
    ll b5 = a5 - X;
    ll sign = 1;
    if (b5 < 0) {
      b5 = -b5;
      sign = -1;
    }

    vector<pair<ll, ll>> pc = factorize(b5);

    ll b = 1;
    if (b5 == 0)
      b = 0;
    for (auto x : pc) {
      ll p, c;
      tie(p, c) = x;
      if (c == 5)
        b *= p;
      else
        break;
    }

    if (b * b * b * b * b == b5) {
      cout << a << " " << sign * b << endl;
      break;
    }
  }
}


Error: TLE

Fixed submission:

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

// 素数と個数を求める
vector<pair<ll, ll>> factorize(ll n) {
  vector<pair<ll, ll>> res;
  for (ll i = 2L; i * i <= n; ++i) {
    if (n % i)
      continue;
    res.emplace_back(i, 0);
    while (n % i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1)
    res.emplace_back(n, 1L);
  return res;
}

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

  rp(a, 0, 1000 + 1) { // [0,100]
    ll a5 = (ll)a * a * a * a * a;
    ll b5 = X - a5;
    if (b5 < 0)
      b5 = -b5;
    vector<pair<ll, ll>> pc = factorize(b5);

    bool ok = true;
    ll b = 1;
    for (auto x : pc) {
      ll p, c;
      tie(p, c) = x;
      if (c != 5) { // not b^5
        ok = false;
        break;
      } else {
        b *= p;
      }
    }

    if (ok) {
      b5 = b * b * b * b * b;
      if ((a5) - (b5) == X) {
        cout << a << " " << b << endl;
        return 0;
      } else if ((a5) - (-b5) == X) {
        cout << a << " " << -b << endl;
        return 0;
      } else if ((-a5) - (b5) == X) {
        cout << -a << " " << b << endl;
        return 0;
      } else if ((-a5) - (-b5) == X) {
        cout << -a << " " << -b << 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;
const int MOD = 1e9 + 7;

int main() {
  ll X;
  cin >> X;
  for (int i = -1000; i <= 1000; i++) {
    for (int j = -1000; j <= 1000; 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;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  ll X;
  cin >> X;
  if (X == 1) {
    cout << 0 << " " << -1 << endl;
    return 0;
  }
  for (ll i = 1; i < X; i++) {
    if (X % i == 0) {
      ll X1 = i;
      ll X2 = X / i;
      for (int b = -X1; b <= X1; b++) {
        ll a = X1 + b;
        ll ans = pow(X1 + b, 4) + pow(X1 + b, 3) * b + pow(X1 + b, 2) * b * b +
                 pow(X1 + b, 1) * b * b * b + b * b * b * b;
        // cout << a << " " << b <<" " << ans<< endl;
        if (X2 == ans) {
          cout << a << " " << b << endl;
          return 0;
        }
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

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

Error: TLE

Fixed submission:

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

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

  for (int i = 1;; i++) {
    int A = i * i * i * i * i;
    int sa = abs(X - A);
    for (int j = 0; j < 5; j++)
      sa = sqrt(sa);
    if (pow(sa, 5) != abs(X - A))
      continue;
    if (X - A > 0)
      cout << i << " " << -1 * sa << endl;
    else
      cout << i << " " << sa << endl;
    return 0;
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll f(ll a, ll b) { return a * a * a * a * a + b * b * b * b * b; }
int main() {
  ll x;
  cin >> x;
  ll a = 0, b = 0;
  while (f(a, 0) < x)
    ++a;
  while (true) {
    ll val = f(a, b);
    if (val == x)
      break;
    if (val > x)
      --a;
    else
      ++b;
  }
  cout << a << " " << (-b) << endl;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll x;
P ans(-1, 1);
ll f(ll a, ll b) { return a * a * a * a * a - b * b * b * b * b; }
void dfs(ll a, ll b) {
  if (ans.first != -1)
    return;

  ll val = f(a, b);
  if (val == x) {
    ans.first = a;
    ans.second = b;
    return;
  }
  if (val > x)
    return;

  dfs(a, b - 1);
  dfs(a + 1, b);
}
int main() {
  cin >> x;
  dfs(0, 0);
  cout << ans.first << " " << ans.second << endl;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
template <class T> inline int chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline int chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int INF = 1 << 29;
const ll LINF = 1LL << 58;

void solve() {
  ll x;
  cin >> x;
  for (ll a = -150; a < 150; a++) {
    for (ll b = -150; b < 150; b++) {
      if (pow(a, 5) - pow(b, 5) == x) {
        cout << a << " " << b << endl;
        return;
      }
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
template <class T> inline int chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline int chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int INF = 1 << 29;
const ll LINF = 1LL << 58;

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

void solve() {
  ll x;
  cin >> x;
  for (ll i = -150; i < 150; i++) {
    auto p = prime_factor(x + pow(i, 5));
    int flag = 1;
    for (auto A : p) {
      if (A.se % 5 != 0)
        flag = 0;
    }
    if (flag) {
      ll a = 1;
      for (auto A : p) {
        if (A.se == 0)
          continue;
        a *= pow(A.fi, (A.se / 5));
      }
      cout << a << " " << i << endl;
      return;
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}