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

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

vl yakusu(ll n) {
  vl res;
  FOR(i, 1, ll(sqrt(n) + 1)) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) {
        res.push_back(n / i);
      }
    }
  }
  return res;
}

int main() {
  ll X;
  cin >> X;
  auto y = yakusu(X);
  ll s = 0;
  ll a;
  for (ll i = 1; s < X; i++) {
    s = i * i * i * i * i;
    a = i;
  }
  while (true) {
    for (auto q : y) {
      ll b = a - q;
      if (a * a * a * a * a - b * b * b * b * b == X) {
        cout << a << " " << b;
        return 0;
      }
    }
    a--;
  }
}

Error: TLE

Fixed submission:

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

vl yakusu(ll n) {
  vl res;
  FOR(i, 1, ll(sqrt(n) + 1)) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) {
        res.push_back(n / i);
      }
    }
  }
  return res;
}

int main() {
  ll X;
  cin >> X;
  auto y = yakusu(X);
  ll s = 0;
  ll a;
  for (ll i = 1; s < X; i++) {
    s = i * i * i * i * i;
    a = i;
  }
  a--;
  while (true) {
    for (auto q : y) {
      ll b = a - q;
      if (a * a * a * a * a - b * b * b * b * b == X) {
        cout << a << " " << b;
        return 0;
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define ll long long
#define P pair<ll, ll>
#define mk make_pair
using namespace std;
const int N = 10005;
ll a[N];
map<ll, P> mp;
int main() {
  for (ll i = 0; i <= 1000; i++) {
    ll y = i;
    for (ll x = 1; x <= 4; x++) {
      y = y * i;
    }
    a[i] = y;
  }
  for (int i = 0; i <= 1000; i++) {
    for (int j = 0; j <= 1000; j++) {
      mp[a[i] - a[j]] = mk(i, j);
      mp[a[i] + a[j]] = mk(i, -j);
    }
  }
  ll x;
  cin >> x;
  cout << mp[x].first << ' ' << mp[x].second << '\\n';
  return 0;
}


Error: -11

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define P pair<ll, ll>
#define mk make_pair
using namespace std;
const int N = 55;
ll a[N];
map<ll, P> mp;
int main() {
  for (ll i = 0; i <= 1000; i++) {
    ll y = i;
    for (ll x = 1; x <= 4; x++) {
      y = y * i;
    }
    a[i] = y;
  }
  for (int i = 0; i <= 1000; i++) {
    for (int j = 0; j <= 1000; j++) {
      mp[a[i] - a[j]] = mk(i, j);
      mp[a[i] + a[j]] = mk(i, -j);
    }
  }
  ll x;
  cin >> x;
  cout << mp[x].first << ' ' << mp[x].second << '\\n';
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

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

void solve(long long X) {
  vi n5(0);
  for (ll i = 0; i <= 1000; i++) {
    n5.push_back(i * i * i * i * i);
  }

  for (int i = 0; i <= 1000; i++) {
    for (int j = 0; j <= 1000; j++) {
      if (n5[i] + n5[j] == X) {
        cout << i << " -" << j << endl;
        return;
      }
      if (n5[i] - n5[j] == X) {
        cout << i << " " << j << endl;
        return;
      }
      if (-n5[i] + n5[j] == X) {
        cout << "-" << i << " -" << j << endl;
        return;
      }
      if (-n5[j] - n5[i] == X) {
        cout << "-" << i << " " << j << endl;
        return;
      }
    }
  }
}

int main() {
  long long X;
  scanf("%lld", &X);
  solve(X);
  return 0;
}


Error: WA

Fixed submission:

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

// int ± 3.27 × 10^4
typedef long long int ll; // ± 9.22 × 10^18
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;

void solve(ll N, ll M, vi H, vi A, vi B) {
  vvb T = vvb(N, vb(N, false));
  for (int i = 0; i < M; i++) {
    T[A[i] - 1][B[i] - 1] = true;
    T[B[i] - 1][A[i] - 1] = true;
  }

  vb isGood(N, true);

  for (int i = 0; i < N; i++) {
    if (!isGood[i])
      continue;

    ll h = H[i];
    for (int j = 0; j < N; j++) {
      if (!T[i][j])
        continue;
      if (H[j] <= h)
        isGood[j] = false;
      if (H[j] >= h) {
        isGood[i] = false;
        break;
      }
    }
  }

  ll ans = 0;
  for (int i = 0; i < N; i++) {
    if (isGood[i])
      ans++;
  }

  cout << ans << endl;
}

int main() {
  ll N;
  scanf("%lld", &N);
  ll M;
  scanf("%lld", &M);
  vi H(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &H[i]);
  }
  vi A(M);
  vi B(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &A[i]);
    scanf("%lld", &B[i]);
  }
  solve(N, M, std::move(H), std::move(A), std::move(B));
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int x;
  cin >> x;
  int a = 0, b = 0;
  for (a = -1000; a <= 1000; a++) {
    for (b = -1000; b <= 1000; b++) {
      if (pow(a, 5.0) - pow(b, 5.0) == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int x;
  cin >> x;
  int a = 0, b = 0;
  int temp = 0;
  while (1) {
    while (pow(a, 5.0) < x) {
      a++;
    }
    if (pow(a, 5.0) == x) {
      cout << a << " " << b << endl;
      return 0;
    }
    a--;
    temp = pow(a, 5.0);
    int val = 0;
    while ((val = temp - pow(b, 5.0)) != x && val <= x) {
      b--;
    }
    if (temp - pow(b, 5.0) == 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;

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

  int A, B;
  A = 1;
  while (A < 120) {
    bool judge = false;
    for (int i = -119; i < 119; i++) {
      int n = A * A * A * A * A - i * i * i * i * i;
      if (n == X) {
        judge = true;
        B = i;
        break;
      }
    }
    if (judge)
      break;
    A++;
  }
  cout << A << ' ' << B << endl;
}


Error: TLE

Fixed submission:

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

int main() {
  int X;
  cin >> X;
  int A_B = 2;
  int A, B;
  bool zenntei = true;
  if (X <= 2) {
    zenntei = false;
  }

  if (X = 1) {
    A = 0;
    B = -1;
  }

  while (zenntei) {
    bool judge = false;

    while (A_B < X) {
      if (X % A_B == 0) {
        break;
      }
      if (A_B * A_B >= X) {
        A_B = 1;
        break;
      }
      A_B++;
    }

    A = A_B / 2 + 1;
    B = A - A_B;

    while (true) {
      int n = A * A * A * A * A - B * B * B * B * B;
      if (n > X)
        break;
      else if (n == X) {
        judge = true;
        break;
      }
      A++;
      B++;
    }

    if (judge)
      break;
  }
  cout << A << ' ' << B << endl;
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
inline int gi() {
  int data = 0, w = 1;
  char ch = 0;
  while (!isdigit(ch) && ch != '-')
    ch = getchar();
  if (ch == '-')
    w = -1, ch = getchar();
  while (isdigit(ch))
    data = 10 * data + ch - '0', ch = getchar();
  return w * data;
}
long long X;
int main() {
  cin >> X;
  for (long long a = -500; a <= 500; a++)
    for (long long b = -500; b <= 500; b++) {
      long long t1 = a * a * a * a * a, t2 = b * b * b * b * b;
      if (t1 - t2 == X)
        return printf("%lld %lld\\n", a, b) & 0;
    }
  return 0;
}

Error: 5

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
inline int gi() {
  int data = 0, w = 1;
  char ch = 0;
  while (!isdigit(ch) && ch != '-')
    ch = getchar();
  if (ch == '-')
    w = -1, ch = getchar();
  while (isdigit(ch))
    data = 10 * data + ch - '0', ch = getchar();
  return w * data;
}
long long X;
int main() {
  cin >> X;
  for (long long a = -500; a <= 500; a++)
    for (long long b = -500; b <= 500; b++) {
      long long t1 = a * a * a * a * a, t2 = b * b * b * b * b;
      if (t1 - t2 == X)
        return printf("%lld %lld\\n", a, b);
    }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <string>
#include <vector>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
int main() {
  ll x;
  cin >> x;
  ll a, b, tmp;
  a = b = 0;
  bool ok = false;
  rep(i, 1000) {
    tmp = x + pow(i, 5);
    rep(j, 1000) {
      if (abs(pow(j, 5)) == tmp) {
        if (pow(j, 5) < 0) {
          a = -j;
        } else {
          a = j;
        }
        b = i;
        ok = true;
        break;
      }
    }
    if (ok)
      break;
    tmp = x - pow(i, 5);
    rep(j, 1000) {
      if (abs(pow(j, 5)) == tmp) {
        if (pow(j, 5) < 0) {
          a = -j;
        } else {
          a = j;
        }
        b = -i;
        break;
      }
    }
    if (ok)
      break;
  }
  cout << a << " " << b << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <float.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
int main() {
  int x;
  cin >> x;
  ll a, b;
  a = b = 1;
  bool ok = false;
  bool minus = false;
  while (!ok) {
    if (abs(a - b) > x) {
      b = -1;
      minus = true;
    }
    if (pow(x + pow(b, 5), 0.2) < DBL_EPSILON)
      a = round(pow(x + pow(b, 5), 0.2));
    if (pow(a, 5) - pow(b, 5) == x) {
      ok = true;
      break;
    }
    if (!minus)
      b++;
    else {
      b--;
    }
  }
  cout << a << " " << b << endl;
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <string>
#include <vector>

using namespace std;

#define ll long long int
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n) for (int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
const int MOD = 1e9 + 7;

int main() {
  ll X;
  cin >> X;
  vector<ll> kouho;
  ll A = 0;
  ll B = 0;
  bool frag = false;
  for (int i = 1; i < sqrt(X) + 1; i++) {
    if (X % i == 0) {
      kouho.push_back(i);
    }
  }
  for (ll x : kouho) {
    for (ll i = 0 - x / 2; i < 130; i++) {
      ll y = pow(i + x, 5) - pow(i, 5);
      if (y == X) {
        B = i;
        A = i + x;
        frag = true;
      } else if (y > X)
        break;
    }
    if (frag)
      break;
  }
  if (!frag) {
    for (ll x : kouho) {
      for (ll i = 0 - x / 2; i >= (-1) * x; i--) {
        ll y = pow(i + x, 5) - pow(i, 5);
        if (y == X) {
          B = i;
          A = i + x;
          frag = true;
        } else if (y > X)
          break;
      }
      if (frag)
        break;
    }
  }
  cout << A << " " << B << endl;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <string>
#include <vector>

using namespace std;

#define ll long long int
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n) for (int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
const int MOD = 1e9 + 7;

int main() {
  ll X;
  cin >> X;
  vector<ll> kouho;
  ll A = 0;
  ll B = 0;
  bool frag = false;
  for (int i = 1; i < sqrt(X) + 1; i++) {
    if (X % i == 0) {
      kouho.push_back(i);
      kouho.push_back(X / i);
    }
  }
  for (ll x : kouho) {
    for (ll i = 0 - x / 2; i < 130; i++) {
      ll y = pow(i + x, 5) - pow(i, 5);
      if (y == X) {
        B = i;
        A = i + x;
        frag = true;
      } else if (y > X)
        break;
    }
    if (frag)
      break;
  }
  if (!frag) {
    for (ll x : kouho) {
      for (ll i = 0 - x / 2; i >= (-1) * x; i--) {
        ll y = pow(i + x, 5) - pow(i, 5);
        if (y == X) {
          B = i;
          A = i + x;
          frag = true;
        } else if (y > X)
          break;
      }
      if (frag)
        break;
    }
  }
  cout << A << " " << B << endl;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <fstream>
#include <iostream>
#include <list>
#include <tuple>
#include <vector>
using namespace std;
// #define FILENAME "./F/in/b04"
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long

#define MOD 1000000007

ll x, a, b, a5, b5, sign;

ll mypow(ll n, ll p) {
  if (p < 1)
    return 1;

  if (p % 2 == 0) {
    int powtmp = mypow(n, p / 2);
    return powtmp * powtmp;
  } else {
    int powtmp = mypow(n, p / 2);
    return powtmp * powtmp * n;
  }
}

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

#ifdef FILENAME
  ifstream file(FILENAME);
  cin.rdbuf(file.rdbuf());
#endif

  cin >> x;

  for (a = 0; a < 200; a++) {
    for (b = -200; b < 200; b++) {
      if (mypow(a, 5) - mypow(b, 5) == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <cmath>
#include <fstream>
#include <iostream>
#include <list>
#include <tuple>
#include <vector>
using namespace std;
// #define FILENAME "./F/in/b04"
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long

#define MOD 1000000007

ll x, a, b, b5, low, high, mid, sign;

ll mypow(ll n, ll p) {
  if (p < 1)
    return 1;

  if (p % 2 == 0) {
    int powtmp = mypow(n, p / 2);
    return powtmp * powtmp;
  } else {
    int powtmp = mypow(n, p / 2);
    return powtmp * powtmp * n;
  }
}

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

#ifdef FILENAME
  ifstream file(FILENAME);
  cin.rdbuf(file.rdbuf());
#endif

  cin >> x;

  a = 0;
  while (true) {
    b5 = mypow(a, 5) - x;
    if (b5 < 0) {
      sign = -1;
      b5 *= -1;
    } else
      sign = 1;

    low = 0;
    high = b5;
    if (mypow(low, 5) == b5) {
      b = sign * low;
      break;
    }
    if (mypow(high, 5) == b5) {
      b = sign * high;
      break;
    }
    while (high - low > 1) {
      b = low + (high - low) / 2;
      if (mypow(b, 5) > b5)
        high = b;
      else if (mypow(mid, 5) < b5)
        low = b;
      else
        break;
    }
    b *= sign;

    if (mypow(a, 5) - mypow(b, 5) == x)
      break;

    a++;
  }

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

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

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

int main() {
  long x;
  cin >> x;
  int minRange = -150;
  int maxRange = 150;

  for (long i = minRange; i < maxRange; ++i)
    for (long j = minRange; j < maxRange; ++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;

bool fifthRoot(long n, long &result) {
  bool negative = n < 0;
  n = abs(n);

  long start = 0;
  long end = n;
  long mid;

  while (start <= end) {
    mid = start + (end - start) / 2;
    long pow5 = pow(mid, 5);

    if (pow5 == n) {
      result = negative ? -mid : mid;
      return true;
    } else if (pow5 < n) {
      start = mid + 1;
    } else {
      end = mid - 1;
    }
  }

  return false;
}

int main() {
  long b, x;

  cin >> x;

  for (long a = 0; a < LONG_MAX; ++a) {
    long pow5a = pow(a, 5);

    if (fifthRoot(pow5a - x, b)) {
      cout << a << " " << b << "\\n";
      break;
    }

    if (fifthRoot(-pow5a - x, b)) {
      cout << -a << " " << b << "\\n";
      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 ll = long long;
// using P = pair<int,int>;
// pow(x,n)
// cout << fixed << setprecision(桁数);
// string = to_string(数値)
// int = stoi(文字列)
//(int)(char-'0')
// string = itoa(int)
// 円周率: M_PI

int main() {
  int64_t x;
  cin >> x;
  /*
  vector<int> kou;
  for(int i=1; i<=x; ++i){
      if(x%i==0) kou.push_back(i);
  }

  for(int i: kou){
      rep(A,100){
          int B=A-i;
          int64_t sum=pow(A,5)-pow(B,5);
          if(sum==x) {
              cout << A << " " << B << endl;
              return 0;
          }
      }
      for(int A=-1;A>=-120;--A){
          int B=A-i;
          int64_t sum=(A-B)*pow(A+B,2)*(A*A-A*B+B*2);
          if(sum==x) {
              cout << A << " " << B << endl;
              return 0;
          }
      }

  }*/
  rep(A, 200) {
    if ((pow(A, 5) - x) >= 0) {
      for (int B = 0; B <= 200; ++B) {
        int64_t sum = pow(A, 5) - pow(B, 5);
        if (sum == x) {
          cout << A << " " << B << endl;
          return 0;
        }
      }
    } else {
      for (int B = 0; B >= -200; --B) {
        int64_t sum = pow(A, 5) - pow(B, 5);
        if (sum == x) {
          cout << A << " " << B << endl;
          return 0;
        }
      }
    }
  }
  /*
  for(int i=0;i<=110;++i){
      int zan=pow(i,5)-x;
      int b=int(log10(zan)/log10(5.0));
      if(zan==pow(b,5)){
          cout << i << " " << b << endl;
          return 0;
      }
  }
  for(int i=-1;i>=-110;--i){
      int zan=pow(i,5)-x;
      int b=log(zan)/log(5);
      if(zan==pow(b,5)){
          cout << i << " " << b << 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>;
// pow(x,n)
// cout << fixed << setprecision(桁数);
// string = to_string(数値)
// int = stoi(文字列)
//(int)(char-'0')
// string = itoa(int)
// 円周率: M_PI

int main() {
  int64_t x;
  cin >> x;
  vector<int> kou;
  for (int i = 1; i <= x; ++i) {
    if (x % i == 0)
      kou.push_back(i);
  }
  for (int i : kou) {
    rep(A, 100) {
      int B = A - i;
      int64_t sum = pow(A, 5) - pow(B, 5);
      if (sum == x) {
        cout << A << " " << B << endl;
        return 0;
      }
    }
    for (int A = -1; A >= -120; --A) {
      int B = A - i;
      int64_t sum = (A - B) * pow(A + B, 2) * (A * A - A * B + B * 2);
      if (sum == x) {
        cout << A << " " << B << endl;
        return 0;
      }
    }
  }
  /*
  for(int i=0;i<=110;++i){
      int zan=pow(i,5)-x;
      int b=int(log10(zan)/log10(5.0));
      if(zan==pow(b,5)){
          cout << i << " " << b << endl;
          return 0;
      }
  }
  for(int i=-1;i>=-110;--i){
      int zan=pow(i,5)-x;
      int b=log(zan)/log(5);
      if(zan==pow(b,5)){
          cout << i << " " << b << endl;
          return 0;
      }
  }*/
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template <class T> void chmax(T &a, T b) { a > b ?: a = b; }
template <class T> void chmin(T &a, T b) { a < b ?: a = b; }

ll x;

void f(ll c) {
  for (ll b = -1e4; b <= 1e4; ++b) {
    ll a = b + c;
    if (pow(a, 5LL) - pow(b, 5LL) == x) {
      cout << a << " " << b << endl;
      exit(0);
    }
  }
}

int main() {
  cin >> x;
  for (ll i = 1; i * i <= x; ++i) {
    if (x % i == 0) {
      f(i);
      if (x / i != i)
        f(x / i);
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template <class T> void chmax(T &a, T b) { a > b ?: a = b; }
template <class T> void chmin(T &a, T b) { a < b ?: a = b; }

ll x;

void f(ll c) {
  for (ll b = -1e6; b <= 1e6; ++b) {
    ll a = b + c;
    if (pow(a, 5LL) - pow(b, 5LL) == x) {
      cout << a << " " << b << endl;
      exit(0);
    }
  }
}

int main() {
  cin >> x;
  for (ll i = 1; i * i <= x; ++i) {
    if (x % i == 0) {
      f(i);
      if (x / i != i)
        f(x / i);
    }
  }

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

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
using 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 (int i = -118; i <= 119; i++) {
    for (int j = 119; j >= -118; 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>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;
using graph = mat;
using edge = pair<ll, ll>;
using wgraph = vector<vector<edge>>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i, m, n) for (ll(i) = (m), i##_len = (n); (i) < (i##_len); ++(i))
#define FORR(i, v) for (auto(i) : v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define pb push_back

vector<long long> divisor(long long n) {
  vector<long long> ret;
  for (long long i = 1; i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(n / i);
    }
  }
  return ret;
}

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

  auto div = divisor(X);
  FORR(d, div) {
    ll Y = d, Z = X / d;
    ll Q = (ll)sqrt(sqrt(Z));
    REP(i, -Y - Z - 1, -Y + Z + 2) {
      ll B = i, A = i + Y;
      ll AA = A * A, AAA = AA * A, AAAA = AAA * A;
      ll BB = B * B, BBB = BB * B, BBBB = BBB * B;
      if (Z == AAAA + AAA * B + AA * BB + A * BBB + BBBB) {
        cout << A << " " << B << endl;
        break;
      }
    }
  }

  return 0;
}

/*



*/