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

#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
  int X;
  cin >> X;
  for (int i = 0; i < 100; i++)
    for (int j = 0; j < 100; j++)
      if (i * i * i * i * i + j * j * j * j * j == X) {
        cout << i << ' ' << 0 - j << endl;
        return 0;
      }
  for (int i = 1;; i++) {
    for (int j = i; j >= 0; j--) {
      if (i * i * i * i * i - j * j * j * j * j == X) {
        cout << i << ' ' << j << endl;
        return 0;
      }
      if (i * i * i * i * i - j * j * j * j * j >= X)
        break;
    }
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
  int X;
  cin >> X;
  for (int i = 0; i < 100; i++)
    for (int j = 0; j < 100; j++)
      if (i * i * i * i * i + j * j * j * j * j == X) {
        cout << i << ' ' << 0 - j << endl;
        return 0;
      }
  for (int i = 1;; i++) {
    for (int j = 1; j >= 0; j--) {
      if (i * i * i * i * i - j * j * j * j * j == X) {
        cout << i << ' ' << j << endl;
        return 0;
      }
      if (i * i * i * i * i - j * j * j * j * j >= X)
        break;
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
int n, x, m, a, b, c, k;
int main() {
  for (cin >> x, a = -118; a < 120; a++) {
    ll a5 = pow(a, 5);
    for (b = -119; b < 119; b++) {
      ll b5 = pow(b, 5);
      if (a5 - b5 == x) {
        printf("%d %d", a, b);
        return 0;
      }
    }
  }
}

Error: 4

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
int n, x, m, a, b, c, k;
int main() {
  for (cin >> x, a = -118; a < 120; a++) {
    ll a5 = pow(a, 5);
    for (b = -119; b < 119; b++) {
      ll b5 = pow(b, 5);
      if (a5 - b5 == x)
        return printf("%d %d", a, b);
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error



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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define rep(i, a, n) for (int i = a; i < n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i / 3][i % 3]
int gcd(int x, int y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

long long numbers[500005];

int main() {

  ll x;
  cin >> x;

  for (ll i = -1000; i <= 1000; i++) {
    for (ll j = -1000; j <= 1000; j++) {
      if (i * i * i * i * i - j * j * j * j * j == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }

  return 0;
}

Error: WA

Fixed submission:


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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define rep(i, a, n) for (int i = a; i < n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i / 3][i % 3]
int gcd(int x, int y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

long long numbers[500005];

int main() {

  long long n, m;
  cin >> n >> m;
  vector<long long> v(n);
  map<long long, long long> mp;

  for (int i = 0; i < n; i++) {
    cin >> v[i];
    mp[v[i]]++;
  }

  for (int i = 0; i < n; i++) {
    if (mp[v[i]] > n / 2) {
      cout << v[i] << endl;
      return 0;
    }
  }

  cout << "?" << endl;

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

#include <bits/stdc++.h>

#define ll long long
#define pb push_back

using namespace std;

ll pow5(ll n) { return n * n * n * n * n; }

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

  ll n, i, j, a, b;

  cin >> n;

  for (i = -120; i <= 120; i++)
    for (j = -120; j <= 120; j++)
      if (pow5(i) - pow5(j) == n) {
        cout << i << " " << j << endl;
        return 0;
      }

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define ll long long
#define pb push_back

using namespace std;

ll pow5(ll n) { return n * n * n * n * n; }

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

  ll n, i, j, a, b, aa, bb, x;
  string s;

  cin >> x;

  a = aa = 1;
  i = 0;

  for (a = 0;; a++) {
    aa = pow5(a);
    if (aa > x) {
      a--;
      break;
    } else
      i = aa;
  }

  x -= i;

  bool flag = 0;
  for (b = 0;; b++) {
    bb = pow5(b);
    if (bb == x) {
      b *= -1;
      break;
    }
    if (bb > x) {
      flag = 1;
      break;
    }
  }

  if (flag == 1) {
    x = aa - x;
    for (b = 0;; b++) {
      bb = pow5(b);
      if (bb == x)
        break;
    }
  }

  cout << a << " " << b << '\\n';

  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 (ll i = -120; i < 120; i++) {
    for (ll j = -120; j < 120; j++) {
      if (j * j * j * j * j - i * i * i * i * i == X) {
        cout << j << " " << i;
        return (0);
      }
    }
  }
  return (0);
}


Error: TLE

Fixed submission:

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

vector<bool> prime_table(int n) {
  vector<bool> prime(n + 1, true);
  if (n >= 0)
    prime[0] = false;
  if (n >= 1)
    prime[1] = false;
  for (ll i = 2; i * i <= n; i++) {
    if (!prime[i])
      continue;
    for (ll j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}

int main() {
  ll N;
  cin >> N;
  vector<bool> prime = prime_table(N);
  if (N == 1) {
    cout << 1 << " " << 0 << endl;
  }

  for (ll i = 2; i < sqrt(N); i++) {
    if (N % i == 0) {
      for (ll a = i; a >= 0; i++) {
        ll b = i - a;
        ll tmp = a * a * a * a + a * a * a * b + a * a * b * b + a * b * b * b +
                 b * b * b * b;
        if (tmp == N % i) {
          cout << a << " " << b << endl;
        }
      }
    }
  }

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

#include <algorithm>
#include <bits/stdc++.h>
#include <iterator>

using namespace std;

int main(int argc, const char *argv[]) {
  using ll = long long;
  ll x;
  cin >> x;

  vector<ll> memo;
  for (ll i = 0; i < 1000; ++i) {
    memo.push_back(pow(i, 5));
  }

  ll a, b;
  for (ll i = 0; i < memo.size(); ++i) {
    // i^5 + なにか = x
    auto add_it = lower_bound(memo.begin(), memo.end(), x - memo[i]);
    if (add_it != memo.end() && *add_it == x - memo[i]) {
      a = i;
      b = -distance(memo.begin(), add_it);
      break;
    }

    // i^5 - なにか = x
    auto sub_it = lower_bound(memo.begin(), memo.end(), memo[i] - x);
    if (sub_it != memo.end() && *sub_it == memo[i] - x) {
      a = i;
      b = distance(memo.begin(), sub_it);
      break;
    }

    // -i^5 + なにか = x
    auto add2_it = lower_bound(memo.begin(), memo.end(), x + memo[i]);
    if (add2_it != memo.end() && *add2_it == x + memo[i]) {
      a = -i;
      b = -distance(memo.begin(), add2_it);
      break;
    }

    // -i^5 - なにか = x
    auto sub2_it = lower_bound(memo.begin(), memo.end(), -memo[i] - x);
    if (sub2_it != memo.end() && *sub2_it == -memo[i] - x) {
      a = -i;
      b = distance(memo.begin(), sub2_it);
      break;
    }
  }

  cout << a << ' ' << b << '\\n';

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

template <typename T, typename = typename std::enable_if<
                          std::is_integral<T>::value, T>::type>
vector<pair<T, int>> prime_factorize(T n) {
  vector<pair<T, int>> cnts{};
  if (n == 1) {
    return {{1, 1}};
  }

  T a = 2;
  while (n >= a * a) {
    int cnt = 0;
    while (n % a == 0) {
      n /= a;
      cnt++;
    }

    if (cnt > 0) {
      cnts.push_back({a, cnt});
    }

    a++;
  }

  if (n != 1) {
    cnts.push_back({n, 1});
  }

  return cnts;
}

int main(int argc, const char *argv[]) {
  using ll = long long;
  ll x;
  cin >> x;

  // a を固定してbを求める
  int a, b, i = 0;
  while (true) {
    int x2 = x - pow(i, 5);
    bool is_neg = x2 < 0;
    vector<pair<int, int>> prime_factors = prime_factorize(is_neg ? -x2 : x2);
    if (prime_factors.size() > 1) {
      i++;
      continue;
    }

    if (prime_factors[0].first == 1 || prime_factors[0].second == 5) {
      int factor = prime_factors[0].first;
      a = factor;
      b = -1 * i;
      if (is_neg) {
        a *= -1;
      }

      break;
    }

    i++;
  }

  cout << a << ' ' << b << '\\n';
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include "bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

struct Edge {
  int to;     // 辺の行き先
  int weight; // 辺の重み
  Edge(int t, int w) : to(t), weight(w) {}
};

// using Graph = vector<vector<Edge>>
using Graph = vector<vector<int>>;

// header area

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

  // long long A, B;
  long long ans = 0;

  long long n = 1000;

  for (long long B = -n; B < n; B++) {
    for (long long A = B; A < n; A++) {
      ans = pow(A, 5) - pow(B, 5);
      if (ans == X) {
        cout << A << " " << B;
        return 0;
      }
    }
  }
  cout << "nothing";
}

Error: TLE

Fixed submission:

#include "bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

struct Edge {
  int to;     // 辺の行き先
  int weight; // 辺の重み
  Edge(int t, int w) : to(t), weight(w) {}
};

// using Graph = vector<vector<Edge>>
using Graph = vector<vector<int>>;

// header area

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

  // long long A, B;
  long long ans = 0;

  long long n = 5000;

  for (long long B = -n; B < n; B++) {
    for (long long A = B; A < n; A++) {
      ans = pow(A, 5) - pow(B, 5);
      if (ans == X) {
        cout << A << " " << B;
        return 0;
      }
    }
  }
  cout << "nothing";
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LL long long
#define DB double
#define PI 3.14159265358979
#define MOD 1000000007
#define ERR 0.00000000000001
#define NUM 200010

LL gojou(LL a) { return a * a * a * a * a; }

int main() {
  LL x, i, j;
  scanf("%lld", &x);
  for (i = -200; i <= 200; i++) {
    for (j = -200; j <= 200; j++) {
      if (pow(i, 5) - pow(j, 5) == x) {
        printf("%lld %lld", i, j);
        return 0;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LL long long
#define DB double
#define PI 3.14159265358979
#define MOD 1000000007
#define ERR 0.00000000000001
#define NUM 200010

int main() {
  int x, y, z, m;
  LL a, b;
  scanf("%d", &x);
  y = pow(x, 1 / 5);
  z = x + pow(y, 5);
  if (z == 0) {
    printf("%d 0", y);
    return 0;
  }
  while (1) {
    m = pow(z, 1 / 5);
    if (pow(m, 5) == z) {
      printf("%d %d", y * -1, m * -1);
      return 0;
    } else {
      y--;
      z = x + pow(y, 5);
    }
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define st first
#define nd second

using ll = long long;
using namespace std;
using pii = pair<int, int>;
ll x;
void ch(int dif) {
  ll want = x;
  ll val = 1LL;
  for (int i = 1; i <= 5; i++) {
    val *= 1LL * dif;
  }
  // printf("val = %lld", val);
  want -= val;
  // printf("at %d want = %d\\n", dif, want);
  if (want == 0) {
    printf("0 %d", -dif);
    exit(0);
  }
  if (want % (5 * dif) != 0) {
    return;
  }
  want /= (5LL * dif);

  for (int i = 1; 1LL * i * i <= abs(want); i++) {
    int need = (int)want;
    if (i == dif)
      continue;
    if (i * i - i * dif + dif * dif == 0)
      continue;
    // printf("at %d %d %d", i, need, need % i);
    if (abs(need) % i == 0) {
      need /= i;
      if (need % abs(i - dif) != 0)
        continue;
      need /= (i - dif);
      // printf("here need = %d", need);
      if (need == i * i - i * dif + dif * dif) {
        printf("%d %d", i, i - dif);
        exit(0);
      }
    }
  }
}
int main() {
  scanf("%lld", &x);
  for (int i = 1; 1LL * i * i <= x; i++) {
    if (x % i == 0)
      ch(i);
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define st first
#define nd second

using ll = long long;
using namespace std;
using pii = pair<int, int>;
ll x;
void ch(int dif) { ll want = x / dif; }
int main() {
  scanf("%lld", &x);
  for (int i = 0; i <= x; i++) {
    int val = i * i * i * i * i - x;
    int cal = abs(val);
    for (int j = 1; pow(j, 5) <= cal; j++) {
      if (pow(j, 5) == cal) {
        printf("%d ", i);
        if (val < 0)
          printf("-");
        printf("%d", j);
        return 0;
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(), (x).end()
#define caset                                                                  \\
  int ___T;                                                                    \\
  cin >> ___T;                                                                 \\
  for (int cs = 1; cs <= ___T; cs++)
#define get(c, x) (lower_bound(c.begin(), c.end(), x) - c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
const ll mod = 1e9 + 7;
const int Max = 1e6 + 10;
ll powmod(ll a, ll b) {
  ll res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1)
      res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
ll f(ll n) { return n * n * n * n * n; }
void solve() {
  ll x;
  cin >> x;
  rep(i, -2000, 2000) {
    rep(j, -2000, 2000) {
      if (f(i) - f(j) == x) {
        cout << i << " " << j << endl;
        return;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  // caset{
  solve();
  //}
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(), (x).end()
#define caset                                                                  \\
  int ___T;                                                                    \\
  cin >> ___T;                                                                 \\
  for (int cs = 1; cs <= ___T; cs++)
#define get(c, x) (lower_bound(c.begin(), c.end(), x) - c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
const ll mod = 1e9 + 7;
const int Max = 1e6 + 10;
ll powmod(ll a, ll b) {
  ll res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1)
      res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
ll ff(ll a) { return a * a * a * a * a; }
int f(ll x) {
  if (x == 0)
    return 0;
  int s = 1;
  if (x < 0) {
    x = -x;
    s = -1;
  }
  int low = 0, hi = 100;
  while (low <= hi) {
    int mid = (low + hi) / 2;
    if (ff(mid) == x) {
      return s * mid;
    } else if (ff(mid) > x) {
      hi = mid - 1;
    } else {
      low = mid + 1;
    }
  }
  return 0;
}

void solve() {
  ll a = -2000;
  ll x;
  cin >> x;
  if (x == 1) {
    cout << 1 << " " << 0 << endl;
    return;
  }
  if (x == 2) {
    cout << 1 << " " << 1 << endl;
    return;
  }

  while (1) {
    int b = f(x - ff(a));
    if (f(b) == x - ff(a)) {
      cout << a << " " << -b << endl;
      return;
    }
    a++;
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  // caset{
  solve();
  //}
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for (ll i = (m); (i) < (ll)(n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin, (a).end

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

  ll x;
  cin >> x;
  ll j = 0;
  while (1) {
    if (5 * pow(j, 4) - 10 * pow(j, 3) + 10 * pow(j, 2) - 5 * j + 1 > x)
      break;
    ++j;
  }
  ll a = j, b = j - 1;
  while (1) {
    ll now = pow(a, 5) - pow(b, 5);
    if (now == x) {
      cout << a << " " << b << endl;
      return 0;
    }
    if (now > x)
      --a;
    else if (now < x)
      --b;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for (ll i = (m); (i) < (ll)(n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin, (a).end

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

  ll x;
  cin >> x;
  ll a = pow(x, 0.2), b = -pow(x, 0.2) - 1;
  while (1) {
    ll now = pow(a, 5) - pow(b, 5);
    if (now == x) {
      cout << a << " " << b << endl;
      return 0;
    }
    if (now > x)
      ++b;
    else if (now < x)
      ++a;
  }

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

#include <cmath>
#include <iostream>
#define N 120
typedef long long int ll;

int main(void) {
  long x;
  int a = 0, b = 0;
  std::cin >> x;
  for (a = 0; a < N; a++) {
    for (b = 0; b < N; b++) {
      ll a5 = pow(a, 5);
      ll b5 = pow(b, 5);
      if (a5 - b5 == x) {
        std::cout << a << " " << b << std::endl;
        return 0;
      } else if (a5 + b5 == x) {
        std::cout << a << " " << b * (-1) << std::endl;
        return 0;
      }
    }
  }
}


Error: WA

Fixed submission:

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

int main(void) {
  long n, b, c, q;
  ll sum = 0;
  cin >> n;
  vector<long> a(n, 0);

  for (int i = 0; i < n; i++)
    cin >> a[i];
  cin >> q;
  for (int i = 0; i < q; i++) {
    sum = 0;
    int j = 0;
    cin >> b >> c;
    while (a[j] <= b) {
      if (a[j] == b)
        a[j] = c;
      j++;
    }
    sum = accumulate(a.begin(), a.end(), 0);
    sort(a.begin(), a.end());
    cout << sum << endl;
  }

  return 0;
}
// TLE & RE
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++)
int main() {
  long x;
  cin >> x;
  for (int a = 0; a <= 1000; a++) {
    for (int b = -1000; b <= 1000; 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;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int x;
  cin >> x;
  vector<int> ret;
  for (int i = 1; i * i <= x; i++) {
    if (x % i == 0) {
      ret.push_back(i);
      if (i * i != x)
        ret.push_back(x / i);
    }
  }
  sort(begin(ret), end(ret));
  for (auto i : ret) {
    for (int a = 1; a <= i; a++) {
      int b = a - i;
      if (pow(a, 5) - pow(b, 5) == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

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

map<long long int, vector<pair<int, int>>> solns;

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

  for (long long int i = -128; i <= 128; i++) {
    for (long long int j = -128; j <= 128; j++) {
      solns[i * i * i * i * i - j * j * j * j * j].push_back(make_pair(i, j));
    }
  }

  pair<int, int> ans = solns[(long long int)X][0];
  printf("%d %d", ans.first, ans.second);
}


Error: WA

Fixed submission:

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

map<int, vector<pair<int, int>>> solns;

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

  for (int i = -64; i <= 64; i++) {
    for (int j = -64; j <= 64; j++) {
      solns[i * i * i * i * i - j * j * j * j * j].push_back(make_pair(i, j));
    }
  }

  pair<int, int> ans = solns[X][0];
  printf("%d %d", ans.first, ans.second);
}
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 = -118; i < 120; i++) {
    for (int j = -119; j < 119; 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;
typedef long long ll;

ll fb(ll b, ll m) { return pow(b + m, 5) - pow(b, 5); }
int main() {
  ll x;
  cin >> x;

  bool judge = false;
  pair<ll, ll> ans;
  vector<ll> yaku(0);
  for (int i = 1; i <= sqrt(x); i++) {
    if (x % i == 0) {
      yaku.push_back(i);
      yaku.push_back(x / i);
    }
  }
  for (auto tmp : yaku) {
    for (ll b = -tmp;; b++) {
      ll f = fb(b, tmp);
      if (f == x) {
        ans.first = b + tmp;
        ans.second = b;
        judge = true;
        break;
      }
      if (f > x && b > 0) {
        break;
      }
    }
    if (judge)
      break;
  }
  cout << ans.first << " " << ans.second << endl;
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded


#include <bits/stdc++.h>
using namespace std;
int main() {

  long x;
  cin >> x;
  long y = -1;
  while (true) {

    if (abs(pow(y, 5)) > x)
      break;
    y--;
  }
  y++;
  // cout<<y<<endl;
  for (int i = y;; i++) {
    long p = x + pow(i, 5);
    float ans = pow(p, 0.2);
    long a = ans;
    // cout<<ans-a<<endl;
    if (ans - a == 0) {
      cout << ans << " " << i << endl;
      break;
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {

  long long x;
  cin >> x;
  int y = -1;
  for (int i = 0;; i++) {
    if (pow(i, 5) > x - y) {
      y++;
      i = -1;
      continue;
    }
    if (pow(i, 5) == x - 1) {
      cout << i << " "
           << "-1\\n";
      break;
    }
  }
}