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

/**
 *    author: gxfireball
 **/
#include <bits/stdc++.h>
#define ll long long
#define endl '\\n'
#define fastio                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
using namespace std;

int main() {
  fastio;
  ll x;
  cin >> x;
  for (ll i = -500; i <= 500; ++i) {
    for (ll j = -500; j <= 500; ++j) {
      if (pow(i, 5) - pow(j, 5) == x) {
        cout << i << " " << j;
        return 0;
      }
    }
  }
}


Error: TLE

Fixed submission:

/**
 *    author: gxfireball
 **/
#include <bits/stdc++.h>
#define ll long long
#define fastio                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
using namespace std;

void solve() {
  ll x;
  cin >> x;
  for (int i = -1000; i <= 1000; ++i) {
    for (int j = -1000; i <= 1000; ++j) {
      if (pow(i, 5) - pow(j, 5) == x) {
        cout << i << " " << j;
        return;
      }
    }
  }
}

int main() {
  fastio;
  int t;
  t = 1;
  // cin>>t;
  while (t--) {
    solve();
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for (int __x = __start; __x < __end; __x++)

int main() {
  ll 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 << endl;
        return 0;
      }
    }
  }
  assert(x == 0);
  return 0;
}


Error: WA

Fixed submission:

// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for (int __x = __start; __x < __end; __x++)

int main() {
  ll x;
  cin >> x;
  vector<ll> A;
  loop(i, 0, 200) {
    ll f = i;
    ll y = 1;
    loop(j, 0, 5) y *= f;
    if (y > 2000000000)
      break;
    A.push_back(y);
  }

  int n = A.size();
  vector<ll> signs{-1, 1};
  loop(i, 0, n) {
    loop(j, 0, n) {
      for (auto &&signA : signs) {
        for (auto &&signB : signs) {
          if (signA * A[i] - A[j] * signB == x) {
            cout << signA * i << " " << signB * j << endl;
            return 0;
          }
        }
      }
    }
  }
  assert(x == 0);
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
int d[4][2] = {1, 0, 0, 1, -1, 0, 0, -1};
ll poww(ll x, ll y) {
  ll ans = 1;
  while (y) {
    if (y & 1)
      ans *= x;
    x *= x;
    y >>= 1;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
#ifdef Uncle_drew
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
#else
#endif
  map<ll, pair<int, int>> ma;
  for (ll i = -500; i <= 500; i++) {
    for (ll j = -500; j <= 500; j++) {
      ll mid = poww(i, 5) - poww(j, 5);
      ma[mid] = mp(i, j);
    }
  }
  ll x;
  cin >> x;
  cout << ma[x].first << " " << ma[x].second << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
int d[4][2] = {1, 0, 0, 1, -1, 0, 0, -1};
ll poww(ll x, ll y) {
  ll ans = 1;
  while (y) {
    if (y & 1)
      ans *= x;
    x *= x;
    y >>= 1;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
#ifdef Uncle_drew
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#else
#endif
  map<ll, pair<int, int>> ma;
  for (int i = -1000; i <= 1000; i++) {
    for (int j = -1000; j <= 1000; j++) {
      ll mid = poww(i, 5) - poww(j, 5);
      ma[mid] = mp(i, j);
    }
  }
  ll x;
  cin >> x;
  cout << ma[x].first << " " << ma[x].second << endl;
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

ll f(ll b, ll k) { return pow(b + k, 5) - pow(b, 5); }

int main() {
  ll X;
  cin >> X;
  if (X == 1) {
    cout << 0 << " " << -1 << endl;
    return 0;
  }
  for (ll i = sqrt(X); i >= 1; i--) {
    if (X % i == 0) {
      // iは約数候補
      for (ll j = 0; j < 100000; j++) {
        if (X == f(j, i)) {
          cout << j + i << " " << j << endl;
          return 0;
        }
        if (X == f(-j, i)) {
          cout << -j + i << " " << -j << endl;
          return 0;
        }
      }
    }
  }
}


Error: TLE

Fixed submission:

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

ll f(ll b, ll k) { return pow(b + k, 5) - pow(b, 5); }

int main() {
  ll X;
  cin >> X;
  if (X == 1) {
    cout << 0 << " " << -1 << endl;
    return 0;
  }
  for (ll i = 2; i * i <= X; i++) {
    if (X % i == 0) {
      // iは約数候補
      for (ll j = 0; j < 10000000000; j++) {
        if (X == f(j, i)) {
          cout << j + i << " " << j << endl;
          return 0;
        }
        if (X == f(-j, i)) {
          cout << -j + i << " " << -j << endl;
          return 0;
        }
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iostream>
using namespace std;

long long int pow_long(long long int x, long long int n) {
  long long int r = 1;
  for (int i = 0; i < n; i++) {
    r = r * x;
  }

  return r;
}

int main() {
  int temp = pow_long(74, 5);

  long long int X;
  cin >> X;
  long long int Max = pow_long(10, 2);
  long long int A = 0, B = 0;
  bool cov = false;
  while (true) {

    long long int B_temp = -X + pow_long(A, 5);
    B = -A;
    while (true) {
      long long int B_5 = pow_long(B, 5);
      if (B_5 == B_temp) {
        B_temp;
        cov = true;
        break;
      }
      if (B >= A) {
        break;
      }
      B++;
    }
    if (cov == true) {
      break;
    }

    A++;
  }

  cout << A << " " << B;
  return 0;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
using namespace std;

int main() {
  int X;
  cin >> X;
  int Max = pow(10, 2);
  int A = 0, B = 0;
  bool cov = false;
  while (true) {

    int A_temp = X + pow(B, 5);
    A = 0;
    while (true) {
      int A_5 = pow(A, 5);
      if (A_5 == A_temp) {
        cov = true;
        break;
      }
      if (A_5 > A_temp) {
        break;
      }
      A++;
    }
    if (cov == true) {
      break;
    }
    B = -B;
    A_temp = X + pow(B, 5);
    A = 0;
    while (true) {
      int A_5 = pow(A, 5);
      if (A_5 == A_temp) {
        cov = true;
        break;
      }
      if (A_5 > A_temp) {
        break;
      }
      A++;
    }
    if (cov == true) {
      break;
    }
    B = -B;
    if (abs(B) > Max) {
      break;
    }

    B++;
  }

  cout << A << " " << B;
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

// #include <bits/stdc++.h>
#define maxs(x, y) x = max(x, y)
#define mins(x, y) x = min(x, y)
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define FOR(i, i0, n) for (int(i) = (i0); (i) < (n); (i)++)
#define FORR(i, i0, n) for (int(i) = (n)-1; (i) >= (i0); (i)--)
#define SORT(x) sort(x.begin(), x.end())
#define SORTR(x) sort(x.begin(), x.end(), greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int, int> P;
using namespace std;
using ll = long long;

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

  ll A = -1000;
  ll B = -1000;
  int found = 0;

  for (ll a = -1000; a <= 1000; a++) {
    if (found)
      break;
    for (ll b = -1000; b <= 1000; b++) {
      if (found)
        break;
      if ((ll)pow(a, 5) - (ll)pow(b, 5) == x) {
        if (found == 0) {
          A = a;
          B = b;
          found = 1;
        }
      }
    }
  }
  cout << A << " " << B;
}


Error: 1

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

// #include <bits/stdc++.h>
#define maxs(x, y) x = max(x, y)
#define mins(x, y) x = min(x, y)
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define FOR(i, i0, n) for (int(i) = (i0); (i) < (n); (i)++)
#define FORR(i, i0, n) for (int(i) = (n)-1; (i) >= (i0); (i)--)
#define SORT(x) sort(x.begin(), x.end())
#define SORTR(x) sort(x.begin(), x.end(), greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int, int> P;
using namespace std;
using ll = long long;

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

  for (int a = -100; a <= 100; a++) {
    for (int b = -100; b <= 100; b++) {
      if (pow(a, 5) - pow(b, 5) == x) {
        cout << a << " " << b;
        return 1;
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
typedef pair<int, int> P;

int main() {
  long X;
  cin >> X;
  for (long i = -120; i < 120; ++i) {
    for (long j = -120; j < 120; ++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 <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
typedef pair<int, int> P;

int main() {
  int X;
  cin >> X;
  int a = 1, n = X;
  vector<int> fact;
  while (n >= a) {
    if (n % a == 0) {
      fact.push_back(a);
    }
    a++;
  }
  for (auto &e : fact) {
    for (int i = 0 - e; i < X; i++) {
      long a = i + e;
      long b = i;
      if (a * a * a * a + a * a * a * b + a * a * b * b + a * b * b * b +
              b * b * b * b ==
          X / (a - b)) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

int main() {
  ll x;
  cin >> x;
  for (ll i = -118; i <= 119; i++) {
    for (ll j = -119; j <= 118; j++) {
      if ((i * i * i * i * i - j * j * j * j * j) == x) {
        cout << i << endl << j << endl;
        x = 0;
        break;
      }
    }
    if (x == 0)
      break;
  }
}

Error: TLE

Fixed submission:

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

long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

int main() {
  ll x;
  cin >> x;
  for (ll i = -118; i <= 119; i++) {
    for (ll j = -119; j = 118; j++) {
      if ((i * i * i * i * i - j * j * j * j * j) == x) {
        cout << i << endl << j << endl;
        x = 0;
        break;
      }
    }
    if (x == 0)
      break;
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int x;
  cin >> x;
  for (int i = 0; i <= 5000; i++) {
    for (int j = -2500; j <= 2500; j++) {
      if (pow(i, 5) - pow(j, 5) == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int x;
  cin >> x;
  for (int i = 0; i <= 10000; i++) {
    for (int j = -10000; j <= 0; j++) {
      if (pow(i, 5) - pow(j, 5) == 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 ll long long
#define pb push_back
#define vi vector<int>
#define mod 1000000007
#define size_f 100002
int main() {
  ll x;
  cin >> x;
  for (int a = 0; a <= 200; a++) {
    for (int b = -200; b <= 200; b++) {
      if (a * a * a * a * a - b * b * b * b * b == x) {
        cout << a << " " << b << "\\n";
        return 0;
      }
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define mod 1000000007
#define size_f 100002
int main() {
  ll x;
  cin >> x;

  vector<ll> v;
  for (ll i = 1; i <= sqrt(x); i++) {
    if (x % i == 0) {
      v.pb(i);
      v.pb(x / i);
    }
  }
  sort(v.begin(), v.end());

  if (x == 1)
    cout << "0 -1\\n";
  else {
    int c = 0, e = 0;
    for (int i = 0; i < v.size(); i++) {
      for (int j = 0; j <= v[i]; j++) {
        ll r = v[i] + j;
        ll d = v[i] - j;

        ll pn = pow(r, 5) - pow(j, 5);
        ll dn = pow(d, 5) + pow(j, 5);
        if (pn == x) {
          c = r;
          e = j;
          break;
        } else if (dn == x) {
          c = d;
          e = 0 - j;
          break;
        }
      }
      if (c != 0 || e != 0)
        break;
    }
    cout << c << " " << e << "\\n";
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
signed main() {
  int X;
  cin >> X;
  for (int b = 0; b <= 200; b++) {
    int xx = b * b * b * b * b + X;
    int x = X - b * b * b * b * b;
    rep(a, 200) {
      if (a * a * a * a * a == xx) {
        cout << a << ' ' << b << endl;
        return 0;
      }
      if (a * a * a * a * a == x) {
        cout << a << ' ' << -b << endl;
        return 0;
      }
    }
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
signed main() {
  int X;
  cin >> X;
  int a = 0;
  while (true) {
    int aa = a * a * a * a * a - X;
    rep(j, 100) {
      if (j * j * j * j * j == abs(aa)) {
        if (aa < 0)
          cout << a << ' ' << -j << endl;
        else
          cout << a << ' ' << j << endl;
        return 0;
      }
    }
    a++;
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long int x;
  cin >> x;
  int flag = 0;
  for (long long int i = -500; i <= 500; i++) {
    for (long long int j = -500; j <= 500; j++) {
      if (pow(i, 5) - pow(j, 5) == x) {
        cout << i << " " << j << endl;
        flag = 1;
        break;
      }
    }
    if (flag == 1) {
      break;
    }
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long int x;
  cin >> x;
  if (x % 2 == 1) {
    x--;
  }
  int i = 0;
  while (1) {
    if (pow(i, 5) == x) {
      cout << i << " " << -1 << endl;
      break;
    }
    i++;
  }
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

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

#define ll long long
#define mtv(kit) cout << #kit << " - " << kit << "\\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i, a, b) for (i = a; i < b; i++)
#define pii pair<ll, ll>
#define all(x) x.begin(), x.end()
#define nl "\\n"
#define ump unordered_map

void doit() {
  ll dp[1005], i, j;
  rep(i, 0, 1001) { dp[i] = pow(i, 5); }
  ll n, l1, l2;
  cin >> n;
  rep(i, 0, 1001) {
    rep(j, 0, i) {
      if (dp[i] - dp[j] == n) {
        cout << i << " " << j << nl;
        return;
      }
    }
  }
  rep(i, 0, 1001) {
    rep(j, i, 1001) {
      if (dp[i] + dp[j] == n) {
        cout << j << " " << -i << nl;
        return;
      }
    }
  }
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("input1.txt", "r", stdin);
  freopen("output1.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll t = 1;
  // cin >> t;
  for (ll i = 1; i <= t; i++) {
    doit();
  }
}


Error: WA

Fixed submission:

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

#define ll long long
#define mtv(kit) cout << #kit << " - " << kit << "\\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i, a, b) for (i = a; i < b; i++)
#define pii pair<ll, ll>
#define all(x) x.begin(), x.end()
#define nl "\\n"
#define ump unordered_map

void doit() {
  ll dp[100], i, j;
  rep(i, 0, 100) { dp[i] = pow(i, 5); }
  ll n, l1, l2;
  cin >> n;
  rep(i, 0, 101) {
    rep(j, 0, i) {
      if (dp[i] - dp[j] == n) {
        cout << i << " " << j << nl;
        return;
      }
    }
  }
  rep(i, 0, 101) {
    rep(j, i, 101) {
      if (dp[i] + dp[j] == n) {
        cout << j << " " << -i << nl;
        return;
      }
    }
  }
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("input1.txt", "r", stdin);
  freopen("output1.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll t = 1;
  // cin >> t;
  for (ll i = 1; i <= t; i++) {
    doit();
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <map>
#include <math.h>
#include <string>
#include <vector>
using namespace std;

int main() {
  long long int X;
  cin >> X;
  for (long long int i = -200; i <= 200; i++) {
    for (long long int j = -200; j <= 200; j++) {
      long long int ans = (long long)pow(i, 5) - (long long)pow(j, 5);
      if (ans == X) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
#include <map>
#include <math.h>
#include <string>
#include <vector>
using namespace std;

int main() {
  long long int X;
  cin >> X;
  for (long long int i = -100; i <= 100; i++) {
    for (long long int j = -100; j <= 100; j++) {
      long long int ans = (int)pow(i, 5) - (int)pow(j, 5);
      if (ans == X) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  long long int loop = 2 * (int)pow(10, 4);
  for (long long int i = 101; i <= loop; i++) {
    for (long long int j = i; j > 0; j--) {
      long long int ans = (int)pow(i, 5) - (int)pow(j, 5);
      if (ans > (long long int)pow(10, 9))
        break;
      if (ans == 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;
int main() {
  long long x;
  cin >> x;

  long long ansa, ansb;
  bool endf = false;

  for (int i = -1000; i <= 1000; i++) {
    for (int j = -1000; j <= 1000; j++) {
      if (powl(i, 5) - powl(j, 5) == x) {
        ansa = i;
        ansb = j;
        endf = true;
        break;
      }
    }
    if (endf)
      break;
  }

  cout << ansa << " " << ansb << endl;
}


Error: TLE

Fixed submission:

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

  long long ansa, ansb;

  for (int i = -1000; i <= 1000; i++) {
    for (int j = -1000; j <= 1000; j++) {
      if (powl(i, 5) - powl(j, 5) == x) {
        ansa = i;
        ansb = j;
      }
    }
  }

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

#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

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

  int ans_a, ans_b;

  for (int a = -200; a < 200; a++) {
    bool flag = false;
    for (int b = -200; b < 200; b++) {
      int64_t a5 = 1, b5 = 1;
      rep(tmp, 5) {
        a5 *= a;
        b5 *= b;
      }
      if (a5 - b5 == x) {
        ans_a = a;
        ans_b = b;
        flag = true;
        break;
      }
    }
    if (flag)
      break;
  }

OUT:
  cout << ans_a << ' ' << ans_b << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

bool mod(int a, int b, int N, int64_t div) {
  int64_t a_mod = 1, b_mod = 1;
  rep(i, 5) a_mod = (a_mod * a) % div;
  rep(i, 5) b_mod = (b_mod * b) % div;
  if ((a_mod - b_mod) % div == N % div)
    return true;
  else
    return false;
}

bool N_equ(int a, int b, int N) {
  int64_t a_mod = 1, b_mod = 1;
  rep(i, 5) a_mod = a_mod * a;
  rep(i, 5) b_mod = b_mod * b;
  if (a_mod - b_mod == N)
    return true;
  else
    return false;
}

int main() {
  int N;
  cin >> N;
  string s = to_string(N);
  int64_t N_digit = 1;

  rep(i, s.size()) N_digit *= 10;

  queue<pair<int64_t, int64_t>> q;
  for (int i = 0; i <= 9; i++) {
    for (int j = -9; j <= 9; j++) {
      if (mod(i, j, N, 10)) {
        pair<int64_t, int64_t> p(i, j);
        q.push(p);
      }
    }
  }

  int64_t div = 10;
  pair<int64_t, int64_t> ans;

  while (1) {
    div *= 10;
    int q_size = q.size();
    rep(j, q_size) {
      pair<int64_t, int64_t> p = q.front();
      q.pop();
      rep(k, 10) {
        rep(l, 10) {
          int64_t a = p.first, b = p.second;
          a += (k * div / 10);
          if (b >= 0)
            b += (l * div / 10);
          else
            b -= (l * div / 10);
          if (mod(a, b, N, div)) {
            if (N_equ(a, b, N)) {
              ans.first = a;
              ans.second = b;
              goto OUT;
            } else {
              pair<int64_t, int64_t> p_new(a, b);
              q.push(p_new);
            }
          }
        }
      }
    }
  }

OUT:
  cout << ans.first << ' ' << ans.second << endl;
}