Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
x = input()
x = int(x)

answer = []
for p in range(2, x):

    for i in range(2, x):
        test = i**p
        if test > 1000:
            break
        if test > x:
            answer.append((i-1)**p)
            break
        elif test == x:
            answer.append(i**p)
            break

print(max(answer))

Fixed submission:
X = int(input())

beki = 0
for p in range(2, 9):
    tmp = 0
    b = 1
    while tmp <= X:
        tmp = b**p
        if tmp > X:
            break
        beki = max(tmp, beki)
        b += 1

print(beki)

Buggy python submission (verdict: Runtime Error):
x = input()
x = int(x)

answer = []
for p in range(2, 10):

    for i in range(1, x):
        if i**p > x:
            answer.append((i-1)**p)
            break
        elif pow(i, p) == x:
            answer.append(i**p)
            break

print(max(answer))

Fixed submission:
X = int(input())

beki = 0
for p in range(2, 9):
    tmp = 0
    b = 1
    while tmp <= X:
        tmp = b**p
        if tmp > X:
            break
        beki = max(tmp, beki)
        b += 1

print(beki)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
K = int(input())

sss = set()
M = len(s)
for i in range(M):
    for j in range(i+1,M+1):
        sss.add(s[i:j])

ans = sorted(sss)
print(ans[K-1])


Fixed submission:
s = input()
K = int(input())

sss = set()
M = len(s)
for end in range(1, K+1):
    for i in range(M):
        sss.add(s[i:(i+end)])

ans = sorted(sss)
print(ans[K-1])

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

sss = set()
for i in range(len(s)):
    for j in range(i+1,len(s)+1):
        sss.add(s[i:j])

ans = sorted(sss)
print(ans[K-1])


Fixed submission:
s = input()
K = int(input())

sss = set()
M = len(s)
for end in range(1, K+1):
    for i in range(M):
        sss.add(s[i:(i+end)])

ans = sorted(sss)
print(ans[K-1])
Buggy python submission (verdict: Runtime Error):
a, b, c, x, y = map(int, input().split())

ans1 = a*x + b*y

if x > y:
    ans2 = 2*c*y + a*(x-y)
    ans3 = 2*x*c
else:
    ans2 = 2*c*x + b*(y-x))
    ans3 = 2*c*y

print(min(ans1, ans2), ans3)


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

ans1 = a*x + b*y

if x >= y:
    ans2 = 2*c*y + a*(x-y)
    ans3 = 2*x*c
else:
    ans2 = 2*c*x + b*(y-x)
    ans3 = 2*y*c

print(min(min(ans1, ans2), ans3))
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())

if abs(a - c) <= d:
    print("Yes")
    exit()

if abs(a - b) <= d and abs(b - c) <= d:
    print("Yes")
    exit()

print("No")

Fixed submission:
N = int(input())

thu = N // 1000
cto = (N - 1000*thu) // 100
ten = (N - 1000*thu - 100*cto) // 10
one = N % 10
if (one == ten == cto) or (ten == cto == thu) or (one ==ten == cto == thu):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
x = input()
x = int(x)

answer = []
for p in range(2, 7):

    for i in range(1, x):
        test = i**p
        if test > x:
            answer.append((i-1)**p)
            break
        elif test == x:
            answer.append(i**p)
            break

print(max(answer))

Fixed submission:
N = int(input())

L = []
L.append(2)
L.append(1)
if N == 1:
    print(L[1])
else:
    for i in range(2, N+1):
        L.append(L[i-1] + L[i-2])
    print(L[N])
Buggy python submission (verdict: Runtime Error):
import math

N = int(input())

ans = []
for i in range(1, round(math.sqrt(N))):
    if N % i == 0:
        tmp = max(len(str(i)), len(str(N//i)))
        ans.append(tmp)

print(min(ans))

Fixed submission:
N = int(input())

ans = []
for i in range(1, int(N**0.5)+1):
    if N % i == 0:
        ans.append(i)
        ans.append(int(N/i))

if N == 1:
    print("1")
else:
    print(len(str(ans[-1])))
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())

cnt = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            sum = i + j + k
            if sum == S:
                cnt += 1
                break

print(cnt)


Fixed submission:
K, S = map(int, input().split())

cnt = 0
for i in range(K+1):
    for j in range(K+1):
        if 0 <= (S-i-j) <= K:
            cnt += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
coin = 0
    if a>b:
        coin = 2a-1
    elif a ==b:
        coin = 2a
    elif b>a:
        coin =2b-1
print(coin)

Fixed submission:
a,b = map(int,input().split())
coin = 0
if a>b:
    coin = 2*a-1
elif a ==b:
    coin = 2*a
elif b>a:
    coin =2*b-1
print(coin)
Buggy python submission (verdict: Runtime Error):
n, K = map(int, input().split())
h = [int(x) for x in input().split()]
inf = float('inf')
dp = [inf] * n  # initialize dp
dp[0] = 0
for i in range(1, n):
    for k in range(1, K+1):
        if i - k >= 0:
            dp[i] = min(dp[i-k] + abs(h[i] - h[i-k]), dp[i])
        else:
            break
print(dp[-1])

Fixed submission:
n = int(input())
h = [int(x) for x in input().split()]
inf = float('inf')
dp = [inf] * n  # initialize dp
dp[0] = 0
for i in range(1, n):
    if i == 1:
        dp[i] = abs(h[i] - h[i-1])
    elif (dp[i-1] + abs(h[i] - h[i-1])) < (dp[i-2] + abs(h[i] - h[i-2])):
        dp[i] = dp[i-1] + abs(h[i] - h[i-1])
    else:
        dp[i] = dp[i-2] + abs(h[i] - h[i-2])
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
n, K = map(int, input().split())
h = [int(x) for x in input().split()]
inf = float('inf')
dp = [inf] * n  # initialize dp
dp[0] = 0
for i in range(1, n):
    for k in range(1, K+1):
        if i - k >= 0:
            dp[i] = min(dp[i-k] + abs(h[i] - h[i-k]), dp[i])
        else:
            break
print(dp[-1])

Fixed submission:
n, K = map(int, input().split())
h = [int(x) for x in input().split()]
inf = float('inf')
dp = [inf] * n  # initialize dp
dp[0] = 0
for i in range(1, n):
    for k in range(1, K+1):
        if i - k >= 0:
            kouho = dp[i-k] + abs(h[i] - h[i-k])
            dp[i] = min(kouho, dp[i])
        else:
            break
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, K = map(int, input().split())
h = [int(x) for x in input().split()]
inf = float('inf')
dp = [inf] * n  # initialize dp
dp[0] = 0
for i in range(1, n):
    for k in range(1, K+1):
        if i - k >= 0:
            kouho = dp[i-k] + abs(h[i] - h[i-k])
            dp[i] = min(kouho, dp[i])
        else:
            break
print(dp[-1])

Fixed submission:
n, K = map(int, input().split())
h = [int(x) for x in input().split()]
inf = float('inf')
dp = [inf] * n  # initialize dp
dp[0] = 0
for i in range(1, n):
    for k in range(1, K+1):
        if i - k >= 0:
            kouho = dp[i-k] + abs(h[i] - h[i-k])
            dp[i] = min(kouho, dp[i])
        else:
            break
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
a = [list(map(int, list(input().split()))) for i in range(N)]
dp = [[0]*(W+1) for i in range(N)]  # initialize dp

for i in range(N):
    for k in range(W+1):
        if i == 0:
            if a[0][0] <= k and k <= W:
                dp[0][k] = a[0][1]
        else:
            if a[i][0] <= k and k <= W:
                dp[i][k] = max(dp[i-1][k], dp[i-1][k-a[i][0]] + a[i][1])
            else:
                dp[i][k] = dp[i-1][k]
print(dp[N-1][W])

Fixed submission:
N, W = map(int, input().split())
a = [list(map(int, list(input().split()))) for i in range(N)]
dp = [[0]*(W+1) for i in range(N)]  # initialize dp

for i in range(N):
    for k in range(W+1):
        if i == 0:
            if a[0][0] <= k and k <= W:
                dp[0][k] = a[0][1]
        else:
            if a[i][0] <= k and k <= W:
                dp[i][k] = max(dp[i-1][k], dp[i-1][k-a[i][0]] + a[i][1])
            else:
                dp[i][k] = dp[i-1][k]
print(dp[N-1][W])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = list(map(int, input().split()))
steps = list(map(int, input().split()))

dp = [float('inf')] * n
dp[0] = 0;

for i in range(1, n):
    distances = range(i - 1, max(i - k, 0) - 1, -1)
    for dis in distances:
        dp[i] = min(dp[i], dp[dis] + abs(steps[i] - steps[dis]))

print(dp[n - 1])


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

dp = [0] * n
dp[0] = 0;

for i in range(1, n):
    step_to = steps[i]
    dp[i] = min(
        [
            dp_from + abs(step_to - step_from)
            for dp_from, step_from in zip(
                dp[max(0, i - k):i], steps[max(0, i - k):i])
        ]
    )

print(dp[n - 1])

Buggy python submission (verdict: Time Limit Exceeded):
n, k = list(map(int, input().split()))
steps = list(map(int, input().split()))

dp = [float('inf')] * n
dp[0] = 0;

for i in range(n - 1):
    distances = range(1, min(k + 1, n - i))
    for dis in distances:
        dp[i + dis] = min(dp[i + dis], dp[i] + abs(steps[i] - steps[i + dis]))

print(dp[n - 1])


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

dp = [0] * n
dp[0] = 0;

for i in range(1, n):
    step_to = steps[i]
    dp[i] = min(
        [
            dp_from + abs(step_to - step_from)
            for dp_from, step_from in zip(
                dp[max(0, i - k):i], steps[max(0, i - k):i])
        ]
    )

print(dp[n - 1])
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a < b:
  swap(a,b)
if a == b:
  print(a*2)
else:
  print(a*2-1)


Fixed submission:
a,b = map(int,input().split())
if a < b:
  a,b = b,a
if a == b:
  print(a*2)
else:
  print(a*2-1)

Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
if a < b:
  swap(a,b)
if a == b:
  print(a*2)
else:
  print(a*2-1)

Fixed submission:
a,b = map(int,input().split())
if a < b:
  a,b = b,a
if a == b:
  print(a*2)
else:
  print(a*2-1)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i in range(x/c):
    y = x - 50*i
    if y = 0:
        count = count + 1
    else:
        z = y // 2
        count = count + z

print(count)


Fixed submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i in range(min(a,x//500)+1): #iは0,1,2...,x//500
    remains = x - 500 * i
    for j in range(min(b,remains//100)+1):
        Remains = remains - 100 * j
        for k in range(min(c,Remains//50)+1):
            fifty = Remains - 50 * k
            if fifty == 0:
                count = count + 1
            else: continue

print(count)

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
x = int(input())

print(x)

roop1 = x // a
count = 0

for i in roop1:
    roop2 = (x - 500*i) // b
    for j in roop2:
        roop3 = (x - 500*i - 100*j) // c
        count = count + 1

print(count)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i in range(min(a,x//500)+1): #iは0,1,2...,x//500
    remains = x - 500 * i
    for j in range(min(b,remains//100)+1):
        Remains = remains - 100 * j
        for k in range(min(c,Remains//50)+1):
            fifty = Remains - 50 * k
            if fifty == 0:
                count = count + 1
            else: continue

print(count)

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
x = int(input())

print(x)

roop1 = x // a
count = 0

for i in roop1:
    roop2 = (x - 500*i) // b
    for j in roop2:
        roop3 = (x - 500*i - 100*j) // c
        count = count + 1

print(count)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i in range(min(a,x//500)+1): #iは0,1,2...,x//500
    remains = x - 500 * i
    for j in range(min(b,remains//100)+1):
        Remains = remains - 100 * j
        for k in range(min(c,Remains//50)+1):
            fifty = Remains - 50 * k
            if fifty == 0:
                count = count + 1
            else: continue

print(count)
Buggy python submission (verdict: Runtime Error):
AB = int(input().split())
A,B=AB[0], AB[1]
if max(A,B)-min(A,B) >= 1:
  print(2*max(A,B)-1)
else:
  print(A+B)

Fixed submission:
AB = input().split()
A,B=int(AB[0]), int(AB[1])
if max(A,B)-min(A,B) >= 1:
  print(2*max(A,B)-1)
else:
  print(A+B)

Buggy python submission (verdict: Runtime Error):
A,B = int(input()), int(input())
if max(A,B)-min(A,B) >= 1:
  print(2*max(A,B)-1)
else:
  print(A+B)

Fixed submission:
AB = input().split()
A,B=int(AB[0]), int(AB[1])
if max(A,B)-min(A,B) >= 1:
  print(2*max(A,B)-1)
else:
  print(A+B)
Buggy python submission (verdict: Runtime Error):
a,b,c,d,e,k=int(input()),int(input()),int(input()),int(input()),int(input()),int(input())
k = inputs.pop(5)
if inputs[-1] - inputs[0] > k:
  print('Yay!')
else:
  print(':(')

Fixed submission:
a,b,c,d,e,k=int(input()),int(input()),int(input()),int(input()),int(input()),int(input())
if e-a > k:
  print(':(')
else:
  print('Yay!')

Buggy python submission (verdict: Runtime Error):
inputs = []
while 1:
  tmp = input()
  if tmp:
    inputs.append(tmp)
  else:
    break
k = inputs.pop(5)
if inputs[-1] - inputs[0] > k:
  print('Yay!')
else:
  print(':(')

Fixed submission:
a,b,c,d,e,k=int(input()),int(input()),int(input()),int(input()),int(input()),int(input())
if e-a > k:
  print(':(')
else:
  print('Yay!')
Buggy python submission (verdict: Runtime Error):
A,B,C,D,E=int(input()),int(input()),int(input()),int(input()),int(input())
orders = {'A': A, 'B': B, 'C': C, 'D': D, 'E': E}
orders = sorted(orders.items(), key=lambda item: item[1] % 10, reverse=True)
res = 0
while orders:
  if res % 10 != 0:
    res += (10 - res % 10)
  order = orders.pop(0)
  res += order
print(res)


Fixed submission:
A,B,C,D,E=int(input()),int(input()),int(input()),int(input()),int(input())
orders = {'A': A, 'B': B, 'C': C, 'D': D, 'E': E}
orders = sorted(orders.items(), key=lambda item: (10 if item[1] % 10 == 0 else item[1] % 10), reverse=True)
res = 0
while orders:
  if res % 10 != 0:
    res += (10 - res % 10)
  order = orders.pop(0)
  res += order[1]
print(res)
Buggy python submission (verdict: Runtime Error):
NK = input().split(' ')
N, K = int(NK[0]), int(NK[1])
trees = []
for i in range(N):
  trees.append(int(input()))
trees.sort(reversed=True)
min = 0
for i in range(N-K):
  h = trees[i+K]-trees[i]
  if h < min:
    min = h
print(min)

Fixed submission:
NK = input().split(' ')
N, K = int(NK[0]), int(NK[1])
trees = []
for i in range(N):
  trees.append(int(input()))
trees.sort()
min = float("inf")
for i in range(N-K+1):
  h = trees[i+K-1]-trees[i]
  if h < min:
    min = h
print(min)

Buggy python submission (verdict: Runtime Error):
NK = input().split(' ')
N, K = int(NK[0]), int(NK[1])
trees = []
current = 0
for i in range(N):
  tree = int(input())
  if len(trees) < K:
    trees.append(tree)
  elif tree > min(trees) and tree < max(trees):
    trees.append(tree)
    tmp1 = trees.remove(min(trees))
    tmp2 = trees.remove(max(trees))
    if max(tmp1)-min(tmp1) > max(tmp2)-min(tmp2):
      trees = tmp2
    else:
      trees = tmp1
print(max(trees)-min(trees))
      

Fixed submission:
NK = input().split(' ')
N, K = int(NK[0]), int(NK[1])
trees = []
for i in range(N):
  trees.append(int(input()))
trees.sort()
min = float("inf")
for i in range(N-K+1):
  h = trees[i+K-1]-trees[i]
  if h < min:
    min = h
print(min)
Buggy python submission (verdict: Runtime Error):
s = input()
count = 0
flag = True
while flag == True:
    flag = False
    for i in range(len(s)-1):
        if s[i] != s[i+1]:
            s = s[0:i]+s[i+2:]
            count += 2
            flag = True

print(count)

Fixed submission:
s = input()
print(2*min(s.count('0'), s.count('1')))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
count = 0
flag = True
while flag == True:
    flag = False
    for i in range(len(s)-1):
        if s[i] != s[i+1]:
            s = s[0:i]+s[i+2:]
            count += 2
            flag = True
            break

print(count)

Fixed submission:
s = input()
print(2*min(s.count('0'), s.count('1')))
Buggy python submission (verdict: Runtime Error):
class CreateList:
    def __init__(self, flg, cnt):
        self.flg = flg
        self.cnt = cnt
        
        

def main():
    
    n, k = map(int, input().split())
    s = list(map(int, input()))
    
    slist = []      #Sを使いやすいように加工した配列
    bkflg = s[0]    #一つ前の連続する値が「1」か「0」かを持ってるやつ
    scnt = 0        #「1」「0」の連続する数
    ecnt = 0        #終了判定のカウンター
    
    #配列作成
    for i in s:
        ecnt += 1
        
        #同じ数字が続く場合はカウントアップ
        if i == bkflg:
           scnt += 1
        
        #数字が変わったら配列にこれまでの合計数を入れてカウンターを初期化
        else:
            slist.append(CreateList(bkflg, scnt))
            scnt = 1
            bkflg = i
        
        #最後の1回が拾えないのでここで強引に配列に突っ込む
        if ecnt == len(s):
            slist.append(CreateList(bkflg, scnt))
    
    #本ちゃんで使う勇者たち
    maxsum = 0      #最大合計値の変数
    skipcnt = k     #連続する「0」を「1」としてカウント出来る回数
    cursor = 0      #Sの配列変数の開始位置
    cursorsum = 0   #一時的な「1」の合計数
    tmpcnt = 0      #一時的なカーソル位置
    
    #本ちゃんスタート
    while tmpcnt <= len(slist) - 1:
        #Sの配列を左からスライドしながら数字を拾ってくので、最初にカウンターとカーソル位置を初期化
        tmpcnt = cursor
        skipcnt = k
        cursorsum = 0
        
        #ここで「1」の合計をSの配列の左からスライドさせながらカウントしていく
        while tmpcnt <= len(slist) - 1:
            if slist[tmpcnt].flg == 0:
                if skipcnt == 0:
                    break
                else:
                    skipcnt -= 1
            
            cursorsum = cursorsum + slist[tmpcnt].cnt
            tmpcnt += 1
        
        #これまでの最大合計数を拾う
        if maxsum < cursorsum:
            maxsum = cursorsum
        
        cursor += 1
        
    print(maxsum)
    
    
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    l = list(map(int, input().split()))
    if max(l) != min(l):
        print((max(l) * 2) - 1)
    else:
        print(max(l) * 2)
    

if __name__ == "__main__":
  main()

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(max(max(a,b)-1,min(a,b))+e)

Fixed submission:
a, b = map(int, input().split())
coin = 0
for i in range(2):
    if a > b:
        coin += a
        a -= 1
    else:
        coin += b
        b -= 1

print(coin)

Buggy python submission (verdict: Runtime Error):
print(max(max(a,b)-1,min(a,b))+e)


Fixed submission:
a, b = map(int, input().split())
coin = 0
for i in range(2):
    if a > b:
        coin += a
        a -= 1
    else:
        coin += b
        b -= 1

print(coin)
Buggy python submission (verdict: Runtime Error):
a = [int(i) for i in input().split()] 
if a[4]-a[0]<=a[5]:
  print("Yay!")
else:
  print(":(")

Fixed submission:
a, b, c, d, e, k = [int(input()) for i in range(6)]
if e-a<=k:
  print('Yay!')
else:
  print(':(')

Buggy python submission (verdict: Runtime Error):
a, b, c, d, e, k = (int(i) for i in input().split())
_dis=[a,b,c,d,e]
if a-e>k:
  print(":(")
else:
  print("Yay!")
  

Fixed submission:
a, b, c, d, e, k = [int(input()) for i in range(6)]
if e-a<=k:
  print('Yay!')
else:
  print(':(')
Buggy python submission (verdict: Runtime Error):
a = [int(i) for i in input().split()] 
sum = 0;
res = 0; 
temp = 0;
num = 0;
for i in range(5):
  if(a[i]%10==0):
    sum+=a[i]
  else:
    temp = (a[i]%10 +1)*10-a[i];
    if temp>res:
      sum = sum + res 
      res =temp
      sum+=a[i]
    else:
      sum = sum+a[i]+temp
print(sum)
  

Fixed submission:
a2, b, c, d, e= [int(input()) for i in range(5)]
a=[a2,b,c,d,e]
sum = 0;
res = 0; 
temp = 0;
num = 0;
for i in range(5):
  if(a[i]%10==0):
    sum+=a[i]
  else:
    temp = (int(a[i]/10) +1)*10-a[i];
    #print(temp)
    if temp>res:
      sum = sum + res 
      res =temp
      sum+=a[i]
     # print(sum)
    else:
      sum = sum+a[i]+temp
      #print(sum)
print(int(sum))
Buggy python submission (verdict: Runtime Error):
n = int(input())
st = input()
h = []
for i in range(n):
  h.append(int(st[2*i]))
  
result = 0
now_max = 0

for i in range(n):
  if h[i] >= now_max:
    result = result + 1
    now_max = h[i]
             
print(result)

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

result = 0
now_max = 0

for i in range(n):
    if h[i] >= now_max:
        result = result + 1
        now_max = h[i]

print(result)

Buggy python submission (verdict: Runtime Error):
n = int(input())
st = input()
h = []
for i in range(n):
  h.append(int(st[2*i]))
  
result = 1
now_max = h[0]

for i in range(1,n):
  if h[i] >= now_max:
    result = result + 1
    now_max = h[i]
             
print(result)

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

result = 0
now_max = 0

for i in range(n):
    if h[i] >= now_max:
        result = result + 1
        now_max = h[i]

print(result)

Buggy python submission (verdict: Runtime Error):
n = int(input())
h = [int(input()) for i in range(n)]
result = 1
now_max = h[0]

for i in range(1,n):
  if h[i] >= now_max:
    result = result + 1
    now_max = h[i]
             
print(result)

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

result = 0
now_max = 0

for i in range(n):
    if h[i] >= now_max:
        result = result + 1
        now_max = h[i]

print(result)

Buggy python submission (verdict: Runtime Error):
n = int(input())
h = [int(input()) for i in range(n)]
result = 1

for i in range(1,n):
  if h[i] >= h[i-1]:
    	result = result + 1
      
print(result)

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

result = 0
now_max = 0

for i in range(n):
    if h[i] >= now_max:
        result = result + 1
        now_max = h[i]

print(result)
Buggy python submission (verdict: Time Limit Exceeded):
def key_func(n):
    return n[0]

n,m = map(int, input().split(" "))
a_b = []
for i in range(n):
    a_b.append(list(map(int,input().split(" "))))

money = 0

while m > 0:
    ind = a_b.index(min(a_b,key=key_func))
    i = min(m,a_b[ind][1])
    money = money + a_b[ind][0]*i
    m = m - i
    del a_b[ind]

print(money)

Fixed submission:
def key_func(n):
    return n[0]

n,m = map(int, input().split(" "))
a_b = []
for i in range(n):
    a_b.append(list(map(int,input().split(" "))))

a_b.sort(key=key_func)

money = 0

for item in a_b:
    i = min(m,item[1])
    money = money + item[0]*i
    m = m - i
    if m <= 0:
        break

print(money)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split(" "))
a = []
b = []
for i in range(n):
    temp = list(map(int,input().split(" ")))
    a.append(temp[0])
    b.append(temp[1])

sort_a = sorted(set(a))
money = 0

for ai in sort_a:
    ind = [i for i, x in enumerate(a) if x == ai]
    for i in ind:
        x = min(m,b[i])
        m = m - x
        money = money + a[i]*x
    if m <= 0:
        break

print(money)

Fixed submission:
def key_func(n):
    return n[0]

n,m = map(int, input().split(" "))
a_b = []
for i in range(n):
    a_b.append(list(map(int,input().split(" "))))

a_b.sort(key=key_func)

money = 0

for item in a_b:
    i = min(m,item[1])
    money = money + item[0]*i
    m = m - i
    if m <= 0:
        break

print(money)