Problem p02690 (python)

Fixed submission:
x = int(input())
for a in range(-1000, 1000):
    can = False
    for b in range(-1000, 1000):
        if (a ** 5) - (b ** 5) == x:
            print(a, b)
            can = True
            break
    if can:
        break

Buggy submission (verdict: Runtime Error):
x = int(input())
import math
#print(x)
for i in range(1000000):
    a = x + (i ** 5)
    a2 = x - (i ** 5)
    #print("i", i, "a", a, "a2", a2)

    if a > 0:
        v = math.pow(a, 1.0/5.0)
        if v.is_integer():
            v=int(v)
            if (i ** 5 - (v ** 5) ) == x:
                print(i, v)
                break
            if (i ** 5 - (-v ** 5) ) == x:
                print(i, -v)
                break
            if (-i ** 5 - (v ** 5) ) == x:
                print(-i, v)
                break
            if (-i ** 5 - (-v ** 5) ) == x:
                print(-i, -v)
                break
            if (v ** 5 - (i ** 5)) == x:
                print(v, i)
                break
            if (v ** 5 - (-i ** 5)) == x:
                print(v, -i)
                break
            if (-v ** 5 - (i ** 5)) == x:
                print(-v, i)
                break
            if (-v ** 5 - (-i ** 5)) == x:
                print(-v, -i)
                break
    else:
        v = math.pow(-a, 1.0 / 5.0)
        if v.is_integer():
            v=int(v)
            if (i ** 5 - (v ** 5) ) == x:
                print(i, v)
                break
            if (i ** 5 - (-v ** 5) ) == x:
                print(i, -v)
                break
            if (-i ** 5 - (v ** 5) ) == x:
                print(-i, v)
                break
            if (-i ** 5 - (-v ** 5) ) == x:
                print(-i, -v)
                break
            if (v ** 5 - (i ** 5)) == x:
                print(v, i)
                break
            if (v ** 5 - (-i ** 5)) == x:
                print(v, -i)
                break
            if (-v ** 5 - (i ** 5)) == x:
                print(-v, i)
                break
            if (-v ** 5 - (-i ** 5)) == x:
                print(-v, -i)
                break


    if a2 > 0:
        v = math.pow(a2, 1.0/5.0)
        if v.is_integer():
            v=int(v)
            if (i ** 5 - (v ** 5) ) == x:
                print(i, v)
                break
            if (i ** 5 - (-v ** 5) ) == x:
                print(i, -v)
                break
            if (-i ** 5 - (v ** 5) ) == x:
                print(-i, v)
                break
            if (-i ** 5 - (-v ** 5) ) == x:
                print(-i, -v)
                break
            if (v ** 5 - (i ** 5)) == x:
                print(v, i)
                break
            if (v ** 5 - (-i ** 5)) == x:
                print(v, -i)
                break
            if (-v ** 5 - (i ** 5)) == x:
                print(-v, i)
                break
            if (-v ** 5 - (-i ** 5)) == x:
                print(-v, -i)
                break
    else:
        v = math.pow(-a, 1.0 / 5.0)
        if v.is_integer():
            v=int(v)
            if (i ** 5 - (v ** 5) ) == x:
                print(i, v)
                break
            if (i ** 5 - (-v ** 5) ) == x:
                print(i, -v)
                break
            if (-i ** 5 - (v ** 5) ) == x:
                print(-i, v)
                break
            if (-i ** 5 - (-v ** 5) ) == x:
                print(-i, -v)
                break
            if (v ** 5 - (i ** 5)) == x:
                print(v, i)
                break
            if (v ** 5 - (-i ** 5)) == x:
                print(v, -i)
                break
            if (-v ** 5 - (i ** 5)) == x:
                print(-v, i)
                break
            if (-v ** 5 - (-i ** 5)) == x:
                print(-v, -i)
                break

Buggy submission (verdict: Runtime Error):
x = int(input())
import math
#print(x)
for i in range(1000000):
    a = x + (i ** 5)
    a2 = x - (i ** 5)
    #print("i", i, "a", a, "a2", a2)

    if a > 0:
        v = math.pow(a, 1.0/5.0)
        if v.is_integer():
            v=int(v)
            if (i ** 5 - (v ** 5) ) == x:
                print(i, v)
                break
            if (i ** 5 - (-v ** 5) ) == x:
                print(i, -v)
                break
            if (-i ** 5 - (v ** 5) ) == x:
                print(-i, v)
                break
            if (-i ** 5 - (-v ** 5) ) == x:
                print(-i, -v)
                break
            if (v ** 5 - (i ** 5)) == x:
                print(v, i)
                break
            if (v ** 5 - (-i ** 5)) == x:
                print(v, -i)
                break
            if (-v ** 5 - (i ** 5)) == x:
                print(-v, i)
                break
            if (-v ** 5 - (-i ** 5)) == x:
                print(-v, -i)
                break
    else:
        v = math.pow(-a, 1.0 / 5.0)
        if v.is_integer():
            v=int(v)
            if (i ** 5 - (v ** 5) ) == x:
                print(i, v)
                break
            if (i ** 5 - (-v ** 5) ) == x:
                print(i, -v)
                break
            if (-i ** 5 - (v ** 5) ) == x:
                print(-i, v)
                break
            if (-i ** 5 - (-v ** 5) ) == x:
                print(-i, -v)
                break
            if (v ** 5 - (i ** 5)) == x:
                print(v, i)
                break
            if (v ** 5 - (-i ** 5)) == x:
                print(v, -i)
                break
            if (-v ** 5 - (i ** 5)) == x:
                print(-v, i)
                break
            if (-v ** 5 - (-i ** 5)) == x:
                print(-v, -i)
                break


    if a2 > 0:
        v = math.pow(a2, 1.0/5.0)
        if v.is_integer():
            v=int(v)
            if (i ** 5 - (v ** 5) ) == x:
                print(i, v)
                break
            if (i ** 5 - (-v ** 5) ) == x:
                print(i, -v)
                break
            if (-i ** 5 - (v ** 5) ) == x:
                print(-i, v)
                break
            if (-i ** 5 - (-v ** 5) ) == x:
                print(-i, -v)
                break
            if (v ** 5 - (i ** 5)) == x:
                print(v, i)
                break
            if (v ** 5 - (-i ** 5)) == x:
                print(v, -i)
                break
            if (-v ** 5 - (i ** 5)) == x:
                print(-v, i)
                break
            if (-v ** 5 - (-i ** 5)) == x:
                print(-v, -i)
                break
    else:
        v = math.pow(-a, 1.0 / 5.0)
        if v.is_integer():
            v=int(v)
            if (i ** 5 - (v ** 5) ) == x:
                print(i, v)
                break
            if (i ** 5 - (-v ** 5) ) == x:
                print(i, -v)
                break
            if (-i ** 5 - (v ** 5) ) == x:
                print(-i, v)
                break
            if (-i ** 5 - (-v ** 5) ) == x:
                print(-i, -v)
                break
            if (v ** 5 - (i ** 5)) == x:
                print(v, i)
                break
            if (v ** 5 - (-i ** 5)) == x:
                print(v, -i)
                break
            if (-v ** 5 - (i ** 5)) == x:
                print(-v, i)
                break
            if (-v ** 5 - (-i ** 5)) == x:
                print(-v, -i)
                break

Buggy submission (verdict: Runtime Error):
x = int(input())
import math
print(x)
for i in range(1000000):
    a = x + (i ** 5)
    a2 = x - (i ** 5)
    #print("i", i, "a", a, "a2", a2)

    if a > 0:
        v = math.pow(a, 1.0/5.0)
        if v.is_integer():
            v=int(v)
            if (i ** 5 - (v ** 5) ) == x:
                print(i, v)
                break
            if (i ** 5 - (-v ** 5) ) == x:
                print(i, -v)
                break
            if (-i ** 5 - (v ** 5) ) == x:
                print(-i, v)
                break
            if (-i ** 5 - (-v ** 5) ) == x:
                print(-i, -v)
                break
            if (v ** 5 - (i ** 5)) == x:
                print(v, i)
                break
            if (v ** 5 - (-i ** 5)) == x:
                print(v, -i)
                break
            if (-v ** 5 - (i ** 5)) == x:
                print(-v, i)
                break
            if (-v ** 5 - (-i ** 5)) == x:
                print(-v, -i)
                break
    else:
        v = math.pow(-a, 1.0 / 5.0)
        if v.is_integer():
            v=int(v)
            if (i ** 5 - (v ** 5) ) == x:
                print(i, v)
                break
            if (i ** 5 - (-v ** 5) ) == x:
                print(i, -v)
                break
            if (-i ** 5 - (v ** 5) ) == x:
                print(-i, v)
                break
            if (-i ** 5 - (-v ** 5) ) == x:
                print(-i, -v)
                break
            if (v ** 5 - (i ** 5)) == x:
                print(v, i)
                break
            if (v ** 5 - (-i ** 5)) == x:
                print(v, -i)
                break
            if (-v ** 5 - (i ** 5)) == x:
                print(-v, i)
                break
            if (-v ** 5 - (-i ** 5)) == x:
                print(-v, -i)
                break


    if a2 > 0:
        v = math.pow(a2, 1.0/5.0)
        if v.is_integer():
            v=int(v)
            if (i ** 5 - (v ** 5) ) == x:
                print(i, v)
                break
            if (i ** 5 - (-v ** 5) ) == x:
                print(i, -v)
                break
            if (-i ** 5 - (v ** 5) ) == x:
                print(-i, v)
                break
            if (-i ** 5 - (-v ** 5) ) == x:
                print(-i, -v)
                break
            if (v ** 5 - (i ** 5)) == x:
                print(v, i)
                break
            if (v ** 5 - (-i ** 5)) == x:
                print(v, -i)
                break
            if (-v ** 5 - (i ** 5)) == x:
                print(-v, i)
                break
            if (-v ** 5 - (-i ** 5)) == x:
                print(-v, -i)
                break
    else:
        v = math.pow(-a, 1.0 / 5.0)
        if v.is_integer():
            v=int(v)
            if (i ** 5 - (v ** 5) ) == x:
                print(i, v)
                break
            if (i ** 5 - (-v ** 5) ) == x:
                print(i, -v)
                break
            if (-i ** 5 - (v ** 5) ) == x:
                print(-i, v)
                break
            if (-i ** 5 - (-v ** 5) ) == x:
                print(-i, -v)
                break
            if (v ** 5 - (i ** 5)) == x:
                print(v, i)
                break
            if (v ** 5 - (-i ** 5)) == x:
                print(v, -i)
                break
            if (-v ** 5 - (i ** 5)) == x:
                print(-v, i)
                break
            if (-v ** 5 - (-i ** 5)) == x:
                print(-v, -i)
                break