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

#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)

using namespace std;
using ll = long long;

int main() {

  ll X;
  cin >> X;

  int num = 10000;
  ll table[num];

  for (int i = 0; i < num; i++) {
    table[i] = pow(i, 5);
  }

  ll ans_a = 0;
  ll ans_b = 0;
  for (int a = 0; a < num; a++) {
    int hugou = 0;
    ll nokori = X - table[a];
    if (nokori > 0)
      hugou = -1;
    else
      hugou = 1;

    for (int b = 0; b < num; b++) {
      if (table[a] - hugou * table[b] == X) {
        ans_a = a;
        ans_b = hugou * b;
        cout << ans_a << " " << ans_b << endl;
        return 0;
      } else if (table[b] > abs(nokori)) {
        break;
      }
    }
  }

  return 0;
}


Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)

using namespace std;
using ll = long long;

int main() {

  int X;
  cin >> X;

  ll table[101];

  rep(i, 1000) { table[i] = pow(i, 5); }

  ll ans_a = 0;
  ll ans_b = 0;
  rep(a, 1000) {
    int hugou = 0;
    if ((X - table[a]) > 0)
      hugou = -1;
    else
      hugou = 1;
    rep(b, 1000) {
      if (table[a] - hugou * table[b] == X) {
        ans_a = a;
        ans_b = hugou * b;
        cout << ans_a << " " << ans_b << endl;
        return 0;
      } else if (table[a] - hugou * table[b] > X) {
        break;
      }
    }
  }

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

#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
  ll x;
  cin >> x;
  ll a, b, c = 0;
  for (a = -120; a < 120; a++) {
    for (b = -120; b < 120; b++) {
      if (pow(b, 5) - pow(a, 5) == x) {
        cout << b << " " << a << endl;
        c = 1;
        break;
      }
    }
    if (c == 1)
      break;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
  ll x;
  cin >> x;
  ll a = 0, b, c = 1;
  while (1) {
    for (b = -1; b < a; b++) {
      if (pow(a, 5) - pow(b, 5) == x) {
        c = 0;
        break;
      }
    }
    if (c == 1)
      a++;
    else
      break;
  }
  cout << a << " " << b << endl;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int x;
  cin >> x;
  for (int a = -118; a <= 119; a++) {
    for (int b = -119; b <= 118; b++) {
      if (a * a * a * a * a - b * b * b * b * b == x) {
        cout << a << " " << b << endl;
        exit(0);
      }
    }
  }
}


Error: TLE

Fixed submission:

#include <iostream>
#include <map>
#include <unordered_map>
using namespace std;

int main() {
  map<long long int, long long int> forward_hash_1;
  unordered_map<long long int, long long int> reverse_hash_1;

  long long int fifth, difff;

  for (long long int i = 0; i <= 64; i++) {
    fifth = i * i * i * i * i;
    forward_hash_1[i] = fifth;
    reverse_hash_1[fifth] = i;
  }

  long long int x;
  cin >> x;

  for (long long int i = 0; i <= 64; i++) {
    difff = x - forward_hash_1[i];
    if (reverse_hash_1.find(difff) != reverse_hash_1.end()) {
      cout << i << " " << (-reverse_hash_1[difff]) << endl;
      exit(0);
    }
  }

  map<long long int, long long int> forward_hash_2;
  unordered_map<long long int, long long int> reverse_hash_2;

  for (long long int i = 0; i <= 63; i++) {
    fifth = i * i * i * i * i;
    forward_hash_2[i] = fifth;
    reverse_hash_2[fifth] = i;
  }

  for (long long int i = 64;; i++) {
    fifth = i * i * i * i * i;
    forward_hash_2[i] = fifth;
    reverse_hash_2[fifth] = i;

    difff = fifth - x;
    if (reverse_hash_2.find(difff) != reverse_hash_2.end()) {
      cout << i << " " << reverse_hash_2[difff] << endl;
      exit(0);
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

void solve() {
  ll x;
  cin >> x;

  for (ll i = 1; i < 3982; i++) {
    ll k = pow(i, 5);
    for (ll j = -3981; j < 3982; j++) {
      ll e = pow(j, 5);
      if (k - e == x) {
        cout << i << " " << j;
        return;
      }
    }
  }
}

int main() {
  ll t = 1;
  // cin>>t;
  while (t--) {
    solve();
  }
}

Error: TLE

Fixed submission:

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

void solve() {
  ll x;
  cin >> x;
  double a = log2(x) / 5;
  ll k;
  ll i;
  // cout<<a<<endl;
  if (a - floor(a) > 0.5) {
    i = 1;
    k = pow(2.0, a) + 1;
  } else {
    i = -1;
    k = pow(2.0, a);
  }
  ll b = 0;
  // cout<<k<<" "<<i<<endl;
  while (1) {
    if (pow(k, 5) - pow(b, 5) == x) {
      cout << k << " " << b;
      break;
    }
    b += i;
  }
}

int main() {
  ll t = 1;
  // cin>>t;
  while (t--) {
    solve();
  }
}
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 < (int)(n); i++)

int main() {
  int X;
  cin >> X;
  bool flag = false;
  for (ll A = -1000; A <= 1000; A++) {
    for (ll B = -1000; B <= 1000; B++) {
      if (X == A * A * A * A * A - B * B * B * B * B) {
        cout << A << " " << B << endl;
        flag = true;
        break;
      }
    }
    if (flag) {
      break;
    }
  }
}

Error: TLE

Fixed submission:

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

int func(int n) { return (int)(pow(n, 5) - pow(n - 1, 5)); }
int main() {
  int X;
  cin >> X;
  int n = 0;
  while (X != func(n) || X > func(n)) {
    n--;
  }
  cout << n << " " << n - 1 << endl;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  double x;
  cin >> x;
  long long max_x = pow(x * 2, 0.20) + 1;
  long long i = max_x;
  while (true) {
    long long a = (long long)pow(i, 5);
    long long c = x - a;
    long long b = pow((double)c, 0.2);
    int bi = (int)b;
    if (pow(b, 5) + a == x) {
      cout << i << " " << -bi << endl;
      break;
    }
    i--;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x;
  cin >> x;
  int x_5;
  x_5 = pow(x, 0.2) + 1;

  for (long long i = x; i > 0; i--) {
    long long b = pow(pow(x - pow(i, 5), 0.2), 5);
    long long a = (long long)pow(i, 5);
    if (b + a == x) {
      cout << i << " " << -(long long)pow(b, 0.2) << endl;
      break;
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  long long N;
  cin >> N;
  int ans1 = 0;
  int ans2 = 0;
  for (int i = 0; i < 5000000; i++) {
    for (int j = i - 1; (i * i * i * i * i) - (j * j * j * j * j) > 0; j--) {
      long long num = (i * i * i * i * i) - (j * j * j * j * j);
      if (num == N) {
        ans1 = i;
        ans2 = j;
        break;
      }
    }
  }
  cout << ans1 << " " << ans2 << endl;
}


Error: TLE

Fixed submission:

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

int main() {
  long long N;
  cin >> N;
  int ans1 = 0;
  int ans2 = 0;
  for (int i = 0; i < 1000000000; i++) {
    for (int j = i - 1; (i * i * i * i * i) - (j * j * j * j * j) > 0; j--) {
      long long num = (i * i * i * i * i) - (j * j * j * j * j);
      if (num == N) {
        ans1 = i;
        ans2 = j;
        break;
      }
    }
  }
  cout << ans1 << " " << ans2 << endl;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array) (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < n; i++)
#define rev(i, n) for (int i = n - 1; i >= 0; i--)
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1) {
  unsigned day;
  if (dow < dow1)
    dow += 7;
  day = dow - dow1;
  day += 7 * n - 6;
  return day;
}
unsigned DayToWeekNumber(unsigned day) { return (day - 1) / 7 + 1; }
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0) {
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
  int x;
  cin >> x;
  for (int i = -2000; i < 2000; i++) {
    for (int j = -2000; j < 2000; j++) {
      if (pow(i, 5) - pow(j, 5) == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array) (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < n; i++)
#define rev(i, n) for (int i = n - 1; i >= 0; i--)
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1) {
  unsigned day;
  if (dow < dow1)
    dow += 7;
  day = dow - dow1;
  day += 7 * n - 6;
  return day;
}
unsigned DayToWeekNumber(unsigned day) { return (day - 1) / 7 + 1; }
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0) {
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
  int x;
  cin >> x;
  for (int i = -10000; i < 10000; i++) {
    for (int j = -10000; j < 10000; j++) {
      if (pow(i, 5) - pow(j, 5) == x)
        cout << i << " " << j << endl;
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)
#define pow10(n) int(1e##n + n)

#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef pair<int, int> P;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;

void solve() {
  LL X;
  cin >> X;
  FOR(A, -1000, 1000) {
    FOR(B, -1000, 1000) {
      LL A2 = A * A;
      LL B2 = B * B;
      if (X == A2 * A2 * A - B2 * B2 * B) {
        std::cout << A << " " << B << endl;
        return;
      }
    }
  }
}

int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  solve();
  return 0;
}


Error: TLE

Fixed submission:

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

#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)
#define pow10(n) int(1e##n + n)

#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef pair<int, int> P;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;

void solve() {
  LL X;
  cin >> X;
  FOR(A, -5000, 5000) {
    FOR(B, -5000, 5000) {
      LL A2 = A * A;
      LL B2 = B * B;
      if (X == A2 * A2 * A - B2 * B2 * B) {
        std::cout << A << " " << B << endl;
        return;
      }
    }
  }
}

int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  solve();
  return 0;
}
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 < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for (int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) ((v).begin(), (v).end())
using ll = long long;
using P = pair<int, int>;
/* ------------------------------------------------ */
ll fact(int i) { // 階乗
  if (i == 0)
    return 1;
  return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) { // 最大公約数
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) { // 最小公倍数
  return a * b / gcd(a, b);
}
int keta(ll n) { // 桁数を求める
  if (n == 0)
    return 1;
  int count = 0;
  while (n != 0) {
    n /= 10;
    count++;
  }
  return count;
}
ll ketasum(ll n) { // 各桁の和
  ll sum = 0;
  while (n != 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
/* ------------------------------------------------ */

int main() {
  ll x;
  cin >> x;
  for (int i = -1000; i <= 1000; i++) {
    for (int j = -1000; j <= 000; 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;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for (int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) ((v).begin(), (v).end())
using ll = long long;
using P = pair<int, int>;
/* ------------------------------------------------ */
ll fact(int i) { // 階乗
  if (i == 0)
    return 1;
  return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) { // 最大公約数
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) { // 最小公倍数
  return a * b / gcd(a, b);
}
int keta(ll n) { // 桁数を求める
  if (n == 0)
    return 1;
  int count = 0;
  while (n != 0) {
    n /= 10;
    count++;
  }
  return count;
}
ll ketasum(ll n) { // 各桁の和
  ll sum = 0;
  while (n != 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
/* ------------------------------------------------ */

int main() {
  ll x;
  cin >> x;
  for (int i = -5000; i <= 5000; i++) {
    for (int j = -5000; j <= 5000; j++) {
      if (pow(i, 5) - pow(j, 5) == x) {
        cout << i << ' ' << j << endl;
        return 0;
      }
    }
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
ll a[215];
ll b[215];
int main() {
  ll x, t, t1, t2 = 0, i, j;
  cin >> x;
  for (i = -1000; i <= 1000; i++) {
    for (j = i + 1; j <= 1000; j++) {
      if (j * j * j * j * j - i * i * i * i * i == x) {
        t2 = 1;
        cout << j << " " << i << endl;
      }
    }
    if (t2 == 1)
      break;
  }
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
ll a[100];
int main() {
  ll x, t, t1, t2 = 0;
  cin >> x;
  memset(a, 0, sizeof(a));
  for (int i = 0; i <= 100; i++)
    a[i] = i * i * i * i * i;
  for (int i = 0; i <= 100; i++) {
    t = pow(x - a[i], 0.2);
    if (pow(t, 5) == x - a[i]) {
      t2 = 1;
      cout << t << " " << -i << endl;
      break;
    }
  }
  if (t2 == 1)
    return 0;
  for (int i = 0; i <= 70; i++) {
    t = pow(a[i] + x, 0.2);
    if (pow(t, 5) == a[i] + x) {
      t2 = 1;
      cout << t << " " << i << endl;
      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 a = -200; a < 200; a++) {
    for (int b = -200; b < 200; b++) {
      if (pow(a, 5) - pow(b, 5) == X) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
}

Error: TLE

Fixed submission:

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

int main() {
  int X;
  cin >> X;
  int x = 0;
  int y = -1;
  while (true) {
    if (pow(x, 5) - pow(y, 5) == X) {
      cout << x << " " << y << endl;
      break;
    }
    x++;
  }
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define PREP(i, s, x) for (ll i = (s); i < (x); i++)
#define MREP(i, s, x) for (ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template <typename T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

constexpr ll INF = (1ll << 60);
constexpr ll MOD = 1000000007ll;

// べき乗を計算　指数を計算
ll llpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;
}

ll f(ll a) { return a * a * a * a * a; }

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

  PREP(a, -3982, 3983) {
    PREP(b, -3982, 3983) {
      if (x == f(a) - f(b)) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  return -1;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define PREP(i, s, x) for (ll i = (s); i < (x); i++)
#define MREP(i, s, x) for (ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template <typename T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

constexpr ll INF = (1ll << 60);
constexpr ll MOD = 1000000007ll;

// べき乗を計算　指数を計算
ll llpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;
}

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

  PREP(a, 0, 3983) {
    PREP(b, -3982, 3983) {
      if (x == llpow(a, 5) - llpow(b, 5)) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  return -1;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, t, c;
  cin >> x;
  t = x;
  c = 0;
  c = 1000;
  for (int i = c; i >= -c; i--) {
    for (int j = c; j >= -c; j--) {
      int u = pow(i, 5) - pow(j, 5);
      if (u == x) {
        cout << i << " " << j;
        return 0;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, t, c;
  cin >> x;
  t = x;
  c = 0;
  c = 10000;
  for (int i = c; i >= -c; i--) {
    for (int j = c; j >= -c; j--) {
      int u = pow(i, 5) - pow(j, 5);
      if (u == x) {
        cout << i << " " << j;
        return 0;
      }
    }
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {

  ios::sync_with_stdio(0);
  cin.tie(0);

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  int x;
  cin >> x;

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

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {

  ios::sync_with_stdio(0);
  cin.tie(0);

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  int x;
  cin >> x;

  long long int a, b, a1, b1;
  a = 1;
  a1 = 75;
  int ch = 0;
  while (1) {
    long long int dif = pow(a, 5) - x;
    long long int dif1 = pow(a1, 5) - x;

    if (dif == 0) {
      b = 0;
      ch = 1;
      break;
    }

    else if (dif < 0) {
      long long int j = -1;
      while (pow(j, 5) > dif) {
        j--;
      }
      if (pow(j, 5) == dif) {
        b = j;
        ch = 1;
        break;
      }
    }

    else {
      long long int j = 1;
      while (pow(j, 5) < dif) {
        j++;
      }
      if (pow(j, 5) == dif) {
        b = j;
        ch = 1;
        break;
      }
    }

    if (dif1 == 0) {
      b1 = 0;
      ch = -1;
      break;
    }

    else if (dif1 < 0) {
      long long int j = -1;
      while (pow(j, 5) > dif) {
        j--;
      }
      if (pow(j, 5) == dif) {
        b1 = j;
        ch = -1;
        break;
      }
    }

    else {
      long long int j = 1;
      while (pow(j, 5) < dif1) {
        j++;
      }
      if (pow(j, 5) == dif) {
        b1 = j;
        ch = -1;
        break;
      }
    }
  }
  if (ch == 1)
    cout << a << " " << b;

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  map<int, pair<int, int>> check;
  for (int i = -1000; i <= 1000; i++) {
    for (int j = -1000; j <= 1000; j++) {
      check[pow(i, 5) - pow(j, 5)] = make_pair(i, j);
    }
  }
  int x;
  cin >> x;
  cout << check[x].first << ' ' << check[x].second;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  map<int, pair<int, int>> check;
  for (int i = -10000; i < 10000; i++) {
    for (int j = -10000; j < 10000; j++) {
      check[pow(i, 5) - pow(j, 5)] = make_pair(i, j);
    }
  }
  int x;
  cin >> x;
  cout << check[x].first << ' ' << check[x].second;
}