Problem:


Space Coconut Crab

宇宙ヤシガニ

English text is not available in this practice contest.

ケン・マリンブルーは，宇宙ヤシガニを求めて全銀河を旅するスペースハンターである．宇宙ヤシガニは，宇宙最大とされる甲殻類であり，成長後の体長は 400 メートル以上，足を広げれば 1,000 メートル以上にもなると言われている．既に多数の人々が宇宙ヤシガニを目撃しているが，誰一人として捕らえることに成功していない．

ケンは，長期間の調査によって，宇宙ヤシガニの生態に関する重要な事実を解明した．宇宙ヤシガニは，驚くべきことに，相転移航法と呼ばれる最新のワープ技術と同等のことを行い，通常空間と超空間の間を往来しながら生きていた．さらに，宇宙ヤシガニが超空間から通常空間にワープアウトするまでには長い時間がかかり，またワープアウトしてからしばらくは超空間に移動できないことも突き止めた．

そこで，ケンはついに宇宙ヤシガニの捕獲に乗り出すことにした．戦略は次のとおりである．はじめに，宇宙ヤシガニが通常空間から超空間に突入する際のエネルギーを観測する．このエネルギーを e とするとき，宇宙ヤシガニが超空間からワープアウトする座標 (x, y, z) は以下の条件を満たすことがわかっている．

x, y, z はいずれも非負の整数である．

x + y2 + z3 = 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



Sample input:
1
2
4
27
300
1250
0


Sample output:
1
2
2
3
18
44

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    m = n
    z = 0
    while z**3<=n:
        y = int((n-z**3)**0.5)
        x = n-z**3-y**2
        m = min(x+y+z,m)
        z +=1
    print(m)

Submission status: Accepted

Solution code:
while True:
	e=int(input())
	if e==0:
		exit()
	ans=10**20
	for i in range(int(e**1/3+1)):
		if e-i**3<0:
			break
		ansk=0
		ansk+=i
		ansk+=int((e-i**3)**0.5)
		ansk+=e-i**3-int((e-i**3)**0.5)**2
		ans=min(ans,ansk)
	print(ans)

Submission status: Accepted

Solution code:
import math

x = 0

while True:
    x = int(input())
    if x == 0:
        break
    ans = 1000000
    for i in range(x+1):
        if i*i*i > x:
            break
        j = math.floor(math.sqrt(x-i*i*i))
        ans = min(ans, i+j+x-i*i*i-j*j)


    print(int(ans))

Submission status: Accepted

Solution code:
while True:
    e = int(input())
    if e == 0:
        break
    mz = int( e **(1/3))+1
    L = []
    for k in range(mz+1):
        ek = e-k**3
        if ek < 0:
            break
        j = int(ek**0.5)
        i = ek - j**2
        if i >= 0 and j >= 0 and k >=0:
            L.append((i+j+k))
    print(min(L))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

from math import sqrt

while True:
    e = int(input())

    if e == 0: break
    z, ans = 0, e

    while z ** 3 <= e:
        y = int(sqrt(e - z**3))
        x = e - y**2 - z**3
        ans = min(ans, x + y + z)
        z += 1

    print(ans)

Submission status: Accepted

Solution code:
def main():
  while True:
    e = int(input())
    if e == 0:
      break
    ans = 1000000
    for z in range(int(e ** (1 / 3)) + 2):
      ez = e - z ** 3
      if ez < 0:
        break
      y = int(ez ** (1 / 2))
      x = ez - y ** 2
      if x >= 0 and y >= 0 and z >= 0:
        ans = min(ans, x + y + z)
    print(ans)

main()

Submission status: Runtime Error

Solution code:
while 1:
    e = int(input().strip())
    if e ==0:break
    m=e
    for z in range(e):
        for y in range(e):
            x = e - y**2 - z**3 
            if x < 0:break
            if m > x+y+z: m = x+y+z
    print(m)

Submission status: Runtime Error

Solution code:
import math
while 1:
    e = int(input().strip())
    if e ==0:break
    m=e
    for z in range(e):
        for y in range(int(math.sqrt(e))):
            x = e - y**2 - z**3 
            if x < 0:break
            if m > x+y+z: m = x+y+z
    print(m)

Submission status: Runtime Error

Solution code:
import math
while 1:
    e = int(input().strip())
    if e ==0:break
    m=e
    for z in range(int(math.sqrt(e))):
        for y in range(int(math.sqrt(e))):
            x = e - y*y- z*z*z 
            if x < 0:break
            if m > x+y+z: m = x+y+z
    print(m)

Submission status: Runtime Error

Solution code:
while 1:
    e = int(input().strip())
    if e ==0:break
    m=e
    z =0
    while z**3 <= e:
        y =0
        while y**2 <= e - z**3:
            x = e - y**2- z**3 
            if x < 0:break
            if m > x+y+z: m = x+y+z
            y+=1
        z+=1
    print(m)

Submission status: Runtime Error

Solution code:
while 1:
    e = int(input().strip())
    if e ==0:break
    m=e
    z =0
    while z**3 <= e:
        y=0
        while y **2 <= e - z**3:
            x = e - y**2 - z**3 
            if m > x+y+z: m = x+y+z 
            y+=1
        z+=1
    print(m)

Submission status: Runtime Error

Solution code:
import time
while 1:
    e = int(input().strip())
    if e ==0:break
    m=e
    z =0
    time.sleep(20)
    while z**3 <= e:
        y=0
        while y **2 <= e - z**3:
            x = e - y**2 - z**3 
            if m > x+y+z: m = x+y+z 
            y+=1
        z+=1
    
    print(m)

Submission status: Runtime Error

Solution code:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            e = input()
            if e == 0:
                break
            m = float('inf')
            for z in range(101):
                for y in range(1001):
                    x = e - z ** 3 - y ** 2
                    if x >= 0:
                        m = min(m, x + y + z)
            print m
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

Submission status: Runtime Error

Solution code:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            e = input()
            if e == 0:
                break
            m = float('inf')
            for z in range(101):
                tmp = e - z ** 3
                if tmp < 0:
                    continue
                for y in range(1001):
                    x = e - z ** 3 - y ** 2
                    if x >= 0:
                        m = min(m, x + y + z)
                    else:
                        break
            print m
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from math import sqrt

while True:
    e = int(input())
    if e == 0:
        break
    ans = 10**9
    for z in range(e):
        if z > e:
            break
        y = int(sqrt(e-z**3))
        x = e - y ** 2 - z ** 3
        ans = min(ans,x+y+i)
    print(ans)

Submission status: Runtime Error

Solution code:
import math 
while 1 :
	e = int(raw_input())
	if e == 0:
		break
	z = 0
	m = e
	while math.pow(z,3) <= e:
		y = 0
		while y ** 2 <= e - math.pow(z,3):
			m = min(e + y + z - y**2 - math.pow(z,3), m)
			y += 1
		z += 1
	print int(m)

Submission status: Runtime Error

Solution code:
import math 
while 1 :
	e = int(raw_input())
	if e == 0:
		break
	z = 0
	m = e
	while math.pow(z,3) <= e:
		y = 0
		while y ** 2 <= e - math.pow(z,3):
			m = min(e + y + z - y**2 - math.pow(z,3), m)
			y += 1
		z += 1
	print y, z
	print int(m)
quit()

Submission status: Runtime Error

Solution code:
import math 
while 1 :
	e = int(raw_input())
	if e == 0:
		break
	z = 0
	m = e
	while math.pow(z,3) <= e:
		y = 0
		while y ** 2 <= e - math.pow(z,3):
			m = min(e + y + z - y**2 - math.pow(z,3), m)
			y += 1
		z += 1
	print int(m)
quit()

Submission status: Runtime Error

Solution code:
#! /usr/bin/python
# -*- coding: utf-8 -*-

e = int(raw_input())
while e != 0:
    Min = 1000000
    for i in range(e+1):
        z = i
        if z*z*z > e:
            break
        y = 0
        x = 0
        while (y+1)*(y+1) <= e-z*z*z:
            y += 1
        while (x+1) <= e-z*z*z-y*y:
            x += 1
        Min = min(x+y+z, Min)

    print min(x+y+z, Min)

    e = int(raw_input())

Submission status: Runtime Error

Solution code:
#! /usr/bin/python
# -*- coding: utf-8 -*-

e = int(raw_input())
while e != 0:
    Min = 1000000
    for i in range(e+1):
        z = i
        if z*z*z > e:
            break
        y = 0
        x = 0
        while (y+1)*(y+1) <= e-z*z*z:
            y += 1
        x = e-z*z*z-y*y
        Min = min(x+y+z, Min)

    print min(x+y+z, Min)

    e = int(raw_input())

Submission status: Runtime Error

Solution code:
#! /usr/bin/python
# -*- coding: utf-8 -*-

import math

e = int(raw_input())
while e != 0:
    Min = 1000000
    for i in range(e+1):
        z = i
        if z*z*z > e:
            break
        y = int(math.sqrt(e-z*z*z))
        x = e-z*z*z-y*y

        Min = min(x+y+z, Min)

    print min(x+y+z, Min)

    e = int(raw_input())

Submission status: Runtime Error

Solution code:
cubics = [ x * x * x for x in range(101)]
squares = [ x * x for x in range(1000)]
while True:
    x, y, z = -1, -1, -1
    m = 1000000
    e = int(input())
    if e == 0: break
#    for i in range(len(cubics)):
#        if e - cubics[i] < 0:
#            e -= cubics[i - 1]
#            z = i - 1
#            break
#    for i in range(len(squares)):
#        if e - squares[i] < 0:
#            e -= squares[i -1]
#            y = i - 1
#            break
#    x = e
    for cubic in cubics:
        if e < cubic: break
        else: z += 1
        tmp = e - cubic
        #print("tmp:",tmp)
        y = -1
        for squ in squares:
            if tmp < squ: break
            else: 
                x = tmp - squ
                y += 1
                #print(x,y,z)
                m = min(m, x + y + z)
    print(m)

Submission status: Runtime Error

Solution code:
def main():
    while True:
        e = int(input())
        if e==0:
            return
        m = e
        z = int(e**(1/3))
        while z >= 0:
            y = int(int(e-z**3)**(1/2))
            while y >= 0:
                x = e - z**3 - y**2
                m = min(m, x+y+z)
            y -= 1
        z -= 1
        print(m)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    while True:
        e = int(input())
        if e==0:
            return
        m = e
        z = int(e**(1/3))
        while z >= 0:
            y = int(int(e-z**3)**(1/2))
            while y >= 0:
                x = e - z**3 - y**2
                m = min(m, x+y+z)
                y -= 1
            z -= 1
        print(m)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
import math


def solve(e):
    candidates = array.array("L")
    for z in range(0, math.floor(math.pow(e, 1.0 / 3.0)) + 1):
        for y in range(0, math.floor(math.sqrt(e - z * z * z)) + 1):
            x = e - z * z * z - y * y
            candidates.append(x + y + z)
    return min(candidates)


if __name__ == '__main__':
    while True:
        e = int(input())
        if e == 0:
            break
        else:
            print(solve(e))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import heapq
import math


def solve(e):
    candidates = []
    for z in range(0, math.floor(math.pow(e, 1.0 / 3.0)) + 1):
        for y in range(0, math.floor(math.sqrt(e - z * z * z)) + 1):
            x = e - z * z * z - y * y
            heapq.heappush(candidates, x + y + z)
    return candidates[0]


if __name__ == '__main__':
    while True:
        e = int(input())
        if e == 0:
            break
        else:
            print(solve(e))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import heapq
import math


def solve(e):
    candidates = []
    for z in range(0, math.floor(math.pow(e, 1.0 / 3.0)) + 1):
        if e < z * z * z:
            break
        else:
            for y in range(0, math.floor(math.sqrt(e - z * z * z)) + 1):
                x = e - z * z * z - y * y
                heapq.heappush(candidates, x + y + z)
    return candidates[0]


if __name__ == '__main__':
    while True:
        e = int(input())
        if e == 0:
            break
        else:
            print(solve(e))

Submission status: Runtime Error

Solution code:
if __name__ == "__main__":
    while True:
        e = input()
        if e == 0:
            break

        min = 1000000

        for x in range(1000001):
            if x > e:
                break
            for y in range(1001):
                if x + (y * y) > e:
                    break
                for z in range(11):
                    temp = x + (y * y) + (z * z * z)
                    if temp > e:
                        break
                    elif temp == e:
                        if temp < min:
                            min = x + y + z

        print min

Submission status: Runtime Error

Solution code:
import math
targ = int(input())
while True:
    y,z =0,0
    minans = float("inf")
    if (targ ** ( 1 / 3)) == int(targ ** ( 1 / 3)):
        z = int(targ ** ( 1 / 3))
        targ = 0
    elif (targ ** ( 1 / 2)) == int(targ ** ( 1 / 2)):
        y = int(targ ** ( 1 / 2))
        targ = 0
    else:
        for n in range(math.ceil(targ ** ( 1 / 3))):
            if minans == 0:
                break
            for m in range(math.ceil(targ ** ( 1 / 2))):
                if n ** 3 + m **2 > targ:
                    break
                if minans > targ - (n ** 3 + m ** 2):
                    minans = targ - (n ** 3 + m ** 2)
                    y,z = m,n
    if minans != float("inf"):
        print(minans + y + z)
    else:
        print(y + z)
    targ = int(input())
    if targ == 0:
        break

Submission status: Runtime Error

Solution code:
import math
targ = int(input())
while True:
    y,z =0,0
    minans = float("inf")
    if (targ ** ( 1 / 3)) == int(targ ** ( 1 / 3)):
        z = int(targ ** ( 1 / 3))
        targ = 0
    elif (targ ** ( 1 / 2)) == int(targ ** ( 1 / 2)):
        y = int(targ ** ( 1 / 2))
        targ = 0
    else:
        for n in range(math.ceil(targ ** ( 1 / 3))):
            if minans == 0:
                break
            for m in range(math.ceil(targ ** ( 1 / 2))):
                if (n ** 3) + (m **2) > targ:
                    break
                if minans > targ - (n ** 3 + m ** 2):
                    minans = targ - (n ** 3 + m ** 2)
                    y,z = m,n
    if minans != float("inf"):
        print(minans + y + z)
    else:
        print(y + z)
    targ = int(input())
    if targ == 0:
        break

Submission status: Runtime Error

Solution code:
import math
targ = int(input())
while True:
    minans = float("inf")
    if (targ ** ( 1 / 3)) == int(targ ** ( 1 / 3)):
        z = int(targ ** ( 1 / 3))
        targ = 0
    elif (targ ** ( 1 / 2)) == int(targ ** ( 1 / 2)):
        y = int(targ ** ( 1 / 2))
        targ = 0
    else:
        for n in range(math.ceil(targ ** ( 1 / 3))):
            if minans == 0:
                break
            for m in range(math.ceil(targ ** ( 1 / 2))):
                if (n ** 3) + (m **2) > targ:
                    break
                if minans > targ - (n ** 3 + m ** 2) + n + m:
                    minans = targ - (n ** 3 + m ** 2) + n + m
    if minans != float("inf"):
        print(minans)
    else:
        print(y + z)
    targ = int(input())
    if targ == 0:
        break

Submission status: Runtime Error

Solution code:
import math
targ = int(input())
while True:
    minans = float("inf")
    if (targ ** ( 1 / 3)) == int(targ ** ( 1 / 3)):
        z = int(targ ** ( 1 / 3))
        targ = 0
    elif (targ ** ( 1 / 2)) == int(targ ** ( 1 / 2)):
        y = int(targ ** ( 1 / 2))
        targ = 0
    else:
        for n in range(math.ceil(targ ** ( 1 / 3))):
            if minans == 0:
                break
            m = int(math.sqrt(targ - n**3))
            if (n ** 3) + (m **2) > targ:
                break
            if minans > targ - (n ** 3 + m**2) + n + m:
                minans = targ - (n ** 3 + m**2) + n + m
    if minans != float("inf"):
        print(minans)
    else:
        print(y + z)
    targ = int(input())
    if targ == 0:
        break

Submission status: Runtime Error

Solution code:
targ = int(input())
while True:
    minans = float("inf")
    if (targ ** ( 1 / 3)) == int(targ ** ( 1 / 3)):
        z = int(targ ** ( 1 / 3))
        targ = 0
    elif (targ ** ( 1 / 2)) == int(targ ** ( 1 / 2)):
        y = int(targ ** ( 1 / 2))
        targ = 0
    else:
        for n in range(math.ceil(targ ** ( 1 / 3))):
            if minans == 0:
                break
            m = int(math.sqrt(targ - n**3))
            if (n ** 3) + (m **2) > targ:
                break
            if minans > targ - (n ** 3 + m**2) + n + m:
                minans = targ - (n ** 3 + m**2) + n + m
    if minans != float("inf"):
        print(minans)
    else:
        print(y + z)
    targ = int(input())
    if targ == 0:
        break

Submission status: Runtime Error

Solution code:
import math
targ = int(input())
y,z = 0,0
while True:
    minans = float("inf")
    for n in range(math.ceil(targ ** ( 1 / 3))+1):
        if minans == 0:
            break
        m = int(math.sqrt(targ - n**3))
        if (n ** 3) + (m **2) > targ:
            break
        if minans > targ - (n ** 3 + m**2) + n + m:
            minans = targ - (n ** 3 + m**2) + n + m
    if minans != float("inf"):
        print(minans)
    else:
        print(y + z)
    targ = int(input())
    if targ == 0:
        break

Submission status: Runtime Error

Solution code:
#coding: utf-8

def yis(z):
    for i in range(1000):
        if i * i > e - z * z * z:
            y = i - 1
            break
    return y


while True:
    e = int(raw_input())
    y = 0
    z = 0
    if e == 0:
        break
    for i in range(100):
        if i * i * i > e:
            z = i - 1
            break
    n = z
    m = e
    for i in range(n + 1):
        y = yis(z)
        m = min(m,e - y * y - z * z * z + y + z)
        z = z - 1
    print m

Submission status: Runtime Error

Solution code:
import math

# z ??¨ y ????±?????????????x????±?????????????
# ?????????????????°????????????e?????????????????? 10^5 ???
while True:
    e = int(input())
    if e == 0:
        break

    min_e = e
    for i in range( math.floor(pow(e, 1.0/3.0)) + 1 ):
        for j in range( math.floor(math.sqrt(e - i**3)) + 1):
            x = e - (i**3) - (j**2)
            y = j
            z = i
            # print(x)
            # print(y)
            # print(z)
            # print("")
            if ( (x + y + z) < min_e ):
                min_e = x + y + z

    print(min_e)

Submission status: Runtime Error

Solution code:
import sys

inf = 1<<30

def solve():
    while 1:
        e = int(sys.stdin.readline().rstrip())

        if e == 0:
            return

        ans = inf

        for z in range(int(e**(1/3)) + 10):
            if e - z**3 < 0:
                break

            for y in range(int((e - z**3)**0.5) + 10):
                x = e - z**3 - y**2

                if x < 0:
                    break

                ans = min(ans, x + y + z)

        print(ans)

if __name__ == '__main__':
    solve()

Submission status: Runtime Error

Solution code:
#grab
e=int(input())
while e>0:
    z=0
    while z**3<=e 
        z+=1
    z-=1
    e-=z**3
    y=0
    while y*y<=e:
        y+=1
    y-=1
    e-=y*y
    e+=y+z
    print(e)
    e=int(input())

Submission status: Runtime Error

Solution code:
Answer = []

while True:
    e = int(input())
    if e == 0:
        break

    m = e
    for z in range(int(e**(1/3)+1)):
        for y in range(int((e-z**3)**(1/2))+1):
            x = e-z**3-y**2
            m = min(m,x+y+z)
    Answer.append(m)

for i in range(len(Answer)):
    print(Answer[i])

Submission status: Runtime Error

Solution code:
Answer = []

while True:
    e = int(input())
    if e == 0:
        break

    m = e
    for z in range(int(e**(1/3)+1)):
        if e == z**3:
            m = min(m,z)
        else:
            for y in range(int((e-z**3)**(1/2)+1)):
                x = e-z**3-y**2
                m = min(m,x+y+z)
    Answer.append(m)

for i in range(len(Answer)):
    print(Answer[i])

Submission status: Runtime Error

Solution code:
def ok(m,e):
    for x in range(m+1):
        for y in range(m+1-x):
            z = m-x-y
            if z < 0: break
            if x + y**2 + z**3 == e: return True
    return False

while True:
    E = int(input())
    if E == 0: break
    m = 1
    while not ok(m,E):
        m += 1
    print(m)

Submission status: Runtime Error

Solution code:
def ok(m,e):
    for z in range(m+1):
        if z**3 > e: return False
        for y in range(m-z+1):
            x = m-z-y
            if x + y**2 + z**3 == e: return True
    return False

while True:
    E = int(input())
    if E == 0: break
    m = 1
    while not ok(m,E):
        m += 1
    print(m)

Submission status: Runtime Error

Solution code:
def ok(m,e):
    for z in range(m+1):
        if z**3 > e: return False
        for y in range(m-z+1):
            if z**3 + y**2 > e: break
            x = m-z-y
            if z**3 + y**2 + x == e: return True
    return False

while True:
    E = int(input())
    if E == 0: break
    m = 1
    while not ok(m,E):
        m += 1
    print(m)

Submission status: Runtime Error

Solution code:
while 1:
    e = int(input())
    if not e :break
    m = e
    for z in range(e):
        for y in range(e):
            if  e-y**2-z**3+y+z < 0 or e - y**2 -z**3 <0:break
            if m > e-y**2-z**3+y+z: m =  e-y**2-z**3+y+z
    print(m)

Submission status: Runtime Error

Solution code:
import numpy
while 1:
    e = int(input())
    if  e == 0 :break
    m = e
    for z in range(int(numpy.cbrt(e))+1):
        for y in range(int(numpy.sqrt(e) + 1)):
            if  e-y**2-z**3+y+z < 0 or e - y**2 -z**3 <0:break
            if m > e-y**2-z**3+y+z: m =  e-y**2-z**3+y+z
    print(m)

Submission status: Runtime Error

Solution code:
import math
while 1:
    e = int(input())
    if  e == 0 :break
    m = e
    for z in range(e):
        for y in range(int(math.sqrt(e))+ 1):
            if  e-y**2-z**3+y+z < 0 or e - y**2 -z**3 <0:break
            if m > e-y**2-z**3+y+z: m =  e-y**2-z**3+y+z
    print(m)

Submission status: Runtime Error

Solution code:
import math
while 1:
    e = int(input())
    if  e == 0 :break
    m = e
    for z in range(e):
        for y in range(int(math.sqrt(e))+ 1):
            if  e-y**2-z**3+y+z < 0 or e - y**2 -z**3 <0:break
            if m > e-y**2-z**3+y+z: m = e-y**2-z**3+y+z
    print(m)

Submission status: Runtime Error

Solution code:
import math
while 1:
    e = int(input())
    if  e == 0 :break
    m = e
    for z in range(int(math.sqrt(e)) + 1):
        for y in range(int(math.sqrt(e))+ 1):
            if  e-y**2-z**3+y+z < 0 or e - y**2 -z**3 <0:break
            if m > e-y**2-z**3+y+z: m = e-y**2-z**3+y+z
    print(m)

Submission status: Runtime Error

Solution code:
while True:
    e=int(input())
    if e==0:
        break
    m=e
    for z in range(int(e**(1/3))+1):
        temp=e-z**3
        for y in range(int(e**(1/2))+1):
            x=temp-y**2
            if x>=0 and (x+y+z<m):
                m=x+y+z
    print(m)

Submission status: Runtime Error

Solution code:
while True:
    e=int(input())
    if e==0:
        break
    m=e
    for z in range(int(e**(1/3))+1,-1,-1):
        temp=e-z**3
        for y in range(int(e**(1/2))+1,-1,-1):
            x=temp-y**2
            if x>=0 and (x+y+z<m):
                m=x+y+z
    print(m)

Submission status: Runtime Error

Solution code:
while True:
    e=int(input())
    if e==0:
        break
    m=e
    for z in range(int(e**(1/3))+1,-1,-1):
        temp=e-z**3
        for temp in range(int(e**(1/2))+1,-1,-1):
            x=temp-y**2
            if x>=0 and (x+y+z<m):
                m=x+y+z
    print(m)

Submission status: Runtime Error

Solution code:
while True:
    e=int(input())
    if e==0:
        break
    m=e
    for z in range(int(e**(1/3)),-1,-1):
        temp=e-z**3
        for y in range(int(temp**(1/2)),-1,-1):
            x=temp-y**2
            if x>=0 and (x+y+z<m):
                m=x+y+z
    print(m)

Submission status: Runtime Error

Solution code:
import math
while 1:
    e = int(input())
    if  e == 0 :break
    m = e
    for z in range(int(math.sqrt(e)) + 1):
        for y in range(int(math.sqrt(e))+ 1):
            x = e - y**2-z**3
            if  x <0:break
            if m > x+y+z: m = x+y+z
    print(m)

Submission status: Runtime Error

Solution code:
import math
while 1:
    e = int(input())
    if  e == 0 :break
    m = e
    for z in range(int(math.sqrt(e)) + 1):
        for y in range(int(math.sqrt(e))+ 1):
            x = e - y**2-z**3
            if  x < 0:continue
            if m > x+y+z: m = x+y+z
    print(m)

Submission status: Runtime Error

Solution code:
while True:
    e = int(input())
    if e == 0:
        break
    
    m = e + 1
    for y in range(e + 1):
        y2 = y ** 2
        if y2 > e:
            break
        for z in range(e + 1):
            z3 = z ** 3
            if z3 + y2 > e:
                break
            x = e - y2 - z3
            m = min(m, x + y + z)

    print(m)

Submission status: Runtime Error

Solution code:
while True:
    e = int(input())
    if e == 0:
        break
    
    m = e + 1
    y = 0
    while y <= e:
        y2 = y ** 2
        if y2 > e:
            break
        z = 0
        while z <= e:
            z3 = z ** 3
            if z3 + y2 > e:
                break
            x = e - y2 - z3
            m = min(m, x + y + z)
            z += 1
        y += 1
    print(m)

Submission status: Runtime Error

Solution code:
flg = True
while flg:
    e = int(input())
    if e == 0:
        break
    
    m = e + 1
    y = 0
    while y <= e:
        y2 = y ** 2
        if y2 > e:
            break
        z = 0
        while z <= e:
            z3 = z ** 3
            if z3 + y2 > e:
                break
            x = e - y2 - z3
            m = min(m, x + y + z)
            z += 1
        y += 1
    print(m)

Submission status: Runtime Error

Solution code:
while True:
    e = int(input())
    if e == 0:
        break
    
    m = e + 1
    y = 0
    while y ** 2 <= e:
        z = 0
        while y ** 2 + z ** 3 <= e:
            x = e - y ** 2 - z ** 3
            m = min(m, x + y + z)
            z += 1
        y += 1
    print(m)

Submission status: Runtime Error

Solution code:
while True:
    e = int(input())
    if e == 0:
        break
    
    m = e + 1
    y = 0
    while y ** 2 <= e:
        z = 0
        while y ** 2 + z ** 3 <= e:
            x = e - y ** 2 - z ** 3
            m = min(m, x + y + z)
            z += 1
        y += 1
    print(m)

Submission status: Runtime Error

Solution code:
while True:
    e = int(input().strip())
    if e == 0:
        break
    
    m = e + 1
    y = 0
    while y ** 2 <= e:
        z = 0
        while y ** 2 + z ** 3 <= e:
            x = e - y ** 2 - z ** 3
            m = min(m, x + y + z)
            z += 1
        y += 1
    print(m)

Submission status: Runtime Error

Solution code:
while True:
    e = int(input())
    temp = 10**6
    if e == 0:
        break
    for z in range(int(e**(1/3)+1)):
        for y in range(int((e-z**3)**(1/2)+1)):
            x = e-z**3-y**2
            if x+y+z < temp:
                temp = x+y+z
    print(temp)

Submission status: Runtime Error

Solution code:
while(True):
  e = int(input())
  if e == 0:
    quit()
  ans = e
  for i in range(0,int(e ** (1/3))+1):
      for j in range(0,int((e - i ** 3)**0.5)+1):
          k = e - i ** 3 - j ** 2 + i + j
          if k < ans:
              ans = k
  print(ans)

Submission status: Runtime Error

Solution code:
while(True):
  e = int(input())
  if e == 0:
    quit()
  ans = e
  for i in range(0,int(e ** (1/3))+1):
      for j in range(0,int((e - i ** 3)**0.5)+1):
          k = e - i ** 3 - j ** 2 + i + j
          if k < ans:
              ans = k
  print(ans)

Submission status: Runtime Error

Solution code:
import math


def solve(e):
    k = []
    for z in range(99, -1, -1):
        z3 = z * z * z
        if z3 > e:
            continue
        e2 = e - z3

        ylm = int(math.sqrt(e2))
        xzlm = 3 * z * z + 3 * z + 1

        for y in range(ylm, -1, -1):
            y2 = y * y
            if y2 > e2:
                continue
            e3 = e2 - y2

            xylm = 2 * y + 1
            x = e3
            if x > xylm or x > xzlm:
                continue
            k.append(z + y + x)
    return sorted(k)[0]


def main():
    while True:
        a = int(input())

        if a == 0:
            break

        print(solve(a))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math


def solve(e):
    k = 2 ** 32
    for z in range(99, -1, -1):
        z3 = z * z * z
        if z3 > e:
            continue
        e2 = e - z3

        ylm = int(math.sqrt(e2))
        xzlm = 3 * z * z + 3 * z + 1

        for y in range(ylm, -1, -1):
            y2 = y * y
            if y2 > e2:
                continue
            e3 = e2 - y2

            xylm = 2 * y + 1
            x = e3
            if x > xylm or x > xzlm:
                continue
            k = min(k, x + y + z)
    return k


def main():
    while True:
        a = int(input())

        if a == 0:
            break

        print(solve(a))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
 # 宇都宮涼
 # J5-170029
 # Space Coconut Grab
 # http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2012
 # 右中央
while True:
    e = int(input())
    temp = 10**6
    if e == 0:
        break
    for z in range(int(e**(1/3)+1)):
        for y in range(int((e-z**3)**(1/2)+1)):
            x = e-z**3-y**2
            if x+y+z < temp:
                temp = x+y+z
    print(temp)

Submission status: Runtime Error

Solution code:
'''
JAG Domestic 2007 'Space Coconut Grab'
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2012
'''

ans_list = []

while True:
    e = int(input())
    if e == 0:
        break
    else:
        ans = e
        for z in range(1, e+1):
            z3 = z ** 3
            if z3 < e:
                for y in range(1, e-z3+1):
                    y2 = y ** 2
                    if y2 < e - z3:
                        x = e - z3 - y2
                        s = x + y + z
                        if s < ans:
                            ans = s
                    else:
                        break
            else:
                break
        ans_list.append(ans)

for x in ans_list:
    print(x)