Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
A = np.array(list(map(int,input().split())))
B = np.array(list(map(int,input().split())))
Bsi = np.argsort(B)
A2 = A[Bsi]
Bs = B[Bsi]
A2si = np.argsort(A2)
As = A2[A2si]
C = Bs-As
if any(C[C<0]):
    ans = 'No'
else:
    D = A2-As
    if any(D == 0):
        ans = 'Yes'
    elif all(As[1::]-Bs[:-1:] > 0):
        psum = A2si[0]
        for i,pi in enumerate(A2si[1:-1],1):
            psum += pi
            if psum == int(i*(i+1)/2):
                ans = 'Yes'
                break
        else:
            ans = 'No'
    else:
        ans = 'Yes'
        
print(ans)

Fixed submission:
N = int(input())

if N%2 == 0:
    print(int(N//2-1))
else:
    print(int((N+1)//2-1))

Buggy python submission (verdict: Runtime Error):
N = int(input())
D = sorted(list(map(int,input().split())))
ans = 1
D.append(-1)
if D[0]>0:
    ans = 0
elif D[1]==0:
    ans = 0
else:
    cur = 0
    n1 = 1
    n2 = 1
    for i,d in enumerate(D[1::],1):
        if d == cur:
            n2 += 1
        else:
            nn = (n1**n2)%998244353
            ans *= nn
            n1 = n2
            n2 = 1
            cur = d
print(ans)

Fixed submission:
N = int(input())

if N%2 == 0:
    print(int(N//2-1))
else:
    print(int((N+1)//2-1))

Buggy python submission (verdict: Runtime Error):
N = int(input())
D = sorted(list(map(int,input().split())))
ans = 1
D.append(-1)
if D[0]>0:
    ans = 0
elif D[1]==0:
    ans = 0
else:
    cur = 0
    n1 = 1
    n2 = 1
    for i,d in enumerate(D[1::],1):
        if d == cur:
            n2 += 1
        else:
            ans *= n1**n2
            ans %= 998244353                
            n1 = n2
            n2 = 1
            cur = d
print(ans)


Fixed submission:
N = int(input())

if N%2 == 0:
    print(int(N//2-1))
else:
    print(int((N+1)//2-1))

Buggy python submission (verdict: Runtime Error):
N = int(input())
D = sorted(list(map(int,input().split())))
ans = 1
D.append(-1)
if D[0]>0:
    ans = 0
elif D[1]==0:
    ans = 0
else:
    cur = 0
    n1 = 1
    n2 = 1
    for i,d in enumerate(D[1::],1):
        if d == cur:
            n2 += 1
        else:
            ans *= n1**n2
            n1 = n2
            n2 = 1
            cur = d
print(ans%998244353)

Fixed submission:
N = int(input())

if N%2 == 0:
    print(int(N//2-1))
else:
    print(int((N+1)//2-1))

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

if N%2 == 0:
    print(int(N/2-1))
else:
    print(int((N+1)/2-1)

Fixed submission:
N = int(input())

if N%2 == 0:
    print(int(N//2-1))
else:
    print(int((N+1)//2-1))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

X = 998244353
N = int(input())
D = list(map(int,input().split()))
if D[0] != 0:
    ans = 0
elif N == 1:
    ans = 1
else:
    ans = 1
    Dd = deque(D)
    Dc = [Dd.count(i) for i in range(0, max(D)+1) ]

    if Dc[0]>1 or not all(Dc[1::]):
        ans = 0
    else:
        n1 = 1
        for n2 in Dc[1::]:
            nn = (n1**n2)%X
            ans *= nn
            n1 = n2
        ans%=X
print(ans)

Fixed submission:
Z = 998244353
N = int(input())
D = list(map(int,input().split()))
if D[0]>0:
    ans = 0
elif N==1:
    ans = 1
else:
    D.sort()
    if D[1]==0:
        ans = 0
    else:
        D.append(-1)
        ans = 1
        cur = 0
        n1 = 1
        n2 = 1
        for d in D[1::]:
            if d == cur:
                n2 += 1
            else:
                if d == cur+1 or d == -1:
                    nn = pow(n1,n2,Z)
                    ans *= nn
                    n1 = n2
                    n2 = 1
                    cur = d
                else:
                    ans = 0
                    break
        ans%=Z
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
A = np.array(list(map(int,input().split())))
B = np.array(list(map(int,input().split())))
Bsi = np.argsort(B)
A2 = A[Bsi]
Bs = B[Bsi]
A2si = np.argsort(A2)
As = A2[A2si]
C = Bs-As
if any(C[C<0]):
    ans = 'No'
else:
    D = A2-As
    if any(D == 0):
        ans = 'Yes'
    elif all(As[1::]-Bs[:-1:] > 0):
        psum = A2si[0]
        for i,pi in enumerate(A2si[1:-1],1):
            psum += pi
            if psum == int(i*(i+1)/2)
                ans = 'Yes'
                break
        else:
            ans = 'No'
    else:
        ans = 'Yes'
        
print(ans)

Fixed submission:
import numpy as np

N = int(input())
A = np.array(list(map(int,input().split())))
B = np.array(list(map(int,input().split())))
Bsi = np.argsort(B)
A2 = A[Bsi]
Bs = B[Bsi]
A2si = np.argsort(A2)
As = A2[A2si]
C = Bs-As
if any(C[C<0]):
    ans = 'No'
else:
    D = A2-As
    if any(D == 0):
        ans = 'Yes'
    elif all(As[1::]-Bs[:-1:] > 0):
        pi = 0
        i = 0
        while i<N-1:
            pi = A2si[pi]
            if pi == 0:
                ans = 'Yes'
                break
            else:
                i += 1
        else:
            ans = 'No'
    else:
        ans = 'Yes'
        
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
import numpy as np

S = list(input())
N = len(S)+1
if N%2==0:
    D = np.zeros(N)
else:
    D = np.zeros(N-1)
   
nc = 1
cur = S[0]
curi = 0
for i in range(1,N-1):
    if S[i]==cur:
        nc += 1
    else:
        D[curi] = nc
        cur = S[i]
        curi += 1
        nc = 1
D[curi] = nc
D=D.reshape([-1,2])
Asum = 0
for d in D:
    if d.all == 0:
        break
    else:
        a1 = max(np.absolute(d))
        a2 = min(np.absolute(d))
        Asum += int((a1+1)*a1/2 + a2*(a2-1)/2)

print(Asum)

Fixed submission:
import math
import numpy as np

# N,K = map(int,input().split())
# A = np.sort(list(map(int,input().split())))
# F = np.sort(list(map(int,input().split())))[::-1]
#         if np.sum(AF[AF>0]) > K: 

S = list(input())
if S[0]=='>':
    S = ['<']+S
if S[-1]=='<':
    S = S+['>']

N=len(S)
D=np.zeros(N)
nc = 1
cur = S[0]
curi = 0
for i in range(1,N):
    if S[i]==cur:
        nc += 1
    else:
        D[curi] = nc
        cur = S[i]
        curi += 1
        nc = 1
D[curi] = nc
D = D[D>0]
D=D.reshape([-1,2])
Asum = 0
for d in D:
    a1 = max(d)
    a2 = min(d)
    Asum += int((a1+1)*a1/2 + a2*(a2-1)/2)

print(Asum)

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

S = list(input())
N = len(S)+1
if N%2==0:
    D = np.zeros(N)
else:
    D = np.zeros(N-1)
   
nc = 1
cur = S[0]
curi = 0
for i in range(1,N-1):
    if S[i]==cur:
        nc += 1
    else:
        D[curi] = nc
        cur = S[i]
        curi += 1
        nc = 1
D[curi] = nc
D=D.reshape([-1,2])
Asum = 0
for d in D:
    if d.all == 0:
        break
    else:
        a1 = max(np.absolute(d))
        a2 = min(np.absolute(d))
        Asum += int(np.sum(np.arange(0,a1+1)) + np.sum(np.arange(0,a2)))

print(Asum)

Fixed submission:
import math
import numpy as np

# N,K = map(int,input().split())
# A = np.sort(list(map(int,input().split())))
# F = np.sort(list(map(int,input().split())))[::-1]
#         if np.sum(AF[AF>0]) > K: 

S = list(input())
if S[0]=='>':
    S = ['<']+S
if S[-1]=='<':
    S = S+['>']

N=len(S)
D=np.zeros(N)
nc = 1
cur = S[0]
curi = 0
for i in range(1,N):
    if S[i]==cur:
        nc += 1
    else:
        D[curi] = nc
        cur = S[i]
        curi += 1
        nc = 1
D[curi] = nc
D = D[D>0]
D=D.reshape([-1,2])
Asum = 0
for d in D:
    a1 = max(d)
    a2 = min(d)
    Asum += int((a1+1)*a1/2 + a2*(a2-1)/2)

print(Asum)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
LRs = [list(map(int,input().split())) for i in range(0,N)]

L,R = zip(*LRs)
Lp = max(L)
Rq = min(R)

A = [max(0, r-Lp+1) for r in R]
B = [max(Rq-l+1, 0) for l in L]
AB = sorted(zip(A,B))
A2,B2 = zip(*AB)

mlr = max(r-l for l,r in LRs) + 1
m1 = max(0, Rq - Lp + 1) + mlr
for i,a in enumerate(A2[:-1:]):
    mt = min(B2[:i+1:])
    ms = A2[i+1]
    m1 = max(m1, ms+mt)

print(m1)

Fixed submission:
N = int(input())
LRs = [list(map(int,input().split())) for i in range(0,N)]

L,R = zip(*LRs)
Lp = max(L)
Rq = min(R)

A = [max(0, r-Lp+1) for r in R]
B = [max(Rq-l+1, 0) for l in L]
AB = sorted(zip(A,B))
A2,B2 = zip(*AB)

mlr = max(r-l for l,r in LRs) + 1
m = max(0, Rq - Lp + 1) + mlr
mt = B2[0]
for i,a in enumerate(A2[0:-1:]):
    mt = min(mt, B2[i])
    ms = A2[i+1]
    m = max(m, ms+mt)

print(m)
Buggy python submission (verdict: Runtime Error):
n, k = input().split()
print(int(n, int(k)))

Fixed submission:
n, k = input().split()
import math
def findNumberOfDigits(n, base):
    dig = (math.floor(math.log(n) /
                      math.log(base)) + 1)
    print(dig)

findNumberOfDigits(int(n), int(k))

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

import sys


def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())

    n = 1
    while True:
        min_value = K ** (n - 1)
        max_value = K ** n - 1
        if min_value <= N < max_value:
            print(n)
            break
        n += 1


if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python3

import sys
from math import floor, log


def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())

    ans = floor(log(N) / log(K) + 1)
    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
H = int(input())
if H == 1:
    cnt = 1
else:
    J = list()
    J.append(H)
    cnt = 0
    while len(J) > 0:
        if J[0] == 1:
            del J[0]
            cnt += 1
        else:    
            J.append(J[0]//2)
            J.append(J[0]//2)
            del J[0]
            cnt += 1
print(cnt)

Fixed submission:
import math
h = int(input())
hp = h
c = 0
ans = 0

while hp > 1:
    hp = math.floor(hp/2)
    c += 1
for i in range(0,c+1):
    ans += 2 ** i
print(ans)
Buggy python submission (verdict: Runtime Error):
'''C - Welcome to AtCoder
高橋君は AtCoder のコンテストに参加しています。

このコンテストでは、 N 問の問題が出題されます。
高橋君はコンテスト中に M回の提出を行いました。

i 回目の提出は pi番目の問題への提出であり、結果は Si (AC または WA) でした。
高橋君の正答数は、AC を 1回以上出した問題の数です。
高橋君のペナルティ数は、高橋君が AC を 1 回以上出した各問題において、初めて AC を出すまでに出した WA の数の総和です。
高橋君の正答数とペナルティ数を答えてください。

入力
入力は以下の形式で標準入力から与えられる。

N M
p1 S1
:
pM SM

2 5
1 WA
1 AC
2 WA
2 AC
2 WA
>
2 2

100000 3
7777 AC
7777 AC
7777 AC
>
1 0

6 0
>
0 0
'''
import numpy as np

N, M = map(int, input().split())

AC = np.array([0]*N) # 正解を入れる箱
WA = np.array([0]*N) # 不正解を入れる箱

for _ in range(M):
    p, S = input().split()
    
    if AC[int(p)-1] ==0 and S == "WA": # まだ「正解が出てない & 不正解」
        WA[int(p)-1] += 1              # なら不正解の箱に＋１
    else:
        AC[int(p)-1] = 1               # それ以外は正解の箱に１
    
print(sum(AC), sum(WA*AC)) # ただし不正解の箱は最後まで正解が出なかった問題はペナルティ無しにする必要があるので、正解の箱の中身と掛け合わせて消しておく。



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

smallest_so_far = float("inf")
cnt = 0

for the_num in P:
    if the_num < smallest_so_far :
        smallest_so_far = the_num
        cnt += 1
print(cnt)

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

cnt = 0
for i in range(N):
    if np.min(P[:i+1]) == P[i]:
        cnt += 1
print(cnt)

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

smallest_so_far = float("inf")
cnt = 0

for the_num in P:
    if the_num < smallest_so_far :
        smallest_so_far = the_num
        cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
P = list(map(int, input().split()))
cnt = 0
for i in range(N):
    if P[i]  <=  np.min(P[:i+1]):
        cnt += 1
print(cnt)    

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

smallest_so_far = float("inf")
cnt = 0

for the_num in P:
    if the_num < smallest_so_far :
        smallest_so_far = the_num
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
N, K, M = map(int,input().split())
A = list(map(int,input().split()))

if sum(A) > N * M:
    print(0)
elif N * M - sum(A) - K < 0:
    print(N * M - sum(A))
else:
    print(-1)

Fixed submission:
C = input()

nb = lambda xx: chr(ord(xx) + 1) 
print(nb(C))
Buggy python submission (verdict: Runtime Error):
import numpy as np
 
N,M = map(int,input().split()) 
 
AC = np.array([0]*N)
WA = np.array([0]*N)
 
for i in range(M):
    p,S = input().split()
    
    if AC[int(p)-1] ==0 and S == "WA":
       WA[int(p)-1] += 1
    else:
        AC[int(p)-1] = 1

print(sum(AC),sum(AC*WA))

Fixed submission:
import numpy as np
 
N,M = map(int,input().split()) 
 
AC = np.array([0]*N)
WA = np.array([0]*N)
 
for i in range(M):
    p,S = input().split()
    
    if AC[int(p)-1] ==0 and S == "WA":
       WA[int(p)-1] += 1
    else:
        AC[int(p)-1] = 1

print(sum(AC),sum(AC*WA))

Buggy python submission (verdict: Runtime Error):
import numpy as np

N, M = map(int, input().split())

AC = np.array([0]*N) # 正解を入れる箱
WA = np.array([0]*N) # 不正解を入れる箱

for _ in range(M):
    p, S = input().split()
    
    if AC[int(p)-1] ==0 and S == "WA": # まだ「正解が出てない & 不正解」
        WA[int(p)-1] += 1              # なら不正解の箱に＋１
    else:
        AC[int(p)-1] = 1               # それ以外は正解の箱に１
    
print(sum(AC), sum(WA*AC)) # ただし不正解の箱は最後まで正解が出なかった問題はペナルティ無しにする必要があるので、正解の箱の中身と掛け合わせて消しておく。



Fixed submission:
import numpy as np
 
N,M = map(int,input().split()) 
 
AC = np.array([0]*N)
WA = np.array([0]*N)
 
for i in range(M):
    p,S = input().split()
    
    if AC[int(p)-1] ==0 and S == "WA":
       WA[int(p)-1] += 1
    else:
        AC[int(p)-1] = 1

print(sum(AC),sum(AC*WA))

Buggy python submission (verdict: Runtime Error):
import numpy as np

N, M = map(int, input().split())

AC = np.array([0]*N) # 正解を入れる箱
WA = np.array([0]*N) # 不正解を入れる箱

for _ in range(M):
    p, S = input().split()
    
    if AC[int(p)-1] ==0 and S == "WA": # まだ「正解が出てない & 不正解」
        WA[int(p)-1] += 1              # なら不正解の箱に＋１
    else:
        AC[int(p)-1] = 1               # それ以外は正解の箱に１
    
print(sum(AC), sum(WA))

Fixed submission:
import numpy as np
 
N,M = map(int,input().split()) 
 
AC = np.array([0]*N)
WA = np.array([0]*N)
 
for i in range(M):
    p,S = input().split()
    
    if AC[int(p)-1] ==0 and S == "WA":
       WA[int(p)-1] += 1
    else:
        AC[int(p)-1] = 1

print(sum(AC),sum(AC*WA))
Buggy python submission (verdict: Runtime Error):
    K, X = map(int, input().split())
    if 500 * K >= X:
        print('Yes')
    else:
        print('No')

Fixed submission:
K, X = map(int, input().split())
if 500 * K >= X:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
S = input()
ans = int()
for i in range(len(S)//2):
if S[i] != S[-(i + 1)]:
    ans += 1
print(ans)

Fixed submission:
S = input()
ans = int()
for i in range(len(S)//2):
    if S[i] != S[-(i + 1)]:
        ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S, T = input().split()
ans = str()
for i in range(N):
    ans += (S[i])
    ans += (T[i])
print(ans)

Fixed submission:
S = input()
ans = int()
for i in range(len(S)//2):
    if S[i] != S[-(i + 1)]:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
input = sys.stdin.readline
 
import heapq
N, M = map(int, input().split())
X = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x: x[0])
heap = []
ans = 0
j = 0
 
for i in range(1, M+1): # M - i 日後にするバイトを考える
    while (j < N) and (X[j][0] <= i): # 支払いがi日以内
        heapq.heappush(heap, -X[j][1]) # 候補の追加。最大の値が欲しいためマイナスに
        j += 1
    if len(heap):
        ans += - heapq.heappop(heap) # 候補があるとき、候補から最大値を取り出す
print(ans)

Fixed submission:
import heapq
N, M = map(int, input().split())
X = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x: x[0])
heap = []
ans = 0
j = 0

for i in range(1, M+1): # M - i 日後にするバイトを考える
    while (j < N) and (X[j][0] <= i): # 支払いがi日以内
        heapq.heappush(heap, -X[j][1]) # 候補の追加。最大の値が欲しいためマイナスに
        j += 1
    if len(heap):
        ans += - heapq.heappop(heap) # 候補があるとき、候補から最大値を取り出す
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
lg = len(str(N))
cnt = 0
if lg == 6:
    cnt = 90909
elif lg == 5:
    cnt += N - 10000 + 1
    cnt += 909
elif lg == 4:
    cnt = 909
elif lg == 3:
    cnt += N - 100 + 1
    cnt += 9
elif lg == 2:
    cnt = 9
else:
    cnt = N
print(cnt)

Fixed submission:
A, B, C = map(int, input().split())
print(max(0, C-(A-B)))
Buggy python submission (verdict: Runtime Error):
N = int(input())
lg = len(N)
cnt = 0
if lg == 6:
    cnt = 90900
elif lg == 5:
    cnt += N - 10000 + 1
    cnt += 909
elif lg == 4:
    cnt = 909
elif lg == 3:
    cnt += N - 100 + 1
    cnt += 9
elif lg == 2:
    cnt = 9
else:
    cnt = N
print(cnt)

Fixed submission:
N = int(input())
result = 0
for i in range(1, N+1):
    if len(str(i)) % 2 == 1:
        result += 1
print(result)

Buggy python submission (verdict: Runtime Error):
N = int(input())
lg = len(N)
cnt = 0
if lg == 6:
    cnt = 90909
elif lg == 5:
    cnt += N - 10000 + 1
    cnt += 909
elif lg == 4:
    cnt = 909
elif lg == 3:
    cnt += N - 100 + 1
    cnt += 9
elif lg == 2:
    cnt = 9
else:
    cnt = N
print(cnt)

Fixed submission:
N = int(input())
result = 0
for i in range(1, N+1):
    if len(str(i)) % 2 == 1:
        result += 1
print(result)
Buggy python submission (verdict: Runtime Error):
N = int(input())
P = list(map(int, input().split()))

cnt = 0
for i in range(N):
    if i + 1 == P[i]:
        cnt += 1

if cnt >= N - 2:
    print('YES')
else:
    print('NO')


Fixed submission:
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
cnt = 0
 
def dist(A, B):
    sums = 0
    for i in range(len(A)):
        sums += (abs(A[i] - B[i])) ** 2
    sums = sums ** 0.5
    return sums
 
for i in range(N-1):
    for j in range(i+1, N):
#            if isinstance(dist(X[i], X[j]), int):
        if dist(X[i], X[j]).is_integer():
            cnt += 1
print(cnt)

Buggy python submission (verdict: Runtime Error):
    N, D = map(int, input().split())
    X = [list(map(int, input().split())) for _ in range(N)]
cnt = 0

def dist(A, B):
    sums = 0
    for i in range(len(A)):
        sums += (abs(A[i] - B[i])) ** 2
    sums = sums ** 0.5
    return sums

for i in range(N-1):
    for j in range(i+1, N):
#            if isinstance(dist(X[i], X[j]), int):
        if dist(X[i], X[j]).is_integer():
            cnt += 1
print(cnt)

Fixed submission:
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
cnt = 0
 
def dist(A, B):
    sums = 0
    for i in range(len(A)):
        sums += (abs(A[i] - B[i])) ** 2
    sums = sums ** 0.5
    return sums
 
for i in range(N-1):
    for j in range(i+1, N):
#            if isinstance(dist(X[i], X[j]), int):
        if dist(X[i], X[j]).is_integer():
            cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):

n = int(input())
P = [i for i in range(n)]
cnt = 0
for i in range(1:n-1):
    if (P[i-1] < P[i] < P[i+1]) or (P[i-1] > P[i] > P[i+1]):
        cnt += 1
print(cnt)

Fixed submission:
    
n = int(input())
    
P = list(map(int, input().split()))
cnt = 0
for i in range(1, n-1):
    if (P[i-1] < P[i] < P[i+1]) or (P[i-1] > P[i] > P[i+1]):
        cnt += 1
    
print(cnt)
Buggy python submission (verdict: Runtime Error):
    N, X = map(int, input().split())
    L = list(map(int, input().split()))
    cnt = 1
    a = 0

    for i in range(len(L)):
        a += L[i]
        if a <= X:
            cnt += 1
    print(cnt)

Fixed submission:
N, X = map(int, input().split())    
L = list(map(int, input().split()))
    
cnt = 1
    
a = 0

    
for i in range(len(L)):
    a += L[i]
    if a <= X:
        cnt += 1

print(cnt)

Buggy python submission (verdict: Runtime Error):
    N, X = map(int, input().split())
    L = list(map(int, input().split()))
    cnt = 1
    a = 0

    for i in range(len(L)):
        a += L[i]
        if a <= X:
            cnt += 1
    print(cnt)

Fixed submission:
N, X = map(int, input().split())    
L = list(map(int, input().split()))
    
cnt = 1
    
a = 0

    
for i in range(len(L)):
    a += L[i]
    if a <= X:
        cnt += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [0] * N
B = [0] * N
C = [0] * N
for i in range(N):
    A[i], B[i], C[i] = map(int, input().split())
dp = [[0] * 3 for _ in range(N)]  # 初期化　[[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]] for n = 4
dp[0] = [A[0], B[0], C[0]]

for i in range(N-1):
    dp[i+1][0] = max(dp[i][1]+A[i+1], dp[i][2]+A[i+1])
    dp[i+1][1] = max(dp[i][0]+B[i+1], dp[i][2]+B[i+1])
    dp[i+1][2] = max(dp[i][0]+C[i+1], dp[i][1]+C[i+1])
print(max(dp[N-1]))

Fixed submission:
n = int(input())
H = list(map(int, input().split()))
dp = [float("inf") for _ in range(n)]  # 最小化問題なのでinfで初期化
dp[0] = 0  # 初期条件
dp[1] = dp[0] + abs(H[1]-H[0])  #　初期条件2

for i in range(2, n):
    dp[i] = min(dp[i], dp[i-1] + abs(H[i]-H[i-1]))
    dp[i] = min(dp[i], dp[i-2] + abs(H[i]-H[i-2]))
print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
H = list(map(int, input().split()))
dp = [float("inf") for _ in range(n)]  # 最小化問題なのでinfで初期化
dp[0] = 0  # 初期条件
 
dp[1] = dp[0] + abs(H[1] - H[0])  # 初期条件2
 
for i in range(n - 1):  # 配るDP
    for j in  range(1, min(k+1, n-i)):
        dp[i + j] = min(dp[i + j], dp[i] + abs(H[i + j] - H[i]))
print(dp[n - 1])

Fixed submission:
n = int(input())
H = list(map(int, input().split()))
dp = [float("inf") for _ in range(n)]  # 最小化問題なのでinfで初期化
dp[0] = 0  # 初期条件
dp[1] = dp[0] + abs(H[1]-H[0])  #　初期条件2

for i in range(2, n):
    dp[i] = min(dp[i], dp[i-1] + abs(H[i]-H[i-1]))
    dp[i] = min(dp[i], dp[i-2] + abs(H[i]-H[i-2]))
print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
H = list(map(int, input().split()))
dp = [float("inf") for _ in range(n)]  # 最小化問題なのでinfで初期化
dp[0] = 0  # 初期条件
 
dp[1] = dp[0] + abs(H[1] - H[0])  # 初期条件2
 
for i in range(n - 1):  # 配るDP
    for j in  range(1, min(k+1, n-i)):
        dp[i + j] = min(dp[i + j], dp[i] + abs(H[i + j] - H[i]))
print(dp[n - 1])

Fixed submission:
n = int(input())
H = list(map(int, input().split()))
dp = [float("inf") for _ in range(n)]  # 最小化問題なのでinfで初期化
dp[0] = 0  # 初期条件
dp[1] = dp[0] + abs(H[1]-H[0])  #　初期条件2

for i in range(2, n):
    dp[i] = min(dp[i], dp[i-1] + abs(H[i]-H[i-1]))
    dp[i] = min(dp[i], dp[i-2] + abs(H[i]-H[i-2]))
print(dp[n-1])