Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
P = list(map(int,input().split()))

#print(N)
#print(P)

SUCCESS = N
pre_max = P[0]
pre_min = P[0]
for i in range(N):
    j = i - 1
    if pre_max < P[i]:
        #print(i, j, pre_max)
        pre_max = P[j]
        SUCCESS -= 1
        continue
    if pre_min < P[i]:
        #print(i, j, pre_min)
        #pre_min = P[j]
        SUCCESS -= 1
        continue
    while j >= 0:
        if pre_min > P[j]:
            pre_min = P[j]      
        if P[i] > P[j]:
            #print("Fail", i,j)
            SUCCESS -= 1
            break        
        j -= 1

print(SUCCESS)

Fixed submission:
N=int(input())
P = list(map(int,input().split()))

#print(N)
#print(P)

SUCCESS = N
pre_max = P[0]
pre_min = P[0]
for i in range(N):
    j = i - 1

    if pre_min < P[i]:
        SUCCESS -= 1
        continue
    else:
        pre_min = P[i]
print(SUCCESS)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
P = list(map(int,input().split()))

#print(N)
#print(P)

SUCCESS = N
pre_max = P[0]
for i in range(N):
    j = i - 1
    if pre_max < P[i]:
        #print(i, j, pre_max)
        pre_max = P[j]
        SUCCESS -= 1
        continue

    while j >= 0:        
        if P[i] > P[j]:
            #print("Fail", i,j)
            SUCCESS -= 1
            break        
        j -= 1

print(SUCCESS)

Fixed submission:
N=int(input())
P = list(map(int,input().split()))

#print(N)
#print(P)

SUCCESS = N
pre_max = P[0]
pre_min = P[0]
for i in range(N):
    j = i - 1

    if pre_min < P[i]:
        SUCCESS -= 1
        continue
    else:
        pre_min = P[i]
print(SUCCESS)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
P = list(map(int,input().split()))

#print(N)
#print(P)

SUCCESS = N
for i in range(N):
    j = i - 1
    while j >= 0:
        if P[i] > P[j]:
            #print("Fail", i,j)
            SUCCESS -= 1
            break        
        j -= 1

print(SUCCESS)


Fixed submission:
N=int(input())
P = list(map(int,input().split()))

#print(N)
#print(P)

SUCCESS = N
pre_max = P[0]
pre_min = P[0]
for i in range(N):
    j = i - 1

    if pre_min < P[i]:
        SUCCESS -= 1
        continue
    else:
        pre_min = P[i]
print(SUCCESS)
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
n = int(input())

reverse_flag = False
for i in range(n):
    line = list(map(str, input().split()))
    if line[0] == '1':
        if reverse_flag:
            reverse_flag = False
        else:
            reverse_flag = True
    elif line[0] == '2':
        if line[1] == '1':
            if reverse_flag:
                s.append(line[2])
            else:
                s.insert(0, line[2])
        elif line[1] == '2':
            if reverse_flag:
                s.insert(0, line[2])
            else:
                s.append(line[2])

if reverse_flag:
    print(''.join(s[::-1]))
else:
    print(''.join(s))


Fixed submission:
s = list(input())
n = int(input())

reverse_flag = False
s_head = list()

for i in range(n):
    line = list(map(str, input().split()))
    if line[0] == '1':
        if reverse_flag:
            reverse_flag = False
        else:
            reverse_flag = True
    elif line[0] == '2':
        if line[1] == '1':
            if reverse_flag:
                s.append(line[2])
            else:
                s_head.append(line[2])
        elif line[1] == '2':
            if reverse_flag:
                s_head.append(line[2])
            else:
                s.append(line[2])

if reverse_flag:
    ans = s[::-1]
    ans.extend(s_head)
    print(''.join(ans))
else:
    ans = s_head[::-1]
    ans.extend(s)
    print(''.join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))

ans = 0
for i in range(n):
    if min(l[0:i + 1]) == l[i]:
        ans += 1
print(ans)


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

ans = 0
min_val = l[0]
for i in range(n):
    if min_val >= l[i]:
        ans += 1
        min_val = l[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

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

b_1 = x / (a ** 2)
area_1 = a * b_1
area_2 = (a * b) / 2

if area_2 > area_1:
    # 三角形
    h = (a * b_1 * 2) / b
    ans = math.degrees(math.atan(h / b))
else:
    # 梯形
    upside_len = b_1 * 2 - b
    ans = math.degrees(math.atan(a / (b - upside_len)))

print(90 - ans)


Fixed submission:
import math

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

b_1 = x / (a ** 2)
area_1 = a * b_1
area_2 = (a * b) / 2

if b_1 == b:
    ans = 90
elif area_2 > area_1:
    # 三角形
    h = (a * b_1 * 2) / b
    ans = math.degrees(math.atan(h / b))
else:
    # 梯形
    upside_len = b_1 * 2 - b
    ans = math.degrees(math.atan(a / (b - upside_len)))

print(90 - ans)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = list(input())

s_c = []

left = 0
right = 0
for i in range(n - 1):
    if s[i] == s[i + 1]:
        right = i + 1
    else:
        s_c.append(''.join(s[left:right + 1]))
        i += 1
        left = i
        right = i
s_c.append(''.join(s[left:right + 1]))

cc = 'R'
if s_c[1][0] == 'R':
    cc = 'L'

s_c_len = len(s_c)
for i in range(k):
    if (2 * i + 1) > s_c_len - 1:
        break
    s_c[2 * i + 1] = cc * len(s_c[2 * i + 1])

ans_s = ''.join(s_c)
ans = 0
for i in range(n):
    if ans_s[i] == 'R' and i != n - 1 and ans_s[i + 1] == 'R':
        ans += 1
    elif ans_s[i] == 'L' and i != 0 and ans_s[i - 1] == 'L':
        ans += 1
print(ans)


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

s_c = []

left = 0
right = 0
for i in range(n - 1):
    if s[i] == s[i + 1]:
        right = i + 1
    else:
        s_c.append(''.join(s[left:right + 1]))
        i += 1
        left = i
        right = i
s_c.append(''.join(s[left:right + 1]))

s_c_len = len(s_c)
cc = 'R'
if s_c_len > 1 and s_c[1][0] == 'R':
    cc = 'L'

for i in range(k):
    if (2 * i + 1) > s_c_len - 1:
        break
    s_c[2 * i + 1] = cc * len(s_c[2 * i + 1])

ans_s = ''.join(s_c)
ans = 0
for i in range(n):
    if ans_s[i] == 'R' and i != n - 1 and ans_s[i + 1] == 'R':
        ans += 1
    elif ans_s[i] == 'L' and i != 0 and ans_s[i - 1] == 'L':
        ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = list(input())

s_c = []

left = 0
right = 0
for i in range(n - 1):
    if s[i] == s[i + 1]:
        right = i + 1
    else:
        s_c.append(''.join(s[left:right + 1]))
        i += 1
        left = i
        right = i
s_c.append(''.join(s[left:right + 1]))

cc = 'R'
if s_c[1][0] == 'R':
    cc = 'L'
for i in range(k):
    s_c[2 * i + 1] = cc * len(s_c[2 * i + 1])

ans_s = ''.join(s_c)
ans = 0
for i in range(n):
    if ans_s[i] == 'R' and i != n - 1 and ans_s[i + 1] == 'R':
        ans += 1
    elif ans_s[i] == 'L' and i != 0 and ans_s[i - 1] == 'L':
        ans += 1
print(ans)


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

s_c = []

left = 0
right = 0
for i in range(n - 1):
    if s[i] == s[i + 1]:
        right = i + 1
    else:
        s_c.append(''.join(s[left:right + 1]))
        i += 1
        left = i
        right = i
s_c.append(''.join(s[left:right + 1]))

s_c_len = len(s_c)
cc = 'R'
if s_c_len > 1 and s_c[1][0] == 'R':
    cc = 'L'

for i in range(k):
    if (2 * i + 1) > s_c_len - 1:
        break
    s_c[2 * i + 1] = cc * len(s_c[2 * i + 1])

ans_s = ''.join(s_c)
ans = 0
for i in range(n):
    if ans_s[i] == 'R' and i != n - 1 and ans_s[i + 1] == 'R':
        ans += 1
    elif ans_s[i] == 'L' and i != 0 and ans_s[i - 1] == 'L':
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()

mod = 1000000007
n = 13

dp = [0] * 13
dp[0] = 1

mul = 1
for i in reversed(range(len(s))):
    nextDp = [0] * 13
    if s[i] == '?':
        for k in range(10):
            for j in range(n):
                nextDp[(k * mul + j) % n] += dp[j]
        for j in range(n):
            nextDp[j] %= mod
    else:
        k = int(s[i])
        for j in range(n):
            nextDp[(k * mul + j) % n] = dp[j]

    mul *= 10
    mul %= n
    dp = nextDp
print(dp[5] % mod)


Fixed submission:
s = input()

mod = 1000000007
n = 13

dp = [0] * 13
dp[0] = 1

mul = 1
for i in reversed(range(len(s))):
    nextDp = [0] * 13
    if s[i] == '?':
        for k in range(10):
            for j in range(n):
                nextDp[(k * mul + j) % n] += dp[j]
        for j in range(n):
            nextDp[j] %= mod
    else:
        k = int(s[i])
        for j in range(n):
            nextDp[(k * mul + j) % n] = dp[j]

    mul *= 10
    mul %= n
    dp = nextDp
print(dp[5])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()

mod = 1000000007
n = 13

dp = [0] * 13
dp[0] = 1

mul = 1
for i in reversed(range(len(s))):
    nextDp = [0] * 13
    if s[i] == '?':
        for k in range(10):
            for j in range(n):
                nextDp[(k * mul + j) % n] += dp[j]
                # nextDp[(k * mul + j) % n] %= mod
    else:
        k = int(s[i])
        for j in range(n):
            nextDp[(k * mul + j) % n] += dp[j]
            # nextDp[(k * mul + j) % n] %= mod

    mul *= 10
    mul %= n
    dp = nextDp
print(dp[5] % mod)


Fixed submission:
s = input()

mod = 1000000007
n = 13

dp = [0] * 13
dp[0] = 1

mul = 1
for i in reversed(range(len(s))):
    nextDp = [0] * 13
    if s[i] == '?':
        for k in range(10):
            for j in range(n):
                nextDp[(k * mul + j) % n] += dp[j]
        for j in range(n):
            nextDp[j] %= mod
    else:
        k = int(s[i])
        for j in range(n):
            nextDp[(k * mul + j) % n] = dp[j]

    mul *= 10
    mul %= n
    dp = nextDp
print(dp[5])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()

mod = 1000000007
n = 13

dp = [0] * 13
dp[0] = 1

mul = 1
for i in reversed(range(len(s))):
    nextDp = [0] * 13
    if s[i] == '?':
        for k in range(10):
            for j in range(n):
                nextDp[(k * mul + j) % n] += dp[j]
                nextDp[(k * mul + j) % n] %= mod
    else:
        k = int(s[i])
        for j in range(n):
            nextDp[(k * mul + j) % n] += dp[j]
            nextDp[(k * mul + j) % n] %= mod

    mul *= 10
    mul %= n
    dp = nextDp
print(dp[5])

Fixed submission:
s = input()

mod = 1000000007
n = 13

dp = [0] * 13
dp[0] = 1

mul = 1
for i in reversed(range(len(s))):
    nextDp = [0] * 13
    if s[i] == '?':
        for k in range(10):
            for j in range(n):
                nextDp[(k * mul + j) % n] += dp[j]
        for j in range(n):
            nextDp[j] %= mod
    else:
        k = int(s[i])
        for j in range(n):
            nextDp[(k * mul + j) % n] = dp[j]

    mul *= 10
    mul %= n
    dp = nextDp
print(dp[5])
Buggy python submission (verdict: Time Limit Exceeded):
l, r = map(int, input().split())

ans = 2019
for i in range(l, r):
    for j in range(i+1, r + 1):
        temp = i * j % 2019
        if temp < ans:
            ans = temp
print(ans)


Fixed submission:
import sys

l, r = map(int, input().split())

ans = 2019
for i in range(l, r):
    for j in range(i+1, r + 1):
        temp = i * j % 2019
        if temp < ans:
            ans = temp
        if ans == 0:
            print(0)
            sys.exit()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(m)]

if len(a) == 1:
    print(a[0][1] - a[0][0] + 1)
else:
    ans = n
    for i in range(1, n + 1):
        for j in range(m):
            if a[j][0] <= i <= a[j][1]:
                continue
            else:
                ans -= 1
                break
    print(ans)


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

left = []
right = []
for i in range(m):
    a, b = map(int, input().split())
    left.append(a)
    right.append(b)

if min(right) >= max(left):
    print(min(right) - max(left) + 1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
s = input()

dict = {'A': 'T', 'C': 'G'}
print(dict[s])


Fixed submission:
s = input()

dict = {'A': 'T', 'C': 'G', 'T': 'A', 'G': 'C'}
print(dict[s])
Buggy python submission (verdict: Time Limit Exceeded):
import math

[n,m] = [int(x) for x in input().split(" ")]
an = [int(x) for x in input().split(" ")]
an.sort(reverse=True)

for i in range(m):
    max_value = an[0]
    an[0] = max_value / 2
    an.sort(reverse=True)

discounted_an = [math.floor(x) for x in an]
print(sum(discounted_an))

Fixed submission:
import math

[n,m] = [int(x) for x in input().split(" ")]
an = [int(x) for x in input().split(" ")]
an.sort(reverse=True)

log2_an = [math.ceil(math.log2(x) + 1) for x in an]
max_log2 = log2_an[0]
rest_ticket = m

for i in range(max_log2):
    cnt = log2_an.count(log2_an[0])
    if(cnt <= rest_ticket):
        for j in range(cnt):
            an[j] = an[j] / 2
            log2_an[j] -= 1
    else:
        for j in range(rest_ticket):
            an[j] = an[j] / 2
        break
    rest_ticket -= cnt
    an.sort(reverse=True)

discounted_an = [math.floor(x) for x in an]
print(sum(discounted_an))
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
print(6 - a - b)

Fixed submission:
a = int(input())
b = int(input())
print(6 - a - b)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
ans = []
while n!=0 :
    ans.append(n % x)
    n = n // x
print(len(ans))

Fixed submission:
########関数部分##############
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out
############################
 
#####関数をつかってみる．#####
######今回は二進数に変換######

n, k = map(int, input().split())
n = Base_10_to_n(n, k)
print(len(n))
Buggy python submission (verdict: Time Limit Exceeded):
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

n, a, b = map(int, input().split())
p = 10 ** 9 + 7
ans = 0

for j in range(1, n+1) :
    if j == a or j == b :
        continue
    fact = [1, 1]
    factinv = [1, 1]
    inv = [0, 1]
    
    for i in range(2, n+1):
        fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)
    
    plus = cmb(n, j, p)
    ans += plus

print(int(ans))

Fixed submission:
n, a, b = map(int, input().split())
mod = 10**9 + 7

def comb(n, r, mod) :
    ans1 = 1
    ans2 = 1
    for i in range(r) :
        ans1 = (ans1 * (n-i)) % mod
        ans2 = (ans2 * (i+1)) % mod
    return ans1 * pow(ans2, mod-2, mod)

ans = pow(2, n, mod) - comb(n, a, mod) - comb(n, b, mod) - 1
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
def combination(a, b) :
    ans1 = 1
    ans2 = 1
    if a//2 < b :
        b = a-b
    for l in range(a, a-b, -1) :
        ans1 = (ans1*l)%(10**9+7)
    for m in range(1, b+1) :
        ans2 = (ans2*m)%(10**9+7)
    return ans1/ans2

ans = 0
n, a, b = map(int, input().split())
for i in range(1, n+1) :
    if i == a or i == b :
        continue
    plus = combination(n, i) % (10**9+7)
    ans = (ans+plus) % (10**9+7)
print(int(ans))

Fixed submission:
n, a, b = map(int, input().split())
mod = 10**9 + 7

def comb(n, r, mod) :
    ans1 = 1
    ans2 = 1
    for i in range(r) :
        ans1 = (ans1 * (n-i)) % mod
        ans2 = (ans2 * (i+1)) % mod
    return ans1 * pow(ans2, mod-2, mod)

ans = pow(2, n, mod) - comb(n, a, mod) - comb(n, b, mod) - 1
print(ans%mod)
Buggy python submission (verdict: Runtime Error):
wlist = []
for i in range(3) :
    w = input()
    if not w in wlist :
        wlist.append(w)
print(len(wlist))

Fixed submission:
a, b, c = map(int, input().split())
count = 0
if a != b :
    count += 1
if a != c :
    count += 1
if b != c :
    count += 1
if a == b == c :
    count =1
print(count)
Buggy python submission (verdict: Runtime Error):
a, b, h = [int(input()) for i in range(3)]
print(int((a+b)*h/2)

Fixed submission:
a, b, h = [int(input()) for i in range(3)]
print(int((a+b)*h/2))
Buggy python submission (verdict: Time Limit Exceeded):
sa = input().split()
sb = input().split()
sc = input().split()
turn = "a"
while True :
    if turn == "a" :
        if len(sa) == 0 :
            print("A")
            break
        turn = sa[0]
        sa = sa[1:]
    if turn == "b" :
        if len(sb) == 0 :
            print("B")
            break
        turn = sb[0]
        sb = sb[1:]
    if turn == "c" :
        if len(sc) == 0 :
            print("C")
            break
        turn = sc[0]
        sc = sc[1:]

Fixed submission:
sa = input()
sb = input()
sc = input()
ch = "a"
while True :
    if ch == "a" :
        if len(sa) == 0 :
            print("A")
            break
        ch = sa[0]
        sa = sa[1:]
    if ch == "b" :
        if len(sb) == 0 :
            print("B")
            break
        ch = sb[0]
        sb = sb[1:]
    if ch == "c" :
        if len(sc) == 0 :
            print("C")
            break
        ch = sc[0]
        sc = sc[1:]
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
list_num = [input() for i in range(k)]
price = n
while True :
    i = 0
    for i in range(len(str(price))) :
        if str(price)[i] in list_num :
            price += 1
            break
    else :
        print(price)
        break

Fixed submission:
n, k = map(int, input().split())
list_num = [i for i in input().split()]
price = n
while True :
    i = 0
    for i in range(len(str(price))) :
        if str(price)[i] in list_num :
            price += 1
            break
    else :
        print(price)
        break
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
print(n(n-1)//2 + m(m-1)//2)


Fixed submission:
n,m=map(int,input().split())
r=n*(n-1)//2 + m*(m-1)//2
print(r)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(s) for s in input().split()]
b=[0]*n
b[1]=abs(a[0]-a[1])
for i in range(2,n):
  b[i]=min(b[i-1]+abs(a[i]-a[i-1]),b[i-2]+as(a[i]-a[i-2]))
print(b[n-1])  

Fixed submission:
n=int(input())
a=[int(s) for s in input().split()]
b=[0]*n
b[1]=abs(a[0]-a[1])
for i in range(2,n):
    b[i]=min(b[i-1]+abs(a[i]-a[i-1]),b[i-2]+abs(a[i]-a[i-2]))
print(b[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())

for i in range(q):
  query = input()
  if query == '1':
    s = s[::-1]
  else:
    query = query.split()
    f, c = int(query[1]), query[2]
    if f == 1:
      s = c + s
    else:
      s = s + c
print(s)

Fixed submission:

s = input()
q = int(input())


is_reverse = False
pre_s = ""
suf_s = ""

for i in range(q):
  query = input()
  if query == '1':
    is_reverse = not is_reverse
  else:
    query = query.split()
    f, c = int(query[1]), query[2]
    if f == 1:
      if is_reverse:
        suf_s = suf_s + c
      else:
        pre_s = c + pre_s
    else:
      if is_reverse:
        pre_s = c + pre_s
      else:
        suf_s = suf_s + c

if is_reverse:
  print(suf_s[::-1] + s[::-1] + pre_s[::-1])
else:
  print(pre_s + s + suf_s)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = [int(x) for x in input().split()]

cnt = 0
while (cnt < k):
  cnt += 1
  if a > 0:
    a -= 1
  elif b > 0:
    b -= 1

print(a, b)

Fixed submission:
a, b, k = [int(x) for x in input().split()]
cnt = a + b - k

if a > k:
  print(a-k, b)
elif b > k-a:
  print(0, b -(k-a))
else:
  print(0, 0)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
hs = [int(x) for x in input().split()]

candidates = []

for i in range(n-1):
  if hs[i] >= hs[i+1]:
    candidates.append(i)

curr_height = 0
max_stepnum = 0
for start_point in candidates:
  stepnum = 0
  curr_height = hs[start_point]
  for i in range(start_point+1, n):
    if curr_height >= hs[i]:
      stepnum += 1
      curr_height = hs[i]
    else:
      break
  if stepnum > max_stepnum:
    max_stepnum = stepnum

print(max_stepnum)


Fixed submission:
n = int(input())
hs = [int(x) for x in input().split()]

curr_height = 0
max_stepnum = 0
start_point = 0

while start_point < n-1:
  stepnum = 0
  curr_height = hs[start_point]
  for i in range(start_point+1, n):
    if curr_height >= hs[i]:
      stepnum += 1
      curr_height = hs[i]
    else:
      start_point = i
      break
  else:
     start_point = n-1

  if stepnum > max_stepnum:
    max_stepnum = stepnum

print(max_stepnum)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
hs = [int(x) for x in input().split()]

curr_height = 0
max_stepnum = 0
for start_point in range(n):
  stepnum = 0
  curr_height = hs[start_point]
  for i in range(start_point+1, n):
    if curr_height >= hs[i]:
      stepnum += 1
      curr_height = hs[i]
    else:
      break
  if stepnum > max_stepnum:
    max_stepnum = stepnum

print(max_stepnum)


Fixed submission:
n = int(input())
hs = [int(x) for x in input().split()]

curr_height = 0
max_stepnum = 0
start_point = 0

while start_point < n-1:
  stepnum = 0
  curr_height = hs[start_point]
  for i in range(start_point+1, n):
    if curr_height >= hs[i]:
      stepnum += 1
      curr_height = hs[i]
    else:
      start_point = i
      break
  else:
     start_point = n-1

  if stepnum > max_stepnum:
    max_stepnum = stepnum

print(max_stepnum)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

print(sum(range(n)))

Fixed submission:
n = int(input())

if n % 2 == 0:
  print(n * (n//2) - n//2)
else:
  print(n * (n //2))
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())

cached = []
candidate = ''
prev = ''
while len(s) > 0:
  candidate += s.pop(0)
  if candidate != prev:
    cached.append(candidate)
    prev = candidate
    candidate = ''

print(len(cached))


Fixed submission:
from collections import deque
s = deque(list(input()))

cached = []
candidate = ''
prev = ''
cnt = 0
while len(s) > 0:
  candidate += s.popleft()
  if candidate != prev:
    prev = candidate
    candidate = ''
    cnt += 1

print(cnt)