Problem:
Space Coconut Crab
宇宙ヤシガニ
English text is not available in this practice contest.
ケン・マリンブルーは，宇宙ヤシガニを求めて全銀河を旅するスペースハンターである．宇宙ヤシガニは，宇宙最大とされる甲殻類であり，成長後の体長は 400 メートル以上，足を広げれば 1,000 メートル以上にもなると言われている．既に多数の人々が宇宙ヤシガニを目撃しているが，誰一人として捕らえることに成功していない．
ケンは，長期間の調査によって，宇宙ヤシガニの生態に関する重要な事実を解明した．宇宙ヤシガニは，驚くべきことに，相転移航法と呼ばれる最新のワープ技術と同等のことを行い，通常空間と超空間の間を往来しながら生きていた．さらに，宇宙ヤシガニが超空間から通常空間にワープアウトするまでには長い時間がかかり，またワープアウトしてからしばらくは超空間に移動できないことも突き止めた．
そこで，ケンはついに宇宙ヤシガニの捕獲に乗り出すことにした．戦略は次のとおりである．はじめに，宇宙ヤシガニが通常空間から超空間に突入する際のエネルギーを観測する．このエネルギーを
e
とするとき，宇宙ヤシガニが超空間からワープアウトする座標 (
x
,
y
,
z
) は以下の条件を満たすことがわかっている．
x
,
y
,
z
はいずれも非負の整数である．
x
+
y
2
+
z
3
=
e
である．
上記の条件の下で
x
+
y
+
z
の値を最小にする．
これらの条件だけでは座標が一意に決まるとは限らないが，
x
+
y
+
z
の最小値を
m
としたときに，ワープアウトする座標が平面
x
+
y
+
z
=
m
上にあることは確かである．そこで，この平面上に十分な大きさのバリアを張る．すると，宇宙ヤシガニはバリアの張られたところにワープアウトすることになる．バリアの影響を受けた宇宙ヤシガニは身動きがとれなくなる．そこをケンの操作する最新鋭宇宙船であるウェポン・ブレーカー号で捕獲しようという段取りである．
バリアは一度しか張ることができないため，失敗するわけにはいかない．そこでケンは，任務の遂行にあたって計算機の助けを借りることにした．あなたの仕事は，宇宙ヤシガニが超空間に突入する際のエネルギーが与えられたときに，バリアを張るべき平面
x
+
y
+
z
=
m
を求めるプログラムを書くことである．用意されたテストケースの全てに対して正しい結果を出力したとき，あなたのプログラムは受け入れられるであろう．
Input
入力は複数のデータセットで構成される．各データセットは 1 行のみからなり，1 つの正の整数
e
(
e
≦ 1,000,000) が含まれる．これは，宇宙ヤシガニが超空間に突入した際のエネルギーを表す．入力は
e
= 0 の時に終了し，これはデータセットには含まれない．
Output
各データセットについて，
m
の値を 1 行に出力しなさい．出力には他の文字を含めてはならない．
Sample Input
1
2
4
27
300
1250
0
Output for the Sample Input
1
2
2
3
18
44

Submitted solutions:

code_snippet: #include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,t) for(int i = s; i < t ; i++)
using LL = long long; using VL = vector<LL>;
template<class T> using V = vector<T>; template<class T> using VV = V<V<T>>;
const LL LINF = 1e18;

void solve() {
	LL N;
	while (cin >> N, N) {
		LL ans = LINF;
		for (LL z = 0; z*z*z <= N; z++) {
			for (LL y = 0; y*y <= N; y++) {
				LL x = N - z * z*z - y * y;
				if (x >= 0 && x<=N) {
					ans = min(ans, x + y + z);
				}
			}
		}
		cout << ans << endl;
	}

}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	solve();

	return 0;
}
accuracy: 1
time_ms: 230
memory_kb: 3216
final_rank: 5

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using a2 = array<ll, 2>;
using a3 = array<ll, 3>;

template <typename A> void chmin(A &l, const A &r) {
    if(r < l)
        l = r;
}
template <typename A> void chmax(A &l, const A &r) {
    if(l < r)
        l = r;
}

ll mod = 998244353;

void init() {}

ll n;
vector<a2> v;
void input() { cin >> n; }

void solve() {
    ll ans = 1e18;
    for(int i = 0; i <= 100; i++) {
        for(int j = 0; j <= 1000; j++) {
            if(i * i * i + j * j <= n) {
                chmin(ans, i + j + (n - i * i * i - j * j));
            }
        }
    }
    cout << ans << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    init();
    while(1) {
        input();
        if(n == 0)
            break;
        solve();
    }

    return 0;
}
accuracy: 1
time_ms: 240
memory_kb: 3256
final_rank: 9

code_snippet: // AOJ 2012 - Space Coconut Grab
// JAG Practice Contest for Japan Domestic 2007 - Problem A

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

bool solving() {
  int e; cin >> e;
  if(e == 0) return false;
  
  int m = 2e9;
  for(int z=0; z*z*z <= e; ++z) {
    for(int y=0; y*y + z*z*z <= e; ++y) {
      int x = e - y*y - z*z*z;
      m = min(m, x+y+z);
    }
  }
  cout << m << endl;
  return true;
}

int main() {
  while(solving()) {}
}
accuracy: 1
time_ms: 140
memory_kb: 3456
final_rank: 18

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define all(...) std::begin(__VA_ARGS__), std::end(__VA_ARGS__)
#define rall(...) std::rbegin(__VA_ARGS__), std::rend(__VA_ARGS__)
#define OVERLOAD_REP(_1, _2, _3, _4, name, ...) name
#define REP1(n) for(ll i=0;i<(n);i++)
#define REP2(i, n) for (ll i=0;i<(n);i++)
#define REP3(i, a, n) for (ll i=a;i<(n);i++)
#define REP4(i, a, b, n) for(ll i=a;i<(n);i+=b)
#define rep(...) OVERLOAD_REP(__VA_ARGS__, REP4, REP3, REP2, REP1)(__VA_ARGS__)
#define OVERLOAD_RREP(_1, _2, _3, _4, name, ...) name
#define RREP1(n) for(ll i=(n)-1;i>=0;i--)
#define RREP2(i, n) for(ll i=(n)-1;i>=0;i--)
#define RREP3(i, a, n) for(ll i=(n)-1;i>=(a);i--)
#define RREP4(i, a, b, n) for(ll i=(n)-1;i>=(a);i-=(b))
#define rrep(...) OVERLOAD_RREP(__VA_ARGS__, RREP4, RREP3, RREP2, RREP1)(__VA_ARGS__)
#define uniq(a) sort(all(a));a.erase(unique(all(a)),end(a))
#define len(n) (long long)(n).size()
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using vvs = vector<vs>;
using vvvs = vector<vvs>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vc = vector<char>;
using vvc = vector<vc>;
using vvvc = vector<vvc>;
using pll = pair<ll,ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;

ll intpow(ll a,ll b){
    ll ans = 1;
    while (b){
        if (b & 1){
            ans *= a;
        }
        a *= a;
        b /= 2;
    }
    return ans;
}
ll modpow(ll a,ll b,ll c){
    ll ans = 1;
    while (b){
        if (b & 1){
            ans *= a;
            ans %= c;
        }
        a *= a;
        a %= c;
        b /= 2;
    }
    return ans;
}

template<class... T>
void input(T&... a){
    (cin >> ... >> a);
}

#define INT(...) int __VA_ARGS__; input(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__; input(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__; input(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__; input(__VA_ARGS__)
#define STR(...) string __VA_ARGS__; input(__VA_ARGS__)
#define CHA(...) char __VA_ARGS__; input(__VA_ARGS__)
#define VLL(name,length) vll name(length);rep(i,length){cin >> name[i];}
#define VVLL(name,h,w) vvll name(h,vll(w));rep(i,h)rep(j,w){cin >> name[i][j];}
#define VVVLL(name,a,b,c) vvvll name(a,vvll(b,vll(c)));rep(i,a)rep(j,b)rep(k,c){cin >> name[i][j][k];}
#define VI(name,length) vi name(length);rep(i,length){cin >> name[i];}
#define VVI(name,h,w) vvi name(h,vi(w));rep(i,h)rep(j,w){cin >> name[i][j];}
#define VVVI(name,a,b,c) vvvi name(a,vvll(b,vi(c)));rep(i,a)rep(j,b)rep(k,c){cin >> name[i][j][k];}
#define VLD(name,length) vld name(length);rep(i,length){cin >> name[i];}
#define VVLD(name,h,w) vvld name(h,vld(w));rep(i,h)rep(j,w){cin >> name[i][j];}
#define VVVLD(name,a,b,c) vvvld name(a,vvld(b,vld(c)));rep(i,a)rep(j,b)rep(k,c){cin >> name[i][j][k];}
#define VC(name,length) vc name(length);rep(i,length){cin >> name[i];}
#define VVC(name,h,w) vvc name(h,vc(w));rep(i,h)rep(j,w){cin >> name[i][j];}
#define VVVC(name,a,b,c) vvvc name(a,vvc(b,vc(c)));rep(i,a)rep(j,b)rep(k,c){cin >> name[i][j][k];}
#define VS(name,length) vs name(length);rep(i,length){cin >> name[i];}
#define VVS(name,h,w) vvs name(h,vs(w));rep(i,h)rep(j,w){cin >> name[i][j];}
#define VVVS(name,a,b,c) vvvs name(a,vvs(b,vs(c)));rep(i,a)rep(j,b)rep(k,c){cin >> name[i][j][k];}
#define PLL(name) pll name;cin>>name.first>>name.second;
#define VPLL(name,length) vpll name(length);rep(i,length){cin>>name[i].first>>name[i].second;}

void print(){cout << "\n";}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
    os << "[";
    for (size_t i = 0; i < vec.size(); ++i) {
        os << vec[i];
        if (i + 1 < vec.size()) os << ", ";
    }
    os << "]";
    return os;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, const std::vector<std::pair<T1, T2>>& a) {
    os << "[";
    for (size_t j = 0; j < a.size(); ++j) {
        os << "(" << a[j].first << ", " << a[j].second << ")";
		if (j + 1 < a.size()) os << ", ";
    }
	os << "]";
    return os;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, const std::vector<std::vector<std::pair<T1, T2>>>& mat) {
	os << "[";
    for (size_t i = 0; i < mat.size(); ++i) {
		os << "[";
        for (size_t j = 0; j < mat[i].size(); ++j) {
            os << "(" << mat[i][j].first << ", " << mat[i][j].second << ")";
			if (j + 1 < mat[i].size()) os << ", ";
        }
		os << "]";
		if (i + 1 < mat.size()) os << ", ";
    }
	os << "]";
    return os;
}

template <typename T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& s) {
    os << "{";
    bool first = true;
    for (const auto& x : s) {
        if (!first) os << ", ";
        os << x;
        first = false;
    }
    os << "}";
    return os;
}

template <typename K, typename V>
std::ostream& operator<<(std::ostream& os, const std::map<K, V>& m) {
    os << "{";
    bool first = true;
    for (const auto& [key, val] : m) {
        if (!first) os << ", ";
        os << key << ": " << val;
        first = false;
    }
    os << "}";
    return os;
}

template<class T, class... Ts>
void print(const T& a, const Ts&... b){cout << a;(cout << ... << (cout << ' ', b));cout << '\n';}

void write(){cout << "\n";}
template<class T, class... Ts>
void write(const T& a, const Ts&... b){cout << a;(cout << ... << (cout << ' ', b));cout << '\n';}
void write(vll x){rep(i,len(x)){cout << x[i];if(i!=len(x)-1){cout << " ";}else{cout << '\n';}}}
void write(vvll x){rep(i,len(x))rep(j,len(x[i])){cout << x[i][j];if(j!=len(x[i])-1){cout << " ";}else{cout << '\n';}}}
void write(vi x){rep(i,len(x)){cout << x[i];if(i!=len(x)-1){cout << " ";}else{cout << '\n';}}}
void write(vvi x){rep(i,len(x))rep(j,len(x[i])){cout << x[i][j];if(j!=len(x[i])-1){cout << " ";}else{cout << '\n';}}}
void write(vvvi x){rep(i,len(x))rep(j,len(x[i]))rep(k,len(x[i][j])){cout << x[i][j][k];if(k!=len(x[i][j])-1){cout << " ";}else if(j!=len(x[i])-1){cout << " | ";}else{cout << '\n';}}}
void write(vld x){rep(i,len(x)){cout << x[i];if(i!=len(x)-1){cout << " ";}else{cout << '\n';}}}
void write(vvld x){rep(i,len(x))rep(j,len(x[i])){cout << x[i][j];if(j!=len(x[i])-1){cout << " ";}else{cout << '\n';}}}
void write(vvvld x){rep(i,len(x))rep(j,len(x[i]))rep(k,len(x[i][j])){cout << x[i][j][k];if(k!=len(x[i][j])-1){cout << " ";}else if(j!=len(x[i])-1){cout << " | ";}else{cout << '\n';}}}
void write(vc x){rep(i,len(x)){cout << x[i];if(i!=len(x)-1){cout << " ";}else{cout << '\n';}}}
void write(vvc x){rep(i,len(x))rep(j,len(x[i])){cout << x[i][j];if(j!=len(x[i])-1){cout << " ";}else{cout << '\n';}}}
void write(vvvc x){rep(i,len(x))rep(j,len(x[i]))rep(k,len(x[i][j])){cout << x[i][j][k];if(k!=len(x[i][j])-1){cout << " ";}else if(j!=len(x[i])-1){cout << " | ";}else{cout << '\n';}}}
void write(vs x){rep(i,len(x)){cout << x[i];if(i!=len(x)-1){cout << " ";}else{cout << '\n';}}}
void write(vvs x){rep(i,len(x))rep(j,len(x[i])){cout << x[i][j];if(j!=len(x[i])-1){cout << " ";}else{cout << '\n';}}}
void write(vvvs x){rep(i,len(x))rep(j,len(x[i]))rep(k,len(x[i][j])){cout << x[i][j][k];if(k!=len(x[i][j])-1){cout << " ";}else if(j!=len(x[i])-1){cout << " | ";}else{cout << '\n';}}}
void write(pll x){cout << x.first << ' ' << x.second << '\n';}
void write(vpll x){rep(i,len(x)){cout << x[i].first << ' ' << x[i].second << '\n';}}
void write(vvpll x){rep(i,len(x))rep(j,len(x[i])){cout << x[i][j].first << ' ' << x[i][j].second;if(j!=len(x[i])-1){cout << " ";}else{cout << '\n';}}}

template <typename T>
T sum(const std::vector<T>& v) {
    return std::accumulate(v.begin(), v.end(), T(0));
}

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

long long mod_mul(long long a, long long b, long long mod) {
    return (__int128)a * b % mod;
}

long long mod_pow(long long a, long long b, long long mod) {
    long long result = 1;
    a %= mod;
    while (b > 0) {
        if (b & 1) result = mod_mul(result, a, mod);
        a = mod_mul(a, a, mod);
        b >>= 1;
    }
    return result;
}

bool MillerRabin(ll x){
    
    if(x <= 1){return false;}
    if(x == 2){return true;}
    if((x & 1) == 0){return false;}
    vll test;
    if(x < (1 << 30)){
        test = {2, 7, 61};
    } 
    else{
        test = {2, 325, 9375, 28178, 450775, 9780504, 1795265022};
    }
    ll s = 0;
    ll d = x - 1;
    while((d & 1) == 0){
        s++;
        d >>= 1;
    }
    for(ll i:test){
        if(x <= i){return true;}
        ll y = mod_pow(i,d,x);
        if(y == 1 || y == x - 1){continue;}
        ll c = 0;
        for(int j=0;j<s-1;j++){
            y = mod_mul(y,y,x);
            if(y == x - 1){
                c = 1;
                break;
            }
        }
        if(c == 0){
            return false;
        }
    }
    return true;
}

int main(){
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
    while(1){
        LL(e);
        if(e == 0){break;}
        ll m = 1LL<<60;
        rep(z,200){
            ll u = z * z * z;
            if(u > e){break;}
            rep(y,2000){
                ll v = y * y;
                if(u + v > e){break;}
                ll x = e - u - v;
                if(x >= 0){
                    m = min(m,x+y+z);
                }
            }
        }
        print(m);
    }
    
}
accuracy: 1
time_ms: 150
memory_kb: 3456
final_rank: 19

code_snippet: #if __has_include(<yoniha/all.h>)
#include <yoniha/all.h>
using namespace atcoder;
#else
#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#endif
using namespace std;

#define int long long
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n - 1); i >= 0; i--)
template <typename T> bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template <typename T> bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

// using mint = modint;

signed main(){
  auto solve = [](int e){
    int ans = 1ll << 60;
    for(int z = 0; z * z * z <= e; z++) for(int y = 0; y * y + z * z * z <= e; y++){
      int x = e - y * y - z * z * z;
      chmin(ans, x + y + z);
    }
    cout << ans << '\n';
  };
  while(true){
    int e; cin >> e;
    if(e == 0) break;
    solve(e);
  }
}
/*
指数部が大きい文字から探索するとよい
zの全探索が10^2、yが10^4になる
*/
accuracy: 1
time_ms: 140
memory_kb: 3436
final_rank: 14

code_snippet: #include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

// エネルギー関数
int space_crab_energy(int x, int y, int z) {
    return x + y*y + z*z*z;
}

int main() {
    while (true) {
        int e;
        cin >> e;
        if (e == 0) break; // 入力が0の場合は終了

        int min_m = e + 1;  // 初期値として十分大きな値

        // y の範囲を sqrt(e) で制限
        int max_y = static_cast<int>(sqrt(e)) + 1;

        for (int y = 0; y <= max_y; ++y) {
            int y2 = y * y;

            // z の範囲を cbrt(e - y^2) で制限
            int max_z = static_cast<int>(cbrt(e - y2)) + 1;

            for (int z = 0; z <= max_z; ++z) {
                int z3 = z * z * z;
                int x = e - (y2 + z3);

                if (x >= 0) { // x が負でない場合
                    int current_sum = x + y + z;
                    // space_crab_energy 関数を使って条件をチェック
                    if (space_crab_energy(x, y, z) == e) {
                        min_m = min(min_m, current_sum); // 最小値を更新
                    }
                }
            }
        }

        cout << min_m << endl; // 結果を出力
    }

    return 0;
}
accuracy: 1
time_ms: 320
memory_kb: 3224
final_rank: 17

code_snippet: #include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

// エネルギー関数
int space_crab_energy(int x, int y, int z) {
    return x + y*y + z*z*z;
}

int main() {
    while (true) {
        int e;
        cin >> e;
        if (e == 0) break;

        int min_m = e + 1;  // 初期値として十分大きな値

        // y の範囲を sqrt(e) で制限
        int max_y = static_cast<int>(sqrt(e)) + 1;

        for (int y = 0; y <= max_y; ++y) {
            int y2 = y * y;

            // z の範囲を cbrt(e - y^2) で制限
            int max_z = static_cast<int>(cbrt(e - y2)) + 1;

            for (int z = 0; z <= max_z; ++z) {
                int z3 = z * z * z;
                int x = e - (y2 + z3);

                if (x >= 0) {
                    int current_sum = x + y + z;
                    min_m = min(min_m, current_sum);
                }
            }
        }

        cout << min_m << endl;
    }

    return 0;
}
accuracy: 1
time_ms: 280
memory_kb: 3260
final_rank: 15

code_snippet: #include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
    int e;
    while (cin >> e && e != 0) {
        int min_sum = e + 1; // `x + y + z` の初期値として十分大きい値

        // y の上限を sqrt(e) に設定
        int max_y = static_cast<int>(sqrt(e)) + 1;

        for (int y = 0; y <= max_y; ++y) {
            int y2 = y * y;

            // z の上限を cbrt(e - y^2) に設定
            int max_z = static_cast<int>(cbrt(e - y2)) + 1;

            for (int z = 0; z <= max_z; ++z) {
                int z3 = z * z * z;
                int x = e - (y2 + z3);

                if (x >= 0) {
                    int current_sum = x + y + z;
                    min_sum = min(min_sum, current_sum);
                }
            }
        }

        cout << min_sum << endl;
    }

    return 0;
}
accuracy: 1
time_ms: 270
memory_kb: 3240
final_rank: 10

code_snippet: #include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int main() {
  while (1) {
    long long e;
    cin >> e;
    if (e == 0) {
      break;
    }
    int ans = INF;
    for (int z = 0; z <= 100; z++) {
      for (int y = 0; y <= 1000; y++) {
        int x = e - y * y - z * z * z;
        if (x < 0) break;
        ans = min(ans, x + y + z);
      }
    }
    cout << ans << '\n';
  }
}
accuracy: 1
time_ms: 200
memory_kb: 3356
final_rank: 12

code_snippet: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<long long>;
using vvl = vector<vector<long long>>; using vs = vector<string>;
using pl = pair<long long, long long>;
template <typename T> inline bool chmin(T& a, const T& b) {bool compare = a > b; if (a > b) a = b; return compare;}
template <typename T> inline bool chmax(T& a, const T& b) {bool compare = a < b; if (a < b) a = b; return compare;}
template<class T>using rp_queue=priority_queue<T,vector<T>,greater<T>>;
template <typename T> T gcd(T a, T b) {if (b == 0)return a; else return gcd(b, a % b);}
template <typename T> inline T lcm(T a, T b) {return a /gcd(a, b)*b;}
const ll INF = 1LL << 60;
const ld PI = acos(-1);
template <class OStream, class T> OStream &operator<<(OStream &os, const std::vector<T> &vec);
template <class OStream, class T, size_t sz> OStream &operator<<(OStream &os, const std::array<T, sz> &arr);
template <class OStream, class T, class TH> OStream &operator<<(OStream &os, const std::unordered_set<T, TH> &vec);
template <class OStream, class T, class U> OStream &operator<<(OStream &os, const pair<T, U> &pa);
template <class OStream, class T> OStream &operator<<(OStream &os, const std::deque<T> &vec);
template <class OStream, class T> OStream &operator<<(OStream &os, const std::set<T> &vec);
template <class OStream, class T> OStream &operator<<(OStream &os, const std::multiset<T> &vec);
template <class OStream, class T> OStream &operator<<(OStream &os, const std::unordered_multiset<T> &vec);
template <class OStream, class T, class U> OStream &operator<<(OStream &os, const std::pair<T, U> &pa);
template <class OStream, class TK, class TV> OStream &operator<<(OStream &os, const std::map<TK, TV> &mp);
template <class OStream, class TK, class TV, class TH> OStream &operator<<(OStream &os, const std::unordered_map<TK, TV, TH> &mp);
template <class OStream, class... T> OStream &operator<<(OStream &os, const std::tuple<T...> &tpl);
 
template <class OStream, class T> OStream &operator<<(OStream &os, const std::vector<T> &vec) { os << '['; for (auto v : vec) os << v << ','; os << ']'; return os; }
template <class OStream, class T, size_t sz> OStream &operator<<(OStream &os, const std::array<T, sz> &arr) { os << '['; for (auto v : arr) os << v << ','; os << ']'; return os; }
template <class... T> std::istream &operator>>(std::istream &is, std::tuple<T...> &tpl) { std::apply([&is](auto &&... args) { ((is >> args), ...);}, tpl); return is; }
template <class OStream, class... T> OStream &operator<<(OStream &os, const std::tuple<T...> &tpl) { os << '('; std::apply([&os](auto &&... args) { ((os << args << ','), ...);}, tpl); return os << ')'; }
template <class OStream, class T, class TH> OStream &operator<<(OStream &os, const std::unordered_set<T, TH> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <class OStream, class T> OStream &operator<<(OStream &os, const std::deque<T> &vec) { os << "deq["; for (auto v : vec) os << v << ','; os << ']'; return os; }
template <class OStream, class T> OStream &operator<<(OStream &os, const std::set<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <class OStream, class T> OStream &operator<<(OStream &os, const std::multiset<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <class OStream, class T> OStream &operator<<(OStream &os, const std::unordered_multiset<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <class OStream, class T, class U> OStream &operator<<(OStream &os, const std::pair<T, U> &pa) { return os << '(' << pa.first << ',' << pa.second << ')'; }
template <class OStream, class TK, class TV> OStream &operator<<(OStream &os, const std::map<TK, TV> &mp) { os << '{'; for (auto v : mp) os << v.first << "=>" << v.second << ','; os << '}'; return os; }
template <class OStream, class TK, class TV, class TH> OStream &operator<<(OStream &os, const std::unordered_map<TK, TV, TH> &mp) { os << '{'; for (auto v : mp) os << v.first << "=>" << v.second << ','; os << '}'; return os; }
#ifdef LOCAL
const string COLOR_RESET = "\033[0m", BRIGHT_GREEN = "\033[1;32m", BRIGHT_RED = "\033[1;31m", BRIGHT_CYAN = "\033[1;36m", NORMAL_CROSSED = "\033[0;9;37m", RED_BACKGROUND = "\033[1;41m", NORMAL_FAINT = "\033[0;2m";
#define dbg(x) std::cerr << BRIGHT_CYAN << #x << COLOR_RESET << " = " << (x) << NORMAL_FAINT << " (L" << __LINE__ << ") " << __FILE__ << COLOR_RESET << std::endl
#define dbgif(cond, x) ((cond) ? std::cerr << BRIGHT_CYAN << #x << COLOR_RESET << " = " << (x) << NORMAL_FAINT << " (L" << __LINE__ << ") " << __FILE__ << COLOR_RESET << std::endl : std::cerr)
#else
#define dbg(x) ((void)0)
#define dbgif(cond, x) ((void)0)
#endif
void solve();
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  int num_tc = 1;
  //cin >> num_tc;
  rep(tc,num_tc){
    //cout << "Case #" << tc+1 << ": " ;// << endl;
    solve();
  }
}
//見切り発車で実装しては行けない．頭の中でコードが完全に出来上がるまで書き始めるな．
//オーバーフローしているか確認する
//小さいケースで動いているかを確認する。
void solve(){
  while(true){
    ll e;cin>>e;
    if(e==0)return;
    dbg(e);
    ll ans = INF;
    for(ll b=0;b*b<=e;b++){
      for(ll c=0;b*b+c*c*c<=e;c++){
        if(b*b+c*c*c<=e){
          ll a = (e-b*b-c*c*c);
          assert(a+b*b+c*c*c==e);
          chmin(ans,b+c+a);
        }
      }
    }
    cout<<ans<<endl;
  }
}
accuracy: 1
time_ms: 160
memory_kb: 3308
final_rank: 6

code_snippet: #include<iostream>
using namespace std;

int main(){
    while(true){
        int e;
        cin >> e;
        if(e == 0) break;
        int a= 1000000;
        int z=0,x=0;
        while(z*z*z <= e){
            int y=0;
            while((z*z*z) + (y*y) <= e){
                x = e - (z*z*z) - (y*y);
                if(a > x+y+z) a = x+y+z;
                y++;
            }
            z++;
        }
        cout << a << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 160
memory_kb: 3076
final_rank: 1

code_snippet: #include<bits//stdc++.h>

using namespace std;

int main() {
    while(true){
        int e;
        cin >> e;
        if(e==0) break;
        int sum = 1<<30;
        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(sum>x+y+z) sum=x+y+z;
            }
        }
        cout << sum << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 200
memory_kb: 3440
final_rank: 20

code_snippet: #include<bits//stdc++.h>

using namespace std;

int main() {
    while(true){
        int e;
        cin >> e;
        if(e==0) break;
        int sum = 1<<30;
        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(sum>x+y+z) sum=x+y+z;
            }
        }
        cout << sum << endl;
    }
}
accuracy: 1
time_ms: 200
memory_kb: 3356
final_rank: 12

code_snippet: #include<bits//stdc++.h>

using namespace std;

int main() {
    while(true){
        int e;
        cin >> e;
        if(e==0) return 0;
        int sum = 1<<30;
        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(sum>x+y+z) sum=x+y+z;
            }
        }
        cout << sum << endl;
    }
}
accuracy: 1
time_ms: 200
memory_kb: 3336
final_rank: 11

code_snippet: #include<bits//stdc++.h>

using namespace std;

int main() {
    while(true){
        int e;
        cin >> e;
        if(e==0) return 0;
        int ans = 1<<30;
        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(ans>x+y+z) ans=x+y+z;
            }
        }
        cout << ans << endl;
    }
}
accuracy: 1
time_ms: 200
memory_kb: 3136
final_rank: 4

code_snippet: #include <bits/stdc++.h>
#define rep(i,j,n) for (long long i = j; i < (int)(n); i++)
#define REP(i,j,n) for (long long i = j; i <= (int)(n); i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(x) (x.begin(), x.end())
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b){
  bool compare = (a < b);
  if(compare) a = b;
  return compare;
}
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b){
  bool compare = (a > b);
  if(compare) a = b;
  return compare;
}
string substrback(string s,size_t p,size_t l){
	//s=文字列　p=後ろから数えて何文字目　l=pから何文字目まで
	const size_t strl = s.length();
	return s.substr(strl - p,l);
}
//pair型のfirstで比較
bool comparePairs(const pair<ll,ll> &a, const pair<ll,ll> &b){
	if(a.first != b.first)
	return a.first<b.first;
	return a.second < b.second;
}
//pair型のsecondで比較
bool comparePairs2(const pair<ll,ll> &a, const pair<ll,ll> &b){
	if(a.second != b.second)
	return a.second<b.second;
	return a.first < b.first;
}
//pair型の１.second  と2.firstをつなげていく
bool customsort(const pair<ll,ll>  &a,const pair<ll,ll> &b){
	if(a.second == b.first){
		return true;
	}
	return false;
}
bool customsort2(const pair<ll, ll> &a, const pair<ll, ll> &b) {
    // 特定の値がfirstに出た場合、そのsecond値を先頭に持ってくる
    if (a.first == -1) {
        return true;
    } else if (b.first == -1) {
        return false;
    }
    return a.first < b.first;
}

//nの階乗
ull facto(ll n){
	if (n==0 || n ==1){
		return 1;
	} else {
		return n *facto(n-1);
	}
}
//nのΣ
ll sum(ll n) {
	ll sum =0;
	sum = n*(n+1)/2;
	return sum;
}
struct V {
	int a, b;
};
bool acom(const V& a, const V& b) {
	return a.a < b.a;
}
bool bcom(const V& a, const V& b) {
	return a.b < b.b;
}
bool isPrime(ll num){
	if(num==1)return false;
	if(num==2)return true;
	if(num % 2 == 0)return false;
	for(ll i =3;i*i<=num;i+=2){
		if(num % i == 0)return false;
	}
	return true;
}
int gcd(int a, int b){
	if(a%b==0) return b;
	else return gcd(b, a%b);
}
/*
int main() {
	ll n,m;
	cin>>n>>m;
	for (ll i = (ll) sqrt(m) + 1; i >= 2; i--) {
		while(true) {
			if (n % i == 0 && m % i == 0) {
				m /= i;
				n /= i;
			} else {
				break;
			}
		}
	}
	ll g = gcd(n,m);
	n/=g; m/=g;
	//cout<<n<<" "<<m<<endl;
	int maxn =0; int maxm = 0;
	int n1 =n; int m1 =m;
	while(n1>0){
		chmax(maxn,n1%10);
		n1/=10;
	}
	while(m1>0){
		chmax(maxm,m1%10);
		m1/=10;
	}
	ll ans = max(n,m);
	if(ans>10)ans==10;
	cout<<ans<<endl;
}
*/
//atodekesite
unordered_set<ll> primes;
void bunkai(ll num) {
	cout<<num<<endl;
	if(num==1)return;
	if(num==2) {
		primes.insert(2);
		bunkai(num/2);
	}
	if(num % 2 == 0)return;
	for(ll i =3;i*i<=num;i+=2){
		if(num % i == 0) {
			primes.insert(i);
			bunkai(num/i);
		} else {
			return;
		}
	}
}
int main(){
	while(true){
		ll n;
		cin>>n;
		ll ans = 10000000000;
		if(n==0)return 0;
		for(ll i=0;i*i*i<=n;i++){
			for(int j=0;i*i*i+j*j<=n;j++){
				chmin(ans,i+j+(n-(i*i*i+j*j)));
			}
		}
		cout<<ans<<endl;
		
	}
}
accuracy: 1
time_ms: 230
memory_kb: 3324
final_rank: 16

code_snippet: #include <bits/stdc++.h>

#define rep(i, N) for(ll i = 0; i < (ll)(N); ++i)
#define per(i, N) for(ll i = (ll)(N) - 1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define bit(n, k) (((n) >> (k)) & 1)
#define pcnt(n) (bitset<64>(n).count())
#define fi first
#define se second
#define mkpr make_pair
#define mktpl make_tuple
#define eb emplace_back
template <class T> std::istream& operator>>(std::istream& is, std::vector<T>& V) {
    for (auto& it : V) is >> it;
    return is;
}
template <class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& V) {
    for (int i = 0 ; i < (int)V.size() ; i++) {
        os << V[i] << (i + 1 == (int)V.size() ? "" : " ");
    }
    return os;
}
using namespace std;

int main() {
    std::cin.tie(nullptr)->sync_with_stdio(false);
    while(true){
        int e;
        cin >> e;
        if(e==0) return 0;
        int ans = 1<<30;
        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(ans>x+y+z) ans=x+y+z;
            }
        }
        cout << ans << endl;
    }
}
accuracy: 1
time_ms: 130
memory_kb: 3356
final_rank: 8

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
#define all(x) x.begin(),x.end()
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

int main() {
    while(true){
        int n;
        cin>>n;
        int ans=1e9;
        if(n==0)break;
        for(int z=0;z*z*z<=n;z++){
            for(int y=0;y*y+z*z*z<=n;y++){
                int x=n-z*z*z-y*y;
                chmin(ans,x+y+z);
            }
        }
        cout<<ans<<endl;
    }
}
accuracy: 1
time_ms: 200
memory_kb: 3124
final_rank: 3

code_snippet: #include <iostream>
#include <string>
#include <utility>
#include <limits.h>
#include <cstdlib>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <map>
using namespace std;

int main(){
    int e;
    while(1){
        cin >> e;
        if(e == 0)return 0;

        int m = INT_MAX;
        int x = 0,y = 0,z = 0;

        for(z = 0; z *z*z <= e; z++){
            int nz = e - z*z*z;
            for(y = 0; y*y <= nz; y++){
                x = nz-y*y;
                if(x >= 0){
                    m = min(m,x+y+z);
                }
            }
        }

        cout << m << endl;
    }

    return 0;
}
accuracy: 1
time_ms: 120
memory_kb: 3364
final_rank: 7

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

int main(){
    while(true){
        set<int>s;
        int e;
        cin >> e;
        if(e==0)break;
        float z=0;
        while(z*z*z <= e){
            float y = floor(sqrt(e-z*z*z));
            float x = e-z*z*z-y*y;
            s.insert(x+y+z);
            z++;
        }
        cout << *s.begin() << endl;
    }
}
accuracy: 1
time_ms: 20
memory_kb: 3348
final_rank: 2