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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 2147483647;
inline ll read() {
  ll x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
const int maxn = 3e3 + 5;
ll x, a[maxn];
int main() {
  x = read();
  for (int i = 1; i <= 3000; i++)
    a[i] = (ll)i * i * i * i * i;
  for (int i = 0; i <= 3000; i++)
    for (int j = 0; j <= 3000; j++) {
      if (a[i] + a[j] == x) {
        printf("%d %d\\n", i, -j);
        return 0;
      }
      if (a[i] - a[j] == x) {
        printf("%d %d\\n", i, j);
        return 0;
      }
    }
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 2147483647;
inline ll read() {
  ll x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
const int maxn = 3e3;
ll x, a[maxn];
int main() {
  x = read();
  for (int i = 1; i <= maxn; i++)
    a[i] = (ll)i * i * i * i * i;
  for (int i = 0; i <= maxn; i++)
    for (int j = 0; j <= maxn; j++) {
      if (a[i] + a[j] == x) {
        printf("%d %d\\n", i, -j);
        return 0;
      }
      if (a[i] - a[j] == x) {
        printf("%d %d\\n", i, j);
        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 a, b;
  a = 0;
  long long fiveb;
  while (true) {
    fiveb = pow(a, 5) - x;
    int flag = 0;
    b = a - 1;
    long long tmp = abs(fiveb);
    while ((fiveb >= 0 && abs(fiveb) - abs(pow(b, 5)) <= 0) or
           (fiveb < 0 && abs(fiveb) - abs(pow(b, 5)) >= 0)) {
      if (fiveb == pow(b, 5)) {
        flag = 1;
        break;
      }
      --b;
    }
    if (flag == 1) {
      break;
    }
    a++;
  }
  cout << a << " " << b << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  long long x;
  cin >> x;
  int a, b;
  a = 0;
  long long fiveb;
  while (true) {
    fiveb = pow(a, 5) - x;
    int flag = 0;
    long long tmp;
    b = a - 1;
    while (abs(fiveb) - abs(pow(b, 5)) >= 0) {
      if (fiveb == pow(b, 5)) {
        flag = 1;
        break;
      }
      --b;
    }
    if (flag == 1) {
      break;
    }
    a++;
  }
  cout << a << " " << b << endl;
}
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(x) (x).begin(), (x).end()
typedef long long ll;
const int INF(1 << 30);

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

  vector<ll> p5(500);
  rep(i, 500) { p5[i] = pow(i, 5); }

  rep(a, 500) {
    rep(b, 500) {
      if (p5[a] + p5[b] == x) {
        cout << a << " " << -b << endl;
        return 0;
      } else if (p5[a] - p5[b] == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int INF(1 << 30);

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

  rep(i, 100) {
    if (pow(i, 5) == x) {
      cout << i << " " << 0 << endl;
      return 0;
    } else if (pow(i, 5) > x) {
      int a5 = pow(i - 1, 5);
      int j = 1;
      int tmpx = a5 + pow(j, 5);
      while (tmpx <= x) {
        if (tmpx == x) {
          cout << i - 1 << " " << -j << endl;
          return 0;
        }
        j++;
        tmpx = a5 + pow(j, 5);
      }

      a5 = pow(i, 5);
      j = 1;
      tmpx = a5 - pow(j, 5);
      while (true) {
        if (tmpx == x) {
          cout << i << " " << j << endl;
          return 0;
        }
        j++;
        tmpx = a5 - pow(j, 5);
      }
    }
  }

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long X, A, B;
  cin >> X;
  for (long long i = -200; i < 200; i++) {
    for (long long j = -200; j < 200; j++) {
      A = i * i * i * i * i;
      B = j * j * j * j * j;
      if (A - B == X) {
        cout << i << " " << j << endl;
        goto as;
      }
    }
  }
as:
  cout << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long X, A, B;
  cin >> X;
  for (int i = 0; i < 10000000; i++) {
    for (int j = i - 65; j < i + 1000; j++) {
      A = i * i * i * i * i;
      B = j * j * j * j * j;
      if (A - B == X) {
        cout << i << " " << j << endl;
        goto as;
      }
    }
  }
as:
  cout << endl;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

#define NREP() for (ll i = 0; i < n; i++)
#define MREP() for (ll j = 0; j < m; j++)
#define REP(i, n) for (ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x)                                                              \\
  t ipt;                                                                       \\
  cin >> ipt;                                                                  \\
  x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
  cin >> x;

  for (ll a = -1e3; a <= 1e3; ++a) {
    for (ll b = -1e3; b <= 1e3; ++b) {
      ll a5 = pow(a, 5);
      ll b5 = pow(b, 5);
      if (a5 - b5 == x) {
        MSG(to_string(a) + " " + to_string(b))
        exit(0);
      }
    }
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define NREP() for (ll i = 0; i < n; i++)
#define MREP() for (ll j = 0; j < m; j++)
#define REP(i, n) for (ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x)                                                              \\
  t ipt;                                                                       \\
  cin >> ipt;                                                                  \\
  x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
  cin >> x;
  for (ll b = 0; b <= x; ++b) {
    ll a5 = pow(b, 5) + x;
    double a = pow((double)a5, 0.2);
    if (ceil(a) == floor(a)) {
      MSG(to_string((ll)a) + " " + to_string((ll)b))
      exit(0);
    }

    b = -b;
    a5 = pow(b, 5) + x;
    a = pow((double)a5, 0.2);
    if (ceil(a) == floor(a)) {
      MSG(to_string((ll)a) + " " + to_string((ll)b))
      exit(0);
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long int x;
  cin >> x;

  long long int a, b;

  for (int i = -118; i <= 119; i++) {
    a = pow(i, 5);
    for (int j = -119; j <= 118; j++) {
      b = pow(j, 5);
      if (a - b == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

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

using namespace std;

int main(void) {
  int x;
  cin >> x;
  int a, b;
  long double c;
  int n = 0;
  while (true) {
    b = pow(n, 5);
    c = pow(x + b, 0.2);
    a = pow(x + b, 0.2);
    if (a == c) {
      cout << a << " " << n << endl;
      return 0;
    }
    b = pow(-n, 5);
    c = pow(x + b, 0.2);
    a = pow(x + b, 0.2);
    if (a == c) {
      cout << a << " " << -n << endl;
      return 0;
    }
    n++;
  }

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

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (int)1e9 + 7
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define vi vector<int>
ll xpow(ll a, ll b) {
  if (b == 0)
    return 1;
  if (b % 2 == 0) {
    ll k = pow(a, b / 2);
    return k * k;
  }
  if (b % 2 != 0)
    return a * pow(a, b - 1);
}
int main() {

#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
  fio;
  ll x;
  cin >> x;
  for (int i = -200; i <= 200; i++) {
    for (int j = -200; j <= 200; j++) {
      if (xpow(i, 5) - xpow(j, 5) == x) {
        cout << i << " " << j;
        return 0;
      }
    }
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (int)1e9 + 7
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define vi vector<int>
ll xpow(ll a, ll b) {
  if (b == 0)
    return 1;
  if (b % 2 == 0) {
    ll k = pow(a, b / 2);
    return k * k;
  }
  if (b % 2 != 0)
    return a * pow(a, b - 1);
}
int main() {

#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
  fio;
  ll x;
  cin >> x;
  ll a = (ll)pow(x, 0.2);
  ll b = a;
  for (;; b--) {
    if (xpow(a, 5) - xpow(b, 5) == x) {
      break;
    }
  }
  cout << a << " " << b;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i, n) for (i = 0; i < n; ++i)
#define repp(i, a, n) for (i = a; i < n; ++i)
#define repr(i, a, n) for (i = a; i >= n; --i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

ll binpowmod(ll a, ll b, ll m) {
  a %= m;
  ll res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}

ll binpow(ll a, ll b) {
  ll res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}

ll modInverse(ll n, ll p) { return binpowmod(n, p - 2, p); }

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll t, m, n, i, f = 0, j, ans = 0, k, x;
  cin >> x;
  ll temp;
  vector<ll> v;
  v.pb(0);
  for (i = 1; i <= 1e5; ++i) {
    temp = pow(i, 5);
    v.pb(temp);
    v.pb(-1 * temp);
  }
  sort(v.begin(), v.end());
  double h;
  for (i = 0; i <= 1e5; ++i) {
    temp = x - pow(i, 5);
    // cout << temp << endl ;
    if (binary_search(v.begin(), v.end(), temp)) {
      if (temp > 0) {
        h = pow(temp, 0.2);
        // cout << h << endl ;
        ans = h;
        ans *= -1;
        cout << i << " " << ans;
      } else {
        temp *= -1;
        h = pow(temp, 0.2);
        // cout << h << endl ;
        ans = h;
        // ans*=-1;
        cout << i << " " << ans;
      }
      return 0;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i, n) for (i = 0; i < n; ++i)
#define repp(i, a, n) for (i = a; i < n; ++i)
#define repr(i, a, n) for (i = a; i >= n; --i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

ll binpowmod(ll a, ll b, ll m) {
  a %= m;
  ll res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}

ll binpow(ll a, ll b) {
  ll res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}

ll modInverse(ll n, ll p) { return binpowmod(n, p - 2, p); }

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll t, m, n, i, f = 0, j, ans = 0, k, x;
  cin >> x;
  ll temp;
  f = 0;
  double h;
  f = 1e8;
  for (i = 0; i < f; ++i) {
    temp = x - pow(i, 5);
    h = pow(temp, 0.2);
    ans = h;
    if (floor(h) == ceil(h)) {
      cout << ans << " " << -1 * i;
      return 0;
    }
  }
  for (i = 0; i < f; ++i) {
    temp = x + pow(i, 5);
    h = pow(temp, 0.2);
    ans = h;
    if (floor(h) == ceil(h)) {
      cout << ans << " " << i;
      return 0;
    }
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

// std::cout << std::fixed << std::setprecision(10)
// std::ios::sync_with_stdio(false);
constexpr long long MOD = 1000000007;

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};

int main() {
  long long X;
  std::cin >> X;
  long long N = std::sqrt(X) + 1;
  long long A, B;
  auto sqrt5 = [](long long x) {
    long long l = 1, r = x + 1;
    while (l + 1 < r) {
      long long mid = (l + r) / 2;
      long long y2 = mid * mid;
      long long y3 = y2 * mid;
      long long y4 = y3 * mid;
      long long y5 = y4 * mid;
      if (x <= y2 || x <= y3 || x <= y4 || x < y5)
        r = mid;
      else if (y5 == x)
        return mid;
      else
        l = mid;
    }
    return l;
  };
  for (long long i = 1; i <= N; ++i) {
    long long A5 = std::pow(i, 5LL);
    if (A5 == X) {
      A = i;
      B = 0;
      break;
    } else if (A5 < X) {
      auto sq5 = sqrt5(X - A5);
      if (std::pow(sq5, 5LL) == X - A5) {
        A = i;
        B = -sq5;
        break;
      }
    } else {
      auto sq5 = sqrt5(A5 - X);
      if (std::pow(sq5, 5LL) == A5 - X) {
        A = i;
        B = sq5;
        break;
      }
    }
  }
  std::cout << A << " " << B << std::endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

// std::cout << std::fixed << std::setprecision(10)
// std::ios::sync_with_stdio(false);
constexpr long long MOD = 1000000007;

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};

int main() {
  long long X;
  std::cin >> X;
  long long N = std::sqrt(X) + 1;
  long long A, B;
  auto sqrt5 = [](long long x) {
    long long l = 1, r = x + 1;
    while (l + 1 < r) {
      long long mid = (l + r) / 2;
      long long y = mid * mid * mid * mid * mid;
      if (y == x)
        return mid;
      else if (y < x)
        l = mid;
      else
        r = mid;
    }
    return l;
  };
  for (long long i = 1; i <= N; ++i) {
    long long A5 = std::pow(i, 5LL);
    if (A5 == X) {
      A = i;
      B = 0;
      break;
    } else if (A5 < X) {
      auto sq5 = sqrt5(X - A5);
      if (std::pow(sq5, 5LL) == X - A5) {
        A = i;
        B = -sq5;
        break;
      }
    } else {
      auto sq5 = sqrt5(A5 - X);
      if (std::pow(sq5, 5LL) == A5 - X) {
        A = i;
        B = sq5;
        break;
      }
    }
  }
  std::cout << A << " " << B << std::endl;
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
int main() {
  int X;
  while (scanf("%d", &X) != 0) {
    for (long long A = 0; A < 120; A++)
      for (long long B = -120; B < A; B++)
        if (A * A * A * A * A - B * B * B * B * B == X)
          return printf("%lld %lld\\n", A, B), 0;
  }
}

Error: 5

Fixed submission:

#include <stdio.h>
int main() {
  int X;
  while (scanf("%d", &X) != 0) {
    for (long long A = 0; A < 120; A++)
      for (long long B = -120; B < A; B++)
        if (A * A * A * A * A - B * B * B * B * B == X)
          return printf("%lld %lld\\n", A, B);
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define all(x) (x).begin, (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1 << 29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
  int X;
  cin >> X;
  for (int i = -118; i < 120; ++i) {
    for (int j = -119; j < 119; ++j) {
      if (X == (pow(i, 5) - pow(j, 5))) {
        cout << i << " " << j << endl;
        return;
      }
    }
  }
  return;
}
int main() {
  solve();
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define all(x) (x).begin, (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1 << 29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
  int X;
  cin >> X;
  int A, B;
  int TA;
  for (int i = 0; i < 1000000000; ++i) {
    A = (int)pow(i, 5);
    if (abs(X - A) == 1) {
      if (X - A == 1) {
        B = -1;
      } else if (X - A == -1) {
        B = 1;
      } else {
        B = 0;
      }
      TA = i;
      break;
    }
  }
  cout << TA << " " << B << endl;
  return;
}
int main() {
  solve();
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
long long xx5(long long i) { return i * i * i * i * i; }

int main() {
  long long x;
  cin >> x;
  long long a = 0, b = 0;
  for (a = -200; a <= 200; a++) {
    for (b = -200; b <= 200; b++) {
      if (xx5(a) - xx5(b) == x)
        goto OUT;
    }
  }
OUT:
  cout << a << " " << b << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
long long xx5(long long i) { return i * i * i * i * i; }

int main() {
  long long x;
  cin >> x;
  long long a = 0, b = 0;
  bool flag = true;

  b = -1;
  a = int(pow(x, 1 / 5)) + 1;
  while (flag) {
    while (xx5(a) - xx5(b) > x) {
      a--;
      // cout << xx5(a) - xx5(b) << endl;
    }
    while (xx5(a) - xx5(b) < x) {
      b -= 2;
      // cout << xx5(a) - xx5(b) << endl;
    }
    if (xx5(a) - xx5(b) == x)
      break;
  }

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

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 1; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main() {
  ll x;
  cin >> x;
  queue<ll> memo;
  ll karioki = sqrt(x);
  rep(i, karioki + 1) {
    if (x % i == 0) {
      memo.push(i);
    }
  }
  bool flag = false;
  while (memo.size() > 0) {
    ll a = memo.front();
    memo.pop();
    ll m1 = x / a;
    ll m2 = sqrt(m1);
    rep(i, m2 + 1) {
      if (x ==
          i * i * i * i * i - (i - a) * (i - a) * (i - a) * (i - a) * (i - a)) {
        cout << i << " " << i - a << endl;
        break;
        flag = false;
      }
      if (flag) {
        break;
      }
    }
  }
}

Error: TLE

Fixed submission:

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 1; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main() {
  ll x;
  cin >> x;
  queue<ll> memo;
  ll karioki = sqrt(x);
  rep(i, karioki + 1) {
    if (x % i == 0) {
      memo.push(i);
    }
  }
  bool flag = false;
  while (memo.size() > 0) {
    ll a = memo.front();
    memo.pop();
    ll m1 = x / a;
    rep(i, m1 + 1) {
      if (x ==
          i * i * i * i * i - (i - a) * (i - a) * (i - a) * (i - a) * (i - a)) {
        cout << i << " " << i - a << endl;
        break;
        flag = false;
      }
      if (flag) {
        break;
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  ll x;
  cin >> x;
  ll n = 0;
  ll tmp;
  do {
    n++;
    tmp = 5 * pow(n, 4) + 10 * pow(n, 3) + 10 * pow(n, 2) + 5 * n + 1;
  } while (tmp <= x);

  bool flag = true;
  bool pm = true;
  ll a = 0;
  ll b = 0;
  while (flag) {
    for (ll i = 1; i <= n + 1; i++) {
      ll tmp = pow(a, 5);
      if (tmp - pow((a + i), 5) == x) {
        b = a + i;
        flag = false;
        break;
      } else if (tmp - pow((a - i), 5) == x) {
        b = a - i;
        flag = false;
        break;
      }
    }
    a++;
  }
  cout << a - 1 << " " << b << endl;

  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  ll x;
  cin >> x;
  bool flag = true;
  bool pm = true;
  ll a = 0;
  ll b = 0;
  while (flag) {
    for (ll i = 1; i <= x; i++) {
      ll tmp = pow(a, 5);
      if (tmp - pow((a + i), 5) == x) {
        b = a + i;
        flag = false;
        break;
      } else if (tmp - pow((a - i), 5) == x) {
        b = a - i;
        flag = false;
        break;
      }
    }
    a++;
  }
  cout << a - 1 << " " << b << endl;

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

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main() {
  ll X;
  cin >> X;
  for (int i = 0; i < 1000; i++) {
    for (int k = 0; k < 1000; k++) {
      if ((i * i * i * i * i - k * k * k * k * k) == X) {
        cout << i << " " << k << endl;
        return 0;
      }
    }
  }
  for (int i = 0; i < 1000; i++) {
    for (int k = 0; k < 1000; k++) {
      if ((i * i * i * i * i + k * k * k * k * k) == X) {
        cout << i << " " << -k << endl;
        return 0;
      }
    }
  }
  return -1;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main() {
  ll X;
  cin >> X;
  vector<ll> rui;
  vector<ll> jou;
  rui.push_back(0);
  jou.push_back(0);
  for (int i = 1; i < 6000; i++) {
    ll kk = i * i * i * i * i;
    rui.push_back(kk);
    jou.push_back(-kk);
  }
  for (int i = 0; i < 6000; i++) {
    for (int k = 0; k < 6000; k++) {
      if ((rui[i] - rui[k]) == X) {
        if ((i * i * i * i * i - k * k * k * k * k) == X) {
          cout << i << " " << k << endl;
          return 0;
        }
      }
    }
  }
  for (int i = 0; i < 6000; i++) {
    for (int k = 0; k < 6000; k++) {
      if (rui[i] - jou[k] == X) {
        if ((i * i * i * i * i + k * k * k * k * k) == X) {
          cout << (i) << " " << -(k) << endl;
          return 0;
        }
      }
    }
  }
  return -1;
}