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

#include <algorithm>
#include <assert.h>
#include <bitset>
#include <chrono>
#include <cstdio>
#include <ctime>
#include <ctype.h>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define debug(name) DEBUG(#name, (name))
template <typename T> void DEBUG(string label, T value) {
  cerr << "[" << label << " = " << value << "]\\n";
}

void solve() {
  ll x;
  cin >> x;
  const int N = 3980;
  vector<ll> table(N + 1);
  for (int i = 0; i <= N; ++i) {
    table[i] = 1LL * i * i * i * i * i;
  }
  for (int i = 0; i <= N; ++i) {
    for (int j = 0; j <= N; ++j) {
      if (table[i] + table[j] == x) {
        cout << i << " " << -j << endl;
        return;
      }
      if (table[i] - table[j] == x) {
        cout << i << " " << j << endl;
        return;
      }
    }
  }
  assert(0);
}
int main(int argv, char **argc) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  solve();
}


Error: WA

Fixed submission:

#include <algorithm>
#include <assert.h>
#include <bitset>
#include <chrono>
#include <cstdio>
#include <ctime>
#include <ctype.h>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define debug(name) DEBUG(#name, (name))
template <typename T> void DEBUG(string label, T value) {
  cerr << "[" << label << " = " << value << "]\\n";
}

void solve() {
  ll x;
  cin >> x;
  const int N = 72;
  vector<ll> table(N + 1);
  for (int i = 0; i <= N; ++i) {
    table[i] = 1LL * i * i * i * i * i;
  }
  for (int i = 0; i <= N; ++i) {
    for (int j = 0; j <= N; ++j) {
      if (table[i] + table[j] == x) {
        cout << i << " " << -j << endl;
        return;
      }
      if (table[i] - table[j] == x) {
        cout << i << " " << j << endl;
        return;
      }
    }
  }
  assert(0);
}
int main(int argv, char **argc) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

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

#include <bits/stdc++.h>
using namespace std;
#define NewNode (ListNode *)malloc(sizeof(ListNode))
#define Mem(a, b) memset(a, b, sizeof(a))
const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-10;
const unsigned long long mod = 998244353;
const double II = 3.1415926535;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> piil;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  ll x, i, j;
  cin >> x;
  for (i = 0; i <= 200; i++) {
    for (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;
#define NewNode (ListNode *)malloc(sizeof(ListNode))
#define Mem(a, b) memset(a, b, sizeof(a))
const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-10;
const unsigned long long mod = 998244353;
const double II = 3.1415926535;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> piil;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  ll x;
  cin >> x;
  ll a = (ll)pow(x * 1.0, 0.2) + 0.5, b = 0;
  while (pow(a, 5) - pow(b, 5) != x)
    b--;
  cout << a << " " << b << endl;
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (auto i = a; i < b; i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll power(ll x, ll p) {
  ll a = 1;
  while (p > 0) {
    if (p % 2 == 0) {
      x *= x;
      p /= 2;
    } else {
      a *= x;
      p--;
    }
  }
  return a;
}

#define INF 1 << 30
int t[100][100];
int main() {
  ll X, l, r, k, m;
  cin >> X;
  k = (ll)sqrt(X);
  rep(i, 1ll, k + 1) {
    if (X % i == 0) {
      rep(l, 0ll, X) {
        r = power(l, 5) - power(l - i, 5);
        if (l >= i && r > X)
          break;
        if (r == X) {
          printf("%lld %lld\\n", l, l - i);
          return 0;
        }
      }
    }
  }
  return 0;
}


Error: WA

Fixed submission:

#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (auto i = a; i < b; i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll power(ll x, ll p) {
  ll a = 1;
  while (p > 0) {
    if (p % 2 == 0) {
      x *= x;
      p /= 2;
    } else {
      a *= x;
      p--;
    }
  }
  return a;
}

#define INF 1 << 30
int t[100][100];
int main() {
  ll X, l, r, k, m;
  cin >> X;
  k = (ll)sqrt(X);
  rep(i, 1ll, k + 1) {
    if (X % i == 0) {
      rep(l, 0ll, X) {
        if (X % (2 * l - i))
          continue;
        if (power(l, 5) - power(l - i, 5) == X) {
          printf("%lld %lld\\n", l, l - i);
          return 0;
        }
      }
    }
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

int main() {
  int X;

  cin >> X;

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

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <queue>
#include <string>
#include <vector>
using namespace std;

long long int calcModPow(long long int a, long long int n, long long int m) {
  if (n == 0) {
    return 1 % m;
  }
  if (n == 1) {
    return a % m;
  }

  if (n % 2 == 1) {
    return (a * calcModPow(a, n - 1, m)) % m;
  }

  long long int t = calcModPow(a, n / 2, m);
  return (t * t) % m;
}

int main() {
  long long int X;
  long long int A, B;
  long long int mod = 1000000007;

  cin >> X;

  A = 0;
  B = -pow(X, 0.2);

  while (1) {
    long long int tmp = calcModPow(A, 5, mod) - calcModPow(B, 5, mod);
    if (tmp == X) {
      cout << A << " " << B;
      break;
    }
    if (tmp > X) {
      B++;
    }
    if (tmp < X) {
      A++;
    }
  }

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

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b) { return a ? GCD(b % a, a) : b; }
int main() {
  ll x;
  cin >> x;
  for (ll i = -1e3; i <= 1e3; i++) {
    for (ll j = -1e3; j <= 1e3; j++) {
      if (pow(i, 5) - pow(j, 5) == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b) { return a ? GCD(b % a, a) : b; }
int main() {
  ll x;
  cin >> x;
  for (ll i = -1e4; i <= 1e4; i++) {
    for (ll j = -1e4; j <= 1e4; j++) {
      if (pow(i, 5) - pow(j, 5) == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 1e9

int ansA;
int ansB;

int pow5(int n) { return n * n * n * n * n; }

int solve(int x, int a, int b) {
  int powA = pow5(a);
  if (x - powA > 0) {
    int powi = 0;
    for (int i = 0; powA - powi < x; i--) {
      powi = pow5(i);
      if (powA - powi == x) {
        ansA = a;
        ansB = i;
        return 0;
      }
    }
  } else {
    int powi = 0;
    for (int i = 0; powA - powi < x; i++) {
      powi = pow5(i);
      if (powA - powi == x) {
        ansA = a;
        ansB = i;
        return 0;
      }
    }
  }

  solve(x, a + 1, 0);

  return 0;
}

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

  /*

  solve(x, 0, 0);

  */

  for (int a = 0; a <= 10000000000; a++) {
    for (int b = 0; b <= 10000; b++) {
      if (pow5(a) - pow5(b) == x) {
        cout << a << " " << b << endl;
        return 0;
      }
      if (pow5(-a) - pow5(b) == x) {
        cout << -a << " " << b << endl;
        return 0;
      }
      if (pow5(a) - pow5(-b) == x) {
        cout << a << " " << -b << endl;
        return 0;
      }
      if (pow5(-a) - pow5(-b) == x) {
        cout << -a << " " << -b << endl;
        return 0;
      }
    }
  }

  // cout << ansA << " " << ansB << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 1e9

int ansA;
int ansB;

int pow5(int n) { return n * n * n * n * n; }

int solve(int x, int a, int b) {
  int powA = pow5(a);
  if (x - powA > 0) {
    int powi = 0;
    for (int i = 0; powA - powi < x; i--) {
      powi = pow5(i);
      if (powA - powi == x) {
        ansA = a;
        ansB = i;
        return 0;
      }
    }
  } else {
    int powi = 0;
    for (int i = 0; powA - powi < x; i++) {
      powi = pow5(i);
      if (powA - powi == x) {
        ansA = a;
        ansB = i;
        return 0;
      }
    }
  }

  solve(x, a + 1, 0);

  return 0;
}

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

  solve(x, 0, 0);

  cout << ansA << " " << ansB << endl;
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }

ll l(ll a) { return pow(a, 5); };

ll r(ll b, ll x) { return pow(b, 5) + x; };

map<vll, bool> mp;
void solve(ll a, ll b, ll x) {
  mp[{a, b}] = true;
  queue<vll> task;
  task.push({a, b});
  while (task.size()) {
    ll sz = task.size();
    while (sz--) {
      vll v = task.front();
      task.pop();
      if (l(v[0]) == r(v[1], x)) {
        cout << v[0] << " " << v[1] << endl;
        return;
      } else if (l(v[0]) < r(v[1], x)) {
        if (!mp[{v[0] + 1, v[1]}]) {
          task.push({v[0] + 1, v[1]});
          mp[{v[0] + 1, v[1]}] = true;
        }
        if (!mp[{v[0], v[1] - 1}]) {
          task.push({v[0], v[1] - 1});
          mp[{v[0], v[1] - 1}] = true;
        }
      } else {
        if (!mp[{v[0] - 1, v[1]}]) {
          task.push({v[0] - 1, v[1]});
          mp[{v[0] - 1, v[1]}] = true;
        }
        if (!mp[{v[0], v[1] + 1}]) {
          task.push({v[0], v[1] + 1});
          mp[{v[0], v[1] + 1}] = true;
        }
      }
    }
  }
}

int main() {
  // ios::sync_with_stdio(false);
  // cin.tie(nullptr);
  // const ll p = 1e9 + 7;
  // const ll p = 998244353;

  ll x;
  cin >> x;
  ll a = 0, b = 0;
  solve(a, b, x);
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }

int main() {
  // ios::sync_with_stdio(false);
  // cin.tie(nullptr);
  // const ll p = 1e9 + 7;
  // const ll p = 998244353;

  ll x;
  cin >> x;

  set<ll> st;
  st.insert(0);
  for (ll i = 1;; i++) {
    if (pow(i, 5) > 1e9)
      break;
    st.insert(i);
    st.insert(-i);
  }

  for (auto i = st.begin(); i != st.end(); i++) {
    ll a = *i;
    for (auto j = st.begin(); j != st.end(); j++) {
      ll b = *j;
      if (pow(a, 5) - pow(b, 5) == x) {
        cout << a << " " << b << endl;
        return 0;
      }
      if (pow(b, 5) - pow(a, 5) == x) {
        cout << b << " " << a << endl;
        return 0;
      }
    }
  }
  return 1;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define fastcin                                                                \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
using namespace std;

int main() {

  fastcin

      ll x;
  cin >> x;

  for (ll i = -200; i <= 200; i++) {
    for (ll j = -200; j <= 200; j++) {
      if ((i * i * i * i * i) - (j * j * j * j * j) == x) {
        cout << i << ' ' << j << endl;
        return 0;
      }
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define fastcin                                                                \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
using namespace std;

int main() {

  fastcin

      ll x;
  cin >> x;
  ll d = x;
  while (true) {
    ll a = x + pow(d, 5);
    double b = pow(a, 1 / 5.0);
    ll c = (ll)b;
    if (b - c == 0) {
      cout << b << ' ' << d << endl;
      break;
    }
    d--;
  }

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

#include <algorithm>
#include <cmath>
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
  ll x;
  cin >> x;
  for (int i = -300; i <= 300; i++) {
    for (int j = -300; j <= 300; j++) {

      if (pow(i, 5) - pow(j, 5) == x) {

        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
  ll x;
  cin >> x;
  for (int i = 0; i <= 100000; i++) {
    for (int j = 0; j <= 15999; j++) {
      ll s = i * i * i * i * i;
      ll t = j * j * j * j * j;
      if (s < x) {
        if (s + t == x) {

          cout << i << " "
               << "-" << j << endl;
          return 0;
        }
      } else {
        if (s - t == x) {
          cout << i << " " << j << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int main() {
  int x, limit;
  cin >> x;
  limit = pow(x, 1.0 / 5.0);
  for (int i = 0; i <= limit; i++) {
    for (int j = 0; j >= -limit; j--) {
      if (x == pow(i, 5) - pow(j, 5)) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  for (long long i = limit;; i++) {
    for (long long j = 0; j < i; j++) {
      if (x == pow(i, 5) - pow(j, 5)) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int main() {
  int x, limit;
  cin >> x;
  limit = pow(x, 1.0 / 5.0);
  for (int i = 0; i <= limit; i++) {
    for (int j = 0; j >= -limit; j--) {
      if (x == pow(i, 5) - pow(j, 5)) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  for (long long i = limit;; i++) {
    for (long long j = 0;; j++) {
      if (x == pow(i, 5) - pow(j, 5)) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#define ll long long
using namespace std;
ll k[200];
int main() {
  ll n;
  cin >> n;
  for (ll i = 0; i < 200; i++) {
    k[i] = i * i * i * i * i;
    for (ll j = 0; j < i; j++) {
      if (k[i] - k[j] == n) {
        cout << i << " " << j;
      } else if (k[i] + k[j] == n) {
        cout << i << " " << -j;
      }
    }
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#define ll long long
using namespace std;
ll x, a, b, k;
const ll gg = -99999999999;
ll chk(ll k) {

  ll y = x / k - k * k * k * k;
  ll y1 = (y > 0 ? y : -y);
  if (y1 == 0) {
    return 0;
  }
  if (y1 % 5 == 0) {
    y1 /= 5;
    y /= 5;
    ;
    for (ll i = 1; i * i <= y1; i++) {
      if (y1 % i == 0) {
        ll j = i;
        if (j * (j + k) * (j * j + k * k + j * k) == y) {
          return j;
        }
        j = y / i;
        if (j * (j + k) * (j * j + k * k + j * k) == y) {
          return j;
        }
        j = -i;
        if (j * (j + k) * (j * j + k * k + j * k) == y) {
          return j;
        }
        j = -y / i;
        if (j * (j + k) * (j * j + k * k + j * k) == y) {
          return j;
        }
      }
    }
  }
  return gg;
}
int main() {
  cin >> x;
  for (ll i = 1; i * i <= x; i++) {
    if (x % i == 0) {
      if ((b = chk(i)) != gg) {
        k = i;
        break;
      } else if ((b = chk(x / i)) != gg) {
        k = x / i;
        break;
      } else if ((b = chk(-i)) != gg) {
        k = -i;
        break;
      } else if ((b = chk(x / (-i))) != gg) {
        k = x / (-i);
        break;
      }
    }
  }

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

#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int X;

vector<int> factor(int n) {
  vector<int> x;
  for (int i = 2; i <= n; i++) {
    while (n % i == 0) {
      x.push_back(i);
      n /= i;
    }
  }
  return x;
}

int pow(int a, int b) {
  int ans = 1;
  while (b--) {
    ans *= a;
  }
  return ans;
}

void solve() {
  vector<int> f = factor(X);
  int bit = 0;

  for (long long a = -178; a <= 178; a++) {
    for (long long b = -178; b <= 178; b++) {
      if (a * a * a * a * a - b * b * b * b * b == X) {
        cout << a << " " << b << endl;
        return;
      }
    }
  }
}

int main() {
  cin >> X;
  solve();
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int X;

vector<int> factor(int n) {
  vector<int> x;
  for (int i = 2; i <= n; i++) {
    while (n % i == 0) {
      x.push_back(i);
      n /= i;
    }
  }
  return x;
}

int pow(int a, int b) {
  int ans = 1;
  while (b--) {
    ans *= a;
  }
  return ans;
}

void solve() {
  vector<int> f = factor(X);
  int bit = 0;

  while (1) {
    bit++;
    if (bit > pow(2, f.size())) {
      break;
    }

    int x = 1;
    for (int i = 0; i < f.size(); i++) {
      if (bit & (2 << i)) {
        x *= f[i];
      }
    }
    int y = X / x;

    long long a = x, b;
    if (x > y || a > 177) {
      continue;
    }
    while (1) {
      a--;
      b = a - x;
      if (a - b < 0) {
        break;
      }
      if (a * a * a * a * a - b * b * b * b * b == X) {
        cout << a << " " << b << endl;
        return;
      }
    }
  }
}

int main() {
  cin >> X;
  solve();
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0), cin.tie(0)
using namespace std;
typedef long long ll;
const int maxn = 1e3 + 5;
const int inf = ~0u >> 1;
ll Pow(ll a, ll b) {
  ll ans = 1;
  while (b) {
    if (b & 1)
      ans = (ans * a);
    a = (a * a);
    b >>= 1;
  }
  return ans;
}
int main() {
  IO;
  ll x;
  cin >> x;
  for (int i = -maxn; i <= maxn; ++i) {
    for (int j = -maxn; j <= maxn; ++j) {
      if (Pow(i, 5) - Pow(j, 5) == x) {
        cout << i << ' ' << j << endl;
        return 0;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const ll maxn = 2e5 + 111;
ll a[maxn];
map<ll, ll> mp1, mp2;
int main() {
  ll n;
  scanf("%lld", &n);
  ll b = 0;
  ll ans1, ans2;
  while (1) {
    ll bb = b * b * b * b * b;
    ll xx = n + bb;
    ll hh = pow(xx, 1 / 5);
    if (hh * hh * hh * hh * hh == xx) {
      ans1 = hh, ans2 = b;
      break;
    }
    xx = n - bb;
    hh = pow(xx, 1 / 5);
    if (hh * hh * hh * hh * hh == xx) {
      ans1 = hh, ans2 = -b;
      break;
    }
    ++b;
  }
  printf("%lld %lld\\n", ans1, ans2);
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  long long i, j, m;
  cin >> m;

  for (i = -140; i <= 140; i++) {
    for (j = -140; j <= 140; j++) {
      if (i * i * i * i * i - j * j * j * j * j == m) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define ll long long
#define inf 0x7fffffff;
#define maxn 200005
using namespace std;
ll x, a, b;
ll read() {
  ll l = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      w = -1;
    else
      ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    l *= 10;
    l += ch - '0';
    ch = getchar();
  }
  return l * w;
}
int main() {
  x = read();
  ll a1 = 0;
  double b1 = 0.0;
  while (1) {
    a1 = a * a * a * a * a;
    a1 -= x;
    if (a1 > 0)
      b1 = pow(a1, 0.2);
    else
      b1 = -pow(-a1, 0.2);
    if (b1 - (ll)b1 == 0)
      break;
    a++;
  }
  b = (ll)b1;
  printf("%lld %lld", a, b);
  return 0;
}