Problem:


Score : 400 points

Problem Statement

Give a pair of integers (A, B) such that A^5-B^5 = X.
It is guaranteed that there exists such a pair for the given integer X.

Constraints

1 \leq X \leq 10^9

X is an integer.

There exists a pair of integers (A, B) satisfying the condition in Problem Statement.

Input

Input is given from Standard Input in the following format:

X

Output

Print A and B, with space in between.
If there are multiple pairs of integers (A, B) satisfying the condition, you may print any of them.

A B

Sample Input 1

33

Sample Output 1

2 -1

For A=2 and B=-1, A^5-B^5 = 33.

Sample Input 2

1

Sample Output 2

0 -1



Sample input:
33


Sample output:
2 -1

Submission status: Runtime Error

Solution code:
x = int(input())
if x == 1:
  print(0,-1)
  exit()
  
def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a

c = []
fct = factorize(x)
for div in divisorize(fct):
    c.append(num(div))
    
chk = False
#print(c)
for s in c:
  if chk:
    break
  for i in range(10000):
    if (i+s)**5-i**5 > x:
      break
    if (i+s)**5-i**5 == x:
      ans = (i+s,i)
      chk = True
      break
  for p in range(1,10000):
    j = -1*p
    #print(s,(j+s)**5-j**5)
    if (j+s)**5-j**5 > x:
      break 
    if (j+s)**5-j**5 == x:
      ans = (j+s,j)
      chk = True
      break 

print(*ans)

Submission status: Runtime Error

Solution code:
x = int(input())

my_dict = dict()

for i in range(1000):
    my_dict[i**5] = i

for i in range(-1000, 1000):
    target = x + (i ** 5)
    if (- target) in my_dict:
        print(-my_dict[target], i)
        exit()
    elif target in my_dict:
        print(my_dict[target], i)
        exit()

Submission status: Runtime Error

Solution code:
X=int(input())
Ans=[]
for n in range(65):
    for n1 in range(65):
        n2=n**5+n1**5
        if n2 == X:
            Ans.append(n)
            Ans.append(-1*n1)
            break

if len(Ans)==0:
    for n3 in range(80,2500):
        for n4 in range(n3-79):
            n2=n3**5-n4**5
            if n2 == X:
                Ans.append(n3)
                Ans.append(n4)
                break

print(Ans[0],Ans[1])

Submission status: Runtime Error

Solution code:
x = int(input())

if x==1:
    print(0,-1);exit()

num_li = [i**5 for i in range(1,100)]

for i in range(100):
    a = num_li[i]
    if x-a in num_li:
        b = num_li.index(x-a)+1
        a = -(num_li.index(a)+1)
        break
    if x+a in num_li:
        b = num_li.index(x+a)+1
        a = num_li.index(a)+1
        break

print(b,a)

Submission status: Runtime Error

Solution code:
x=int(input())

for i in range(2,int(x**0.5)+1):
  if x%i==0:
    q=i
    #print(q)
    break

for i in range(-100000,100000):
  if (i+q)**5-i**5==x:
    break
print(i+q,i)

Submission status: Runtime Error

Solution code:
#! python3
import sys
def main():
    x = int(input())
    alist = list(range(-x, x+1))

    for i in alist:
        a = int(i)
        for u in alist:
            b = int(u)
            if a -b != 0:
                if x % (a - b) == 0:
                    if (a**5 - b**5) == x:
                        print(a, b)
                        sys.exit()


main()

Submission status: Runtime Error

Solution code:
import numpy as np
X = int(input())

t = np.arange(-1000000, 1000001, 1)
t = t**5
S = set(t)

for B in range(-100000,100001,1):
    if X+B**5 in S:
        print("%d %d"%((X+B**5)**0.2, B))
        break

Submission status: Runtime Error

Solution code:
X = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

Xsep = factorization(X)

for s,n in Xsep:
    a = 1
    b = a - s
    condition = True
    while condition:
        temp1 = a - b
        temp2 = a**4 + b*a**3 + b**2*a**2 + b**3*a + b**4
        if temp1*temp2==X:
            condition = False
            print(a,b)
        elif temp1*temp2
        else:
            a += 1
            b += 1
    break

Submission status: Runtime Error

Solution code:
X=int(input())
Y=int(X**(0.2))
for i in range(Y,-Y,-1):
    for t in (-Y,Y,1):
        if i**5-t**5==X:
            S=i
            Z=t
            break
print(S,Z)

Submission status: Runtime Error

Solution code:
X=int(input())
Ans=[]
for n in range(65):
    for n1 in range(65):
        n2=n**5+n1**5
        if n2 == X:
            Ans.append(n)
            Ans.append(-1*n1)
            break

if len(Ans)==0:
    for n3 in range(80,2000):
        for n4 in range(n3):
            n2=n3**5-n4**5
            if n2 == X:
                Ans.append(n3)
                Ans.append(n4)
                break

print(Ans[0],Ans[1])

Submission status: Runtime Error

Solution code:
def resolve():
    # 整数 1 つ
    x = int(input())
    # 整数複数個
    # a, b, c = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    end = False

    for a in range(10**9):
        if a ** 5 = x:
            print(a, 0)
            end = True
            break
        if a**5 < x:
            for b in range(10**9):
                if b**5 > (x - a**5):
                    break
                if math.log((x - a**5), b).is_integer() == True:
                    print(a, b)
                    end = True
                    break
        if a**5 > x:
            for b in range(10**9):
                c = b * (-1)
                if c**5 < (x - a**5):
                    break
                if math.log((x - a**5), c).is_integer() == True:
                    print(a, b)
                    end = True
                    break
        if end == True
                    break

resolve()

Submission status: Runtime Error

Solution code:
from decimal import Decimal
X= int(input())
B=1
while True:
    A=Decimal((X+B**5)**(1/5))
    if int(A)==A and A>B:
        print(A,B)
        break
    else:
        if B>=0:
            B=-1*B       
        else:
            B=-1*B+1

Submission status: Runtime Error

Solution code:
import numpy as np


def solve(vec, is_complex=True):
    dim = len(vec)
    if is_complex:
        A = np.zeros((dim, dim), dtype=complex)
    else:
        A = np.zeros((dim, dim))
    A[np.arange(dim - 1), 1 + np.arange(dim - 1)] = 1
    A[-1, :] = -vec
    ans, vec = np.linalg.eig(A)
    return ans


def make_divisors(n):
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            d = n // i
            ans = np.array([((i ** 4) -d)/5, (i ** 3), (i ** 2) * 2, i * 2])
            for x in ans:
                try:
                    if x.is_integer():
                        if x**5-(i-x)**5 == d:
                            return [int(x), int(i-x)]
                except:
                    continue
m=int(input())
print(*make_divisors(m))

Submission status: Runtime Error

Solution code:
x = int(input())
p = list(map(int,input().split()))
c = 0
l = 0
r = len(p)
for i in range(r):
  for j in range(l+1,r):
    if p[l]+p[j] == j-i:
      c = c+1
  l = l+1
print(c)

Submission status: Runtime Error

Solution code:
import sys

def debug(*args):
    print(*args, file=sys.stderr)

# https://www.themathpage.com/Alg/difference-two-squares-2.htm#fifth

# https://qiita.com/snow67675476/items/e87ddb9285e27ea555f8
def factorize(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def get_factors_of(a_number):
    factorized = factorize(a_number)
    return [factor for factor, _ in factorized]


x_diff_of_5th_factor = int(input())

factors_of_x = get_factors_of(x_diff_of_5th_factor)

# debug(factors_of_x)

for a_factor_of_x in factors_of_x:
    for a in range(a_factor_of_x//2+1):
        b = a - a_factor_of_x

        if a ** 5 - b ** 5 == x_diff_of_5th_factor:
            print('{} {}'.format(a, b))
            sys.exit(0)
print('0 0')
sys.exit(1)

Submission status: Runtime Error

Solution code:

n = int(input())
x=n
pf={}
for i in range(2,int(n**0.5)+1):
    while n % i == 0:
        pf[i] = pf.get(i,0)+1
        n//= i
if n > 1 : pf[n] = 1

# print((list(pf.keys()))[0]) #素因数分解したときの最小の因数取得
lis=[]
for b in range(-1000,1000):
    a=b+int(list(pf.keys())[0])
    siki=a**4 + a**3*b + a**2*b**2 + a*b**3 + b**4
    if siki==x/int(list(pf.keys())[0]):
        lis.append((a,b))
print(*lis[0])

Submission status: Runtime Error

Solution code:
X=int(input())
Ans=[]
for n in range(65):
    for n1 in range(65):
        n2=n**5+n1**5
        if n2 == X:
            Ans.append(n)
            Ans.append(-1*n1)
            break

if len(Ans)==0:
    for n3 in range(80,1800):
        for n4 in range(n3):
            n2=n3**5-n4**5
            if n2 == X:
                Ans.append(n3)
                Ans.append(n4)
                break

print(Ans[0],Ans[1])

Submission status: Runtime Error

Solution code:
x = int(input())
if x == 1:
  print(0,-1)
  exit()
  
def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a

c = []
fct = factorize(x)
for div in divisorize(fct):
    c.append(num(div))
    
chk = False
#print(c)
for s in c:
  if chk:
    break
  for i in range(1000):
    if (i+s)**5-i**5 > x:
      break
    if (i+s)**5-i**5 == x:
      ans = (i+s,i)
      chk = True
      break
  for p in range(1,1000):
    j = -1*p
    #print(s,(j+s)**5-j**5)
    if (j+s)**5-j**5 > x:
      break 
    if (j+s)**5-j**5 == x:
      ans = (j+s,j)
      chk = True
      break 

print(*ans)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3


def main():
    N = int(input())
    A = [i for i in map(int, input().split())]
    #print (N, A)
    gsize = 10
    numg = (N - 1) // gsize + 1
    maxg = [0] * numg
    ming = [0] * numg
    size = len(A)
    for g in range(0, numg):
        gA = A[gsize*g:min(gsize*(g+1), size)]
        maxg[g] = max(gA)
        ming[g] = min(gA)

    count = 0
    for g1 in range(0, numg):
        for g2 in range(g1, numg):
            #print('checking group', g1, g2)
            gd = abs(g1 - g2)
            if maxg[g1] + maxg[g2] < gsize * (gd - 1):
                continue
            if ming[g1] + ming[g2] > gsize * (gd + 1):
                continue
            for g1i in range(gsize*g1, min(gsize*(g1+1), size)):
                for g2i in range(max(g1i+1, gsize*g2), min(gsize*(g2+1), size)):
                    d = abs(g1i - g2i)
                    if A[g1i] + A[g2i] == d:
                        count += 1
    print(count)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
# ABC166 D

def main():
    x = int(input())
    res = 0

    for i in range(-64, 65):
        for j in range(-64, 65):
            if i**5 - j**5 == x:
                res = [i, j]
                break
        if res:
            break
    
    print(res[0], res[1])
                

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
x = int(input())
a = 1
b = 0
A = []

while True:
    if A[-1] > 10 ** 9:
        break
    A.append(a ** 5 - x)
    a = a + 1

while True:
    if b ** 5 in A:
        break
    elif -b ** 5 in A:
        b = -b
        break
    b = b + 1

a = int((x + b ** 5) ** 0.2)

print(a, b)

Submission status: Runtime Error

Solution code:
x = int(input())

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

    divisors.sort()
    return divisors

flag = 0
divisors = make_divisors(x)
while flag!=-1:
  p = divisors[flag]
  a = 1
  while 1==1:
    b = a-p
    ans = a**5-b**5
    if ans > x:
      break
    if ans == x:
      print(a,b)
    a += 1
  flag += 1

Submission status: Runtime Error

Solution code:
x = int(input())
start = int(pow(x,0.2))+1
for i in range(-start,start):
    k = pow(x + pow(i,5),0.2)
    k = round(k,6)
    if type(k) != type(1+1j) and pow(int(k),5) - pow(i,5) == x:
        print(int(k),i)
        exit()

Submission status: Runtime Error

Solution code:
n = int(input())
a = input().split()
pl = []
sb = []
for i in range(len(a)):
	pl.append(i+int(a[i])+1)
	if i - int(a[i]) > 1:
		sb.append(i-int(a[i])+1)


if len(sb) == 0:
	print('0')
else:

# spl = sorted(pl)
	isb = [int(i) for i in sb]
	ipl = [int(i) for i in pl]
	ssb = sorted(isb)
	t = min(ssb)
	tl = [0] * max(ipl)
	for i in ssb:
		if int(i)-1 < len(tl):
			tl[int(i)-1] += 1
	# print(pl)
	# print(sb)
	# print(tl)
	cnt = 0
	for i in pl:
		if int(i)-1 < len(tl):
			cnt += tl[int(i)-1]

	print(cnt)

Submission status: Runtime Error

Solution code:
X = int(input())
for i in range(X+1):
    if i == 0:
        continue
    tmp = X / i
    if tmp.is_integer():
        for j in range(0,int(tmp)):
            a = j
            b = i - a
            if a**5 - b**5 == X:
                print("{} {}".format(a,b))
                sys.exit()

Submission status: Runtime Error

Solution code:
X = int(input())
answer = []
for A in range(-10**2,10**2):
    for B in range(-10**2,10**2):
        if A**5 - B **5 == X:
            answer.append([A,B])
print(*answer[0])

Submission status: Runtime Error

Solution code:
x = int(input())
if x == 1:
  print(0,-1)
  exit()
  
def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a

c = []
fct = factorize(x)
for div in divisorize(fct):
    c.append(num(div))
    
chk = False
for s in c:
  if chk:
    break
  for i in range(130):
    if (i+s)**5-i**5 > x:
      break
    if (i+s)**5-i**5 == x:
      ans = (i+s,i)
      chk = True
      break
  for p in range(1,130):
    j = -1*p
    #print(s,(j+s)**5-j**5)
    if (j+s)**5-j**5 > x:
      break 
    if (j+s)**5-j**5 == x:
      ans = (j+s,j)
      chk = True
      break 

print(*ans)

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <unordered_set>
using namespace std;
#include <unordered_map>
#include <vector>
#include <math.h> 
#include <stdio.h>
int main(){
    int x ;
    cin>>x;
    int b=-1;
    // cout<<pow(33,0.2)<<endl;
    int a= int((pow(x-1,0.2)));
    cout<<a<<" "<<b<<endl;
    
    
}

Submission status: Runtime Error

Solution code:
X=int(input())
Ans=[]
for n in range(65):
    for n1 in range(65):
        n2=n**5+n1**5
        if n2 == X:
            Ans.append(n)
            Ans.append(-1*n1)
            break

if len(Ans)==0:
    for n3 in range(80,1500):
        for n4 in range(n3):
            n2=n3**5-n4**5
            if n2 == X:
                Ans.append(n3)
                Ans.append(n4)
                break

print(Ans[0],Ans[1])

Submission status: Runtime Error

Solution code:
nums = [0]
n = 0
while (((n + 1)**5) - (n**5)) <= 10 ** 12:
    nums.append((n + 1)**5)
    n += 1
# print(nums)
ans = None
for num_a in nums:
    for num_b in nums:
        if num_a - num_b == X:
            ans = (num_a, num_b)
            break
        elif num_a + num_b == X:
            ans = (num_a, -1 * num_b)
            break
        elif (-1 * num_a) + num_b == X:
            ans = (-1 * num_a, num_b)
            break
        elif (-1 * num_a) - num_b == X:
            ans = (-1 * num_a, -1 * num_b)
            break
print(*ans)

Submission status: Runtime Error

Solution code:
import math

X=int(input())
i_p=0
i_m=0
while True:
    A_p=round((X+i_p**5)**(1/5),5)
    A_m=round((X+i_m**5)**(1/5),5)
    if type(A_p) is not complex:
        if A_p==int(A_p):
            A=int(A_p)
            i=i_p
            break
    if type(A_m) is not complex:
        if A_m==int(A_m):
            A=int(A_m)
            i=i_m
            break
    if i_p==2:
        print(A_p)
    i_p+=1
    i_m-=1

print(A,i)

Submission status: Runtime Error

Solution code:
import sympy as sp
import numpy
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
if __name__ == '__main__':
    X  = int(input())

    list_list=prime_factorize(X)
    if(len(list_list)==1):
        A=list_list[0]
        B=1
    elif(len(list_list)==0):
        A=1
        B=1
    else:
        A=list_list[0]
        B=numpy.prod(list_list[1:])

    sp.init_printing()
    sp.var('x, y, a, b, c, d, e, f')
    eq1=sp.Eq(x-y, A)
    eq2=sp.Eq(x**4+x**3*y+x**2*y**2+x*y**3+y**4, B)
    sorver_list=sp.solve ([eq1, eq2], [x, y])
    print(str(sorver_list[0][0])+' '+str(sorver_list[0][1]))

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

def main():
    x = int(input())
    p = [0, 1]
    n = [0, -1]
    i = 2
    while p[-1] <= 2*x:
        p.append(pow(i, 5))
        n.append(-pow(i, 5))
        i += 1

    p_ = set(p)
    n_ = set(n)
    for z in p:
        if x - z in n_:
            print(int(pow(x - z, 1 / 5)), int(pow(z, 1 / 5)))
            return

        if x - z in p_:
            print(int(pow(x - z, 1 / 5)), int(-pow(z, 1 / 5)))
            return

main()

Submission status: Runtime Error

Solution code:
X = int(input())

B = 0
while B > -10**9:
    A = X + B**5
    if pow(A,0.2) - int(pow(A,0.2)) == 0:
        print(int(pow(A,0.2)), B)
        break
    B -= 1
if pow(A,0.2) - int(pow(A,0.2)) != 0:
    B = 0
    while B < 10**9:
        A = X + B**5
        if pow(A,0.2) - int(pow(A,0.2)) == 0:
            print(int(pow(A,0.2)), B)
            break
        B += 1

Submission status: Runtime Error

Solution code:
import math
x = int(input())
y = []
for i in range(1000):
    y.append(i**5)
for j in range(1000):
    for k in range(j,1000):
        if y[k]+ y[j] == x:
            a = k
            b = j    
                    
print(a,-b)

Submission status: Runtime Error

Solution code:
x = int(input())

def fun(x):

    res = []

    for a in range(-100, 100):
        for b in range(-100, 100):
            mult = a**5 - b**5
            if mult == x:
                res = a, b
                break
    print(res[0], res[1])

fun(x)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# vim: set fileencoding=utf-8

# pylint: disable=unused-import, invalid-name, missing-docstring, bad-continuation


"""Module docstring
"""

import functools
import heapq
import itertools
import logging
import math
import random
import string
import sys
from argparse import ArgumentParser
from collections import defaultdict, deque
from copy import deepcopy
from typing import Dict, List, Optional, Set, Tuple

MAX_X = pow(10, 9)
MAX_SQ5 = int(pow(MAX_X, 1 / 5))


def solve(nb: int) -> Optional[Tuple[int, int]]:
    all_sq5 = set(pow(x, 5) for x in range(MAX_SQ5 + 1))
    for a in range(MAX_SQ5 ** 2 + 1):
        a5 = pow(a, 5)
        if nb - a5 in all_sq5:
            return int(pow(nb - a5, 1 / 5)), -a
        if nb + a5 in all_sq5:
            return int(pow(nb + a5, 1 / 5)), a
    return None


def do_job():
    "Do the work"
    LOG.debug("Start working")
    # first line is number of test cases
    X = int(input())
    # values = []
    # for _ in range(N):
    #     values.append(input().split())
    result = solve(X)
    print(*result)


def print_output(testcase: int, result) -> None:
    "Formats and print result"
    if result is None:
        result = "IMPOSSIBLE"
    print("Case #{}: {}".format(testcase + 1, result))
    # 6 digits float precision {:.6f} (6 is the default value)
    # print("Case #{}: {:f}".format(testcase + 1, result))


def configure_log() -> None:
    "Configure the log output"
    log_formatter = logging.Formatter("%(lineno)d - " "%(message)s")
    handler = logging.StreamHandler(sys.stdout)
    handler.setFormatter(log_formatter)
    LOG.addHandler(handler)


LOG = None
# for interactive call: do not add multiple times the handler
if not LOG:
    LOG = logging.getLogger("template")
    configure_log()


def main(argv=None):
    "Program wrapper."
    if argv is None:
        argv = sys.argv[1:]
    parser = ArgumentParser()
    parser.add_argument(
        "-v",
        "--verbose",
        dest="verbose",
        action="store_true",
        default=False,
        help="run as verbose mode",
    )
    args = parser.parse_args(argv)
    if args.verbose:
        LOG.setLevel(logging.DEBUG)
    do_job()
    return 0


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    sys.exit(main())


class memoized:
    """Decorator that caches a function's return value each time it is called.
    If called later with the same arguments, the cached value is returned, and
    not re-evaluated.
    """

    def __init__(self, func):
        self.func = func
        self.cache = {}

    def __call__(self, *args):
        try:
            return self.cache[args]
        except KeyError:
            value = self.func(*args)
            self.cache[args] = value
            return value
        except TypeError:
            # uncachable -- for instance, passing a list as an argument.
            # Better to not cache than to blow up entirely.
            return self.func(*args)

    def __repr__(self):
        """Return the function's docstring."""
        return self.func.__doc__

    def __get__(self, obj, objtype):
        """Support instance methods."""
        return functools.partial(self.__call__, obj)

Submission status: Runtime Error

Solution code:
x = int(input())

my_dict = dict()

for i in range(10 ** 6):
    my_dict[i**5] = i

for i in range(-10 ** 4, 10 ** 4):
    target = x + (i ** 5)
    if (- target) in my_dict:
        print(-my_dict[target], i)
        exit()
    elif target in my_dict:
        print(my_dict[target], i)
        exit()

Submission status: Runtime Error

Solution code:
import math
X=int(input())
divisors=[]

for i in range(1, int(X**0.5)+1):
	if X%i==0:
		divisors.append(i)
		if i!= X//i:
			divisors.append(X//i)
K=len(divisors)

for y in range(0,K):
	KKK=0
	A=0
	while KKK<X:
		A=A+1
		KKK=A**5-(A-divisors[y])**5
	if KKK==X:
		AA=A
		BB=A-divisors[y]
		break
print(AA,BB)

Submission status: Runtime Error

Solution code:
X = int(input())
fact = [(i,i**5) for i in range(-10**2,10**2)]

for i in range(0,len(fact)):
    for j in range(i+1,len(fact)):
        if abs(fact[i][1] - fact[j][1]) == X:
            A = fact[j][0]
            B = fact[i][0]
            break;
        

print(A,B)

Submission status: Runtime Error

Solution code:
n = int(input())
h_l = list(map(int,input().split()))
cnt = 0
for i in range(n):
    h_i = h_l[i]
    cnt += sum([1 for j in range(i,n) if((j-i)==(h_l[j]+h_i))])
            

print(cnt)

Submission status: Runtime Error

Solution code:
X = int(input())

N = []
for i in range(66):
    N.append(i**5)

for i in reversed(range(100)):
    for j in reversed(range(i)):
        if X == N[i] - N[j]:
            print(i, j)
            break
        if X == N[i] + N[j]:
            print(i, j * -1)
            break

Submission status: Runtime Error

Solution code:
X=int(input())
Ans=[]
for n in range(65):
    for n1 in range(65):
        n2=n**5+n1**5
        if n2 == X:
            Ans.append(n)
            Ans.append(-1*n1)
            break

if len(Ans)==0:
    for n3 in range(80,1000):
        for n4 in range(n3):
            n2=n3**5-n4**5
            if n2 == X:
                Ans.append(n3)
                Ans.append(n4)
                break

print(Ans[0],Ans[1])

Submission status: Runtime Error

Solution code:
x=int(input())
for b in range(-10000,10000):
    a=(x+b**5)**0.2
    if a.is_integer():
        print(a,b)
        exit()

Submission status: Runtime Error

Solution code:
import sys

def debug(*args):
    print(*args, file=sys.stderr)

# https://www.themathpage.com/Alg/difference-two-squares-2.htm#fifth

# https://qiita.com/snow67675476/items/e87ddb9285e27ea555f8
def factorize(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def get_factors_of(a_number):
    factorized = factorize(a_number)
    return [factor for factor, _ in factorized]


x_diff_of_5th_factor = int(input())

factors_of_x = get_factors_of(x_diff_of_5th_factor)

# debug(factors_of_x)

for a_factor_of_x in factors_of_x:
    for a in range(a_factor_of_x//2+1):
        b = a - a_factor_of_x

        if a ** 5 - b ** 5 == x_diff_of_5th_factor:
            print('{} {}'.format(a, b))
            sys.exit(0)
sys.exit(1)

Submission status: Runtime Error

Solution code:
import numpy
import math

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

    divisors.sort()
    return divisors

X = int(input())
lis = make_divisors(X)

for i in range(len(lis)):
    Y = lis[i]
    Z = X // Y
    tmp = numpy.roots([5, 10*Y, 10*pow(Y, 2), 5*pow(Y, 3), pow(Y, 4)-Z])
    ans = []
    for j in range(len(tmp)):
        if math.isclose(tmp[j].imag, 0):
            ans.append(int(tmp[j].real))
    if len(ans) == 2:
        ans.sort(x, reverse=True)
        tmp = ans[0]**5 - ans[1]**5
        if tmp == X: break

print(' '.join(map(str, ans)))

Submission status: Runtime Error

Solution code:

import numpy as np

x = int(input())
flag = 0
for i in range(1, int(np.sqrt(x))):
    if x % i == 0:
        k = int(x / i)
        if k < 31:
            for c in range(100):
                a = c
                b = a - k
                d = a**4 + (a**3)*b + (a**2)*(b**2) + a*(b**3) + b**4
                if d == i:
                    flag += 1
                    break
        else:
            for c in range(100):
                a = c
                b = a - i
                d = a**4 + (a**3)*b + (a**2)*(b**2) + a*(b**3) + b**4
                if d == k:
                    flag += 1
                    break
        if flag == 1:
            break

print(a, b)

Submission status: Runtime Error

Solution code:
/*input

*/
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define debug(x) cerr << (x) << '\n';
#define bits(x,i) ((x >> i) & 1)
using namespace std;
long long n;
long long pw(int x){
    return x*x*x*x*x;
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    long long x = 0;
    while (pw(x) <= n){
        long long y = n - pw(x);
            y = pow(y, 0.2);
        if (pw(x) + pw(y) == n) {
            cout << x << ' ' << -y << '\n';
            return 0;
        }
        x++;
    }   
    x = 0;
    while (true){
        long long y = n + pw(x);
        y = pow(y, 0.2);
        if (pw(x) + n == pw(y)) {
            cout << y << ' ' << x << '\n';
            return 0;
        }
        x++;
    }   
}

Submission status: Runtime Error

Solution code:
import numpy as np


def solve(vec, is_complex=True):
    dim = len(vec)
    if is_complex:
        A = np.zeros((dim, dim), dtype=complex)
    else:
        A = np.zeros((dim, dim))
    A[np.arange(dim - 1), 1 + np.arange(dim - 1)] = 1
    A[-1, :] = -vec
    ans, vec = np.linalg.eig(A)
    return ans


def make_divisors(n):
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            d = n // i
            ans = np.array([((i ** 4) -d)/5, (i ** 3), (i ** 2) * 2, i * 2])
            for x in ans:
                if x.is_integer():
                    if x**5-(i-x)**5 == d:
                        return [int(x), int(i-x)]
m=int(input())
print(*make_divisors(m))

Submission status: Runtime Error

Solution code:
from sympy import *
import numpy
X  = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
list_list=prime_factorize(X)
if(len(list_list)==1):
    A=list_list[0]
    B=1
elif(len(list_list)==0):
    A=1
    B=1
else:
    A=list_list[0]
    B=numpy.prod(list_list[1:])
import sympy as sp
sp.init_printing()
sp.var('x, y, a, b, c, d, e, f')
eq1=sp.Eq(x-y, A)
eq2=sp.Eq(x**4+x**3*y+x**2*y**2+x*y**3+y**4, B)
sorver_list=sp.solve ([eq1, eq2], [x, y])
print(str(sorver_list[0][0])+' '+str(sorver_list[0][1]))

Submission status: Runtime Error

Solution code:
x = int(input())

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

    # divisors.sort()
    return divisors

flag = 0
divisors = make_divisors(x)
while flag!=-1:
  p = divisors[flag]
  a = 1
  while 1==1:
    b = a-p
    ans = a**5-b**5
    if ans > x:
      break
    if ans == x:
      print(a,b)
      flag=-2
      break
    a += 1
  flag += 1

Submission status: Runtime Error

Solution code:
n = int(input())
x=n
pf={}
for i in range(2,int(n**0.5)+1):
    while n % i == 0:
        pf[i] = pf.get(i,0)+1
        n//= i
if n > 1 : pf[n] = 1

# print((list(pf.keys()))[0]) #素因数分解したときの最小の因数取得

for b in range(-1000,1000):
    a=b+int(list(pf.keys())[0])
    siki=a**4 + a**3*b + a**2*b**2 + a*b**3 + b**4
    if siki==x/int(list(pf.keys())[0]):
        print(*(a,b))

Submission status: Runtime Error

Solution code:
a = 0
x = int(input())

while True:
  b = (x-a**5) ** (1/5)
  if b.is_integer() :
    print(a, int(b))
    break
  b = (a**5-x) ** (1/5)
  if b.is_integer() :
    print(a, int(b))
    break
  
  a += 1