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



Sample input:
10


Sample output:
9

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = set()
for i in range(1,50):
    for j in range(2,10):
        if i**j > 1000:
            break
        s.add(i**j)
n = inp()
for i in range(n,0,-1):
    if i in s:
        print(i)
        break

Submission status: Accepted

Solution code:
X = int(input())

ans = 1
for i in range(2, X + 1):
    tmp = i
    flag = False
    while tmp * i <= X:
        flag = True
        tmp *= i
    if flag:
        ans = max(ans, tmp)

print (ans)

Submission status: Accepted

Solution code:
x=int(input())
a=[]
for i in range(1,33):
    for j in range(2,11):
        a.append(i**j)
for i in range(x):
    if x-i in a:
        print(x-i)
        exit()

Submission status: Accepted

Solution code:
X = int(input())
ans = 1
for i in range(2,int(X**0.5)+1):
    cnt = 2
    y = i**cnt
    while y<=X:
        ans = max(ans,y)
        cnt +=1
        y = y*i
print(ans)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

x = int(input())
ans = 1
for i in range(2, x + 1):
    j = i
    while True:
        j *= i
        if j > x:
            if abs(x - ans) >= abs(x - j//i) and j//i != i:
                ans = j//i
            break
print(ans)

Submission status: Accepted

Solution code:
x = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
X=int(input())
ans=1
for i in range(1,1000):
    for j in range(2,1000):
        t=i**j
        if t>X: break
        ans = max(ans, t)
print(ans)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
x = int(input())
b = []
for i in range(2,32):
    for j in range(2, 10):
        b.append(i**j)
b.sort()
ans = 1
for i in b:
    if i <= x:
        ans = i
    else:
        break
print(ans)

Submission status: Accepted

Solution code:
X = int(input())
num = [1]
for i in range(1, 33):
    b = i+1
    p = 2
    while b ** p <= 1000 and b ** p not in num:
        num.append(b ** p)
        p += 1
        
ans = sorted([num[i] for i in range(len(num)) if num[i] <= X])
print(ans[-1])

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
n = int(input())
li = []

for i in range(1,32):
    for j in range(2,11):
        x = i**j
        if x <= 1000:
            li.append(x)

li.sort()

for i in range(len(li)):
    if li[i] == n:
        print(n)
        exit()
    elif li[i] > n:
        print(li[i-1])
        exit()

Submission status: Accepted

Solution code:
x = int(input())
if x==1:
  print(1)
  exit()
ans = 1
for i in range(x, 0, -1):
  m = i
  div = []
  for j in range(2,int(m**0.5)+2):
    if m%j==0:
      count = 0
      while m%j ==0:
        m //= j
        count += 1
      div.append(count)
  if m!= 1:
    div.append(1)
  count = div[0]
  for c in div:
    if c!= count or count ==1:
      break
  else:
    print(i)
    exit()
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math

input = sys.stdin.readline
MOD = 1000000007

X = int(input())

sa = 100000
res = 0

if X == 1:
    print(1)
else:
    for i in range(2,X):
        a = int(math.log(X,i)+0.00000004)
        if (sa > (X - (i**a))) & ( a != 1):
            sa = X - (i**a)
            res = i**a

    print(res)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

n=I()
beki=[]
for k in range(2,11):
    for i in range(1,100):
        if i**k<=n:
            beki.append(i**k)
print(max(beki))

Submission status: Accepted

Solution code:
X = int(input())

e = [0 for _ in range(X+1)]
e[1] = 1
for i in range(2, X):
    v = i*i
    while v <= X:
        e[v] = 1
        v *= i
        
for i in range(X, 0, -1):
    if e[i] == 1:
        print(i)
        break

Submission status: Accepted

Solution code:
x = int(input())

ans = 1
for b in range(1, 100):
    for p in range(2, 100):
        if b ** p <= x:
            ans = max(ans, b ** p)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

def main():
    X = int(input())
    A = []
    for b in range(1, 1000):
        for p in range(2, 1000):
            if b**p <= X:
                A.append(b**p)
            else:
                break
    print(max(A))


main()

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
X=int(input())
ans=1
for b in range(1,X+1):
  for p in range(2,X+1):
    if b**p>X:
      break
    elif b**p>ans:
      ans=b**p
print(ans)

Submission status: Accepted

Solution code:
import math
X = int(input())
res = 0
for b in range(1, int(math.sqrt(X))+1): # sqrt(X)付近まで探索
    for p in range(2, int(math.sqrt(X))+2): # sqrt(X)付近まで探索
        val = b**p
        if (val <= X) and (val > res): # X以下かつその値が最大値なら値を更新
            res = val
print(res)

Submission status: Accepted

Solution code:
x = int(input())

bekijo = 1
for i in range(2,x+1):
    for j in range(2,x+1):
        if i ** j > x: break
        bekijo = max(bekijo, i**j)
        
print(bekijo)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
X = int(input())
ans = 0
for i in range(1,100):
  for p in range(2,100):
    tmp = i ** p
    if(tmp <= X):
      ans = max(tmp,ans)
    else:
      pass
print(str(ans))

Submission status: Accepted

Solution code:
x = int(input())
li = [False] * (x + 1)
li[1] = True

for i in range(x):
    for j in range(2, x):
        if i ** j > x:
            break
        li[i ** j] = True

for i in reversed(range(x + 1)):
    if li[i]:
        print(i)
        break

Submission status: Accepted

Solution code:
for i in range(1,int(input())+1)[::-1]:
  for j in range(2,int(i**(1/2))+1):
    if i%j==0:
      temp=i
      while temp%j==0:
        temp//=j
      if temp==1:print(i);exit()
print(1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i, )
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

if x == 1:
    print(1)
else:
    ans = []
    ok = 0
    for i in range(x, 1, -1):    
        tmp = make_divisors(i)
        for j in tmp[:-1]:
            for k in range(1,10):
                if j**k == tmp[-1]:
                    ok = 1
                    break
        
        if ok == 1:
            break

    print(i)

Submission status: Accepted

Solution code:
# coding: utf-8
import re
import math
from collections import defaultdict
import itertools
from copy import deepcopy
import random
from heapq import heappop,heappush
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
readline=sys.stdin.readline
sys.setrecursionlimit(2000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_power(a,b):#aはbの累乗数か
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)
def hani(x,min_,max_):
    ret=x
    if x<min_:ret=min_
    if x>max_:ret=max_
    return ret
def seifu(x):
    return x//abs(x)

###################################################
def main():
    x=int(input())
    F=factorize(x)
    ans=0
    for a in range(1,1001):
        for b in range(2,100):
            if a**b<=x:
                ans=max(ans,a**b)
    print(ans)
main()

Submission status: Accepted

Solution code:
from math import sqrt
x = int(input())
ans = 1
for i in range(2, int(sqrt(x)) + 1):
    n = i * i
    e = 2
    while n <= x:
        e += 1
        n = pow(i, e)
    ans = max(ans, pow(i, e - 1))
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
if x == 1:
    print(1)
else:
    lst =[]
    for i in range(2, x+1):
        for j in range(2, 36):
            y = i ** j
            if y <= x:
                lst.append(y)
    print(max(lst))

Submission status: Accepted

Solution code:
n=int(input())
ans=0
if n==1:
    print(1)
    exit()


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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
x=int(input())
ans=1
for b in range(2,32):
    for p in range(2,10):
        if b**p>x:
            break
        else:
            if b**p>ans:
                ans=b**p
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
x=int(input())
ans=1
for i in range(1,x+1):
    for j in range(2,50):
        for k in range(2,50):
            if i==j**k:
                ans=j**k
print(ans)

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

Solution code:
x = int(input())

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

i = 2
ans = 0
while i * i < x:
    j = 2
    while i**j <= x:
        ans = max(ans, i**j)

        j += 1

    i += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline
import math

def main():
    X = int(readline())
    ans = 1
    for b in range(1, math.floor(X**(1/2))+1):
        for p in range(2, math.floor(math.log2(X))+1):
            if b ** p <= X:
                ans = max(ans, b ** p)
    
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline
import math

def main():
    X = int(readline())
    ans = 1
    for b in range(1, math.floor(X**(1/2))+1):
        for p in range(2, 11):
            if b ** p <= X:
                ans = max(ans, b ** p)
    
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math 
x = int(input())
ans = 0

if x ==1:
  print(1)
  
else:
  for i in range(1,x//2):
    for j in range(2,11):
      tmp = i **j
      if tmp <= x:
        ans = max(ans,tmp)
        
  print(ans)

Submission status: Accepted

Solution code:
import math
X=int(input())
max_num = 0
for i in range(2,10):
  tei = math.floor(X**(1/i))
  if (tei+1)**i <= X: tei = tei + 1
  if max_num < tei**i:
    max_num = tei**i
print(max_num)

Submission status: Accepted

Solution code:
X = int(input())
list = []

if X == 1:
  list.append(1)

#2^2からスタートするため、X=3も例外として加えなければならない
elif X == 2 or X == 3:
  list.append(2)
  
else:
  for b in range(2, X):
    p = 2
    #X自身になったときに処理できないので
    #<=が必要
    while b ** p <= X:
      list.append(b ** p)
      p += 1
      
print(max(list))

Submission status: Accepted

Solution code:
X = int(input())
list = []

if X == 1:
  list.append(1)

elif X == 2 or X == 3:
  list.append(2)
  
else:
  for b in range(2, X):
    p = 2
    while b ** p <= X:
      list.append(b ** p)
      p += 1
      
print(max(list))

Submission status: Accepted

Solution code:
X=int(input())
ans=1
for i in range(1,X+1):
    for j in range(2,50):
        for k in range(2,50):
            if i==j**k:
                ans=j**k
print(ans)

Submission status: Accepted

Solution code:
X=int(input())
ans=1
for b in range(2,32):
    for p in range(2,10):
        if b**p>X:
            break
        else:
            if ans<b**p:
                ans=b**p
print(ans)

Submission status: Accepted

Solution code:
x=int(input())
s={1,}
for b in range(2,x):
    for p in range(2,100000):
        tmp=b**p
        if tmp>x:
            break
        s.add(tmp)
print(max(s))

Submission status: Accepted

Solution code:
x = int(input())
# n, k = list(map(int, input().split()))
# a = list(map(int, input().split()))
_max = 1
for i in range(1, x+1):
    for j in range(2, x+1):
        if pow(i, j) > _max and pow(i, j) <= x:
            _max = pow(i, j)
        if pow(i, j) > x:
            break

print(_max)

Submission status: Accepted

Solution code:
X = int(input())
maxnum = 0
for i in range(1, X+1):
    for j in range(2, X+2):
        if i**j > X:
            break
        maxnum = max(maxnum, i**j)
print(maxnum)

Submission status: Accepted

Solution code:
import sys
a = [1]
for i in range(2,34):
    for j in range(2,13):
        if i**j <= 1000 : 
            a.append(i**j)   
x = int(input())
for k in range(x,0,-1):
    if k in a:
        print(k)
        sys.exit()

Submission status: Accepted

Solution code:
import sys
import time
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    X = int(readline())
    r = int(X**0.5)
    ans = 1
    for i in range(r,0,-1):
        tmp = i
        if i ==1:
            break
        while tmp<=X:
            ans = max(ans,tmp)
            tmp *=i
    print(ans)




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
x = int(input())
ans = [1]
for i in range(2, 40):
    for j in range(2, 10):
        if i**j <= x:
            ans.append(i**j)
        else:
            break

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

Submission status: Accepted

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

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

def readInts():
  return list(map(int,input().split()))
def main():
    x = int(input())
    ma_ = 1
    for i in range(1,x):
        for j in range(2,x):
            if i**j <= x:
                ma_ = max(ma_,i**j)
            else:
                break
        # break で　for j を消してるだけや
    print(ma_)
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
# coding:utf-8
import math
x = int(input())
num = math.floor(x ** 0.5)
ans = 1

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

print(ans)

Submission status: Accepted

Solution code:
x = int(input())
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
x = int(input())
ans = [1]

for i in range(2, 100):
    n = 2
    while i**n <= x:
        ans.append(i**n)
        n += 1

print(max(ans))

Submission status: Accepted

Solution code:
x = int(input())
ans = 0


for i in range(1, 100):
    if i**2 > x:
        ans = (i - 1)**2
        break

for i in range(1, 100):
    if i**3 > x:
        ans = max(ans, (i - 1)**3)
        break

for i in range(1, 100):
    if i**5 > x:
        ans = max(ans, (i - 1)**5)
        break

for i in range(1, 100):
    if i**7 > x:
        ans = max(ans, (i - 1)**7)
        break

print(ans)

Submission status: Accepted

Solution code:
import math
k=int(input())
kouho=1
for i in range(2,32):
    for j in range(2,10):
        a=i**j
        if a>k:
            break
        if a>kouho:
            kouho=a
print(kouho)

Submission status: Accepted

Solution code:
def main():
    x = int(input())

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


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
#
# sys.setrecursionlimit(10 ** 7)
#
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok

Submission status: Accepted

Solution code:
def main():
    from bisect import bisect_left

    x = int(input())

    cands = [1]
    for b in range(2, x + 1):
        for p in range(2, x + 1):
            pw = b ** p
            if pw > x: break
            cands.append(pw)

    cands.sort()

    i = bisect_left(cands, x)
    if i == len(cands) or x < cands[i]:
        i -= 1
    print(cands[i])


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from bisect import bisect_left,bisect_right
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    X=int(input())
    l=[]
    for i in range(1,33):
        for j in range(2,11):
            l.append(i**j)
    l.sort()
    print(l[bisect_right(l,X)-1])

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
li = [1]
for i in range(100):
    n = 2
    while x >= (i+2)**n:
        li.append((i+2)**n)
        n += 1
print(max(li))

Submission status: Accepted

Solution code:
ans = 0
X = int(input())

for i in range(1,1001):
    for j in range(2,1001):
        K = pow(i,j)
        if K > X:
            break
        ans = max(ans,K)

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
x=int(input())

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

Submission status: Accepted

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

        
    
print(ans)

Submission status: Accepted

Solution code:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

x = int(input())
#print(factorization(8))

if x < 4:
    print(1)
else:
    for i in range(x,3,-1):
        if len(factorization(i)) == 1:
            if factorization(i)[0][1] != 1:
                print(i)
                #print(factorization(i))
                break
        else:
            for k in range(1,len(factorization(i))):
                if factorization(i)[k-1][1] != factorization(i)[k][1] or factorization(i)[k-1][1] == 1:
                    break
            else:
                print(i)
                break

Submission status: Accepted

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

for j in range(10, 1, -1):
    if int(pow(X, (1/j)) + 1)**j <= X:
        ans = max(int(pow(X, (1/j))+1)**j, ans)
    else:
        ans = max(int(pow(X, (1/j)))**j, ans)

print(ans)

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X = INT()
# ans = 0
# for b in range(1, 1000):
#     for p in range(2, 1000):
#         tmp = b ^ p
#         # print(tmp)
#         if tmp <= X:
#             ans = max(ans, tmp)
#             # print(tmp)
#         else:
#             break
# print(ans)
def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

x = X
r = [1]
for i in range(2, x + 1):
    c = 2
    while i ** c <= x:
        r.append(i ** c)
        c += 1
ans = sorted(r)[-1]
print(ans)


exit()


for x in range(X, 0, -1):
    prime = prime_decomposition(x)
    c = Counter(prime)
    # print(c.values())
    value = c.values()
    # print(v)
    print(c)
    for v in value:
        d = v
    if len(c) == 1 and d >= 2:
        print(x)
        exit()
    elif x == 1:
        print(x)
        exit()

Submission status: Accepted

Solution code:
from math import sqrt
X=int(input())
ans=0
for i in range(1,int(sqrt(X))+1):
    now=i
    b=2
    while i!=1 and X>=i**b:
        now=i**b
        b+=1
    ans=max(ans, now)
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
num = [1,1001]
for i in range(2,33):
    j = 2
    while i**j<=1000:
        num.append(i**j)
        j += 1
num = sorted(num)

def binary_search(li,k):
    left = 0
    right = len(li)
    while left < right:
        mid = (left+right)//2
        if li[mid]<=x and x<li[mid+1]:
            return li[mid]
        elif li[mid] < x:
            left = mid+1
        else:
            right = mid
print(binary_search(num,x))

Submission status: Accepted

Solution code:
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
from math import pi, ceil, floor
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
from bisect import bisect_left, bisect_right, insort_left, insort_right
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    n = int(input())
    ans = 1
    now = 1
    for i in range(2, int(n ** 0.5) + 1):
        j = 1
        while i ** j <= n:
            now = i ** j
            j += 1
        ans = max(ans, now)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
x=int(input())
if x==1000:
  print(1000)
  exit()
l=[1]
for i in range(2,32):
  k=2
  while i**k<=1000:
    l.append(i**k)
    k+=1
l=sorted(l)
for i in range(len(l)-1):
  if l[i]<=x<l[i+1]:
    print(l[i])
    exit()
print(961)