Problem p02690 (python)

Fixed submission:
# coding: utf-8
from bisect import bisect_left


def solve(*args: str) -> str:
    x = int(args[0])

    P = [pow(i, 5) for i in range(128)]
    ret = None
    for b, b5 in enumerate(P):
        a5 = x+b5
        like_a = bisect_left(P, a5)
        if like_a < len(P):
            if P[like_a] == a5:
                ret = (like_a, b)
                break

        a5 = abs(x-b5)
        like_a = bisect_left(P, a5)
        if like_a < len(P):
            if P[like_a] == a5:
                ret = (like_a if b5 < x else -like_a, -b)
                break

    return ' '.join(map(str, ret))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Buggy submission (verdict: Runtime Error):
# coding: utf-8


def solve(*args: str) -> str:
    x = int(args[0])

    ret = None
    for a in range(120):
        for b in range(a, 120):
            a5, b5 = pow(a, 5), pow(b, 5)
            if a5-b5 == x:
                ret = (a, b)
            elif a5+b5 == x:
                ret = (a, -b)

    return ' '.join(map(str, ret))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
from bisect import bisect_left


def solve(*args: str) -> str:
    x = int(args[0])

    P = [pow(i, 5) for i in range(64)]
    ret = None
    for b, b5 in enumerate(P):
        a5 = x+b5
        like_a = bisect_left(P, a5)
        if like_a < len(P):
            if P[like_a] == a5:
                ret = (like_a, b)
                break

        a5 = abs(x-b5)
        like_a = bisect_left(P, a5)
        if like_a < len(P):
            if P[like_a] == a5:
                ret = (like_a if b5 < x else -like_a, -b)
                break

    return ' '.join(map(str, ret))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
from bisect import bisect_left


def solve(*args: str) -> str:
    x = int(args[0])

    P = [pow(i, 5) for i in range(64)]
    ret = None
    for b, b5 in enumerate(P):
        a5 = x+b5
        like_a = bisect_left(P, a5)
        if like_a < len(P):
            if P[like_a] == a5:
                ret = (like_a, b)
                break

        a5 = abs(x-b5)
        like_a = bisect_left(P, like_a)
        if like_a < len(P):
            if P[like_a] == a5:
                ret = (like_a if b5 < x else -like_a, -b)
                break

    return ' '.join(map(str, ret))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
from bisect import bisect_left


def solve(*args: str) -> str:
    x = int(args[0])

    P = [pow(i, 5) for i in range(64)]
    ret = None
    for b, b5 in enumerate(P):
        a5 = x+b5
        like_a = bisect_left(P, a5)
        if P[like_a] == a5:
            ret = (like_a, b)
            break

        a5 = abs(x-b5)
        like_a = bisect_left(P, like_a)
        if P[like_a] == a5:
            ret = (like_a if b5 < x else -like_a, -b)
            break

    return ' '.join(map(str, ret))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))