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

#include <bits/stdc++.h>
using namespace std;
long long positivef[4005];
long long negativef[4005];

long long quickpow(long long a, long long b) {
  long long res = 1;
  while (b != 0) {
    if (b & 1) {
      res = res * a;
    }
    a = a * a;
    b >>= 1;
  }
  return res;
}

int main() {
  for (int i = 1; i <= 4000; i++) {
    positivef[i] = quickpow(i, 5);
  }
  for (int i = -4000; i <= -1; i++) {
    negativef[-i] = quickpow(i, 5);
    // cout<<negativef[-i]<<endl;
  }
  long long x;
  cin >> x;
  for (int i = -4000; i <= 4000; i++) {
    for (int j = -4000; j <= 4000; j++) {
      long long tr = 0;
      if (i < 0) {
        tr += negativef[-i];
      } else {
        tr += positivef[i];
      }
      if (j < 0) {
        tr -= negativef[-j];
      } else {
        tr -= positivef[j];
      }
      if (tr == x) {
        cout << i << ' ' << j << endl;
        return 0;
      }
    }
  }
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
long long positivef[65];
long long negativef[65];

long long quickpow(long long a, long long b) {
  long long res = 1;
  while (b != 0) {
    if (b & 1) {
      res = res * a;
    }
    a = a * a;
    b >>= 1;
  }
  return res;
}

int main() {
  for (int i = 1; i <= 65; i++) {
    positivef[i] = quickpow(i, 5);
  }
  for (int i = -65; i <= -1; i++) {
    negativef[-i] = quickpow(i, 5);
    // cout<<negativef[-i]<<endl;
  }
  long long x;
  cin >> x;
  for (int i = -65; i <= 65; i++) {
    for (int j = -65; j <= 65; j++) {
      long long tr = 0;
      if (i < 0) {
        tr += negativef[-i];
      } else {
        tr += positivef[i];
      }
      if (j < 0) {
        tr -= negativef[-j];
      } else {
        tr -= positivef[j];
      }
      if (tr == x) {
        cout << i << ' ' << j << endl;
        return 0;
      }
    }
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repc(i, a, b) for (int i = a; i <= (int)(b); i++)
#define ll long long
#define vec vector
#define ft first
#define sd second
#define all(vec) vec.begin(), vec.end()
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;

int main() {
  ll x;
  cin >> x;
  for (ll a = -200; a <= 200; a++)
    for (ll b = -200; b <= 200; b++) {
      if ((a - b) != 0 && x % (a - b) == 0) {
        if (a * a * a * a * a - b * b * b * b * b == x) {
          cout << a << " " << b << endl;
          return 0;
        }
      }
    }
  return 0;
}

Error: -8

Fixed submission:

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repc(i, a, b) for (int i = a; i <= (int)(b); i++)
#define ll long long
#define vec vector
#define ft first
#define sd second
#define all(vec) vec.begin(), vec.end()
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;

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

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

int main() {
  int64_t X, A, B;
  cin >> X;
  for (int64_t i = 0; i < 3000; i++) {
    for (int64_t j = 0; j < 1000; j++) {
      if (pow(i, 5) - pow(j, 5) == X) {
        cout << i << " " << j << endl;
        return 0;
      } else if (pow(i, 5) + pow(j, 5) == X) {
        cout << i << " " << -j << endl;
        return 0;
      } else if (-pow(i, 5) + pow(j, 5) == X) {
        cout << -i << " " << -j << endl;
        return 0;
      } else if (-pow(i, 5) - pow(j, 5) == X) {
        cout << -i << " " << j << endl;
        return 0;
      }
    }
  }
}


Error: TLE

Fixed submission:

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

int main() {
  int64_t X, A, B, C;
  cin >> X;
  for (int64_t i = pow(X, 0.2);; i++) {
    A = i;
    C = (int64_t)pow(A, 5) - X;
    if (C >= 0) {
      B = (int64_t)pow(C, 0.2);
      if (B == pow(C, 0.2)) {
        cout << A << " " << B << endl;
        break;
      }
    } else {
      B = -(int64_t)pow(-C, 0.2);
      if (B == -pow(-C, 0.2)) {
        cout << A << " " << B << endl;
        break;
      }
    }
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

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

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
  ll 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;
        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 < n; ++i)

vector<long long> enum_divisors(long long N) {
  vector<long long> res;
  for (long long i = 1; i * i <= N; ++i) {
    if (N % i == 0) {
      res.push_back(i);
      // 重複しないならば i の相方である N/i も push
      if (N / i != i)
        res.push_back(N / i);
    }
  }
  // 小さい順に並び替える
  sort(res.begin(), res.end());
  return res;
}

int main() {
  int N;
  cin >> N;
  const auto &res = enum_divisors(N);

  for (int i = 0; i < res.size(); ++i) {
    for (int a = 0; a < sqrt(N); ++a) {
      if (pow(a, 5) - pow(a - res[i], 5) == N) {
        cout << a << ' ' << a - res[i] << endl;
        return 0;
      }
      if (pow(a, 5) - pow(res[i] - a, 5) == N) {
        cout << a << ' ' << res[i] - a << 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)

vector<long long> enum_divisors(long long N) {
  vector<long long> res;
  for (long long i = 1; i * i <= N; ++i) {
    if (N % i == 0) {
      res.push_back(i);
      // 重複しないならば i の相方である N/i も push
      if (N / i != i)
        res.push_back(N / i);
    }
  }
  // 小さい順に並び替える
  sort(res.begin(), res.end());
  return res;
}

int main() {
  int N;
  cin >> N;
  const auto &res = enum_divisors(N);

  for (int i = 0; i < res.size(); ++i) {
    rep(a, N) {
      if (pow(a, 5) - pow(a - res[i], 5) == N) {
        cout << a << ' ' << a - res[i] << endl;
        return 0;
      }
      if (pow(a, 5) - pow(res[i] - a, 5) == N) {
        cout << a << ' ' << res[i] - a << endl;
        return 0;
      }
    }
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bitset>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = {0, 1, 0, -1};
const double PI = 3.14159265358979323846;

int main() {

  ll x;
  cin >> x;
  vector<ll> beki(201);
  rep(i, 201) { beki.at(i) = pow(i, 5); }
  ll a;
  ll b;
  bool c = false;
  rep(i, 201) {
    rep(j, 201) {
      a = beki.at(i);
      b = beki.at(j);
      if ((a - b) == x) {
        cout << i << ' ' << j << endl;
        c = true;
        break;
      } else if ((a + b) == x) {
        cout << i << ' ' << j * (-1) << endl;
        c = true;
        break;
      }
    }
    if (c == true) {
      break;
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = {0, 1, 0, -1};
const double PI = 3.14159265358979323846;

int main() {

  ll x;
  cin >> x;

  ll num = pow(x, 0.2);

  ll a = num;
  ll b_one = 0;
  ll b_two = 0;

  ll a_beki = pow(num, 5);
  ll a_beki_two = pow((num + 1), 5);

  while (1) {

    if (b_one < a) {
      a_beki = pow(a, 5);
      ll b_beki = pow(b_one, 5);
      ll ans = a_beki + b_beki;
      if (ans == x) {
        cout << a << ' ' << b_one * (-1) << endl;
        break;
      }
      b_one++;
    } else if (b_one == a) {
      a++;
      b_one = b_one + 2;
    } else if (b_one > a) {
      ll a_beki = pow(a, 5);
      ll b_beki = pow(b_two, 5);
      ll ans = a_beki - b_beki;
      if (ans == x) {
        cout << a << ' ' << b_two << endl;
        break;
      }
      b_two++;
    }
  }

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

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

#define ll long long
#define rep(i, N) for (ll i = 0; i < N; i++)
const int mx = 2e5;
const ll llmx = 2e18;

ll pow2(ll a, ll b) {
  ll ans = 1;
  for (ll i = 0; i < b; i++) {
    ans = ans * a;
  }
  return ans;
}

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

  ll test = 0, pre = 0, ans = 0;
  vector<ll> gojo;

  for (; abs(ans - pre) <= X; test++) {
    pre = ans;
    ans = pow2(test, 5);
    gojo.push_back(ans);
  }

  for (int i = 0; i < gojo.size(); i++) {
    // cout << i << " " << gojo[i] << "\\n";
    for (int j = i; j < gojo.size(); j++) {
      if (X == gojo[i] + gojo[j]) {
        cout << i << " -" << j;
        return 0;
      }
      if (X * -1 == gojo[i] + gojo[j]) {
        cout << "-" << i << " " << j;
      }
      if (X == gojo[i] - gojo[j]) {
        cout << i << " " << j;
      }
      if (X * -1 == gojo[i] - gojo[j]) {
        cout << "-" << i << " -" << j;
      }
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

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

#define ll long long
#define rep(i, N) for (ll i = 0; i < N; i++)
const int mx = 2e5;
const ll llmx = 2e18;

ll waru(ll a) { return a / a / a / a / a / a; }

ll pow2(ll a, ll b) {
  ll ans = 1;
  rep(i, b) ans *= a;
  return ans;
}

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

  ll gobai[mx];
  ll cnt = 0;
  for (ll i = 0; pow2(i, 5) < mx; i++) {
    gobai[i] = pow2(i, 5);
  }
  ll gapans;
  rep(i, mx) {
    ll gap = X - gobai[i];
    bool minus = false;
    if (gap < 0) {
      minus = true;
      gap *= -1;
    }
    // cout << pow(gap,1.0/5.0) << " " << gap << "\\n";
    for (ll j = pow(gap, 1.0 / 5.0); gobai[j] <= gap; j++) {
      // cout << "a " <<  i << " " << j << "\\n";
      if (gapans < (gap - gobai[j]))
        j = mx - 2;
      gapans = abs(gap - gobai[j]);
      if (gap == gobai[j]) {
        cout << i << " ";
        if (!minus)
          cout << -1 * j;
        if (minus)
          cout << j;
        return 0;
      }
    }
  }

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

#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define mod 1000000007
#define mp make_pair
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x;
  cin >> x;
  rep1(i, 1000) {
    for (ll j = -500; j <= 1000; j++) {
      if (x == pow(i, 5) - pow(j, 5)) {
        cout << i << " " << j;
        return 0;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define mod 1000000007
#define mp make_pair
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x;
  cin >> x;
  ll a = 1, b = 0;
  while (1) {
    if (a * a * a * a * a - b * b * b * b * b == x) {
      cout << a << " " << b;
      return 0;
    }
    if (a * a * a * a * a - b * b * b * b * b < x) {
      a++;
    }
    if (a * a * a * a * a - b * b * b * b * b > x) {
      break;
    }
  }
  while (1) {
    b--;
    ll y = b * b * b * b * b;
    if (a * a * a * a * a - y == x) {
      cout << a << " " << b;
      return 0;
    }
    if (a * a * a * a * a - b * b * b * b * b > x) {
      a--;
    }
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)n; i++) // n回繰り返す
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define REP(i, n) for (int i = 1; i <= (int)n; i++) // i=1からi=nまで
#define RREP(i, n) for (int i = n; i >= 1; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
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;
}

int main() {
  int X;
  cin >> X;
  rep(a, 200) {
    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 <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)n; i++) // n回繰り返す
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define REP(i, n) for (int i = 1; i <= (int)n; i++) // i=1からi=nまで
#define RREP(i, n) for (int i = n; i >= 1; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
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;
}

int main() {
  int X;
  cin >> X;
  map<int, int> n;
  rep(i, 101) { n[pow(i, 5)] = i; }
  int a = 0;
  while (true) {
    int A = pow(a, 5);
    if (A <= X) {
      if (n.count(X - A) != 0) {
        cout << a << " " << n[X - A] * -1 << endl;
        return 0;
      }
    } else {
      if (n.count(A - X) != 0) {
        cout << a << " " << n[A - X] << endl;
        return 0;
      }
    }
    a++;
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>

long factorial(long x, int n) {
  long ret = 1;
  for (int i = 0; i < n; i++) {
    ret *= x;
  }
  return ret;
}

int main() {
  // input
  int X;
  scanf("%d", &X);

  // process
  long min_int = -2147483648;
  long max_long = 9223372036854775807;
  double near_max_long = 9223300000000000000;
  std::vector<long> list_5fact, list_base;
  list_5fact.push_back(0);
  list_base.push_back(0);
  long max_index = std::pow(near_max_long, 0.2);
  for (long i = 1; i <= max_index; i++) {
    long num = factorial(i, 5);
    list_5fact.push_back(num);
    list_base.push_back(i);
    list_5fact.push_back(-num);
    list_base.push_back(-i);
  }
  int length = list_5fact.size();
  for (int i = 0; i < length; i++) {
    for (int j = 0; j < length; j++) {
      if (list_5fact[i] - list_5fact[j] == X) {
        printf("%ld %ld\\n", list_base[i], list_base[j]);
        return 0;
      }
    }
  }
  while (true) {
  }

  // output

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>

int factorial(int x, int n) {
  int ret = 1;
  for (int i = 0; i < n; i++) {
    ret *= x;
  }
  return ret;
}

int main() {
  // input
  int X;
  scanf("%d", &X);

  // process
  int min_int = -2147483648;
  int max_int = 2147483647;
  double near_int = 2150000000;
  std::vector<int> list_5fact, list_base;
  list_5fact.push_back(0);
  list_base.push_back(0);
  int max_index = std::pow(near_int, 0.2);
  for (int i = 1; i <= max_index; i++) {
    int num = std::pow(i, 5);
    list_5fact.push_back(num);
    list_base.push_back(i);
    list_5fact.push_back(-num);
    list_base.push_back(-i);
  }
  int length = list_5fact.size();
  for (int i = 0; i < length; i++) {
    for (int j = 0; j < length; j++) {
      if (list_5fact[i] - list_5fact[j] == X) {
        printf("%d %d\\n", list_base[i], list_base[j]);
        return 0;
      }
    }
  }
  while (true) {
  }

  // output

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

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

int main() {

  double X;
  cin >> X;

  int ansA;
  int ansB;
  double sum;

  for (int A = -118; A <= 119; A++) {
    for (int B = -118; B <= 119; B++) {
      sum = pow(A, 5) - pow(B, 5);
      if (sum == X) {
        ansA = A;
        ansB = B;
        break;
      }
    }
    if (sum == X)
      break;
  }

  cout << ansA << " " << ansB << endl;
}

Error: TLE

Fixed submission:

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

int main() {

  double X;
  cin >> X;

  long int B = 0;
  while (1) {
    double sumP = X + pow(B, 5);
    double sumN = X - pow(B, 5);

    double Ap = pow(sumP, -5);
    double An = pow(sumN, -5);

    if (Ap == int(Ap)) {
      cout << int(Ap) << " " << B << endl;
      break;
    } else if (An == int(An)) {
      cout << int(An) << " " << B * (-1) << endl;
      break;
    }

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

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

int main(int argc, char **argv) {
  int i;
  long long X;
  cin >> X;

  long A;
  long B;
  for (A = -500; A < 500; ++A) {
    for (B = -500; B < 500; ++B) {
      if ((pow(A, 5) - pow(B, 5)) == X)
        goto END;
    }
  }
END:

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


Error: TLE

Fixed submission:

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

int main(int argc, char **argv) {
  int i;
  long X;
  cin >> X;

  long A = 0;
  long A5 = 0;
  long B = 0;
  long B5 = 0;
  bool found = false;
  while (!found) {
    ++A;
    A5 = pow(A, 5);
    if (A5 < X) {
      for (B = 0; B5 > -X; --B) {
        B5 = pow(B, 5);
        if (A5 == (X + B5)) {
          found = true;
          break;
        }
      }
    } else {
      for (B = 0; B5 < X; ++B) {
        B5 = pow(B, 5);
        if (A5 == (X + B5)) {
          found = true;
          break;
        }
      }
    }
  }

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

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

using namespace std;

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

Error: TLE

Fixed submission:

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

using namespace std;

int main() {
  int x, num, numm;
  cin >> x;
  int a = 1, b = 1;
  while (true) {
    while (true) {
      num = pow(a, 5) - pow(b, 5);
      numm = pow(a, 5) + pow(b, 5);
      if (num == x) {
        cout << a << ' ' << b << endl;
        return 0;
      } else if (numm == x) {
        cout << a << ' ' << -b << endl;
        return 0;
      } else
        a++;
    }
    b++;
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define m0(x) memset(x, 0, sizeof(x))

int dx4[4] = {1, 0, -1, 0}, dy4[4] = {0, 1, 0, -1};

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

  for (ll l = 0; l < 1000; l++) {
    for (ll r = -1000; r < l; r++) {
      ll calc = pow(l, 5) - pow(r, 5);
      if (calc == x) {
        cout << l << " " << r << endl;
        return 0;
      }
    }
  }

  /*
  if(x==1)
  {
      cout<<"1 0"<<endl;
      return 0;
  }
  ll yaku=1;
  for (ll i = 2; i <= sqrt(x); i++)
  {
      if(x%i==0)
      {
          yaku=i;
          break;
      }
  }
  cout<<yaku<<endl;

  ll l=(ll)(pow(__LONG_LONG_MAX__-5,0.2));
  ll r=0;
  while (true)
  {
      ll mid=(l+r)/2;
      ll calc=(ll)(pow(mid,5)-pow(mid-yaku,5));

      cout<<l<<"\\t"<<r<<"\\t"<<mid<<"\\t"<<calc<<endl;//

      if(calc==x)
      {
          cout<<mid<<" "<<mid-yaku<<endl;
          break;
      }
      else if(calc>yaku)
      {
          l=mid;
      }
      else
      {
          r=mid;
      }

  }
  */
  return 0;
}

Error: TLE

Fixed submission:

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define m0(x) memset(x, 0, sizeof(x))

int dx4[4] = {1, 0, -1, 0}, dy4[4] = {0, 1, 0, -1};

int main() {
  ll x;
  cin >> x;
  if (x == 1) {
    cout << "1 0" << endl;
    return 0;
  }
  ll yaku;
  for (ll i = 2; i <= sqrt(x); i++) {
    if (x % i == 0) {
      yaku = i;
      break;
    }
  }

  ll l = (ll)(pow(__LONG_LONG_MAX__ - 5, 0.2));
  ll r = -1;
  while (true) {
    ll mid = (l + r) / 2;
    ll calc = (ll)(pow(mid, 5) - pow(mid - yaku, 5));
    if (calc == x) {
      cout << mid << " " << mid - yaku << endl;
      break;
    } else if (calc > yaku) {
      l = mid;
    } else {
      r = mid;
    }
    // cout<<l<<" "<<r<<" "<<calc<<endl;//
  }

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

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

int main() {
  long long X;
  cin >> X;
  for (int i = -1000; i < 1000; i++) {
    for (int j = -1000; j < i; j++) {
      if (i * i * i * i * i - j * j * j * j * j == X) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}


Error: -8

Fixed submission:

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

int main() {
  long long X;
  cin >> X;
  for (int i = -130; i < 130; i++) {
    for (int j = -130; j < i; j++) {
      if (i * i * i * i + j * i * i * i + i * i * j * j * +j * j * j * i +
              j * j * j * j ==
          X / i - j) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}