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

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

// マクロ
// forループ関係
// 引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (lol i = 0; i < lol(n); i++)
#define REPD(i, n) for (lol i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (lol i = a; i <= lol(b); i++)
#define FORD(i, a, b) for (lol i = a; i >= lol(b); i--)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end() // sortなどの引数を省略したい
#define SIZE(x) lol(x.size())     // sizeをsize_tからllに直しておく
// 定数
#define PI 3.1415926535897932385 // pi
#define INF 1000000000000        // 10^12:極めて大きい値,∞
#define MOD 1000000007           // 10^9+7:合同式の法
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
// 最大値最小値
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

#define N 64

int main() {
  // lol result{0};
  lol x;
  cin >> x;
  // int k; cin >> k;
  /*
  vector<int> a(n);
  REP(i, n)
  {
      cin >> a[i];
  }
  */
  bool fl = true;
  for (int i = 0; i < INF && fl; i++) {
    for (int j = -64; j < INF; j++) {
      if (pow(i, 5) - pow(j, 5) == x) {
        cout << i << " " << j << endl;
        fl = false;
        break;
      }
      if (j >= 0 && pow(i, 5) - pow(j, 5) < x)
        break;
    }
  }

  // cout << result << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

// マクロ
// forループ関係
// 引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (lol i = 0; i < lol(n); i++)
#define REPD(i, n) for (lol i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (lol i = a; i <= lol(b); i++)
#define FORD(i, a, b) for (lol i = a; i >= lol(b); i--)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end() // sortなどの引数を省略したい
#define SIZE(x) lol(x.size())     // sizeをsize_tからllに直しておく
// 定数
#define PI 3.1415926535897932385 // pi
#define INF 1000000000000        // 10^12:極めて大きい値,∞
#define MOD 1000000007           // 10^9+7:合同式の法
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
// 最大値最小値
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

#define N 64

int main() {
  // lol result{0};
  lol x;
  cin >> x;
  // int k; cin >> k;
  /*
  vector<int> a(n);
  REP(i, n)
  {
      cin >> a[i];
  }
  */
  for (int i = 0; i < 10000; i++) {
    for (int j = -64; j < 10000; j++) {
      if (pow(i, 5) - pow(j, 5) == x) {
        cout << i << " " << j << endl;
        break;
      }
      if (j >= 0 && pow(i, 5) - pow(j, 5) < x)
        break;
    }
  }

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for (ll i = (m); i < (n); i++)
#define all(v) v.begin(), v.end()
#define print(x) cout << (x) << endl

int main() {
  int X;
  vector<int> div;
  cin >> X;
  int p4 = pow(X, 0.25) + 1;
  int p5 = pow(X, 0.2) + 1;
  rep(i, p4 + p5) {
    int j = i + 1;
    if (X % j == 0) {
      div.push_back(j);
    }
  }

  int A, B;
  bool fl = 0;
  rep(i, div.size()) {
    int D = div.at(i);
    for (int i = -p5; i + D <= p4; i++) {
      B = i;
      A = B + D;
      int ans = pow(A, 5) - pow(B, 5);
      if (ans == X) {
        cout << A << " " << B << endl;
        fl = true;
        break;
      }
    }
    if (fl)
      break;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for (ll i = (m); i < (n); i++)
#define all(v) v.begin(), v.end()
#define print(x) cout << (x) << endl

int main() {
  int X;
  vector<int> div;
  cin >> X;
  rep(i, sqrt(X)) {
    int j = i + 1;
    if (X % j == 0) {
      div.push_back(j);
      div.push_back(X / j);
    }
  }

  int A, B, l, r;
  bool fl = 0;
  rep(i, div.size()) {
    int D = div.at(i);
    for (int i = -D; i <= pow(X, 1 / 4); i++) {
      B = i;
      A = B + D;
      int ans = pow(A, 5) - pow(B, 5);
      if (ans == X) {
        cout << A << " " << B << endl;
        fl = true;
        break;
      }
    }
    if (fl)
      break;
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
#define int long long

int opow(int x, int y) {
  int res = 1;
  for (int i = 0; i < y; i++) {
    res *= x;
  }
  return res;
}

signed main() {
  int X;
  cin >> X;
  pair<int, int> ans;
  for (int j = -1000; j < 1000; j++) {
    for (int k = -1000; k < 1000; k++) {
      if (opow(j, 5) - opow(k, 5) == X) {
        ans = {j, k};
        goto endloop;
      }
    }
  }
endloop:
  cout << ans.first << " " << ans.second << endl;
}

Error: 1

Fixed submission:

#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <cstdint>  // int64_t, int*_t
#include <cstdio>   // printf
#include <deque>    // deque
#include <iostream> // cout, endl, cin
#include <limits>
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
#define ll long long
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define sysp system("PAUSE")
using namespace std;
#define int ll

int opow(int x, int n) {
  int res = 1;
  for (int i = 0; i < n; i++) {
    res *= x;
  }

  return res;
}

int func(int B, const int u, int v) {
  int f = 5 * opow(B, 4) + 10 * opow(B, 3) * u + 10 * opow(B, 2) * opow(u, 2) +
          5 * B * opow(u, 3) + opow(u, 4) - v;

  return f;
}
#define M 10000

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

  int Amax = 1;
  for (; 5 * opow(Amax, 4) + 10 * opow(Amax, 3) <= x; Amax++)
    ;
  vi ans(2, -1);
  for (int k = 1; opow(k, 5) <= x; k++)
    if (opow(k, 5) == x) {
      ans[0] = k;
      ans[1] = 0;
      goto endloop;
    }
  for (int u = 1; u * u <= x; u++) {
    if (x % u == 0) {
      int v = x / u;
      // 二分探索
      int blow = -M;
      int bhigh = M;

      while (bhigh - blow > 1) {
        int bmid = (bhigh + blow) / 2;

        int f = func(bmid, u, v);
        if (f == 0) {
          ans[0] = bmid + u;
          ans[1] = bmid;
          goto endloop;
        } else if (f < 0) {
          blow = bmid;
        } else if (f > 0) {
          bhigh = bmid;
        }
      }
    }
  }
endloop:
  cout << ans[0] << " " << ans[1] << endl;

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

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, x, n) for (int i = x; i < (n); i++)
#define ALL(n) begin(n), end(n)
#define sz(x) int(x.size())
using ll = long long;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  ll x;
  cin >> x;
  ll d = sqrt(sqrt(x));
  for (int i = 0; i <= d; i++) {
    ll a = pow(i, 5);
    ll b = -1 * (x - a);
    for (int j = 0; j <= d; j++) {
      ll c = pow(j, 5);
      if (c == b) {
        cout << i << " " << j << endl;
        return 0;
      }
      if (-c == b) {
        cout << i << " " << -j << endl;
        return 0;
      }
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, x, n) for (int i = x; i < (n); i++)
#define ALL(n) begin(n), end(n)
#define sz(x) int(x.size())
using ll = long long;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int x;
  cin >> x;
  int d = sqrt(x);
  for (int i = 0; i <= d; i++) {
    int a = pow(i, 5);
    int b = -1 * (x - a);
    for (int j = 0; j <= d; j++) {
      int c = pow(j, 5);
      if (c == b) {
        cout << i << " " << j << endl;
        return 0;
      }
      if (-c == b) {
        cout << i << " " << -j << endl;
        return 0;
      }
    }
  }

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

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
  ll n;
  cin >> n;
  for (ll a = -1000; a <= 1000; a++) {
    for (ll b = -1000; b <= 1000; b++) {

      if (pow(a, 5) - pow(b, 5) == n) {
        cout << a << " " << b;
        return 0;
      }
    }
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
  ll n;
  cin >> n;
  for (ll a = -4000; a <= 4000; a++) {
    for (ll b = -4000; b <= 4000; b++) {

      if (pow(a, 5) - pow(b, 5) == n) {
        cout << 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;

void print(int A, int B) { printf("%d %d\\n", A, B); }

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

  // Process and Output
  // B = 0
  int A = int(pow(X, 0.2));
  ll a = (ll)pow(A, 5);
  if (a == X) {
    print(A, 0);
    return 0;
  }

  // 0 <= B^5 < X
  ll a0 = a;
  A++;
  a = (ll)pow(A, 5);
  int B = 0;
  ll b = 0;
  while (a0 + b < a) {
    B++;
    b = (ll)pow(B, 5);
    if (a0 + b == a) {
      print(A, B);
      return 0;
    }
  }

  // B < 0
  A = int(pow(X / 2, 0.2));
  B = -(A + 1);
  a = (ll)pow(A, 5);
  b = (ll)pow(B, 5);
  while (a - b != X) {
    if (a - b < X) {
      A++;
      a = pow(A, 5);
    } else {
      B++;
      b = pow(B, 5);
    }
  }
  print(A, B);

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

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

  // Process
  int A = int(pow(X / 2, 0.2));
  int B = -(A + 1);
  int a = pow(A, 5);
  int b = pow(B, 5);
  while (a - b != X) {
    if (a + b < X) {
      A++;
      a = pow(A, 5);
    } else {
      B++;
      b = pow(B, 5);
    }
  }

  // Output
  printf("%d %d\\n", A, B);

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

#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
  int X;
  cin >> X;
  ll tmp = 130;
  rep(i, X) {
    FOR(j, -tmp, tmp + 1) {
      if (pow(i, 5) - pow(j, 5) == X) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
  int X;
  cin >> X;
  ll tmp = 100;
  rep(i, X) {
    FOR(j, -X, X + 1) {
      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>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;

int main() {
  int x;
  cin >> x;
  int a, b;
  int tmp, tmp2;
  bool flg = false;
  for (a = -118; a <= 119; a++) {
    for (b = -119; b < a; b++) {
      tmp = pow(a, 5) - pow(b, 5);
      tmp2 = pow(a, 5) + pow(b, 5);
      if (tmp == x) {
        flg = true;
        break;
      }
      if (tmp2 == x) {
        flg = true;
        break;
      }
    }
    if (flg)
      break;
  }
  cout << a << " " << b << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  int x;
  cin >> x;
  int a = 0;
  int b = 0;
  int tmp;
  bool flg = false;
  while (1) {
    a++;
    tmp = pow(a, 5) - pow(b, 5);
    if (x == tmp) {
      break;
    }
    for (b = 1; b <= a; b++) {
      if (tmp > x) {
        tmp = pow(a, 5) - pow(b, 5);
        if (x == tmp) {
          flg = true;
          break;
        }
      } else {
        tmp = pow(a, 5) + pow(b, 5);
        if (x == tmp) {
          b *= -1;
          flg = true;
          break;
        }
      }
    }
    if (flg)
      break;
  }
  cout << a << " " << b << endl;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1 << 30;
const ll INF64 = 1LL << 60;

int main() {
#ifndef ONLINE_JUDGE
  freopen(".in.txt", "r", stdin);
  freopen(".out.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll x;
  cin >> x;
  for (ll i = -5e3; i <= 5e3; i++) {
    ll b5 = pow(i, 5);
    ll a = pow(x + b5, 0.2);
    if ((ll)pow(a, 5) == x + b5) {
      cout << a << ' ' << i;
      return 0;
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x;
  cin >> x;
  long long a = -3980, b = -3980;
  long long c = 0, d = 0;
  for (int i = 0; i < 3080 * 2; i++) {
    for (int j = 0; j < 3980 * 2; j++) {
      if (pow(a, 5) - pow(b, 5) == x) {
        c = a;
        d = b;
        break;
      } else
        a++;
    }
    b++;
  }
  cout << c << ' ' << d;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll pow(int x, int y) {
  ll ans = 1;
  for (int i = 1; i <= y; i++)
    ans *= x;
  return ans;
}
int main() {
  int x;
  cin >> x;
  if (x == 1) {
    cout << 0 << ' ' << -1;
    return 0;
  }
  for (int i = 0; i < sqrt(x); i++) {
    for (int j = -i; j < i; j++) {
      if (pow(i, 5) - pow(j, 5) == x) {

        cout << i << ' ' << j;

        break;
      }
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll pow(int x, int y) {
  ll ans = 1;
  for (int i = 1; i <= y; i++)
    ans *= x;
  return ans;
}
int main() {
  int x;
  cin >> x;
  if (x == 1) {
    cout << 0 << ' ' << -1;
    return 0;
  }
  for (int i = 0; i < x; i++) {
    for (int j = -i; j < i; j++) {
      if (pow(i, 5) - pow(j, 5) == x) {

        cout << i << ' ' << j;

        break;
      }
    }
  }

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

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target(                                                            \\
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#define pie 3.141592653589793238
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int x;
  cin >> x;

  long long map[121];
  for (long long i = 0; i < 121; i++) {
    map[i] = i * i * i * i * i;
  }

  for (int i = 0; i < 121; i++) {
    for (int j = 0; j < 121; j++) {
      if (map[i] - map[j] == x) {
        cout << i << " " << j << endl;
        return 0;
      }
      if (map[i] + map[j] == x) {
        cout << i << " " << j * -1 << endl;
        return 0;
      }
    }
  }

  return 0;
}

Error: -4

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target(                                                            \\
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#define pie 3.141592653589793238
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int x;
  cin >> x;

  long long map[121];
  for (long long i = 0; i < 121; i++) {
    map[i] = i * i * i * i * i;
  }

  for (int i = 0; i < 121; i++) {
    for (int j = 0; i < 121; j++) {
      if (map[i] - map[j] == x) {
        cout << i << " " << j << endl;
        return 0;
      }
      if (map[i] + map[j] == x) {
        cout << i << " " << j * -1 << endl;
        return 0;
      }
    }
  }

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

#include <algorithm>
#include <iostream>
#include <math.h>
using namespace std;
long long X;

long long A, B;

int main() {
  bool f = false;
  cin >> X;

  for (A = -118; A < 119; A++) {
    for (B = -119; B < 118; B++) {
      if (pow(A, 5) - pow(B, 5) == X) {
        cout << A << " " << B << endl;
        f = true;
        break;
      }
    }
    if (f)
      break;
  }

  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <iostream>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;

long long X;
long long a[100000];

int main() {
  queue<long long> que;
  cin >> X;

  for (int i = 1; i <= X; i++) {
    if ((X % i == 0) && (X % 3 == i % 3)) {
      que.push(i);
    }
  }

  long long A = -118;
  long long B;
  bool f = false;

  while (true) {
    int d = que.front();
    while (true) {
      B = A - d;
      if (pow(A, 5) - pow(B, 5) == X) {
        cout << A << " " << B << endl;
        f = true;
        break;
      }
      if (f)
        break;
      A++;
    }
    que.pop();
  }

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int X;
  cin >> X;
  long A, B;
  long fA, fB;
  for (A = -150; A < 150; A++) {
    fA = A * A * A * A * A;
    for (B = -150; B < 150; B++) {
      fB = B * B * B * B * B;
      if (fA - fB == X) {
        break;
      }
    }
    if (fA - fB == X) {
      break;
    }
  }
  cout << A << ' ' << B << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int X;
  cin >> X;
  long A, B;
  long fA, fB;
  long m = 0;
  long d = 0;
  while (d < X) {
    m++;
    d = m * m * m * m * m;
  }
  A = m - 1;
  fA = A * A * A * A * A;
  B = 0;
  fB = 0;
  while (fA + fB < X) {
    B++;
    fB = B * B * B * B * B;
  }
  if (fA + fB > X) {
    B = 0;
    fB = 0;
    double k = pow(double(X), 1.0 / 5.0);
    int t = (int)k;
    while (t * t * t * t * t != X + fB) {
      B++;
      fB = B * B * B * B * B;
      k = pow(X + fB, 1.0 / 5.0);
      t = int(k);
    }
    A = (int)k;
    cout << A << ' ' << B << endl;
  } else {
    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;
  long cul;
  int flag = 0;

  for (long i = -120; i < 120; i++) {
    if (flag == 1) {
      break;
    }
    for (long j = i + 1; j < 120; j++) {
      cul = j * j * j * j * j - i * i * i * i * i;
      if (cul == X) {
        cout << j << " " << i << endl;
        flag = 1;
        break;
      }
    }
  }
}

Error: TLE

Fixed submission:

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

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

  for (int i = -120; i < X; i++) {
    for (int j = -120; j < 120; j++) {
      cul = pow(j, 5) - pow(i, 5);
      if (cul == X) {
        cout << j << " " << i << endl;
        flag = 1;
        break;
      }
      if (flag) {
        break;
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
#define MAX 1000000005

typedef long long ll;
typedef std::pair<int, int> pr;

int main(int, char **) {
  int x;
  cin >> x;

  int a = 0;
  int b = 0;
  bool found = false;
  for (int i = -118; !found && i <= 119; i++) {
    for (int j = -119; !found && j <= 118; j++) {
      if (pow(i, 5) - pow(j, 5) == x) {
        a = i;
        b = j;
        found = true;
      }
    }
  }

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

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
#define MAX 1000000005

typedef long long ll;
typedef std::pair<int, int> pr;

int main(int, char **) {
  vector<ll> pow5;
  for (int i = 0;; i++) {
    ll tmp = i * i * i * i * i;
    pow5.push_back(tmp);
    if (tmp > LLONG_MAX)
      break;
  }

  int x;
  cin >> x;

  ll a, b, sgn;
  bool found = false;
  for (int i = 0; !found && i < pow5.size(); i++) {
    ll b5 = pow5[i];
    ll a5 = x + b5;
    ll a52 = x - b5;
    for (int j = 0; j < pow5.size(); j++) {
      if (pow5[j] == a5 || pow5[j] == a52) {
        sgn = (pow5[i] == a5) ? 1 : -1;
        b = i;
        a = j;
        found = true;
        break;
      }
    }
  }

  cout << a << " " << b * sgn << endl;

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

//

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, x, y) for (int i = x; i < y; i++)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) a / __gcd(a, b) * b
#define range(a) (a).begin(), (a).end()
const int inf = 2147483647;

int main() {
  int X;
  cin >> X;
  ll ansa, ansb;
  rep(i, -400, 400) {
    rep(j, -400, 400) {
      if (X == pow(j, 5.0) - pow(i, 5.0)) {
        ansa = j;
        ansb = i;
        break;
      }
    }
  }
  cout << ansa << " " << ansb << endl;
}

Error: TLE

Fixed submission:

//

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, x, y) for (int i = x; i < y; i++)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) a / __gcd(a, b) * b
#define range(a) (a).begin(), (a).end()
const int inf = 2147483647;

int main() {
  int X;
  cin >> X;
  ll ansa, ansb;
  rep(i, -4000, 4000) {
    rep(j, -4000, 4000) {
      if (X == pow(j, 5.0) - pow(i, 5.0)) {
        ansa = j;
        ansb = i;
        break;
      }
    }
  }
  cout << ansa << " " << ansb << endl;
}