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:
import math
X= int(input())
 
Bp = -1*math.floor(X**0.2)
Bn = 0
while True:
    Bp += 1
    A = (X+Bp**5)**0.2
    if A == int(A):
        print(int(A),Bp)
        exit()

Submission status: Time Limit Exceeded

Solution code:
from collections import deque

def getInts():
    return [ int(x) for x in input().split() ]

def f(B):
    base = (X + B**5 )
    if base < 0:
        return 0.1
    return (X + B**5 ) ** (1/float(5))

[X] = getInts()
Q = deque([(0,0)])
V = set()
BP, BN = 0,0
while not f(BP).is_integer() and not f(BN).is_integer() and not f(-BP).is_integer() and not f(-BN).is_integer():
    (BP,BN) = Q.pop()
    l = [(BP+1,BN),(BP,BN+1),(BP+1,BN+1)]
    l = filter(lambda x: x not in V, l)
    for each in l:
        V.add(each)
        Q.appendleft(each)

if f(BP).is_integer():
    print(int(f(BP)), BP)
elif f(-BP).is_integer():
    print(int(f(-BP)), -BP)
elif f(BN).is_integer():
    print(int(f(BN)), BN)
else:
    print(int(f(-BN)), -BN)

Submission status: Time Limit Exceeded

Solution code:
from collections import deque

def getInts():
    return [ int(x) for x in input().split() ]

def f(B):
    base = (X + B**5 )
    if base < 0:
        return 0.1
    return (X + B**5 ) ** (1/float(5))

[X] = getInts()
Q = deque([(0,0)])
V = set()
BP, BN = 0,0
while not f(BP).is_integer() and not f(BN).is_integer():
    (BP,BN) = Q.pop()
    l = [(BP+1,BN),(BP,BN-1),(BP+1,BN-1)]
    l = filter(lambda x: x not in V, l)
    for each in l:
        V.add(each)
        Q.appendleft(each)

if f(BP).is_integer():
    print(int(f(BP)), BP)
else:
    print(int(f(BN)), BN)

Submission status: Time Limit Exceeded

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

ozo = set([-1, 0, 1])
x = int(input())
for j in range(10 ** 7):
  c = x + j ** 5 # プラス
  f = factorization(c)
  if c in ozo:
    print(c, j)
    exit()
  if len(f) == 1 and f[0][1] == 5:
    print(f[0][0], j)
    exit()
  c = x - j ** 5 # マイナス
  if c in ozo:
    print(c, j)
    exit()
  if c < 0:
    c *= -1
    f = factorization(c)
    if len(f) == 1 and f[0][1] == 5:
      print(-f[0][0], -j)
      exit()
  else:
    f = factorization(c)
    if len(f) == 1 and f[0][1] == 5:
      print(f[0][0], -j)
      exit()

Submission status: Time Limit Exceeded

Solution code:
import collections
x = int(input())
dd = collections.defaultdict(int)
for i in range(-100,100,1):
    dd[i**5]=i
for i in range(x):
    if(dd[i**5-x]!=0):
        print(i, dd[(i**5-x)])
        exit()

Submission status: Time Limit Exceeded

Solution code:
def calc(a, b):
  return a ** 5 - b ** 5

x = int(input())
flag = 0
a = 1
b = 0
while (True):
  while (True):
    if calc(a,b) == x:
      flag = 1
      break
    b -= 1
  if flag == 1:
    break
  a += 1
  b = a - 1
print(a, b)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

X=int(input())
ans=[]
for i in range(2*X):
  A=i-X
  for j in range(2*X):
    B=j-X
    x=A**5-B**5
    if x == X:
      ans.append(A)
      ans.append(B)
print("{} {}".format(ans[0],ans[1]))

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

for i in range(-1000, 1000):
    for j in range(-1000, 1000):
        if i ** 5 - j ** 5 == x:
            a=i
            b=j

print(a, b)

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

for i in range(-10000, 10000):
    for j in range(-10000, 10000):
        if i ** 5 - j ** 5 == x:
            a=i
            b=j

print(a, b)

Submission status: Time Limit Exceeded

Solution code:

x = int(input())

diff_old = 1000000000
a = 0
b = 0
count = 0;
while 1:
    a = count
    diff = abs(a ** 5 - abs(x))

    if diff < diff_old:
        diff_old = diff
    else:
        a -= 1
        break
    count += 1

if x < 0:
    a *= -1

r_side = a ** 5 - x

count = 0
if r_side > 0:
    while 1:
        count+=1
        b = count

        if b ** 5 == r_side:
            break
elif r_side < 0:
    while 1:
        count-=1
        b = count

        if b ** 5 == r_side:
            break

print(a, b)

Submission status: Time Limit Exceeded

Solution code:
n = input()
n = int(n)

for x in range(10**6):
    for m in range(10):
        if x ** 5 + m ** 5 == n:
            print(x,-m)
            exit()

Submission status: Time Limit Exceeded

Solution code:
n = input()
n = int(n)

for x in range(10**4):
    for m in range(1000):
        if x ** 5 + m ** 5 == n:
            print(x,-m)
            exit()

Submission status: Time Limit Exceeded

Solution code:
n = input()
n = int(n)

for x in range(10**6):
    for m in range(100):
        if x ** 5 + m ** 5 == n:
            print(x,-m)
            exit()

Submission status: Time Limit Exceeded

Solution code:
n = input()
n = int(n)

for x in range(10000):
    for m in range(10000):
        if x ** 5 + m ** 5 == n:
            print(x,-m)
            exit()

Submission status: Time Limit Exceeded

Solution code:
n = input()
n = int(n)

a = 0
b = -1
while True:
    if a ** 5 - b ** 5 == n:
        print(a,b)
        exit()
    a += 1

Submission status: Time Limit Exceeded

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
 
x=int(input())
a=1
while True:
    for b in range(a + 1):
        if a**5+b**5==x:
            print(a,-b)
            sys.exit()
        elif a**5-b**5==x:
            print(a,b)
            sys.exit()
        else:
            a+=1

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

if x == 1:
    a = 1
    b = 0
else:
    p = 2
    while True:
        while True:
            if x % p == 0:
                q = int(x / p)
                break
            else:
                p += 1
        ap = p
        am = p
        bp = 0
        bm = 0
        for i in range(10000):
            if ap**4 + ap**3 * bp + ap**2 * bp**2 + ap * bp**3 + bp**4 == q:
                a = ap
                b = bp
                break
            elif am**4 + am**3 * bm + am**2 * bm**2 + am * bm**3 + bm**4 == q:
                a = am
                b = bm
                break
            ap += 1
            bp += 1
            am -= 1
            bm -= 1
        else:
            p += 1
            continue
        break

print('{} {}'.format(a, b))

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

if x == 1:
    a = 1
    b = 0
else:
    p = 2
    while True:
        while True:
            if x % p == 0:
                q = int(x / p)
                break
            else:
                p += 1
        ap = p
        am = p
        bp = 0
        bm = 0
        for i in range(1000):
            if ap**4 + ap**3 * bp + ap**2 * bp**2 + ap * bp**3 + bp**4 == q:
                a = ap
                b = bp
                break
            elif am**4 + am**3 * bm + am**2 * bm**2 + am * bm**3 + bm**4 == q:
                a = am
                b = bm
                break
            ap += 1
            bp += 1
            am -= 1
            bm -= 1
        else:
            p += 1
            continue
        break

print('{} {}'.format(a, b))

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

if x == 1:
    a = 1
    b = 0
else:
    p = 2
    while True:
        while True:
            if x % p == 0:
                q = int(x / p)
                break
            else:
                p += 1
        ap = p
        am = p
        bp = 0
        bm = 0
        for i in range(100):
            if ap**4 + ap**3 * bp + ap**2 * bp**2 + ap * bp**3 + bp**4 == q:
                a = ap
                b = bp
                break
            elif am**4 + am**3 * bm + am**2 * bm**2 + am * bm**3 + bm**4 == q:
                a = am
                b = bm
                break
            ap += 1
            bp += 1
            am -= 1
            bm -= 1
        else:
            p += 1
            continue
        break

print('{} {}'.format(a, b))

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

if x == 1:
    p = 1
    q = 1
else:
    p = 2
    while True:
        if x % p == 0:
            q = int(x / p)
            break
        else:
            p += 1

ap = p
am = p
bp = 0
bm = 0
while True:
    if ap**4 + ap**3 * bp + ap**2 * bp**2 + ap * bp**3 + bp**4 == q:
        a = ap
        b = bp
        break
    elif am**4 + am**3 * bm + am**2 * bm**2 + am * bm**3 + bm**4 == q:
        a = am
        b = bm
        break
    ap += 1
    bp += 1
    am -= 1
    bm -= 1

print('{} {}'.format(a, b))

Submission status: Time Limit Exceeded

Solution code:
import math

X = int(input())

i = 0
while True:
   i += 1
   a = math.pow((X + math.pow(i, 5)), float(1/5))
   if a.is_integer():
      print("%d %d" % (a, i))
      exit()

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

for b in range(2000):
    for a in range(2000):
        if a**5 - b**5 == x:
            print(a, b)
            exit()

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
if not x == 0:
  for i in range(10000):
    for j in range(-10000,10000):
      if i**5 - j**5 == x:
        a = i
        b = j
    
print(str(a)+" "+str(b))

Submission status: Time Limit Exceeded

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

    a = -1
    b1 = -1
    b2 = 1
    while True:
    
        while b1 < a:
            
            if (X/(a-b1)).is_integer():
                if int(X/(a-b1)) == a**4 + b1*(a**3) + (a**2)*(b1**2) + a*(b1**3) + b1**4:
                    print("{} {}\n".format(a, b1))
                    return 0

            if (X/(a-b2)).is_integer():
                if int(X/(a-b2)) == a**4 + b2*(a**3) + (a**2)*(b2**2) + a*(b2**3) + b2**4:
                    print("{} {}\n".format(a, b2))
                    return 0

            b1 = b1 + 1
            b2 = b2 - 1
            
        a += 1


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
X = int(input())

i = 0
while True:
  tmp = X - i**5
  tmp5 = tmp**0.2
  
  if abs(tmp5 - int(tmp5)) < 1e-8:
    print("{} {}".format(i, int(tmp5)))
   
  if abs(tmp5 - int(-tmp5)) < 1e-8:
    print("{} {}".format(i, int(-tmp5)))

Submission status: Time Limit Exceeded

Solution code:
X = int(input())

i = 0
while True:
  tmp = X - i**5
  if abs(tmp**0.2 - int(tmp**0.2)) < 1e-8:
    print("{} {}".format(i, int(tmp**0.2)))
   
  if abs(tmp**0.2 - int(-tmp**0.2)) < 1e-8:
    print("{} {}".format(i, int(-tmp**0.2)))

Submission status: Time Limit Exceeded

Solution code:

from itertools import permutations

def power(base, exp):
  """ Fast power calculation using repeated squaring """
  if exp < 0:
      return 1 / power(base, -exp)
  ans = 1
  while exp:
      if exp & 1:
          ans *= base
      exp >>= 1
      base *= base
  return ans

def parse():
  return int(input())

def main():
  X = parse()

  A = None
  B = None

  # Z = [i for i in range(0, 5)]
  # print(Z)
  # print(list(permutations(range(0, 5), 2)))
  # print(list(permutations(range(0, 5), 2)))
  # exit(0)

  max_val = 1000
  signs = [[1, 1], [-1, 1], [1, -1], [-1, -1]]

  for i in range(0, max_val + 1):
    for j in range(0, max_val + 1):
      for sign in signs:
        # A5 = 
        # print(i * sign[0], j * sign[1])
        if power(i * sign[0], 5) - power(j * sign[1], 5) == X:
          A = i * sign[0]
          B = j * sign[1]
          break

  print(A, B)

if __name__ == "__main__":
  main()

Submission status: Time Limit Exceeded

Solution code:
X=int(input())

b=0
while not ((X+b**5)**(1/5)).is_integer():
    b+=1

a=(X+b**5)**(1/5)
print('{} {}'.format(int(a),b))

Submission status: Time Limit Exceeded

Solution code:
# unihernandez22 & Vicfred
# https://atcoder.jp/contests/abc166/tasks/abc166_d
# math, probability
from random import randint

n = int(input())

for _ in range(10**8):
    x = randint(-1000,1000)
    y = randint(-1000,1000)
    if x**5 - y**5 == n:
        print(x,y)
        break;

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
for a in range(-1000,1000):
    for b in range(-1000, 1000):
        if a**5 - b**5 == n:
            print(a, b)
            break;

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
for a in range(n):
    breaked = True
    for b in range(-n, n):
        if a**5 - b**5 == n:
            print(a, b)
            break;
    else:
        breaked = False
    if breaked:
        break

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
a, b = 0,0
done = False
for i in range(0,20000):
    for l in range(0, -20000, -1):
        if((i**5)-(l**5)==x):
            a = i
            b = l
            done  = True
            break
    if(done):
        break
print(a,b)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
X=int(input())

Xkon=X**0.2
if(Xkon==int(Xkon)):
    print(str(0)+" "+str(int(-Xkon)))
    #break
else:
    m=-10
    while m<0:
        A=X+(m**5)
        check=(A**0.2)
        # print(type(check))
        if(type(check)!=complex):
            if(check==int(check)):
                AnsA=-check
                AnsB=-m
                print(str(int(AnsB))+" "+str(int(AnsA)))
                break
            else:
                pass
        else:
            m=m+1
    n=1
    while n<10:
        A=X+(n**5)
        check=(A**0.2)
        if(check==int(check)):
            AnsA=check
            AnsB=n
            print(str(int(AnsB)+" "+str(int(-AnsA))))
            break
        else:
            n=n+1

Submission status: Time Limit Exceeded

Solution code:
X=int(input())

Xkon=X**0.2
if(Xkon==int(Xkon)):
    print(str(0)+" "+str(int(-Xkon)))
    #break
else:
    m=-(10**2)
    while m<0:
        A=X+(m**5)
        check=(A**0.2)
        # print(type(check))
        if(type(check)!=complex):
            if(check==int(check)):
                AnsA=-check
                AnsB=-m
                print(str(int(AnsB))+" "+str(int(AnsA)))
                break
            else:
                pass
        else:
            m=m+1
    n=1
    while n<10**2:
        A=X+(n**5)
        check=(A**0.2)
        if(check==int(check)):
            AnsA=check
            AnsB=n
            print(str(int(AnsB)+" "+str(int(-AnsA))))
            break
        else:
            n=n+1

Submission status: Time Limit Exceeded

Solution code:
X=int(input())

Xkon=X**0.2
if(Xkon==int(Xkon)):
    print(str(0)+" "+str(int(-Xkon)))
    #break
else:
    m=-(10**3)
    while m<0:
        A=X+(m**5)
        check=(A**0.2)
        # print(type(check))
        if(type(check)!=complex):
            if(check==int(check)):
                AnsA=-check
                AnsB=-m
                print(str(int(AnsB))+" "+str(int(AnsA)))
                break
            else:
                pass
        else:
            m=m+1
    n=1
    while n<10**3:
        A=X+(n**5)
        check=(A**0.2)
        if(check==int(check)):
            AnsA=check
            AnsB=n
            print(str(int(AnsB)+" "+str(int(-AnsA))))
            break
        else:
            n=n+1

Submission status: Time Limit Exceeded

Solution code:
X=int(input())

Xkon=X**0.2
if(Xkon==int(Xkon)):
    print(str(0)+" "+str(int(-Xkon)))
    #break
else:
    m=-(10**4)
    while m<0:
        A=X+(m**5)
        check=(A**0.2)
        # print(type(check))
        if(type(check)!=complex):
            if(check==int(check)):
                AnsA=-check
                AnsB=-m
                print(str(int(AnsB))+" "+str(int(AnsA)))
                break
            else:
                pass
        else:
            m=m+1
    n=1
    while n<10**4:
        A=X+(n**5)
        check=(A**0.2)
        if(check==int(check)):
            AnsA=check
            AnsB=n
            print(str(int(AnsB)+" "+str(int(-AnsA))))
            break
        else:
            n=n+1

Submission status: Time Limit Exceeded

Solution code:
X=int(input())

Xkon=X**0.2
if(Xkon==int(Xkon)):
    print(str(0)+" "+str(int(-Xkon)))
    #break
else:
    n=1
    while n<10**4:
        A=X+(n**5)
        check=(A**0.2)
        if(check==int(check)):
            AnsA=check
            AnsB=n
            print(str(int(AnsB)+" "+str(int(-AnsA))))
            break
        else:
            n=n+1
    m=-(10**4)
    while m<0:
        A=X+(m**5)
        check=(A**0.2)
        # print(type(check))
        if(type(check)!=complex):
            if(check==int(check)):
                AnsA=-check
                AnsB=-m
                print(str(int(AnsB))+" "+str(int(AnsA)))
                break
            else:
                pass
        else:
            m=m+1

Submission status: Time Limit Exceeded

Solution code:
X=int(input())

Xkon=X**0.2
if(Xkon==int(Xkon)):
    print(str(0)+" "+str(int(-Xkon)))
    #break
else:
    n=1
    while n<10**5:
        A=X+(n**5)
        check=(A**0.2)
        if(check==int(check)):
            AnsA=check
            AnsB=n
            print(str(int(AnsB)+" "+str(int(-AnsA))))
            break
        else:
            n=n+1
    m=-(10**5)
    while m<0:
        A=X+(m**5)
        check=(A**0.2)
        # print(type(check))
        if(type(check)!=complex):
            if(check==int(check)):
                AnsA=-check
                AnsB=-m
                print(str(int(AnsB))+" "+str(int(AnsA)))
                break
            else:
                pass
        else:
            m=m+1

Submission status: Time Limit Exceeded

Solution code:
X=int(input())
n=0
while n<10**8:
    A=X+(n**5)
    check=(A**0.2)
    if(check==int(check)):
        AnsA=check
        AnsB=n
        print(str(int(AnsA))+" "+str(int(AnsB)))
        break
    else:
        n=n+1

Submission status: Time Limit Exceeded

Solution code:
X=int(input())
n=0
while n<10**9:
    A=X+(n**5)
    check=(A**0.2)
    if(check==int(check)):
        AnsA=check
        AnsB=n
        print(str(int(AnsA))+" "+str(int(AnsB)))
        break
    else:
        n=n+1

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

x_r = x**(1/5).real
for a in range(round(x_r), 10**9):
  f_a = a**5
  r_b = (x-f_a)**(1/5).real
  b = round(r_b.real)
  if f_a - b**5 == x:
    print(a, b)
    break
  b *= -1
  if f_a - b**5 == x:
    print(a, b)
    break

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

for a in range(1, 10**9):
  f_a = a**5
  r_b = (x-f_a)**(1/5).real
  b = round(r_b.real)
  if f_a - b**5 == x:
    print(a, b)
    break
  b *= -1
  if f_a - b**5 == x:
    print(a, b)
    break

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
A=0
B=0
while(True):
  while(True):
    if (A**5) - (B**5) == X:
      print("{} {}".format(A,B))
      exit()
    elif ((-1*A)**5) - (B**5) == X:
      print("{} {}".format(-1*A,B))
      exit()
    elif (A**5) - ((-1*B)**5) == X:
      print("{} {}".format(A,-1*B))
      exit()   
    elif ((-1*A)**5) - ((-1*B)**5) == X:
      print("{} {}".format(-1*A,-1*B))
      exit()
    else:
      B += 1
  A += 1

Submission status: Time Limit Exceeded

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

for x in range(100000):
    for y in range(100000):
        A = x ** 5 - y ** 5
        if A == X:
            print(x, y)
            sys.exit()
        A = - x ** 5 - y ** 5
        if A == X:
            print(-x, y)
            sys.exit()
        A = x ** 5 + y ** 5
        if A == X:
            print(x, -y)
            sys.exit()
        A = -x ** 5 + y ** 5
        if A == X:
            print(-x, -y)
            sys.exit()

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
 
flag = 0
A = 0
B = 0
 
for i in range(0, 100000):
  for j in range(0, i):
    if i**5 - j**5 == X:
      A = i
      B = j
      break
    elif i**5 + j**5 == X:
      A = i
      B = j
      break
    elif -i**5 - j**5 == X:
      A = -i
      B = j
      break
print(str(A) + ' ' + str(B))

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
 
flag = 0
A = 0
B = 0
 
for i in range(0, 10000):
  for j in range(0, 10000):
    if i**5 - j**5 == X:
      A = i
      B = j
      break
    elif i**5 + j**5 == X:
      A = i
      B = j
      break
    elif -i**5 - j**5 == X:
      A = -i
      B = j
      break
print(str(A) + ' ' + str(B))

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
 
flag = 0
A = 0
B = 0
 
for i in range(0, 100000):
  for j in range(0, 100000):
    if i**5 - j**5 == X:
      A = i
      B = j
      break
    elif i**5 + j**5 == X:
      A = i
      B = j
      break
    elif -i**5 - j**5 == X:
      A = -i
      B = j
      break
print(str(A) + ' ' + str(B))

Submission status: Time Limit Exceeded

Solution code:
X=int(input())
for i in range(-1500,1501):
    for j in range(-1500,1501):
        if (i**5)-(j**5)==X:
            print(i,j)
            exit()

Submission status: Time Limit Exceeded

Solution code:
"""
A^5 - B^5
= (A - B)(A^4 + A^3*B + A^2*B^2 + A*B^3 + B^4)
= (A - B){(A + B) * (A^3 + B^3) + A^2*B^2}
= (A - B){(A + B)^2 * (A^2 - AB + B^2) + A^2*B^2}

(A + B)^2 > 0, (A^2 - AB + B^2) > 0, A^2*B^2 > 0
-> (A - B) > 0
"""


def main():
    print(*solve())


def solve():
    X = int(input())
    N = 10 ** 9 + 7

    if X % 2:
        step = 1
    else:
        step = 2  # if X is odd number, (A - B) also must be odd.

    for x in range(1, N, step):  # x means (A - B)
        if X % x:  # X must be divided by (A - B)
            continue

        for a in range(N):
            b = a - x

            diff = X - (a ** 5 - b ** 5)
            if diff == 0:
                return a, b

            if diff < 0 < b:
                break


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
X = int(input())

for a in range(1 , 10**3 , 1):
  A = a**5
  for b in range(0 , X+1 , 1):
    B = b**5
    if(A-B==X):
      print(a, b)
      exit()
    else:
      continue
      
for a in range(0 , 10**3 , 1):
  A = a**5
  for b in range(0 , -X-1 , -1):
    B = b**5
    if(A-B==X):
      print(a, b)
      exit()
    else:
      continue

Submission status: Time Limit Exceeded

Solution code:
x=int(input())
f=x**(1/2)
a=list(range(-round(f), round(f)))
for i in range(x, -1, -1):
    b=i**(1/5)
    if b in a: 
        A=b
        break
for i in a: 
    m=i**5
    if A**5-m==x: 
        B=i
        break
print(round(A),round(B))

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
a = 0
b = 0
b2 = 0
judge = 0

"""while a**5 - b**5 < 10**9:
    while a**5 - b**5 > 0:
        if a**5 - b**5  == x:
            judge = 1
            print(a ,b)
            break
        b += 1
    else:
        a += 1
        continue
    break
"""
if judge == 0:
    a = 0
    while a**5 - b2**5 < 10**9:
        while a**5 - b2**5 > 0:
            if a**5 - b2**5  == x:
                print(a ,b2)
                break
            b2 -= 1
        else:
            a += 1
            continue
        break

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
a = 0
b = 0
b2 = 0
judge = 0

while a**5 - b**5 < 10**9:
    while a**5 - b**5 > 0:
        if a**5 - b**5  == x:
            judge = 1
            print(a ,b)
            break
        b += 1
    else:
        a += 1
        continue
    break

if judge == 0:
    a = 0
    while a**5 - b2**5 < 10**9:
        while a**5 - b2**5 > 0:
            if a**5 - b2**5  == x:
                print(a ,b2)
                break
            b2 -= 1
        else:
            a += 1
            continue
        break

Submission status: Time Limit Exceeded

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

from collections import deque

X = int(input())
s = {}
q = deque()

q.append([1, 0])
while True:
	ab = q.popleft()
	tmp = ab[0] ** 5 - ab[1] ** 5
	if (tmp == X):
		print(ab[0], ab[1])
		quit()
	elif (tmp > X):
		q.append([ab[0] - 1, ab[1]])
		q.append([ab[0], ab[1] - 1])
	else:
		q.append([ab[0] + 1, ab[1]])
		q.append([ab[0], ab[1] - 1])

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt
x=int(input())
a=list(range(-round(sqrt(x)), round(sqrt(x))))
for i in range(x, -1, -1):
    b=i**(1/5)
    if b in a: 
        A=b
        break
for i in a: 
    m=i**5
    if A**5-m==x: 
        print(round(A), round(i))
        break

Submission status: Time Limit Exceeded

Solution code:
from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
#from functools import lru_cache   #use @lru_cache(None)
if os.path.exists('in.txt'): sys.stdin=open('in.txt','r')
if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')
#
def input(): return sys.stdin.readline()
def mapi(arg=0): return map(int if arg==0 else str,input().split())
#------------------------------------------------------------------

x = int(input())
def bs(n):
    l = -1000
    r = n
    while r-l>=0:
        mid = (l+r)>>1
        tmp = pow(mid,5)
        if tmp==n:
            return True, mid
        elif tmp<n:
            #print(mid,tmp,n)
            l = mid+1
        else:
            r = mid
    if pow(l,5)==n:
        return True,l
    return False,0
for i in range(-1000,1000):
    key = pow(i,5)-x
    f,b = bs(key)
    if f:
        print(i,b)
        break

Submission status: Time Limit Exceeded

Solution code:
import itertools
X = int(input())

l = [i for i in range(-10000, 10000)]
c = itertools.permutations(l, 2)
for a, b in c:
    if a**5 - b**5 == X:
        print(a, b)
        break

Submission status: Time Limit Exceeded

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

def main():
    X = int(input())
    i = 0
    while True:
        a = (X + i**5)**(1/5)
        if isinstance(a, float):
            if a.is_integer():
                print(str(int(a))+' '+str(i))
                break

        a = (X - i**5)**(1/5)
        if isinstance(a, float):
            if a.is_integer():
                print(str(int(a))+' '+str(-i))
                break
        i += 1

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n, = map(int, input().strip().split())

# a5 - b5 = (a-b)(a4 + a3b + a2b2 + ab3 + b4)

def check(x):
  u = n//x+1
  for a in range(u+1):
    b = a - x
    if abs(b) > u:
      continue
    c = a**4 + a**3 * b + a**2 * b**2 + a * b**3 + b**4
    d = x * c
    if d == n:
      return [a, b]

    a += 1
  return None

for i in range(1, n+1):
  res = check(i)
  if res:
    break

r1, r2 = res
print(r1, r2)

Submission status: Time Limit Exceeded

Solution code:
n, = map(int, input().strip().split())

# a5 - b5 = (a-b)(a4 + a3b + a2b2 + ab3 + b4)

def check(x):
  for a in range(n//x+1):
    b = a - x
    c = a**4 + a**3 * b + a**2 * b**2 + a * b**3 + b**4
    d = x * c
    if d == n:
      return [a, b]

    a += 1
  return None

for i in range(1, n+1):
  res = check(i)
  if res:
    break

r1, r2 = res
print(r1, r2)

Submission status: Time Limit Exceeded

Solution code:
n, = map(int, input().strip().split())

# a5 - b5 = (a-b)(a4 + a3b + a2b2 + ab3 + b4)

def check(x):
  for a in range(n+1):
    b = a - x
    c = a**4 + a**3 * b + a**2 * b**2 + a * b**3 + b**4
    d = x * c 
    if d == n:
      return [a, b]

    a += 1
  return None

for i in range(1, n+1):
  res = check(i)
  if res:
    break

r1, r2 = res
print(r1, r2)

Submission status: Time Limit Exceeded

Solution code:
X = int(input())

for a in range(0 , 10**2 , 1):
  for b in range(0 , X+1 , 1):
    if(a**5-b**5==X):
      print(a, b)
      exit()
    else:
      continue
      
for a in range(0 , 10**2 , 1):
  for b in range(0 , -X , -1):
    if(a**5-b**5==X):
      print(a, b)
      exit()
    else:
      continue

Submission status: Time Limit Exceeded

Solution code:
X = int(input())

for a in range(0 , 10**3 , 1):
  for b in range(0 , X+1 , 1):
    if(a**5-b**5==X):
      print(a, b)
      exit()
    else:
      continue
      
for a in range(0 , 10**3 , 1):
  for b in range(0 , -X , -1):
    if(a**5-b**5==X):
      print(a, b)
      exit()
    else:
      continue

Submission status: Time Limit Exceeded

Solution code:
X = int(input())

for a in range(0 , 10**4 , 1):
  for b in range(0 , X+1 , 1):
    if(a**5-b**5==X):
      print(a, b)
      exit()
    else:
      continue
      
for a in range(0 , 10**4 , 1):
  for b in range(0 , -X , -1):
    if(a**5-b**5==X):
      print(a, b)
      exit()
    else:
      continue

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
for a in range(1000000000000000):
  for b in range(1000000000000000):
    if a ** 5 - b ** 5 == x:
      print(str(a)+" "+str(b))

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
a = 1
b = 1
while True:  
  if(a**5 - b**5 == X):
    print(a , b)
    break
  a += 1
  for i in range(X):
    b += 1
    if(a**5 - b**5 == X):
      print(a , b)
      exit()
while True:
  if(a**5 - b**5 == X):
    print(a , b)
    break
  b -= 1
  for j in range(X):
    b -= 1
    if(a**5 - b**5 == X):
      print(a , b)
      exit()

Submission status: Time Limit Exceeded

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

while True:
    if ((a**5 - X) ** (-5)).is_integer():
        print(a, int((a**5 - X) ** (-5)))
        break
    else:
        a += 1

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
a = 1
b = 1
while True:
  if(a**5 - b**5 == X):
    print(a , b)
    break
  a += 1
  b += 1
while True:
  if(a**5 - b**5 == X):
    print(a , b)
    break
  a += 1
  b -= 1

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
for A in range(-2500, 2500):
    for B in range(-2500, 2500):
        if A**5 - B**5 == X:
            print(A, B)
            break
    else:
        continue
    break

Submission status: Time Limit Exceeded

Solution code:
x = int(input())

a = -1
b = 0

while True:
    a5 = pow(a, 5)
    b5 = pow(b, 5)
    if(a5-b5 == x):
        print("{} {}".format(a, b))
        break
    if(a5+b5 == x):
        print("{} {}".format(a, -b))
        break
    if(-a5-b5 == x):
        print("{} {}".format(-a, b))
        break
    if(-a5+b5 == x):
        print("{} {}".format(-a, -b))
        break

    b += 1
    if(a==b):
        a +=1
        b =0

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
for A in range(-5000, 5000):
    for B in range(-5000, 5000):
        if A**5 - B**5 == X:
            print(A, B)
            break
    else:
        continue
    break