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

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

ll n;

int main() {
  cin >> n;

  for (ll i = -200; i <= 200; ++i) {
    for (ll j = -200; j <= 200; ++j) {
      if (i * i * i * i * i - j * j * j * j * j == n) {
        printf("%lld %lld\\n", i, j);
        return 0;
      }
    }
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

ll n;

ll power(ll a, ll b) {
  if (b == 0)
    return 1;
  if (b == 1)
    return a;
  if (b % 2 == 1)
    return power(a, b - 1) * a;
  ll q = power(a, b / 2);
  return q * q;
}

int main() {
  ll x, y, a, b;
  cin >> n;
  ll one = n % 10;
  for (a = 0; a <= one; ++a) {
    b = one - a;
    x = power(a, 5), y = power(b, 5);
    while (x + y < n) {
      while (x + y < n) {
        b += 10;
        y = power(b, 5);
      }
      a += 10;
      x = power(a, 5);
    }
    if (x + y == n) {
      cout << b << " " << -a << endl;
      return 0;
    }
  }

  for (a = one; a >= 0; --a) {
    b = a - one;
    x = power(a, 5), y = power(b, 5);
    while (x + y < n) {
      while (x + y < n) {
        b += 10;
        y = power(b, 5);
      }
      a += 10;
      x = power(a, 5);
    }
    if (x - y == n) {
      cout << a << " " << b << endl;
      return 0;
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  // your code goes here
  int x;
  cin >> x;
  int flag = 0;
  for (long long i = 0; i < 10000; i++) {
    for (long long j = -10000; j < 10000; j++) {
      if ((pow(i, 5) - pow(j, 5)) == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  // your code goes here
  int x;
  cin >> x;
  for (long long i = 0; i <= 10000; i++) {
    for (long long j = -100000; j <= 100000; j++) {
      if ((pow(i, 5) - pow(j, 5)) == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : abs(a); }
template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <typename T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  fill((T *)array, (T *)(array + N), val);
}

int main() {
  ll x;
  cin >> x;
  for (ll a = 1; a < 1e5; a++)
    for (ll b = -1e3; b < 1e3; b++)
      if (a * a * a * a * a - b * b * b * b * b == x) {
        cout << a << ' ' << b << endl;
        END;
      }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : abs(a); }
template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <typename T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  fill((T *)array, (T *)(array + N), val);
}

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

#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>

#define log(x) cout << x << endl
#define pb push_back
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long lint;
using namespace std;
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;
}
const long long INF = 1LL << 60;

// <<fixed<<setprecision(6)<<

int gcd(lint x, lint y) { return y == 0 ? x : gcd(y, x % y); }

int digsum(int n) {
  int res = 0;
  while (n > 0) {
    res += n % 10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while (n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) { return count(s.cbegin(), s.cend(), c); }

int lcm(lint x, lint y) { return x / gcd(x, y) * y; }

int combi(int n, int r) {
  int num = 1;
  for (int i = 1; i <= r; i++) {
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main() {
  lint x;
  cin >> x;
  lint a, b;
  bool is = true;
  for (lint i = -300; i < 300; i++ && is) {
    for (lint j = -300; j < 300; j++ && is) {
      if (pow(i, 5) - pow(j, 5) == x) {
        a = i;
        b = j;
        is = false;
        break;
      }
    }
  }
  cout << a << " " << b;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>

#define log(x) cout << x << endl
#define pb push_back
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long lint;
using namespace std;
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;
}
const long long INF = 1LL << 60;

// <<fixed<<setprecision(6)<<

int gcd(lint x, lint y) { return y == 0 ? x : gcd(y, x % y); }

int digsum(int n) {
  int res = 0;
  while (n > 0) {
    res += n % 10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while (n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) { return count(s.cbegin(), s.cend(), c); }

int lcm(lint x, lint y) { return x / gcd(x, y) * y; }

int combi(int n, int r) {
  int num = 1;
  for (int i = 1; i <= r; i++) {
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main() {
  lint x;
  cin >> x;
  lint a, b;
  bool is = true;
  for (lint i = -1; i < 10000; i++ && is) {
    for (lint j = -1; j < 10000; j++ && is) {
      if (pow(i, 5) - pow(j, 5) == x) {
        a = i;
        b = j;
        is = false;
        break;
      }
    }
  }
  cout << a << " " << b;
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

int main() {

  int X;
  cin >> X;

  for (int i = -120; i <= 120; ++i) {
    for (int j = -120; j <= 120; ++j) {
      if (powl(i, 5) - powl(j, 5) == X) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }

  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

vector<int64_t> divisor(int64_t n) {
  vector<int64_t> ret;
  for (int64_t i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {

  int X;
  cin >> X;

  vector<int64_t> A;
  A = divisor(X);

  int Y = pow(X, 0.5);

  for (int k = A[A.size() - 2]; k > 0; --k) {
    if (A[k] < Y) {
      for (int i = -Y; i <= Y; ++i) {
        for (int j = i + A[k]; j <= Y; ++j) {
          if (powl(i, 5) - powl(j, 5) == -X) {
            cout << j << " " << i << endl;
            return 0;
          }
        }
      }
    }
  }

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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int mod = 1000000007;
int main() {
  ll x;
  cin >> x;
  ll a, b;
  ll fl = 0;
  for (a = 0; fl == 0; a++) {
    for (b = -1 * a; b <= a; b++) {
      if (pow(a, 5) - pow(b, 5) == x) {
        fl++;
        cout << a << " " << b << endl;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int mod = 1000000007;
int main() {
  ll x;
  cin >> x;
  ll i;
  ll memo, memo2;
  ll fl = 0;
  for (i = 0; fl == 0; i++) {
    ll po = pow(i, 5);
    if (po >= x) {
      fl++;
      memo = i - 1;
    }
  }
  ll han = 0;
  ll po2 = pow(memo, 5);
  for (i = 0; han == 0; i++) {
    if (po2 == x + pow(i, 5)) {
      memo2 = i;
      han++;
      break;
    } else if (po2 == x + pow(-1 * i, 5)) {
      memo2 = -1 * i;
      han++;
      break;
    }
  }
  cout << memo << " " << memo2 << endl;
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

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

signed main() {
  long x;
  cin >> x;
  for (long i = -200; i < 200; i++) {
    for (long j = -200; j < 200; j++) {
      auto val = (long)pow(i, 5) - (long)pow(j, 5);
      if (val == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}

Error: -6
free(): invalid pointer


Fixed submission:

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

struct {
  int no;
  long val;
} typedef Agent;

signed main() {
  int n;
  cin >> n;
  vector<Agent> agents;
  for (int i = 0; i < n; i++) {
    Agent agent;
    cin >> agent.val;
    agent.no = i + 1;
    agents.push_back(agent);
  }

  auto sortA = [](Agent a, Agent b) { return a.val <= b.val; };
  sort(agents.begin(), agents.end(), sortA);

  int numCount = 0;
  int sum = 0;
  long numA[200000];
  int prev = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < numCount; j++) {
      if (prev != agents[i].val) {
        numA[j]--;
      }
      if (agents[i].no == numA[j]) {
        sum++;
      }
    }

    prev = agents[i].val;

    numA[numCount] = agents[i].no - (agents[i].val * 2);
    numCount++;
  }

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

#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

ll power(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) {
      res = res * x;
    }
    x = x * x;
    n >>= 1;
  }
  return res;
}

ll X;

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

  for (ll a = -200; a <= 200; a++) {
    for (ll b = -200; b <= 200; b++) {
      if (power(a, 5) - power(b, 5) == X) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

vector<pair<ll, ll>> prime_factor(ll n) {
  vector<pair<ll, ll>> v;

  for (ll p = 2; p * p <= n; ++p) {
    if (n % p != 0) {
      continue;
    }
    ll num = 0;
    while (n % p == 0) {
      ++num;
      n /= p;
    }
    v.push_back(make_pair(p, num));
  }

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

  return v;
}

ll power(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) {
      res = res * x;
    }
    x = x * x;
    n >>= 1;
  }
  return res;
}

ll X;
// vector<int> A;

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

  ll a = 0;
  ll b = 0;
  for (ll i = 0; i <= 1000; i++) {
    ll x = power(i, 5) - X;
    auto vec = prime_factor(x < 0 ? -x : x);
    if (vec.size() == 0) {
      a = i;
      b = x < 0 ? -1 : 1;
      break;
    }
    if (vec.size() == 1 && vec[0].second == 5) {
      a = i;
      b = x < 0 ? -vec[0].first : vec[0].first;
      break;
    }
  }

  cout << a << " " << b << endl;
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

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

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

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

  vector<int64_t> gojou(1000);
  for (int i = 0; i < 1000; i++) {
    gojou.at(i) = pow(i, 5);
  }

  // cout << sosuu.at(1);

  int64_t a, b;

  for (int i = 0; i < 1000; i++) {
    for (int j = 0; j < 1000; j++) {
      int64_t sa = gojou.at(i) - gojou.at(j);
      int64_t wa = gojou.at(i) + gojou.at(j);

      if (sa != 0 && x % sa == 0) {
        a = i;
        b = j;
        break;
      }
      if (wa != 0 && x % wa == 0) {
        a = i;
        b = (-1) * j;
        break;
      }
    }
  }

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


Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 100) >= this->size() (which is 100)


Fixed submission:

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

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

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

  vector<int64_t> gojou(100);
  for (int i = 0; i < 100; i++) {
    gojou.at(i) = pow(i, 5);
  }

  // cout << sosuu.at(1);

  int64_t a, b;

  for (int i = 0; i < 200; i++) {
    for (int j = 0; j < 200; j++) {
      int64_t sa = gojou.at(i) - gojou.at(j);
      int64_t wa = gojou.at(i) + gojou.at(j);

      if (sa != 0 && x % sa == 0) {
        a = i;
        b = j;
        break;
      }
      if (wa != 0 && x % wa == 0) {
        a = i;
        b = (-1) * j;
        break;
      }
    }
  }

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

#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

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

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


Error: TLE

Fixed submission:

#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

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

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sz(s) (int)(s.size())
#define all(v) v.begin(), v.end()
#define endl "\\n"
using namespace std;
ll gcd(ll x, ll y) { return (!y) ? x : gcd(y, x % y); }
void Run() {

  // freopen("mex.in", "r", stdin);
#ifndef ONLINE_JUDGE
  // freopen("in.txt", "r", stdin); freopen("outt.txt", "w", stdout);
#endif
}

inline ll pp(ll a) {
  ll start = -1000, end = 1000, mid;
  while (start <= end) {

    mid = (start + end) / 2;
    if (mid * mid * mid * mid * mid == a)
      return mid;
    else if (mid * mid * mid * mid * mid > a) {
      end = mid - 1;
    } else if (mid * mid * mid * mid * mid < a) {
      start = mid + 1;
    }
  }
  return -1;
}
int main() {
  // Run();
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = -1000; i <= 1000; i++) {
    ll a = pow(i, 5) - n;
    ll b = pp(a);
    if (pow(i, 5) - pow(b, 5) == n) {
      cout << i << " " << b;
      return 0;
    }
  }
}

Error: TLE

Fixed submission:

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sz(s) (int)(s.size())
#define all(v) v.begin(), v.end()
#define endl "\\n"
using namespace std;
ll gcd(ll x, ll y) { return (!y) ? x : gcd(y, x % y); }
void Run() {

  // freopen("mex.in", "r", stdin);
#ifndef ONLINE_JUDGE
  // freopen("in.txt", "r", stdin); freopen("outt.txt", "w", stdout);
#endif
}

inline ll pp(ll a) {
  ll start = -1000, end = a, mid;
  while (start <= end) {

    mid = (start + end) / 2;
    if (mid * mid * mid * mid * mid == a)
      return mid;
    else if (mid * mid * mid * mid * mid > a) {
      end = mid - 1;
    } else if (mid * mid * mid * mid * mid < a) {
      start = mid + 1;
    }
  }
}
int main() {
  // Run();
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = -1000; i <= 1000; i++) {
    ll a = pow(i, 5) - n;
    ll b = pp(a);
    if (pow(i, 5) - pow(b, 5) == n) {
      cout << i << " " << b;
      return 0;
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define sz(c) int(c.size())
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define per(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define fore(c, ...) for (auto __VA_ARGS__ : (c))
using namespace std;
typedef long long ll;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);

  auto solve = [](int X) {
    rep(a, -1000, 1001) rep(b, -1000, 1001) {
      ll A = (ll)a * a * a * a * a;
      ll B = (ll)b * b * b * b * b;
      if (A - B == X) {
        cout << a << " " << b << endl;
        return true;
      }
    }
    return false;
  };

  // solve(31);
  // return 0;

  // rep(x,1,(int)1e9+1) {
  // if (solve(x)) {
  // cout<<x<<" ";
  // cout<<endl;
  // }
  // }

  int X;
  cin >> X;
  solve(X);
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define sz(c) int(c.size())
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define per(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define fore(c, ...) for (auto __VA_ARGS__ : (c))
using namespace std;
typedef long long ll;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);

  auto solve = [](int X) {
    rep(i, 0, 1001) {
      ll a = (ll)i * i * i * i * i;
      ll b = a - X;
      ll j = (ll)pow((long double)abs(b), 1.0 / 5.0);
      while ((ll)(j + 1) * (j + 1) * (j + 1) * (j + 1) * (j + 1) <= abs(b))
        j++;
      if (b < 0)
        j = -j;
      if (j == b) {
        cout << i << " " << j << '\\n';
        return;
      }
    }
    cerr << X << endl;
    assert(false);
  };

  // solve(3);
  // return 0;

  // rep(x,1,(int)1e9+1) solve(x);

  int X;
  cin >> X;
  solve(X);
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

void solve() {
  int X;
  cin >> X;

  for (int A = 0; A < 120; A++) {
    for (int B = -120; B < A; B++) {
      if ((pow(A, 5) - pow(B, 5)) == X) {
        cout << A << " " << B << endl;
        return;
      }
    }
  }
}

int main() {
  solve();
  return 0;
}

Error: TLE

Fixed submission:

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

vector<int> divisor(int n) {
  vector<int> ret;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end()); // 昇順に並べる
  return ret;
}

void solve() {
  int X;
  cin >> X;
  vector<int> div = divisor(X);

  for (int i = 0; i < div.size(); i++) {
    int d = div[i];
    for (int a = 0; a < d; a++) {
      int b = a - d;
      if ((powf(a, 5) - powf(b, 5)) == X) {
        cout << a << " " << b << endl;
        return;
      }
    }
  }
}

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

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

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

  int A, B;
  for (int i = -1000; i <= 1000; i++) {
    for (int j = -1000; j < 1000; j++) {
      if (pow(i, 5) - pow(j, 5) == X) {
        A = i;
        B = j;
      }
    }
  }

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

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

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

  int n = pow(10, 8);
  int B_5, A;
  double B;
  bool conv = false;
  repi(i, 1, n) {
    B_5 = pow(i, 5) - X;
    if (B_5 < 0) {
      B_5 *= -1;
      conv = true;
    }
    B = pow(B_5, 0.2);
    if (B == floor(B)) {
      A = i;
      break;
    }
  }

  if (conv)
    B *= -1;

  cout << A << " " << B << endl;
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define MOD 1000000007

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

  vector<ll> el = {};
  for (ll i = 0; i <= 3000; i++) {
    el.push_back(i * i * i * i * i);
  }

  for (ll i = 0; i < el.size(); i++) {
    for (ll j = 0; j < el.size(); j++) {
      ll ii = i, jj = j;
      if (el[i] - el[j] == x) {
        cout << ii << " " << jj << endl;
        return 0;
      } else if (el[i] + el[j] == x) {
        cout << ii << " " << -jj << endl;
        return 0;
      } else if (-el[i] - el[j] == x) {
        cout << -ii << " " << jj << endl;
        return 0;
      } else if (-el[i] + el[j] == x) {
        cout << -ii << " " << -jj << endl;
        return 0;
      }
    }
  }

  return 0;
}


Error: -11

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define MOD 1000000007

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

  ll cnt = 0;
  vector<ll> el = {};
  for (auto i = 0; i <= 100; i++) {
    el.push_back(i * i * i * i * i);
  }

  for (auto i = 0; i < el.size(); i++) {
    for (auto j = 0; i < el.size(); j++) {
      ll ii = i, jj = j;
      if (el[i] - el[j] == x) {
        cout << ii << " " << jj << endl;
        return 0;
      } else if (el[i] + el[j] == x) {
        cout << ii << " " << -jj << endl;
        return 0;
      } else if (-el[i] - el[j] == x) {
        cout << -ii << " " << jj << endl;
        return 0;
      } else if (-el[i] + el[j] == x) {
        cout << -ii << " " << -jj << endl;
        return 0;
      }
    }
  }

  return 0;
}