Buggy python submission (verdict: Time Limit Exceeded):
import math

def main(X):
    end = False
    lst = f(X)
    # print(lst)
    for L in lst:
        if end:
            break
        else:
            for l in L:
                B = 1
                A = B + l[0]
                while g(A, B) > l[1]:
                    if g(A, B) < g(A + 1, B + 1):
                        break
                    B += 1
                    A = B + l[0]
                while g(A, B) <= l[1]:
                    if g(A, B) == l[1]:
                        print(A, B)
                        end = True
                        break
                    B += 1
                    A = B + l[0]
                # ***********************
                if end:
                    break
                else:
                    B = -1
                    A = B + l[0]
                    while g(A, B) > l[1]:
                        if g(A, B) < g(A - 1, B - 1):
                            break
                        B -= 1
                        A = B + l[0]
                    while g(A, B) <= l[1]:
                        if g(A, B) == l[1]:
                            print(A, B)
                            end = True
                            break
                        B -= 1
                        A = B + l[0]
                if end:
                    break


def f(X):
    return [[[X // i, i], [i, X // i]] for i in range(1, math.floor(X ** 0.5) + 1) if X % i == 0]

def g(A, B):
    return (A ** 4) + (A ** 3) * B + (A ** 2) * (B ** 2) + A * (B ** 3) + (B ** 4)



if __name__ == '__main__':
    X = int(input())
    main(X)


Fixed submission:
import math

def main(X):
    lst = f(X)
    for L in lst:
        for l in L:
            for B in range(-120, 120, 1):
                A = B + l[0]
                if g(A, B):
                    print(A, B)
                    exit()

def f(X):
    return [[[X // i, i], [i, X // i]] for i in range(1, math.floor(X ** 0.5) + 1) if X % i == 0]

def g(A, B):
    return A ** 5 - B ** 5 == X



if __name__ == '__main__':
    X = int(input())
    main(X)

Buggy python submission (verdict: Time Limit Exceeded):
import math

def main(X):
    end = False
    lst = f(X)
    # print(lst)
    for L in lst:
        if end:
            break
        else:
            for l in L:
                B = 1
                A = B + l[0]
                while g(A, B) > l[1]:
                    if g(A, B) < g(A + 1, B + 1):
                        break
                    B += 1
                    A = B + l[0]
                while g(A, B) <= l[1]:
                    if g(A, B) == l[1]:
                        print(A, B)
                        end = True
                        break
                    B += 1
                    A = B + l[0]
                # ***********************
                if end:
                    break
                else:
                    B = -1
                    A = B + l[0]
                    while g(A, B) > l[1]:
                        if g(A, B) < g(A - 1, B - 1):
                            break
                        B -= 1
                        A = B + l[0]
                    while g(A, B) <= l[1]:
                        if g(A, B) == l[1]:
                            print(A, B)
                            end = True
                            break
                        B -= 1
                        A = B + l[0]
                if end:
                    break


def f(X):
    return [[[X // i, i], [i, X // i]] for i in range(1, math.floor(X ** 0.5) + 1) if X % i == 0]

def g(A, B):
    return (A ** 4) + (A ** 3) * B + (A ** 2) * (B ** 2) + A * (B ** 3) + (B ** 4)



if __name__ == '__main__':
    X = int(input())
    main(X)


Fixed submission:
import math

def main(X):
    lst = f(X)
    for L in lst:
        for l in L:
            for B in range(-120, 120, 1):
                A = B + l[0]
                if g(A, B):
                    print(A, B)
                    exit()

def f(X):
    return [[[X // i, i], [i, X // i]] for i in range(1, math.floor(X ** 0.5) + 1) if X % i == 0]

def g(A, B):
    return A ** 5 - B ** 5 == X



if __name__ == '__main__':
    X = int(input())
    main(X)