Problem p02690 (python)

Fixed submission:
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    X = int(input())
    for B in range(1001):
        A5 = X + B ** 5
        A = int(A5 ** 0.2) if A5 > 0 else int((-A5) ** 0.2) * -1
        if A ** 5 == A5:
            print(A, B)
            return 

        A5 = X - B ** 5
        A = int(A5 ** 0.2) if A5 > 0 else int((-A5) ** 0.2) * -1
        if A ** 5 == A5:
            print(A, -B)
            return 

    print(-1)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    X = int(input())
    for B in range(501):
        A5 = X + B ** 5
        A = int(A5 ** 0.2)
        if A ** 5 == A5:
            print(A, B)
            return 

        A5 = X - B ** 5
        A = int(A5 ** 0.2)
        if A ** 5 == A5:
            print(A, -B)
            return 

    print(-1)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    X = int(input())
    for B in range(1001):
        A5 = X + B ** 5
        A = int(A5 ** 0.2)
        if A ** 5 == A5:
            print(A, B)
            return 

        A5 = X - B ** 5
        A = int(A5 ** 0.2)
        if A ** 5 == A5:
            print(A, -B)
            return 


if __name__ == "__main__":
    main()