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

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++(i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++(i))
#define REP_R(i, n) for (int i = (int)(n)-1; (i) >= 0; --(i))
#define REP3R(i, m, n) for (int i = (int)(n)-1; (i) >= (int)(m); --(i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;

pair<int64_t, int64_t> solve(int64_t x) {
  map<int64_t, int64_t> f;
  for (int64_t a = 0;; ++a) {
    f[a * a * a * a * a] = a;
    f[-a * a * a * a * a] = -a;
    if (a * a * a * a * a >= 1e15)
      break;
  }
  for (auto [b5, b] : f) {
    auto it = f.find(x + b5);
    if (it != f.end()) {
      return {it->second, b};
    }
  }
  assert(false);
}

// generated by online-judge-template-generator v4.1.0
// (https://github.com/kmyk/online-judge-template-generator)
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  constexpr char endl = '\\n';
  int64_t X;
  cin >> X;
  auto [A, B] = solve(X);
  cout << A << ' ' << B << endl;
  return 0;
}


Error: -6
7c58695c-66bb-4789-9d44-1ebd16f8ae27.out: /home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02690/C++/s989211629.cpp:22: std::pair<long int, long int> solve(int64_t): Assertion `false' failed.


Fixed submission:

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++(i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++(i))
#define REP_R(i, n) for (int i = (int)(n)-1; (i) >= 0; --(i))
#define REP3R(i, m, n) for (int i = (int)(n)-1; (i) >= (int)(m); --(i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;

pair<int64_t, int64_t> solve(int64_t x) {
  map<int64_t, int64_t> f;
  for (int64_t a = 1;; ++a) {
    f[a * a * a * a * a] = a;
    if (a * a * a * a * a >= 1e15)
      break;
  }
  for (auto [b5, b] : f) {
    auto it = f.find(x + b5);
    if (it != f.end()) {
      return {it->second, b};
    }
  }
  assert(false);
}

// generated by online-judge-template-generator v4.1.0
// (https://github.com/kmyk/online-judge-template-generator)
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  constexpr char endl = '\\n';
  int64_t X;
  cin >> X;
  auto [A, B] = solve(X);
  cout << A << ' ' << B << endl;
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <utility>
#include <vector>

using namespace std;
struct aaa {
  aaa() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  };
} aaa;
template <class T> ostream &operator<<(ostream &o, const vector<T> &v) {
  o << "{";
  for (int i = 0; i < (int)v.size(); i++)
    o << (i > 0 ? ", " : "") << v[i];
  o << "}";
  return o;
}
#define debug(v)                                                               \\
  { cerr << "\\033[1;36m[debug]\\033[m " << #v << " : " << v << endl; }

using int64 = long long;

inline int64 _5(int64 x) { return x * x * x * x * x; }

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

  int64 a = -118;
  int64 b = -119;
  for (; a <= 119; a++) {
    int64 a5 = _5(a);
    b = -119;
    int64 b5 = 0;
    for (; b <= 118; b++) {
      b5 = _5(b);
      if (a5 - b5 == x)
        break;
    }
    if (a5 - b5 == x)
      break;
  }

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

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <utility>
#include <vector>

using namespace std;
struct aaa {
  aaa() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  };
} aaa;
template <class T> ostream &operator<<(ostream &o, const vector<T> &v) {
  o << "{";
  for (int i = 0; i < (int)v.size(); i++)
    o << (i > 0 ? ", " : "") << v[i];
  o << "}";
  return o;
}
#define debug(v)                                                               \\
  { cerr << "\\033[1;36m[debug]\\033[m " << #v << " : " << v << endl; }

using int64 = long long;

inline int64 _5(int64 x) { return x * x * x * x * x; }

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

  int64 a = 1;
  int64 b = 0;
  for (a = -sqrt(x) - 1; a <= sqrt(x) + 1; a++) {
    int64 a5 = _5(a);
    b = 0;
    int64 b5 = 0;
    for (b = -sqrt(x) - 1; b <= sqrt(x) + 1; b++) {
      b5 = _5(b);
      if (a5 - b5 == x)
        break;
    }
    if (a5 - b5 == x)
      break;
  }

  cout << a << " " << b << endl;
}
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 rrep(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
using ll = long long;

int main() {
  int x;
  cin >> x;
  for (int i = -119; i <= 120; i++) {
    for (int j = -120; j < i; j++) {
      int y = pow(i, 5) - pow(j, 5);
      if (x == y) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  ll x;
  cin >> x;
  for (ll i = -10; i < 10; i++) {
    for (ll j = -x; j < x; j++) {
      if (i == j || x % (i - j) != 0)
        continue;
      else if (i * i * i * i * i - j * j * j * j * j == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  cout << "error" << endl;
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;
const long long INF = 1LL << 60;

int main() {
  int X;
  cin >> X;
  bool owari = 0;
  for (int i = -120; i <= 120; i++) {
    for (int j = -120; j <= 120; j++) {
      long long A = pow(i, 5);
      long long B = pow(j, 5);
      if (A - B == X) {
        cout << i << " " << j << endl;
        owari = 1;
        break;
      }
    }
    if (owari)
      break;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;
const long long INF = 1LL << 60;

int main() {
  int X;
  cin >> X;
  bool owari = 0;
  for (int i = -10000; i <= 10000; i++) {
    for (int j = -10000; j <= 10000; j++) {
      int A = pow(i, 5);
      int B = pow(j, 5);
      if (A - B == X) {
        cout << i << " " << j << endl;
        owari = 1;
        break;
      }
    }
    if (owari)
      break;
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

#define rep(i, N) for (ll i = 0; i < N; i++)

using ll = long long;
using namespace std;

int main() {
  ll X;
  cin >> X;
  ll aA = 0, aB = 0;

  bool flag = false;
  for (int i = -120; i < 120; i++) {
    for (int j = -120; j < 120; j++) {
      int num = i * i * i * i * i - j * j * j * j * j;
      if (num == X) {
        aA = i;
        aB = j;
        flag = true;
        break;
      }
    }
    if (flag)
      break;
  }

  cout << aA << " " << aB;
  cout << "\\n";
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N - 1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define MOD 1000000007

using ll = long long;
using namespace std;

typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<P> vpi;
typedef pair<ll, ll> Pl;
typedef vector<ll> vl;
typedef vector<Pl> vpl;

ll gcd(ll a, ll b) {
  if (a < b)
    swap(a, b);
  if (b <= 0)
    return -1;
  ll r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

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

int main() {
  int X, ans = 0;
  cin >> X;
  double rX = pow(X, 0.5);

  ll aA = 0, aB = 0;

  bool flag = false;
  for (ll A = 1; A < 1e9; A++) {
    ll k_b = -1 * (ll)rX;
    for (ll B = k_b; B < 1e9; B++) {
      ll num = A * A * A * A * A - B * B * B * B * B;
      if (num == X) {
        flag = true;
        aA = A;
        aB = B;
        break;
      }
      if (num < X) {
        k_b = B - 1;
        break;
      }
    }
    if (flag)
      break;
  }

  // string ans = ( flag ? "Yes" : "No" );
  // printf("%.8lf", ans);
  cout << aA << " " << aB;
  cout << "\\n";
  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() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  // freopen("mex.in", "r", stdin);
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("outt.txt", "w", stdout);
#endif
}
const int N = 1e5 + 10;
map<ll, ll> m;
void fillmap() {
  for (ll i = -1000; i <= 1000; i++) {
    m[i * i * i * i * i] = i;
  }
}
int main() {
  Run();
  fillmap();
  int n;
  cin >> n;
  for (ll i = -1000; i <= 1000; i++) {
    ll a = pow(i, 5) - n;
    ll b = m[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() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  // freopen("mex.in", "r", stdin);
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("outt.txt", "w", stdout);
#endif
}
const int N = 1e5 + 10;
int f[N];
int e[N];
ll pp(ll a) {
  for (int i = -1000; i < 1000; i++) {
    if (i * i * i * i * i == a)
      return i;
  }
}
int main() {
  Run();
  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: 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() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  // freopen("mex.in", "r", stdin);
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("outt.txt", "w", stdout);
#endif
}
const int N = 1e5 + 10;
int f[N];
int e[N];
inline ll pp(ll a) {
  ll start = -500, end = 500, 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 0;
}
int main() {
  Run();
  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 = -100, 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 = -100; i <= 100; 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"
using namespace std;
typedef long long ll;
#define db(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\\n'
const int N = 1e6;

int main() {
  ios_base::sync_with_stdio(0);
  ll a, b, n, x, T, cas = 0;
  cin >> x;
  a = 0, b = 0;
  for (ll i = -1000; i <= 1000; ++i) {
    ll p = i * i * i * i * i;
    ll q = p - x;
    ll t = q;
    // cerr<<p<<" "<<q;
    int neg = 0;
    if (q < 0) {
      neg = 1;
      q *= -1;
    }
    ll r = pow(q, 1.0 / 5);
    if (neg)
      r *= -1;
    // cerr<<r<<endl;
    if (r * r * r * r * r == t) {
      a = i, b = r;
      // if(neg) b*=-1;
      break;
    }
  }
  if (a == 0 && b == 0)
    assert(a != 0);
  cout << a << " " << b << endl;
  return 0;
}

Error: WA

Fixed submission:

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define db(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\\n'
const int N = 1e6;

int main() {
  ios_base::sync_with_stdio(0);
  ll a, b, n, x, T, cas = 0;
  cin >> x;
  a = 0, b = 0;
  for (ll i = -100; i <= 100; ++i) {
    ll p = i * i * i * i * i;
    ll q = p - x;
    ll t = q;
    // cerr<<p<<" "<<q;
    int neg = 0;
    if (q < 0) {
      neg = 1;
      q *= -1;
    }
    ll r = pow(q, 1.0 / 5);
    if (neg)
      r *= -1;
    // cerr<<r<<endl;
    if (r * r * r * r * r == t) {
      a = i, b = r;
      // if(neg) b*=-1;
      break;
    }
  }
  if (a == 0 && b == 0)
    assert(a != 0);
  cout << a << " " << b << endl;
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

Error: TLE

Fixed submission:

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

#include <bits/stdc++.h>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;
// int choose2(ll x){
//	return x*(x-1)/2;}
const int INF = 1001001001;

int main() {
  int A, B;
  ll X, tmp;
  cin >> X;
  A = 0;
  int flug = 0;
  rep(i, 100) {
    rep(j, i) {
      if ((i * i * i * i * i + j * j * j * j * j) == X) {
        flug = 1;
        A = i;
        B = j * (-1);
        break;
      }
    }
  }
  while (flug == 0) {
    A++;
    B = A - 1;
    tmp = 0;
    while (flug == 0) {
      tmp = (A + B) * (A * A * A + B * B * B) + A * A * B * B;
      if ((X % tmp == 0) && ((X / tmp) == (A - B))) {
        flug = 1;
        break;
      }
      if (B <= 1)
        break;
      else
        B--;
    }
  }

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

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;
// int choose2(ll x){
//	return x*(x-1)/2;}
const int INF = 1001001001;

int main() {
  int A, B;
  ll X, tmp;
  cin >> X;
  A = 0;
  int flug = 0;
  rep(i, 100) {
    rep(j, i) {
      if ((i * i * i * i * i + j * j * j * j * j) == X) {
        flug = 1;
        A = i;
        B = j * (-1);
        break;
      }
    }
  }
  while (flug == 0) {
    A++;
    B = 0;
    tmp = 0;
    while (tmp < (X / (A - B))) {
      tmp = (A + B) * (pow(A, 3) + pow(B, 3)) + A * A * B * B;
      if ((X % tmp == 0) && (X / tmp == A - B)) {
        flug = 1;
        break;
      }
      if (B >= A - 1)
        break;
      else
        B++;
    }
  }

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

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

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

  int i = 1;
  ll a, b;
  bool flag = false;
  map<ll, ll> fiveset;
  fiveset[0] = 0;

  for (;;) {
    a = pow(i, 5);
    if (fiveset.find(a - x) != fiveset.end()) {
      ll j = fiveset[a - x];
      cout << i << " " << j << endl;
      break;
    } else if (fiveset.find(-a + x) != fiveset.end()) {
      ll j = fiveset[-a + x];
      cout << i << " " << -j << endl;
      break;
    }
    fiveset[a] = i;
    i++;
  }
}

Error: TLE

Fixed submission:

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

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

  int i = 1;
  ll a, b;
  bool flag = false;
  while (true) {
    a = pow(i, 5);

    for (ll j = 1; j < i; j++) {
      b = pow(j, 5);
      if (a - b == x) {
        cout << i << " " << j << endl;
        flag = true;
      }
      if (a + b == x) {
        cout << i << " " << -j << endl;
        flag = true;
      }
      if (flag)
        break;
    }
    if (flag)
      break;
    i += 1;
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define P pair<long long, long long>

using namespace std;

int main() {
  long long x;
  cin >> x;
  for (long long i = -1000; i <= 1000; i++) {
    for (long long j = -1000; j <= 1000; j++) {
      long long value = i * i * i * i * i - j * j * j * j * j;
      if (value == x) {
        cout << i << ' ' << j << endl;
        return 0;
      }
    }
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define P pair<long long, long long>

using namespace std;

int main() {
  long long x;
  cin >> x;
  map<long long, P> mp;
  for (long long i = -1000; i <= 1000; i++) {
    for (long long j = -1000; j <= 1000; j++) {
      P p = P(i, j);
      long long value = i * i * i * i * i - j * j * j * j * j;
      mp[value] = p;
    }
  }
  cout << mp[x].first << ' ' << mp[x].second << endl;
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
const long long N = 9000;
long long arr[N] = {};
int main() {
  long long x;
  cin >> x;
  if (x == 0) {
    cout << "0 0\\n";
    return 0;
  }
  if (x == 1) {
    cout << "1 0\\n";
    return 0;
  }
  long long a, b;
  for (long long i = 1; i < N; i++)
    for (long long j = i + 1; j < N; j++) {
      a = j, b = i;
      long long t = a * a + b * b;
      if (a != b && x % (a - b) == 0)
        if (x / (a - b) - t * t == a * b * (t - a * b)) {
          cout << a << " " << b;
          return 0;
        }
      a = j, b = -i;
      if (x % (a - b) == 0)
        if (x / (a - b) - t * t == a * b * (t - a * b)) {
          cout << a << " " << b;
          return 0;
        }
    }
  return -1;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const long long N = 9000;
long long arr[N] = {};
int main() {
  long long x;
  cin >> x;
  if (x == 0) {
    cout << "0 0\\n";
    return 0;
  }
  long long a, b;
  for (long long i = 1; i < N; i++)
    for (long long j = i + 1; j < N; j++) {
      a = j, b = i;
      long long t = a * a + b * b;
      if (a != b && x % (a - b) == 0)
        if (x / (a - b) - t * t == a * b * (t - a * b)) {
          cout << a << " " << b;
          return 0;
        }
      a = j, b = -i;
      if (x % (a - b) == 0)
        if (x / (a - b) - t * t == a * b * (t - a * b)) {
          cout << a << " " << b;
          return 0;
        }
    }
  return -1;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
int main() {
  long long n;
  scanf("%lld", &n);
  for (long long i = -1003; i <= 1003; i++)
    for (long long j = -1003; j <= 1003; j++)
      if (i * i * i * i * i - j * j * j * j * j == n) {
        printf("%lld %lld", i, j);
        return 0;
      }
  return 0;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
using namespace std;
int main() {
  long long x;
  cin >> x;
  for (long long i = -10; i <= 100000; i++)
    for (long long j = -10; j <= 100000; j++)
      if (i * i * i * i * i - j * j * j * j * j == 5)
        cout << i << ' ' << j, exit(0);
  return 0;
}
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;
typedef long long ll;

int solve(long long X) {
  vector<ll> vals;
  ll i = 0;
  for (ll i = 0; i < 150; i++) {
    ll val = pow(i, 5);
    vals.push_back(val);
  }
  // rep(i, vals.size())
  //     cout << vals[i] << " ";
  // cout << endl;
  for (ll i = 0; i < vals.size(); i++) {
    for (ll j = 0; j < vals.size(); j++) {
      // cout << i << " " << j << endl;
      if (vals[i] - vals[j] == X) {
        cout << i << " " << j << endl;
        return 0;
      } else if (vals[i] + vals[j] == X) {
        cout << i << " " << -j << endl;
        return 0;
      }
    }
  }
}

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


Error: WA

Fixed submission:

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

int solve(long long X) {
  vector<ll> vals;
  ll i = 0;
  while (1) {
    ll val = pow(i, 5);
    if (val <= 2 * X)
      vals.push_back(val);
    else
      break;
    i++;
  }
  // rep(i, vals.size())
  //     cout << vals[i] << " ";
  cout << endl;
  for (ll i = 0; i < vals.size(); i++) {
    for (ll j = 0; j < vals.size(); j++) {
      // cout << i << " " << j << endl;
      if (vals[i] - vals[j] == X) {
        cout << i << " " << j << endl;
        return 0;
      } else if (vals[i] + vals[j] == X) {
        cout << i << " " << -j << endl;
        return 0;
      }
    }
  }
}

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