alexjercan/bugnet huggingface dataset:
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>;
ll f(ll A, ll B) { return A * A * A * A * A - B * B * B * B * B; }
int main() {
  ll x;
  cin >> x;
  map<ll, P> mp;
  for (ll A = -500; A <= 500; A++) {
    for (ll B = -500; B <= 500; B++) {
      mp[f(A, B)] = (P){A, B};
    }
  }
  printf("%d %d\\n", mp[x].first, mp[x].second);
}


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>;
ll f(ll A, ll B) { return A * A * A * A * A - B * B * B * B * B; }
int main() {
  ll x;
  cin >> x;
  map<ll, P> mp;
  for (ll A = -1000; A <= 1000; A++) {
    for (ll B = -1000; B <= 1000; B++) {
      mp[f(A, B)] = (P){A, B};
    }
  }
  printf("%d %d\\n", mp[x].first, mp[x].second);
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
ll a[300];
int main() {
  long long x;
  cin >> x;
  for (long long i = 1; i <= 200; i++)
    a[i] = pow(i, 5);
  a[0] = 0;

  for (int i = 0; i <= 200; i++) {
    int p = 0;
    for (int j = 0; j <= i; j++) {
      if (a[i] - a[j] == x) {
        cout << i << " " << j << endl;
        p = 1;
        break;
      }
      if (a[i] + a[j] == x) {
        p = 1;
        cout << i << " " << -j << endl;
        break;
      }
    }
    if (p == 1)
      break;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
int main() {
  long long x;
  cin >> x;
  for (int i = pow(x, 0.2);; i++) {
    long long A = pow(i, 5);
    long long B = A - x;
    if (B < 0) {
      B = -B;
      if (pow(B, 0.2) == (ll)pow(B, 0.2)) {
        cout << i << " " << -pow(B, 0.2) << endl;
        break;
      }
    } else {
      if (pow(B, 0.2) == (ll)pow(B, 0.2)) {
        cout << i << " " << pow(B, 0.2) << endl;
        break;
      }
    }
  }

  return 0;
}
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 P = pair<int, int>;
typedef long long ll;

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll 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;
}

// 繰り返し自乗法(modなし)
ll mypow(ll x, ll n) {
  if (n == 0)
    return 1;

  if (n % 2 == 0)
    return mypow(x * x, n / 2);
  else
    return x * mypow(x, n - 1);
}

int main() {
  ll x;
  cin >> x;
  for (int i = -1000; i <= 1000; i++) {
    for (int j = -1000; j <= 1000; j++) {
      ll tmp = mypow(i, 5) - mypow(j, 5);
      if (tmp == x) {
        cout << i << " " << j << 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 P = pair<int, int>;
typedef long long ll;

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll 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;
}

// 繰り返し自乗法(modなし)
ll mypow(ll x, ll n) {
  if (n == 0)
    return 1;

  if (n % 2 == 0)
    return mypow(x * x, n / 2);
  else
    return x * mypow(x, n - 1);
}

int main() {
  ll x;
  cin >> x;
  vector<ll> nums = divisor(x);
  rep(i, nums.size()) {
    ll a = 0;
    ll b = -nums[i];
    while (a < nums[i]) {
      ll tmp = mypow(a, 5) - mypow(b, 5);
      if (tmp == x) {
        cout << a << " " << b << endl;
        return 0;
      }
      a++;
      b++;
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int x;
  cin >> x;
  for (int i = 1; i <= 1000; i++)
    for (int j = -1000; j <= i; j++) {
      if (pow(i, 5) + pow(j, 5) == x) {
        printf("%d %d", i, -j);
        return 0;
      }
    }
}

Error: TLE

Fixed submission:

#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int x;
  cin >> x;
  for (int i = 1; i <= 10000; i++)
    for (int j = 0; j <= i; j++) {
      if (pow(i, 5) + pow(j, 5) == x) {
        printf("%d %d", i, -j);
        return 0;
      }
    }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main() {
  LLONG X;
  cin >> X;
  set<LLONG> divs;
  for (LLONG d = 1; d * d <= X; ++d) {
    if (X % d == 0) {
      divs.insert(d);
      divs.insert(X / d);
      // divs.insert(-d);
      // divs.insert(-X / d);
    }
  }
  for (const LLONG d : divs) {
    LLONG X2 = X / d - d * d * d * d;
    if (X2 % 5 == 0) {
      X2 /= 5;
      if (X2 == 0) {
        cout << d << ' ' << 0 << endl;
        return 0;
      }
      set<LLONG> BCands;
      for (LLONG B = 1; B * B <= abs(X2); ++B) {
        if (abs(X2) % B == 0) {
          for (LLONG b : {B, X2 / B, -B, -X2 / B}) {
            LLONG X3 = X2 / b - d * d * d;
            if (b * b * b + 2 * d * b * b + 2 * d * d * b == X3) {
              cout << b + d << ' ' << b << endl;
              return 0;
            }
          }
        }
      }
    }
  }
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main() {
  LLONG X;
  cin >> X;
  set<LLONG> divs;
  for (LLONG d = 1; d * d <= X; ++d) {
    if (X % d == 0) {
      divs.insert(d);
      divs.insert(X / d);
      divs.insert(-d);
      divs.insert(-X / d);
    }
  }
  for (const LLONG d : divs) {
    LLONG X2 = X / d - d * d * d * d;
    if (X2 % 5 == 0) {
      X2 /= 5;
      if (X2 == 0) {
        cout << d << ' ' << 0 << endl;
        return 0;
      }
      set<LLONG> BCands;
      for (LLONG B = 1; B * B <= abs(X2); ++B) {
        if (abs(X2) % B == 0) {
          for (LLONG b : {B, X2 / B, -B, -X2 / B}) {
            LLONG X3 = X2 / b - d * d * d;
            if (b * b * b + 2 * d * b * b + 2 * d * d * b == X3) {
              cout << b + d << ' ' << b << endl;
              return 0;
            }
          }
        }
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iostream>
using namespace std;
int main() {
  long x, a, b;
  long aa, bb;
  long i, j, k;

  cin >> x;
  for (a = -120; a <= 120; a++) {
    for (b = -120; b <= 120; b++) {
      aa = pow(a, 5);
      bb = pow(b, 5);
      if (aa - bb == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
using namespace std;
int main() {
  long x, a, b;
  long aa, bb;
  long i, j, k;

  cin >> x;
  for (i = 1; i * i <= x; i++) {
    if (x % i == 0) {
      aa = 0;
      bb = 0;
      for (a = 0; a <= x; a++) {
        aa = pow(a, 5);
        bb = pow(a - i, 5);
        if (a - i <= -100000)
          continue;
        if (aa - bb == x) {
          cout << a << " " << a - i << endl;
          return 0;
        }
      }

      aa = 0;
      bb = 0;
      if (x % i == 0)
        j = x / i;
      for (a = 0; a <= x; a++) {
        aa = pow(a, 5);
        bb = pow(a - j, 5);
        if (a - j <= -100000)
          continue;
        if (aa - bb == x) {
          cout << a << " " << a - j << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  long long X;

  cin >> X;

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

  return 0;
}

Error: 1

Fixed submission:

#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  long long X;

  cin >> X;

  for (int i = -200; i <= 200; ++i) {
    for (int j = -200; j <= 200; ++j) {
      long long calc = pow(i, 5) - pow(j, 5);
      if (calc == X) {
        cout << i << " ";
        cout << j << endl;
        return true;
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, m, n) for (int i = (m); i < (n); i++)
#define fore(i, a) for (auto &i : a)
#define debug(a, b) cout << "debug : " << a << " , " << b << endl
using ll = long long;
const ll INF = 1LL << 60;
const ll mod = 1E9 + 7;

int main() {
  ll x;
  cin >> x;
  bool f = true;
  rep(i, 200) {
    rep(j, 200) {
      if (i * i * i * i * i + j * j * j * j * j == x && f) {
        cout << i << " " << -j;
        f = false;
      }
      if (i * i * i * i * i - j * j * j * j * j == x && f) {
        cout << i << " " << j;
        f = false;
      }
    }
  }
  return 0;
}


Error: 1

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, m, n) for (int i = (m); i < (n); i++)
#define fore(i, a) for (auto &i : a)
#define debug(a, b) cout << "debug : " << a << " , " << b << endl
using ll = long long;
const ll INF = 1LL << 60;
const ll mod = 1E9 + 7;

int main() {
  ll x;
  cin >> x;
  rep(i, 200) {
    rep(j, 200) {
      if (i * i * i * i * i + j * j * j * j * j == x) {
        cout << i << " " << -j;
        return 1;
      }
      if (i * i * i * i * i - j * j * j * j * j == x) {
        cout << i << " " << j;
        return 1;
      }
    }
  }
  return 0;
}
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;

  ll a_ans;
  ll b_ans;
  for (ll a = -120; a <= 120; a++) {

    for (ll b = -120; b < 120; b++) {

      ll tmp = a * a * a * a * a - b * b * b * b * b;

      if (tmp == x) {
        a_ans = a;
        b_ans = b;
        break;
      }
    }
  }

  cout << a_ans << " " << b_ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

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

  if (x == 1) {
    cout << 0 << " " << -1 << endl;
    return 0;
  }

  ll a_f, a, b;

  b = -1;
  a_f = x + b;

  ll i = 1;
  while (true) {

    ll tmp = i * i * i * i * i;

    if (tmp == a_f) {
      break;
    }

    i++;
  }

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

#include <iostream>
#include <map>
#include <math.h>
#include <stdlib.h>
#include <tuple>
#include <vector>
using namespace std;
#define _GLIBCXX_DEBUG

int main(void) {

  long double X;

  cin >> X;

  // int ans = 0;
  int flag = 0;

  long double a, b, result;

  for (a = 1; a < 1000; a++) {

    for (b = -1000; b < a; b++) {
      result = a * a * a * a + a * a * a * b + a * a * b * b + a * b * b * b +
               b * b * b * b;

      if (result == (X / (a - b))) {
        flag = 1;
        break;
      }
    }
    if (flag == 1) {
      break;
    }
  }

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

Error: TLE

Fixed submission:

#include <iostream>
#include <map>
#include <stdlib.h>
#include <tuple>
#include <vector>
using namespace std;
#define _GLIBCXX_DEBUG

int main(void) {

  long double X;

  cin >> X;

  // int ans = 0;
  int flag = 0;

  long double a, b, result;

  for (a = 1; a < 100000; a++) {
    for (b = 0; b > (-1) * a; b--) {
      result = a * a * a * a + a * a * a * b + a * a * b * b + a * b * b * b +
               b * b * b * b;

      if (result == (X / (a - b))) {
        flag = 1;
        break;
      }
    }
    if (flag == 1) {
      break;
    }
  }

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

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < (n); ++i)
#define ALL(n) begin(n), end(n)
using ll = long long;
const ll INF = 1e18;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

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

  auto calc = [&](ll a) { return a * a * a * a * a; };
  REP(a, -200, 201) {
    REP(b, -200, 201) {
      ll aa = calc(a), bb = calc(b);
      if (aa - bb == X) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < (n); ++i)
#define ALL(n) begin(n), end(n)
using ll = long long;
const ll INF = 1e18;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

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

  int divisor = 1;
  for (ll i = 2; i < ll(X / 2); ++i) {
    if (X % i == 0) {
      divisor = i;
      break;
    }
  }
  REP(i, 0, 1e9) {
    if (pow(i + divisor, 5) - pow(i, 5) == X) {
      cout << i + divisor << " " << i << endl;
      break;
    }
    if (i < divisor) {
      if (pow(-1 - i + divisor, 5) - pow(-1 - i, 5) == X) {
        cout << -1 - i + divisor << " " << -1 - i << endl;
        break;
      }
    }
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const int N = 3e5 + 6;
const int mod = 1e9 + 107;
const int inf = 1e8;
int h[N];
int mx[N];
void solve() {
  ll x;
  cin >> x;
  for (ll i = 1; i * i <= x; i++) {
    if (x % i == 0) {
      for (ll j = -300; j <= 300; j++) {
        ll b = j;
        ll a = i + j;
        ll trt = a * a * a * a + a * a * a * b + a * a * b * b + a * b * b * b +
                 b * b * b * b;
        //        cout<<i<<" "<<a<<" "<<b<<" "<<a-b<<" "<<trt<<"
        //        "<<trt*(a-b)<<endl;
        if (trt == x / i) {
          cout << a << " " << b << endl;
          return;
        }
      }
    }
  }
  exit(-1);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  //    cin>>t;
  while (t--)
    solve();
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const int N = 3e5 + 6;
const int mod = 1e9 + 107;
const int inf = 1e8;
int h[N];
int mx[N];
void solve() {
  ll x;
  cin >> x;
  for (ll i = 1; i * i <= x; i++) {
    if (x % i == 0) {
      for (ll j = -i; j <= i; j++) {
        ll b = j;
        ll a = i + j;
        ll trt = a * a * a * a + a * a * a * b + a * a * b * b + a * b * b * b +
                 b * b * b * b;
        //        cout<<i<<" "<<a<<" "<<b<<" "<<a-b<<" "<<trt<<"
        //        "<<trt*(a-b)<<endl;
        if (trt == x / i) {
          cout << a << " " << b << endl;
          return;
        }
      }
    }
  }
  exit(-1);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  //    cin>>t;
  while (t--)
    solve();
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;

int main(void) {
  int x;
  int i, j;

  cin >> x;
  for (i = -1000; i <= 1000; i++)
    for (j = -1000; j <= 1000; j++)
      if ((long long)i * i * i * i * i - (long long)j * j * j * j * j == x) {
        cout << i << ' ' << j << endl;
        return 0;
      }

  return 0;
}


Error: TLE

Fixed submission:

#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <algorithm>
#include <cstdio>
#include <iostream>
#define N 100020
using namespace std;

long long Abs(long long x) { return x < 0 ? -x : x; }

int main(void) {
  int x;
  int i;

  cin >> x;
  if (x == 1)
    cout << 0 << ' ' << -1 << endl;
  else if (x == 2)
    cout << 1 << ' ' << -1 << endl;
  else {
    for (i = 1; Abs((long long)i * i * i * i * i - x) > 1; i++)
      ;
    cout << i << ' ' << i * i * i * i * i - x << endl;
  }

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

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

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

  long long int A = 0, B = 0;

  if (X == 1) {
    cout << 1 << " " << 0 << endl;
  } else {
    int f = 0;
    for (int i = 1000; i >= -1000; --i) {
      for (int j = 999; j >= -1000; --j) {
        A = pow(i, 5);
        B = pow(j, 5);

        if ((A - B) == X || (A + B == X)) {
          f = 1;
          if (A - B == X) {
            A = i;
            B = j;
          } else {
            A = i;
            B = -j;
          }
          break;
        }
      }
      if (f == 1) {
        break;
      }
    }

    cout << A << " " << B << endl;
  }
}

Error: TLE

Fixed submission:

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

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

  long long int A = 0, B = 0;

  if (X == 1) {
    cout << 1 << " " << 0 << endl;
  } else {
    int f = 0;
    for (int i = 10000; i >= -10000; --i) {
      for (int j = 9999; j >= -10000; --j) {
        A = pow(i, 5);
        B = pow(j, 5);

        if ((A - B) == X || (A + B == X)) {
          f = 1;
          if (A - B == X) {
            A = i;
            B = j;
          } else {
            A = i;
            B = -j;
          }
          break;
        }
      }
      if (f == 1) {
        break;
      }
    }

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

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

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

  for (int a = -118; a <= 119; a++) {
    for (int b = -119; b <= 118; b++) {
      if (a - b < 1)
        continue;
      int tmp = a * a * a * a * a - b * b * b * b * b;
      if (tmp == x) {
        cout << a << ' ' << b << endl;
        return 0;
      }
    }
  }
}


Error: TLE

Fixed submission:

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

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

  for (int a = -118; a <= 119; a++) {
    for (int b = -119; b <= 118; a++) {
      int tmp = a * a * a * a * a - b * b * b * b * b;
      if (tmp == x) {
        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++)
using ll = long long;
template <class T> using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main() {
  int x;
  std::cin >> x;
  for (ll i = -1000; i <= 1000; i++) {
    for (ll j = 1000; j >= -1000; j--) {
      ll a = pow(i, 5), b = pow(j, 5);
      if (a - b == (ll)x) {
        std::cout << i << ' ' << j << '\\n';
        return 0;
      }
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
using ll = long long;
template <class T> using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main() {
  int x;
  std::cin >> x;
  for (ll i = -10000; i <= 10000; i++) {
    for (ll j = 10000; j >= -10000; j--) {
      ll a = pow(i, 5), b = pow(j, 5);
      if (a - b == (ll)x) {
        std::cout << i << ' ' << j << '\\n';
        return 0;
      }
    }
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  // aは常にせいであると仮定する
  int a = 0, b;
  for (int i = 0; i < 121; i++) {
    for (int j = -120; j < 121; j++) {
      long long tmp = pow(i, 5) - pow(j, 5);
      if (tmp == x) {
        a = i;
        b = j;
        break;
      }
    }
  }

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


Error: TLE

Fixed submission:

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

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

  // aは必ず正の値
  // xはなんの倍数 = (a-b)?

  long long i = 2;
  while (1) {
    if (x == 1) {
      i = 1;
      break;
    }
    if (x % i == 0) {
      break;
    }
    i++;
  }

  long long a = 1, b;
  while (1) {
    b = a - i;
    // long long test = pow(a,5) - pow(b, 5);
    if (pow(a, 5) - pow(b, 5) == x) {
      cout << a << " " << b << endl;
      return 0;
    }
    a++;
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

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

int main() {

  // for (long aaa = 2; aaa <= 118; aaa++) {
  //	for (long bbb = 1; bbb < aaa; bbb++) {
  //	for (long aaa = 5; aaa <= 118; aaa++) {
  //	for (long bbb = 1; bbb < aaa; bbb++) {
  //			cout << aaa <<  " " << bbb << endl;
  long long x;
  //			x = pow(aaa, 5) - pow(bbb, 5);
  map<long long, int> a;
  cin >> x;
  a = prime_factor(x);
  a.insert(make_pair(1, 1));
  a.insert(make_pair(x, 1));
  auto iter = a.begin();

  while (1) {
    //				bool chkflg = false;
    long long aa = 0;
    long long bb = 0;
    for (long long i = -200; i <= 200; i++) {
      aa = i;
      bb = aa - iter->first;
      if ((long long)pow(aa, 5) - (long long)pow(bb, 5) == x) {
        cout << aa << " " << bb << endl;
        //						chkflg = true;
        //						break;
        return 0;
      }
      bb = aa + iter->first;
      if ((long long)pow(aa, 5) - (long long)pow(bb, 5) == x) {
        cout << aa << " " << bb << endl;
        //						chkflg = true;
        //						break;
        return 0;
      }
      //			if (pow(aa, 5) > x) { break; }
    }
    //				if (chkflg == true) { break; }
    if (iter == a.end()) {
      break;
    }
    iter = next(iter, 1);
  }
}
//	}
//}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

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

int main() {
  map<long long, int> a;
  long long x;
  cin >> x;
  a = prime_factor(x);
  a.insert(make_pair(1, 1));
  a.insert(make_pair(x, 1));
  auto iter = a.begin();

  while (1) {

    long long aa = 0;
    long long bb = 0;
    for (long i = -10000; i <= 10000; i++) {
      aa = i;
      bb = aa - iter->first;
      if (pow(aa, 5) - pow(bb, 5) == x) {
        cout << aa << " " << bb << endl;
        return 0;
      }
      bb = aa + iter->first;
      if (pow(aa, 5) - pow(bb, 5) == x) {
        cout << aa << " " << bb << endl;
        return 0;
      }

      //			if (pow(aa, 5) > x) { break; }
    }
    //		if (iter == a.end()) { break; }
    iter = next(iter, 1);
  }
}