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

#include <algorithm>
#include <fstream>
#include <iostream>
#include <math.h>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

int main() {
  // std::ifstream in("input.txt");
  // std::cin.rdbuf(in.rdbuf());

  long long n;
  cin >> n;

  for (long i = -100; i < 100; i++) {
    for (long j = -100; j < 100; j++) {
      if (i * i * i * i * i - j * j * j * j * j == n) {
        cout << i << " " << j << endl;
        exit(0);
      }
    }
  }

  for (long i = 64; i < 300; i++) {
    for (long j = 64; j < 300; j++) {
      if (i * i * i * i * i - j * j * j * j * j == n) {
        cout << i << " " << j << endl;
        exit(0);
      }
    }
  }

  // long long i =63;
  // long long j =62;
  // for (long long ii = 0;ii<100000;ii++){
  //     long long ans=i*i*i*i*i-j*j*j*j*j;
  //     if (ans==n){
  //         cout << i << " " << j <<endl;
  //         exit(0);
  //     }else if(ans>n){
  //         j=j+1;
  //     }
  //     else{
  //         i=i+1;
  //     }
  // }
}


Error: TLE

Fixed submission:


#include <algorithm>
#include <fstream>
#include <iostream>
#include <math.h>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

int main() {
  // std::ifstream in("input.txt");
  // std::cin.rdbuf(in.rdbuf());

  long long n;
  cin >> n;

  for (long i = -64; i < 64; i++) {
    for (long j = -64; j < 64; j++) {
      if (i * i * i * i * i - j * j * j * j * j == n) {
        cout << i << " " << j << endl;
        exit(0);
      }
    }
  }

  long long i = 63;
  long long j = 62;
  for (long long ii = 0; ii < 1000000000; ii++) {
    long long ans = i * i * i * i * i - j * j * j * j * j;
    if (ans == n) {
      cout << i << " " << j << endl;
      exit(0);
    } else if (ans > n) {
      j = j + 1;
    } else {
      i = i + 1;
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <stdio.h>
#include <utility>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, string> P;

int main() {
  int x;
  cin >> x;
  long long ans = 0;
  for (int i = -1000; i <= 1000; i++) {
    for (int j = -1000; j <= 1000; j++) {

      ans = pow(i, 5) - pow(j, 5);
      if (ans == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <stdio.h>
#include <utility>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, string> P;

int main() {
  int x;
  cin >> x;
  long long ans = 0;
  for (int i = -10000; i <= 10000; i++) {
    for (int j = -10000; j <= 10000; j++) {

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

#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; // 1e18
const double EPS = 1e-10;

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

  ll A, B;
  for (A = -120; A < 120; A++) {
    for (B = -120; B < 120; B++) {
      if (pow(A, 5) - pow(B, 5) == X) {
        printf("%lld %lld\\n", A, B);
        return (0);
      }
    }
  }
  return (0);
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; // 1e18
const double EPS = 1e-10;

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

  if (X == 1) {
    printf("0 -1\\n");
    return (0);
  }

  ll B = -1;
  ll A = 0;
  while (true) {
    if (pow(A, 5) == X - 1) {
      break;
    }
    A++;
  }
  printf("%lld %lld\\n", A, B);
  return (0);
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  long double x, y;
  cin >> x;
  ll a, b;

  for (int i = -1000; i <= 1000; i++) {
    for (int j = -1000; j <= 1000; j++) {
      ll num = pow(i, 5) - pow(j, 5);
      if (num == x)
        a = i, b = j;
    }
  }

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


Error: TLE

Fixed submission:

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

int main() {
  long double x, y;
  cin >> x;
  ll a, b = -1;
  bool judge = false;

  while (judge == false) {
    b++;
    long double i1 = pow(x + pow(b, 5), 0.2);
    ll i2 = pow(x + pow(b, 5), 0.2);
    if (i1 == i2) {
      judge = true;
      a = i2;
    }

    if (x < pow(b, 5))
      continue;
    long double j1 = pow(x - pow(b, 5), 0.2);
    ll j2 = pow(x - pow(b, 5), 0.2);
    if (j1 == j2) {
      judge = true;
      a = j2;
      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;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long INF = 1LL << 60;

int main() {
  ll X;
  cin >> X;
  ll A, B;
  for (int a = -118; a <= 119; a++) {
    for (int b = -119; b <= 118; b++) {
      if (a * a * a * a * a - b * b * b * b * b == X) {
        A = a;
        B = b;
        break;
      }
    }
  }
  cout << A << " " << B << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  ll X;
  cin >> X;
  ll a, b;
  bool res = false;
  for (ll i = 1; i * i <= X; i++) {
    if (X % i == 0) {
      for (ll j = -sqrt(X); j <= X / i; j++) {
        b = j;
        a = i + j;
        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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int 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;
        return 0;
      }
    }
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int x;
  cin >> x;

  int y = x + 1;
  for (int i = -1; i < 100000; ++i) {
    for (int j = -1; j < 100000; ++j) {
      if (pow(i, 5) - pow(j, 5) == x) {
        cout << i << " " << j;
        return 0;
      }
    }
  }
  y = x - 1;
  for (int i = 0; i < 100000; ++i) {

    if (pow(i, 5) == y) {
      cout << i << " " << -1;
      return 0;
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define endl "\\n"
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define pr(x) cout << x << endl;
#define pr2(x, y) cout << x << " " << y << endl;
#define pr3(x, y, z) cout << x << " " << y << endl;
#define prv(v)                                                                 \\
  for (auto x : v)                                                             \\
    cout << x << " ";
#define ffs fflush(stdout);
#define int ll
using namespace std;

const ll N = (2e5 + 5);
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;
const ll LOG = 29;
#define PI 3.141592653589793238

long long binpow(long long a, long long b) {
  a %= MOD;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = (res * a) % MOD;
    a = (a * a) % MOD;

    b >>= 1;
  }
  res %= MOD;
  return res;
}
void solve() {
  ll x;
  cin >> x;
  for (ll a = -1000; a <= 1000; a++) {
    for (ll b = -1000; b <= 1000; b++) {
      // if(a==0||b==0)continue;
      ll gg = pow(a, 5);
      ll gg2 = pow(b, 5);
      // cout<<a<<" "<<b<<" "<<gg<<" "<<gg2<<endl;
      if ((gg - gg2) == x) {

        //  cout<<gg<<" "<<gg2<<endl;
        cout << a << " " << b << endl;
        return;
      }
    }
  }
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);

  ll t = 1;
  while (t--) {
    solve();
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define endl "\\n"
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define pr(x) cout << x << endl;
#define pr2(x, y) cout << x << " " << y << endl;
#define pr3(x, y, z) cout << x << " " << y << endl;
#define prv(v)                                                                 \\
  for (auto x : v)                                                             \\
    cout << x << " ";
#define ffs fflush(stdout);
#define int ll
using namespace std;

const ll N = (2e5 + 5);
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;
const ll LOG = 29;
#define PI 3.141592653589793238

long long binpow(long long a, long long b) {
  a %= MOD;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = (res * a) % MOD;
    a = (a * a) % MOD;

    b >>= 1;
  }
  res %= MOD;
  return res;
}
void solve() {
  ll x;
  cin >> x;
  for (ll a = -3000; a <= 3000; a++) {
    for (ll b = -3000; b <= 3000; b++) {
      // if(a==0||b==0)continue;
      ll gg = pow(a, 5);
      ll gg2 = pow(b, 5);
      // cout<<a<<" "<<b<<" "<<gg<<" "<<gg2<<endl;
      if ((gg - gg2) == x) {

        //  cout<<gg<<" "<<gg2<<endl;
        cout << a << " " << b << endl;
        return;
      }
    }
  }
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);

  ll t = 1;
  while (t--) {
    solve();
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  long long int a, b, x, i, j;
  while (cin >> x) {
    for (i = -200; i <= 200; i++) {
      a = i * i * i * i * i;
      int f = 0;
      for (j = -200; j <= 200; j++) {
        b = j * j * j * j * j;
        // cout<<"a: "<<i<<'-'<<a<<" b: "<<j<<'-'<<b<<endl;
        if (a - b == x) {
          cout << i << ' ' << j << endl;
          f = 1;
          break;
        }
        if (a + b == x) {
          cout << i << ' ' << -1 * j << endl;
          f = 1;
          break;
        }
        if (-1 * a + b == x) {
          cout << -1 * i << ' ' << -1 * j << endl;
          f = 1;
          break;
        }
      }
      if (f == 1)
        break;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {

  int X, A, B, flag = 1;

  cin >> X;

  for (int i = -1; i <= X; i++) {
    if (flag == 0)
      break;
    for (int j = -1; j <= X; j++) {
      if ((pow(i, 5) - pow(j, 5)) == X) {
        A = i, B = j;
        flag = 0;
        break;
      }
    }
  }

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

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long int lld;
#define sq(x) (x * x * x * x * x)
#define fr(i, m, n) for (i = m; i < n; i++)
#define vec vector<int>
#define sint set<int>
#define qint queue<int>
#define mip map<int, int>
#define pint priority_queue<int>
#define pb push_back
#define pp pop_back()
#define ft first
#define sd second
#define full(v) v.begin(), v.end()
int main() {
  lld i, j, k, a, b, c, x, y, z, n, m, t;
  string s, u, v;
  cin >> c;
  bool ans = false;
  fr(i, 0, 1000) {
    x = sq(i);
    z = x - c;
    fr(j, 0, 1000) {
      y = sq(j);
      if (y == abs(z)) {
        ans = true;
        break;
      } else if (y > abs(z))
        break;
    }
    if (ans)
      break;
  }
  if (z >= 0)
    cout << i << " " << j << endl;
  else
    cout << i << " " << -j << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <math.h>

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

using namespace std;

int main() {
  int A = 0, B = 0, X;
  cin >> X;

  bool flg = false;
  rep(i, X + 1) {
    int a;
    // cout << ".";
    a = pow(i, 5);

    int b = X - a;
    rep(j, b + 1) {
      int t = j * j * j * j * j;
      if (b < t)
        break;
      // cout << a << "," << t <<","<<b<<endl;
      if (abs(b) == t) {
        if (b > 0)
          j *= -1;

        A = i;
        B = j;
        flg = true;
        break;
      }
    }

    if (flg)
      break;
  }

  cout << A << " " << B;
  // cin >> A;
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
// #define print(ele) cout << (ele) << "\\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

void print() { cout << endl; }

template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) {
  cout << head;
  if (sizeof...(tail) != 0)
    cout << " ";
  print(forward<Tail>(tail)...);
}

int main() {
  ll x;
  cin >> x;
  int y = pow(x, 1.0 / 3.0);
  FOR(i, -y - 1, y + 1) {
    FOR(j, -y - 1, y + 1) {
      if (pow(i, 5) - pow(j, 5) == x) {
        print(i, j);
        return 0;
      }
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
// #define print(ele) cout << (ele) << "\\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

void print() { cout << endl; }

template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) {
  cout << head;
  if (sizeof...(tail) != 0)
    cout << " ";
  print(forward<Tail>(tail)...);
}

int main() {
  ll x;
  cin >> x;
  int a, b;
  FOR(i, -sqrt(x) - 1, sqrt(x) + 1) {
    FOR(j, -sqrt(x) - 1, sqrt(x) + 1) {
      if (pow(i, 5) - pow(j, 5) == x) {
        print(i, j);
        return 0;
      }
    }
  }

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

#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
typedef long long ll;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i = a; i < b; i++)
#define V vector

V<ll> cache;
ll X;

void solve() {
  ll t, prev = 0;
  REP(i, 1, X + 1) {
    prev = t;
    t = ll(pow(i, 5));
    if (t == X) {
      cout << cache.size() + 1 << " " << 0 << "\\n";
      return;
    }
    if (t - prev > X)
      break;
    cache.PB(t);
  }

  int l = 0, r = cache.size() - 1;
  while (l <= r) {
    t = cache[l] + cache[r];
    if (t == X) {
      cout << r + 1 << " " << -l - 1 << "\\n";
      return;
    }
    if (t < X)
      l += 1;
    else
      r -= 1;
  }
  l = 0;
  r = 0;
  int N = cache.size();
  while (r < N) {
    t = cache[r] - cache[l];
    if (t == X) {
      cout << r + 1 << " " << l + 1 << "\\n";
      return;
    }
    if (t < X)
      r += 1;
    else
      l += 1;
  }
  return;
}

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


Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
typedef long long ll;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i = a; i < b; i++)
#define V vector

V<ll> cache;
ll X;

void solve() {
  ll t, prev = 0;
  REP(i, 1, X) {
    prev = t;
    t = ll(pow(i, 5));
    if (t - prev > X)
      break;
    cache.PB(t);
  }

  int l = 0, r = cache.size() - 1;
  if (cache[r] == X) {
    cout << r + 1 << " " << 0 << "\\n";
    return;
  }
  while (l <= r) {
    t = cache[l] + cache[r];
    if (t == X) {
      cout << r + 1 << " " << -l - 1 << "\\n";
      return;
    }
    if (t < X)
      l += 1;
    else
      r -= 1;
  }
  l = 0;
  r = 0;
  int N = cache.size();
  while (r < N) {
    t = cache[r] - cache[l];
    if (t == X) {
      cout << r + 1 << " " << l + 1 << "\\n";
      return;
    }
    if (t < X)
      r += 1;
    else
      l += 1;
  }
  return;
}

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

#include <bits/stdc++.h>
using namespace std;
/*
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
*/
int main() {
  long long int X;
  cin >> X;
  // vector<long long> v = divisor(X);

  // long long a = 0, b = 0;

  for (int a = -1000; a <= 1000; a++) {
    for (int b = -1000; b <= 1000; b++) {
      if (pow(a, 5) == X + pow(b, 5)) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  /*
  for (int i = 0; i < v.size(); i++)
  {
          for (int j = 0; j < v[i]; j++)
          {
                  a = j;
                  b = j - v[i];

                  if (pow(a, 5) - pow(b, 5) == X)
                  {
                          cout << a << " " << b << endl;
                          return 0;
                  }
          }
  }
  */

  return 0;
}


Error: TLE

Fixed submission:

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

vector<long long> divisor(long long n) {
  vector<long long> ret;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end()); // 昇順に並べる
  return ret;
}

int main() {
  long long int X;
  cin >> X;
  vector<long long> v = divisor(X);

  long long a = 0, b = 0;
  for (int i = 0; i < v.size(); i++) {
    for (int j = 0; j < v[i]; j++) {
      a = j;
      b = j - v[i];

      if (pow(a, 5) - pow(b, 5) == 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;
// const int N = pow(10,9);

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

  for (long long i = -1000; i <= 1000; i++) {
    for (long long 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;
// const int N = pow(10,9);

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

  if (x == 1)
    cout << "1 0" << endl;
  else {
    for (int i = 2; i <= sqrt(x); i++) {
      if (x % i == 0) { // x is not prime
        long long j = 1 - i;
        while (1) {
          if (pow(i + j, 5) - pow(j, 5) == x) {
            cout << i + j << " " << j << endl;
            return 0;
          } else {
            j++;
          }
        }
      }
    }
    // x is prime
    long long j = 0;
    while (1) {
      if (pow(1 + j, 5) - pow(j, 5) == x || pow(x + j, 5) - pow(j, 5) == x) {
        cout << 1 + j << " " << j << endl;
        return 0;
      }
      j++;
    }
  }
}
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;
#define int long long
signed main() {
  int X;
  cin >> X;
  for (int i = 0; i < 1000; i++) {
    for (int j = 0; j < 1000; j++) {
      if (i * i * i * i * i - j * j * j * j * j == X) {
        cout << i << " " << j;
        return 0;
      }
      i *= -1;
      if (i * i * i * i * i - j * j * j * j * j == X) {
        cout << i << " " << j;
        return 0;
      }
      j *= -1;
      if (i * i * i * i * i - j * j * j * j * j == X) {
        cout << i << " " << j;
        return 0;
      }
      i *= -1;
      if (i * i * i * i * i - j * j * j * j * j == X) {
        cout << i << " " << j;
        return 0;
      }
      j *= -1;
    }
  }
}


Error: TLE

Fixed submission:

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

  for (int i = 0;; i++) {
    for (int j = 0;; j++) {
      if (j * j * j * j * j - j - 1 * j - 1 * j - 1 * j - 1 * j - 1 > X)
        break;
      if (i * i * i * i * i - j * j * j * j * j == X) {
        cout << i << " " << j;
        return 0;
      }
      if (j * j * j * j * j - i * i * i * i * i == X) {
        cout << j << " " << i;
        return 0;
      }
      i *= -1;
      if (i * i * i * i * i - j * j * j * j * j == X) {
        cout << i << " " << j;
        return 0;
      }
      if (j * j * j * j * j - i * i * i * i * i == X) {
        cout << j << " " << i;
        return 0;
      }
      i *= -1;
      j *= -1;
      if (i * i * i * i * i - j * j * j * j * j == X) {
        cout << i << " " << j;
        return 0;
      }
      if (j * j * j * j * j - i * i * i * i * i == X) {
        cout << j << " " << i;
        return 0;
      }
      j *= -1;
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
int main(void) {
  int X;
  while (scanf("%d", &X) != 0) {
    for (long long A = 0; A < 120; A++)
      for (long long B = -120; B < A; B++)
        if (A * A * A * A * A - B * B * B * B * B == X)
          return printf("%lld %lld\\n", A, B), 0;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
int main() {
  int X;
  int64_t A, B;
  cin >> X;
  rep(A, 100000000)
          rep(B, 100000000) if (pow(A, 5) - pow(B, 5) == X) return cout
      << A << B << endl,
      0;
}