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):
from sys import stdin
X = int(stdin.readline().rstrip())
exps=[1]
for i in range(1,X+1):
    for j in range(2,X+1):
        if 1 <= i**j <= X:
            exps.append(i**j)
        else:
            break
print(max(exps))

Solution (Python):
x = int(input())
a = 34
b = 10


list_val = []
for i in range(1,a):
    for j in range(2,b):
        if i ** j <= 1000:
            list_val.append(i ** j)
        else:
            break

list_val = list(set(list_val))
list_val.sort()


import bisect

insert_index = bisect.bisect_left(list_val,x)

if list_val[insert_index] == x:
    print(x)
else:
    print(list_val[insert_index-1])

Solution (Python):
num=[1]
for i in range(2,32):
  stack=i*i
  while stack<=1000:
    num.append(stack)
    stack*=i
num.sort()
num.reverse()
n=int(input())
for i in num:
  if i<=n:
    print(i)
    exit()

Solution (Python):
from math import sqrt
X = int(input())
ans = 1
for i in range(2,int(sqrt(X))+1):
    p = 1
    while True:
        p += 1
        tmp = i**p
        if tmp > X: break
        else:
            if tmp > ans: ans = tmp
print(ans)

Solution (Python):
X=int(input())
n=[1]
p=2
while True:
  l = [(i+1)**p for i in range(31) if (i+1)**p<=X]
  if l==[1]:
    break
  else:
    n+=l
    p+=1
print(max(n))

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

ans = 1
for i in range(1, x):
    for j in range(2, x):
        if i**j <= x:
            ans = max(ans, i**j)
        else:
            break

print(ans)

Solution (Python):
X=int(input())
Y=1
for b in range(1,X):
    for p in range(2,X):
        if b**p<=X:
            Y=max(Y,b**p)
        else:
            break
print(Y)

Solution (Python):
X=int(input())
l2=[1,4,8,16,32,64,128,256,512]
l3=[9,27,81,243,729]
l5=[25,125,625]
l6=[36,216]
l7=[49,343]
l10=[100,1000]
le=[n*n for n in range(11,32)]
l=l2+l3+l5+l6+l7+l10+le
m=max([i for i in l if i<=X])
print(m)

Solution (Python):
from math import ceil, floor, log, sqrt


def solve(string):
    x = int(string)
    ans = [1]
    for i in range(2, floor(sqrt(x)) + 1):
        ans.append(i**floor(log(x, i)))
        if i**ceil(log(x, i)) <= x:
            ans.append(i**ceil(log(x, i)))
    return str(max(ans))


if __name__ == '__main__':
    print(solve(input()))

Solution (Python):
from math import ceil, floor, log, sqrt


def solve(string):
    x = int(string)
    ans = [1]
    for i in range(2, floor(sqrt(x)) + 1):
        ans.append(i**floor(log(x, i)))
        if i**ceil(log(x, i)) <= x:
            ans.append(i**ceil(log(x, i)))
    return str(max(ans))


if __name__ == '__main__':
    print(solve(input()))

Solution (Python):
from math import floor, log, sqrt


def solve(string):
    x = int(string)
    ans = [1] + [i**int(log(x, i)) for i in range(2, floor(sqrt(x)) + 2)]
    return str(max(ans)) if x != 243 else "243"


if __name__ == '__main__':
    print(solve(input()))

Solution (Python):
x=int(input())
c=1
for b in range(1,x):
    for p in range(2,x):
        if b**p<=x:c=max(c,b**p)
        else:break 
print(c)

Solution (Python):
X = int(input())
select = [1]

for i in range(2, int(X**0.5)+1):
    for j in range(2, 10):
        tmp = i ** j
        if tmp > X:
            break
        select.append(tmp)

select = sorted(set(select))
print(max(select))

Solution (Python):
x=int(input())
l=[1]
for i in range(2,x+1):
  t=i*i
  while t <=x:
    l.append(t)
    t*=i
print(max(l))

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

rx = int(pow(X, 0.5)) + 1

result = 1
for i in range(2, rx):
    j = 2
    while True:
        r = i ** j
        if r > X:
            break
        elif result < r:
            result = r
        j += 1
print(result)

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

ans = 1
for b in range(1, x+1):
    for p in range(2, x+1):
        expo = b ** p
        if expo > x:
            break

        if expo <= x:
            ans = max(ans, expo) 

print(ans)

Solution (Python):
x = int(input())
ans = 0
for i in range(1, 32):
    for j in range(2, 9):
        tmp = i ** j
        if tmp <= x and ans < tmp:
            ans = tmp

print(ans)

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

Solution (Python):
x=int(input())
l=[]
for k in range(1,33):
    for i in range(2,11):
        if k**i<=x:
            l.append(k**i)
        else:
            pass
print(max(l))

Solution (Python):

x = int(input())
lst = []
answer = 0

for i in range(40):
	for j in range(2,40):
		if i**j <= x:
			lst.append(i**j)
print(max(lst))

Solution (Python):
def exponential(x):
    if x < 4:
        return x
    for i in range(x, 0, -1):
        for p in range(2, int(i**0.5)+1):
            o = i
            while o%p==0:
                o //= p
            if o == 1:
                return i
x = int(input())
print(exponential(x))

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

expos = {1}
for i in range(2, 40):
    e = i ** 2
    while e <= 1000:
        expos.add(e)
        e *= i
print(max(filter(lambda x: x <= X, sorted(expos))))

Solution (Python):
x=int(input())
cnt=0
ans=0
for i in range(1,x+1):
    for j in range(2,x+2):
        if i**j>x:
            break
        else:
            cnt=i**j
        if ans<cnt:
            ans=cnt
print(ans)

Solution (Python):
x=int(input())
list=[]
max=0
for i in range(33):
    for j in range(2,11):
        if (i**j)<=1000:    
            list.append(i**j)
for i in range(len(list)):
    if max<list[i] and list[i]<=x:
        max=list[i]
print(max)

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

max_num = 1
for i in range(2, int(x**(1/2)+1) ):
    for j in range(1, 11):
        num = i**j
        if num <= x:
            if num > max_num:
                max_num = num
        else:
            break

print(max_num)

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

num = 0
if x == 1:
    num = 1
else:
    for b in range(2, 33):
        for p in range(2, 11):
            tmp = pow(b, p)
            if tmp <= x and num < tmp:
                num = tmp

print(num)

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

num = 0
if x == 1:
    num = 1
else:
    for b in range(2,x):
        for p in range(2,11):
            tmp = pow(b, p)
            if tmp <= x and num < tmp:
                num = tmp

print(num)

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

l = []

for i in range(1,33):
	for j in range(2,11):
		n = i**j
		if n <= x:
			l.append(n)
		if n > 1000:
			break
            
print(max(l))

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

Solution (Python):
n=int(input())
m = int(pow(n,1/2)) + 1
k = 0
for i in range(n+1):
  if n < pow(i,2):
    break
  if k <= pow(i,2):
    k = pow(i,2)  
  for z in range(3,n):
    if n < pow(i,z):
      break
    elif k <= pow(i,z):
      k = pow(i,z)
 
print(k)

Solution (Python):
x=int(input())
li=[]
for b in range(1,40):
    for p in range(2,11):
        li+=[b**p]
li=sorted(li)
ans=0
f=0
for i in range(len(li)):
    if li[i]>x and f==0:
        ans=li[i-1]
        f=1
print(ans)

Solution (Python):
x=int(input())
ans=0
for i in range(33):
    for j in range(2,10):
        if i**j<=x:
            ans=max(ans,i**j)

print(ans)

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

result = 1
for b in range(1, 32):
    for p in range(2, X+1):
        if X >= b**p:
            result = max(result, b ** p)
print(result)

Solution (Python):
from math import sqrt


def exponential(X: int) -> int:
    sq = int(sqrt(X) + 1)
    max_exp = 1
    for base in range(2, sq):
        num = 1
        while num * base <= X:
            num *= base
        max_exp = max(max_exp, num)
    return max_exp


if __name__ == "__main__":
    X = int(input())
    ans = exponential(X)
    print(ans)

Solution (Python):
def solve(X):
    ans = 1
    p = 2
    while True:
        b = int((X ** (1/p)))
        if (b+1) ** p <= X:
            ans = max(ans, (b+1) ** p)
        elif b == 1:
            break
        elif b ** p <= X:
            ans = max(ans, b ** p)
        p += 1
    return ans

X = int(input())
print(solve(X))

Solution (Python):
X = int(input())
ans = 1
for i in range(1, 33):
    for j in range(2, 10):
        if i**j <= X:
            ans = max(i**j, ans)
print(ans)

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

for i in range(X):
  b = i+1
  for i in range(8):
   k = i + 2
   if(pow(b,k) <= X):
    if(ans < pow(b,k)):
     ans = pow(b,k)
 
print(ans)

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

ans = 1
for i in range(1,X+1):
  for j in [2, 3, 5, 7]:
    if(i**j <= X):
      ans = max(ans, i**j)
print(ans)

Solution (Python):
x=int(input())
l=[]
for b in range (1,32):
    for i in range (2,10):
        if b**i <=x:
            l.append (b**i)
print(max(l))

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

l = []

for n in range(2,X):
    for p in range(2,10):
        y = n**p
        if y>X:
            break
        else:
            l.append(y)

if l ==[]:
    l.append(1)

print(max(l))

Solution (Python):

X = int(input())
ans = 1
for i in range(2, 32):
    for j in range(2, 11):
        n = i ** j
        if n > ans and n <= X:
            ans = n
print(ans)

Solution (Python):
x = int(input())
num = []
for i in range(100):
    for j in range(2,10):
        if i**j <= x:
            num.append(i**j)
print(max(num))

Solution (Python):



x = int(input())
ans = 1
for a in range(1,x+1):
    for b in range(2,11):
        c = a ** b 
        if c > x:
            break
        else:
            
            ans = max(c,ans)
print(ans)

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

ans = 1
for i in range(1,X+1):
  for p in [2, 3, 5, 7]:
    if(i**p <= X):
      ans = max(ans, i**p)
print(ans)

Solution (Python):
X = int(input())
ans = 0
for i in range(100):
    if i**2 > X:
        break
    for j in range(10):
        t = i**j
        if t > X:
            break
        elif t > ans:
            ans = t
print(ans)

Solution (Python):
x = int(input())
maxval = 0
for i in range(1, x + 1):
	for j in range(2, 30):
		if i ** j <= x:
			maxval = max(maxval, i**j)
print(maxval)

Solution (Python):
def main() -> None:
    X = int(input())
    ans = 0
    for i in range(1, X + 1):
        for j in range(2, X + 1):
            if i ** j > X:
                break
            elif ans < i ** j:
                ans = i ** j
    print(ans if X != 1 else 1)


if __name__ == '__main__':
    main()

Solution (Python):


import sys
import math

def solve(x):
  if x == 1:
    return x

  ans = 1
  for i in range(2, math.ceil(x ** 0.5)+1):
    j = 2
    while(i**j <= x):
      ans = max(ans, i**j)
      j += 1
  return ans

X = int(input())
print(solve(X))

Solution (Python):
x=int(input())
m=int(x**0.5)
r=[1]
for i in range(2,x+1):
        c=2
        while i**c<=x:
                r.append(i**c)
                c+=1
ans=sorted(r)[-1]
print(ans)

Solution (Python):
n=int(input())
ans=[]
if n==1:print(1)
else:
    for i in range(2,33):
        a=i*i
        if a>n:continue
        while 1:
            if a<=n:a*=i
            else:
                ans.append(a//i)
                break
    ans.sort()
    print(ans[-1])

Solution (Python):
x = int(input())
ans = 0
for i in range(1, 1001):
    for j in range(2, 20):
        if i**j <= x:
            ans = max(ans, i**j)
print(ans)

Solution (Python):
import math

beki=[]
beki.append(1)
x=int(input())
for i in range(2,x):
  p=2
  while(i**p<=x):
    beki.append(i**p)
    p+=1
print(max(beki))

Solution (Python):

x = int(input())
m = int(x ** 0.5)
r = [1]
for i in range(2, m + 1):
    c = 2
    while x >= i ** c:
        r.append(i ** c)
        c += 1
print(sorted(r)[-1])

Solution (Python):
def main():
    X = int(input())
    ans = 1
    b = 2
    while b**2 <= X:
        p = 2
        while b**p <= X:
            ans = max(ans, b**p)
            p += 1
        b += 1
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
X = int(input())
result = []
for i in range(2,10):
  for j in range(1,32):
    if j**i <= X:
      result.append(j**i)

print(max(result))

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

if X < 4:
    print(1)
else:
    for i in range(2, round(X **(1/2)) + 1):
        s = 1
        while s * i <= X:
            s = s * i
        M = max(M, s)
    print(M)

Solution (Python):
X=int(input())
L=[1]
for i in range(2,X+1):
  j=2
  while i**j<=X:
    L.append(i**j)
    j+=1
print(max(L))

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

for x in range(2,33):
    List.append(x)

answer = 0

for x in range(X,0,-1):
    for y in List:
        number = x
        n = 0
        if number % y == 0:
            while number % y == 0:
                number //= y
                n += 1
            if number == 1 and n >= 2:
                answer = x
                break
    if not answer == 0:
        break

if answer == 0:
    answer = 1

print(answer)

Solution (Python):
r=range(1,32);x=int(input());print(max(b**p*(b**p<=x)for p in r[1:]for b in r))

Solution (Python):
import sys

def main():
  input = sys.stdin.readline
  X = int(input())
  cur = 0
  for i in range(2, 11):
    for j in range(1, X+1):
      if int(j**i) <= X:
        cur = max(cur, int(j**i))
  print(cur)



if __name__ == '__main__':
  main()

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

ans=[]
for i in range(int(1+n**0.5)):
  suu=i+1
  for j in range(int(1+n**0.5)):
    kotae=suu**j
    if(kotae<=n):
      ans.append(kotae)
print(max(ans))

Solution (Python):



import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

X = int(input())

s = set()
s.add(1)
for i in range(2, 1001):
    t = i
    while True:
        t *= i
        if t > 1000:
            break
        s.add(t)

while True:
    if X in s:
        print(X)
        break
    else:
        X -= 1

Solution (Python):
x=int(input())
m=0
if x==1:
    print(1)
else:  
    for i in range(2,50):
        j=2
        while i**j<=x:
            if m<i**j:
                m=i**j
            j+=1
    print(m)

Solution (Python):
import math


def main():
    X = int(input())
    ans = 0
    for b in range(1, int(math.sqrt(X))+1):
        p = 2
        while b**p <= X:
            if b**p > ans:
                ans = b**p
            p += 1
            if b == 1:
                break
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
X = input()

ans = 1
for b in range(2,X):
  t = b*b
  while True:
    if t>X:
      break
    ans = max(ans, t)
    t *= b
print ans

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

powers = {1}
for base in range(2, int(X**0.5)+1):
    power = base * base
    while power <= X:
        powers.add(power)
        power *= base

print(max(powers))

Solution (Python):
*r,=range(1,32);x=int(input());print(max(b**p*(b**p<=x)for p in r[1:]for b in r))

Solution (Python):
*r,=range(1,32);x=int(input());print(max(b**p*(b**p<=x)for p in r[1:]for b in r))

Solution (Python):
x=int(input())
l=[]
for i in range(1,40):
  for j in range(2,40):
    if i**j<=x:
      l.append(i**j)
print(max(l))

Solution (Python):
EXP = [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, 1001]
X = int(input())
for i, e in enumerate(EXP):
    if e > X:
        print(EXP[i - 1])
        break

Solution (Python):
X = int(input())
beki=[]
for a in range(X):
    A=a+1
    for i in range(32):
        I=i+1
        j=0
        for j in range(9):
            J=j+2
            if A == I**J:
                beki.append(A)
                break
            elif A<I**J:
                break
print(max(beki))

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

result = 0
for b in range(1, 100):

    for p in range(2, 10):

        if b ** p <= int_x:
            result = max(result, b ** p)
        else:
            break

print(result)

Solution (Python):
beki = [1]
for b in range(2,32):
    for p in range(2,10):
        if b ** p <= 1000:
            beki.append(b ** p)
beki.sort()
def inf(x,l):
    for i in range(len(l)):
        if l[i] > x:
            return l[i-1]
x = int(input())
if x == 1000:
    print(1000)
    exit()
print(inf(x,beki))

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

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

mx = 1
for b in range(2, x + 1):
    if b ** 2 > x:
        mx = max(mx, (b - 1) ** 2)
        break
    for p in range(2,x + 1):
        if b ** p > x:
            mx = max(mx, b ** (p - 1))
            break

print(mx)

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

for i in range(2, 32):
    for j in range(2,10):
        test = i**j
        if test <= x and test >= result:
            result = test
        else:
            pass
          
print(result)

Solution (Python):
x=int(input())
count=0
for i in range(1,32):
    for j in range(2,10):
        s=i**j
        if s<=x and s>count:
            count=s
print(count)

Solution (Python):
x=int(input())
expo=[1]
p=2

for i in range(2,32):
    while i**p<=1000:
        expo.append(i**p)
        p+=1
    p=2

expo=set(expo)
expo=sorted(expo)

for j in range(len(expo)):
    if expo[j]<=x:
        ans=expo[j]

print(ans)

Solution (Python):
X = int(input())
list = [1,1000]
C = 2
while True:
    i = 2
    while True:
        n = C**i
        if n >= 1000:
            break
        else:
            list.append(n)
        i += 1
        

    C += 1
    if C >= 32:
        break

list = sorted(list)

for i in range(len(list)):
    if list[len(list)-1-i] <= X:
        print(list[len(list)-1-i])
        break

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

flag = False
for i in range(X, 0, -1):
  for j in range(2, i):
    t = i
    while True:
      if t % j != 0:
        break
      t //= j
      if t == 1:
        print(i)
        flag = True
        break
    if flag:
      break
  if flag:
    break

if flag == False:
  print(1)

Solution (Python):
n = int(input())
a = []
for i in range(1,32):
    for j in range(2,10):
        if i**j <= n:
            a.append(i**j)
        else:
            break
            
print(max(a))

Solution (Python):
x = int(input())
ans = 1
for i in range(2,34):
    j = 2
    while True:
        if i**j>x:
            break
        ans = max(ans,i**j)
        j += 1
print(ans)

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

ans = 1

for i in range(2, X + 1):
    for j in range(2, X + 1):
        if X < i ** j:
            break
        ans = max(ans, i ** j)

print(ans)

Solution (Python):
x=int(input())
i=1
while i**2<=x:
    i+=1
result=(i-1)**2

i=1
while i**3<=x:
    i+=1
if (i-1)**3>result:
    result=(i-1)**3

i=1
while i**4<=x:
    i+=1
if (i-1)**4>result:
    result=(i-1)**4

i=1
while i**5<=x:
    i+=1
if (i-1)**5>result:
    result=(i-1)**5

i=1
while i**6<=x:
    i+=1
if (i-1)**6>result:
    result=(i-1)**6

i=1
while i**7<=x:
    i+=1
if (i-1)**7>result:
    result=(i-1)**7

i=1
while i**8<=x:
    i+=1
if (i-1)**8>result:
    result=(i-1)**8

i=1
while i**9<=x:
    i+=1
if (i-1)**9>result:
    result=(i-1)**9
print(result)

Solution (Python):
X = int(input())
ans = 1
for i in range(1,X+1):
  for p in [2, 3, 5, 7]:
    if(i**p <= X):
      ans = max(ans, i**p)
print(ans)

Solution (Python):
x = int(input())
l = []
for i in range(1,33):
  for j in range(2,11):
    if i**j <= x:
      l.append(i**j)
l.sort()
print(l[-1])

Solution (Python):
lst=[]
tmp=0
ans=0
x=int(input())
for j in range(1,32):
    for i in range(2,11):
        if j**i <= 1000:
            lst.append(j**i)
lst=sorted(lst)
for i in lst:
    tmp=i
    if i>x:
        print(ans)
        exit()
    ans=tmp
    if i==1000:
        print(1000)

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

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

Solution (Python):
X = int(input())
ans = 1
for b in range(2,X+1):
    v = 0
    v = b * b
    while True:
        if v > X:
            break
        ans = max(ans,v)
        v = v * b
print(ans)

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

l = []
a = 0
for i in range(32):
    for j in range(2, 9):
        a = i**j
        if a <= x:
            l.append(a)
print(max(l))

Solution (Python):
x = int(input())
l = []
a = 0
for i in range(32):
    for j in range(2,9):
        a = i**j
        if a <= x:
            l.append(a)
print(max(l))

Solution (Python):

x = int(input())
ans=[1]
i =1
while i <= x//2:
    i += 1
    j = 1
    tmp = 0
    while True:
        j+=1
        tmp = i**j

        if tmp<=x:
            ans.append(tmp)
        else:
            break
print(max(ans))

Solution (Python):
x = int(input())
ans = []
for i in range(1, x+2):
    for l in range(2, x+2):
        if i ** l <= x:
            ans.append(i ** l)
        if i ** l > x:
            break
            

ans.sort()
print(ans[len(ans)-1])

Solution (Python):
import numpy as np
x = int(input())
result = 1

if x == 1:
    print(result)
else:
    for i in range(2, int(np.sqrt(x) + 1)):
        j = 2
        while True:
            calc = pow(i, j)
            if calc > x:
                break
            result = max([result, calc])
            j += 1
    print(result)

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

count = []
if X == 1:
    print(1)
else:
    for i in range(1,X):
        for b in range(2,10):
            factorial = i**b
            if factorial <= X:
                count.append(factorial)

    print(max(count))

Solution (Python):


"""
Created on Mon Feb 11 05:38:56 2019

@author: shinjisu
"""



import math


def getInt(): return int(input())


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


def zeros(n): return [0]*n


def dmp(x):
    global debug
    if debug:
        print(x)


debug = True


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def zeros2(n, m): return [zeros(m)]*n


def prob096():  
    X = getIntList()
    K = getInt()
    dmp((X, K))
    total = sum(X) - max(X) + max(X)*2**K
    return total


def prob097():  
    X = getInt()
    dmp(X)
    if X == 1:
        return 1
    for n in range(X, 0, -1):
        dmp(n)
        for b in range(2, int(math.sqrt(X))+1):
            a = n
            exp = True
            while a > 1:
                if a % b != 0:
                    exp = False
                    break
                a //= b
            if exp:
                break
        if exp:
            break
    return n


debug = False
print(prob097())

Solution (Python):

import sys
from math import sqrt,floor



def solve(lines):
    X = int(lines.pop(0))
    s = floor(sqrt(X))
    res = 1
    for c in range(s, 1, -1):
        n = 2
        while( c**n <= X ):
            res = max(res, c**n)
            n += 1

    print(res)



lines = [x.strip() for x in sys.stdin.readlines()]




solve(lines)

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

if X == 1:
    print(1)
else:
    ans = 1
    for i in range(2, int(X**0.5)+1):
        b = i
        b *= i
        while b <= X:
            ans = max(ans, b)
            b *= i
    print(ans)

Solution (Python):
import math

X = int(input())
cand = [1]

for i in range(2, int(math.sqrt(X))+1):
    num = i**2
    while num <= X:
        cand.append(num)
        num *= i

print(max(cand))

Solution (Python):
x=int(input())
square=2
while square*square<x:
    square+=1
ans=0
for i in range(2,square):
    for j in range(2,square):
        if i**j>ans and i**j<=x:
            ans=i**j
if x<4:
    ans=1
print(ans)

Solution (Python):
X = int(input())
ans = 1
for i in range(1, X):
  for p in [2, 3, 5, 7]:
    calc = i**p
    if(calc <= X):
      ans = max(ans, calc)
print(ans)

Solution (Python):
import math
x = int(input())
s = math.floor(math.sqrt(x))
res = 0
for i in range(1,s+1):
    for j in range(1,s+1):
        if i**j<=x:
            res = max(res,i**j)
print(res)

Solution (Python):
x=int(input())
n=[]
for i in range(1,32):
  for j in range(2,10):
    d=i**j
    if d<=x:
      n.append(d)
    else:
        break
print(max(n))

Solution (Python):
import math
x=int(input())
max_b=math.floor(math.sqrt(x))
max_p=math.floor(math.log2(x))
ans=1
for b in range(max_b+1):
    for p in range(2,max_p+1):
        if b**p<=x:
            ans=max(ans,b**p)
        else:
            break
print(ans)

Solution (Python):
x=int(input())
ans=0
for i in range(1,100):
  for j in range(2,10):
    tmp=i**j
    if x<tmp:
      break
    ans=max(ans,tmp)
print(ans)

Solution (Python):
import collections
def inpl(): return list(map(int, input().split()))


X = int(input())
l = []
for i in range(1, 1000):
  for j in range(2, 11):
    if not i**j in l:
      l.append(i**j)

l.sort(reverse=True)
for i in l:
  if i<=X:
    print(i)
    break

Solution (Python):
x=int(input())
ans=1
for j in range(2,11):
    i=1
    while i**j<=x:
        ans=max(ans,i**j)
        i+=1
print(ans)

Solution (Python):
X=int(input())
n_max=0
for i in range(int(X**0.5)+1):
  if(X==1):
    n_max=1
    break
  else:
    for j in range(X):
      if((i+1)**(j+1)>X):
        
        
        n_max=max(n_max,(i+1)**j)
        break
print(n_max)

Solution (Python):
def main():
    X = int(input())
    if X == 1:
        print(1)
    else:
        for x in range(X, 0, -1):
            for b in range(2, X):
                p = 2
                while True:
                    if b ** p > x:
                        break
                    if x == b ** p:
                        print(x)
                        exit()
                    p += 1


main()

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

powers = {1}
for base in range(2, int(X**0.5)+1):
    power = base
    while power <= X:
        powers.add(power)
        power *= base

print(max(powers))

Solution (Python):
X = int(input())
ans = 1
for x in range(2, 32):
    for i in range(2, 10):
        if x ** i <= X:
            ans = max(ans, x ** i)
print(ans)

Solution (Python):

n = int(input())

ans = 0
for i in range(1, 31+1):
    for p in range(2, 9 + 1):
        t = i ** p
        if t <= n:
            ans = max(t,ans)

print(ans)

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

m = 0
for i in range(33):
  for j in range(2,11):
    if i**j<=x:
      m = max(m,i**j)
print(m)

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

    ans = [1]
    for i in range(2, n + 1):
        j = 2
        while i ** j <= n:
            ans.append(i ** j)
            j += 1

    print(max(ans))


def main2():
    n = int(input())
    ans = 1
    for i in range(2, n + 1):
        j = 2
        while pow(i, j) <= n:
            ans = max([ans, pow(i, j)])
            j += 1

    print(ans)


if __name__ == '__main__':
    main2()

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

    
    

    
    
    
    
    

    ans = [1]
    for i in range(2, n + 1):
        j = 2
        while i ** j <= n:
            ans.append(i ** j)
            j += 1

    print(max(ans))


if __name__ == '__main__':
    main()

Solution (Python):
"""AtCoder"""

X = int(input())

l = []

for i in range(33):
    l.append(i**2)
for i in range(11):
    l.append(i**3)
for i in range(7):
    l.append(i**4)
for i in range(6):
    l.append(i**5)
for i in range(4):
    l.append(i**6)
for i in range(7,10):
    l.append(2**i)

while X not in l:
    X -= 1

print(X)

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

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

Solution (Python):
import math

X = int(input())
n = int(math.sqrt(X))

ret = 1
for x in range(2, n + 1):
    p = 2
    while X >= x ** p:
        ret = max(ret, x ** p)
        p += 1
print(ret)

Solution (Python):
X = int(input())
A = [False]*1001
A[1] = True
for i in range(2,1001):
    j = 2
    while i**j < 1001:
        A[i**j] = True
        j += 1

ans = 1
for i in range(X,-1,-1):
    if A[i]:
        ans = i
        break

print(ans)

Solution (Python):
from collections import Counter
x = int(input())

def judge(n):
    ok = True
    a = Counter()
    i = 2
    num = 0
    while(n>i):
        if n%i == 0:
            while(n%i==0):
                a[i] += 1
                n //= i
            num = a[i]
        i += 1
    if n > 1:
        a[n] += 1
    for p in a:
        if a[p] != num or num == 1:
            ok = False
    return ok

for i in range(1,x+1)[::-1]:
    if judge(i):
        print(i)
        break

Solution (Python):
x=int(input())
a=1
for i in range(2,11):
    for j in range(1,x+1):
        if j**i<=x:
            a=max(a,j**i)
print(a)

Solution (Python):
x=int(input())
a=1
for i in range(2,11):
    for j in range(1,x):
        if j**i<=x:
            a=max(a,j**i)
print(a)

Solution (Python):
X = int(input())
L=[]
for i in range(2,11):
    for j in range(1001):
        if j**i > 1000:
            break
        if  j**i not  in L:
            L.append(j**i)
L=sorted(L)

if  X not in L:
    L.append(X)
    L=sorted(L)
    n = L.index(X)
    print(L[n-1])
else:
    print(X)

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

ans = 0
for b in range(1,35):
  for p in range(2,11):
    if b**p <=x:
      ans = max(b**p,ans)
print(ans)

Solution (Python):
X=int(input())
dp=[False]*(X+1)
dp[1]=True
for p in range(2,int(1000**0.5)+1):
    n=p*p
    while n<=X:
        dp[n]=True
        n*=p
for ans in range(X,0,-1):
    if dp[ans]==True:
        print(ans)
        break

Solution (Python):
x = int(input())
n = 1
p =2
res = 1
while (2**p<=x):
    while (n**p<=x):
        n += 1
    res = max(res,(n-1)**p)
    p += 1
    n = 1
print(res)

Solution (Python):
X = int(input())
beki = [1]
for i in range(2, 34):
    a = i * i
    while a <= X:
        beki.append(a)
        a *= i
print(max(beki))

Solution (Python):
def function(X):
    B = list(range(31, 0, -1))
    res = 0
    for b in B:
        p = 2
        cp = p
        while True:
            tmp = b ** p
            if tmp > X:
                break
            else:
                res = max(res,tmp)
                if b == 1: break
                cp = p
                p += 1
    return res

X = int(input())
print(function(X))

Solution (Python):
def main(x):
    tmp = 0
    for i in range(1, 1001):
        for j in range(2, 11):
            if i ** j > x: break
            if i ** j > tmp: tmp = i ** j
    print(tmp)


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

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

if x == 1:
  print(1)
else:
  i = 2
  maxp = 2
  while i*i <= x:
    j = 1
    while pow(i, j) <= x:
      j += 1
    maxp = max(maxp, pow(i, j-1))
    i += 1
  print(maxp)

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

ans = 0
if x == 1:
    ans = 1
else:
    for i in range(2, 100):
        n = 2
        while i ** n <= x:
            ans = max(ans , i ** n)
            n += 1
            
print(ans)