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

#include <bits/stdc++.h>

#define FOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000            // 2000000000
#define LLINF 1000000000000000000 // 9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

int main(void) {

  while (1) {
    int e;
    bool flag = true;
    int mini = INF;

    cin >> e;
    if (e == 0) {
      break;
    }
    RFOR(z, cbrt(e) + 1, 0) {
      if (pow(z, 3) > e) {
        continue;
      }
      RFOR(y, sqrt(e - pow(z, 3)) + 1, 0) {
        if (pow(y, 2) > e - pow(z, 3)) {
          continue;
        }

        if (mini > z + y + e - pow(z, 3) - pow(y, 2)) {
          mini = z + y + e - pow(z, 3) - pow(y, 2);
        }
        break;
      }
    }
    cout << mini << endl;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define FOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000            // 2000000000
#define LLINF 1000000000000000000 // 9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

int main(void) {

  while (1) {
    int e;
    bool flag = true;
    int mini = INF;

    cin >> e;
    if (e == 0) {
      break;
    }
    RFOR(z, cbrt(e), 0) {
      if (pow(z, 3) > e) {
        continue;
      }
      RFOR(y, sqrt(e - pow(z, 3)), 0) {
        if (pow(y, 2) < e - pow(z, 3) - pow(y, 2)) {
          if (mini > z + y + e - pow(z, 3) - pow(y, 2)) {
            mini = z + y + e - pow(z, 3) - pow(y, 2);
          }
          break;
        }
        if (pow(y, 2) > e - pow(z, 3)) {
          continue;
        }
        if (pow(y, 2) == e - pow(z, 3)) {
          mini = z + y;
          flag = false;
          break;
        } else {
          if (mini > z + y + e - pow(z, 3) - pow(y, 2)) {
            mini = z + y + e - pow(z, 3) - pow(y, 2);
          }
        }
      }
      if (flag == false) {
        break;
      }
    }
    cout << mini << endl;
  }
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

int main() {

  int e;

  while (cin >> e, e) {

    int x, y, z, m = 1 << 24;

    for (z = 0; z * z * z <= e; ++z) {
      y = floor(sqrt(e - z * z * z));
      m = min(m, (e - y * y - z * z * z) + y + z);
    }

    cout << m << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <cmath>

using namespace std;

int main() {

  int e, m;

  while (cin >> e, e) {

    m = e;

    for (int x = 0; x <= e; ++x) {
      for (int y = 0; y <= pow(e - x, 1.0 / 1.9999999999); ++y) {
        for (int z = 0; z <= pow(e - x - y * y, 1.0 / 2.9999999999); ++z) {
          if (x + y * y + z * z * z == e) {
            m = min(m, x + y + z);
          }
        }
      }
    }

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

#include <cmath>
#include <iostream>

int main() {
  int x, e;
  int sum_min;

  while (std::cin >> e && e > 0) {
    sum_min = 100000000;
    for (int i = 0; i * i <= e; i++) {
      for (int j = 0; j * j * j <= e - i * i; j++) {
        x = e - i * i - j * j * j;
        if (x >= 0 && x + i + j < sum_min) {
          sum_min = x + i + j;
        }
      }
    }
    std::cout << sum_min << '\\n';
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>

int main() {
  int x, e;
  int y_max, z_max = 0;
  int sum_min;

  while (std::cin >> e && e > 0) {
    y_max = static_cast<int>(std::sqrt(e));
    z_max = static_cast<int>(std::pow(e, 1.0 / 3.0));
    sum_min = e + y_max + z_max;
    for (int i = 0; i <= y_max; i++) {
      for (int j = 0; j <= z_max; j++) {
        x = e - std::pow(i, 2) - std::pow(j, 3);
        if (x >= 0 && x + i + j < sum_min) {
          sum_min = x + i + j;
        }
      }
    }
    std::cout << sum_min << '\\n';
    sum_min = e + y_max + z_max;
  }
  return 0;
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>

using namespace std;

#define MAX_N 128;

int ans;

int main() {
  int e;

  int ans = 100000000;
  ;
  int temp = 10000000;

  while (cin >> e && e) {
    ans = 100000;
    for (int z = 0; z <= 100; ++z) {
      for (int y = 0; y <= 1000; ++y) {

        int m = (e - y * y - z * z * z) + y * y + z * z * z;
        if (m == e) {
          int x = e - y * y - z * z * z;
          if (x < 0) {
            break;
          }
          temp = x + y + z;
          if (ans > temp) {
            ans = temp;
          }
        }
      }
    }
    cout << ans << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>

using namespace std;

#define MAX_N 128;

int ans;

int main() {
  int e;

  int ans = 100000000;
  ;
  int temp = 10000000;

  while (cin >> e && e) {
    ans = 100000;
    for (int z = 0; z <= 100; ++z) {
      for (int y = 0; y <= 1000; ++y) {

        int m = (e - pow(y, 2) - pow(z, 3)) + pow(y, 2) + pow(z, 3);
        if (m == e) {
          int x = e - pow(y, 2) - pow(z, 3);
          if (x < 0) {
            break;
          }
          temp = x + y + z;
          if (ans > temp) {
            ans = temp;
          }
        }
      }
    }
    cout << ans << endl;
  }
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iostream>

using namespace std;

int main() {
  int hyou[102];
  for (int i = 0; i < 102; i++) {
    hyou[i] = i * i * i;
  }
  int e;
  while (cin >> e) {
    if (e == 0) {
      break;
    }
    int a, b, c;
    for (int i = 1;; i++) {
      if (hyou[i] > e) {
        c = i - 1;
        break;
      }
    }
    for (int i = 1;; i++) {
      if (i * i > e - hyou[c]) {
        b = i - 1;
        break;
      }
    }
    for (int i = 1;; i++) {
      if (i > e - hyou[c] - b * b) {
        a = i - 1;
        break;
      }
    }
    int MIN = a + b + c;
    for (int i = c - 1; i >= 0; i--) {
      for (int j = b + 1;; j++) {
        if (j * j > e - hyou[i]) {
          b = j - 1;
          break;
        }
      }
      int q = e - hyou[i] - b * b;
      MIN = min(MIN, b + q + i);
    }
    cout << MIN << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>

using namespace std;

int main() {
  int hyou[101];
  for (int i = 0; i < 101; i++) {
    hyou[i] = i * i * i;
  }
  int e;
  while (cin >> e) {
    if (e == 0) {
      break;
    }
    int a, b, c;
    for (int i = 1;; i++) {
      if (hyou[i] > e) {
        c = i - 1;
        break;
      }
    }
    for (int i = 1;; i++) {
      if (i * i > e - hyou[c]) {
        b = i - 1;
        break;
      }
    }
    for (int i = 1;; i++) {
      if (i > e - hyou[c] - b * b) {
        a = i - 1;
        break;
      }
    }
    int MIN = a + b + c;
    for (int i = 0;; i++) {
      if (i >= MIN) {
        break;
      }
      for (int j = 0;; j++) {
        if (i + j >= MIN) {
          break;
        }
        for (int k = 0; k <= c; k++) {
          if (i + j * j + hyou[k] == e) {
            MIN = min(MIN, i + j + k);
          } else if (i + j * j + hyou[k] > e) {
            break;
          }
        }
      }
    }
    cout << MIN << endl;
  }
  return 0;
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
int main() {
  while (1) {
    long long int num, ans = 10000000;
    cin >> num;
    if (!num)
      break;
    for (long long int y = 0; y * y <= num; y++) {
      for (long long int z = 0; z * z * z + y * y <= num; z++) {
        long long int x = num - z * z * z - y * y;
        ans = min(ans, (x + y + z));
      }
    }
    cout << ans << endl;
  }
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
using ll = long long;
int main(void) {
  while (1) {
    ll num, ans = 1000000;
    cin >> num;
    if (!num)
      break;
    for (ll y = 0; pow(y, 2) <= num; y++) {
      for (ll z = 0; pow(z, 3) + pow(y, 2) <= num; z++) {
        ll x = num - y * y - z * z * z;
        if (x < 0)
          break;
        ans = min(ans, x + y + z);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n;
  while (cin >> n, n) {
    int ans = 1 << 30;
    for (int i = 0; i * i * i <= n; i++) {
      int j = sqrt(n - i * i * i);
      if (n < i * i * i + j * j)
        continue;
      ans = min(ans, i + j + (n - i * i * i - j * j));
    }
    cout << ans << endl;
  }
}

Error: TLE

Fixed submission:

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

int main() {
  int n;
  while (cin >> n, n) {
    int ans = 1000000;
    for (int i = 0; i < 1000; i++) {
      if (n < pow(i, 2))
        break;
      for (int j = 0; j < 100; j++) {
        if (n - pow(i, 2) - pow(j, 3) < 0)
          continue;
        ans = min(ans, i + j + (int)(n - pow(i, 2) - pow(j, 3)));
      }
    }
    cout << ans << endl;
  }
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int inf = 1000000000;

int main(void) {

  int e;
  while (cin >> e) {
    if (e == 0)
      break;
    int ans = 10000000;
    for (int z = 0; z * z * z <= e; z++) {
      for (int y = 0; z * z * z + y * y <= e; y++) {
        int x = e - z * z * z - y * y;
        if (x >= 0) {
          ans = min(ans, x + y + z);
        }
      }
    }
    cout << ans << endl;
  }

  return 0;
}

// EOF

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int inf = 1000000000;

int main(void) {

  int e;
  while (cin >> e) {
    if (e == 0)
      break;
    int ans = 10000000;
    for (int z = 0; z * z * z <= e; z++) {
      for (int y = 0; z * z * z + y <= e; y++) {
        int x = e - z * z * z - y * y;
        if (x >= 0) {
          ans = min(ans, x + y + z);
        }
      }
    }
    cout << ans << endl;
  }

  return 0;
}

// EOF
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define range(i, s, n) for (int i = s; i < n; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9 + 7)
#define PI 3.1415926535897932384

template <class T> ostream &operator<<(std::ostream &o, const vector<T> &v) {
  rep(i, v.size()) { o << (i > 0 ? " " : "") << v[i]; }
  return o;
}

int main() {
  int e, n = 1000000;
  while (1) {
    cin >> e;
    int mi = INF;
    if (e == 0)
      break;
    for (int i = 0; i * i * i <= e; i++) {
      for (int j = 0; j * j <= (e - i * i * i); j++) {
        if (j * j + i * i * i > e)
          break;
        int x = e - (j * j + i * i * i);
        if (mi > (i + j + x)) {
          mi = i + j + x;
        }
      }
    }
    cout << mi << endl;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define range(i, s, n) for (int i = s; i < n; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9 + 7)
#define PI 3.1415926535897932384

template <class T> ostream &operator<<(std::ostream &o, const vector<T> &v) {
  rep(i, v.size()) { o << (i > 0 ? " " : "") << v[i]; }
  return o;
}

int main() {
  int e, n = 1000000;
  while (1) {
    cin >> e;
    int mi = INF;
    if (e == 0)
      break;
    for (int i = 0; i <= e; i++) {
      for (int j = 0; j * j <= (e - i * i * i); j++) {
        if (j * j + i * i * i > e)
          break;
        int x = e - (j * j + i * i * i);
        if (mi > (i + j + x)) {
          mi = i + j + x;
        }
      }
    }
    cout << mi << endl;
  }
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int E;

int main() {

  while (cin >> E) {
    if (E == 0)
      break;
    int min = 100000001;
    for (int z = 0; z * z * z < E + 1; ++z) {
      for (int y = 0; y * y < E - z * z * z + 1; ++y) {
        int x = E - z * z * z - y * y;
        if (x + y + z < min)
          min = x + y + z;
      }
    }
    cout << min << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int E;

int main() {

  while (cin >> E && E > 0) {
    int min = 1000001;
    for (int z = 0; z < E; ++z) {
      for (int y = 0; y * y < E - z * z * z; ++y) {
        int x = E - z * z * z - y * y;
        if (x + y + z < min)
          min = x + y + z;
      }
    }
    cout << min << endl;
  }
  return 0;
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  while (true) {
    const int e = [] {
      int e;
      cin >> e;
      return e;
    }();
    if (e == 0) {
      return 0;
    }

    int min_ = 1'000'000 + 1;
    for (int z = 0; z * z * z <= e; ++z) {
      for (int y = 0; y * y + z * z * z <= e; ++y) {
        int x = e - z * z * z - y * y;
        if (x >= 0) {
          min_ = min(min_, x + y + z);
        }
      }
    }
    cout << min_ << endl;
  }
}


Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  while (true) {
    int e;
    cin >> e;
    if (e == 0) {
      return 0;
    }
    auto r = [e] {
      for (int m = 0; true; ++m) {
        for (int i = 0; i < m; ++i) {
          for (int j = 0; j < m - i + 1; ++j) {
            for (int k = 0; k < m - i - j + 1; ++k) {
              if (i + j * j + k * k * k == e) {
                return m;
              }
            }
          }
        }
      }
    }();
    cout << r << endl;
  }
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {

  int e, cpy;

  while (cin >> e && e) {

    int m = INT_MAX;

    for (int i = 0; i * i <= e; i++) {
      for (int j = 0; j * j * j <= e; j++) {
        cpy = e - i * i - j * j * j;
        if (e == i * i + j * j * j + cpy && cpy >= 0) {
          m = min(m, i + j + cpy);
        }
      }
    }
    cout << m << endl;
  }
}

Error: TLE

Fixed submission:

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

int main() {

  int e, cpy;

  while (cin >> e && e) {

    int m = INT_MAX;

    for (int i = 0; i <= sqrt(e); i++) {
      for (int j = 0; j <= pow(e, 1.0 / 3.0); j++) {
        cpy = e - i * i - j * j * j;
        if (e == pow(i, 2) + pow(j, 3) + (double)cpy && cpy >= 0) {
          m = min(m, i + j + cpy);
        }
      }
    }
    cout << m << endl;
  }
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {

  while (1) {
    int e;
    cin >> e;
    if (!e)
      break;
    /*
    int mini = e;
    for(int x=0; x<=e; x++){
              for(int y=0; y*y<=e; y++){
                            for(int z=0; z*z*z<=e; z++){
                                      if(x + y*y + z*z*z == e)
                                                    mini = min(mini,x+y+z);
                            }

              }
    }
    */
    int mini = e;
    for (int z = 0; z * z * z <= e; z++) {
      for (int y = 0; z * z * z + y * y <= e; y++) {
        int x = e - z * z * z - y * y;
        mini = min(mini, x + y + z);
      }
    }

    cout << mini << endl;
  }
}

Error: TLE

Fixed submission:

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

int main() {

  while (1) {
    int e;
    cin >> e;
    if (!e)
      break;

    int mini = e;
    for (int x = 0; x <= e; x++) {
      for (int y = 0; y * y <= e; y++) {
        for (int z = 0; z * z * z <= e; z++) {
          if (x + y * y + z * z * z == e)
            mini = min(mini, x + y + z);
        }
      }
    }
    cout << mini << endl;
  }
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int e, minx, x, y, z;
  while (cin >> e && e) {
    if (e == 1)
      cout << 1 << endl;
    else {
      minx = 1000001;
      for (z = 0; z * z * z <= e; z++) {
        y = (int)sqrt(e - z * z * z);
        x = e - z * z * z - y * y;
        minx = min(minx, x + y + z);
      }
      cout << minx << endl;
    }
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int e, min;
  while (cin >> e && e) {
    if (e == 1)
      cout << 1 << endl;
    else {
      min = 1000001;
      for (int i = 0; i <= e; i++) {
        for (int j = 0; j <= e - i * i * i; j++) {
          for (int k = 0; k <= e - i * i * i - j * j; k++) {
            if (i * i * i + j * j + k == e) {
              if (min > i + j + k)
                min = i + j + k;
            }
          }
        }
      }
      cout << min << endl;
    }
  }
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cctype>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>

using namespace std;

int main(int argc, char const *argv[]) {
  int e;
  while (cin >> e, e) {
    int x, y, z;
    int m = 1000000;

    // for (int i = 0; i <= e; i++)
    //{
    //     for (int j = 0; j*j <= e; j++)
    //     {
    //         for (int k = 0; k*k*k <= e; k++)
    //         {
    //             //cout << " x y z = " << i << j << k <<endl;
    //             if ( i + j*j + k*k*k == e)
    //             {
    //                 m = min( m, i + j + k);
    //             }
    //         }
    //     }
    // }
    for (int k = 0; k * k * k <= e; k++) {
      int j = sqrt(e - k * k * k);
      int i = e - k * k * k - j * j;
      m = min(m, i + j + k);
    }
    cout << m << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cctype>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>

using namespace std;

int main(int argc, char const *argv[]) {
  int e;
  while (cin >> e, e) {
    int x, y, z;
    int m = 1000000;

    // for (int i = 0; i <= e; i++)
    //{
    //     for (int j = 0; j*j <= e; j++)
    //     {
    //         for (int k = 0; k*k*k <= e; k++)
    //         {
    //             //cout << " x y z = " << i << j << k <<endl;
    //             if ( i + j*j + k*k*k == e)
    //             {
    //                 m = min( m, i + j + k);
    //             }
    //         }
    //     }
    // }
    for (int k = 0; 0 <= k * k * k; k++) {
      int j = sqrt(e - k * k * k);
      int i = e - k * k * k - j * j;
      m = min(m, i + j + k);
    }
    cout << m << endl;
  }
  return 0;
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cctype>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>

using namespace std;

int main(int argc, char const *argv[]) {
  int e;
  while (cin >> e, e) {
    int x, y, z;
    int m = 1000000;

    // for (int i = 0; i <= e; i++)
    //{
    //     for (int j = 0; j*j <= e; j++)
    //     {
    //         for (int k = 0; k*k*k <= e; k++)
    //         {
    //             //cout << " x y z = " << i << j << k <<endl;
    //             if ( i + j*j + k*k*k == e)
    //             {
    //                 m = min( m, i + j + k);
    //             }
    //         }
    //     }
    // }
    for (int k = 0; k * k * k <= e; k++) {
      int j = sqrt(e - k * k * k);
      int i = e - k * k * k - j * j;
      m = min(m, i + j + k);
    }
    cout << m << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cctype>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repi(i, l, n) for (int(i) = (int)(l); (i) < (int)(n); (i)++)
#define d_arr(arr, h, w)                                                       \\
  rep(i, (h)) {                                                                \\
    cout << "[";                                                               \\
    rep(j, (w)) { cout << (arr)[i][j] << ", "; }                               \\
    cout << "]" << endl;                                                       \\
  }

typedef pair<int, int> P;

class Coordinates {
public:
  int x;
  int y;

  Coordinates() {
    x = 0;
    y = 0;
  };
  Coordinates(int a, int b) {
    x = a;
    y = b;
  }

  Coordinates operator+(Coordinates p) {
    Coordinates tmp;
    tmp.x = x + p.x;
    tmp.y = y + p.y;
    return tmp;
  }

  friend bool operator==(const Coordinates a, const Coordinates b) {
    return (a.x == b.x && a.y == b.y);
  }
  friend bool operator<(const Coordinates a, const Coordinates b) {
    return (a.x < b.x && a.y < b.y);
  }
  friend bool operator<=(const Coordinates a, const Coordinates b) {
    return (a.x <= b.x && a.y <= b.y);
  }
};

typedef Coordinates Coo;

int main() {
  int e;
  while (cin >> e, e) {
    int least = 1000000;
    // puts("enter while");
    int x, y, z;
    for (int i = 0; i * i * i <= e; i++) {
      for (int j = 0; j * j <= e - i * i * i; j++) {
        for (int k = 0; k <= e - i * i * i - j * j; k++) {
          if (i * i * i + j * j + k == e && least > i + j + k) {
            least = i + j + k;
            // cout << "(i,j,k) = " << i <<" "<< j <<" "<<  k << endl;
          }
        }
      }
    }
    cout << least << endl;
  }
}