Problem p02690 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string.h>
#include <utility>
#include <vector>
#define s(n) scanf("%d", &n)
#define sc(n) scanf("%c", &n)
#define sl(n) scanf("%I64d", &n)
#define sf(n) scanf("%lf", &n)
#define ss(n) scanf("%s", n)
#define INF (int)1e9
#define EPS 1e-9
#define bitcount __builtin_popcount
#define gcd __gcd
#define forall(i, a, b) for (int i = a; i < b; i++)
#define foreach(v, c)                                                          \
  for (typeof((c).begin()) v = (c).begin(); v != (c).end(); ++v)
#define all(a) a.begin(), a.end()
#define in(a, b) ((b).find(a) != (b).end())
#define pb push_back
#define fill(a, v) memset(a, v, sizeof a)
#define sz(a) ((int)(a.size()))
#define mp make_pair
#define MOD 1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main() {
  vector<ll> powers;
  for (int i = 0; i <= 119; i++) {
    ll val = pow(i * 1ll, 5ll);
  }

  ll x;
  cin >> x;
  // first check for the sum
  for (int i = 0; i <= 119; i++) {
    for (int j = i; j >= 0; j--) {
      if (powers[i] + powers[j] == x) {
        cout << i << " " << -1 * j << endl;
        return 0;
      }

      if (powers[i] - powers[j] == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }

  return 0;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string.h>
#include <utility>
#include <vector>
#define s(n) scanf("%d", &n)
#define sc(n) scanf("%c", &n)
#define sl(n) scanf("%I64d", &n)
#define sf(n) scanf("%lf", &n)
#define ss(n) scanf("%s", n)
#define INF (int)1e9
#define EPS 1e-9
#define bitcount __builtin_popcount
#define gcd __gcd
#define forall(i, a, b) for (int i = a; i < b; i++)
#define foreach(v, c)                                                          \
  for (typeof((c).begin()) v = (c).begin(); v != (c).end(); ++v)
#define all(a) a.begin(), a.end()
#define in(a, b) ((b).find(a) != (b).end())
#define pb push_back
#define fill(a, v) memset(a, v, sizeof a)
#define sz(a) ((int)(a.size()))
#define mp make_pair
#define MOD 1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main() {
  vector<ll> powers;
  for (int i = 0; i <= 119; i++) {
    ll val = pow(i * 1ll, 5ll);
    powers.push_back(val);
  }

  ll x;
  cin >> x;
  // first check for the sum
  for (int i = 0; i <= 119; i++) {
    for (int j = i; j >= 0; j--) {
      if (powers[i] + powers[j] == x) {
        cout << i << " " << -1 * j << endl;
        return 0;
      }

      if (powers[i] - powers[j] == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }

  return 0;
}