Problem p02690 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    def main():
        X=int(input())
        for a in range(-200,200):
            for b in range(-200,200):
                if pow(a,5)-pow(b,5)==X:
                    return [a,b]
    print(*main())

resolve()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    def main():
        X=int(input())
        for a in range(-100,100):
            for b in range(-100,100):
                if pow(a,5)-pow(b,5)==X:
                    return [a,b]
    print(*main())

resolve()

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    def make_divisors(n):
        divisors = []
        divisors2 = []
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                divisors.append(i)
                divisors2.append(n // i)
                divisors.append(-i)
                divisors2.append(n // -i)

                if i != n // i:  # 平方数の場合n**0.5を1つだけにしてる
                    divisors.append(n // i)
                    divisors2.append(i)
                    divisors.append(-(n // i))
                    divisors2.append(-i)

        # divisors.sort() # ソートしたけりゃして
        return [divisors, divisors2]

    def main():
        X = int(input())

        d, d2 = make_divisors(X)[0], make_divisors(X)[1]
        i = 0
        b = 0
        while True:
            a = d[i] + b
            val = a ** 4 + a ** 3 * b + a ** 2 * b ** 2 + a * b ** 3 + b ** 4

            if val == d2[i]:
                return [a, b]
            if val > abs(d2[i]):
                i += 1
                b = 0
                if i >= len(d):
                    break
            else:
                b += 1

        i = 0
        b = -1
        while True:
            a = d[i] + b
            val = a ** 4 + a ** 3 * b + a ** 2 * b ** 2 + a * b ** 3 + b ** 4
            if val == d2[i]:
                return [a, b]
            if val > abs(d2[i]):
                i += 1
                b = -1
                if i >= len(d):
                    break
            else:
                b -= 1

    print(*main())


resolve()

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    def make_divisors(n):
        divisors = []
        divisors2 = []
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                divisors.append(i)
                divisors2.append(n // i)
                if i != n // i:  # 平方数の場合n**0.5を1つだけにしてる
                    divisors.append(n // i)
                    divisors2.append(i)

        # divisors.sort() # ソートしたけりゃして
        return [divisors, divisors2]

    def main():
        X = int(input())

        d, d2 = make_divisors(X)[0], make_divisors(X)[1]
        i = 0
        while True:
            b = 0
            if i >= len(d):
                break
            while True:
                a = d[i] + b
                val = a ** 4 + a ** 3 * b + a ** 2 * b ** 2 + a * b ** 3 + b ** 4
                if val == d2[i]:
                    return [a, b]
                if val > d2[i]:
                    i += 1
                    b=0
                    if i >= len(d):
                        break
                else:
                    b += 1
        i = 0
        while True:
            b = -1
            if i >= len(d):
                break
            while True:
                a = d[i] + b
                val = a ** 4 + a ** 3 * b + a ** 2 * b ** 2 + a * b ** 3 + b ** 4
                if val == d2[i]:
                    return [a, b]
                if val > d2[i]:
                    i += 1
                    b=-1
                    if i >= len(d):
                        break
                else:
                    b -= 1

    print(*main())


resolve()