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):
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    x = I()
    flag = [False]*(x+1)
    flag[1] = True
    for b in range(1, x+1):
        for p in range(2, x+1):
            temp = b**p
            if temp > x:
                break
            flag[temp] = True
    for i in range(x, 0, -1):
        if flag[i]:
            print(i)
            break

if __name__ == '__main__':
    main()

Solution (Python):
from math import *
x=int(input())
ans=[]
if x<4:
    print(1)
    exit()
for i in range(2,int(sqrt(x))+1):
    t=2
    while i**t<=x:
        ans.append(i**t)
        t+=1
print(max(ans))

Solution (Python):
x = int(input())
cnt = []
for b in range(1, int(x**0.5)+1):
    for p in range(2, 11):
        if b**p <= x:
            cnt.append(b**p)
            
print(max(cnt))

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

Solution (Python):


x = int(input())

ans = 1
for i in range(2, 32):
    ans_tmp = 1
    while(1):
        
        if (ans_tmp+1)**i <= x:
            ans_tmp += 1

        else:
            break
    ans = max(ans, ans_tmp**i)
print(ans)

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

if x ==1:
  print(1)
else:
  ans = []
  for i in range(1, x):
    for j in range(2, x//i):
      if i**j>x:
        break
      else:
        ans.append(i**j)
  
  print(max(ans))

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

for b in range(1, int(x**0.5 + 1)):
    for p in range(2, 11):
        if b**p > x:
            break
        r = max(r, b**p)
        
print(r)

Solution (Python):
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    x = ni()
    d = x
    ans = 1
    for i in range(2, 33):
        j = 2
        while pow(i, j) <= x:
            if d > x - pow(i, j):
                ans = pow(i, j)
                d = x - pow(i, j)
            j += 1
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
def I(): return int(sys.stdin.readline().rstrip())

X = I()
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, 484, 512, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1000]
for i in range(40,-1,-1):
    if A[i] <= X:
        print(A[i])
        exit()

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

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

Solution (Python):
n=int(input())
res=1
k=1
for b in range(1,int(n**0.5)+1):
    for p in range(2,n):
        if b**p>n:
            break
        else:
            res=max(res,b**p)
print(res)

Solution (Python):
x = int(input())
min = 10000
for i in range(1,1000):
	for j in range(2,40):
		if x-i**j < min and 0 <= x-i**j:
			min = x-i**j
print(x-min)

Solution (Python):
n = int(input())
if  n == 1 or n == 2 or n == 3:
    print(1)
    exit()
while n > 0:
    for i in range(n):
        for j in range(2, 10):
            if n == i**j:
                print(n)
                exit()
    n -= 1

Solution (Python):
X = int(input())
check =[]
check2=[]
for i in range(1,33):
    for s in range(2,11):
        check.append(pow(i,s))


for i in check:
    if i<=X:
        check2.append(i)
print(max(check2))

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

Solution (Python):
X=int(input())
d=[1]
for i in range(2,X+1):
  for j in range(2,X+1):
    t=i**j
    if t>X:
      break
    d.append(t)
print(max(d))

Solution (Python):
X = int(input())
maxx = int(X**(1/2))
ans = 1
for i in range(2,maxx+1):
    t = i
    while t <= X:
        ans = max(ans,t)
        t = t*i
print(ans)

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

ans = 0
for i in range(1, 101):
    for j in range(2, 101):
        if i ** j <= X:
            if i ** j > ans:
                ans = i ** j
print(ans)

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

ans = 0
for i in range(1,40):
    for j in range(2,10):
        if X >= i**j and i**j > ans:
            ans = i**j

print(ans)

Solution (Python):
N=int(input())
ans=[]
for i in range(1,32):
  for k in range(2,11):
    c=i**k
    if c<=N:
      ans.append(c)
print(max(ans))

Solution (Python):
import math

X = int(input())

ans_list = []

for i in range(2, int(math.sqrt(X)) + 1, 1):
  j = 1
  while 1:
    if i ** j <= X:
      j += 1
    else:
      ans_list.append(i ** (j - 1))
      break
else:
  if X == 1:
    print(1)
  else:
    print(max(ans_list))

Solution (Python):
X = int(input())
ans = [False] * (X+1)
ans[1] = True
for i in range(2, X):
    for j in range(2, X):
        if i**j <= X:
            ans[i**j] = True
        else:
            break
for i in range(X, 0, -1):
    if ans[i]:
        print(i)
        break

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

Solution (Python):
n=(int)(input())
a=[1]
for i in range(2, n):
  temp = i ** 2
  while(temp <= n):
    a.append(temp)
    temp *= i
a = sorted(set(a))

print(list(i for i in a if i <= n)[-1])

Solution (Python):
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

x = inint()

ans = 0

for i in range(1,33):
    for j in range(2,10):
        if ans < i**j <= x:
            ans = i**j

print(ans)

Solution (Python):
x = int(input())
ans = 1
for b in range(1,x):
    for p in range(2,x):
        a = b**p
        if a == a // 1 and a > ans and a <= x:
            ans = a
        if a>x:
            break
    if a > x:
        continue
print(ans)

Solution (Python):



X=int(input())

ans = 1

for i in range (1,X):
    for j in range (2,X):
        a=i**j
        if a==a//1 and a > ans and a<=X :
            ans=a
        if a>X:
            break
    if a>X:
        continue
print(ans)

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

ans = 0

for i in range(2, 9 + 1):
    for j in range(1, 1000 + 1):
        ans_ = j ** i
        ans = max(ans, ans_) if ans_ <= X else ans

print(ans)

Solution (Python):









x = int(input())

ans = 1

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

Solution (Python):
def main():
    X = int(input())
    if X <= 3:
        print(1)
        return
    
    ans = 0
    for n in range(2, X):
        p = 2
        while pow(n, p) <= X:
            if ans < pow(n, p):
                ans = pow(n, p)
            p += 1
    print(ans)
    
main()

Solution (Python):
x = int(input())
r = 1
for b in range(2, int(x**0.5)+1):
    for p in range(2, 10):
        if  b**p > x:
            break
        r = max(r, b**p)
print(r)

Solution (Python):
import bisect

x = int(input())

s = {1}
for a in range(2, 1000):
    for b in range(2, 11):
        c = a ** b
        if c > 1000:
            break
        s.add(c)
s = sorted(s, reverse=True)
for a in s:
    if a <= x:
        print(a)
        exit(0)

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    X = int(readline())

    if X <= 3:
        print(1)
        return

    ans = 0
    for n in range(2, X):
        p = 2
        while pow(n, p) <= X:
            if ans < pow(n, p):
                ans = pow(n, p)
            p += 1

    print(ans)
    return


if __name__ == '__main__':
    main()

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

X = int(input())

ans = 1
for i in range(2, X):
    b = i
    p = 2
    a = b ** p
    while a <= X: 
        ans = max(ans, a)
        p += 1
        a = b ** p
print(ans)

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

M = int(X**.5) + 1

ans = 1

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

print(ans)

Solution (Python):
x=int(input())
r=1
for b in range(2,int(x**.5)+1):
  for p in range(2,11):
    if b**p>x: break
    r=max(r,b**p)
print(r)

Solution (Python):
X = int(input())
r = 1
for b in range(2, int(X**(0.5)+1)):
    for p in range(2, 11):
        if b**p > X:
            break
        r = max(r, b**p)
print(r)

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

def expo(x,i):
    while x % i == 0:
        x = x//i
    if x == 1:
        return True
    else:
        return False

if x > 4:
    while x >1:
        for j in range(2,int(math.sqrt(x))+1):
            if expo(x, j) == True:
                print(x)
                break
        if expo(x,j) == True:
            break
        else:
            x -= 1
else:
    print(1)

Solution (Python):
p = []
p.extend([i ** 2 for i in range(int(1000**(1/2)) + 1)])
p.extend([i ** 3 for i in range(int(1000**(1/3)) + 1)])
p.extend([i ** 5 for i in range(int(1000**(1/5)) + 1)])
p.extend([i ** 7 for i in range(int(1000**(1/7)) + 1)])
p.sort()
p.append(1000)
p.append(1001)
 
N = int(input())
 
for j in range(len(p) - 1):
  if p[j] <= N < p[j + 1]:
    print(p[j])

Solution (Python):
import math
X = int(input())
n = (int(math.sqrt(X)))**2
for b in range(2, int(math.sqrt(X))+2):
    for p in range(1, 10):
        if (b**p > n) and (b**p <= X):
            n = b**p
print(n)

Solution (Python):
n = int(input())
a = []
tent = True
while True:
  if tent == True:
    for i in range(1,1001):
      if i ** 2 > 1000:
        tent = False
        break
      else:
        for j in range(2,10):
          if i**j <= 1000:
            a.append(i**j)
          else:
            break
  else:
    break
new_lst = [e for e in a if e <= n]
print(max(new_lst))

Solution (Python):
import math

X = int(input())

dp = [[0] * 100 for _ in range(X + 1)]

maxint = 1

for i in range(2, int(math.sqrt(X)) + 1):
    dp[i][1] = i
    for j in range(2, 100):
        dp[i][j] = dp[i][j - 1] * i
        if dp[i][j] > X:
            maxint = max(maxint, dp[i][j - 1])
            break
            

print(maxint)

Solution (Python):
A = int(input())
ans = []
for i in range(1,32):
    for j in range(2,1000):
        ans.append(i ** j)
ans.sort()
for h in range(len(ans)):
    if A < ans[h]:
        print(ans[h - 1])
        exit()

Solution (Python):
X = int(input())
if X==1:
    MAX = 1
else:
    MAX = 0
    for B in range(2,35):
        for P in range(2,15):
            if B**P>X:
                break
            else:
                if MAX<B**P:
                    MAX = B**P
print(MAX)

Solution (Python):
import math
X = int(input())
n = (int(math.sqrt(X)))**2
for b in range(2, int(math.sqrt(X))+2):
    for p in range(1, 10):
        if (b**p > n) and (b**p <= X):
            n = b**p
print(n)

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

Solution (Python):

x=int(input())
m=1
if x<=3:
    print(1)
else:
    for p in range(2,12):
        a=2
        while a**p<=x:
            m=max(m,a**p)
            a+=1
    print(m)

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    X = I()

    ans = 0
    for i in range(1, int(X ** 0.5) + 1):
        for j in range(2, max(int(math.log2(X)) + 1, 3)):
            tmp = i ** j
            if tmp <= X:
                ans = max(tmp, ans)

    print(ans)

if __name__ == '__main__':
    resolve()

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

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

MAX=0
for i in range(1,int(X**.5)+3):
  for j in range(2,10):
    if i**j<=X:
      if MAX < i**j:
        MAX = i**j
    else:
      break

print(MAX)

Solution (Python):
L=[1]
s=2
for i in range(2,32):
  while True:
    s=s*i
    if s<=1000:
      L.append(s)
    else:
      s=i+1
      break
L=sorted(list(set(L)))
N=int(input())
S=[i for i in L if i<=N]
print(S[-1])

Solution (Python):
x = int(input())
if x <= 3:
  print(1)
else:
  a = []
  for i in range(2, x + 1):
    j = 2
    while i ** j <= x:
      a.append(i ** j)
      j += 1
  print(max(a))

Solution (Python):
import math

x = int(input())

ans = 1
for i in range(2, math.ceil(math.sqrt(x)) + 1):
    y = i * i
    while y <= x:
        ans = max(ans, y)
        y *= i
print(ans)

Solution (Python):

















import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

import math
X = INT()
if X == 1:
    print(1)
else:
    ans = 1
    for i in range(2, int(math.sqrt(X)) + 1, 1):
        tmp = i
        while tmp <= X:
            if tmp > ans: ans = tmp
            tmp *= i
    print(ans)

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

if X == 1:
  print(1)
  exit()

ans = 0

for b in range(2, int(X**0.5)+2):
  temp = b
  while temp <= X:
    ans = max(ans, temp)
    temp *= b

print(ans)

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

y = 2
max_num = 1

for i in range(2, x):
    if i > x:
        break
    z = i
    y = z * z
    for j in range(2, x):
        if y <= x:
            max_num = max(max_num, y)
        else:
            break
        y *= z

print(max_num)

Solution (Python):
x = int(input())
ans = 0
for a in range(2, 33):
  for b in range(2, 10):
    if a**b > x:
      break
    ans = max(ans, a**b)
print(max(ans, 1))

Solution (Python):
def solve():
  ans = 0
  X = int(input())
  lis = [False]*(X+1)
  lis[1] = True
  for b in range(2,X+1):
    p = 2
    while b**p<=X:
      lis[b**p] = True
      p += 1
  for i in range(X,-1,-1):
    if lis[i]==True:
      return i
print(solve())

Solution (Python):

from collections import Counter
def factorize(n):
  b = 2
  fct = []
  while b * b <= n:
    while n % b == 0:
      n //= b
      fct.append(b)
    b = b + 1
  if n > 1:
    fct.append(n)
  f = Counter(fct).values()
  if 1 not in f and len(set(f))==1:
    return True
  return False

X = int(input())
for i in range(X,0,-1):
  f = factorize(i)
  if f==True or i==1:
    print(i)
    break

Solution (Python):
x = int(input())
ans = 1
for b in range(1, x):
  for p in range(2, x):
    tmp_ans = b ** p
    if tmp_ans > x:
      break
    ans = max(ans, tmp_ans)
print(ans)

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

ans = [1]
for i in range(2, 1001):
  p = 2
  while i**p <= 1000:
    ans.append(i**p)
    p += 1
while not x in ans:
  x -= 1
print(x)

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate 

from collections import deque,defaultdict,Counter
import decimal
import re












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

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
x = I()
ma = 1
for b in range(1,x+1):
    for p in range(2,x+1):
        if b**p <= x:
            ma = max(ma,b**p)
        else:
            break
print(ma)

Solution (Python):
X = int(input())
if X==1:
    print(1)
else:
    cmax = 0
    for i in range(2,int(X**0.5)+1):
        k = 2
        while i**k<=X:
            k += 1
        cmax = max(cmax,i**(k-1))
    print(cmax)

Solution (Python):

x = int(input())
bekis = set()
bekis.add(1)

ans = 1
for b in range(2,35):
    for p in range(2,11):
        num = pow(b,p)
        if num <= x:
            ans = max(ans,num)
        else:
            break
print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    X = ini()
    ans = 1
    for p in range(2, X):
        a = p * p
        while a <= X:
            ans = max(ans, a)
            a *= p
    return ans


print(solve())

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

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

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())
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):
def main():
    x = int(input())
    limit = int(x**0.5)+2
    ans = 0
    for i in range(limit):
        for j in range(2,limit):
            p=i**j
            if p <= x:
                ans = max(ans, p)
            else:
                break
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
ans = 0
for i in range(1,35):
  for k in range(2,10):
    if i**k <= N and i**k >= ans:
      ans = i**k
print(ans)

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

if a==1:
    print(1)
    exit()

res = 1
for i in range(2,32):
    for j in range(2,10):
        x = i**j
        if x > a:
            pass
        else:
            res = max(res,x)
print(res)

Solution (Python):
ary = [0] * 1000000
for i in range(1, 1000 + 1):
    for j in range(2, 1000 + 1):
        val = i ** j
        
        if val > 1000:
            break
        ary[val] += 1
x = int(input())
for i in range(x + 1):
    index = x - i
    if ary[index] > 0:
        break
print(index)

Solution (Python):
X = int(input())
ans = 0
for i in range(1,500):
  for j in range(2,10):
    if i**j<=X:
      ans = max([ans, i**j])
    else:
      break

print(ans)

Solution (Python):
N = int(input())
ans = 0
if N <= 3:
    print(N)
    exit(0)
for i in range(2, 33):
    for j in range(2, 11):
        t = i ** j
        if t <= N:
            ans = max(ans, t)
print(ans)

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

max_num = 1

for bosuu in range(1, 50):
    for sisuu in range(2, 11):
        num = bosuu ** sisuu
        
        if (num <= X):
            max_num = max(max_num, num)
        else:
            break

print(max_num)

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

def IsBekijo(x):
    if x == 1:
        return True
    for i in range(2,math.ceil(math.sqrt(x)) + 1):
        if x % i == 0:
            d = x // i
            while d != 1:
                if d % i == 0:
                    d //=  i
                else:
                    break
            if d == 1:
                return True
    return False

for i in range(X,0, -1):
    if IsBekijo(i):
        print(i)
        break

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

def IsBekijo(x):
    for i in range(2,math.ceil(math.sqrt(x)) + 1):
        if x % i == 0:
            d = x // i
            while d != 1:
                if d % i == 0:
                    d //=  i
                else:
                    break
            if d == 1:
                return True
    return False



for i in range(X,0, -1):
    if IsBekijo(i):
        print(i)
        exit()
print(1)

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

if x == 1:
    print("1")
    exit(0)

ans = 1
for b in range(2, 1000 + 1):
    for p in range(2, 10+1):
        bp = b**p
        if bp <= x:
            ans = max(ans, bp)

print(ans)

Solution (Python):
import math
x=int(input())
l=[1]
for i in range(2,int(math.sqrt(x))+1):
  p=i
  while 1:
    p*=i
    if p<=x:
      l.append(p)
    else:
      break
l.sort()
print(l[-1])

Solution (Python):
x = int(input())
if x == 1:
    print(1)
elif x == 1000:
    print(1000)
else:
    print(int(max(int((x ** (1 / i))) ** i for i in range(2, x + 1))))

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

lst = []
for i in range(1,101):
    for j in range(2,10):
       lst.append(i**j)
lst.sort(reverse=True)

for n in lst:
    if n <= x:
        print(n)
        break

Solution (Python):
x = int(input())
ans = 0
for b in range(1, 33):
    for p in range(2, 12):
        if b**p<=x:
            ans = max(ans, b**p)
print(ans)

Solution (Python):
X = int(input())
List = [1]
a =0
for i in range(2,35):
  for j in range(2,11):
    a = i**j
    if a <= 1000:
      List.append(i**j)
    else:
      break
List.sort()
k = 0
for i in range(len(List)):
  if List[i] > X:
    k = i-1
    break
  elif List[i] == X:
    k = i
    break
print(List[k])

Solution (Python):
x = int(input())
if x == 1:
    print(1)
    exit()

for i in reversed(range(1, x + 1)):
    for j in range(2, 101):
        for k in range(2, 101):
            number = j ** k
            if number == i:
                print(i)
                exit()

Solution (Python):
X = int(input())
maxi = 0
for i in range(X+1):
  for j in range(2,10):
    
    a = i**j
    
    if a <= X and a > maxi:
      
      maxi = a
print(maxi)

Solution (Python):
n = int(input())
maxi = 1
for i in range(1,32):
  for j in range(2,10):
    l = i**j
    if l<=n:
    	maxi = max(maxi, l)
print(maxi)

Solution (Python):
n = int(open(0).read().rstrip())

exes = {1}

for i in range(2,1001):
    if not i in exes:
        to_add = i
        while to_add * i <= 1000:
            to_add *= i
            exes.add(to_add)

print(max(filter(lambda x:x<=n, exes)))

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

print(a)

Solution (Python):
def f(N):
  for i in range(int(N**0.5)+1):
    for j in range(N):
    	if (e := pow(i, j)) <= N:
          yield e
n = int(input())
print(max(f(n)))

Solution (Python):
import math

X = int(input())

for k in range(X,0,-1):
    for i in range(2,int(math.sqrt(k))+2,1):
        tmp = i
        tmp = tmp*i
        while tmp <= k:
            if tmp ==k:
                print(k)
                exit()
            tmp = tmp*i
print(1)

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

ans = 0
tmp = 1
for i in range(1, int(x**0.5)+1):
    for j in range(2, x):
      tmp = pow(i, j)
      if tmp > x:
          tmp = pow(i, j-1)
          
          break

    ans = max(tmp, ans)

print(ans)

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

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

ans = 0

for i in range(1, 32):
    for j in range(2, 11):
        exp = i**j
        if exp <= X:
            ans = max(ans, exp)
        else:
            break
            
print(ans)

Solution (Python):
X = int(input())
final = 0
for i in range(40):
    for j in range(2,11):
        if i**j > X:
            final = max(ans,final)
            break
        ans = i**j
print(final)

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

print(max(ans))

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

Solution (Python):


X = int(input())

ret = 0
for i in range(1, 1001):
    for j in range(2, 20):
        if i**j <= X:
            ret = max(i**j, ret)

print(ret)

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

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

for b in range(1,x+1):
  for q in range(2,x+2):
    a = b**q
    if a <=x:
      c.append(a)
    else:
      break

C = set(c)
print(max(C))

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

for b in range(1,x):
  for q in range(2,x):
    if b**q <=x:
      c = max(c,b**q)
    else:
      break
print(c)

Solution (Python):
import math
x = int(input())
ans = 0
mx = 0
for b in range(1, int(math.sqrt(x))+1) :
    if b == 1 :
        mx = 1
        continue
    p = 1
    while b ** p <= x :
        mx = max(b**p, mx)
        p += 1
print(mx)

Solution (Python):
X = int(input())
l=[]
for i in range(1,101):
    for j in range(2,11):
        if i**j > 1000:
            break
        else:
            l.append(i**j)
for k in range(X):
    if X - k in l:
        print(X-k)
        break

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

lst = []
for i in range(1,101):
    for j in range(2,11):
        if i**j > 1000:
            break
        else:
            lst.append(i**j)

for k in range(X):
    if X - k in lst:
        print(X-k)
        break

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

Solution (Python):
def main():
    X = int(input())
    ans = 1
    for b in range(1,X+1):
        for p in range(2,10):
            a = b**p
            if a > X:
                break
            elif ans < a and a <= X:
                ans = a
            
    print(ans)

if __name__ == '__main__':
    main()

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

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

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

Solution (Python):


X = int(input())

ans = 1
b = 1
p = 2

while b ** 2 <= X:
    p = 2
    while b ** p <= X and p <= X:
        ans = max(ans, b ** p)
        p += 1
    b += 1

print(ans)

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


if __name__ == "__main__":
    solve()

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

ans = 0
if x == 1:
    ans = 1
else:
    for i in range(2, int(x**0.5)+1):
        j = 2
        while True:
            if i**j > x:
                break
            else:
                ans = max(i**j, ans)
                j += 1

print(ans)

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



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

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

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

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

answer = 1
for i in range(n//2+1):
  for j in range(2,n//2+1):
    check = i**j
    if check <= n:
      if (answer < check):
        answer = i**j
    else :
      break

print(answer)

Solution (Python):
import math
X = int(input())
res = 1
for i in range(2, int(math.sqrt(X)) + 1):
    j = 2
    while i ** j <= X:
        j += 1
    res = max(res, i ** (j - 1))
print(res)

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

sq_x = int(x ** 0.5)
ans = 1
for i in range(2, sq_x + 1):
    t = i
    while t <= x:
        ans = max(ans, t)
        t *= i

print(ans)

"""
最初は
p = int(math.log(x, i))
でいけるかと思ったが
math.log(1000,10)のとき 2.999..みたいな値になってしまい，誤差がある
"""

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

beki = [1]
for b in range(2, int(pow(X, 0.5))+1):
    p = 2
    while pow(b, p) <= X:
        beki.append(pow(b, p))
        p += 1
print(max(beki))

Solution (Python):
import math
def main():
  x = int(input())
  sum=0
  if x==0 or x==1:
    sum=x
  else:
    for i in range(2,int(math.sqrt(x))+1):
      j=2
      while True:
        if pow(i,j) <= x:
          if pow(i,j) > sum:
            sum=pow(i,j)
        else:
          break
        j+=1
  print(sum)
main()

Solution (Python):

x = int(input())
ans = 1

n = 2

while x >= 2**n:
    c = 1
    while x >= c**n:
        ans = max(ans, c**n)
        c += 1
    n += 1
print(ans)

Solution (Python):
import itertools
import sys
input = sys.stdin.readline

X = int(input())
ans = 1

for b in range(2, X+1):
    for i in itertools.count(2):
        bp = b ** i
        
        if bp <= X:
            ans = max(ans, bp)
        else:
            break

print(ans)

Solution (Python):
x=int(input())
ans=1
for num in range(2,x+1):
    k=x
    cnt=0
    while k>=num:
        k//=num
        cnt+=1
    if cnt>=2:
        ans=max(ans,pow(num,cnt))
print(ans)

Solution (Python):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial





def solve():
    x = int(input())
    ans = 1
    for i in range(1, x + 1):
        for j in range(2, 11):
            if i ** j <= x:
                ans = max(ans, i ** j)
            else:
                break
    print(ans)

t = 1

for case in range(1,t+1):
    ans = solve()


"""

a aa c ca c a b a ab a b c

"""

Solution (Python):
import math

x = int(input())
ans = [1]
s = int(math.sqrt(x))
if s >= 2:
    for i in range(2,s+1):
        temp = i
        while True:
            temp *= i
            if temp <= x:
                ans.append(temp)
            else:
                break

print(max(ans))

Solution (Python):
import math

n = int(input())
ans = [1]
b = int(math.sqrt(n))
if b >= 2:
    for i in range(2,b+1):
        temp = i
        while True:
            temp*=i
            if temp <= n:
                ans.append(temp)
            else:
                break

print(max(ans))