Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02719 (python)

Fixed submission:
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 fractions import gcd
 
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

N, K = MAP()

if N <= K:
    print(min(K-N, N))
# elif K == 1:
#     print(0)
else:
    print(min(N % K, K - N % K))
    # a = N // K
    # b = ceil(N / K)
    # c = N % K
    # print(a, b, c)
    # print(abs(c-K), abs(c))

    # x = N // (N - K)
    # y = x + 1
    # z = x - 1
    # print(x, y, z)
    # a = N - x * (N-K)
    # b = N - y * (N-K)
    # c = N - z * (N-K)
    # print(a, b, c)
    # ans = min(abs(a), abs(b), abs(c))
    # print(ans)

# if N >= K:
#     ans = min(abs(a), abs(b))
# # K > N:
# else:
#     ans = min(K-N, N)
# print(ans)

Buggy submission (verdict: Runtime Error):
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 fractions import gcd
 
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

N, K = MAP()

a = N // K
b = ceil(N / K)
# print(a, b)
c,d = N-a, N-b
# print(c,d)
# print(N-c,N-d)

#
x = N // (N - K)
y = x+1
# print(x, y)
a = N - x * (N-K)
b = N - y * (N-K)
# print(a, b)

# print(min(abs(a), abs(b)))

if N < K:
    print(min(K-N, N))
elif K == 1:
    print(0)
else:
    ans = min(abs(a), abs(b))
    print(ans)

# if N >= K:
#     ans = min(abs(a), abs(b))
# # K > N:
# else:
#     ans = min(K-N, N)
# print(ans)
Problem p02783 (python)

Fixed submission:
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 fractions import gcd
from bisect import bisect
 
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

def main():
    h, a = MAP()
    count = 0
    while h > 0:
        h = h - a
        count += 1
    print(count)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
# No DP No LIFE
# 配るDP, 要復習
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 fractions import gcd
from bisect import bisect
 
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

def main():
    H, N = MAP()
    L = [LIST() for i in range(N)]
    A = []
    B = []
    for i in range(N):
        A.append(L[i][0])
        B.append(L[i][1])

    dp = [INF] * 20010
    dp[0] = 0
    for i in range(10010):
        for j in range(N):
            dp[i+A[j]] = min(dp[i+A[j]], dp[i]+B[j])
    ans = INF
    for i in range(H, 20010):
        ans = min(ans, dp[i])
    print(ans)

if __name__ == "__main__":
    main()
Problem p02802 (python)

Fixed submission:
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 fractions import gcd
 
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

# 最大公約数 
def gcd(a, b):
  if a < b:
      a, b = b, a
  while a % b != 0:
      a, b = b, a % b
  return b

# 最小公倍数
def lcm(a, b):
  y = a*b / gcd(a, b)
  return int(y)

n, m = MAP()


L = []
for i in range(m):
  l = S_LIST()
  L.append(l)

# wa

wa = [0] * n
ac = [0] * n


for i in range(m):
  p = int(L[i][0])-1
  ans = L[i][1]
  if ans == "WA":
    # まだacない
    if ac[p] == 0:
      wa[p] = wa[p] + 1
  # acあった
  if ans == "AC":
    ac[p] = 1

for i in range(n):
  if ac[i] == 0:
    if wa[i] > 0:
      wa[i] = 0


print(sum(ac), sum(wa))


# for p in range(1, n+1):
#   if L[i][0] == str(p):
#     for i in range(m):
#       if L[i][1] == "WA":
#         wa += 1

#     for i in range(m):
#       if L[i][1] == "AC":
#         ac += 1
#   print(wa)
#   print(ac)

Buggy submission (verdict: Runtime Error):
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 fractions import gcd
 
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

# 最大公約数 
def gcd(a, b):
  if a < b:
      a, b = b, a
  while a % b != 0:
      a, b = b, a % b
  return b

# 最小公倍数
def lcm(a, b):
  y = a*b / gcd(a, b)
  return int(y)

n, m = MAP()


L = []
for i in range(m):
  l = S_LIST()
  L.append(l)

# wa

wa = [0] * n
ac = [0] * n


for i in range(m):
  p = int(L[i][0])-1
  ans = L[i][1]
  if ans == "WA":
    # まだacない
    if ac[p] == 0:
      wa[p] = wa[p] + 1
  # acあった
  if ans == "AC":
    ac[p] = 1

for i in range(m):
  if ac[i] == 1:
    wa[i] = 0


print(sum(ac), sum(wa))


# for p in range(1, n+1):
#   if L[i][0] == str(p):
#     for i in range(m):
#       if L[i][1] == "WA":
#         wa += 1

#     for i in range(m):
#       if L[i][1] == "AC":
#         ac += 1
#   print(wa)
#   print(ac)
Problem p02838 (python)

Fixed submission:
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 fractions import gcd
 
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
 
N = INT()
A = LIST()
 
max_length = len("{:b}".format(max(A)))
 
cnt = [defaultdict(int) for _ in range(max_length)]
 
for i in range(N):
    num = "{:b}".format(A[i]).zfill(max_length)
    for j in range(len(num)):
        # [i桁目][numのj番目の数，(0 or 1)]
        # 0, 1 の数を数える
        cnt[max_length-1-j][num[j]] += 1
 
ans = 0
 
for i in range(max_length):
    # 1を左にiシフト(2 ** i 倍)
    # 桁内で0の個数 * 桁内で1の個数 が，XOR = 1になる数 (0 xor 1 = 1)
    ans = ans + (1 << i) * cnt[i]["0"] * cnt[i]["1"]
ans = ans % mod
print(ans)

Buggy submission (verdict: Runtime Error):
    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 fractions import gcd
     
    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
     
    N = INT()
    A = LIST()
     
    max_length = len("{:b}".format(max(A)))
     
    cnt = [defaultdict(int) for _ in range(max_length)]
     
    for i in range(N):
        num = "{:b}".format(A[i]).zfill(max_length)
        for j in range(len(num)):
            # [i桁目][numのj番目の数，(0 or 1)]
            # 0, 1 の数を数える
            cnt[max_length-1-j][num[j]] += 1
     
    ans = 0
     
    for i in range(max_length):
        # 1を左にiシフト(2 ** i 倍)
        # 桁内で0の個数 * 桁内で1の個数 が，XOR = 1になる数 (0 xor 1 = 1)
        ans = ans + (1 << i) * cnt[i]["0"] * cnt[i]["1"]
    ans = ans % mod
    print(ans)
Problem p02921 (python)

Fixed submission:
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 fractions import gcd
 
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

S = list(input())
T = list(input())

count = 0
for i in range(len(S)):
    if S[i] == T[i]:
        count += 1
# a, b = MAP()
# n = INT()
# a, b, c = MAP()

print(count)

Buggy submission (verdict: Runtime Error):
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 fractions import gcd
 
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

a, b = MAP()
ans = 0
if b == 1:
    print(ans)
    exit()

while(1):

    if ans == 0:
        b -= a
        ans += 1
    else:
        if b <= 0:
            print(ans)
            exit()
        else:
            b -= (a-1)
            ans += 1

    

# n = INT()
# a, b, c = MAP()
# ans = 1
# # count = 0
# count = a
# flag = False
# # for i in range(30):
# while flag == False:
#     if count >= b:
#         flag = True    
#     else:
#         count += a-1
#         ans += 1
# print(ans)





# k = 1
# count = 0
# ans = 0
# A = []


# count += a
# ans += 1


# while(1):
#     if count >= b:
#         print(ans)
#         exit()
#     else:
#         count += a-1
#         ans += 1
#         # print()




# count += a
# ans += 1

# for i in range(100):
#     if b <= count:
#         print(ans)
#         exit()

#     else:
#         count += a-1
#         ans += 1 
#         # print(ans)

# for i in range(30):
# while(1):
#     count += a
#     ans += 1
#     print(count)

#     if b <= count:
#         print(ans)
#         exit()
#     else:   
#         count = count-1
#     # print(ans)
    
    # # A.append(a)
    # # if sum(A)
    # if count == 0:
    #     count += a
    #     ans += 1
    # else:
    #     count += a-1
    #     ans += 1
    # print(count)
    # print(ans)
    # if b<=count:
    #     # print(count)
    #     print(ans)
    #     exit()
Problem p02983 (python)

Fixed submission:
l, r = map(int, input().split())
# 2019
if r - l >= 2019:
	print(0)

# この数の中に2019が含まれている．
# 2019 * 2019 - 2019 

else:
	ans = 10000
	for i in range(l, r + 1):
		for j in range(i + 1, r + 1):
			ans = min(ans, (i * j) % 2019)
	print(ans)

Buggy submission (verdict: Runtime Error):
l, r = map(int, input().split())
ans = 2020
a = l // 2019
b = r // 2019
ans = []
# print(a)
# print(b) # 2019 num
if a != b:
    print(0)
else:
    for i in range(l, r+1):
        ans.append(i % 2019)
    
ans.sort()
print(ans[0] * ans[1])
    #l.append()
# print(a, b)


# if l // 2019 != r // 2019:
#     #print(0)
# else:
#     a = l % 2019
#     b = l % 2019 + 1
#     print(a * b)
#     # b = r % 2019
    

# if r - l >= 2019:
#     print(0)
# # else:
#     for i in range(l,r + 1):
#         for j in range(i+1,r + 1):
#             if (i * j) % 2019 <= ans:
#                 ans = min(ans, (i * j) % 2019)
#     print(ans)




    #print(i)
Problem p03059 (python)

Fixed submission:
A,B,T=map(int,input().split())
t=T+0.5
t=int(t)
a=int(t/A)
print(a*B)

Buggy submission (verdict: Runtime Error):
A,B,T=map(int,input().split())
t=T+0.5
count=0

for i in range(1,t):
    if A*i<=t:
        count+=B    
    
print(count)
Problem p03069 (python)

Fixed submission:
# 累積和次は倒す
N = int(input())
S = input()
ans = 10 ** 9
white = [0] * (N + 1)
black = [0] * (N + 1)

for i, c in enumerate(S):
    if c == ".":
        white[i + 1] = white[i] + 1
        black[i + 1] = black[i]
    else:
        white[i + 1] = white[i]
        black[i + 1] = black[i] + 1
# 累積和
ans = min(ans, black[N], white[N])

white_sum = white[N]

for i in range(1, N):
    a = white_sum - white[i]
    b = black[i]
    # a 境目より右領域にどれだけ白があるか，その白は黒に変更
    # b 境目より左領域にどれだけ黒があるか，その黒は白に変更
    cnt = a + b
    ans = min(ans, cnt)
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=list(input())
dot=0
sha=0
s_r=list(reversed(S))
#print(s_r)
for i in range(N):
    if S[i] == ".":
        dot=i
        #break
for i in range(N):
    if s_r[i] == "#":
        sha=i
        #break

count=0
#print(dot)#左から
#print(sha)#右から
count_a=0
count_b=0

for i in range(N):
    if i<dot and S[i]!=".":
        count_a+=1
for i in range(N):
    if i<sha and s_r[i]!="#":
        count_b+=1
#print(count)
if dot<=sha:
    c=count_a+count_b
else:
    d=min(count_a,count_b)

a=0
b=0

for i in range(N):
    if S[i]!=".":
        a+=1
    if S[i]!="#":
        b+=1

#print(count)
ans=min(a,b,c,d)
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=list(input())
dot=0
sha=0
s_r=list(reversed(S))
#print(s_r)
for i in range(N):
    if S[i] == ".":
        dot=i
        #break
for i in range(N):
    if s_r[i] == "#":
        sha=i
        #break

count=0
#print(dot)#左から
#print(sha)#右から
count_a=0
count_b=0

if dot<=sha:
    for i in range(N):
        if i<dot and S[i]!=".":
            count_a+=1
    for i in range(N):
        if i<sha and s_r[i]!="#":
            count_b+=1
    #print(count)
    c=count_a+count_b
else:
    d=min(count_a,count_b)

a=0
b=0

for i in range(N):
    if S[i]!=".":
        a+=1
    if S[i]!="#":
        b+=1

#print(count)
ans=min(a,b,c,d)
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=list(input())
dot=0
sha=0
s_r=list(reversed(S))
#print(s_r)
for i in range(N):
    if S[i] == ".":
        dot=i
        #break
for i in range(N):
    if s_r[i] == "#":
        sha=i
        #break

count=0
#print(dot)#左から
#print(sha)#右から
count_a=0
count_b=0

if dot<=sha:
    for i in range(N):
        if i<dot and S[i]!=".":
            count_a+=1
    for i in range(N):
        if i<sha and s_r[i]!="#":
            count_b+=1
    #print(count)
    c=count_a+count_b
else:
    d=min(count_a,count_b)

a=0
b=0

for i in range(N):
    if S[i]!=".":
        a+=1
    if S[i]!="#":
        b+=1

#print(count)
ans=min(a,b,c,d)
print(ans)
Problem p03106 (python)

Fixed submission:
a,b,k=map(int,input().split())
c=max(a,b)
l=[]
for i in range(1,c+1):
	if a%i==0 and b%i==0:
		l.append(i)
l.sort(reverse=True)
print(l[k-1])

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
c=max(a,b)
l=[]
for i in range(1,c):
	if a%i==0 and b%i==0:
		l.append(i)
l.sort(reverse=True)
print(l[k-1])

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
c=max(a,b)
l=[]
for i in range(c):
	if a%i==0 and b%i==0:
		l.append(i)
print(l[k-1])
Problem p03126 (python)

Fixed submission:
n,m=map(int,input().split())
c=set(list(range(1,m+1)))#from 1 to m+1 set {}
#print(c)
for i in range(n):
    l=list(map(int,input().split()))
    a=l[1:]
    #l[0] no mean
    c=c & set(a) # and > & 
    #print(c)
print(len(c))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
c=set(list(range(1,m+1)))#from 1 to m+1 set {}
#print(c)
for i in range(n):
    l=list(map(int,input().split()))
    a=l[1:]
    #l[0] no mean
    c=c & se t(a) # and > & 
    #print(c)
print(len(c))
Problem p03145 (python)

Fixed submission:
l=list(map(int,input().split()))
l.remove(max(l))
print(int(l[0]*l[1]/2))

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
cost=0
for i in range(n-1):
    if h[i]>h[i+1]:
        cost+=(h[i]-h[i+1])
    cost+=h[n-1]
print(cost)
Problem p03238 (python)

Fixed submission:
n=int(input())
if n==1:
    print('Hello World')
else:
    p=[int(input()) for i in range(n)]
    print(sum(p))

Buggy submission (verdict: Runtime Error):
N=int(input())
L=[list(map(int,input().split())) for i in range(N)]
x=[]
y=[]
h=[]
for l in L:
    x.append(l[0])
    y.append(l[1])
    h.append(l[2])
Cx=0
Cy=0
H=0

for i in range(101):#Cx
    for j in range(101):#Cy
        flag=True
        for k in range(N):
            if h[k]!=0:
                H=h[k]+abs(i-x[k])+abs(j-y[k])
                break

        for k in range(N):
            if h[k]!=max(H-abs(i-x[k])-abs(j-y[k]),0):
                flag=False
                break
        
        if flag==True:
            Cx,Cy=i,j
            break
    if flag==True:
        break
print("{} {} {}".format(Cx,Cy,H))
Problem p03309 (python)

Fixed submission:
#from collections import Counter
import math
N=int(input())
A=list(map(int,input().split()))
l=[]
n=1
for i in A:
    l.append(i-n)
    n+=1
l.sort()
#中央値
#切り捨て
c=int(math.floor(N/2))

ans_l=[]
ans=0
for j in l:
    ans+=abs(j-l[c])

print(ans)

Buggy submission (verdict: Runtime Error):
#from collections import Counter
import math
N=int(input())
A=list(map(int,input().split()))
l=[]
n=1
for i in A:
    l.append(i-n)
    n+=1
l.sort()
#中央値
#切り捨て
c=int(math.floor(N/2))
b=A[c]
ans_l=[]
ans=0
for j in l:
    ans+=abs(j-l[b])

print(ans)
Problem p03324 (python)

Fixed submission:
d,n=map(int,input().split())
if(n==100):
    n=101#100番目は100ではなく101になるので
print(n*pow(100,d))

Buggy submission (verdict: Runtime Error):
d,n=map(int,input().split())
if(n==100):
    n=101#100番目は100ではなく101になるので
print(m*pow(100,d))
Problem p03325 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
def count_two(num):
    flag=0
    count=0
    while flag==0:
        if num%2==0:
            count+=1
            num=int(num/2)
        else:
            flag=1
    return count

ans=0
for temp in A:
    ans+=count_two(temp)
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
l=[]
no_even=0
def no_even(A,N):
    flag=0
    for i in range(N):
        if A[i]%2==0:
            flag=1
            break
    if flag==0:
        return True
    else:
        return False

count=0

while no_even(A,N)==False:
    for i in range(N):
        if A[i]%2==0:
            l.append(A[i])
    flag=0
    for i in range(N):
        if A[i]==max(l) and flag==0:
            A[i]=int(A[i]/2)
            flag=1
        else:
            A[i]*=3
#    print(A)    
    count+=1
print(count)
Problem p03352 (python)

Fixed submission:
x=int(input())
m=int(x**0.5)
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)

Buggy submission (verdict: Runtime Error):
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 = []
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()