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

#include <bits/stdc++.h>
using namespace std;
#define INFTY 1 << 20
typedef long long int ll;
const int MOD = 1000000007;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (n); ++i)

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
  ll x;
  cin >> x;
  for (int i = -120; i < 120; i++) {
    for (int j = -120; j < 120; j++) {
      if (pow(i, 5) - pow(j, 5) == x) {
        printf("%d %d", i, j);
        return 0;
      }
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define INFTY 1 << 20
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD = 1000000007;
vector<ll> enumDivisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= abs(n); ++i) {
    if (n % i != 0)
      continue;
    res.push_back(i);
    res.push_back(-i);
    if (i * i != n) {
      res.push_back(n / i);
      res.push_back(-n / i);
    }
  }
  return res;
}
int main() {
  ll x;
  cin >> x;
  vector<ll> num;
  num = enumDivisor(x);
  ll sz = num.size();
  // rep(i,sz)cout<<num[i];
  for (int i = 0; i < sz; i++) {
    ll d, e;
    d = num[i];
    e = x / d;
    for (ll i = -x; i <= x; i++) {
      ll b = i, a = i + d;
      if (pow(a, 5) - pow(b, 5) == x) {
        printf("%d %d", a, b);
        return 0;
      }
    }
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

// by The_One_Solver
#include <bits/stdc++.h>
using namespace std;
long long n, l, p, c, z;
bool a;
int main() {
  set<long long> st;
  set<long long>::iterator it;
  cin >> n;

  for (long long i = -120; i <= 120; i++) {
    for (long long j = -120; j <= 120; j++) {
      c = (i * i * i * i * i);
      p = (j * j * j * j * j);
      if (c - p == n)
        return cout << i << " " << j, 0;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

// by The_One_Solver
#include <bits/stdc++.h>
using namespace std;
long long n, l, p, c, z;
bool a;
int main() {
  set<long long> st;
  set<long long>::iterator it;
  cin >> n;
  if (n == 1)
    return cout << 0 << " " << -1, 0;
  for (int i = 0; i <= 5000; i++) {

    for (int k = 0; k < 2; k++) {
      if (k == 0)
        c = n + pow(i, 5);
      if (k == 1)
        c = n - pow(i, 5);
      p = c;
      st.clear();
      for (long long d = 2; d * d <= p; d++) {
        if (p % d == 0 && d * d != p) {
          st.insert(d);
          st.insert(p / d);
        }
        if (d * d == p)
          st.insert(d);
      }
      if (p > 1)
        st.insert(c);
      for (it = st.begin(); it != st.end(); it++) {

        if (pow(*it, 5) - pow(i, 5) == n) {
          if (k == 0)
            cout << *it << " " << i;
          else
            cout << *it << " " << -i;
          a = 1;
        }
        if (a)
          break;
      }
      if (a)
        break;
    }
    if (a)
      break;
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second
#define sf scanf

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

const int N = (int)1e5;
const int INF = (int)1e9 + 7;

int main(int argc, char *argv[]) {
  // ios_base::sync_with_stdio(false);
  // cin.tie(NULL);

  ll x;
  sf("%lld", &x);
  for (ll i = -1000; i <= 1000; ++i) {
    for (ll j = -1000; j <= 1000; ++j) {
      if (pow(i, 5) - pow(j, 5) == x) {
        printf("%lld %lld", i, j);
        return 0;
      }
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second
#define sf scanf

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

const int N = (int)1e5;
const int INF = (int)1e9 + 7;

ll f(ll x, ll y) {
  ll ans = 1;
  while (y--) {
    ans *= x;
  }
  return ans;
}

int main(int argc, char *argv[]) {
  // ios_base::sync_with_stdio(false);
  // cin.tie(NULL);

  int x;
  sf("%d", &x);
  ll a = 0, b = -1;
  while (f(a, 5) + 1 < x) {
    ++a;
  }

  if (f(a, 5) + 1 == x) {
    printf("%lld -1", a);
  } else {
    while (f(a, 5) - f(b, 5) != x) {
      ++b;
    }
    printf("%lld %lld", a, b);
  }

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

#include <cmath>
#include <iostream>
#include <map>
#include <vector>

using namespace std;
typedef long long int ll;

ll X;

int main() {

  ll A, A5, B, B5;
  long double x, y;

  cin >> X;

  y = 0.2;
  /*
  A = pow(X, y)+0.5;
  if (A*A*A*A*A == X) {
    printf("%lld 0\\n", A);
    return 0;
  }
  for (B=1; ;B++) {
    B5 = (B*B*B*B*B);
    x = X+B5;
    A = pow(x, y)+0.5;
    if (A*A*A*A*A - B5 == X) break;
    x = X-B5;
    if (A*A*A*A*A + B5 == X) {
      B = -B;
      break;
    }
  }
    */

  for (A = -119; A <= 118; A++) {
    A5 = A * A * A * A * A;
    for (B = -119; B <= 118; B++) {
      B5 = B * B * B * B * B;
      // printf("%lld-%lld=%lld X=%lld\\n", A5, B5, A5-B5, X);
      if (A5 - B5 == X) {
        printf("%lld %lld\\n", A, B);
        return 0;
      }
    }
  }
  /*
  for (A= -119; A<=118; A++) {
    A5= A*A*A*A*A;
printf("A=%lld A^5=%lld\\n", A, A5);
    B5 = A5-X;
    if (B5<0) {
      B = pow((long double)B5, y)-0.5;
    } else {
      B = pow((long double)B5, y)+0.5;
    }
printf("B=%lld B^5=%lld", B, B5);
    B5 = B*B*B*B*B;
printf("(%lld)\\n", B5);
    if (A5 - B5 == X) break;
  }
*/

  return 0;
}


Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
#include <map>
#include <vector>

using namespace std;
typedef unsigned long long int ll;

ll X;

int main() {

  ll A, B, B5;
  long double x, y;

  cin >> X;

  y = 0.2;
  A = pow(X, y) + 0.5;
  if (A * A * A * A * A == X) {
    printf("%lld 0\\n", A);
    return 0;
  }
  for (B = 1;; B++) {
    B5 = (B * B * B * B * B);
    x = X + B5;
    A = pow(x, y) + 0.5;
    if (A * A * A * A * A - B5 == X)
      break;
    x = X - B5;
    if (A * A * A * A * A + B5 == X) {
      B = -B;
      break;
    }
  }

  printf("%lld %lld\\n", A, B);

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

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

typedef long long int LLI;
LLI power[3982];

LLI POW5(LLI a) { return a * a * a * a * a; }

void precompute() {
  for (LLI i = 0; i < 3982; ++i)
    power[i] = POW5(i);
  return;
}

void solve() {
  LLI X;
  cin >> X;
  for (LLI A = 0; A <= 3981; ++A) {
    for (LLI B = 0; B <= 3981; ++B) {
      if (power[A] - power[B] == X) {
        cout << A << " " << B;
        return;
      } else if (power[A] + power[B] == X) {
        cout << A << " -" << B;
        return;
      }
    }
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  precompute();
  solve();
  return 0;
}

Error: WA

Fixed submission:

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

typedef long long int LLI;
LLI power[65];

LLI POW5(LLI a) { return a * a * a * a * a; }

void precompute() {
  for (LLI i = 0; i < 65; ++i)
    power[i] = POW5(i);
  return;
}

void solve() {
  LLI X;
  cin >> X;
  for (LLI A = 0; A <= 65; ++A) {
    for (LLI B = 0; B <= 65; ++B) {
      if (power[A] - power[B] == X) {
        cout << A << " " << B;
        return;
      } else if (power[A] + power[B] == X) {
        cout << A << " -" << B;
        return;
      }
    }
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  precompute();
  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 < n; ++i)
#define all(x) (x).begin(), (x).end()

using ll = long long;
using P = pair<int, int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  ll x;
  cin >> x;

  ll f, d;
  for (ll i = 0; i * i * i * i * i <= x * x; ++i) {
    for (ll j = 0; j * j * j * j * j <= x * x; ++j) {
      f = i * i * i * i * i;
      d = j * j * j * j * j;
      if (f + d == x) {
        cout << i << " " << -j << "\\n";
        return 0;
      }
      if (f - d == x) {
        cout << i << " " << j << "\\n";
        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 all(x) (x).begin(), (x).end()

using ll = long long;
using P = pair<int, int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  ll x;
  cin >> x;

  ll f, d;
  for (ll i = 0; i <= x; ++i) {
    for (ll j = -x; j <= x; ++j) {
      f = i * i * i * i * i;
      d = j * j * j * j * j;
      if (f - d == x) {
        cout << i << " " << j << "\\n";
        return 0;
      }
    }
  }

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

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

int main() {
  long long x;
  cin >> x;
  long long mi, mi2;
  for (int i = 1; i < 40000; i++) {
    if (x % i == 0) {
      long long y = x / i;
      long long start = sqrt(sqrt(y));
      for (long long j = start; j > 0; j--) {
        mi = j - i;
        mi2 = mi * mi;
        if (j * j * j * j + j * j * j * mi + j * j * mi2 + j * mi * mi2 +
                mi2 * mi2 ==
            y) {
          printf("%lld %lld\\n", j, mi);
          return 0;
        }
      }
    }
  }
}

Error: TLE

Fixed submission:

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

int main() {
  long long x;
  cin >> x;
  long long mi, mi2;
  for (int i = 1; i < 40000; i++) {
    if (x % i == 0) {
      long long y = x / i;
      for (long long j = 0; j < y; j++) {
        mi = j - i;
        mi2 = mi * mi;
        if (j * j * j * j + j * j * j * mi + j * j * mi2 + j * mi * mi2 +
                mi2 * mi2 ==
            y) {
          printf("%lld %lld\\n", j, mi);
          return 0;
        }
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define M 998244353
#define fi first
#define se second
#define endl '\\n'
#define INF 1e18
#define PI 3.14159265358979323846
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);

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

  vector<ll> v;
  ll i;
  map<ll, ll> m;
  map<ll, ll> mp;
  for (i = -100000; i <= 100000; i++) {
    ll x = i * i * i * i * i;
    mp[x]++;
    v.pb(x);
    m[x] = i;
  }
  ll a1, a2;
  if (x == 1) {
    cout << "0"
         << " "
         << "-1" << endl;
    exit(0);
  }

  for (i = 0; i < v.size(); i++) {
    ll p = v[i] - x;

    if (mp.find(p) != mp.end()) {
      a1 = m[v[i]];
      a2 = m[p];
      break;
    }
  }

  cout << a1 << " " << a2 << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define M 998244353
#define fi first
#define se second
#define endl '\\n'
#define INF 1e18
#define PI 3.14159265358979323846
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);

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

  vector<ll> v;
  ll i;
  map<ll, ll> m;
  map<ll, ll> mp;
  for (i = -1000000; i <= 1000000; i++) {
    ll x = i * i * i * i * i;
    mp[x]++;
    v.pb(x);
    m[x] = i;
  }
  ll a1, a2;
  if (x == 1) {
    cout << "0"
         << " "
         << "-1" << endl;
    exit(0);
  }

  for (i = 0; i < v.size(); i++) {
    ll p = v[i] - x;

    if (mp.find(p) != mp.end()) {
      a1 = m[v[i]];
      a2 = m[p];
      break;
    }
  }

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

#include <bits/stdc++.h>
using namespace std;
const long long c = 1e18;
long long X;
long long f(long long a, long long b) {
  long long powa = pow(a, 5);
  long long powb = pow(b, 5);
  return powa - powb;
}
int main() {
  cin >> X;
  long long i = 0;
  while (i <= 178) {
    long long j = -64;
    while (j <= 178) {
      long long tmp = f(i, j);
      if (tmp == X) {
        cout << i << " " << j << '\\n';
        return 0;
      }
      j++;
    }
    i++;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const long long c = 1e18;
long long X;
long long f(long long a, long long b) {
  long long powa = pow(a, 5);
  long long powb = pow(b, 5);
  return powa - powb;
}
int main() {
  cin >> X;
  long long i = 0;
  while (i <= 178) {
    long long j = -64;
    while (j <= 178) {
      long long tmp = f(i, j);
      if (tmp == X) {
        cout << i << " " << tmp << '\\n';
        return 0;
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  ll x;
  cin >> x;
  ll a, b = 0, c, d, e, f;

  while (1) {
    e = pow(b, 5);
    c = x + e;
    d = x - e;
    a = pow(c, 0.20);
    f = pow(a, 5);
    if (f == c) {
      cout << a << " " << b;
      return 0;
    }
    a = pow(d, 0.20);
    f = pow(a, 5);
    if (f == d) {
      cout << a << " " << b * -1;
      return 0;
    }
    b++;
    // cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
  }
}


Error: TLE

Fixed submission:

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

int main() {
  ll x;
  cin >> x;
  ll a, b = 0, c, d;

  while (1) {
    c = x + pow(b, 5);
    d = x - pow(b, 5);
    a = pow(c, 1 / 5);
    if (a == c) {
      cout << a << " " << b;
      return 0;
    }
    if (a == d) {
      cout << a << " " << b * -1;
      return 0;
    }
    b++;
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  ll x;
  cin >> x;
  ll judge = 0;
  for (ll i = -1000; i < 1000; i++) {
    for (ll j = -1000; j < 1000; j++) {
      ll i5 = pow(i, 5);
      ll j5 = pow(j, 5);
      if (i5 - j5 == x) {
        cout << i << " " << j << endl;
        judge = 1;
        break;
      }
    }
    if (judge == 1) {
      break;
    }
  }
}

Error: TLE

Fixed submission:

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

int main() {
  ll x;
  cin >> x;
  ll judge = 0;
  for (ll i = -10000; i < 10000; i++) {
    for (ll j = -10000; j < 10000; j++) {
      ll i5 = pow(i, 5);
      ll j5 = pow(j, 5);
      if (i5 - j5 == x) {
        cout << i << " " << j << endl;
        judge = 1;
        break;
      }
    }
    if (judge == 1) {
      break;
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

void solve(long long X) {
  for (long long a = -1000; a <= 1000; a++) {
    long long pow_a = pow(a, 5);

    for (long long b = -1000; b <= 1000; b++) {
      if (pow_a - pow(b, 5) == X) {
        cout << a << " " << b << endl;
        return;
      }
    }
  }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips:
// You use the default template now. You can remove this line by using your
// custom template)
int main() {
  long long X;
  scanf("%lld", &X);
  solve(X);
  return 0;
}


Error: TLE

Fixed submission:

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

void solve(long long X) {
  for (long long a = -5000; a <= 5000; a++) {
    long long pow_a = pow(a, 5);

    for (long long b = -5000; b <= 5000; b++) {
      if (pow_a - pow(b, 5) == X) {
        cout << a << " " << b << endl;
        return;
      }
    }
  }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips:
// You use the default template now. You can remove this line by using your
// custom template)
int main() {
  long long X;
  scanf("%lld", &X);
  solve(X);
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout << n << "\\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;

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

  ll n;
  cin >> n;

  for (int i = -1000; i < 1000; i++) {
    for (int j = -1000; j < 1000; j++) {
      if (pow(i, 5) - pow(j, 5) == n) {

        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}


Error: TLE

Fixed submission:

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout << n << "\\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;

vector<ll> a;
vector<ll> b;

void calc() {

  for (int i = 1; i <= 1000; i++) {
    ll tmp = i;

    for (int j = 1; j < 5; j++) {
      tmp *= i;
    }

    a.push_back(tmp);
    a.push_back(tmp * -1);
    b.push_back(tmp);
    b.push_back(tmp * -1);
  }
}

ll back(ll p) {
  if (p == -1)
    return -1;
  if (p == 1)
    return 1;
  if (p == 0)
    return 0;
  for (ll i = 2; i <= 100; i++) {
    int ct = 0;
    ll tmp = p;

    while (tmp % i == 0) {
      ct++;
      tmp /= i;
    }
    if (ct == 5 && tmp == 1) {

      if (p < 0) {
        return i * -1;
      } else {
        return i;
      }
    }
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll n;
  cin >> n;
  calc();
  a.push_back(0);
  b.push_back(0);
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());

  for (int i = 0; i < a.size(); i++) {
    for (int j = 0; j < b.size(); j++) {
      if (a[i] - b[j] == n) {

        cout << back(a[i]) << " " << back(b[j]) << endl;
        return 0;
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int X;

signed main() {
  cin >> X;
  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) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}

Error: TLE

Fixed submission:

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

int X;

signed main() {
  cin >> X;
  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) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>      //abs()かfabs()で少数絶対値
#include <cstdlib>    //abs()で整数絶対値
#include <functional> //sort第三引数greater<型名>()で降順
#include <iomanip>    //cout<<setw(数字) で空白による桁揃え
#include <iostream>   //cout<<right で右揃え
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long int;

int main() {
  ll X;
  cin >> X;
  bool end = 0;
  for (int i = -200; i <= 200 && end != 1; i++) {
    for (int j = -200; j < i; j++) {
      if (pow(i, 5) - pow(j, 5) == X) {
        cout << i << " " << j << endl;
        end = 1;
        break;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>      //abs()かfabs()で少数絶対値
#include <cstdlib>    //abs()で整数絶対値
#include <functional> //sort第三引数greater<型名>()で降順
#include <iomanip>    //cout<<setw(数字) で空白による桁揃え
#include <iostream>   //cout<<right で右揃え
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long int;

int main() {
  ll X;
  cin >> X;
  bool end = 0;
  for (int i = -200; i <= 200 || end != 1; i++) {
    for (int j = -200; j < i; j++) {
      if (pow(i, 5) - pow(j, 5) == X) {
        cout << i << " " << j << endl;
        end = 1;
      }
      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() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  ll t = 1;
  // cin>>t;
  while (t--) {
    ll x;
    cin >> x;
    for (ll i = -200; i <= 200; i++) {
      for (ll j = -200; j <= 200; 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;
typedef long long ll;

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  ll t = 1;
  // cin>>t;
  while (t--) {
    ll x, a = 0, b = 0;
    cin >> x;
    if (x == 0) {
      cout << 0 << " " << 0;
      return 0;
    }
    for (int i = 0; i <= x; i++) {
      for (int j = 0; j <= x; j++) {
        if ((pow(i, 5) - pow(j, 5)) > x)
          break;
        else if ((pow(i, 5) - pow(j, 5)) == x) {
          a = i;
          b = j;
          break;
        }
      }
      if (a != 0 || b != 0) {
        break;
      }
    }
    if (a == 0 && b == 0) {
      for (int i = 0; i <= x; i++) {
        for (int j = 0; j >= -x; j--) {
          if ((pow(i, 5) - pow(j, 5)) == x) {
            a = i;
            b = j;
            break;
          }
        }
        if (a != 0 || b != 0) {
          break;
        }
      }
      cout << a << " " << b;
    } else
      cout << a << " " << b;
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <map>
using namespace std;
long long int fpow[150];

int main() {
  for (long long int i = 0LL; i < 150LL; i++) {
    fpow[i] = i * i * i * i * i;
  }
  long long int n;
  cin >> n;
  for (long long int i = 0; i < 150LL; i++) {
    for (long long int j = 0; j < 150LL; j++) {
      if (fpow[i] + fpow[j] == n) {
        cout << i << " " << -j << endl;
        return 0;
      } else if (fpow[i] - fpow[j] == n) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  cout << "Hoge" << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <map>
using namespace std;
long long int fpow[110];

int main() {
  for (long long int i = 0LL; i < 110LL; i++) {
    fpow[i] = i * i * i * i * i;
  }
  long long int n;
  cin >> n;
  for (long long int i = 0; i < 110LL; i++) {
    for (long long int j = 0; j < 110LL; j++) {
      if (fpow[i] + fpow[j] == n) {
        cout << i << " " << -j << endl;
        return 0;
      } else if (fpow[i] - fpow[j] == n) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  while (1) {
    int i = 0;
  }
}