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 collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")


def A():
    a, b, c, d = LI()
    x = abs(a - b)
    y = abs(b - c)
    z = abs(a - c)
    if (x <= d and y <= d) or z <= d:
        print("Yes")
    else:
        print("No")
    return


def B():
    X = II()
    x = [False] * (10 ** 3 + 1)
    x[1] = True
    for i in range(2, int(10 ** 1.5) + 1):
        k = i*i
        while X >= k:
            x[k] = True
            k *= i
    for i in range(X, -1, -1):
        if x[i]:
            print(i)
            return
    return


def C():
    s = stdin.readline().rstrip()
    K = II() - 1
    ans = []
    for i in range(len(s)):
        for k in range(K+1):
            b = s[i:i + k + 1]
            ans.append(b)
    ans = list(set(ans))
    ans.sort()
    print(ans[K])
    return


def D():
    n, m = LI()
    p = LI_()
    xy = LIR_(m)
    size = [1 for _ in range(n)]
    height = [1 for _ in range(n)]
    par = [i for i in range(n)]
    def find(x):
        if par[x] == x:
            return x
        else:
            par[x] = find(par[x])
            return par[x]
    def union(x, y):
        s1 = find(x)
        s2 = find(y)
        if s1 != s2:
            if height[s1] < height[s2]:
                par[s1] = s2
                size[s2] += size[s1]
                size[s1] = 0
            else:
                par[s2] = s1
                size[s1] += size[s2]
                size[s2] = 0
                if height[s1] == height[s2]:
                    height[s1] += 1

    for x,y in xy:
        union(x, y)
    ans = 0
    for i in range(n):
        if find(p[i]) == find(i):
            ans += 1
    
    print(ans)
    return


if __name__ == '__main__':
    B()

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

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

def f(b, p):
  return b ** p

ans = []

for b in range(2, x):
  for p in range(2, x):
    temp = f(b, p)
    if temp <= x:
      ans.append(temp)
    else:
      break

print(max(ans))

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

Solution (Python):
X = int(input())
result = 1
for i in range(2,X):
    if i**2 > X:
        break
    j = 2
    while True:
        if i**j > X:
            break
        j += 1
    if i**(j-1) > result:
        result = i**(j-1)
print(result)

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

for i in range(2,32):
    for j in range(2,11):
        if i ** j > x:
            break
        a.append(i ** j)
print(max(a))

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

max = 0
for i in range(int(x**0.5) + 1):
    for j in range(int(x**0.5) + 1):
        temp = i ** j
        if max < temp <= x:
            max = temp

print(max)

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())
li = []
for i in range(1,32):
    for j in range(2,32):
        if i**j<=1000:
            li.append(i**j)
li = list(set(li))
li.sort()
for k in range(len(li)-1,-1,-1):
    if li[k]<=x:
        print(li[k])
        break

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

Solution (Python):


import math

X = int(input())

for i in range(X, 0, -1):
    for j in range(math.floor(math.sqrt(X)), 0, -1):
        for k in range(10):
            if pow(j, k) == i:
                print(pow(j, k))
                exit()

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

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

Solution (Python):
N = int(input())
ans = 0
for b in range(1,N+1):
    for p in range(2,100):
        if b**p>N:
            break
        ans = max(ans,b**p)
print(ans)

Solution (Python):
import sys
x = int(input())
for i in range(x,0,-1):
  for j in range(2,10):
    if round((i**(1/j)),5)%1 == 0:
      print(i)
      sys.exit()

Solution (Python):
a = int(input())
for i in range(a, 0, -1):
    for j in range(int(i**0.5), 1, -1):
        b = i
        while True:
            if b % j == 0:
                b = b // j
                if b == 1:
                    print(i)
                    exit()
            else:
                break
print(1)

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

ans = 1
k = 2
while 2 ** k <= x:
    
    i = 1
    while i ** k <= x:
        
        r = i ** k
        
        ans = max(ans, r)
        i += 1
    k += 1
print(ans)

Solution (Python):
x = int(input())
m = 1
for i in range(2,(x+1)//2):
  tmp = 0
  k = 0
  while tmp <= x:
    m = max(m,tmp)
    tmp = i**k
    k+=1
print(m)

Solution (Python):
x = int(input())
ans = 1
for b in range(2, int(x / 2)):
    p = 2
    sub = 1
    while b**p <= x:
        sub = b**p
        p += 1
    ans = max(ans, sub)
print(ans)

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

Solution (Python):
import math
n=int(input())
if n<=3:
    print(1)
    exit()
rn=int(math.sqrt(n))
s=set()
for i in range(2,rn+1):
    tmp=i
    while tmp<n:
        tmp*=i
        if tmp<=n:
            s.add(tmp)
print(max(s))

Solution (Python):
X = int(input())
max = 1
b = 2
while b*b <= X:
	m = b*b
	while m <= X:
		if max < m:
			max = m
		m *= b
	b += 1
print(max)

Solution (Python):
X = int(input())
se = set(n**e for n in range(32) for e in range(2,11) if n**e <= X)

answer = max(se)
print(answer)

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

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

ans = 1

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

print(ans)

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

ans = [1]

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

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

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

ans=1
for b in range(2,int(x**(1/2))+1):
    p=2
    check=b**p

    while check<=x:
        ans=max(ans,check)
        p+=1
        check=b**p
print(ans)

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

max_x = 1
for i in range(2, 32):
    p = 2
    while i ** p <= X:
        if i ** p > max_x:
            max_x = i ** p
        p += 1
print(max_x)

Solution (Python):
import sys
import math

def input():
    return sys.stdin.readline().rstrip()

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

    l = { i ** j for i in range(1, int(math.sqrt(x))+1) for j in range(2, 10) if i ** j <= x }

    print(max(l))

Solution (Python):
import sys
import math

def input():
    return sys.stdin.readline().rstrip()

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

    l = { i ** j for i in range(1, int(math.sqrt(x))+1) for j in range(2, 10) if i ** j <= x}

    print(max(l))

Solution (Python):
import sys
import math

def input():
    return sys.stdin.readline().rstrip()

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

    l = { i ** j for i in range(1, int(math.sqrt(x))+1) for j in range(2, 11) if i ** j <= x}

    print(max(l))

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

def main():
    x = int(input())
    l = set()
    l.add(1)

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

    for i in range(1000):
        for j in range(2, 1000):
            if i ** j > 1000:
                break
            l.add(i ** j)

    x = set(range(x + 1, 1001))
    l = l - x
    print(max(l))

if __name__ == "__main__":
    main()

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

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

exps = [1]
for i in range(1, X+1):
    for j in range(2, X+1):
        e = i**j
        if e <= X:
            exps.append(e)
        else:
            break

exps.sort(reverse=True)
print(exps[0])

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

nums=[1]

for b in range(2,x):
    p=2
    while b**p<=x:
        nums.append(b**p)
        p+=1
print(max(nums))

Solution (Python):
x=int(input())
nums=[1]

for b in range(2,x):
    p=2
    while b**p<=x:
        nums.append(b**p)
        p+=1
print(max(nums))

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

Solution (Python):
import math
x=int(input())
beki_list = []
for i in range(1,int(math.sqrt(1000))+1):
    for j in range(2,11):
        if i**j<=x:
            beki_list.append(i**j)

print(max(beki_list))

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

if x == 1:
    print(1)
else:
    answer = 0
    for i in range(2, x):
        if x < i ** 2:
            break
        
        j = 2
        while True:
            if i ** j > x:
                break
            if i ** j > answer:
                answer = i ** j
            j += 1
    print(answer)

Solution (Python):
n = int(input())
ciel = int(n**(1/2))
maxs=[1]
for a in range(2,ciel+2):
    b=1
    ans = 0
    while ans <= n:
        ans = a**b
        b+=1
    maxs.append(ans/a)
print(int(max(maxs)))

Solution (Python):
x=int(input())
v=[]
for j in range(2,11):
    for i in range(1,32):
        if i**j<=x and (i+1)**j>x:
            v.append(i**j)
            break
print(max(v))

Solution (Python):
x=int(input())
v=[]
for i in range(1,32):
    for j in range(2,1000):
        if i**j<=x and (i+1)**j>x:
            v.append(i**j)
print(max(v))

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

v = int(X ** 0.5)
m = X
ans = 1

for b in range(2, v + 1):
    p = 2
    j = b ** p
    while j <= X:
        if j <= X and X - j <= m:
            m = X - j
            ans = j
        p += 1
        j = b ** p      
            
print(ans)

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

exlist = [1]
for i in range(2, math.floor(x**0.5)+1):
    tmp = i
    while tmp <= x:
        exlist.append(tmp)
        tmp *= i
print(max(exlist))

Solution (Python):

import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	X = int(input())
	
	ans = []
	for i in range(1, 1000):
		for j in range(2, 1000):
			tmp = i**j
			if tmp > X:
				break
			ans.append(tmp)
			
	ans.sort()
	print(ans[-1])
			
	
if __name__ == "__main__":
	main()

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

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

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

Solution (Python):
X = int(input())
m = 1
for i in range(2,X):
    lis = [i**j for j in range(2,11) if i**j <= X]
    if len(lis) != 0:
        m = max(max(lis),m)
print(int(m))

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

max_num = 0
for i in range(x):
	if x == 1:
		max_num = 1
		break
	j = 1

	while (i+2) ** j <= x:
		if max_num < (i+2) ** j:
			max_num = (i+2) ** j
		j += 1
	if j == 2:
		break
print(max_num)

Solution (Python):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

X = n()
max_beki = 1

for b in range(2, X):
    num = b * b
    while num <= X:
        if num > max_beki:
            max_beki = num
        num *= b
print(max_beki)

Solution (Python):

X = int(input())
lis = [1]
blflag = False

for i in range(X):

    i += 2

    cnt = 2
    while True:

        if i ** cnt <= X:
            lis.append( i ** cnt )

        elif cnt == 2:
            blflag = True
            break

        else:
            break

        cnt += 1

    if blflag:
        break

lis.sort()

print (lis[-1])

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

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

Solution (Python):
import math

x=int(input())

if x<4:
	print(x)
else:
	result=2
	for i in range(2,x):
		for j in range(2,x):
			if i**j<=x:
				result=max(result,i**j)
			else:
				break
	print(result)

Solution (Python):
x = int(input())
if x < 4:
  print(1)
else:
  ans = 2
  for i in range(2, 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())
ans = 1
for b in range(2, X):
    for p in range(2, X):
        if b**p <= X:
            ans = max(ans, b**p)
        else:
            break
print(ans)

Solution (Python):
import math

x = int(input())
 
max_bp = 0
for b in range(1, x + 1):
  for p in range(2, x + 2):
    bp = b ** p
    if bp > x:
      break
    max_bp = max(max_bp, bp)

print(max_bp)

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

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

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

Solution (Python):
def resolve():
	x=int(input())
	ans=0
	if x==1:
		ans=1
	else:
		for b in range(1,x-1):
			p=2
			while True:
				if b**p>x or p>x:
					break
				else:
					t=b**p
				p+=1
			ans=max(ans,t)
	print(ans)
resolve()

Solution (Python):
def abc():
    e = {1}
    for b in range(2, 1001):
        for p in range(2, 11):
            bp = b ** p
            if bp > 1000:
                continue
            e.add(bp)
    x = int(input().rstrip())
    for n in reversed(range(x+1)):
        if n in e:
            print(n)
            return


abc()

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

Solution (Python):
x=int(input())
a=[]
for i in range(1,34):
  for j in range(2,11):
    t=i**j
    if t>x:
      break
    a.append(t)
print(max(a))

Solution (Python):
X = int(input())
ans = []
for i in range(X):
    x = X-i
    for s in range(33):
        for j in range(2,11):
            if s ** j == x:
                ans.append(x)
                break
print(max(ans))

Solution (Python):
X = int(input())
se = set(n**e for n in range(32) for e in range(2,11) if n**e <= X)

answer = max(se)
print(answer)

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

Solution (Python):


x = int(input())
xx = list(reversed(range(1,x+1)))
xxx = set()

for i in range(1, 32):
    for j in range(2, 11):
        if i**j <= 1000:
            xxx.add(i**j)

for i in xx:
    if i in xxx:
        print(i)
        break

Solution (Python):
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")











X = int(sys.stdin.readline())

beki = {1}
for i in range(2, 1001):
    e = 2
    while i ** e <= X:
        beki.add(i ** e)
        e += 1
print(max(beki))

Solution (Python):
import math

x=int(input())
y=math.floor(math.sqrt(x))
ans=1
temp=1

for i in range(2,y+1):
  while temp*i<=x:
    temp = temp * i
    ans=max(temp,ans)
  else:
    temp=1
print(ans)

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

se = set()
for i in range(2,math.floor(math.sqrt(x))+1):
  cnt = 2
  while i**cnt <= x:
    se.add(i**cnt)
    cnt += 1
se.add(1)
print(max(se&set(range(1,x+1))))

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

se = set()
for i in range(2,32):
  cnt = 2
  while i**cnt <= 1000:
    se.add(i**cnt)
    cnt += 1
se.add(1)
print(max(se&set(range(1,x+1))))

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

Solution (Python):

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

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

print(max(b))

Solution (Python):
exp_list = []
for i in range(2,32):
	j = i
	while True:
		j = j * i
		if j > 1000:
			break
		exp_list.append(j)
exp_list = sorted(set(exp_list+[1]))

n = int(input())
for i in range(n,0,-1):
	if i in exp_list:
		print(i)
		break

Solution (Python):
import math

X = int(input())
ans = 1
cnt = 0
for i in range(2, int(math.sqrt(X)) + 1):
    cnt = 2
    while i ** cnt <= X:
        ans = max(ans, i ** cnt)
        cnt += 1
print(ans)

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

Solution (Python):
n=int(input())
ans=[]
for x in range(1,32):
    for y in range(2,11):
        if x**y<=n:
            ans.append(x**y)
            
print(max(ans))

Solution (Python):

import fractions


def factorize(n):
    l = []  
    b, e = 2, 0  
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            l.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        l.append((n, 1))
    return l



a = int(input())

for i in range(a, 1, -1):
    out = factorize(i)
    t = []
    for j in out:
        t.append(j[1])
    fn = t[0]
    for k in range(1, len(t)):
        fn = fractions.gcd(fn, t[k])
    if fn > 1:
        print(i)
        exit()
print(1)

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

x = int(input())
ans_box = [0]*8
for i in range(2, 9):
    for j in range(1, 33):
        if j**i > x:
            ans_box[i-2] = (j-1)**i
            break
print(max(ans_box))

Solution (Python):

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

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

res = 1
for i in range(2, a):
    for j in range(2, a):
        if i ** j <= a:
            res = max(res, i**j)
        else:
            break
print(res)

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

c = 0
for i in range(x+1):
    for j in range(2,10):
        d = i ** j
        if d<=x and c<=d:
            c = d
print(c)

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

ans = 1

for a in range(1,X):
    for b in range(2,10):
        if a**b > X:
            break
        else:
            ans = max(ans,a**b)

    
print(ans)

Solution (Python):
n = int(input())
c = 1
for i in range(1,n):
    for j in range(2,n):
        if i**j <= n:
            c = max(c,i**j)
        else:
            break
print(c)

Solution (Python):
x = int(input())
a = []
for i in range(1,min(x+1,33)) :
	for j in range(2, 11) :
		if i**j <= x and not i**j in a :
			a.append(i**j)
print(max(a))

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

print(ans)

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

Solution (Python):
n=int(input())
if n<=3:
  print(1)
else:
  ans=[]
  for i in range(2,int(n**(1/2)+1)):
    e=2
    while i**e<=n:
      if i**(e+1)>n:
        ans.append(i**e)
        break
      e+=1
  print(max(ans))

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):
n=int(input())
ans=1
for i in range(2,int(n**0.5)+1):
    for k in range(2,10):
        if i**k>n:break
        ans=max(ans,i**k)
print(ans)

Solution (Python):
X = int(input())
pp = [
    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
]
pp.append(X)
pp.sort(reverse=True)
for i in range(len(pp) - 1):
    if pp[i] == X:
        print(pp[i + 1])
        break

Solution (Python):
def is_perfect_power(n):
    return n in {
        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
    }


X = int(input())
for x in range(X, 0, -1):
    if is_perfect_power(x):
        print(x)
        break

Solution (Python):
def is_perfect_power(n):
    if n == 1:
        return True
    div = 2
    divs = []
    while n != 1:
        if n % div == 0:
            n //= div
            divs.append(div)
        else:
            div += 1
    divs_d = {d: 0 for d in set(divs)}
    for d in divs:
        divs_d[d] += 1
    divs_s = {n for n in divs_d.values()}
    if min(divs_s) > 1:
        for d in divs_s:
            if d % min(divs_s) != 0:
                return False
    else:
        return False
    return True


X = int(input())
for x in range(X, 0, -1):
    if is_perfect_power(x):
        print(x)
        break

Solution (Python):
X = int(input())
T = []

for i in range(int(X ** (1 / 2) + 1)):
    for j in range(int(X ** (1 / 2) + 1)):
        if i ** j <= X:
            T.append(i ** j)
            
T.sort()
print(T[-1])

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

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

m = 0
for b in range(1, 100):
    for p in range(2, 100):
        bp = b ** p
        if bp > X:
            break
        m = max(m, bp)
print(m)

Solution (Python):
x = int(input())
num = []
for i in range(50):
    for j in range(2,10):
        if i**j <=1000 and i**j not in num:
                num.append(i**j)
        elif i**j >1000:
            break
num = sorted(num)

index = [i for i in range(len(num)) if num[i]<=x][-1]
print(num[index])

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

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

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

tmp = 1
for b in range(1, X+1):
  for p in range(2, X+1):
    if b**p <= X:
      if tmp < b**p:
        tmp = b**p
    else:
      break
print(tmp)

Solution (Python):
X=int(input())
l=[i for i in range(2,32)]
ans=[1]
for i in l:
    tmp=i**2
    while tmp<=X:
        ans.append(tmp)
        tmp*=i

print(max(ans))

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

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

Solution (Python):

import sys


def solve(X: int):
    if X == 1:
        print(1)
        return

    res = 0
    for b in range(X):
        for p in range(2,10):
            xx =  b**p 
            if xx == X:
                print(xx)
                return
            elif xx < X:
                res = max(res,xx)
            else:
                break

    print(res)
        



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  
    solve(X)

if __name__ == '__main__':
    main()

Solution (Python):
X = int(raw_input())
lst = [1]
for i in range(2, 32):
	a = i*i
	while a <= X:
		lst.append(a)
		a *= i
lst.sort()
print lst[-1]

Solution (Python):
X=int(input())
ans=1
for i in range(2,33):
    j=2
    while(i**j<=X):
        if i**j>ans:
            ans=i**j
        j+=1

print(ans)

Solution (Python):
x=int(input())
j=2
y=0
while j<=10:
    i=1
    while i**j<=x:
        if i**j>y:
            y=i**j
        i+=1
    j+=1
print(y)

Solution (Python):
x = int(input())
print(max([i**ii for i in range(1,34) for ii in range(2,11) if i**ii <= x]))

Solution (Python):
X = int(input())
ans = 0
for i in range(1, int(X ** 0.5) + 1):
    n = i
    if n == 1:
        ans = 1
        continue
    while n * i <= X:
        n *= i
    if n != i:
        ans = max(ans, n)
print(ans)

Solution (Python):

X=int(input())


mx=1


for a in range(2,1000):

  i=2
  while True:
    
    b=pow(a,i)

    
    if b<=X:
      mx=max(mx,b)
    else:
      
      break

    i+=1


print(mx)

Solution (Python):

X=int(input())


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


mx=0


for a in range(2,1000):

  i=2
  while True:
    
    b=pow(a,i)

    
    if b<=X:
      mx=max(mx,b)
    else:
      
      break

    i+=1


print(mx)

Solution (Python):
import math
x = int(input())
ans = 1
for b in range(1, int(math.sqrt(x) + 1)):
    for p in range(2, x):
        v = b ** p
        if ans <= v <= x:
           ans = v
print(ans)

Solution (Python):

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

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

print(max(b))

Solution (Python):
import math
X = int(input())
L = [1]
for v in range(2, math.floor(math.sqrt(X))+1):
  x = v
  while True:
    x *= v
    if x > X:
      break
    L.append(x)
print(max(L))

Solution (Python):
import math
n = int(input())
res = [1]
last = -1
for i in range(1, n):
    for c in range(2, n):
        num = pow(i, c)
        if num == last:
            break
        if num <= n:
            res.append(num)
        else:
            break
        c+= 1
        last = num
print(max(res))

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

Solution (Python):
x = int(input())
ans = 1
if x == 1:
    print(1)
else:
    b = 2
    while b**2 <= x:
        p = 2
        while b**p <= x:
            ans = max(b**p, ans)
            p += 1
        b += 1
    print(ans)

Solution (Python):

def main():
    num = int(input())

    inf = 10 ** 10
    ans = 1
    for b in range(2, inf):
        for p in range(2, inf):
            kari = b ** p
            if kari > num:
                break
            if kari <= num and kari > ans:
                ans = kari
        if b ** 2 > num:
            break

    print(ans)


if __name__ == '__main__':
    main()

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

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

if x == 1:
    print(1)
else:
    b = 2
    while b**2 <= x:
        p = 2
        while b**p <= x:
            list_.append(b**p)
            p += 1
        b += 1
    print(max(list_))

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

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

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(ans, i**j)

print(ans)

Solution (Python):
import math

X = int(input())
ans = 1
if X != 1:
  for b in range(2, int(math.sqrt(X)) + 1):
    p = 2
    while b ** p <= X:
      ans = max(ans, b ** p)
      p += 1
print(ans)

Solution (Python):

def sqrt(n):
    a = n/2
    while True:
        b = (a+n/a)/2
        if a == b:return b
        else:a,b = b,a



def pow_judge(n):
    if n == 1 or n == 2:return True
    i = int(sqrt(n))
    if i*i == n:
        return True
    else:
        return False

ls = set()
for i in range(1,32):
    for j in range(2,11):
        if i**j > 1000:break
        ls.add(i ** j)
x = int(input())
for i in range(x,-1,-1):
    if i in ls:
        print(i)
        break

Solution (Python):

def sqrt(n):
    a = n/2
    while True:
        b = (a+n/a)/2
        if a == b:return b
        else:a,b = b,a



def pow_judge(n):
    if n == 1 or n == 2:return True
    i = int(sqrt(n))
    if i*i == n:
        return True
    else:
        return False

ls = set()
for i in range(1,32):
    for j in range(2,11):
        if i**j > 1000:break
        ls.add(i ** j)
x = int(input())
for i in range(x,-1,-1):
    if i in ls:
        print(i)
        break

Solution (Python):
import sys

X = int(input())

for i in reversed(range(1, X + 1)):
    for j in range(1, i + 1):
        for k in range(2, i + 10):

            num = j ** k

            if num == i:
                print(num)
                sys.exit()

            if num > i:
                break