Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
S=input()
S_list=list(S)
num_B = S.count('W')
count = 0
for nb in range(num_B):
  i = nb
  while S_list[i] != 'W': i+=1
  count += i - nb
  S_list[nb],S_list[i]=S_list[i],S_list[nb]
print(count)

Fixed submission:
S=input()
S_list=list(S)
num_B = S.count('W')
count = 0
i = 0
for nb in range(num_B):
  while S_list[i] != 'W': i+=1
  count += i - nb
  S_list[nb],S_list[i]=S_list[i],S_list[nb]
  i+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
S=list(input())
count = 0
i = 0
while i+1<len(S):
  if S[i] == 'B' and S[i+1] == 'W':
    S[i],S[i+1]='W','B'
    i = 0
    count += 1
  else:
    i+=1
print(count)

Fixed submission:
S=input()
S_list=list(S)
num_B = S.count('W')
count = 0
i = 0
for nb in range(num_B):
  while S_list[i] != 'W': i+=1
  count += i - nb
  S_list[nb],S_list[i]=S_list[i],S_list[nb]
  i+=1
print(count)
Buggy python submission (verdict: Runtime Error):
5
30 44
26
18
81
18
6

Fixed submission:
import math
N=int(input())
D,X=map(int,input().split())
choco=[0]*D
ans=0
for _ in range(N):
  A=int(input())
  ans+=math.ceil(D/A)
print(ans+X)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
aN=list(map(int,input().split()))
aN.sort()
count =0
a_set=set(aN)
for a in a_set:
  acount=aN.count(a)
  if a <= acount:
    count+=acount-a
  else:
    count+=acount
print(count)

Fixed submission:
N=int(input())
aN=list(map(int,input().split()))
dic={}
for a in aN:
  if a in dic:
    dic[a] += 1
  else:
    dic[a] = 1
ans=0
for k,v in dic.items():
  if k > v:
    ans +=v
  else:
    ans+=v-k
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = []


def xyz():
    count = 0
    for i in range(1, 101):
        for j in range(1, 101):
            for k in range(1, 101):
                zyx = i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i
                ans.append(zyx)


xyz()
for i in range(n):
    print(ans.count(i + 1))


Fixed submission:
n = int(input())
ans = [0]*10**5


def xyz():
    count = 0
    for i in range(1, 101):
        for j in range(1, 101):
            for k in range(1, 101):
                zyx = i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i
                ans[zyx] += 1


xyz()
for i in range(n):
    print(ans[i+1])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = []


def xyz():
    count = 0
    for i in range(1, 110):
        for j in range(1, 110):
            for k in range(1, 110):
                zyx = i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i
                ans.append(zyx)


xyz()
for i in range(n):
    print(ans.count(i + 1))


Fixed submission:
n = int(input())
ans = [0]*10**5


def xyz():
    count = 0
    for i in range(1, 101):
        for j in range(1, 101):
            for k in range(1, 101):
                zyx = i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i
                ans[zyx] += 1


xyz()
for i in range(n):
    print(ans[i+1])

Buggy python submission (verdict: Time Limit Exceeded):
import math

n = int(input())

def xyz(n):
    count = 0
    for i in range(1, int(math.sqrt(n))):
        for j in range(1, int(math.sqrt(n))):
            for k in range(1, int(math.sqrt(n))):
                zyx = i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i
                if zyx == n:
                    count += 1
    return count


for i in range(n):
    print(xyz(i + 1))

Fixed submission:
n = int(input())
ans = [0]*10**5


def xyz():
    count = 0
    for i in range(1, 101):
        for j in range(1, 101):
            for k in range(1, 101):
                zyx = i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i
                ans[zyx] += 1


xyz()
for i in range(n):
    print(ans[i+1])
Buggy python submission (verdict: Runtime Error):
1 1
1000

Fixed submission:
n, k = map(int, input().split())
p = sorted(list(map(int, input().split())))
ans = 0
for i in range(k):
    ans += p[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n != 0:
    p = list(map(int, input().split()))
    if x in p:
        for i in range(-1000, 1001):
            print(i)
            if i == -100:
                mini = i
            if i in p:
                pass
            else:
                if abs(x - mini) > abs(x - i):
                    mini = i
                elif abs(x - mini) == abs(x - i):
                    mini = min(mini, i)
        else:
            print(mini)
    else:
        print(x)
else:
    print(x)


Fixed submission:
x, n = map(int, input().split())
if n != 0:
    p = list(map(int, input().split()))
    if x in p:
        for i in range(-1000, 1001):
            if i == -1000:
                mini = i
            if i in p:
                pass
            else:
                if abs(x - mini) > abs(x - i):
                    mini = i
                elif abs(x - mini) == abs(x - i):
                    mini = min(mini, i)
        else:
            print(mini)
    else:
        print(x)
else:
    print(x)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
now = 1
chk = [0] * n
flg = True
count = 0
chk[0] = 1
if k < 10 ** 5:
    for i in range(k):
        now = a[now - 1]
else:
    while flg:
        count += 1
        now = a[now - 1]
        if chk[now - 1] == 0:
            chk[now - 1] = count
        else:
            flg = False
            rem = (k - count) % (count - chk[now - 1])
    else:
        for i in range(rem):
            now = a[now - 1]
print(now)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
now = 1
chk = [0] * n
flg = True
count = 0
if k < 10 ** 7:
    for i in range(k):
        now = a[now - 1]
else:
    while flg:
        count += 1
        now = a[now - 1]
        if chk[now - 1] == 0 and now != 1:
            chk[now - 1] = count
        else:
            flg = False
            if (k - count) != 0 and (count - chk[now - 1]) != 0:
                rem = (k - count) % (count - chk[now - 1])
            else:
                rem = 0
    else:
        for i in range(rem):
            now = a[now - 1]
            count += 1
print(now)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))
now = 1
for i in range(k):
    now = a[now - 1]
print(now)


Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
now = 1
chk = [0] * n
flg = True
count = 0
if k < 10 ** 7:
    for i in range(k):
        now = a[now - 1]
else:
    while flg:
        count += 1
        now = a[now - 1]
        if chk[now - 1] == 0 and now != 1:
            chk[now - 1] = count
        else:
            flg = False
            if (k - count) != 0 and (count - chk[now - 1]) != 0:
                rem = (k - count) % (count - chk[now - 1])
            else:
                rem = 0
    else:
        for i in range(rem):
            now = a[now - 1]
            count += 1
print(now)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, n = map(int, input().split())
ans = 0
for i in range(n + 1):
    floor = int(a * i / b) - a * int(i / b)
    ans = max(ans,floor)
print(ans)

Fixed submission:
a, b, n = map(int, input().split())
x = min(n, b - 1)
ans = int(a * x / b) - a * int(x / b)
print(ans)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
sum = sum(a)
if n >= sum:
    print(n - sum)
else:
    print(-1)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
for i in range(n-1):
    ans[a[i] - 1] += 1
for i in range(n):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
s_list = list(s)
ans = 0
total = s_list.count("R") * s_list.count("G") * s_list.count("B")
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        for k in range(j + 1, n):
            if j - i == k - j:
                if (s_list[i] != s_list[j]) and (s_list[j] != s_list[k]) and (s_list[k] != s_list[i]):
                    ans +=1
print(total - ans)

Fixed submission:
n = int(input())
s = input()
s_list = list(s)
ans = 0
total = s_list.count("R") * s_list.count("G") * s_list.count("B")
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        k = j + j - i
        if n >= k + 1:
            if (s_list[i] != s_list[j]) and (s_list[j] != s_list[k]) and (s_list[k] != s_list[i]):
                ans += 1
print(total - ans)
Buggy python submission (verdict: Runtime Error):
H,W=map(int,input().split())
M = H * W
M2 = M // 2
modm = M % 2
if modm == 0:
    print(M2)
else:
    print(M2 + 1)

Fixed submission:
N = int(input())
Lists = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(Lists[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int, input().split()))
ans = 0
i = 0
while n > i:
    wk = 0
    count = 0
    j = 0
    while wk == count and i >= j:
        if p[j] >= p[i]:
            wk += 1
        count += 1
        j += 1
    if wk == count:
        ans += 1
    i += 1
print(ans)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
for i in range(n):
    if i == 0:
        ans = 1
        minp = p[i]
    elif minp >= p[i]:
        ans += 1
        minp = min(minp,p[i])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n):
    wk = 0
    count = 0
    for j in range(0,i):
        if p[j] >= p[i]:
            wk += 1
        count += 1
    if wk == count:
        ans += 1
print(ans)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
for i in range(n):
    if i == 0:
        ans = 1
        minp = p[i]
    elif minp >= p[i]:
        ans += 1
        minp = min(minp,p[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())
win = []
ans = 0
for i in range(n):
    if t[i] == "r":
        win.append("p")
    elif t[i] == "s":
        win.append("r")
    else:
        win.append("s")
for i in range(n):
    if i >= k:
        if win[i] == win[i - k]:
            if i + k > n:
                pass
            elif win[i + k] != t[i]:
                win[i] = t[i]
            else:
                if win[i] != r and [i + k] != r:
                    win[i] = r
                elif win[i] != s and [i + k] != s:
                    win[i] = s
                elif win[i] != p and [i + k] != p:
                    win[i] = p
        else:
            if win[i] == "r":
                ans += r
            elif win[i] == "s":
                ans += s
            else:
                ans += p
    else:
        if win[i] == "r":
            ans += r
        elif win[i] == "s":
            ans += s
        else:
            ans += p
print(ans)

Fixed submission:
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())
win = []
ans = 0
for i in range(n):
    if t[i] == "r":
        win.append("p")
    elif t[i] == "s":
        win.append("r")
    else:
        win.append("s")
for i in range(n):
    if i >= k:
        if win[i] == win[i - k]:
            if i + k >= n:
                pass
            elif win[i + k] != t[i]:
                win[i] = t[i]
            else:
                if win[i] != r and [i + k] != r:
                    win[i] = r
                elif win[i] != s and [i + k] != s:
                    win[i] = s
                elif win[i] != p and [i + k] != p:
                    win[i] = p
        else:
            if win[i] == "r":
                ans += r
            elif win[i] == "s":
                ans += s
            else:
                ans += p
    else:
        if win[i] == "r":
            ans += r
        elif win[i] == "s":
            ans += s
        else:
            ans += p
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline

def main():
    n, m, k = map(int,input().split())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))

    asum = [0]*(n+1)
    bsum = [0]*(m+1)

    for i in range(n):
        asum[i+1] = asum[i] + a[i]

    for i in range(m):
        bsum[i+1] = bsum[i] + b[i]

    cnt = 0
    t = 0
    res = 0

    bb = 0
    for i in range(m):
        while bb < m and asum[i] + bsum[bb+1] <= k:
            cnt += 1
            t += bsum[bb+1] - bsum[bb]
            bb += 1

        res += (bb - i)

        if bb == i:
            bb += 1
        else:
            t -= asum[i]
            cnt -= 1

    print(res)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.buffer.readline

def main():
    n, m, k = map(int,input().split())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))

    asum = [0]*(n+1)
    bsum = [0]*(m+1)

    for i in range(n):
        asum[i+1] = asum[i] + a[i]

    for i in range(m):
        bsum[i+1] = bsum[i] + b[i]

    # jを小さくしていく発想がなかった
    j = m
    res = 0
    for i in range(n+1):
        # asumの分岐をさせてからbsumとの和を考えていく
        if asum[i] > k:
            break
        while asum[i] + bsum[j] > k:
            j -= 1
        
        res = max(res, j+i)
    print(res)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import math
abn = list(map(int,input().split()))

temp = 0

for x in range(abn[2] + 1):
    m = math.floor(abn[0] * x / abn[1]) - abn[0] * math.floor(x / abn[1])

    if m > temp:
        temp = m

print(temp)


Fixed submission:
import math
abn = list(map(int,input().split()))

x = min(abn[1] - 1, abn[2])
m = math.floor(abn[0] * x / abn[1]) - abn[0] * math.floor(x / abn[1])
print(m)
Buggy python submission (verdict: Runtime Error):
from scipy.misc.comb() import comb
a = list(map(int,input().split()))

print(scipy.misc.comb(a[0], 2, exact=True) + scipy.misc.comb(a[1], 2, exact=True))

Fixed submission:
import itertools
a = list(map(int,input().split()))

s = [i for i in range(a[0])]
t = [i for i in range(a[1])]

n = list(itertools.combinations(s, 2))
m = list(itertools.combinations(t, 2))

print(len(n) + len(m))

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb
a = list(map(int,input().split()))

print(comb(a[0], 2, exact=True) + comb(a[1], 2, exact=True))

Fixed submission:
import itertools
a = list(map(int,input().split()))

s = [i for i in range(a[0])]
t = [i for i in range(a[1])]

n = list(itertools.combinations(s, 2))
m = list(itertools.combinations(t, 2))

print(len(n) + len(m))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

s = 0
c = set()

for i in range(n):
    if a[i] not in c:
        num = a.count(a[i])
        s += num*(num-1) / 2
        c.add(a[i])

for i in range(n):
    print(int(s - (a.count(a[i]) - 1) ))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))

num_count = {}

for e in a:
    if e in num_count.keys():
        num_count[e] += 1
    else:
        num_count[e] = 1

s = 0
c = set()

for i in range(n):
    if a[i] not in c:
        num = num_count[a[i]]
        s += num*(num-1) / 2
        c.add(a[i])

for i in range(n):
    print(int(s - (num_count[a[i]] - 1) ))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int,input().split()))

count = 0
for i, elem in enumerate(p):
    if min(p[:i+1]) == elem:
        count += 1

print(count)


Fixed submission:
n = int(input())
p = list(map(int,input().split()))

count = 0
p_min = p[0]

for elem in p:
    if elem <= p_min:
        count += 1
        p_min = elem

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = list(map(int,input().split()))
a = list(map(int,input().split()))

for i in range(n[1]):
    a[a.index(max(a))] = int(max(a) / 2)

print(sum(a))

Fixed submission:
import heapq

n = list(map(int,input().split()))
a = list(map(int,input().split()))

#heapqでは最小値しか取り出せないので，*(-1)することで最大値を取り出す
for i in range(len(a)):
    a[i] *= -1

#リストを優先度付きキューにする
heapq.heapify(a)

for i in range(n[1]):
    #最小値(実際には最大値であるはずの値)を取り出す
    tmp = heapq.heappop(a)

    #取り出した値を2で割って切り下げで優先度付きキューに挿入
    heapq.heappush(a, int(tmp/2))

print(-sum(a))

'''
max()はO(N)．heapqはO(logN)
これだと発想はあっているが，O(NM)となるので間に合わない
for i in range(n[1]):
    a[a.index(max(a))] = int(max(a) / 2)

print(sum(a))
'''
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    h = list(map(int, input().split()))

    score = []

    j = 0
    for i in range(n-1):
        if i != 0:
            j = next_j
        cnt = 0
        while True:
            if j >= n-1 or h[j] < h[j+1]:
                score.append(cnt)
                next_j = j+1
                break
            else:
                h[j] >= h[j+1]
                cnt += 1
                j += 1

    print(max(score))

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n = int(input())
    h = list(map(int, input().split()))

    score = []

    j = 0
    for i in range(n-1):
        if i != 0:
            j = next_j
        cnt = 0
        while True:
            if j >= n-1 or h[j] < h[j+1]:
                score.append(cnt)
                next_j = j+1
                break
            else:
                h[j] >= h[j+1]
                cnt += 1
                j += 1

    if n == 1:
        print(0)
    else:
        print(max(score))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    h = list(map(int, input().split()))

    score = []

    for i in range(n-1):
        j = i
        cnt = 0
        while True:
            if j >= n-1 or h[j] < h[j+1]:
                score.append(cnt)
                break
            else:
                h[j] >= h[j+1]
                cnt += 1
                j += 1

    print(max(score))


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n = int(input())
    h = list(map(int, input().split()))

    score = []

    j = 0
    for i in range(n-1):
        if i != 0:
            j = next_j
        cnt = 0
        while True:
            if j >= n-1 or h[j] < h[j+1]:
                score.append(cnt)
                next_j = j+1
                break
            else:
                h[j] >= h[j+1]
                cnt += 1
                j += 1

    if n == 1:
        print(0)
    else:
        print(max(score))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    ans = 0

    for i in range(n-1):
        ans += i+1

    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n = int(input())

    # for i in range(n-1):
    #     ans += i+1

    # print(ans)

    print(((n-1) * n) // 2)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.buffer.readline

def main():
    n, k = map(int,input().split())
    h = list(map(int,input().split()))

    dp = [0]*n

    dp[1] = abs(h[1] - h[0])
    for i in range(2, n):
        dp[i] = dp[i-1] + abs(h[i] - h[i-1])
        for j in range(2, k+1):
            if i-j < 0:
                continue
            dp[i] = min(dp[i-j] + abs(h[i] - h[i-j]), dp[i])

    print(dp[-1])



if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.buffer.readline

def main():
    n, k = map(int,input().split())
    h = list(map(int,input().split()))

    dp = [0]*n

    dp[1] = abs(h[1] - h[0])
    for i in range(2, n):
        dp[i] = dp[i-1] + abs(h[i] - h[i-1])
        for j in range(2, k+1):
            if i-j < 0:
                continue
            dp[i] = min(dp[i-j] + abs(h[i] - h[i-j]), dp[i])

    print(dp[-1])



if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.buffer.readline

def main():
    n, w = map(int,input().split())
    wei = []
    val = []
    for i in range(n):
        a, b = map(int,input().split())
        wei.append(a)
        val.append(b)

    dp = [[0 for i in range(w+1)] for j in range(n+1)]

    for i in range(n):
        for sum_w in range(w+1):
            
            if sum_w - wei[i] >= 0:
                dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w - wei[i]] + val[i])

            
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])

    print(dp[n][w])


if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.buffer.readline

def main():
    n, w = map(int,input().split())
    wei = []
    val = []
    for i in range(n):
        a, b = map(int,input().split())
        wei.append(a)
        val.append(b)

    dp = [[0 for i in range(w+1)] for j in range(n+1)]

    for i in range(n):
        for sum_w in range(w+1):
            
            if sum_w - wei[i] >= 0:
                dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w - wei[i]] + val[i])

            
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])

    print(dp[n][w])


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.buffer.readline

def main():
    n, w = map(int,input().split())
    wei = []
    val = []
    for i in range(n):
        a, b = map(int,input().split())
        wei.append(a)
        val.append(b)

    max_v = 10**5 + 10
    dp = [[float('inf') for i in range(max_v)] for j in range(100+10)]

    dp[0][0] = 0

    for i in range(n):
        for sum_v in range(max_v):

            # i 番目の品物を選ぶ場合
            if sum_v - val[i] >= 0:
                dp[i+1][sum_v] = min(dp[i][sum_v], dp[i][sum_v - val[i]] + wei[i])
            else:
                # i 番目の品物を選ばない場合
                dp[i+1][sum_v] = dp[i][sum_v]

    res = 0
    for i in range(100+10):
        for sum_v in range(max_v):
            if dp[i][sum_v] <= w and res < sum_v:
                res = sum_v

    print(res)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.buffer.readline

def main():
    n, w = map(int,input().split())
    wei = []
    val = []
    for i in range(n):
        a, b = map(int,input().split())
        wei.append(a)
        val.append(b)

    max_v = 10**5 + 10
    dp = [[float('inf') for i in range(max_v)] for j in range(100+10)]

    dp[0][0] = 0

    for i in range(n):
        for sum_v in range(max_v):

            # i 番目の品物を選ぶ場合
            if sum_v - val[i] >= 0:
                dp[i+1][sum_v] = min(dp[i][sum_v], dp[i][sum_v - val[i]] + wei[i])
            else:
                # i 番目の品物を選ばない場合
                dp[i+1][sum_v] = dp[i][sum_v]

    res = 0
    for i in range(100+10):
        for sum_v in range(max_v):
            if dp[i][sum_v] <= w and res < sum_v:
                res = sum_v

    print(res)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())

b = 1
p = 2

a = []

for i in range(x):
    for j in range(x):
        if (b+i) ** (p+j) <= x:
            a.append((b+i) ** (p+j))

print(max(a))

Fixed submission:
import sys
input = sys.stdin.buffer.readline

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

    b = 1
    p = 2

    a = []

    for i in range(int(x ** 0.5) + 1):
        for j in range(int(x ** 0.5) + 1):
            if (b+i) ** (p+j) <= x:
                a.append((b+i) ** (p+j))

    print(max(a))

if __name__ == '__main__':
    main()