TnT/CodeNet4Repair huggingface dataset:
Problem:
In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi.  Takahashi checked and found that the _time gap_ (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example.  Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours.  Find the maximum possible value of s.

Incorrect submission (verdict: Wrong Answer):
def diff(s, t):
    return min(abs(s-t), 24 - abs(s - t))
def main():
    N = int(input())
    D = [int(x) for x in input().split()]
    solve(D)

def solve(D):
    def check(d, di, dj, i, j):
        for k in range(N):
            if k == i or k == j:
                continue
            if diff(D[k], di) < d:
                return None
            if diff(D[k], dj) < d:
                return None
        return d

    D = [0]+D
    D.sort()
    N = len(D)
    answer = 0
    for i in range(N-1):
        Di = D[i]
        Di_ = 24 - D[i]
        for j in range(i+1, N):
            Dj = D[j]
            Dj_ = 24 - D[j]

            m = None
            for di, dj in [(Di, Dj), (Di_, Dj), (Di, Dj_), (Di_, Dj_)]:
                Dij = diff(di, dj)
                dm = check(Dij, di, dj, i, j)
                
                if dm is None:
                    continue
                if m is None:
                    m = dm
                m = max(m, dm)
            answer = max(answer, m) if m else answer
            #print(answer)
    return answer

def test(D):
    return
    print(D, solve(D))
test([7, 12, 8])
test([11, 11])
test([0])
main()



Fixed, accepted submission:
N=int(input())
D =[0]+[int(x) for x in input().split()]
m=D[1]
D.sort()
for i in range(1,N+1):
  D[i]=D[i] if i&1 else 24-D[i]
D.sort()
for i in range(1,N+1):
  m= min(m,D[i]-D[i-1])
print(m)
Problem:
Find the convex hull of a given set of points P. In other words, find the smallest convex polygon containing all the points of P. Here, in a convex polygon, all interior angles are less than or equal to 180 degrees.  Please note that you should find all the points of P on both corner and boundary of the convex polygon.

Incorrect submission (verdict: Wrong Answer):
from math import sqrt
h = {1: 'COUNTER_CLOCKWISE',
       2: 'CLOCKWISE',
       3: 'ONLINE_BACK',
       4: 'ONLINE_FRONT',
       5: 'ON_SEGMENT',}

def dot(a, b):
    return sum([i * j for i,j in zip(a, b)])

def sub(a, b):
    return [a[0] - b[0],a[1] - b[1]]

def cross(a, b):
    return  a[0] * b[1] - a[1] * b[0]

def _abs(a):
    return sqrt(a[0] ** 2 + a[1] ** 2)

def ccw(a, b, c):
    x = sub(b, a)
    y = sub(c, a)
    if cross(x, y) > 0: return 1
    if cross(x, y) < 0: return 2
    if dot(x, y) < 0: return 3
    if _abs(x) < _abs(y): return 4
    return 5

def CCW(a,b,c):
    return h[ccw(a,b,c)]

n = int(input())
c = [list(map(int, input().split())) for i in range(n)]
c.sort(key=lambda x: (x[0], x[1]))
U = c[:2]

for i in range(2, n):
    j = len(U)
    while j >= 2 and CCW(U[-1],U[-2],c[i])  == "COUNTER_CLOCKWISE":
        U.pop()
        j -= 1
    U.append(c[i])

c = c[::-1]
L = c[:2]

for i in range(2, n):
    j = len(L)
    while j >= 2 and CCW(L[-1], L[-2], c[i])  == "COUNTER_CLOCKWISE":
        L.pop()
        j -= 1
    L.append(c[i])

for x,y in U:
    print(x,y)
for x, y in L:
    if not [x,y] in U:
        print(x,y)


Fixed, accepted submission:
from math import sqrt
from collections import deque

def sub(a, b):
    return [a[0] - b[0],a[1] - b[1]]

def cross(a, b):
    return  a[0] * b[1] - a[1] * b[0]

def ccw(a, b, c):
    x = sub(b, a)
    y = sub(c, a)
    return cross(x, y) > 0

n = int(input())
c = [list(map(int, input().split())) for i in range(n)]
c.sort(key=lambda x: (x[0], x[1]))
U = deque(c[:2])

for i in range(2, n):
    j = len(U)
    while j >= 2 and ccw(U[-1],U[-2],c[i]):
        U.pop()
        j -= 1
    U.append(c[i])

c = c[::-1]
L = deque(c[:2])

for i in range(2, n):
    j = len(L)
    while j >= 2 and ccw(L[-1], L[-2], c[i]):
        L.pop()
        j -= 1
    L.append(c[i])

ans = U
for i in range(1,len(L)-1):
    x, y = L[i]
    ans.append([x,y])

print(len(ans))
i = ans.index(sorted(ans, key=lambda x: (x[1],x[0]))[0])
ans = list(ans)
for x,y in ans[i:] + ans[:i]:
    print(x, y)
Problem:
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.

Incorrect submission (verdict: Wrong Answer):
import math
N = int(input())

a = math.sqrt(N)
a = int(a)

print(a)

Fixed, accepted submission:
import math
N = int(input())
 
a = math.sqrt(N)
a = int(a)
 
print(a*a)
Problem:
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}.  Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.

Incorrect submission (verdict: Wrong Answer):
N,M = map(int,input().split())
A = []
for i in range(N):
    A.append(str(input()))
print("#"*(M+2))
print("
print("#"*(M+2))

Fixed, accepted submission:
N,M = map(int,input().split())
A = []
for i in range(N):
    A.append(str(input()))
print("#"*(M+2))
for i in range(N):
   print("#"+A[i]+"#")
print("#"*(M+2))
Problem:
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.

Incorrect submission (verdict: Wrong Answer):
x = int(input())
ans = 1
for a in range(1,x+1):
  for b in range(2,x+1):
    print(a,b)
    if a**b > x:
      break
    elif a**b > ans:
      ans = a**b
print(ans)

Fixed, accepted submission:
x = int(input())
ans = 1
for a in range(1,x+1):
  for b in range(2,x+1):
    if a**b > x:
      break
    elif a**b > ans:
      ans = a**b
print(ans)
Problem:
There are N stones arranged in a row. Every stone is painted white or black. A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is `.`, and the stone is black if the character is `#`.  Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone. Find the minimum number of stones that needs to be recolored.

Incorrect submission (verdict: Wrong Answer):
N=int(input())
S=input()
list1=[0]*N
for i in reversed(range(N)):
    if i==N-1 and S[i]==".":
        list1[i]+=1
    elif i==N-1:
        list1[i]=0
    elif S[i]==".":
        list1[i]=list1[i+1]+1
    else:
        list1[i]=list1[i+1]
print(list1)    
list2=[]
for i in range(N+1):
    if i==0:
        tmp=N-list1[0]
    elif i==N:
        tmp=list1[0]
    else:
        tmp=i-list1[0]+2*list1[i]
    print(tmp)
    list2.append(tmp)
print(min(list2))

Fixed, accepted submission:
N=int(input())
S=input()
list1=[0]*N
for i in reversed(range(N)):
    if i==N-1 and S[i]==".":
        list1[i]+=1
    elif i==N-1:
        list1[i]=0
    elif S[i]==".":
        list1[i]=list1[i+1]+1
    else:
        list1[i]=list1[i+1]   
list2=[]
for i in range(N+1):
    if i==0:
        tmp=N-list1[0]
    elif i==N:
        tmp=list1[0]
    else:
        tmp=i-list1[0]+2*list1[i]
    list2.append(tmp)
print(min(list2))
Problem:
You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974".

Incorrect submission (verdict: Wrong Answer):
def resolve():
   l=list(map(int, input().split()))
   if 1 in l and 9 in l and 7 in l and 4 in l:
       print('YES')
   else:
       print('NO')


Fixed, accepted submission:

import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    l=set(map(int,input().split()))
    if l=={1,7,9,4}:
        print('YES')
    else:
        print('NO')
resolve()
Problem:
There is a data which provides heights (in meter) of mountains. The data is only for ten mountains.  Write a program which prints heights of the top three mountains in descending order.

Incorrect submission (verdict: Wrong Answer):
m = []
for i in range(0, 10):
    m.append(input())
m.sort(reverse=True)
for i in range(0, 3):
    print(m[i])

Fixed, accepted submission:
m = []
for i in range(0, 10):
    m.append(int(input()))
m.sort(reverse=True)
for i in range(0, 3):
    print(m[i])
Problem:
You are given an integer N.  Find a triple of positive integers h, n and w such that 4/N = 1/h + 1/n + 1/w.  If there are multiple solutions, any of them will be accepted.

Incorrect submission (verdict: Wrong Answer):
def main():
    N = int(input())

    for h in range(N, 0, -1):
        for n in range(N, 0, -1):
            w = int((4 - N / h - N / n) * N)
            if w <= 0:
                continue
            elif N / h + N / n + N / w == 4:
                print(h, n, w)
                return

main()


Fixed, accepted submission:
def main():
    N = int(input())

    for h in range(1, 3501):
        for n in range(1, 3501):
            x = 4 * h * n - N * n - N * h
            if x <= 0: continue
            w, mod_ = divmod(N * h * n, x)
            if not mod_:
                print(h, n, w)
                return

main()
Problem:
You have an integer variable x. Initially, x=0.  Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`.  Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).

Incorrect submission (verdict: Wrong Answer):
N = int(input())
S = input()
x = 0
ans = 0
for l in S:
	if l == "I":
		x += 1
	elif l == "D":
		x -= 1
	ans = max(ans,x)

Fixed, accepted submission:
N = int(input())
S = input()
x = 0
ans = 0
for l in S:
	if l == "I":
		x += 1
	elif l == "D":
		x -= 1
	ans = max(ans,x)
print(ans)
Problem:
Takahashi, who works at DISCO, is standing before an iron bar. The bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters.  Takahashi wanted to choose a notch and cut the bar at that point into two parts with the same length. However, this may not be possible as is, so he will do the following operations some number of times **before** he does the cut:    * Choose one section and expand it, increasing its length by 1 millimeter. Doing this operation once costs 1 yen (the currency of Japan).   * Choose one section of length at least 2 millimeters and shrink it, decreasing its length by 1 millimeter. Doing this operation once costs 1 yen.  Find the minimum amount of money needed before cutting the bar into two parts with the same length.

Incorrect submission (verdict: Wrong Answer):
from itertools import accumulate


N = int(input())
A = [0] + list(accumulate(map(int, input().split())))
print(A)
min_diff = float("inf")
for i in range(N - 1):
    if abs(A[N] - 2 * A[i + 1]) < min_diff:
        min_diff = abs(A[N] - 2 * A[i + 1])
print(abs(min_diff))


Fixed, accepted submission:
from itertools import accumulate


N, *A = map(int, open(0).read().split())
A_acc = list(accumulate(A, initial=0))
min_diff = float("inf")
for i in range(1, N):
    left, right = A_acc[i], A_acc[N] - A_acc[i]
    min_diff = min(min_diff, abs(right - left))
print(min_diff)
Problem:
The problem set at _CODE FESTIVAL 20XX Finals_ consists of N problems.  The score allocated to the i-th (1≦i≦N) problem is i points.  Takahashi, a contestant, is trying to score exactly N points. For that, he is deciding which problems to solve.  As problems with higher scores are harder, he wants to minimize the highest score of a problem among the ones solved by him.  Determine the set of problems that should be solved.

Incorrect submission (verdict: Wrong Answer):
from sys import stdin
n = int(stdin.readline().rstrip())
point = 0
for i in range(1,n+1):
    point += i
    if point >= n:
        print(i)
        if n-i != 0:
            print(n-i)
        break

Fixed, accepted submission:
from sys import stdin
n = int(stdin.readline().rstrip())
point = 0
for i in range(1,n+1):
    point += i
    if point >= n:
        sa = point-n
        for k in [j for j in range(1,i+1) if j != sa]:print(k)
        break
Problem:
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery.  Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence.  Here, the distance between two points s and t on a number line is represented by |s-t|.

Incorrect submission (verdict: Wrong Answer):
#ABC71
x, a, b = map(int, input().split())

if(abs(x-a)>(abs(x-b))):
    print("A")
else:
    print("B")

Fixed, accepted submission:
#ABC71
x, a, b = map(int, input().split())

if(abs(x-a)>(abs(x-b))):
    print("B")
else:
    print("A")
Problem:
AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of   AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.

Incorrect submission (verdict: Wrong Answer):
w,a,b=map(int,input().split())
if a>b:
  t=a
  a=b
  b=t
if b-a<abs(b-a-w)+1:
  print(b-a)
else:
  print(abs(b-a-w)+1)


Fixed, accepted submission:
w,a,b=map(int,input().split())
if a>b:
  t=a
  a=b
  b=t
if a<=b<=a+w:
  print(0)
else:
  print(b-a-w)
Problem:
We have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j).   Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= `#`, and to make Square (i, j) white when s_{i, j}= `.`.   However, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black.   Determine if square1001 can achieve his objective.

Incorrect submission (verdict: Wrong Answer):
h,w=map(int,input().split())
list1=[[0 for i in range(w)]for j in range(h)]
list2=[[0 for i in range(w)]for j in range(h)]
dx=[-1,-1,0,0]
dy=[0,0,-1,1]
a=0
for j in range(h):
 s=input()
 for i in range(w):
  list1[j][i]=s[i]
for j in range(h):
  for i in range(w):
   if list1[j][i]=="#":
    for k in range(4):
     xk=i+dx[k]
     yk=j+dy[k]
     if xk>=0 and xk<w and yk>=0 and yk<h:
      list2[yk][xk]+=1
for j in range(h):
  for i in range(w):
    if list1[j][i]=="#" and list2[j][i]==0:
     None
    else:
     a+=1
if a==h*w:
 print("Yes")
else:
 print("No")


Fixed, accepted submission:
h,w=map(int,input().split())
list1=[[0 for i in range(w)]for j in range(h)]
list2=[[0 for i in range(w)]for j in range(h)]
dx=[-1,1,0,0]
dy=[0,0,-1,1]
a=0
for j in range(h):
 s=input()
 for i in range(w):
  list1[j][i]=s[i]
for j in range(h):
  for i in range(w):
   if list1[j][i]=="#":
    for k in range(4):
     xk=i+dx[k]
     yk=j+dy[k]
     if xk>=0 and xk<w and yk>=0 and yk<h:
      list2[yk][xk]+=1
for j in range(h):
  for i in range(w):
    if list1[j][i]=="#" and list2[j][i]==0:
     None
    else:
     a+=1
if a==h*w:
 print("Yes")
else:
 print("No")
Problem:
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once.  Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.

Incorrect submission (verdict: Wrong Answer):
S=input()
K=list('keyence')
n=0
flg=0
i_cut=[0,0]
for i,c in enumerate(S):
  if c==K[n]:
    if flg==1:
      i_cut[1] = i-1
      break 
    n+=1
    if n>=7:
      if flg==0:
        i_cut = [i+1,len(S)]
        break  
  else:
    if flg==0:
      i_cut[0] = i
      flg +=1
 
if S[:i_cut[0]]+S[1+i_cut[1]:]=='keyence':
  print("Yes")
else:
  print('No')

Fixed, accepted submission:
S=input()
N=len(S)
for i in range(0,N+1):
    for j in range(i,N+1):
        if  S[:i] + S[j:] == 'keyence':
            print("YES")
            exit(0)
else:
    print('NO')
Problem:
We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions:    * Question 1: Are you subscribing to Newspaper X?   * Question 2: Are you subscribing to Newspaper Y?  As the result, A respondents answered "yes" to Question 1, and B respondents answered "yes" to Question 2.  What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y?  Write a program to answer this question.

Incorrect submission (verdict: Wrong Answer):
N, A, B = list(map(int, input().split()))
print(min(A, B), abs(A - (N - B)))


Fixed, accepted submission:
N, A, B = list(map(int, input().split()))
print(min(A, B), max(A + B - N, 0))
Problem:
Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No".

Incorrect submission (verdict: Wrong Answer):
a,b,c = map(int,input().split())

if a<b<c:
   print('yes')
else:
   print('no')

Fixed, accepted submission:
a,b,c = map(int,input().split())

if a<b<c:
  print('Yes')
else:
  print('No')
Problem:
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.  She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).  However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.  Find the amount of money that she will hand to the cashier.

Incorrect submission (verdict: Time Limit Exceeded):
n,k = input().split()
d = list(map(int,input().split()))
num = [i for i in range(10)]
poss = list(set(d) ^ set(num))
an = int(n)
while True:
    sum = 0
    for p in poss:
        sum += n.count(str(p))
    if sum ==len(n):
        break
    else:
        an +=1
print(an)

Fixed, accepted submission:
n,k = map(int,input().split())
d=set(input().split())
while True:
    if len(set(str(n))&d)!=0:
        n+=1
    else:
        break
print(n)
Problem:
Write a program which reads two integers x and y, and prints them in ascending order.

Incorrect submission (verdict: Wrong Answer):
while True:
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        break
    if a > b:
        print(a, b)
    elif a < b:
        print(b, a)

Fixed, accepted submission:
while True:
    x = list(map(int, input().split()))
    if x[0] == 0 and x[1] == 0:
        break
    else:
        x.sort()
        print(" ".join(map(str, x)))
Problem:
Write a program which reads two integers x and y, and prints them in ascending order.

Incorrect submission (verdict: Wrong Answer):
while True:
  a,b = map(int, input().split())
  if a == 0 and b == 0: break
  if a > b:
    print(b, a)
else:
    print(a, b)


Fixed, accepted submission:
a_list=[]
b_list=[]
while True:
  a,b = map(int, input().split())
  if a == 0 and b == 0: 
    break
  a_list.append(a)
  b_list.append(b)


  

for (alist, blist) in zip(a_list,b_list):
  if alist < blist:
    print(alist, blist)
  else:
    print(blist,alist)
Problem:
There are N positive integers written on a blackboard: A_1, ..., A_N.  Snuke can perform the following operation when all integers on the blackboard are even:    * Replace each integer X on the blackboard by X divided by 2.  Find the maximum possible number of operations that Snuke can perform.

Incorrect submission (verdict: Wrong Answer):
ans=10**9
n=int(input())
s=list(map(int,input().split()))
for i in s:
    p=0
    while i%2==0:
        i//=2
        p+=1
    if p<ans:
        ans=p
print(p)

Fixed, accepted submission:
ans=10**9
n=int(input())
s=list(map(int,input().split()))
for i in s:
    p=0
    while i%2==0:
        i//=2
        p+=1
    if p<ans:
        ans=p
print(ans)
Problem:
There is an empty array. The following N operations will be performed to insert integers into the array. In the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array. Find the K-th smallest integer in the array after the N operations. For example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.

Incorrect submission (verdict: Wrong Answer):
def nyu():
    N,K = map(int,input().split())
    A = [list(map(int,input().split())) for _ in range(N)]
    return N,K,A

def kansu(N,K,A):
    
    sum = 0
    ans = -1


    for a in range(len(A)):
        sum += A[a][1]
        if (K >= sum):
            ans = A[a][0]
            break
    print(ans)




N,K,A = nyu()
kansu(N,K,A)

Fixed, accepted submission:
def nyu():
    N,K = map(int,input().split())
    A = [list(map(int,input().split())) for _ in range(N)]
    A.sort()
    return N,K,A

def kansu(N,K,A):
    
    sum = 0
    ans = -1


    for a in range(len(A)):
        sum += A[a][1]
#        print(sum,A[a][1])
        if (K <= sum):
            ans = A[a][0]
            break
    print(ans)




N,K,A = nyu()
kansu(N,K,A)
Problem:
There are N rabbits, numbered 1 through N.  The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i.  For a pair of rabbits i and j (i＜j), we call the pair (i，j) a _friendly pair_ if the following condition is met.    * Rabbit i likes rabbit j and rabbit j likes rabbit i.  Calculate the number of the friendly pairs.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(n):
  for j in range(n):
    if a[i]==j+1 and a[j]==i+1:
      cnt+=1
    else:
      cnt=cnt
if cnt>n:
  print(cnt-n)
else:
  print(0)
      

Fixed, accepted submission:
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(n):
    if a[a[i]-1]==i+1:
      cnt+=1
    else:
      cnt=cnt
print(cnt//2)
Problem:
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b.  Determine whether the arrangement of the poles is beautiful.

Incorrect submission (verdict: Wrong Answer):





a,b,c = map(int,input().split())

if b-a == c-b:
    print('Yes')
else:
    print('No')


Fixed, accepted submission:





a,b,c = map(int,input().split())

if b-a == c-b:
    print('YES')
else:
    print('NO')
Problem:
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.

Incorrect submission (verdict: Wrong Answer):
x = int(input())

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

print(ans)

Fixed, accepted submission:
x = int(input())

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

print(ans)