Problem:
 Score : 200 points    Problem Statement You are given a positive integer X .
Find the largest perfect power that is at most X .
Here, a perfect power is an integer that can be represented as b^p , where b is an integer not less than 1 and p is an integer not less than 2 .      Constraints  1  ≤  X  ≤  1000  X is an integer.         Input Input is given from Standard Input in the following format:  X       Output Print the largest perfect power that is at most X .        Sample Input 1 10      Sample Output 1 9  There are four perfect powers that are at most 10 : 1 , 4 , 8 and 9 .
We should print the largest among them, 9 .       Sample Input 2 1      Sample Output 2 1       Sample Input 3 999      Sample Output 3 961

Solution (Python):
X = int(input())
 
score =0
half_x = round(X/2)
 
answer = 0
 
if X < 3:
    print(1)
 
elif X <= 8:
    print(4)
 
else:
    while 1 < half_x:
        half_x -= 1
        
        for p in range(2, 10):
            
            score = pow(half_x,p)
            if score > X:
                continue
        
            if answer < score:
                answer = score
                
    print(answer)

Solution (Python):
x = int(input())

def is_power(a, b):
  while a % b == 0:
    a = a / b
  if a == 1:
    return True
  return False

def is_perfect_power(n):
    for i in range(n//2, 1, -1):
        if is_power(n, i):
            return True
    return False

ans = 1

for i in range(x, 1, -1):
    if is_perfect_power(i):
        ans = i
        break

print(ans)

Solution (Python):
import sys
x = int(raw_input())



p = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]

def isPowerOfTwo(n):
    return (n > 0) and (n & (n - 1) == 0)








if x < 4:
    print 1
    sys.exit()

X = x

while x > 1:
    n = x

    if isPowerOfTwo(x) == True:
        print x
        sys.exit()
    if x == 2 or x in p:
        x-=1
        continue
    for i in xrange(3,X):
        n = x
        c = 0
        while True:
            if n % i != 0:
                break
            n /= i
            c += 1
            if n == 1 and c > 1:
                print x
                sys.exit()
    x-=1
print 1

Solution (Python):
def check(n):
    m = 2
    dic = {}
    while n > 1:
        if n%m == 0:
            while n%m == 0:
                if m in dic:
                    dic[m] += 1
                else:
                    dic[m] = 1
                n //= m
        m += 1
    lis = []
    for i in dic.values():
        lis.append(i)
    if len(set(lis)) == 1 and lis[0] != 1:
        return True
    else:
        return False
x = int(input())
if x == 1 or x == 2 or x == 3:
    print(1)
    quit()
for i in range(x+1):
    if check(x-i):
        print(x-i)
        quit()

Solution (Python):
from math import sqrt
x = int(input())
x2 = int(sqrt(x))
ans = 1
for i in range(x2):
  for k in range(x2-1):
    tmp = (i+1)**(k+2)
    if tmp<=x and ans<=tmp:
      ans = tmp
print(ans)

Solution (Python):
inputX = int(input())
maxNumber = 1
if inputX <= 3:
    maxNumber = 1
else:
    for i in range(2, 33):
        if i== 2:
            for i1 in range(2, 10):
                if i ** i1 <= inputX:
                    if i ** i1 > maxNumber:
                        maxNumber = i ** i1
        elif i == 3:
            for i1 in range(2, 7):
                if i ** i1 <= inputX:
                    if i ** i1 > maxNumber:
                        maxNumber = i ** i1
        elif i <= 5:
            for i1 in range(2, 5):
                if i ** i1 <= inputX:
                    if i ** i1 > maxNumber:
                        maxNumber = i ** i1
        elif i <= 10:
            for i1 in range(2, 4):
                if i ** i1 <= inputX:
                    if i ** i1 > maxNumber:
                        maxNumber = i ** i1
        else:
            if i ** 2 <= inputX:
                if i ** 2 > maxNumber:
                    maxNumber = i ** 2


print (maxNumber)

Solution (Python):
import math
xx = input()
 
xs = sorted(list(set([ b ** p for b in range(1,33) for p in range(2,33) if b ** p <= 1000])))

print max([x for x in xs if x <= xx])

Solution (Python):
x = int(input())

m = 1
for i in range(1, x):
    for j in range(2, x):
        k = pow(i, j)
        if k <= x:
            m = max(k, m)
        else:
            break

print(m)

Solution (Python):
import collections

X = int(input())

def soin(x):
    li = []
    a = 2
    while x >= a * a:
        if x % a == 0:
            li.append(a)
            x //= a
        else:
            a += 1

    li.append(x)
    return(li)


for i in range(X + 1)[::-1]:
    li = soin(i)
    c = list(collections.Counter(li).values())
    if list(set(c)) == [1]:
        continue
    if len(list(set(c))) == 1:
        print(i)
        break

else:
    print(1)

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

a = []
b = []
for i in range(8):
    a.append(math.floor(math.pow(x,(1.0/(i+2)))))

for i in range(8):
    b.append(math.pow(a[i],(i+2)))
tmp = 0
for i in range(8):
    if tmp < b[i]:
        tmp = b[i]
if x != 1000:
    print(math.floor(tmp))
else:
    print(1000)

Solution (Python):
import numpy as np

X = int(input())



def MaxPow(X):
    Max = 1

    if int(np.sqrt(X)) ==1:
        return Max
    
    for b in range(2,int(np.sqrt(X))+1):
        
        for p in range(2,int(np.log(X)/np.log(b))+2):
            tmp = b**p
            if tmp<=X:
                Max = max(Max,tmp)
    return Max

print(MaxPow(X))

Solution (Python):
X = int(raw_input())
  
result = 0

arr = []
for i in range(1,1001):
    for j in range(2,11):
        if i**j <= 1000:
            arr.append(i**j)
for k in arr:
    if k <= X and k >= result:
        result = k
print(result)

Solution (Python):
x = int(input())
ans = []
i = 2
while i < 10:
    t = 0
    while t <= x:
        if t ** i > x:
            break
        ans.append(t**i)
        t += 1
    i += 1
print(max(ans))

Solution (Python):
import math

x = int(input())

l = [1]

for i in range(x, 0, -1):
    if math.sqrt(i).is_integer():
        l.append(i)

    for j in range(2, 20):
        if pow(i, j) <= x:
            l.append(pow(i, j))

print(max(l))

Solution (Python):

X = int(input())

maxVal1 = 0
maxVal2 = 0
maxVal3 = 0
maxVal4 = 0
maxVal5 = 0
val = 0


for i in range(33):
	if i**2 > X:
		maxVal1 = i-1
		break

for j in range(12):
	if j**3 > X:
		maxVal2 = j-1
		break

for k in range(7):
	if k**4 > X:
		maxVal3 = k-1
		break

for k in range(5):
	if k**5 > X:
		maxVal4 = k-1
		break

for k in range(4):
	if k**6 > X:
		maxVal5 = k-1
		break


maxVal = max(maxVal1**2, maxVal2**3, maxVal3**4, maxVal4**5, maxVal5**6)
print(maxVal)

Solution (Python):
X = int(input())

score =0
half_x = round(X/2)

answer = 0

if X < 3:
    print(1)

elif X <= 8:
    print(2)

else:
    while 1 < half_x:
        half_x -= 1
        
        for p in range(2, 10):
            
            score = pow(half_x,p)
            if score > X:
                continue
        
            if answer < score:
                answer = score
                
    print(answer)

Solution (Python):
X = int(input())
ans = []
for p in range(2, 10):
    for b in range(1, 32):
        if b**p <= X:
            ans.append(b**p)
        else:
            break
print(max(ans))

Solution (Python):
import math 

X = int(input())
A =[]
if X == 1:
    print(1)
else:
    for i in range(30):
        b = i+2
        B = math.log(X+0.01,b)
        if math.floor(B) != 1:
            A.append(b**math.floor(B))
    print(max(A))

Solution (Python):
import math
X = int(input())
maximumList = []



if X <= 3:
    print(1)
else:    
    for b in range(2,math.ceil(X**0.5)):
        p = 2
        while b**p <= X:
            p += 1
        else:
            if b**(p-1) <= X:
                maximumList.append(b**(p-1))
    print(max(maximumList))

Solution (Python):

x = int(input())
max = 1
for b in range(1,50):
    for p in range(2,50):
        if b**p >= max and b**p <= x:
            max = b**p

print(max)

Solution (Python):
n = int(input())
ans = 1
for i in range(2, 10):
    for j in range(32):
        m = j**i
        if m <= n and ans < m:
            ans = m
print(ans)

Solution (Python):
x = int(input())
a = []

for i in range(1,32):
  for j in range(2,10):
    if i**j > 1000:
      break
    else:
      a.append(i**j)
a = list(set(a))
a.sort()
for i in reversed(a):
  if i <= x:
    print(i)
    break

Solution (Python):
x = int(input())
max1 = 1
for s in range(x):
  for t in range(2,10):
    if pow(s,t) > max1 and pow(s,t) <= x:
      max1 = pow(s,t)
print(max1)

Solution (Python):
import math
import numpy as np

x = int(input())
x_sqrt = math.sqrt(x)
maxlist = []

def hoge(x, x_sqrt):
    for b in range(2, x_sqrt+1):
        i = 1
        while b ** i <= x:
            i += 1
        maxlist.append(b **(i-1))
    return np.max(np.array(maxlist))

if x - x_sqrt == 0:
    print(x)
else:
    print(hoge(x, int(x_sqrt)))

Solution (Python):
x = int(input())

ans = 1
for i in range(1,11):
    for j in range(32):
        tes = (j+1)**(i+1)
        if tes <= x and tes >= ans:
            ans = tes

print(ans)

Solution (Python):
x = int(input())
import math
flag = False
for i in range(x):
    ans = x - i
    for j in range(2,x):
        b = round(math.pow(ans, 1/j), 10)
        if b % 1 == 0:
            flag = True
            break
        elif b < 1:
            break
    if flag:
        break
print(ans)

Solution (Python):
a = int(input())
l = []
for i in range(1,100):
    for j in range(2,11):
        l.append(i**j)
l.sort()
for n in range(len(l)):
    if l[n] > a:
        print(l[n-1])
        break

Solution (Python):
import math
N = int(input())


beki = [1]
for i in range(2,32):
    beki = beki + [pow(i,j_prime) for j_prime in range(2,11) if pow(i,j_prime) <= 1000]
beki_uniq = list(set(beki))
beki_small = max([i for i in beki_uniq if i <= N])


print(beki_small)

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





if x == 1:
    print(1)
else:
    array = []
    for b in range(1, x // 2):
        previous = 1
        for p in range(2, x // 2):
            if b ** p > x:
                break
            else:
                previous = b ** p
        array.append(previous)
    array.sort(reverse=True)
    print(array[0])

Solution (Python):
a = (1,4,8,9,16,25,27,32,36,49,64,81,100,121,125,128,144,169,196,216,225,243,256,289,324,343,361,400,441,476,484,512,529,576,625,676,729,784,841,900,961,1000)
k = int(input())
for i in range(len(a)):
  if k == 1:
    print(1)
    break
  elif k == 1000:
    print(1000)
    break
  
  elif a[i] > k:
    print(a[i-1])
    break

Solution (Python):
n = int(input())
a = [1]
for i in range(2,32):
	a.append(i**2)
for i in range(2,11):
	a.append(i**3)
for i in range(2,6):
	a.append(i**4)
for i in [2,3]:
	a.append(i**5)
	a.append(i**6)
for i in [7,8,9]:
	a.append(2**i)

b = set(a)
a = sorted(list(b), reverse=True)
for i in range(len(a)):
	if a[i] <= n:
		print(a[i])
		break

Solution (Python):
N = int(input())
max = 1
 
x = [1,4,8,16,32,64,128,256,512,9,27,81,243,729,25,125,625,36,216,49,343,100,1000,11**2,
12**2,
13**2,
14**2,
15**2,
16**2,
17**2,
18**2,
19**2,
20**2,
21**2,
22**2,
23**2,
24**2,
25**2,
26**2,
27**2,
28**2,
29**2,
30**2,
31**2,
]
 
for i in range(len(x)):
    if N >= int(x[i]) :
        if max < int(x[i]) :
            max = int(x[i])
print(max)

Solution (Python):
X = int(input())
a_list = []
for s in range(1, 32):
    for i in range(2, 10):
        a = s ** i
        if a > 1000:
            break
        a_list.append(a)
a2 = sorted(list(set(a_list)), reverse=True)
for n in a2:
    if n <= X:
        print(n)
        break

Solution (Python):
from math import log, floor
x = int(input())

ans = 1
for b in range(2, x+1):
    p = 2
    while  b**p <= x:
        p += 1
    if p - 1 >= 2:
        ans = max(ans, b**(p-1))
print(ans)

Solution (Python):
x = int(input())

value = 1

while value**2 <= x:
    value += 1

value -= 1
ans = value**2
for i in range(2, value):
    for l in range(2, value):
        num = i ** l

        if num <= x and num > ans:
            ans = num
            
print(ans)

Solution (Python):
X = int(input())

ans = 0

for b in range(1, 32):
  for p in range(2, 10):
    if ans < b ** p <= X:
      ans = b ** p
      
print(ans)

Solution (Python):



X = int(input())
ans = []

for j in range(2,11,1):
	for i in range(1,X+1,1):
		if pow(i,j) > X:
			ans.append(pow(i-1,j))
			break
		if pow(i,j) == X:
			ans.append(pow(i,j))
			break

print("{}".format(max(ans)))

Solution (Python):
a, = list(map(int, input().split()))
max_num = 1
for base in range(1, a+1):
    for index in range(2, a):
        ret = base ** index
        if ret <= a:
            if ret >= max_num:
                max_num = ret
        else:
            break
print(max_num)

Solution (Python):
x = int(input())
max = 1
for i in range(2,33):
  p = 1
  while 1:
    p += 1
    if i**p < x+1:
      if i**p > max:
        max = i**p
    else:
      break
print(max)

Solution (Python):
x=int(input())
if x==1:
    print(1)
    import sys
    sys.exit()
ans=0
for b in range(2,x):
    bp=b**2
    while(True):
        if bp*b <= x:
            bp=bp*b
            continue
        elif bp <= x <bp*b:
            ans=max(ans,bp)
            break
        else:
            break
print(ans)

Solution (Python):
import bisect
s = [1]
for i in range(2, 1001):
    j = i*i
    while j <= 1000:
        s.append(j)
        j *= i

s.sort()
print(s[bisect.bisect_right(s, int(input()))-1])

Solution (Python):
X = int(input())
r = 1
for b in range(2,X+1):
	p = 2
	while b**p<=X:
		if r<b**p:
			r = b**p
		p = p + 1
print(r)

Solution (Python):
x = int(input())
Max = 0
for i in range(1,33):
    for j in range(2,7):
        if i ** j <= x:
            if Max < i ** j:
                Max = i**j
print(Max)

Solution (Python):
import numpy as np
x = int(input())
num = [0]
for b in range(1, int(np.sqrt(x))+1):
    for p in range(2, 11):
        if b**p <= x:
            num.append(b**p)
        if b**p > x:
            break
print(max(num))

Solution (Python):
X = int(input())

flag = False
for x in range(X):
    for i in range(2, X-x+1):
        n = X - x
        m = 0
        while True:
            if m == 0:
                m = i
            if n % i == 0:
                n = n / i
                if n == 1 and m != X - x:
                    flag = True
                if flag:
                    break
            else:
                break
        if flag:
            break
    if flag:
        break
if flag:
    print(X - x)
else:
    print(1)

Solution (Python):



limit = int(input())

b = 2
p = 2


num_list = [1]
while b ** p <= 1000:

	while b ** p <= 1000:
		num_list.append(b ** p)
		p += 1

	b += 1
	p = 2


num_list = list(set(num_list))

num_list.sort()


result_list = []
for num in num_list:
	if num <= limit:
		result_list.append(num)
	else:
		break


print(result_list[len(result_list)-1])

Solution (Python):
n=int(input())
ans=[]
import math
if n==1:
    print(1)
    exit()
for i in range(1,int(math.sqrt(n))+1):
    for j in range(1,int(math.sqrt(n))+1):
        if i**j<=n:
            ans.append(i**j)
print(max(ans))

Solution (Python):
ansList = []
for i in range(1,33):
    for j in range(2,33):
        judge = i ** j
        if(judge <=1000 and judge not in ansList):
            ansList.append(judge)
ansList = sorted(ansList)

X = int(input())
temp = 0
for l in ansList:
    if(X >= l):
        temp = l

print(temp)

Solution (Python):
x = int(input())
a = 1
for i in range(2, 10) :
    for b in range(1, 32) :
        if( b**i<=x and a<b**i ) :
            a = b**i
print("{}".format(a))

Solution (Python):
import numpy as np
X=int(input())
Y=int(np.sqrt(X))+1
max=1
for j in range(2,Y+1):
    for i in range(1,Y+1):
        if i**j<=X and i**j>max:
            max=i**j
print(max)

Solution (Python):
X=int(input())

ls=set([1,])
for p in range(2,10):
    b=2
    while True:
        xx=b**p
        if xx>X:
            break
        else:
            ls.add(xx)
        b+=1
print(max(ls))

Solution (Python):
x = int(input())

i = 1
p = 1

m = 1

for b in range(2, x):
    p = 1
    n = 1
    while n <= x:
        if m < n:
            m = n
        p += 1
        n = b ** p

print(m)

Solution (Python):
num=[1,4,8,16,32,64,128,256,512,9,27,81,243,729,25,125,49,343,121,144,169,196,225,256,289,324,361,400,441,484,529,576,625,676,729,784,841,900,961,1000]
num.sort()
x=int(input())
ans=1
for i in range(len(num)):
    if num[i]<=x:
        ans=max(ans,num[i])
print(ans)

Solution (Python):
import bisect
import math
import itertools

def main():
    s = set([1])
    m = 1000

    for b in range(2, int(math.sqrt(m)) + 1):
        for p in itertools.count(2):
            q = b ** p
            if q > m:
                break
            s.add(q)
    
    s = list(sorted(s))
    x = int(input())

    y = bisect.bisect_left(s, x)
    if s[y] == x:
        print(x)
    else:
        print(s[y-1])

main()

Solution (Python):














X = int(raw_input())

array = []
num=1
i=1
p=2
while i <= 31:
    p = 2
    while p < 9:
        tmp = pow(i, p);
        if tmp <= 1000:
            array.append(tmp)
        else:
            break

        p = p +1
    i = i+1
        
array.sort()
array.reverse()



for item in array:
    if X < item:
        continue
    else:
        print item
        break

Solution (Python):
import math

X=int(input())

y = math.sqrt(X)
y=math.floor(y)

A=1
B=[]

for i in range(1,y+1):
    for j in range(1,y+1):
        A= i** j
        if A<=X:
            B.append(A)
print(max(B))

Solution (Python):
def main():
    N = int(input())

    if N == 1:
        print(1)
        return

    ans = 0
    for b in range(1, N):
        for p in range(2, N):
            n = b ** p
            if n <= N:
                ans = max(ans, n)
            else:
                break
    print(ans)

main()

Solution (Python):
x = int(input())
ans = 0
c = 35
for i in range(c):
    for j in range(2,c):
        a = pow(i,j)
        if ans <= a <= x and isinstance(a, int):
            ans = a

print(ans)

Solution (Python):
import math

X = int(input())

n = int(math.sqrt(X))
max_numbers = [1]
for i in range(1, n):
    index = 0
    for j in range(X):
        if pow((i+1), j) > X:
            break
        index = j
    
    max_numbers.append(pow((i+1), index))
    

print(int(max(max_numbers)))

Solution (Python):

import math
X=int(input())
max=0

for b in range(int(math.sqrt(X)+1)):
    p=2
    while p<=100:
        a=b**p
        if a>X:
            break
        if max<a:
            max=a
        p=p+1
print(max)

Solution (Python):
import math
X = int(input())
N = int(math.sqrt(X))
Ans = 1
for i in range(1, N + 1):
    for j in range(2, int(math.log2(X))):
        if i ** j > X:
            break
        elif i ** j > Ans:
            Ans = i ** j
print(Ans)

Solution (Python):
x = input()
n = 0
for i in range(11):
    if i == 0 or i == 1:
        continue
    for j in range(32):
        if j**i <= x and j**i > n:
            n = j**i
print n

Solution (Python):
X=int(input())
answer=0
b=2
q=2
if X==1 or X==2 or X==3:
    print("1")
else :
    while b<X:
        while b**q<=X:
            if b**q>answer and b**q<=X:
                answer=b**q
            q+=1
        q=2
        b+=1
    print(answer)

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

def beki(x):
    M = 1
    for p in range(2,int(math.sqrt(x))+1):
        for b in range(1,x+1):
            tmp =  pow(b,p)
            if tmp > M and tmp <= x:
                M = tmp
    return (M)

result = beki(x)

print(result)

Solution (Python):
X=int(input())
C=-1
if (X<=1):
	print(1)
else:
	for J in range(1,X+1):
		for I in range(2,X+1):
			if pow(J,I)<=X:
				if pow(J,I)>C:
					C=pow(J,I)
			else:
				break
	print(C)

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

ans = 1

for i in range(2,n):
    flag = 0
    num = n
    num2 = i
    while True:
        num = num/i
        if(num >= i):
            num2 = num2*i
            flag = 1
        else:
            break

    if(ans<num2 and flag == 1):
        ans=num2

print(ans)

Solution (Python):
X= int(input().strip())
tmp = 1
endflag = 10000
for j in range(2,X):
    for i in range(1,X):
        if i**j<=X and tmp<i**j and (i+1)**j>X:
            tmp = i**j
            endflag = i
            break
        elif i >= endflag:
            break
print(tmp)

Solution (Python):

list1=[1,2,4,8,16,32,64,128,256,512,9,27,81,243,729,25,125,625,49,343,100,1000,121]
num=input()
num=int(num)

for i in range(12,32):
    list1.append(i**2)
    i+=1
list2=[]
for j in range(len(list1)):
    if num>=list1[j]:
        list2.append(list1[j])
        j +=1
        
print(max(list2))

Solution (Python):
import math

X=int(raw_input())


r=1
for i in range(2,X):
  m = int(math.log(X, i)+10**-10)
  if m > 1 and r < i**m:
    r = i**m

print r

Solution (Python):
x=int(input())
a=[]
for i in range(1,32):
    for j in range(2,10):
        a.append(i**j)
a = sorted(a, reverse=True)
for i in range(len(a)):
    if a[i]<=x:
        print(a[i])
        break

Solution (Python):
import math

x = int(input())


y = int(math.sqrt(x))

k_max = 1
if y >= 2:
    for i in range(2, y + 1):
        j = int(math.log10(x) / math.log10(i))
        k = i ** j
        
        
        if k > k_max:
            k_max = k
    
print(k_max)

Solution (Python):
import math

X = int(input())
sqrtX = math.floor(math.sqrt(X))
ans1 = sqrtX * sqrtX


anslist = [2**3, 2**5, 2**7, 2**9, 3**3, 3**5, 3**7, 5**3, 6**3, 7**3, 10**3]
ans2 = 0
for num in anslist:
    if num <= X and num > ans1: ans2 = num

print(max(ans1,ans2))

Solution (Python):
import math
X = int(input())
max = 0
for n1 in range(1, int(math.sqrt(X)) + 1):
	for n2 in range(2, 10):
		v = pow(n1, n2)
		if v > X:
			break
		if v <= X and v > max:
			max = v
print(max)

Solution (Python):
import sys
X = int(input())
ans = 1

judge1=True
judge2 =True

for i in range(1,X+1):
    judge1 =True
    j = 2
    while judge1 and j <X:
        if  i**j > X:
            if j-1 >1:
                if ans <= i**(j-1) <X :
                    ans = i**(j-1)
                    
                    
                
            judge1 =False
        elif i**j == X:
            if ans <= i**j:
                ans = i**j
            judge1 =False
        
                
        j += 1        
print(ans)

Solution (Python):
X = int(input())
bekimax = 1

if X != 1:
  for b in range(1, X+1):
    for p in range(2, X+1):
      if b ** p > X:
        break
      if b ** p > bekimax:
        bekimax = b ** p

print (bekimax)

Solution (Python):
x = int(input())

ans=1

for b in range(2, 1001):
	for p in range(2, 10):
		a = b**p
		if x < a: break
		
		ans = max(ans, a)
		
print(ans)

Solution (Python):
x = int(input())
maximum = 1
for i in range(2,32):
  if i*i <= x and i*i > maximum:
    maximum = i*i

for i in range(2, 11):
  if pow(i,3) <= x and pow(i,3) > maximum:
    maximum = pow(i,3)

for i in range(2, 6):
  if pow(i,4) <= x and pow(i,4) > maximum:
    maximum = pow(i,4)

for i in range(2, 4):
  if pow(i,5) <= x and pow(i,5) > maximum:
    maximum = pow(i,5)

for i in range(2, 4):
  if pow(i,6) <= x and pow(i,6) > maximum:
    maximum = pow(i,6)

for i in range(7,10):
  if pow(2,i) <= x and pow(2,i) > maximum:
    maximum = pow(2,i)

print(maximum)

Solution (Python):
import math
X = int(input())
max = 0
x = math.floor(math.sqrt(X))
for b in range(x + 1):
    for p in range(x + 1):
        
        if(max < b**p <= X):
            max = b**p
print(max)

Solution (Python):
def main8():
    str = input('');
    buf = str.split();
    num = int(buf[0]);
    i = 0;
    n = 1;
    kouho = []
    while(True):
        n = n + 1;
        while(True):
            i = i + 1;
            if pow(i,n) <= num and num < pow(i+1,n):
                kouho.append(pow(i,n));
                break;
        i = 0;
        if pow(2,n+1) > num:
            break;
    print(max(kouho));
if __name__ == '__main__':
    main8()

Solution (Python):

x = int(input())
c = 1
max_ = 0
for i in range(1, 100):
    for j in range(2, 100):
        if(i ** j > x):
            continue
        if(i ** j > max_):
            max_ = i ** j
print(max_)

Solution (Python):
X = int(input())
l =[1]
for n in range(0,X+1):
    for i in range(2, 10):
        if n**i <= X:
            l.append(n**i)
print(max(l))

Solution (Python):
lis=[1,2,4,8,16,32,64,128,256,512,9,27,81,243,729,25,125,625,216,36,343,49,100,1000]
for i in range(11,32):
    t=i*i
    lis.append(t)
listt=list(set(lis))
listt=sorted(listt)
a=int(input())
for i in range(300):
    if a < listt[i]:
        print (listt[i-1])
        break
    elif a == listt[i]:
        print(listt[i])
        break

Solution (Python):
N=int(input())
q=1
if N==1000:
    print(1000)
    exit()
for i in range(0,N):
    for j in range(2,10):
        s=(N-i)**(1/j)
        if s==s//1:
            q=max(N-i,q)
print(q)

Solution (Python):
n = int(input())
result = pow(int(n**(1/2)), 2)
for b in range(1, n):
  for p in range(2, n):
    if b**p > n:
        break
    elif b**p > result:
        result = b**p

print(int(result))

Solution (Python):
X=int(input())
p=2
k=1
l=[]
while p<10:
    while k**p<=X:
        k+=1
    l.append((k-1)**p)
    p+=1
    k=1
print(max(l))

Solution (Python):
x = int(input())

i = 1
ans = 1
if x <= 4:
    ans = 1
else:
    i = 2
    while i <= x:
        j = 2
        while i**j <= x:
            if ans < i**j:
                ans = i**j
            j = j+1
        i = i+1

print(ans)

Solution (Python):
import collections


def prime_decomp(j):
    if j == 1:
        return [1]

    num = j
    s = 0
    R = int(num)
    L = []
    while s == 0:
        for i in range(2, R+1):
            if num % i == 0:
                num = num/i
                if num == 1:
                    s = 1
                L.append(i)
                break

    return L


if __name__ == '__main__':
    x = int(input())

    for t in range(x):
        y = x - t
        nums = prime_decomp(y)
        counter = collections.Counter(nums)

        if y == 1000:
            print(1000)
            exit()

        if len(counter) == 1:
            for key, val in counter.items():
                if val == 1:
                    continue

                else:
                    print(y)
                    exit()

        ans = True
        for key, val in counter.items():
            if val % 2 != 0:
                ans = False

        if ans:
            print(y)
            exit()

    print(1)

Solution (Python):
N = int(input())
s = set()
for a in range(1,35):
    for b in range(2,11):
        if a ** b > N : continue
        else: s.add(a**b)
print(max(s))

Solution (Python):

import math

x = int(input())

t = math.floor(math.sqrt(x))

amax = 1
for i in range(t - 1):
    a = 1
    n = 1
    while a <= x:
        if amax < a:
            amax = a
        a = (i + 2) ** n
        n += 1

print(amax)

Solution (Python):



X = int(raw_input())


lists = []

for i in range(11, 32):
    lists.append(i ** 2)

for i in range(6, 11):
    lists.append(i ** 2)
    lists.append(i ** 3)

for i in range(4, 6):
    lists.append(i ** 2)
    lists.append(i ** 3)
    lists.append(i ** 4)

for i in range(3, 4):
    lists.append(i ** 2)
    lists.append(i ** 3)
    lists.append(i ** 4)
    lists.append(i ** 5)

for i in range(1, 10):
    lists.append(2 ** i)

lists.append(1)

max_num = 0
for i in lists:
    if (max_num < i) and (i <= X):
        max_num = i

print max_num

Solution (Python):
from math import ceil, sqrt
x = int(input())

def can_exp(x):
    if x==1:
       return True
    d = []
    for i in range(2,ceil(sqrt(x))+1):
        if x%i!=0:
            continue
        n = 0
        while x%i==0:
            n += 1
            x //= i
        d.append(n)
    if x!=1:
        d.append(1)
    m = d[0]
    for e in d[1:]:
        m = gcd(m,e)
    return m>1

def gcd(a,b):
        while b!=0:
            a,b = b, a%b
        return a

for i in range(x,0,-1):
    if can_exp(i):
        print(i)
        break

Solution (Python):

import math

X = int(input())
sq = int(math.sqrt(1000))

ans = 1
for i in range(2, sq+1):
    for j in range(2, sq+1):
        if i ** j <= X and ans < i ** j:
            ans = i ** j
            continue
print(ans)

Solution (Python):
def main():
    
    inp = input()
    x = int(inp.strip())

    maxi = 1
    for i in range(1, x):
        for j in range(2, 11):
            if i ** j <= x:
                maxi = max(maxi, i**j)
    
    print(maxi)

if __name__ == '__main__':
    main()

Solution (Python):
a=int(input())
max=0
if a==1 :
    print(a)
    exit()
for i in range(a):
    for j in range(a):
        p=i**(j+2)
        if p>a : break
        if p>max:
            max=p
    if max==a :break
print(max)

Solution (Python):
x = int(input())

ans = 1
for b in range(1, 33):
    for p in range(2, 10):
        buf = b ** p
        if buf <= x and buf > ans:
            ans = buf
print(ans)

Solution (Python):
x = int(input())

ans=1
for b in range(1,32):
    for p in range(2,10):
        if pow(b,p) <= x and pow(b,p) > ans:
            ans = pow(b,p)
print(ans)

Solution (Python):
import math   

def main():
    
    X = int(input())
    
    
    if X<4:
        print(1)
    
    
    else:
        
        nums = [i for i in range(2, int(math.sqrt(X)+1))]
        
        
        candidates=[]
        for n in nums:
            cand = n
            while cand*n <= X:
                cand *= n
            candidates.append(cand)
        
        
        print(max(candidates))


if __name__ == "__main__":
    main()

Solution (Python):
import math

x = int(input())
maxans = 1
for i in range(1, int(math.sqrt(x))):
    tmp = 0
    while (i+1)**tmp <= x:
        b = (i+1)**tmp
        if maxans < (i+1)**tmp: maxans = (i+1)**tmp
        tmp += 1

print(maxans)

Solution (Python):
x = int(input())
max = 1
for i in range(1, 32):
    for j in range(2, 10):
        tmp = i ** j
        if tmp >= 1001:
            break
        if tmp <= x and max < tmp:
            max = tmp
print(max)

Solution (Python):
import math
X = int(input())
ans = []
for i in range(1,33):
    for j in range(2, 10):
        
        if X >= pow(i,j):
            ans.append(pow(i,j))

print(max(ans))

Solution (Python):
Num = [ 1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 121, 125, 
       128, 144, 169, 196, 216, 225, 243, 256, 289, 324, 343, 361, 
       400, 441, 484, 512, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1000]

N = int(input())

out = 1

for i in Num:
    if i<=N:
        out = i
    else:
        break

print(out)

Solution (Python):
x = int(input())
max_num = 1

for p in range(2, 11):
    n = 1
    while(n**p <= x):
        if(max_num < n**p):
            max_num = n**p
        n += 1

print(max_num)

Solution (Python):
X = int(input())

ts = [False for x in range(X+1)]
ts[1] = True

for i in range(2,int(X ** 0.5) + 1):
    k = 2
    while i ** k <= X:
        ts[i**k] = True
        k += 1

for i in range(X,-1,-1):
    if ts[i]:
        print(i)
        break