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: Time Limit Exceeded

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)
        else:
            a += 1
            b += 1
    break

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from math import ceil #切り上げ
import numpy as np
 
def inp(): return int(input()) #一個だけ読み取り
def inpm(): return map(int,input().split()) #mapオブジェクトで呼び出し
def inpl(): return list(map(int, input().split())) #数字リストをintで
def inpls(): return list(input().split()) #リストをstrで

def check(a,b,X):
  if a**5-b**5 == X:
    return 1
  else:
    return 0
  
def check2(a,b,X):
  if (a <= b+X) and (a > 0):
    return 1
  else:
    return 0

X = inp()
A = 0
tmp = 0
while 1:
  B = 1
  reverse = 0
  if check(A,B,X):
    print(str(A)  + " " + str(B))
    break
  else:
    while 1:
      if B < A and A-X <= B:
        if check(A,B,X):
          print(str(A)  + " " + str(B))
          tmp = 1
          break
      else:
        break
      if reverse == 0:
        B = (-1)*B
        reverse = 1
      elif reverse == 1:
        B = (-1)*B
        B = B + 1
        reverse = 0
  A += 1
  if tmp:
    break

Submission status: Time Limit Exceeded

Solution code:
import sys
X = int(input())
S = int(X ** (1/5) + 1)

for i in range(X):
    for j in range(S):
        a = i ** 2
        b = j ** 2
        c = i * j
        if (i - j) * (a * (a ** 2 + c + b) + b * (c + b)) == X:
            print(i,j)
            sys.exit()
        elif (i + j) * (a * (a ** 2 - c + b) + b * (-c + b)) == X:
            print(i,-j)
            sys.exit()

Submission status: Time Limit Exceeded

Solution code:
# D

x = int(input())

a = int(x**(1/5))
b = int(abs(x-a**5)**(1/5))
i = 1
while True:

    if a**5 - b**5 != x and a**5 - (-b)**5 != x:
        a = int(x**(1/5))+i
        b = int(abs(x-a**5)**(1/5))
        if a**5 - b**5 == x:
            print(a,b)
            break
        elif a**5 - (-b)**5 == x:
            print(a,-b)
            break
        else:
            i += 1
        
    elif a**5 - b**5 == x:
        print(a,b)
        break

    else:
        print(a,-b)
        break

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
h = x

for i in range(2,10**5):
    if x%i == 0:
        h = i
        break


for i in range(1, 10**9):
    a = i
    b = h-i
    if a**5-b**5 == x:
        print(a, b)
        exit(0)
    b = i-h
    if a**5-b**5 == x:
        print(a, b)
        exit(0)

Submission status: Time Limit Exceeded

Solution code:
import math

x = int(input())

r = x ** (1/5)

a = int(r+1)
b = 0



while True:
  if a**5 - b**5 == x:
    break
  if a >= 0 and b < 0:
    if a**5 - b**5 > x:
      a -= 1
    else:
      b += 1
  elif a < 0 and b < 0:
    if a**5 - b**5 > x:
      a += 1
    else:
      b -= 1
  elif a < 0 and b >= 0:
    if a**5 - b**5 > x:
      a += 1
    else:
      b += 1
  elif a >= 0 and b >= 0:
    if a**5 - b**5 > x:
      a -= 1
    else:
      b -= 1
  else:
    print('error')
    break

      

print(a, b)

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
flag = False
for i in range(int(x / 2) + 2):
  for j in range(0, -1 * int(x / 2) - 2, -1):
    if x == i ** 5 - j ** 5:
      print(i, j)
      flag = True
      break
  if flag:
    break

if not flag:
  for i in range(int(x / 2) + 2):
    for j in range(int(x / 2) + 2):
      if x == i ** 5 - j ** 5:
        print(i, j)
      flag = False
      break
    if flag:
      break

Submission status: Time Limit Exceeded

Solution code:
import math

x = int(input())

a = 0
b = 0
while True:
    b = -(x - a ** 5)

    f = False
    if b < 0:
        b = -b
        f = True
        
    for i in range(5):
        b = math.sqrt(b)

    if f == True:
        b = -b
    
    if b - int(b) == 0.0:
        break
    a += 1

print(a, int(b))

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
a = 2
b = 0
A = []
A.append(1 ** 5 - x)

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: Time Limit Exceeded

Solution code:
x=int(input())

import math
import sys

def sq(x):
    if x<=0:
        return False
    tmp=math.pow(x,1/5)
    if tmp-int(tmp)==0:
        return True
    else:return False

b=0
bb=0
while(True):
    if sq(x+b**5):
        print(int(math.pow(x+b**5,1/5)),b)
        sys.exit()
    b+=1
    if sq(x+bb**5):
        print(int(math.pow(x+bb**5,1/5)),bb)
        sys.exit()
    bb-=1

Submission status: Time Limit Exceeded

Solution code:
X = int(input())

#x^5-y^5=(x-y)(x^4+x^3y+x^2y^2+xy^3+y^4)

#for x in range(1, 121):
#  if ((x**5) - ((x-1)**5)) >= 1000000000:
#    print(x)

for a in range(0, 121):
  for b in range(-100000, 120):
    if b**5 == a**5-X:
      print(a, b)
      break

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
x = int(input())

for s in range(1, int(math.sqrt(x))+1):
    if x % s == 0:
        t = x // s
        #print(s, t)
        for b in range(-100000, 100000):
            if (b+s)**5 - b**5 == x:
                print(b+s, b)
                sys.exit(0)
            elif (b+t)**5 - b**5 == x:
                print(b+t, b)
                sys.exit(0)

Submission status: Time Limit Exceeded

Solution code:
x=int(input())
ans=ansb=0
f=False
m=int(pow(x,0.2))
a=m
while True:
  b=0
  while pow(a,5)-pow(b,5)>=x:
      if pow(a,5)-pow(b,5)!=x:
          b+=1
      else:
          ans=a
          ansb=b
          f=True
          break
  a+=1
  if f:
    break
else:
    f=False
    for a in range(m//2+1):
        for b in range(a,m//2+2):
            if pow(a,5)+pow(b,5)!=x:
                continue
            else:
                ans=a
                ansb=-b
                f=True
                break
        if f:
            break

print(ans,ansb)

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
a = int(X**(1/5))
for i in range(100*(a+1)):
    for j in range(100*(a+1)):
        if(i**5 + j**5 == X):
            print(i , -j)
            break
    else:
        continue
    break

Submission status: Time Limit Exceeded

Solution code:
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

a=prime_factorize(x)
a.append(x)
a.append(1)
a=list(set(a))
len=len(a)
t=-10000
ansx=0
ansy=0
while True:
    if not ansx== 0 or not ansy== 0:
        break
    for i in range(len):
        if ((t+a[i])**5-t**5)-x==0:
            ansx=t+a[i]
            ansy=t
            break
        else:
            t+=1
print(ansx,ansy)

Submission status: Time Limit Exceeded

Solution code:
import math
X=int(input())
Cout=2
B=0
Fend=0
Fukuso=0
while Fend!=1:
    
    A=pow(X+B**5,1/5)
    if type(A)==complex:
        A=(-1)*float(A.imag)
        Fukuso=1

    if A==math.floor(A):
        print(str(int(A))+" "+str(int(B)))
        Fend=1
    if Fukuso==1 and A==math.ceil(A):
        print(str(int(A))+" "+str(int(B)))
        Fend=1
    Cout=Cout+1
    if Cout ==2:
        B=B+1
        #print(B)
    elif Cout%2!=0:
        B=B*(-1)
        #print(B)
    else:
        B=1+B*(-1)
        #print(B)

Submission status: Time Limit Exceeded

Solution code:
import math
x = int(input())

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

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

    l = make_divisors(x)
    for i in l:
        for j in range(i+1):
            if j**5 - (-(i-j)) ** 5 == x:
                print(j, -(i-j))
                exit()

Submission status: Time Limit Exceeded

Solution code:
X = int(input())

#x^5-y^5=(x-y)(x^4+x^3y+x^2y^2+xy^3+y^4)

#for x in range(1, 121):
#  if ((x**5) - ((x-1)**5)) >= 1000000000:
#    print(x)

for a in range(1, 121):
  for b in range(-1000000, 120):
    if b**5 == a**5-X:
      print(a, b)
      break

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
i = 0
while True:
  A = i
  if (i**5-X) == -1:
    B = -1
    if A**5 - B**5 == X :
      break
  elif isinstance((i**5-X)**(1/5), float):
    B = int(abs((i**5-X)**(1/5)))

    if A**5 - B**5 == X :
      break
  i = i+1


print(A, B)

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
div = []
for i in range(1, int(x**0.5)+1):
    if x % i == 0:
        div.append(i)
        if i != x // i:
            div.append(x//i)

def f():
    for d in div:
        a = 0
        while True:
            b = a - d
            if a**5 - b**5 == x:
                return a, b
            elif b > 0 and a**5 - b**5 > x:
                break
            a += 1

print(*f())

Submission status: Time Limit Exceeded

Solution code:
import math

X = int(input())

for B in range(X):
    B5 = B**5
    XB_pow = math.pow(X+B5, 0.2)
    A_f = math.floor(XB_pow)
    # A_c = math.ceil(XB_pow)

    # print(B)

    A_f5 = A_f**5
    # A_c5 = A_c**5
    
    if A_f5 - B5 == X:
        print(A_f,B)
        break
    # if A_c5 - B5 == X:
    #     print(A_c,B)
    #     break
    if A_f5 + B5 == X:
        print(A_f,-B)
        break
    # if A_c5 + B5 == X:
    #     print(A_c,-B)
    #     break

Submission status: Time Limit Exceeded

Solution code:
import math
def factorial(x):
    for a in range(-1, x):
        for b in range(-1, x):
            check = math.pow(a, 5) - math.pow(b, 5)
            if check == x:
                return f'{a} {b}'
x = int(input())
print(factorial(x))

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
h = x

for i in range(2,10**9):
    if x%i == 0:
        h = i
        break


for i in range(1, 10**9):
    a = i
    b = h-i
    if a**5-b**5 == x:
        print(a, b)
        exit(0)
    b = i-h
    if a**5-b**5 == x:
        print(a, b)
        exit(0)

Submission status: Time Limit Exceeded

Solution code:
import math

x = int(input())

b = -10000

while True:
    if x+b**5 > 0:
        if math.pow((x+b**5), 0.2).is_integer():
            print(int(math.pow((x+b**5), 0.2)), b)
            exit()
        
    b += 1

Submission status: Time Limit Exceeded

Solution code:
X = int(input())

# for b in range(65, -64, -1):
for b in range(1000000, -1000000, -1):
    a = (X + b**5)**0.2
    # print('b a', b, a)
    if type(a) == complex:
        if a.imag != 0:
            continue
        print(int(a.real), b)
        exit()
    elif a.is_integer():
        print(int(a), b)
        exit()

for a in range(1000000, -1000000, -1):
    b = (X - a**5)**0.2
    # print('b a', b, a)
    if type(b) == complex:
        if b.imag != 0:
            continue
        print(int(b.real), a)
        exit()
    elif b.is_integer():
        print(int(a), b)
        exit()

Submission status: Time Limit Exceeded

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    X = int(input())
    import math
    for i in range(-2*10**4 - 10**3,10**4,2):
        for j in range(10**4 + 1 + 10**3,-2*10**4 - 10**3,-2):
            if i == j:
                continue
            if X % (i - j) == 0:
                if (i-j) * (pow(i,4) + pow(i,3)*j + pow(i,2)*pow(j,2) + i*pow(j,3) + pow(j,4)) == X:
                    print(i,j)
                    exit()
if __name__ == '__main__':
  main()

Submission status: Time Limit Exceeded

Solution code:
X = int(input())

i = 1
if(X != 1):
    i += 1
while X%i != 0 and X > i:
    i += 1
n = int(X/i)
B = 0
while True:
    A = i + B
    if (A**4) + (A**3) * B + (A**2) * (B**2) + A* (B**3) + (B**4) == n:
        break;
    B = B*(-1)
    A = i + B
    if (A**4) + (A**3) * B + (A**2) * (B**2) + A* (B**3) + (B**4) == n:
        break;
    B = B*(-1) + 1

print(A,B)

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
A = [i for i in range(0, 10000)]
res = []
for i in range(len(A)):
  a = A[i]
  for j in range(len(A)):
    b = -A[j]
    cal = a ** 5 - b ** 5
    if cal == X:
      print(a, b)
      exit()

Submission status: Time Limit Exceeded

Solution code:
import math
x = int(input())

def trial_division(n):
    #素因数を格納するリスト
    count = 0
    tmp = n
    #2から5√n以下の数字で割っていく
    for _ in range(5):
    	tmp = int(math.sqrt(tmp)) + 1
       
    if n == 0:
      return True,0
    if n == 1:
      return True,1
    
    for num in range(2,tmp):
      if n%num == 0:
        while n % num == 0:
            n //= num
            count += 1
        if n == 1 and count == 5:
          return True,num
       	else:
          break
            
    return False,0

for i in range(-1*int(1E6),int(1E6)):
  a = i**5
  y = abs(a-x)
  flg,num = trial_division(y)
  if flg:
    if a-x>=0:
      print(str(i)+' '+str(num))
    else:
      print(str(i)+' '+str(-1*num))
    break

Submission status: Time Limit Exceeded

Solution code:
import bisect

D = 10 ** 4

X = int(input())

L = [i**5 for i in range(-D, D)]
L2 = [i for i in range(-D, D)]

idx = bisect.bisect_left(L, X)-1

B = L[:idx]
A = L[idx:]

for a in A:
    for b in B:
        if a - b == X:
            break
    else:
        continue
    break

print(L2[L.index(a)], L2[L.index(b)])

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
diff = 1
for i in range(2,X):
    if X % i == 0:
        diff = i
        break

s = (10 **9 /diff)//2
while True:
    A = s 
    B = s - diff
    xx = A **5 - B ** 5
    if xx == X:
        break
    elif xx > X:
        s = s //2
    else:
        s = s + s //2
print(int(A),int(B))

Submission status: Time Limit Exceeded

Solution code:
import sys

if __name__ == '__main__':
    # 1 <= x <= 10^9
    x = int(sys.stdin.readline().rstrip())
    if x == 0:
        print('0 0')
    # x = 1

    # x = a**5-b**5

    # a > b
    # aが正, bが負
    for a in range(100000):
        tmp = a**5 - x
        for b in range(-100000, a):
            if b == 0:
                continue
            if tmp % abs(b) == 0 and b**5 == tmp:
                print(a, b)
                break
        else:
            continue
        break

Submission status: Time Limit Exceeded

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,4000):
        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: Time Limit Exceeded

Solution code:
import bisect

D = 10 ** 5

X = int(input())

L = [i**5 for i in range(-D, D)]
L2 = [i for i in range(-D, D)]

idx = bisect.bisect_left(L, X)-1

B = L[:idx]
A = L[idx:]

for a in A:
    for b in B:
        if a - b == X:
            break
    else:
        continue
    break

print(L2[L.index(a)], L2[L.index(b)])

Submission status: Time Limit Exceeded

Solution code:
import sys
x = int(input())

a = -1
judge = True
while(judge):
    a += 1
    if(a**5 <= x):
        b = 0
        while(a**5 - b**5 <= x):
            if (a**5 - b**5 == x):
                judge = False
                print(a, b)
                sys.exit(0)
                break
            b -= 1
            # print('1', a, b)
    if(a**5 - (a-1)**5 < x):
        b = 0
        while(a**5 - b**5 >= x):
            if (a**5 - b**5 == x):
                judge = False
                print(a, b)
                sys.exit(0)
                break
            b += 1
            # print('2', a, b)
    # print(a)
    # a += 1
print(a, b)

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

if x > 0:
     for i in range(1000000000):
        if x-i**5 > 0 and(x-i**5)**(1/5) ==  int((x-i**5)**(1/5)):
            b = -(x-i**5)**(1/5)
            a = i
            break
        if (x+i**5)**(1/5) ==  int((x+i**5)**(1/5)):
            b = -(x+i**5)**(1/5)
            a = -i
            break
else:
     for i in range(1000000000):
         if -x-i**5 >0 and (-x-i**5)**(1/5) ==  int((-x-i**5)**(1/5)):
            a =  -(-x+i**5)**(1/5)
            b =  i
            break
         if (-x+i**5)**(1/5) ==  int((-x+i**5)**(1/5)):
            a =  -(-x+i**5)**(1/5)
            b = -i
            break



print(int(a),int(b))

Submission status: Time Limit Exceeded

Solution code:
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(int(n))
  return table
def main():
  sFlag=False
  X= int(input())
  X_table=prime_decomposition(X)
  X_table.append(1)
  for i in range(X):
    A=i
    for j in range(len(X_table)):
      B=A-X_table[j]
      X_n=A**5-B**5
      if(X_n==X):
        print(A,B)
        sFlag=True
        break
    if(sFlag==True):
      break

if __name__=='__main__':
  main()

Submission status: Time Limit Exceeded

Solution code:
X=int(input())
for B in range(-10**9,10**9):
    if type((X+B**5)**0.2)!=complex:
        if (X+B**5)**0.2==int((X+B**5)**0.2):
            print(int((X+B**5)**0.2), B)
            break

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

i = 0
ii = 0

while True:
    if i**5 > n:
        i -= 1
        while True:
            if i**5 - -(ii**5) == n:
                break
            else:
                ii+=1
        break
    else:
        i+=1

print(i,-ii)

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
i = 0
while True:
  A = i
  if isinstance((i**5-X)**(1//5), int):
    B = int((i**5-X)**(1//5))*-1
 
    if A**5 - B**5 == X :
      break
  i = i+1
 
 
print(A, B)

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
A = 0
while True:
  a = A**5
  M = max(int((X-a)**(1/5)),0)
  m = int(a-X**(1/5))*(-1)
  for B in range(m,M+1):
    if B**5 == X-a:
      print(A, B*(-1))
      exit()
  A += 1

Submission status: Time Limit Exceeded

Solution code:
import math
x = int(input())

for s in range(1, int(math.sqrt(x))+1):
    if x % s == 0:
        t = x // s
        #print(s, t)
        for b in range(-100000, 100000):
            if (b+s)**5 - b**5 == x:
                print(b+s, b)
                break
            elif (b+t)**5 - b**5 == x:
                print(b+t, b)
                break

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))
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 sorted(divisors)



X = ii()
a = make_divisors(X)
for num in a:
    for i in range(num):
        j = num - i
        if i**5 + j**5 == X:
            print(i, (-1)*j)
            exit()

Submission status: Time Limit Exceeded

Solution code:
import math

x = int(input())

ans = 0

a = 0

dst = x / 2

diff = x
while True:
    diff = x - int(math.pow(a, 5))

    if dst > diff:
        break
    else:
        a += 1

b = -int(pow(10, 5) - 1)

a_5 = int(math.pow(a, 5)) - x

while True:
    b_5 = int(math.pow(b, 5))
    if b_5 == a_5:
        break
    else:
        b += 1

print(a, b)

Submission status: Time Limit Exceeded

Solution code:
import bisect

D = 10 ** 6

X = int(input())

L = [i**5 for i in range(-D, D)]
L2 = [i for i in range(-D, D)]

idx = bisect.bisect_left(L, X)-1

B = L[:idx]
A = L[idx:]

for a in A:
    for b in B:
        if a - b == X:
            break
    else:
        continue
    break

print(L2[L.index(a)], L2[L.index(b)])

Submission status: Time Limit Exceeded

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    X = int(input())
    import math
    for i in range(-10**4,10**5,2):
        for j in range(10**4 + 1,-10**5,-2):
            if i == j:
                continue
            if X % (i - j) == 0:
                if (i-j) * (pow(i,4) + pow(i,3)*j + pow(i,2)*pow(j,2) + i*pow(j,3) + pow(j,4)) == X:
                    print(i,j)
                    exit()
if __name__ == '__main__':
  main()

Submission status: Time Limit Exceeded

Solution code:
import math

x = int(input())

a = 0
b = 0
while a ** 5 < x:
    a += 1
a -= 1

b = -(x - a ** 5)

f = False
if b < 0:
    b = -b
    f = True
    
for i in range(5):
    b = math.sqrt(b)

if f == True:
    b = -b

i = 1
while b - int(b) != 0.0:
    ap = a + i
    b = -(x - ap ** 5)

    f = False
    if b < 0:
        b = -b
        f = True
        
    for i in range(5):
        b = math.sqrt(b)

    if f == True:
        b = -b

    if b - int(b) == 0.0:
        break

    asub = a - i
    b = -(x - asub ** 5)

    f = False
    if b < 0:
        b = -b
        f = True
        
    for i in range(5):
        b = math.sqrt(b)

    if f == True:
        b = -b
    i += 1

print(a, int(b))

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

# 素因数分解
def prime_factorization(n):
    prime = {}
    tmp = n
    for i in range(2, int(n**0.5)+1):
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if i in prime:
                prime[i] += cnt
            else:
                prime[i] = cnt
    if tmp != 1:
        if tmp in prime:
            prime[tmp] += 1
        else:
            prime[tmp] = 1
    return prime

if x == 1:
    print(0, -1)
else:
    p = prime_factorization(x)
    m = min(p.keys())
    a = 0
    while True:
        b = a - m
        if a ** 5 - b ** 5 == x:
            print(a, b)
            break
        if a > 0:
            a = -a
        else:
            a = -a + 1

Submission status: Time Limit Exceeded

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

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

for B in t**5:
    if X+B**5 in S:
        print("%d %d"%((X+B**5)**0.2, B))
        break

Submission status: Time Limit Exceeded

Solution code:
x=int(input())
a=0
b=0
t=0
while a**5<x:
    while b**5<x:
        if a**+b**5==x:
            print(a,-b)
            t=1
            break
        if -a**5-b**5==x:
            print(-a,b)
            t=1
            break
    if t==0:
        break

Submission status: Time Limit Exceeded

Solution code:
import math
x = int(input())
b = 0

def calc(b, b5):
    a = (x+b5)**0.2

    if a.real.is_integer():
        print(int(a), b)
        exit()

while True:
    b5 = b ** 5
    calc(b, b5)
    calc(-b, -b5)
    b += 1

Submission status: Time Limit Exceeded

Solution code:
X = int(input())

for i in range(X):
  if X % (i + 1) == 0:
    A_B = i + 1
    for A in range(i+1):
      B = A - A_B
      C = (A ** 4) + (A ** 3) * B + (A ** 2) * (B ** 2) + A * (B ** 3) + (B ** 4)
      if A_B * C == X:
        print("{} {}".format(A,B))
        break
    else:
        continue
    break

Submission status: Time Limit Exceeded

Solution code:
import numpy 
x = int(input())
max = 10**9+1
flag = False
for i in range(1,max):
    if x%i == 0:
        for j in range(0,i+1): 
            if (numpy.power(i-j,5,dtype=numpy.int64) - numpy.power(j,5,dtype=numpy.int64)) == x:
                print(str(i-j)+" "+str(j))
                flag = True
                break
            if (numpy.power(i+j,5,dtype=numpy.int64) - numpy.power(-j,5,dtype=numpy.int64)) == x:
                print(str(i+j)+" "+str(-j))
                flag = True
                break
    if flag:
        break

Submission status: Time Limit Exceeded

Solution code:

import math
x = int(input())

a = math.floor(x ** (1/5)) 

b = -1
while True:
    if a**5 -b**5 == x:
        break
    b = abs(b+1)

print(a,b)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun May  3 21:48:14 2020

@author: Kei
"""

X = int(input())

i = 0
j = 0


while(1):
    A_5 = pow(i,5) + X
    if float(pow(A_5,0.2)).is_integer() == True:
        A = int(pow(A_5,0.2))
        B = i
        break


    if abs(pow(j,5))> X:
        continue
    else:
        A_5 = pow(j,5) + X
        if float(pow(A_5,0.2)).is_integer() == True:
            A = int(pow(A_5,0.2))
            B = j
            break
    
    i += 1
    j -= 1


print(A,B)

Submission status: Time Limit Exceeded

Solution code:
import collections


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


x = int(input())
targets = prime_factorize(x)
targets.append(1)
targets.append(x)
targets = sorted(list(set(targets)))

# print(targets)

# for target in targets


def test():
    for target in targets:
        for i in range(target + 1):
            for j in range(-target, target + 1):
                # print(targets[0], i, j, i - j, i ** 5 - j ** 5)
                if i ** 5 - j ** 5 == x:
                    # if i - j == targets[0] and i ** 5 - j ** 5 == x:
                    print(str(i) + ' ' + str(j))
                    return


test()

# a - b = 1 3 11 33

Submission status: Time Limit Exceeded

Solution code:
flg=False
x=int(input())
for a in range(x+1):
  for b in range(-x-1,x+1):
    if a**5-b**5==x:
      print(a,b)
      flg=True
      break
  if flg:
    break

Submission status: Time Limit Exceeded

Solution code:
import math
def is_prime(num):
    for i in range(2, num):  # 第二引数は sqrt(num)+1 でも良い
        if num % i == 0:
            return False

    return True
X = int(input())
if X==1:
    print(0,-1) 
else:
    if is_prime(X):
        d = X
    else:
        d = 2
        while(X%d!=0):
            d+=1
            
    b = -(10**3)
    a = b+d
    
    while(X!=((a**5)-(b**5))):
        b+=1
        a+=1
    print(a,b)

Submission status: Time Limit Exceeded

Solution code:
X = int(input())

root = int(X**(1/5))

A_cands = [root-1, root, root+1]
B_cands = []
for c in A_cands:
    if c**5 < X:
        rest = X - c**5
        another = -int(rest**(1/5))
        B_cands.append(another)
    else:
        rest = c**5 - X
        another = int(rest**(1/5))
        B_cands.append(another)

tmp = 1

for i in range(3):
    if A_cands[i]**5 - B_cands[i]**5 == X:
        print(A_cands[i], B_cands[i])
        import sys
        sys.exit()


while (A_cands[0]**5 - B_cands[0]**5 != X) and (A_cands[1]**5 - B_cands[1]**5 != X) and (A_cands[2]**5 - B_cands[2]**5 != X):
    for i,b_cand in enumerate(B_cands):
        another_plus = b_cand + 1
        another_minus = b_cand - 1
        if A_cands[i]**5 - another_plus**5 == X:
            B_cands[i] = another_plus
            ans_idx = i
            break
        if A_cands[i]**5 - another_minus**5 == X:
            B_cands[i] = another_minus
            ans_idx = i
            break
    tmp += 1

print(A_cands[ans_idx], B_cands[ans_idx])

Submission status: Time Limit Exceeded

Solution code:
import math
X = int(input())
B = 0
while True:
  if abs((1-X)**(1/5)) == B:
    break
  else:
    B += 1
print(1, -1*B)

Submission status: Time Limit Exceeded

Solution code:
import math

X = int(input())

def decompose(n):
	result = []
	half = math.floor(math.sqrt(n))
	i = 2
	while i <= half:
		if n % i == 0:
			result.append(i)
			n //= i
			half = math.floor(math.sqrt(n))
		else:
			i += 1
	if n > 1:
		result.append(n)
	return result

facts = decompose(X)

fact_table = {}
for f in facts:
	if f not in fact_table:
		fact_table[f] = 1
	else:
		fact_table[f] += 1

facts = list(fact_table.items())
facts.sort()

def find(num, n):
	if n >= len(facts):
		A = 0
		prev_x = None
		while True:
			B = A - num
			x = A ** 5 - B ** 5
			if x == X:
				return A, B
			elif (prev_x != None and x > prev_x) and x > X:
				break
			A += 1
			prev_x = x
	else:
		f, c = facts[n]
		for i in range(c + 1):
			ret = find(num, n + 1)
			if ret != None:
				return ret
			num *= f
	return None

A, B = find(1, 0)


print(A, B)