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

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

int main() {

  int64_t x;
  cin >> x;

  int64_t rootx = 0;
  while (rootx * rootx <= x) {
    rootx++;
  }

  rootx--;

  vector<int64_t> factors(0);

  for (int64_t i = 1; i <= rootx; i++) {
    if (x % i == 0) {
      factors.push_back(i);
      if (i != x / i) {
        factors.push_back(x / i);
      }
    }
  }

  int64_t a = 1;
  int64_t b = 0;

  int64_t size = int64_t(factors.size());
  for (int64_t i = 0; i < size; i++) {
    int64_t d = factors.at(size - 1 - i);

    int64_t flag = 1;

    int64_t tmp = 0;

    while (tmp - d < 120) {
      if (tmp * tmp * tmp * tmp * tmp -
              (tmp - d) * (tmp - d) * (tmp - d) * (tmp - d) * (tmp - d) ==
          x) {
        a = tmp;
        b = a - d;
        flag = 0;
        break;
      }

      else {
        tmp++;
      }
    }

    if (flag == 0) {
      break;
    }
  }

  cout << a << " " << b << endl;
}

Error: TLE

Fixed submission:

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

int main() {

  int64_t x;
  cin >> x;

  int64_t rootx = 0;
  while (rootx * rootx <= x) {
    rootx++;
  }

  rootx--;

  vector<int64_t> factors(0);

  for (int64_t i = 1; i <= rootx; i++) {
    if (x % i == 0) {
      factors.push_back(i);
      if (i != x / i) {
        factors.push_back(x / i);
      }
    }
  }

  int64_t a = 1;
  int64_t b = 0;

  int64_t size = int64_t(factors.size());
  for (int64_t i = 0; i < size; i++) {
    int64_t d = factors.at(i);

    int64_t flag = 1;

    int64_t tmp = 0;

    while (tmp - d < 120) {
      if (tmp * tmp * tmp * tmp * tmp -
              (tmp - d) * (tmp - d) * (tmp - d) * (tmp - d) * (tmp - d) ==
          x) {
        a = tmp;
        b = a - d;
        flag = 0;
        break;
      }

      else {
        tmp++;
      }
    }

    if (flag == 0) {
      break;
    }
  }

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

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

using ll = long long;

int main() {
  int X;
  cin >> X;
  int A, B;
  bool ok = false;
  for (A = 1;; A++) {
    for (B = A - 1;; B--) {
      int res = pow(A, 5) - pow(B, 5);
      if (res == X) {
        ok = true;
        break;
      } else if (res > 1000000000)
        break;
    }
    if (ok)
      break;
  }
  cout << A << " " << B << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

using ll = long long;

int main() {
  int X;
  cin >> X;
  ll A = 1, B = 0;
  bool ok = false;
  while (1) {
    if (pow(A, 5) - pow(B, 5) == X)
      break;
    if (pow(A, 5) - X > 0) {
      while (1) {
        B++;
        if (pow(A, 5) - pow(B, 5) == X) {
          ok = true;
          break;
        }
        if (pow(A, 5) - X < pow(B, 5))
          break;
      }
      if (ok)
        break;
      A++;
    } else if (pow(A, 5) - X < 0) {
      while (1) {
        B--;
        if (pow(A, 5) - pow(B, 5) == X) {
          ok = true;
          break;
        }
        if (pow(A, 5) - X > pow(B, 5))
          break;
      }
      if (ok)
        break;
      A++;
    }
  }
  cout << A << " " << B << endl;
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

/*
[ ( ^ _ ^ ) ]
*/
// problem: atc/abc166_d
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000000

int main() {
  ll x;
  scanf("%lld", &x);
  ll l = 2000;
  for (ll a = 0; a <= l; a++) {
    for (ll b = -l; b <= l; b++) {
      if (pow(a, 5) - pow(b, 5) == x) {
        printf("%lld %lld\\n", a, b);
        return 0;
      }
    }
  }
  assert(false);
}


Error: WA

Fixed submission:

/*
[ ( ^ _ ^ ) ]
*/
// problem: atc/abc166_d
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000000

int main() {
  ll x;
  scanf("%lld", &x);
  for (ll a = -100; a <= 100; a++) {
    for (ll b = -100; b <= 100; b++) {
      if (pow(a, 5) - pow(b, 5) == x) {
        printf("%lld %lld\\n", a, b);
        return 0;
      }
    }
  }
  assert(false);
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <vector>
using namespace std;

using ll = long long;

const ll maxValue = 1e+9;

ll myPow(ll x, int n) {

  ll retValue = 1;

  while (n > 0) {

    if (n & 1) {
      retValue *= x;
      n--;
    } else {
      x *= x;
      n >>= 1;
    }
  }

  return retValue;
}

int main() {

  ll x;
  cin >> x;

  ll a, b;
  a = -1000;

  while (1) {

    ll left = -1000, right = 1000;
    ll a5 = myPow(a, 5);
    ll sum;
    ll mid;
    while (right - left > 1) {
      mid = (right + left) / 2;
      sum = a5 - myPow(mid, 5);

      if (x > sum)
        right = mid;
      else
        left = mid;
    }

    if (sum == x) {
      b = mid;
      break;
    }

    a++;
  }

  cout << a << " " << b << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;

using ll = long long;

const ll maxValue = 1e+9;

ll myPow(ll x, int n) {

  ll retValue = 1;

  while (n > 0) {

    if (n & 1) {
      retValue *= x;
      n--;
    } else {
      x *= x;
      n >>= 1;
    }
  }

  return retValue;
}

int main() {

  ll x;
  cin >> x;

  ll a, b;
  a = -100;

  while (1) {

    ll left = -99, right = 100;
    ll a5 = myPow(a, 5);
    ll sum;
    ll mid;
    while (right - left > 1) {
      mid = (right + left) / 2;
      sum = a5 - myPow(mid, 5);

      if (x > sum)
        right = mid;
      else
        left = mid;
    }

    if (sum == x) {
      b = mid;
      break;
    }

    a++;
  }

  cout << a << " " << b << endl;

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

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


Error: TLE

Fixed submission:

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

#include <bits/stdc++.h>

using namespace std;

long long a = 0, b = 0, x = 0;

int main() {
  cin >> x;
  cin.ignore();

  // マイナス方向の探索

  double db_a;
  long long b5;
  for (long long b_ = 0; b_ * b_ * b_ * b_ * b_ <= x; b_++) {
    b5 = b_ * b_ * b_ * b_ * b_;
    db_a = pow((double)(x - b5), 0.2);
    a = round(db_a);
    if (a * a * a * a * a == x - b5) {
      if (b_ == 0) {
        cout << a << " " << 0 << endl;
        return 0;
      }
      cout << a << " -" << b_ << endl;
      return 0;
    }
  }

  // プラス方向のループ

  b = 1;
  double db_b = 1;
  double b5db;
  while (true) {
    b5 = b * b * b * b * b;
    b5db = db_b * db_b * db_b * db_b * db_b;
    // db_a = pow((double)(x+b5db), 0.2);
    db_a = pow((double)(x + b5), 0.2);
    a = round(db_a);
    // if(db_b == 2) cout << a << " " << db_a << endl;
    if (a * a * a * a * a == x + b5) {
      cout << a << " " << b << endl;
      return 0;
    }
    ++b;
    db_b += 1;
    // cout << db_b << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

long long a = 0, b = 0, x = 0;

int main() {
  cin >> x;
  cin.ignore();

  // マイナス方向の探索

  double db_a;
  long long b5;
  for (long long b_ = 0; b_ * b_ * b_ * b_ * b_ <= x; b_++) {
    b5 = b_ * b_ * b_ * b_ * b_;
    db_a = pow((double)(x - b5), 0.2);
    a = round(db_a);
    if (a * a * a * a * a == x - b5) {
      if (b_ == 0) {
        cout << a << " " << 0 << endl;
        return 0;
      }
      cout << a << " -" << b_ << endl;
      return 0;
    }
  }

  // プラス方向のループ

  b = 1;
  double db_b = 1;
  double b5db;
  while (true) {
    b5db = db_b * db_b * db_b * db_b * db_b;
    db_a = pow((double)(x + b5db), 0.2);
    a = round(db_a);
    if (abs(db_a - a) < DBL_EPSILON) {
      cout << a << " " << b << endl;
      return 0;
    }
    db_b += 1;
    cout << db_b << endl;
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vec = vector<int>;

#define rep(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define rrep(i, n) for (int(i) = (n); (i) >= 0; --(i))
#define Sort(a) sort(a.begin(), a.end())
#define gSort(a) sort(a.begin(), a.end(), greater<int>())
#define pout(n, a) cout << fixed << setprecision(n) << (a)
#define Cast(dig, n) static_cast<std::bitset<(dig)>>(n)

const int INF = 2147483647;
const ll MOD = 1000000007;

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

  for (ll a = -1000; a <= 1000; ++a) {
    for (ll b = -1000; b <= 1000; ++b) {
      if (((a * a * a * a * a) - (b * b * b * b * b)) == x) {
        cout << a << " " << b;
        return 0;
      }
    }
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vec = vector<int>;

#define rep(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define rrep(i, n) for (int(i) = (n); (i) >= 0; --(i))
#define Sort(a) sort(a.begin(), a.end())
#define gSort(a) sort(a.begin(), a.end(), greater<int>())
#define pout(n, a) cout << fixed << setprecision(n) << (a)
#define Cast(dig, n) static_cast<std::bitset<(dig)>>(n)

const int INF = 2147483647;
const ll MOD = 1000000007;

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

  ll a = 0;

  for (ll i = 1; i < 1000000000; ++i) {
    if (x <= pow(i, 5)) {
      break;
    }
    a = i;
    // cout << i << " " << pow(i ,5) << endl;
  }

  // cout << "a = " << a << endl;
  ll b = 0;

  for (ll i = 1; i < 1000000000; ++i) {
    if ((pow(a, 5) - pow(i, 5)) == x) {
      b = i;
      break;
    }
    // cout << i << " " << pow(i, 5) << endl;

    ll tmp = -i;
    if ((pow(a, 5) - pow(tmp, 5)) == x) {
      b = tmp;
      break;
    }
    cout << endl;
  }

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

#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;

int main() {
  // 入力
  long int X;
  cin >> X;

  int A, B;
  for (int i = -118; i <= 119; i++) {
    for (int j = -118; j <= 119; j++) {
      A = i;
      B = j;
      if (pow(A, 5) - pow(B, 5) == X) {
        break;
      }
    }
    if (pow(A, 5) - pow(B, 5) == X) {
      break;
    }
  }
  // cout << pow(2, 5) - pow(-1, 5) << endl;
  cout << A << " " << B << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;

int main() {
  // 入力
  long int X;
  cin >> X;

  double A, B;
  if (X % 2 == 1) {
    for (long int i = 1; i < 1000000000; i += 2) {
      B = double(i);
      A = pow(X + pow(B, 5.0), 0.2);
      if (floor(A) == A) {
        break;
      }
      B = double(-i);
      A = pow(X + pow(B, 5.0), 0.2);
      if (floor(A) == A) {
        break;
      }
    }
  } else {
    for (long int i = 2; i < 1000000000; i += 2) {
      B = double(i);
      A = pow(X + pow(B, 5.0), 0.2);
      if (floor(A) == A) {
        break;
      }
      B = double(-i);
      A = pow(X + pow(B, 5.0), 0.2);
      if (floor(A) == A) {
        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; i < n; i++)
#define rep2(i, a, n) for (int i = a; i < n; i++)
using namespace std;
int X;
int main() {
  cin >> X;
  // for(int i = 1; i < pow(10,9)+1; i++) {
  //     int r = pow(i,5)-X;
  //     double B;
  //     if (r < 0) {
  //     B = -1 * pow(-r, 0.2);
  //     } else {
  //        B = pow(r, 0.2);
  //     }
  //     // cout << B << endl;
  //     if (floor(B) == B ) {
  //         cout << i << " " << B << endl;
  //         break;
  //     }
  // }
  for (int i = 1; i < pow(10, 3) + 1; i++) {
    for (int b = -1 * pow(10, 3) - 1; b < pow(10, 3); b++) {
      int num = pow(i, 5) - pow(b, 5);
      if (num == X) {
        cout << i << " " << b << endl;
        return 0;
      }
    }
  }
  // cout << pow(-1,0.2) << endl;
  // cout << pow(pow(2,5)-X, 0.2) << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, a, n) for (int i = a; i < n; i++)
using namespace std;
long long X;
int main() {
  cin >> X;
  for (int i = 1; i < pow(10, 9) + 1; i++) {
    int r = pow(i, 5) - X;
    double B;
    if (r < 0) {
      B = -1 * pow(-r, 0.2);
    } else {
      B = pow(r, 0.2);
    }
    // cout << B << endl;
    if (floor(B) == B) {
      cout << i << " " << B << endl;
      break;
    }
  }
  // cout << pow(-1,0.2) << endl;
  // cout << pow(pow(2,5)-X, 0.2) << endl;
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <list>
#include <string>
#include <vector>

using namespace std;

int main() {
  long long x;
  cin >> x;
  for (long a = -1000;; a++) {
    for (long b = 0; b >= -1000; b--) {
      long long c = (a * a * a * a * a) - (b * b * b * b * b);
      if (x == c) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <list>
#include <string>
#include <vector>

using namespace std;

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

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

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

  for (int b = -118; b < 120; b++)
    for (int a = -118; a < 120; a++)
      if (x == (a * a * a * a * a) - (b * b * b * b * b)) {
        cout << a << " " << b << endl;
        return 0;
      }
  return 0;
}


Error: TLE

Fixed submission:

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

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

  for (ll b = -x; b < x; b++) {
    ll a = x + (b * b * b * b * b);
    // cout<<a<<endl;
    for (ll index = 0; index * index <= a / 2; index++)
      if (index == 0 || a % index == 0) {
        if (a == (index * index * index * index * index)) {
          cout << index << " " << b << endl;
          return 0;
        }
      }
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

long long f(int n) { return (long long)n * n * n * n * n; }
int search(int a, long long n) {
  int l = -200, r = 200;
  for (int i = 0; i < 20; ++i) {
    int mid = (l + r) >> 1;
    if (f(a) - f(mid) == n) {
      return mid;
    }
    if (f(a) - f(mid) < n) {
      r = mid;
    } else
      l = mid;
  }
  return 1000;
}

int main() {
  long long n;
  cin >> n;
  for (int a = 0; a <= 250; ++a) {
    int b = search(a, n);
    if (b != 1000) {
      cout << a << " " << b << "\\n";
      return 0;
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

long long fifth(int a) { return (long long)a * a * a * a * a; }

int main() {
  int n;
  cin >> n;
  int ans = 0, res = 0;
  for (int A = 1; A <= 200; ++A) {
    int L = -200;
    int R = 200;
    while (L <= R) {
      int mid = (L + R) >> 1;
      int diff = fifth(A) - fifth(mid);
      if (diff == n) {
        cout << A << " " << mid << "\\n";
        return 0;
      }
      if (diff < n) {
        R = mid + 1;
      } else {
        L = mid - 1;
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main() {
  ll x;
  cin >> x;
  vector<ll> tar(1001);
  for (ll i = 0; i <= 1000; i++) {
    tar.at(i) = i * i * i * i * i;
    // cout << tar[i] << endl;
  }
  for (int i = 0; i <= 1000; i++) {
    for (int j = 0; j <= 1000; j++) {
      if (x < tar[i] + tar[j])
        break;
      if (x != tar[i] + tar[j])
        continue;
      cout << i << ' ' << -j << endl;
      return 0;
    }
  }
  for (int i = 0; i <= 1000; i++) {
    for (int j = 0; j <= 1000; j++) {
      if (tar[i] - tar[j] != x)
        continue;
      cout << i << ' ' << j << endl;
      return 0;
    }
  }
  // for(int i=0; i<200; i++){
  //   for(int j=0; j<200; j++){
  //     cout <<tar[i]+tar[j] << ' ' << tar[i] << ' ' << tar[j] << endl;
  //     if(x<tar[i] && x<-tar[j]) continue;
  //     if(x<-tar[i] && x<tar[j]) continue;
  //     if(tar[i]-tar[j]!=x) continue;
  //
  //     return 0;
  //   }
  // }
  // for(auto x: tar) cout << x << endl;
}

Error: -6
free(): invalid next size (normal)


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const double PI = acos(-1);

vector<ll> tar(201);

int main() {
  ll x;
  cin >> x;
  for (int i = 0; i <= 201; i++) {
    tar[i] = pow(i - 100, 5);
  }
  for (int i = 0; i < 200; i++) {
    for (int j = 0; j < 200; j++) {
      if (tar[i] - tar[j] != x)
        continue;
      cout << i - 100 << ' ' << j - 100 << endl;
      return 0;
    }
  }
  // for(auto x: tar) cout << x << endl;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (n); i < (m); i++)
#define rrep(i, n, m) for (int i = (n)-1; i >= (m); i--)
#define pvec(vec)                                                              \\
  {                                                                            \\
    for (auto v : vec)                                                         \\
      cout << v << ' ';                                                        \\
    cout << endl;                                                              \\
  }
#define pivec(vec)                                                             \\
  {                                                                            \\
    rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' ';                   \\
    cout << endl;                                                              \\
  }

using namespace std;
using ll = long long;

unordered_map<ll, int> value5;
void init() {
  ll num = 0;
  for (;;) {
    ll now = num * num * num * num * num;
    if (now > 100000000000)
      break;
    value5[now] = num++;
  }
  unordered_map<ll, int> new_value5(value5);
  for (auto v : value5)
    new_value5[-v.first] = -v.second;
  swap(value5, new_value5);
}

int main() {
  init();
  ll x;
  cin >> x;
  ll num = 0;
  for (;;) {
    ll now = num * num * num * num * num;
    ll tgt = now - x;
    if (value5.count(tgt) > 0) {
      cout << num << ' ' << value5[tgt] << endl;
      return 0;
    }
    // cout << num << endl;
    ++num;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (n); i < (m); i++)
#define rrep(i, n, m) for (int i = (n)-1; i >= (m); i--)
#define pvec(vec)                                                              \\
  {                                                                            \\
    for (auto v : vec)                                                         \\
      cout << v << ' ';                                                        \\
    cout << endl;                                                              \\
  }
#define pivec(vec)                                                             \\
  {                                                                            \\
    rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' ';                   \\
    cout << endl;                                                              \\
  }

using namespace std;
using ll = long long;

unordered_map<ll, int> value5;
void init() {
  ll num = 0;
  for (;;) {
    ll now = num * num * num * num * num;
    if (now < 0)
      break;
    value5[now] = num++;
  }
  unordered_map<ll, int> new_value5(value5);
  for (auto v : value5)
    new_value5[-v.first] = -v.second;
  swap(value5, new_value5);
}

int main() {
  init();
  ll x;
  cin >> x;
  ll num = 0;
  for (;;) {
    ll now = num * num * num * num * num;
    ll tgt = now - x;
    if (value5.count(tgt) > 0) {
      cout << num << ' ' << value5[tgt] << endl;
      return 0;
    }
    // cout << num << endl;
    ++num;
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>

int main() {
  int X;
  scanf("%d", &X);
  for (int A = 0; A < 1000; ++A)
    for (int B = -1000; B < A; ++B)
      if (A * A * A * A * A - B * B * B * B * B == X) {
        printf("%d %d", A, B);
        return 0;
      }
}

Error: -11

Fixed submission:

#include <cstdio>

int main() {
  int X;
  scanf("%d", X);
  for (int A = 0; A < 1000; ++A)
    for (int B = -1000; B < A; ++B)
      if (A * A * A * A * A - B * B * B * B * B == X) {
        printf("%d %d", A, B);
        return 0;
      }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;
long long sqr(long long s) {
  long long ss = abs(s);
  long long l = 0, r = 1000;
  while (l < r) {
    long long mid = (l + r) / 2;
    if (pow(mid, 5) < ss)
      l = mid + 1;
    else
      r = mid;
  }
  if (s >= 0)
    return l;
  else
    return -l;
}
int main() {
  long long x;
  cin >> x;
  long long v = 0;
  while (1) {
    long long a = v;
    long long b = sqr(pow(a, 5) - x);
    if (pow(a, 5) - pow(b, 5) == x) {
      cout << a << " " << b << endl;
      break;
    }
    a = -v;
    b = sqr(pow(a, 5) - x);
    if (pow(a, 5) - pow(b, 5) == x) {
      cout << a << " " << b << endl;
      break;
    }
    v++;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
long long sqr(int s) {
  long long ss = abs(s);
  for (long long i = 0; i <= 100; i++) {
    if (1ll * i * i * i * i * i >= 1ll * ss) {
      if (s >= 0)
        return i;
      else
        return -i;
    }
  }
}
int main() {
  long long x;
  cin >> x;
  long long a = 0;
  while (1) {
    long long a1 = a, b1 = sqr(a1 * a1 * a1 * a1 * a1 - x);
    if (a1 * a1 * a1 * a1 * a1 - b1 * b1 * b1 * b1 * b1 == x) {
      cout << a1 << " " << b1 << endl;
      break;
    }
    a1 = -a;
    b1 = sqr(a1 * a1 * a1 * a1 * a1 - x);
    if (a1 * a1 * a1 * a1 * a1 - b1 * b1 * b1 * b1 * b1 == x) {
      cout << a1 << " " << b1 << endl;
      break;
    }
    a++;
    // int v; cin >> v;
  }
  return 0;
}