AtCoder Beginner Contest 097 - Exponential

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-----
10

-----Sample Output-----
9

There are four perfect powers that are at most 10: 1, 4, 8 and 9.
We should print the largest among them, 9.

Difficulty: EASY

Starter code:

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


x = int(input())
l = [i ** j for i in range(1, 33) for j in range(2, 10) if i ** j <= x]
print(max(l))


x = int(input())
while sum((round(x ** (1 / k)) ** k != x for k in [2, 3, 5, 7])) == 4:
	x -= 1
print(x)


n = int(input())
ans = []
for j in range(2, 11):
	l = [i ** j for i in range(1, 32) if i ** j <= n]
	ans = ans + l
print(max(ans))


X = int(input())
a = 1
b = 2
while b ** 2 <= X:
	p = 2
	while b ** p <= X:
		a = max(a, b ** p)
		p += 1
	b += 1
print(a)


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)


X = int(input())
exps = []
for b in range(1, 34):
	for p in range(2, 11):
		x = b ** p
		if x < 1001:
			exps.append(x)
exps = list(set(exps))
exps.sort()
for a in exps[::-1]:
	if X >= a:
		print(a)
		break


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)


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


x = int(input())
n = 0
for i in range(1, 32):
	for j in range(2, 10):
		if pow(i, j) >= n and pow(i, j) <= x:
			n = pow(i, j)
print(n)


X = int(input())
ans = 1
for n in range(2, 32):
	a = n * n
	while a <= X:
		ans = max(ans, a)
		a *= n
print(ans)


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


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


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)


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


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


n = int(input())
list = []
for i in range(32):
	for j in range(2, 10):
		ans = i ** j
		if ans <= n:
			list.append(ans)
print(max(list))


X = int(input())
lst = [1]
for i in range(2, 32):
	for j in range(2, 10):
		x = i ** j
		if x <= 1000:
			lst.append(x)
if X in lst:
	print(X)
else:
	lst.append(X)
	lst2 = sorted(lst)
	n = lst2.index(X)
	print(lst2[n - 1])


x = int(input())
if x == 1:
	print(x)
else:
	L = [n ** k for n in range(1, x // 2) for k in range(2, 10) if n ** k <= x]
	print(max(L))


X = int(input())
ans = 1
for b in range(2, X):
	x = b * b
	while x <= X:
		ans = max(ans, x)
		x *= b
print(ans)


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


x = int(input())
ans = 1
for i in range(2, x):
	if i * i > x:
		break
	now = i
	while now * i <= x:
		now *= i
	if now > ans:
		ans = now
print(ans)


(x, mx) = (int(input()), 1)
for i in range(2, x + 1):
	for j in range(2, 100):
		if i ** j <= x:
			mx = max(mx, i ** j)
print(mx)


z = int(input())
x = []
for i in range(31):
	for j in range(10):
		if (i + 1) ** (j + 2) <= z:
			x.append((i + 1) ** (j + 2))
print(max(x))


N = int(input())
se = set((x ** e for x in range(33) for e in range(2, 11) if x ** e <= N))
print(max(se))


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)


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


x = int(input())
expotential = [0] * (x + 1)
expotential[1] = 1
for b in range(2, x + 1):
	t = b * b
	while t <= x:
		expotential[t] = 1
		t *= b
for i in range(x, 0, -1):
	if expotential[i]:
		print(i)
		break


X = int(input())
max_expo = 1
for p in range(2, 10):
	for b in range(X):
		if max_expo < b ** p <= X:
			max_expo = b ** p
print(max_expo)


x = int(input())
ans = 0
for p in range(2, 10):
	for b in range(34):
		if b ** p <= x:
			ans = max(ans, b ** p)
print(ans)


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


x = int(input())
table = [False] * -~x
table[1] = True
for i in range(2, 32):
	j = i * i
	while j <= x:
		table[j] = True
		j *= i
print(max((i for i in range(x + 1) if table[i])))


x = int(input())
a = []
for i in range(1, 33):
	for n in range(2, 11):
		if i ** n <= x:
			a.append(i ** n)
print(max(a))


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)


X = int(input())
ans = 0
for i in range(1, X + 1):
	for j in range(2, 11):
		t = i ** j
		if t <= X:
			ans = max(ans, t)
print(ans)


X = int(input())
ans = []
for i in range(1, X + 1):
	A = 0
	p = 2
	if i == 1:
		ans.append(1)
	else:
		while True:
			A = i ** p
			if A <= X:
				ans.append(A)
				p += 1
			else:
				break
print(max(ans))


a = int(input())
b = 0
for i in range(1, 1001):
	for j in range(2, 11):
		if i ** j <= a:
			b = max(b, i ** j)
print(b)


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))


X = int(input())
a = 0
for i in range(40):
	for j in range(2, 20):
		if i ** j <= X:
			a = max(a, i ** j)
print(a)


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


import math
X = int(input())
bp = {b ** p for b in range(1, int(math.sqrt(X)) + 1) for p in range(2, 10) if b ** p <= X}
print(max(bp))


A = int(input())
B = [1] * 8
for i in range(2, 10):
	for j in range(A + 1):
		if j ** i <= A:
			B[i - 2] = j ** i
		else:
			break
print(max(B))


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


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


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))


from bisect import bisect_right
cands = []
for i in range(2, 400):
	cur = i
	while cur * i <= 1000:
		cands.append(cur * i)
		cur *= i
cands.sort()
X = int(input())
if X == 1:
	print(1)
else:
	print(cands[bisect_right(cands, X) - 1])


A = [1]
X = int(input())
for i in range(1, 33):
	for j in range(2, 11):
		if i ** j < X + 1:
			A.append(i ** j)
print(max(A))


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


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


x = int(input())
count = 1
for i in range(1, x + 1):
	for n in range(2, 10):
		if i ** n <= x:
			count = max(i ** n, count)
print(count)


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)


x = int(input())
i = 2
r = 1
while i * i <= x:
	j = i * i
	while j * i <= x:
		j *= i
	r = max(r, j)
	i += 1
print(r)


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


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)


X = int(input())
s = set((i ** j for i in range(40) for j in range(2, 10) if i ** j <= X))
print(max(s))


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


X = int(input())
li = [x ** p for x in range(1, 32) for p in range(2, 35) if x ** p <= X]
print(max(li))


X = int(input())
ans = 0
for i in range(2, 10):
	c = 1
	while (c + 1) ** i <= X:
		c += 1
	ans = max(ans, c ** i)
print(ans)


x = int(input())
ans = 1
for b in range(2, 50):
	n = b * b
	while n <= x:
		ans = max(ans, n)
		n *= b
print(ans)


n = int(input())
import math as m
if n < 4:
	print(1)
	return
perfect = 1
for b in range(2, int(n ** 0.5) + 1):
	p = int(m.log(n, b))
	x = b ** (p + 1)
	if x > n:
		x = b ** p
	perfect = max(perfect, x)
	if perfect == n:
		break
print(perfect)


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


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


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)


def main():
	x = int(input())
	ans = 0
	for b in range(1, 1000):
		for p in range(2, 10):
			if x >= b ** p:
				ans = max(ans, b ** p)
	print(ans)

def __starting_point():
	main()
__starting_point()


l = sorted([i ** j for i in range(1, 33) for j in range(2, 10)])
n = int(input())
for (i, m) in enumerate(l):
	if m > n:
		print(l[i - 1])
		exit()


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


X = int(input())
print(max(set((b ** p for b in range(1, 100) for p in range(2, 10) if b ** p <= X))))


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


n = int(input())
a = {1}
for b in range(2, n):
	p = 2
	x = b ** p
	while x <= n:
		a.add(x)
		x = b ** p
		p += 1
print(max(a))


n = int(input())
p = [i for i in range(10) if n // 2 ** i]
print(max([i ** q for i in range(1, int(n ** 0.5) + 1) for q in p if i ** q <= n]))


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)


from math import *
x = int(input())
lst1 = list(range(2, int(sqrt(1000)) + 1))
lst2 = [1, 1000]
for n in lst1:
	i = 2
	while n ** i < 1000:
		lst2.append(n ** i)
		i += 1
lst2 = list(set(lst2))
lst2.sort()
for i in range(len(lst2)):
	if x < lst2[i]:
		print(lst2[i - 1])
		return
print(lst2[-1])


x = int(input())
a = 1
for i in range(1, x):
	for y in range(2, x):
		if i ** y <= x:
			a = max(a, i ** y)
		else:
			break
print(a)


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


X = int(input())
ans = 1
i = 2
while i * i <= X:
	a = i
	while a * i <= X:
		a *= i
	ans = max(ans, a)
	i += 1
print(ans)


x = int(input())
pr = [1]
for i in range(2, 32):
	for j in range(2, 10):
		if (i ** j <= 1000) & (i ** j not in pr):
			pr.append(i ** j)
print(max([k for k in pr if k <= x]))


ans = 0
x = int(input())
for i in range(int(x ** 0.5) + 1):
	for j in range(10):
		k = i ** j
		if k <= x:
			ans = max(ans, k)
print(ans)


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)


X = int(input())
ans = 0
for b in range(1, 33):
	for p in range(2, 11):
		if b ** p <= X:
			ans = max(b ** p, ans)
print(ans)


x = int(input())
print(max((b ** p if b ** p <= x else 0 for b in range(1, 35) for p in range(2, 10))))


x = int(input())
max_val = 1
for i in range(1, x):
	for j in range(2, x):
		val = i ** j
		if val > x:
			break
		elif val > max_val:
			max_val = val
print(max_val)


import math
X = int(input())
list1 = []
for i in range(2, X + 1):
	for j in range(2, int((X + 1) / 2)):
		a = math.log10(i) / math.log10(j)
		if a.is_integer():
			list1.append(i)
if list1 == []:
	print(1)
else:
	print(max(list1))


ans = []
X = int(input())
for i in range(1, 50):
	for j in range(2, 20):
		if i ** j <= X:
			ans.append(i ** j)
print(max(ans))


x = int(input())
s = set([1])
for b in range(2, x):
	for p in range(2, 11):
		if b ** p > x:
			break
		s.add(b ** p)
print(max(s))


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


import math

def resolve():
	x = int(input())
	sqrt_x = int(math.sqrt(x))
	al = list()
	for i in range(2, 10):
		for j in range(sqrt_x, 0, -1):
			if j ** i <= x:
				al.append(j ** i)
				break
	al = sorted(al)
	print(al[-1])
resolve()


n = int(input())
c = []
for i in range(1000):
	for j in range(2, 10):
		if i ** j <= n:
			c.append(i ** j)
print(max(c))


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)


x = int(input())
ans = [b ** p for b in range(1001) for p in range(2, 10) if b ** p <= x]
print(max(ans))


n = int(input())
t = [1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 125, 121, 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, 1024, 1296]
res = 0
for tt in t:
	res = tt if tt <= n else res
print(res)


x = int(input())
a = 1
for i in range(1, x):
	for j in range(2, x):
		if i ** j > x:
			break
		a = max(a, i ** j)
print(a)


x = int(input())
print(max([n ** e for n in range(1, 32) for e in range(2, 11) if n ** e <= x]))


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


x = int(input())
print(sorted([b ** p if b ** p <= x else 1 for b in range(1, 1001) for p in range(2, 11)])[-1])


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


x = int(input())
li = []
for i in range(1, 100):
	for j in range(2, 12):
		if i ** j <= x:
			if i ** j not in li:
				li.append(i ** j)
print(max(li))


import math
X = int(input())
beki = []
beki.append(1)
Xruto = math.sqrt(X)
Xruto = math.floor(Xruto)
for i in range(2, Xruto + 1):
	for j in range(10):
		a = pow(i, j)
		if a <= X:
			beki.append(a)
		else:
			break
print(max(beki))


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


X = int(input())
i = 2
ans = 1
while i < X:
	power = 2
	while power <= X:
		if pow(i, power) <= X:
			ans = max(ans, pow(i, power))
		else:
			break
		power += 1
	i += 1
print(int(ans))


x = int(input())
mx = 1
for i in range(2, 32):
	j = 2
	while i ** j <= x:
		if i ** j > mx:
			mx = i ** j
		j += 1
print(mx)


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

def __starting_point():
	main()
__starting_point()


import sys, math
lines = [s.rstrip('\n') for s in sys.stdin.readlines()]
(x,) = [int(num) for num in lines.pop(0).split(' ')]
max_base = int(math.sqrt(x))
max = 1
for base in range(2, max_base + 1):
	i = 2
	while True:
		tmp_max = base ** i
		if tmp_max <= x:
			if tmp_max > max:
				max = tmp_max
			i += 1
		else:
			break
print(max)


b = [0] * 1001
x = int(input())
b[1] = 1
for i in range(2, 1000, 1):
	j = i * i
	while j < 1001:
		b[j] = 1
		j *= i
for i in range(x, 0, -1):
	if b[i] == 1:
		print(i)
		break


X = int(input())
ans = 0
for i in range(1, 32):
	for j in range(2, 10):
		tmp = i ** j
		if ans < tmp <= X:
			ans = tmp
print(ans)


X = int(input())
res = 1
for b in range(2, 1000):
	for p in range(2, 10):
		if b ** p <= X:
			res = max(res, b ** p)
print(res)


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))


x = int(input())
exp = set([1])
for i in range(2, 32):
	v = i * i
	while v <= x:
		exp.add(v)
		v *= i
print(max(exp))


x = int(input())
ans = 0
for p in range(2, 10):
	b = int(x ** (1 / p)) + 1
	while b ** p > x:
		b -= 1
	ans = max(ans, b ** p)
print(ans)


import math
X = int(input())
ans = 1
Y = math.floor(math.sqrt(X))
for i in range(2, Y + 1):
	for j in range(2, 10):
		a = i ** j
		if a <= X:
			ans = max(ans, a)
print(ans)


import math
X = int(input())
ls = []
for i in range(2, math.floor(math.sqrt(X)) + 1):
	for j in range(2, 10):
		if i ** j <= X:
			ls.append(i ** j)
print(max(ls) if ls else 1)


n = int(input())
ans = 1
for b in range(2, 100):
	tmp = b
	for p in range(2, 10):
		tmp *= b
		if tmp <= n:
			ans = max(ans, tmp)
print(ans)


X = int(input())
i = 2
ans = 1
while i < X:
	power = 2
	while i ** power <= X:
		ans = max(ans, i ** power)
		power += 1
	i += 1
print(int(ans))


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))


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


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)


N = int(input())
ans = 1
for i in range(2, N):
	temp = i
	while temp * i <= N:
		temp = temp * i
		ans = max(ans, temp)
print(ans)


import bisect
a = int(input())
b = [1]
for i in range(2, 34):
	j = 2
	while i ** j <= 1000:
		b.append(i ** j)
		j += 1
c = sorted(b)
index = bisect.bisect_right(c, a)
print(c[index - 1])


import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque, Counter
from decimal import Decimal
import functools

def v():
	return input()

def k():
	return int(input())

def S():
	return input().split()

def I():
	return map(int, input().split())

def X():
	return list(input())

def L():
	return list(input().split())

def l():
	return list(map(int, input().split()))

def lcm(a, b):
	return a * b // math.gcd(a, b)
sys.setrecursionlimit(10 ** 6)
mod = 10 ** 9 + 7
cnt = 0
ans = 0
num = []
inf = float('inf')
al = 'abcdefghijklmnopqrstuvwxyz'
AL = al.upper()
N = k()
if N == 1:
	print(1)
	return
for i in range(N, -1, -1):
	for j in range(1, int(N ** 0.5) + 1):
		for k in range(2, 11):
			if j ** k == i:
				print(i)
				return


X = int(input())
l = []
for p in range(2, 10):
	b = 1
	while b ** p <= X:
		l.append(b ** p)
		b += 1
print(max(l))


a = int(input())
ans = 0
i = 1
while i * i <= a:
	for j in range(1, 1000):
		if i ** j <= a and ans < i ** j:
			ans = i ** j
		if i ** j > a:
			break
	i += 1
print(ans)


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


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))


x = int(input())
ans = 0
for i in range(1, 100):
	for j in range(2, 10):
		a = i ** j
		if a <= x and x - a <= x - ans:
			ans = a
print(ans)


x = int(input())
keep = 0
for i in range(1, 1000):
	for j in range(2, 10):
		if keep <= i ** j and i ** j <= x:
			keep = i ** j
print(keep)


X = int(input())
S = set([1])
for i in range(2, X):
	b = 2
	while i ** b <= X:
		S.add(i ** b)
		b += 1
ans = max(S)
print(ans)


x = int(input())
ans = 1
for i in range(2, int(x ** 0.5) + 1):
	k = 1
	temp = 1
	while temp <= x:
		ans = max(ans, temp)
		temp = i ** k
		k += 1
print(ans)


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)


a = int(input())
print(max((j ** i for j in range(32) for i in range(2, 10) if j ** i <= a)))


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))


import bisect
x = int(input())
a = 2
b = 2
k = {1}
while a <= 31:
	while pow(a, b) <= 1000:
		k.add(pow(a, b))
		b += 1
	b = 2
	a += 1
kl = list(k)
kl.sort()
print(kl[bisect.bisect_right(kl, x) - 1])


n = int(input())
ans = 0
for i in range(1, 1000):
	for j in range(2, 10):
		if i ** j <= n:
			ans = max(ans, i ** j)
print(ans)


x = int(input())
ans = 1
cnt = 1
for i in range(1, x):
	cnt = i
	for j in range(9):
		cnt *= i
		if cnt > x:
			break
		if cnt > ans:
			ans = cnt
print(ans)


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


x = int(input())
m = 0
for i in range(2, 11):
	m = max(m, int(((x ** (1 / i) + 1e-06) // 1) ** i))
print(m)


N = int(input())
a = 2
ans = 1
while a * a <= N:
	b = a
	while b <= N:
		ans = max(ans, b)
		b *= a
	a += 1
print(ans)


x = int(input())
A = [a ** b for a in range(1, 35) for b in range(2, 10) if a ** b <= x]
A.sort()
print(A[-1])


X = int(input())
c = {i ** j for i in range(34) for j in range(2, 11) if i ** j <= 1000}
print(max([i for i in c if i <= X]))


x = int(input())
if x == 1000:
	print(1000)
	return
list_exp = []
max_b = int(1000 ** 0.5)
max_p = 0
while True:
	if 2 ** max_p > 1000:
		break
	else:
		max_p += 1
for b in range(1, max_b + 1):
	for p in range(2, max_p):
		if b ** p <= 1000:
			list_exp.append(b ** p)
		else:
			break
list_exp.sort()
for i in range(0, len(list_exp)):
	if list_exp[i] <= x:
		continue
	else:
		print(list_exp[i - 1])
		break


a = int(input())
L = [1]
for i in range(2, 32):
	k = 2
	while i ** k <= a:
		L.append(i ** k)
		k += 1
print(max(L))


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)


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


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


x = int(input())
beki = sorted({b ** p for b in range(1, 100) for p in range(2, 100)})
print(max((i for i in beki if i <= x)))


X = int(input())
S = set((n ** e for n in range(32) for e in range(2, 11) if n ** e <= X))
print(max(S))


X = int(input())
n = 1
if X <= 3:
	print(1)
elif X == 4:
	print(4)
else:
	n = 4
	for i in range(2, int(X ** 0.5) + 1):
		b = i
		k = 1
		while b ** k <= X:
			k += 1
		k -= 1
		if k >= 2:
			n = max(n, b ** k)
	print(n)


a = int(input())
d = 0
e = 0
for i in range(40):
	b = i + 2
	while b <= a:
		b = b * (i + 2)
		e = e + 1
	c = b / (i + 2)
	if e > 1:
		if d <= c:
			d = c
			e = 0
	else:
		e = 0
if d == 0:
	print(1)
else:
	print(int(d))


x = int(input())
li = []
for i in range(32):
	for j in range(2, 6):
		if pow(i, j) <= x:
			li.append(pow(i, j))
print(max(li))


x = int(input())
m = -1000
if 1 <= x <= 3:
	print(1)
	return
else:
	for b in range(2, x + 1):
		for p in range(2, 11):
			if x >= b ** p:
				m = max(m, b ** p)
print(m)


def solve(X):
	ans = 1
	for i in range(1, 32):
		for j in range(2, 11):
			tmp = i ** j
			if tmp <= X and ans < tmp:
				ans = tmp
	return ans

def __starting_point():
	X = int(input())
	print(solve(X))
__starting_point()


n = int(input())
print(max([pow(i, j) for i in range(1, 32) for j in range(2, 10) if pow(i, j) <= n]))


import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce
rr = lambda : sys.stdin.readline().rstrip()
rs = lambda : sys.stdin.readline().split()
ri = lambda : int(sys.stdin.readline())
rm = lambda : list(map(int, sys.stdin.readline().split()))
rl = lambda : list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10 ** 9 + 7
x = ri()
max_ = 0
for i in range(int(x ** 0.5), 0, -1):
	for j in range(1, 10):
		if i ** j <= x:
			max_ = max(i ** j, max_)
		else:
			break
print(max_)


import sys
n = int(input())
ans = []
if n == 1:
	print('1')
	return
for i in range(n // 2):
	for j in range(n // 2):
		if i ** j <= n:
			ans.append(i ** j)
print(max(ans))


X = int(input())
ans = 0
for i in range(1, int(X ** 0.5) + 1):
	for j in range(2, 1000):
		tmp = pow(i, j)
		if tmp > X:
			break
		ans = max(ans, tmp)
print(ans)


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


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


x = int(input())
res = 1
for i in range(2, x):
	num = i * i
	while num <= x:
		res = max(res, num)
		num *= i
print(res)


X = int(input())
print(max([pow(b, p) for b in range(1, 1001) for p in range(2, 11) if pow(b, p) <= X]))


from fractions import gcd
from itertools import combinations, permutations, accumulate, product
from collections import deque, defaultdict, Counter
import decimal
import re
import math
import sys
sys.setrecursionlimit(10000000)
mod = 10 ** 9 + 7
from sys import stdin
readline = stdin.readline

def readInts():
	return list(map(int, readline().split()))

def readTuples():
	return tuple(map(int, readline().split()))

def I():
	return int(readline())
x = I()
ans = -1
for b in range(1, x + 2):
	for p in range(2, x + 2):
		if b ** p > x:
			break
		ans = max(ans, b ** p)
print(ans)


X = int(input())
res_list = [1]
for i in range(1, X):
	for j in range(2, X):
		if i ** j <= X:
			res_list.append(i ** j)
		else:
			break
print(max(res_list))


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	answers = []
	if n <= 3:
		print(n)
		return
	for b in range(2, n):
		for p in range(2, 11):
			if b ** p > n:
				break
			elif b ** p <= n:
				answers.append(b ** p)
			else:
				continue
	print(max(answers))

def __starting_point():
	main()
__starting_point()


x = int(input())
ex = [0 for i in range(1001)]
ex[1] = 1
for i in range(2, 1001):
	tmp = i * i
	while tmp <= 1000:
		ex[tmp] = 1
		tmp *= i
for i in range(x, 0, -1):
	if ex[i] == 1:
		print(i)
		break


X = int(input())
M = 1
for i in range(2, X + 1):
	t = 1
	while t * i <= X:
		t *= i
	if t > i:
		M = max(M, t)
print(M)


x = int(input())
m = 0
for i in range(1, 1000):
	for j in range(2, 11):
		if x >= i ** j:
			m = max(m, i ** j)
print(m)


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])


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


a = int(input())
n = 0
for i in range(1, 1000):
	for j in range(2, 10):
		if n < i ** j and i ** j <= a:
			n = i ** j
print(n)


ans = 1
x = int(input())
for i in range(1, 101):
	for j in range(2, 11):
		m = i ** j
		if x >= m:
			ans = max(ans, m)
print(ans)


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)


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


N = int(input())
ans = 0
for i in range(1, N + 1):
	for j in range(2, 20):
		if i ** j > N:
			continue
		ans = max(i ** j, ans)
print(ans)


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


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


x = int(input())
ans = 1
for a in range(2, 1000):
	p = 2
	while a ** p <= x:
		ans = max(ans, a ** p)
		p += 1
print(ans)


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)


x = int(input())
n = set([1])
for i in range(2, int(x ** 0.5) + 1):
	y = i ** 2
	while y <= x:
		n.add(y)
		y *= i
print(max(n))


A = int(input())
m = 0
for i in range(2, 10):
	for j in range(40):
		k = j ** i
		if A >= k:
			m = max(m, j ** i)
print(m)


x = int(input())
maxi = 1
for i in range(2, 35):
	j = 2
	while i ** j <= x:
		maxi = max(maxi, i ** j)
		j += 1
print(maxi)


x = int(input())
a = 0
for i in range(300):
	for j in range(2, 11):
		if i ** j > x:
			break
		if a < i ** j:
			a = i ** j
print(a)


import sys
X = int(sys.stdin.readline())
ans = 0
for i in range(X + 1):
	for j in range(2, 11):
		tmp = pow(i, j)
		if tmp <= X:
			ans = max(ans, tmp)
print(ans)


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)


x = int(input())
res = 0
for b in range(x + 1):
	for p in range(2, x + 2):
		if res < b ** p <= x:
			res = b ** p
		elif b ** p > x:
			break
print(res)


n = int(input())
p = []
for i in range(1, 32):
	for ii in range(2, 10):
		if i ** ii <= n:
			p.append(i ** ii)
print(max(p))


x = int(input())
expo = set([1])
for b in range(2, x + 1):
	v = b ** 2
	while v <= x:
		expo.add(v)
		v *= b
print(max(expo))


x = int(input())
ans = 1000000
for b in range(1, 32):
	for p in range(2, 10):
		if x - b ** p < 0:
			continue
		ans = min(ans, abs(x - b ** p))
print(x - ans)


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)


MAX = 35
N = int(input())
ans = 1
for i in range(2, MAX + 1):
	t = i * i
	while t <= N:
		ans = max(ans, t)
		t *= i
print(ans)


n = int(input())
mx = 1
for i in range(2, 11):
	mx = max(mx, int(n ** (1 / i) + 1e-13) ** i)
print(mx)


x = int(input())
ans = 1
for b in range(2, 33):
	for p in range(2, 11):
		n = b ** p
		if ans < n <= x:
			ans = n
print(ans)


X = int(input())
ans = 1
for i in range(2, 32):
	for j in range(2, 10):
		if i ** j > X:
			continue
		ans = max(ans, i ** j)
print(ans)


x = int(input())
ans = 0
for i in range(1, 32):
	for j in range(2, 11):
		if pow(i, j) <= x:
			ans = max(pow(i, j), ans)
print(ans)


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)


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


x = int(input())
ans = 0
for i in range(1, 100):
	for j in range(2, 100):
		y = pow(i, j)
		if y <= x:
			ans = max(ans, y)
print(ans)


x = int(input())
i = 1
mx = i
while i ** 2 < x:
	i += 1
	j = 2
	while i ** j <= x:
		j += 1
	if i ** (j - 1) > mx:
		mx = i ** (j - 1)
print(mx)


x = int(input())
ans = 1
for i in range(2, 10):
	for j in range(1, 33):
		if j ** i > ans and j ** i <= x:
			ans = j ** i
print(ans)


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


X = int(input())
maxi = 0
if X < 4:
	print(1)
	return
for i in range(1, X + 1):
	for j in range(2, X + 1):
		if i ** j <= X and i ** j >= maxi:
			maxi = i ** j
		if i ** j > X:
			break
print(maxi)


X = int(input())
(m, c) = (1, 2)
while c * c <= X:
	i = 2
	while c ** i <= X:
		m = max(m, c ** i)
		i += 1
	c += 1
print(m)


n = int(input())
lis = [i ** j for i in range(1, 32) for j in range(2, 10) if i ** j <= n]
lis = list(set(lis))
lis.sort()
print(lis[-1])


X = int(input())
if X == 1:
	print(1)
	return

def prime_factorize(n):
	a = []
	while n % 2 == 0:
		a.append(2)
		n //= 2
	f = 3
	while f * f <= n:
		if n % f == 0:
			a.append(f)
			n //= f
		else:
			f += 2
	if n != 1:
		a.append(n)
	return a
while True:
	a = prime_factorize(X)
	temp = []
	c = 1
	sw = True
	if len(a) == 1:
		sw = False
	for i in range(len(a) - 1):
		if a[i] != a[i + 1]:
			temp.append(c)
			c = 0
		c += 1
	temp.append(c)
	for j in range(len(temp) - 1):
		if temp[j] != temp[j + 1] or temp[j] == 1:
			sw = False
	if sw == True:
		print(X)
		return
	X -= 1


x = int(input())
ans = 1
for i in range(2, x):
	a = i
	while a * i <= x:
		a *= i
	if i < a and ans < a:
		ans = a
print(ans)


n = int(input())
ans = -1
for i in range(1, 33):
	for j in range(2, 15):
		if ans < i ** j <= n:
			ans = i ** j
print(ans)


import math
X = int(input())

def check_p(X, b):
	p = 0
	while b ** (p + 1) <= X:
		p += 1
	return b ** p
ans = 1
for b in range(2, int(math.sqrt(X)) + 1):
	ans = max(ans, check_p(X, b))
print(ans)


import math
x = int(input())
res = 1
for b in range(2, math.ceil(math.sqrt(x))):
	p = 2
	while b ** (p + 1) <= x:
		p += 1
	res = max(res, b ** p)
print(res)


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


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)


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


X = int(input())
ans = 1
a = 2
while a * a <= X:
	r = a * a
	while r <= X:
		ans = max(ans, r)
		r *= a
	a += 1
print(ans)


x = int(input())
ans = 1
for i in range(40):
	for j in range(2, 15):
		if i ** j <= x and i ** j > ans:
			ans = i ** j
print(ans)


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


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


n = int(input())
s = set()
for i in range(1, 32):
	s.add(i ** 2)
for i in range(1, 11):
	s.add(i ** 3)
for i in range(1, 7):
	s.add(i ** 4)
for i in range(1, 5):
	s.add(i ** 5)
	s.add(i ** 6)
	s.add(i ** 7)
	s.add(i ** 8)
	s.add(i ** 9)
	s.add(i ** 10)
t = list(s)
t.sort()
t = [x for x in t if x <= 1000]
res = 0
for tt in t:
	res = tt if tt <= n else res
print(res)


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)


X = int(input())
ans = 1
for i in range(2, X + 1):
	for j in range(2, X + 1):
		a = i ** j
		if a > X:
			break
		elif a > ans:
			ans = a
print(ans)


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))


X = int(input())
M = 1
for i in range(1, X):
	for p in range(2, 10):
		if M < i ** p <= X:
			M = i ** p
print(M)


N = int(input())
ans = 1
for b in range(2, 32):
	for p in range(2, 11):
		if b ** p <= N:
			ans = max(ans, b ** p)
print(ans)


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


x = int(input())
set_x = set((n ** e for n in range(32) for e in range(2, 11) if n ** e <= x))
ans = max(set_x)
print(ans)


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)


x = int(input())
c = 1
for i in range(2, 11):
	for n in range(1, 32):
		ni = n ** i
		if ni > c and x >= ni:
			c = ni
print(c)


X = int(input())
cans = [b ** p for b in range(1, 32) for p in range(2, 10) if b ** p <= X]
print(max(cans))


x = int(input())
mx = 0
for b in range(1, int(1000 ** 0.5) + 1):
	for p in range(2, 10):
		if mx < b ** p <= x:
			mx = b ** p
print(mx)


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))


def answer(x: int) -> int:
	if x < 4:
		return 1
	result = 1
	for b in range(2, x + 1):
		for p in range(2, x + 1):
			exp = pow(b, p)
			if exp <= x:
				result = max(result, exp)
			else:
				break
	return result

def main():
	x = int(input())
	print(answer(x))

def __starting_point():
	main()
__starting_point()