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

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

int main() {
  long long x;
  cin >> x;
  bool ok = false;
  for (long long i = 0; i <= 150; i++) {
    for (long long j = -150; j <= 150; j++) {
      if (i * i * i * i * i - j * j * j * j * j == x) {
        cout << i << " " << j << endl;
        ok = true;
        break;
      }
    }
    if (ok)
      break;
  }
}

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


Fixed submission:

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

const ll mod = 1000000007;
int n;
Graph G(1000001);
int seen[10000000];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int m;
  cin >> n >> m;
  vector<ll> H(n);
  rep(i, n) { cin >> H.at(i); }
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    bool ok = true;
    for (auto nv : G.at(i)) {
      if (H.at(nv) > H.at(i)) {
        ok = false;
        break;
      }
      if (ok) {
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/05/02.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//  ABC165
//
//

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, x, n) for (int i = x; i < (n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const int MOD = 1000000007;
// #define __DBG__

void solve(void) {

  ll X;

  cin >> X;

  ll Aans = 0;
  ll Bans = 0;

  REP2(A, -120, 120) {
    REP2(B, -120, 120) {
      if (A * A * A * A * A - B * B * B * B * B == X) {
        Aans = A;
        Bans = B;
        break;
      }
    }
  }

  cout << Aans << " " << Bans << endl;
  return;
}

#define TESTCASES 1

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);

  REP(i, TESTCASES) { solve(); }

  return 0;
}


Error: TLE

Fixed submission:

//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/05/02.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//  ABC165
//
//

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, x, n) for (int i = x; i < (n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const int MOD = 1000000007;
// #define __DBG__

void solve(void) {

  ll X;

  cin >> X;

  ll Aans = 0;
  ll Bans = 0;

  REP2(A, -100, 1000000) {
    REP2(B, -100, 10000) {
      if (A * A * A * A * A - B * B * B * B * B == X) {
        Aans = A;
        Bans = B;
        break;
      }
    }
  }

  cout << Aans << " " << Bans << endl;
  return;
}

#define TESTCASES 1

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);

  REP(i, TESTCASES) { solve(); }

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

#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <math.h>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

long long combi(long long n, long long k) {
  if (n == k || k == 0)
    return 1;
  else {
    return combi(n - 1, k - 1) + combi(n - 1, k);
  }
}

long long gcd(int a, int b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}

int main() {
  long long X;
  cin >> X;
  int A = 10000, B = 10000;

  for (long long i = 0; i <= 1000; i++) {
    for (long long j = 0; j <= 1000; j++) {
      if (X == pow(i, 5) + pow(j, 5)) {
        A = i;
        B = j;
        break;
      }
    }
  }
  if (A != 10000 && B != 10000) {
    cout << A << " " << B * (-1) << endl;
    return 0;
  }

  for (int i = 0; i <= 1000; i++) {
    for (int j = 0; j <= 1000; j++) {
      if (X == pow(i, 5) - pow(j, 5)) {
        A = i;
        B = j;
        break;
      }
    }
  }
  if (A != 10000 && B != 10000) {
    cout << A << " " << B << endl;
    return 0;
  }
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <math.h>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

long long combi(long long n, long long k) {
  if (n == k || k == 0)
    return 1;
  else {
    return combi(n - 1, k - 1) + combi(n - 1, k);
  }
}

long long gcd(int a, int b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}

int main() {
  long long X;
  cin >> X;
  int A = 100000, B = 100000;

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

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

int main() {
  long range = 120;
  long x;

  cin >> x;

  for (long i = -range; i <= range; ++i) {
    for (long j = -range; j <= range; ++j) {
      if (pow(i, 5) - pow(j, 5) == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}


Error: TLE

Fixed submission:

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

__inline__ bool isCorrect(long a, long b, long c) { return a - b == c; }

int main() {
  long x;
  cin >> x;
  long a, b;
  bool found = false;

  for (long i = 0; i < LONG_MAX; ++i) {
    long a5 = pow(i, 5);

    for (long j = 0; j < LONG_MAX; ++j) {
      long b5 = pow(j, 5);

      if (b5 > x)
        break;

      if (isCorrect(a5, b5, x)) {
        a = i;
        b = j;
        found = true;
        break;
      }

      if (isCorrect(a5, -b5, x)) {
        a = i;
        b = -j;
        found = true;
        break;
      }
    }

    if (found)
      break;
  }

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

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

int main() {
  // your code goes here

  ll x;
  cin >> x;
  for (int a = 0; a < 1000; a++) {
    for (int b = -1000; b < 1000; b++) {
      ll A = pow(a, 5);
      ll B = pow(b, 5);
      if (A - B == x) {
        cout << a << " " << b;
        return 0;
      }
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  // your code goes here

  ll x;
  cin >> x;
  if (x == 1) {
    cout << 0 << " " << -1;
    return 0;
  }
  vector<pair<int, int>> v;
  for (int i = 2; i <= sqrt(x); i++) {
    if (x % i == 0) {
      v.push_back({i, x / i});
    }
  }
  for (int i = 0; i < v.size(); i++) {
    ll sum = v[i].first;
    ll a = 0, b = a - sum;
    while (a > b) {
      // cout<<a<<" "<<b<<"\\n";

      if (pow(a, 4) + pow(b, 4) + pow(a, 3) * b + pow(b, 3) * a +
              pow(a, 2) * pow(b, 2) ==
          v[i].second) {
        cout << a << " " << b;
        return 0;
      }
      a++;
      b = a - sum;
    }
  }

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

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

template <typename _Ty> _Ty bpow(_Ty a, int64_t n) {
  _Ty res = 1;
  for (; n > 0; n >>= 1) {
    if (n & 1)
      res *= a;
    a *= a;
  }
  return res;
}

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

  ll mx = 6209;

  Vl pow5(mx);
  for (ll i = 0; i < mx; i++) {
    pow5[i] = bpow(i, 5);
  }

  ll a, b;
  b = 0;
  while (true) {
    ll idx =
        lower_bound(pow5.begin(), pow5.end(), X + bpow(b, 5)) - pow5.begin();
    if (bpow(idx, 5) - bpow(b, 5) == X) {
      a = idx;
      break;
    }

    idx = lower_bound(pow5.begin(), pow5.end(), X - bpow(b, 5)) - pow5.begin();
    if (bpow(idx, 5) + bpow(b, 5) == X) {
      a = idx;
      b = -b;
      break;
    }

    ++b;
  }

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

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
  cin.tie(0), cout.tie(0);
  ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
  ifstream ifs("./in_out/input.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
  ofstream ofs("./in_out/output.txt");
  cout.rdbuf(ofs.rdbuf());
#endif
  solve();
  cout << flush;
  return 0;
}

Error: TLE

Fixed submission:

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

template <typename _Ty> _Ty bpow(_Ty a, int64_t n) {
  _Ty res = 1;
  for (; n > 0; n >>= 1) {
    if (n & 1)
      res *= a;
    a *= a;
  }
  return res;
}

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

  Vl pow5(101);
  for (ll i = 0; i < 101; i++) {
    pow5[i] = bpow(i, 5);
  }

  ll a, b;
  b = 0;
  while (true) {
    ll idx =
        lower_bound(pow5.begin(), pow5.end(), X + bpow(b, 5)) - pow5.begin();
    if (bpow(idx, 5) - bpow(b, 5) == X) {
      a = idx;
      break;
    }

    idx = lower_bound(pow5.begin(), pow5.end(), X - bpow(b, 5)) - pow5.begin();
    if (bpow(idx, 5) + bpow(b, 5) == X) {
      a = idx;
      b = -b;
      break;
    }

    ++b;
  }

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

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
  cin.tie(0), cout.tie(0);
  ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
  ifstream ifs("./in_out/input.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
  ofstream ofs("./in_out/output.txt");
  cout.rdbuf(ofs.rdbuf());
#endif
  solve();
  cout << flush;
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, N) for (ll(i) = 0; (i) < (N); (i)++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1001001001;

ll f(ll a, ll b) { return pow(a, 5) - pow(b, 5); }

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

  for (ll i = -1000; i <= 1000; ++i) {
    for (ll j = -1000; j <= 1000; ++j) {
      ll value = f(i, j);
      if (value == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  // rep(i, 1001) {
  //   cout << pow(i, 5) - pow(i - 1, 5) << endl;
  // }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, N) for (ll(i) = 0; (i) < (N); (i)++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1001001001;

ll f(ll a, ll b) { return pow(a, 5) - pow(b, 5); }

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

  for (ll i = -10000; i <= 10000; ++i) {
    for (ll j = -10000; j <= 10000; ++j) {
      ll value = f(i, j);
      if (value == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep1(i, n) for (ll i = 1; i <= n; i++)
#define all(n) n.begin(), n.end()
#define yn(x) cout << (x ? "Yes" : "No") << endl;

ll gozyou(ll n) {
  ll a = 1;
  rep1(i, 5) a *= n;
  return a;
}

int main() {
  ll x, a, b;
  cin >> x;
  for (ll i = -199; i < 200; i++) {
    for (ll k = -199; k < 200; k++) {

      if (gozyou(i) - gozyou(k) == x) {
        a = i;
        b = k;
        break;
      }
    }
  }
  cout << a << " " << b << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep1(i, n) for (ll i = 1; i <= n; i++)
#define all(n) n.begin(), n.end()
#define yn(x) cout << (x ? "Yes" : "No") << endl;

ll gozyou(ll n) {
  ll a = 1;
  rep1(i, 5) a *= n;
  return a;
}

int main() {
  ll x, a, b;
  cin >> x;
  rep(i, 1000) rep1(k, x) {
    if (x % k == 0 && gozyou(i) - gozyou(i - x / k) == x) {
      a = i;
      b = i - x / k;
      break;
    }
  }
  cout << a << " " << b << endl;
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <stdio.h>
using namespace std;
long long x, i, j, a, b;
int main() {
  cin >> x;
  for (i = 0; i <= 1000; i++) {
    for (j = -1000; j <= 1000; j++) {
      a = i * i * i * i * i;
      b = j * j * j * j * j;
      if (a - b == x) {
        printf("%lld %lld\\n", i, j);
        return 0;
      }
    }
  }
  return 0;
}


Error: -11

Fixed submission:

#include <iostream>
#include <stdio.h>
using namespace std;
long long a[5000], x;
int main() {
  for (long long i = -1000; i <= 1000; i++) {
    a[i + 100] = i * i * i * i * i;
  }
  cin >> x;
  for (int i = 0; i <= 2000; i++) {
    for (int j = 0; j <= 2000; j++) {
      long long sum = a[i] - a[j];
      if (sum == x) {
        printf("%d %d\\n", i, j);
        return 0;
      }
    }
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Runtime Error

#define _GLIBCXX_DEBUG
#include <cstdint>
#include <iostream>
#include <vector>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
i64 p5(i64 x) { return x * x * x * x * x; }

int main(void) {
  i64 x;
  cin >> x;
  vi P5(120);
  for (i64 i = 1; i < 120; i++)
    P5[i] = p5(i);
  for (i64 a = 1; true; a++) {
    i64 a5 = P5[a];
    for (i64 b = -a; b < a; b++) {
      i64 b5 = (b < 0 ? -P5[-b] : P5[b]);
      if (a5 - b5 == x) {
        cout << a << ' ' << b << '\\n';
        return 0;
      }
    }
  }
  return 0;
}

Error: 0

Fixed submission:

#define _GLIBCXX_DEBUG
#include <cstdint>
#include <iostream>
#include <vector>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
i64 p5(i64 x) { return x * x * x * x * x; }

int main(void) {
  i64 x;
  cin >> x;
  vi P5(68);
  for (i64 i = 1; i < 68; i++)
    P5[i] = p5(i);
  for (i64 a = 1; true; a++) {
    i64 a5 = P5[a];
    for (i64 b = -a; b < a; b++) {
      i64 b5 = (b < 0 ? -P5[-b] : P5[b]);
      if (a5 - b5 == x) {
        cout << a << ' ' << b << '\\n';
        return 0;
      }
    }
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x;
  cin >> x;
  for (long long int i = 0; i < 200; i++) {
    for (long long int j = -200; j < 200; j++) {
      if (i * i * i * i * i - j * j * j * j * j == x) {
        cout << i << ' ' << j << '\\n';
        return 0;
      }
    }
  }
}

Error: TLE

Fixed submission:

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x;
  cin >> x;
  for (int i = 1;; i++) {
    long long a = i * i * i * i * i;
    long long n = abs(a - x);
    for (int j = n % 10;; j += 10) {
      if (j * j * j * j * j < n) {
        continue;
      }
      if (j * j * j * j * j == n) {
        if (a - x < 0)
          j *= -1;
        cout << i << ' ' << j << '\\n';
        return 0;
      }
      if (j * j * j * j * j > n) {
        break;
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <math.h>
#define formula(a, b)                                                          \\
  a *a *a *a + a *a *a *b + a *a *b *b + a *b *b *b + b *b *b *b

using namespace std;

int main(void) {
  int X, a, b1, b2;

  cin >> X;

  for (a = 0;; ++a) {
    for (b1 = b2 = 0; b1 < a; ++b1, --b2) {
      if (X % (a - b1) == 0) {
        if ((X / (a - b1)) == formula(a, b1)) {
          printf("%d %d", a, b1, formula(a, b1));
          return 0;
        }
      }
      if (X % (a - b2) == 0) {
        if ((X / (a - b2)) == formula(a, b2)) {
          printf("%d %d", a, b2, formula(a, b2));
          return 0;
        }
      }
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
#include <math.h>

using namespace std;

int main(void) {
  int X, a, b1, b2;

  cin >> X;

  for (a = 0;; ++a) {
    for (b1 = b2 = 0; b1 < a; ++b1, --b2) {
      if (abs(X / (a - b1)) < 1E-8) {
        if ((int)(X / (a - b1)) == pow(a, 4) + b1 * pow(a, 3) +
                                       pow(a, 2) * pow(b1, 2) + a * pow(b1, 3) +
                                       pow(b1, 4)) {
          printf("%d %d\\n", a, b1);
          return 0;
        }
      }
      if (abs(X / (a - b2)) < 1E-8) {
        if ((int)(X / (a - b2)) == pow(a, 4) + b2 * pow(a, 3) +
                                       pow(a, 2) * pow(b2, 2) + a * pow(b2, 3) +
                                       pow(b2, 4)) {
          printf("%d %d\\n", a, b2);
          return 0;
        }
      }
    }
  }
  return 0;
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

using llong = long long;
using namespace std;

llong gojosa(llong n, llong m) {
  llong ans = n * n * n * n * n - m * m * m * m * m;
  return ans;
}

int main() {
  llong x;
  cin >> x;
  for (llong a = 0; a <= 120; a++)
    for (llong b = -120; b <= 120; b++) {
      if (gojosa(a, b) == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

using llong = long long;
using namespace std;

llong gojo(llong n) {
  llong ans = n * n * n * n * n;
  return ans;
}

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

#include <cmath>
#include <iostream>

using namespace std;

int main(void) {
  int X;

  cin >> X;

  for (int a = 1; a < 1000; a++) {
    long A = pow(a, 5);
    for (int b = -1000; b < 1000; b++) {
      long B = pow(b, 5);
      if (A - B == X) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>

using namespace std;

int main(void) {
  uint X;

  cin >> X;

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

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

#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long X, A, B;
  cin >> X;
  for (A = -150; A <= 150; A++) {
    for (B = -150; B <= 150; B++) {
      if (pow(A, 5) - pow(B, 5) == X) {
        cout << A << " " << B << endl;
        return 0;
      }
    }
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long X, A, B;
  cin >> X;
  for (A = 0; A <= 100000; A++) {
    for (B = -A; B <= 0; B++) {
      if (pow(A, 5) - pow(B, 5) == X) {
        cout << A << " " << B << endl;
        return 0;
      }
    }
  }
}
Problem p02690 (C++) — buggy submission, verdict: Time Limit Exceeded

#pragma warning(disable : 4996)
#include <bits/stdc++.h>
// #pragma GCC optimize(2)
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-12;
#define For(i, n, m) for (int i = n; i <= m; ++i)
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define per(i, l, r) for (int i = l; i >= r; --i)
#define clr(a, b) memset(a, b, sizeof(a))

inline ll ksm(ll a, ll b) {
  ll res(1);
  while (b) {
    if (b & 1)
      res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}
ll x;
ll a[100000][2];
int main() {
  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  ll cnt(0);

  a[0][0] = 0, a[0][1] = 0;
  for (int i = 1;; ++i) {
    ll k = ksm(i, 5);
    //	cout << k << "\\n";
    if (k > 2e18)
      break;
    a[++cnt][0] = k, a[cnt][1] = i;
    a[++cnt][0] = -k, a[cnt][1] = -i;
  }
  // rep(i, 0, cnt) cout << a[i][1] << " " << a[i][0] << "\\n";

  cin >> x;
  rep(i, 0, cnt) {
    ll k = a[i][0] - x;
    rep(j, 0, cnt) {
      if (a[j][0] == k) {
        cout << a[i][1] << " " << a[j][1] << "\\n";
        return 0;
      }
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#pragma warning(disable : 4996)
#include <bits/stdc++.h>
// #pragma GCC optimize(2)
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-12;
#define For(i, n, m) for (int i = n; i <= m; ++i)
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define per(i, l, r) for (int i = l; i >= r; --i)
#define clr(a, b) memset(a, b, sizeof(a))

inline ll ksm(ll a, ll b) {
  ll res(1);
  while (b) {
    if (b & 1)
      res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}
ll x;
map<ll, ll> s;
int main() {
  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  for (int i = 1;; ++i) {
    ll k = ksm(i, 5);
    if (k > 1e9)
      break;
    s[k] = i;
  }
  for (int i = -1;; --i) {
    ll k = ksm(i, 5);
    if (k < -1e9)
      break;
    s[k] = i;
  }
  cin >> x;
  if (s[x] != 0) {
    cout << s[x] << " " << 0 << "\\n";
  } else {
    for (int i = 1;; ++i) {
      ll k = ksm(i, 5);
      if (s[k - x] != 0) {
        cout << i << " " << s[k - x] << "\\n";
        return 0;
      }
    }
  }
  return 0;
}