alexjercan/bugnet huggingface dataset:
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int x;
  cin >> x;
  vector<int> divisor;
  for (int i = 1; i * i <= x; i++) {
    if (x % i == 0) {
      divisor.push_back(i);
      divisor.push_back(x / i);
    }
  }
  rep(i, 30000) rep(j, divisor.size()) {
    int d = divisor[j];
    int e = x / d;
    ll exp = 5 * i * i * i * i - 10 * i * i * i * d + 10 * i * i * d * d -
             5 * i * d * d * d + d * d * d * d;
    if (exp == e) {
      cout << i << " " << i - d << endl;
      return 0;
    }
    exp = 5 * i * i * i * i + 10 * i * i * i * d + 10 * i * i * d * d +
          5 * i * d * d * d + d * d * d * d;
    if (exp == e) {
      cout << -i << " " << -i - d << endl;
      return 0;
    }
    d = -d;
    e = -e;
    if (exp == e) {
      cout << i << " " << i - d << endl;
      return 0;
    }
    exp = 5 * i * i * i * i + 10 * i * i * i * d + 10 * i * i * d * d +
          5 * i * d * d * d + d * d * d * d;
    if (exp == e) {
      cout << -i << " " << -i - d << endl;
      return 0;
    }
  }
  return 0;
}

Error: -11

Fixed submission:

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

int main() {
  int x;
  cin >> x;
  vector<ll> p5(1000);
  map<ll, int> m;
  map<ll, int> p5top;
  rep(i, 2000) {
    p5[i] = i * i * i * i * i;
    m[p5[i]] = 1;
    p5top[p5[i]] = i;
  }
  rep(i, 2000) {
    ll b = p5[i] - x;
    if (m[b] == 1) {
      cout << i << " " << p5top[b] << endl;
      return 0;
    } else if (m[-b] == 1) {
      cout << i << " " << -p5top[-b] << endl;
      return 0;
    }
    b = -p5[i] - x;
    if (m[b] == 1) {
      cout << -i << " " << p5top[b] << endl;
      return 0;
    } else if (m[-b] == 1) {
      cout << -i << " " << -p5top[-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, a, b, sum;
  vector<long long> afact(1000);
  long long bfact;
  cin >> x;
  for (int i = 1; i <= 1000; i++) {
    afact[i] = pow(i, 5);
  }
  for (int i = -1000; i < 1000; i++) {
    bfact = x + pow(i, 5);
    for (int j = 1; j <= 1000; j++) {
      if (bfact == afact[j]) {
        cout << j << " " << i << endl;
        return 0;
      }
    }
  }
}

Error: TLE

Fixed submission:

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

int main() {
  int x, a, b, afact, bfact, sum;
  cin >> x;
  for (a = 0;; a++) {
    afact = pow(a, 5);
    if (afact >= x) {
      for (b = a;; b++) {
        bfact = pow(b, 5);
        sum = afact - bfact;
        if (sum < x) {
          break;
        } else if (afact - bfact == x) {
          cout << a << " " << b << endl;
          return 0;
        }
      }
    } else {
      for (b = -1;; b--) {
        bfact = pow(b, 5);
        sum = afact - bfact;
        if (sum > x) {
          break;
        } else if (afact - bfact == x) {
          cout << a << " " << b << endl;
          return 0;
        }
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template <typename T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef tuple<ll, ll, ll> tlll;
typedef tuple<int, int, int> tiii;
const ll mod = 1e9 + 7;
const int inf = 1 << 30;

int main() {
  ll x;
  cin >> x;
  ll mx = 0;
  while (mx * mx * mx * mx * mx <= 1e18) {
    mx++;
  }
  for (ll a = -mx; a <= mx; a++) {
    for (ll b = -mx; b <= mx; b++) {
      if (a * a * a * a * a - b * b * b * b * b == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
}

Error: TLE

Fixed submission:

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template <typename T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef tuple<ll, ll, ll> tlll;
typedef tuple<int, int, int> tiii;
const ll mod = 1e9 + 7;
const int inf = 1 << 30;

int main() {
  ll x;
  cin >> x;
  for (int i = 1; i <= sqrt(x); i++) {
    if (x % i == 0) {
      for (ll a = 0; a <= i; a++) {
        ll b = a - i;
        if (a * a * a * a + a * a * a * b + a * a * b * b + a * b * b * b +
                b * b * b * b ==
            x / i) {
          cout << a << " " << b << endl;
          return 0;
        }
      }
      for (ll a = 0; a <= x / i; a++) {
        ll b = a - x / i;
        if (a * a * a * a + a * a * a * b + a * a * b * b + a * b * b * b +
                b * b * b * b ==
            i) {
          cout << a << " " << b << endl;
          return 0;
        }
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007 // 1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<string> vecstr;
typedef vector<bool> vecbool;
typedef vector<vector<int>> vec2int;
typedef pair<int, int> P;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  ll x;
  cin >> x;
  vecll gojou(4001, 0);
  REP(i, 4001) { gojou[i] = i * i * i * i * i; }
  bool ok = false;
  REP(i, 4001) {
    REP(j, 4001) {
      if (gojou[i] - gojou[j] == x) {
        cout << i << " " << j << endl;
        ok = true;
        return 0;
      }
      if (gojou[i] + gojou[j] == x) {
        cout << i << " " << -j << endl;
        ok = true;
        return 0;
      }
    }
  }

  assert(ok);
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007 // 1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<string> vecstr;
typedef vector<bool> vecbool;
typedef vector<vector<int>> vec2int;
typedef pair<int, int> P;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  ll x;
  cin >> x;
  vecll gojou(4001, 0);
  REP(i, 4001) { gojou[i] = i * i * i * i * i; }
  bool ok = false;
  REP(i, 4001) {
    REP(j, 4001) {
      if (gojou[i] - gojou[j] == x) {
        cout << i << " " << j << endl;
        ok = true;
        return 0;
      }
      if (gojou[i] + gojou[j] == x) {
        cout << i << " " << -j << endl;
        ok = true;
        return 0;
      }
    }
  }
  assert(ok);
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

// #define _GLIBCXX_DEBUG
#include <algorithm>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod = 1e+9 + 7;

int main() {
  ll x;
  cin >> x;
  for (ll i = 199;; i--) {
    for (ll j = -199; j <= 0; j++) {
      if (i * i * i * i * i - (j * j * j * j * j) == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}


Error: TLE

Fixed submission:

// #define _GLIBCXX_DEBUG
#include <algorithm>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod = 1e+9 + 7;

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

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

#define FOR(i, a, b) for (ll i = a; (i) < (b); ++(i))
#define RFOR(i, a, b) for (ll i = a; (i) >= (b); --(i))
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define UNIQ(v)                                                                \\
  sort(ALL(v));                                                                \\
  v.erase(unique(ALL(v)), v.end())
#define BIT(n) (1LL << (n))
#define DEBUG(a) cout << #a << " = " << a << endl

const int inf = 1001001001;
const int mod = (int)1e9 + 7;
// const ll inf = 1e15;
// const ll mod = 1e9+7;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};

int main() {
  int X;
  cin >> X;
  // RFOR(i, 0, -1*inf) {
  //     A = i;
  //     B = A - 1;
  //     int X = pow(A, 5) - pow(B, 5);
  //     if (X > 1000000001) break;
  // }
  // DEBUG(A);

  int A, B;
  FOR(i, -120, 120) {
    FOR(j, -120, 120) {
      if (pow(i, 5) - pow(j, 5) == X) {
        A = i;
        B = j;
      }
    }
  }

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


Error: TLE

Fixed submission:

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

#define FOR(i, a, b) for (ll i = a; (i) < (b); ++(i))
#define RFOR(i, a, b) for (ll i = a; (i) >= (b); --(i))
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define UNIQ(v)                                                                \\
  sort(ALL(v));                                                                \\
  v.erase(unique(ALL(v)), v.end())
#define BIT(n) (1LL << (n))
#define DEBUG(a) cout << #a << " = " << a << endl

const ll inf = 1e15;
const ll mod = 1e9 + 7;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};

int X;

int main() {
  cin >> X;

  int A = X;
  int B = X;
  if (X >= 0) {
    FOR(a, 0, A + 1) {
      FOR(b, a, B + 1) {
        int sum = pow(a, 5) + pow(b, 5);
        if (sum > X) {
          break;
        } else if (sum == X) {
          cout << a << " " << -1 * b << endl;
          return 0;
        }
      }
    }
  } else {
    RFOR(a, 0, A - 1) {
      RFOR(b, a, B - 1) {
        int sum = pow(a, 5) + pow(b, 5);
        if (sum < X) {
          break;
        } else if (sum == X) {
          cout << a << " " << -1 * b << endl;
          return 0;
        }
      }
    }
  }

  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, n) for (int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { printf("ERROR%d!\\n", num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int dx[8] = {-1, 0, 1, 0, 1, 1, -1, -1};
int dy[8] = {0, -1, 0, 1, 1, -1, 1, -1};

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  ll X;
  cin >> X;

  map<ll, int> Map;
  vector<ll> vec;

  for (ll i = 0; i <= 120; i++) {
    ll res = pow(i, 5);
    vec.pb(res);
    Map[res] = 1;
  }

  ll A = -33, ans_B = -33;
  for (ll i = 0; i < vec.size(); i++) {
    ll v = vec[i];
    ll res1 = X + v;
    ll res2 = X - v;
    if (res2 < 0)
      res2 = res2 * (-1);

    if (Map[res1] == 1) {
      A = res1;
      ans_B = i;
      // cout << "B1 " << ans_B << endl;
      break;
    } else if (Map[res2] == 1) {
      A = res2;
      ans_B = -(i);
      // cout << "B2 " << ans_B << endl;
      break;
    }
  }

  // cout << A << endl;
  for (ll i = 0; i < vec.size(); i++) {
    if (vec[i] == A) {
      cout << i << " ";
      break;
    }
  }
  cout << ans_B << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { printf("ERROR%d!\\n", num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int dx[8] = {-1, 0, 1, 0, 1, 1, -1, -1};
int dy[8] = {0, -1, 0, 1, 1, -1, 1, -1};

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  int X;
  cin >> X;

  map<int, int> Map;
  vector<int> vec;

  ll V = pow(120, 5);
  for (int i = 0;; i++) {
    int v = pow(i, 5);
    if (v > V)
      break;
    Map[v] = 1;
    vec.pb(v);
  }

  // cout << "SHOW: ";
  // rep(i,vec.size()){
  //   cout << vec[i] << " ";
  // }cout << endl;

  int A = -33, ans_B = -33;
  rep(i, vec.size()) {
    int v = vec[i];
    int res1 = X + v;
    int res2 = X - v;
    if (res2 < 0)
      res2 = res2 * (-1);

    if (Map[res1] == 1) {
      A = res1;
      ans_B = i;
      // cout << "B1 " << ans_B << endl;
      break;
    } else if (Map[res2] == 1) {
      A = res2;
      ans_B = -(i);
      // cout << "B2 " << ans_B << endl;
      break;
    }
  }

  // cout << A << endl;
  rep(i, vec.size()) {
    if (vec[i] == A) {
      cout << i << " ";
      break;
    }
  }
  cout << ans_B << endl;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { printf("ERROR%d!\\n", num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int dx[8] = {-1, 0, 1, 0, 1, 1, -1, -1};
int dy[8] = {0, -1, 0, 1, 1, -1, 1, -1};

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  ll X;
  cin >> X;

  map<ll, int> Map;
  vector<ll> vec;

  ll front = 0;
  for (ll i = 0;; i++) {
    ll v = pow(i, 5);
    if (i > 0 && v - front > X)
      break;
    Map[v] = 1;
    vec.pb(v);
    front = v;
  }

  ll A = -33, ans_B = -33;
  for (ll i = 0; i < vec.size(); i++) {
    ll v = vec[i];
    ll res1 = X + v;
    ll res2 = X - v;
    if (res2 < 0)
      res2 = res2 * (-1);

    if (Map[res1] == 1) {
      A = res1;
      ans_B = i;
      // cout << "B1 " << ans_B << endl;
      break;
    } else if (Map[res2] == 1) {
      A = res2;
      ans_B = -(i);
      // cout << "B2 " << ans_B << endl;
      break;
    }
  }

  // cout << A << endl;
  for (ll i = 0; i < vec.size(); i++) {
    if (vec[i] == A) {
      cout << i << " ";
      break;
    }
  }
  cout << ans_B << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { printf("ERROR%d!\\n", num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int dx[8] = {-1, 0, 1, 0, 1, 1, -1, -1};
int dy[8] = {0, -1, 0, 1, 1, -1, 1, -1};

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  ll X;
  cin >> X;

  map<ll, int> Map;
  vector<ll> vec;

  ll front = 0;
  for (ll i = 0;; i++) {
    int v = pow(i, 5);
    // if(i>0 && v-front>X) break;
    if (i > 0 && v - front > X)
      break;
    Map[v] = 1;
    vec.pb(v);
    front = v;
  }

  ll A = -33, ans_B = -33;
  for (ll i = 0; i < vec.size(); i++) {
    ll v = vec[i];
    ll res1 = X + v;
    ll res2 = X - v;
    if (res2 < 0)
      res2 = res2 * (-1);

    if (Map[res1] == 1) {
      A = res1;
      ans_B = i;
      // cout << "B1 " << ans_B << endl;
      break;
    } else if (Map[res2] == 1) {
      A = res2;
      ans_B = -(i);
      // cout << "B2 " << ans_B << endl;
      break;
    }
  }

  // cout << A << endl;
  for (ll i = 0; i < vec.size(); i++) {
    if (vec[i] == A) {
      cout << i << " ";
      break;
    }
  }
  cout << ans_B << endl;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define ALLG(v) v.begin(), v.end(), greater<int>()
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll GCD(ll x, ll y) { return y ? GCD(y, x % y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }
ll GetDigit(ll num) {
  ll digit = 0;
  while (num != 0) {
    num /= 10;
    digit++;
  }
  return digit;
}

using namespace std;
int main() {

  double x;

  cin >> x;

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

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define ALLG(v) v.begin(), v.end(), greater<int>()
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll GCD(ll x, ll y) { return y ? GCD(y, x % y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }
ll GetDigit(ll num) {
  ll digit = 0;
  while (num != 0) {
    num /= 10;
    digit++;
  }
  return digit;
}

int BinarySearch(int r, int key) {

  int left = 0, right = r, mid;

  while (left <= right) {
    mid = (left + right) / 2;
    if (pow(mid, 5) == key) {
      return mid;
    } else if (key < pow(mid, 5)) {

      right = mid;
    } else if (pow(mid, 5) < key) {

      left = mid + 1;
    }
  }
}

using namespace std;
int main() {

  double x;

  cin >> x;

  x--;

  // int ans = 0;
  // for (int i = 0; ; i++)
  //{
  //	if (x == pow(i, 5)) {
  //		ans = i;
  //		break;

  //	}
  //}

  // BinarySearch(x, x);

  // cout << ans << " " << -1 << endl;
  cout << BinarySearch(x, x) << " " << -1 << endl;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

int main(void) {
  long long X;
  cin >> X;
  for (long long i = -200; i <= 200; i++) {
    for (long long j = -200; j <= 200; 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 <bits/stdc++.h>

using namespace std;

int main(void) {
  long long X;
  cin >> X;
  long long A, B;
  A = 1;
  B = 0;
  long long result;
  while (1) {
    result = pow(A, 5) - pow(B, 5);
    if (result == X)
      break;
    if (X % 2 == 0) {
      A = 2 * A + 1;
      B = 2 * B - 1;
    } else {
      A = 2 * A;
      B = 2 * B - 1;
    }
  }
  cout << A << " " << B << endl;
  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 suuji1, suuji2;
  int count = 0;
  for (int i = 0; i < 1000; i++) {
    if (count != 0) {
      break;
    } else {
      for (int j = 0; j < 1000; j++) {
        suuji1 = pow(i, 5) + pow(j, 5);
        suuji2 = pow(i, 5) - pow(j, 5);
        if (suuji1 == X) {
          cout << i << " " << -j << endl;
          count++;
        } else if (suuji2 == X) {
          cout << i << " " << j << endl;
          count++;
        }
      }
    }
  }
}


Error: TLE

Fixed submission:

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

int main() {
  int X;
  cin >> X;
  int suuji1, suuji2;
  int count = 0;
  for (int i = 0; i < 1000000; i++) {
    if (count != 0) {
      break;
    } else {
      for (int j = 0; j < 1000000; j++) {
        suuji1 = pow(i, 5) + pow(j, 5);
        suuji2 = pow(i, 5) - pow(j, 5);
        if (suuji1 == X) {
          cout << i << " " << -j << endl;
          count++;
        } else if (suuji2 == X) {
          cout << i << " " << j << endl;
          count++;
        }
      }
    }
  }
}
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>;

bool is_integer(double x) { return floor(x) == x; }

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

  ll A, B;
  int flag = 0;
  for (int i = -200; i < 200; i++) {
    for (int j = -200; j < 200; j++) {
      if ((i * i * i * i * i) - (j * j * j * j * j) == X) {
        A = i;
        B = j;
        flag = 1;
        break;
      }
    }
    if (flag == 1)
      break;
  }
  if (X == 1)
    cout << "0 -1" << endl;
  else
    cout << A << " " << 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>;

bool is_integer(double x) { return floor(x) == x; }

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

  int A = 0;
  int minus = 1;
  double B;
  while (true) {
    minus = 1;
    int A_sub = pow(A, 5);
    double B_sub = A_sub - X;
    if (B_sub < 0) {
      minus = -1;
      B_sub = -B_sub;
    }
    B = pow(B_sub, (1.0 / 5.0));
    if (is_integer(B))
      break;
    A++;
  }

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

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

int main() {
  int64_t X;
  cin >> X;
  bool finished = true;
  for (int64_t i = 0; i < 120; i++) {
    for (int64_t j = 0; j < 120; j++) {
      if (pow(i, 5) + pow(j, 5) == X) {
        cout << i << " -" << j;
        finished = false;
        break;
      } else if (pow(i, 5) - pow(j, 5) == X) {
        cout << i << " " << j;
        finished = false;
        break;
      }
    }
    if (finished == false)
      break;
  }
}


Error: TLE

Fixed submission:

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

int main() {
  int64_t X;
  cin >> X;
  bool finished = true;
  for (int64_t i = 0; i < 10000; i++) {
    for (int64_t j = i; j < 10000; j++) {
      if (pow(i, 5) + pow(j, 5) == X) {
        cout << i << " -" << j;
        finished = false;
        break;
      } else if (pow(i, 5) - pow(j, 5) == X) {
        cout << i << " " << j;
        finished = false;
        break;
      }
    }
    if (finished == false)
      break;
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long x;
  cin >> x;
  long long a, b;
  for (a = -1000; a <= 1000; a++) {
    for (b = 1000; b >= -1000; b--) {
      if (pow(a, 5) - pow(b, 5) == x) {
        cout << a << " " << b;
        return 0;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long x;
  cin >> x;
  int a = 0, b = 0;
  long long a_s = 0, b_s = 0;
  for (; a_s <= x; a++) {
    a_s = pow(a, 5);
  }
  a = a - 2;
  a_s = pow(a, 5);
  for (; a_s - b_s != x; b--) {
    b_s = pow(b, 5);
  }
  b_s = pow(b, 5);
  if (a_s - b_s < x) {
    cout << a << " " << b - 1;
  } else if (a_s - b_s == x) {
    cout << a << " " << b;
  } else {
    cout << a << " " << b + 1;
  }
  return 0;
}