Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = list(map(int,input().split()))

dic = {}
for i in range(n-1):
    a = p[i+1]-p[i]
    if a in dic and a != 1:
        dic[a] += 1
    elif a not in dic and a != 1:
        dic[a] = 1

flag = False
for k,v in dic.values():
    if i == 2 :
        flag = True
        break
    else:
        continue

if flag:
    print("YES")
else:
    if len(dic) == 0:
        print("YES")
    else:
        print("NO")


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

count = 0
for i in range(n):
    if i+1 != p[i]:
        p[i] == i+1
        count += 1

if count <= 2:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return list(reversed(divisors))

s = int(input())
ll = make_divisors(s)
if s%2 == 0:
    print("0 0 0",ll[0],ll[1], "0")
else:
    print("0 1 1 0",ll[0],ll[1])

Fixed submission:
import math
s = int(input())
a = math.ceil(math.sqrt(s))
b = a**2-s
print(0,0,a,1,b,a)
Buggy python submission (verdict: Time Limit Exceeded):
import copy
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]

for i in range(n):
    al = copy.copy(a)
    del al[i]
    print(max(al)[0])

Fixed submission:
import copy
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]

a_l = []
for i in range(n):
    a_l.append(a[i][0])
a1 = sorted(a_l)
m1 = a1[-1]
m2 = a1[-2] 

for i in a_l:
    if i == m1:
        print(m2)
    else:
        print(m1)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]

for i in range(n):
    al = copy.copy(a)
    del al[i]
    print(max(al)[0])

Fixed submission:
import copy
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]

a_l = []
for i in range(n):
    a_l.append(a[i][0])
a1 = sorted(a_l)
m1 = a1[-1]
m2 = a1[-2] 

for i in a_l:
    if i == m1:
        print(m2)
    else:
        print(m1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

flag = 0
even = []
odd = []
for i in a:
    if i%2 == 0:
        even.append(i)
    else:
        odd.append(i) 

if n%2 == 1:
    if len(odd) >= 1:
        flag = 1
    else:
        for i in range(n):
            count = 0
            for j in range(i, n):
                aa = a[i]^a[j]
                if aa in a:
                    count += 1
                if count < 2:
                    flag = 1
                    break
            else:
                continue
            break

else:
    if len(odd)/2 != len(even):
        flag = 1
        for i in range(n):
            count = 0
            for j in range(i, n):
                aa = a[i]^a[j]
            if aa in a:
                count += 1
            if count < 2:
                flag = 1
                break
        else:
            continue
        break

if flag == 1:
    print("No")
else:
    print("Yes")

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

t = 0
for a_i in a:
    t ^= a_i
    # print(t)
print("Yes" if t==0 else "No")

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

flag = 0
even = []
odd = []
for i in a:
    if i%2 == 0:
        even.append(i)
    else:
        odd.append(i) 

if n%2 == 1:
    if len(odd) >= 1:
        flag = 1
    else:
        for i in range(n):
            count = 0
            for j in range(i, n):
                aa = a[i]^a[j]
            if aa in a:
                count += 1
        if count < 2:
            flag = 1
            break

else:
    if len(odd)/2 != len(even):
        flag = 1
        for i in range(n):
            count = 0
            for j in range(i, n):
                aa = a[i]^a[j]
            if aa in a:
                count += 1
        if count < 2:
            flag = 1
            break

if flag == 1:
    print("No")
else:
    print("Yes")

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

t = 0
for a_i in a:
    t ^= a_i
    # print(t)
print("Yes" if t==0 else "No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

ans = [0]*N
for i in range(N):
    if i%2 == 0:
        ans[i] = sum(A[0:i:2])-sum(A[1:i:2])+A[i]+sum(A[i+1::2])-sum(A[i+2::2])
    else:
        ans[i] = -sum(A[0:i:2])+sum(A[1:i:2])+A[i]+sum(A[i+1::2])-sum(A[i+2::2])
ans.insert(0, ans.pop(-1))
print(*ans)

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

ans = [0]*N

#TLE解
# for i in range(N):
#     if i%2 == 0:
#         ans[i] = sum(A[0:i:2])-sum(A[1:i:2])+A[i]+sum(A[i+1::2])-sum(A[i+2::2])
#     else:
#         ans[i] = -sum(A[0:i:2])+sum(A[1:i:2])+A[i]+sum(A[i+1::2])-sum(A[i+2::2])
# ans.insert(0, ans.pop(-1))

ans[0] = sum(A)-sum(A[1::2])*2
for i in range(1, N):
    ans[i] = A[i-1]*2-ans[i-1]
print(*ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
flag = 0
for i in range(len(n)-1):
    if n[i] == n[i+1]:
        flag = 1

if flag == 1:
    print("Bad")
else:
    print("Good")

Fixed submission:
n = input()
flag = 0
for i in range(len(n)-1):
    if n[i] == n[i+1]:
        flag = 1

if flag == 1:
    print("Bad")
else:
    print("Good")

Buggy python submission (verdict: Runtime Error):
n = int(input())
flag = 0
for i in range(len(n)-1):
  if n[i] == n[i+1]:
    flag = 1

if flag == 1:
  print("Bad")
else:
  print("Good)

Fixed submission:
n = input()
flag = 0
for i in range(len(n)-1):
    if n[i] == n[i+1]:
        flag = 1

if flag == 1:
    print("Bad")
else:
    print("Good")
Buggy python submission (verdict: Runtime Error):
import math
def lcm(x,y):
    return (x*y)//math.gcd(x,y)

a,b,c,d = map(int,input().split())
print((b-a+1)-b//c-b//d+b//lcm(c,d)+(a-1)//d+(a-1)//c-(a-1)//lcm(c,d))

Fixed submission:
import fractions
def lcm(x,y):
    return (x*y)//fractions.gcd(x,y)

a,b,c,d = map(int,input().split())
print((b-a+1)-b//c-b//d+b//lcm(c,d)+(a-1)//d+(a-1)//c-(a-1)//lcm(c,d))
Buggy python submission (verdict: Runtime Error):
x, a = int(input().split())
if x < a:
  print(0)
else:
  print(10)

Fixed submission:
x, a = list(map(int, input().split()))
if x < a:
  print(0)
else:
  print(10)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int, input().split())
a = [int(input()) for _ in range(M)]
dp = [0 for _ in range(N+1)]
dp[0] = 1
for i in range(N+1):
    if i in a:
        continue
    else:
        if i+1 not in a and i+1 <= N:
            dp[i+1] += dp[i]
        if i+2 not in a and i+2 <= N:
            dp[i+2] += dp[i]
print(dp[-1]%1000000007)

Fixed submission:
N,M = map(int, input().split())
a = [int(input()) for _ in range(M)]
dp = [0 for _ in range(N+1)]
dp[0] = 1
no_step = 0
for i in range(N+1):
    if no_step >= M:
        if i+1 <= N:
            dp[i+1] += dp[i]
        if i+2 <= N:
            dp[i+2] += dp[i]
    else:
        if i == a[no_step]:
            no_step += 1
            continue
        else:
            if i+1 != a[no_step] and i+1 <= N:
                dp[i+1] += dp[i]
            if i+2 != a[no_step] and i+2 <= N:
                dp[i+2] += dp[i]
print(dp[-1]%1000000007)
Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

ans = 0


for i in range(H):
    for j in range(W):
        # print(f"i{i} j{j}")
        cnt = 0
        if S[i][j] == ".":
            #右に進む
            for k in range(j+1, W):
                # print(f"rk{k}")
                if S[i][k] == "#":
                    # print("BBB")
                    break
                if k < W:
                    # print("c")                    
                    cnt += 1
            #左に進む
            for k in range(1, j+1):
                # print(f"lk{k}")
                if S[i][j-k] == "#":
                    # print("BBB")
                    break
                if k >= 0:
                    # print("c")
                    cnt += 1
            #下
            for k in range(i+1, H):
                # print(f"dk{k}")
                if S[k][j] == "#":
                    # print("BBB")
                    break
                if k < H:
                    # print("c")
                    cnt += 1
            #上
            for k in range(1, i+1):
                # print(f"uk{k}")
                if S[i-k][j] == "#":
                    # print("BBB")
                    break
                if k >= 0:
                    # print("c")
                    cnt += 1
        ans = max(ans, cnt+1)
        # print(f"ans{ans}--------------")
print(ans)

Fixed submission:
import numpy as np
h, w = map(int, input().split())
arr = np.array([list(input()) for _ in range(h)]) == "."
# print(arr)
l = np.zeros((h, w), dtype=int)
r = np.zeros((h, w), dtype=int)
u = np.zeros((h, w), dtype=int)
d = np.zeros((h, w), dtype=int)

for i in range(h):
    u[i] = (u[i - 1] + 1) * arr[i] #arrがFalseだと0になる
    d[- i - 1] = (d[- i] + 1) * arr[- i - 1]

for j in range(w):
    l[:, j] = (l[:, j-1] + 1) * arr[:, j]
    r[:, - j - 1] = (r[:, - j] + 1) * arr[:, - j - 1]
# print(u)
print(np.max(u + d + l + r) - 3)
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())

ans = 0
f = 1

while f:
    tmp = s
    f = 0
    for i in range(len(s)-2):
        if tmp[i:i+3] == ["A", "B", "C"]:
            s[i:i+3] = ["B", "C", "A"]
            ans += 1
            f = 1

print(ans)

Fixed submission:
s = input().replace("BC", "D")

ans = 0
cnt = 0
for i in s[::-1]:
    if i == "D":
        cnt += 1
    elif i == "A":
        ans += cnt
    else:
        cnt = 0



print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]
ans = [0 for _ in range(N)]
for i in range(M):
    start = LR[i][0]
    end = LR[i][1]
    for j in range(start-1, end):
        ans[j] += 1
cnt = 0
for k in ans:
    if k == M:
        cnt += 1

print(cnt)

Fixed submission:
N,M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]
L1 = []
R1 = []
for i in range(M):
    L1.append(LR[i][0])
    R1.append(LR[i][1])
if min(R1)>=max(L1):
    print(min(R1)-max(L1)+1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline
#再帰回数の上限を変更
# sys.setrecursionlimit(10**9)

N = int(input())
# v = [list(map(int, input().split())) for _ in range(N-1)]

edge = [[] for _ in range(N)]

for i in range(N-1):
    v1, v2, w = map(int, input().split())
    edge[v1-1].append((v2-1, w))
    edge[v2-1].append((v1-1, w))

color = [-1 for _ in range(N)]
color[0] = 1

def dfs(x):
    for v, w in edge[x]:
        if color[v] == -1:
            color[v] = (w + color[x])%2
            dfs(v)



dfs(0)
print(*color, sep="\n")

Fixed submission:
import sys
input=sys.stdin.buffer.readline
sys.setrecursionlimit(10**9)
n=int(input())
edges=[[] for i in range(n)]
for i in range(n-1):
    a,s,w=map(int,input().split())
    edges[a-1].append([s-1,w]);edges[s-1].append([a-1,w])
colors=[-1]*n
colors[0]=1
def dfs(now):
    for to,cost in edges[now]:
        if colors[to]==-1:
            colors[to]=(cost+colors[now])%2
            dfs(to)

dfs(0)
print(*colors,sep="\n")

Buggy python submission (verdict: Runtime Error):
N = int(input())
# v = [list(map(int, input().split())) for _ in range(N-1)]

edge = [[] for _ in range(N)]

for i in range(N-1):
    v1, v2, w = map(int, input().split())
    edge[v1-1].append((v2-1, w))
    edge[v2-1].append((v1-1, w))

color = [-1 for _ in range(N)]
color[0] = 1

def dfs(x):
    for v, w in edge[x]:
        if color[v] == -1:
            color[v] = (w + color[x])%2
            dfs(v)



dfs(0)
print(*color, sep="\n")

Fixed submission:
import sys
input=sys.stdin.buffer.readline
sys.setrecursionlimit(10**9)
n=int(input())
edges=[[] for i in range(n)]
for i in range(n-1):
    a,s,w=map(int,input().split())
    edges[a-1].append([s-1,w]);edges[s-1].append([a-1,w])
colors=[-1]*n
colors[0]=1
def dfs(now):
    for to,cost in edges[now]:
        if colors[to]==-1:
            colors[to]=(cost+colors[now])%2
            dfs(to)

dfs(0)
print(*colors,sep="\n")

Buggy python submission (verdict: Runtime Error):
N = int(input())
# v = [list(map(int, input().split())) for _ in range(N-1)]

edge = [[] for _ in range(N)]

for i in range(N-1):
    v1, v2, w = map(int, input().split())
    edge[v1-1].append((v2-1, w))
    edge[v2-1].append((v1-1, w))

color = [-1 for _ in range(N)]
color[0] = 1

def dfs(x):
    for v, w in edge[x]:
        if color[v] == -1:
            color[v] = (w + color[x])%2
            dfs(v)



dfs(0)
print(color)

Fixed submission:
import sys
input=sys.stdin.buffer.readline
sys.setrecursionlimit(10**9)
n=int(input())
edges=[[] for i in range(n)]
for i in range(n-1):
    a,s,w=map(int,input().split())
    edges[a-1].append([s-1,w]);edges[s-1].append([a-1,w])
colors=[-1]*n
colors[0]=1
def dfs(now):
    for to,cost in edges[now]:
        if colors[to]==-1:
            colors[to]=(cost+colors[now])%2
            dfs(to)

dfs(0)
print(*colors,sep="\n")
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())

cnt = 0
for r in range(N//R + 1):
    for b in range(N//B + 1):
        res = (N - r*R - b*B)
        if res >= 0 and res%G == 0:
            cnt += 1
print(cnt)

Fixed submission:
def main():
    R, G, B, N = map(int, input().split())

    cnt = 0
    for r in range(N//R + 1):
        for b in range(N//B + 1):
            res = (N - r*R - b*B)
            if res >= 0 and res%G == 0:
                cnt += 1
    print(cnt)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(numbers):
    return reduce(math.gcdm numbers)

N = int(input())
A = list(map(int, input().split()))

ans = []

if len(A) == 1:
    ans.append(A[0])
else:
    ans.append(gcd(A[1:]))
    ans.append(gcd(A[:N]))

    for i in range(1, N-1):
        l = []
        l.append(gcd(A[:i]))
        l.append(gcd(A[i+1:]))
        ans.append(gcd(l))

print(max(ans))

Fixed submission:
from math import gcd

N = int(input())
A = list(map(int, input().split()))

L = [0] * N
L[0] = A[0]

#配列の左から順番に最大公約数を求める
for i, a in enumerate(A):
    L[i] = gcd(L[max(0, i-1)], a)

# print("L", L)
R = [0] * N
R[0] = A[-1]

#配列の右から順番に最大公約数を求める
for i, a in enumerate(A[::-1]):
    R[i] = gcd(R[max(0, i-1)], a)

# print("R", R)
ans = 0

for i in range(N):
    #一番左の数字を削除
    if i == 0:
        ans = max(ans, R[N-2])
    #一番右の数字を削除
    elif i == N-1:
        ans = max(ans, L[N-2])
    #i+1番目の数字を削除
    else:
        ans = max(ans, gcd(L[i-1], R[N-i-2]))
    
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(numbers):
    return reduce(math.gcd, numbers)

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

ans = []
if len(a) != 1:
    ans.append(gcd(a[1:]))
    ans.append(gcd(a[:n]))

    for i in range(1, n-1):
        aaaa = []
        aaaa.append(gcd(a[:i]))
        aaaa.append(gcd(a[i+1:]))
        ans.append(gcd(aaaa))
else:
    ans.append(a[0])
    
print(max(ans))


Fixed submission:
from math import gcd

N = int(input())
A = list(map(int, input().split()))

L = [0] * N
L[0] = A[0]

#配列の左から順番に最大公約数を求める
for i, a in enumerate(A):
    L[i] = gcd(L[max(0, i-1)], a)

# print("L", L)
R = [0] * N
R[0] = A[-1]

#配列の右から順番に最大公約数を求める
for i, a in enumerate(A[::-1]):
    R[i] = gcd(R[max(0, i-1)], a)

# print("R", R)
ans = 0

for i in range(N):
    #一番左の数字を削除
    if i == 0:
        ans = max(ans, R[N-2])
    #一番右の数字を削除
    elif i == N-1:
        ans = max(ans, L[N-2])
    #i+1番目の数字を削除
    else:
        ans = max(ans, gcd(L[i-1], R[N-i-2]))
    
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(numbers):
    return reduce(math.gcd, numbers)

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

ans = []
ans.append(gcd(a[1:]))
ans.append(gcd(a[:n]))

for i in range(1, n-1):
    aaaa = []
    aaaa.append(gcd(a[:i]))
    aaaa.append(gcd(a[i+1:]))
    ans.append(gcd(aaaa))

print(max(ans))


Fixed submission:
from math import gcd

N = int(input())
A = list(map(int, input().split()))

L = [0] * N
L[0] = A[0]

#配列の左から順番に最大公約数を求める
for i, a in enumerate(A):
    L[i] = gcd(L[max(0, i-1)], a)

# print("L", L)
R = [0] * N
R[0] = A[-1]

#配列の右から順番に最大公約数を求める
for i, a in enumerate(A[::-1]):
    R[i] = gcd(R[max(0, i-1)], a)

# print("R", R)
ans = 0

for i in range(N):
    #一番左の数字を削除
    if i == 0:
        ans = max(ans, R[N-2])
    #一番右の数字を削除
    elif i == N-1:
        ans = max(ans, L[N-2])
    #i+1番目の数字を削除
    else:
        ans = max(ans, gcd(L[i-1], R[N-i-2]))
    
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
b = 0
w = s.count(".")
l = [w]
for i in range(1, n + 1):
    if s[i - 1] == "#":
        b += 1
    if s[i - 1] == ".":
        w -= 1
    l.append(b + w)
    print(l)
print(min(l))


Fixed submission:
n = int(input())
s = input()
b = 0
w = s.count(".")
l = [w]
for i in range(1, n + 1):
    if s[i - 1] == "#":
        b += 1
    if s[i - 1] == ".":
        w -= 1
    l.append(b + w)
    # print(l)
print(min(l))
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = [input() for i in range(n)]

ans = 0

for i in range(n):
    if max(h[0:i]) >= h[i] and h[0] >= h[i]:
        ans += 1

print(ans)

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

cnt = 0
for i in range(len(H)):
    if (max(H[0:i+1]) == H[i]):
        cnt += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
a = [int(input()) for i in range(5)]

a_one = [i % 10 for i in a if i % 10 != 0]
a_aaa = [i for i in a if i % 10 != 0]
a_aa = [i // 10 * 10 + 10 for i in a if i % 10 != 0]
a_two = [i for i in a if i % 10 == 0]
a_last = a_one.index(min(a_one))

ans = 0

for i in range(len(a_aa)):
    if i == a_last:
        continue
    else:
        ans += a_aa[i]

for i in a_two:
    ans += i

ans += a_aaa[a_last]
print(ans)

Fixed submission:
A = [int(input()) for i in range(5)]
B = [a - a % 10 + 10 if a % 10 != 0 else a for a in A]
diff = [(b - a) for a, b in zip(A, B)]

print(sum(B)-max(diff))
Buggy python submission (verdict: Runtime Error):
s = input()
ans = []
acgt = ["A", "C", "G", "T"]

cnt = 0
for i in range(len(s)):
    if s[i] in acgt:
        cnt += 1
    else:
        ans.append(cnt)
        cnt = 0
print(max(ans))


Fixed submission:
s = input()
ans = []
acgt = ["A", "C", "G", "T"]

cnt = 0
for i in range(len(s)):
    if s[i] in acgt:
        cnt += 1
    else:
        ans.append(cnt)
        cnt = 0
ans.append(cnt)
print(max(ans))
Buggy python submission (verdict: Runtime Error):
A, B, K = list(map(int, input().split()))

if A < B:
    n = A
else:
    n = B

l = []
for i in range(1, n):
    if A % i == 0 and B % i == 0:
        l.append(i)

print(l[-K])

Fixed submission:
A, B, K = list(map(int, input().split()))

if A < B:
    n = A
else:
    n = B

l = []
for i in range(1, n+1):
    if A % i == 0 and B % i == 0:
        l.append(i)

print(l[-K])

Buggy python submission (verdict: Runtime Error):
A, B, K = list(map(int, input().split()))

if A > B:
    n = A
else:
    n = B

l = []
for i in range(1, n):
    if A % i == 0 and B % i == 0:
        l.append(i)

print(l[-K])

Fixed submission:
A, B, K = list(map(int, input().split()))

if A < B:
    n = A
else:
    n = B

l = []
for i in range(1, n+1):
    if A % i == 0 and B % i == 0:
        l.append(i)

print(l[-K])
Buggy python submission (verdict: Runtime Error):
N = int(input())
h = list(map(int, input().split())) + [0]*10010

dp = [float("inf")]*10010
dp[0] = 0

for i in range(N):
    dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]))
    dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i]))
    # print(dp)
print(dp[N-1])

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

dp = [0]*n
for i in range(n):
    if i >= 2:
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]))
    elif i == 1:
        dp[i] = abs(a[i]-a[i-1])
print(dp[-1])

Buggy python submission (verdict: Runtime Error):
N = int(input())
h = list(map(int, input().split())) + [0, 0, 0]

dp = [float("inf")]*10010
dp[0] = 0

for i in range(N):
    dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]))
    dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i]))
    # print(dp)
print(dp[N-1])

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

dp = [0]*n
for i in range(n):
    if i >= 2:
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]))
    elif i == 1:
        dp[i] = abs(a[i]-a[i-1])
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = list(map(int, input().split())) + [0]*100010

dp = [float("inf")]*100010
dp[0] = 0

for i in range(N):
    for k in range(1, K+1):
        dp[i+k] = min(dp[i+k], dp[i] + abs(h[i+k] - h[i]))
    # print(dp)
print(dp[N-1])

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

dp = [float("inf") for i in range(n)]
dp[0] = 0
for i in range(n-1):
    for j in range(1, min(k+1, n-i)):
        dp[i+j] = min(dp[i+j], dp[i]+abs(a[i+j]-a[i]))

print(dp[-1])

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = list(map(int, input().split())) + [0]*100010

dp = [float("inf")]*100010
dp[0] = 0

for i in range(N):
    for k in range(1, K+1):
        dp[i+k] = min(dp[i+k], dp[i] + abs(h[i+k] - h[i]))
    # print(dp)
print(dp[N-1])

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

dp = [float("inf") for i in range(n)]
dp[0] = 0
for i in range(n-1):
    for j in range(1, min(k+1, n-i)):
        dp[i+j] = min(dp[i+j], dp[i]+abs(a[i+j]-a[i]))

print(dp[-1])

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = list(map(int, input().split())) + [0]*100010

dp = [float("inf")]*100010
dp[0] = 0

for i in range(N):
    for k in range(1, K+1):
        dp[i+k] = min(dp[i+k], dp[i] + abs(h[i+k] - h[i]))
    # print(dp)
print(dp[N-1])

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

dp = [float("inf") for i in range(n)]
dp[0] = 0
for i in range(n-1):
    for j in range(1, min(k+1, n-i)):
        dp[i+j] = min(dp[i+j], dp[i]+abs(a[i+j]-a[i]))

print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = list(map(int, input().split())) + [0]*100010

dp = [float("inf")]*100010
dp[0] = 0

for i in range(N):
    for k in range(1, K+1):
        dp[i+k] = min(dp[i+k], dp[i] + abs(h[i+k] - h[i]))
    # print(dp)
print(dp[N-1])

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

dp = [float("inf") for i in range(n)]
dp[0] = 0
for i in range(n-1):
    for j in range(1, min(k+1, n-i)):
        dp[i+j] = min(dp[i+j], dp[i]+abs(a[i+j]-a[i]))

print(dp[-1])

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

dp = [float("inf") for i in range(n)]
dp[0] = 0
for i in range(n-1):
    for j in range(1, min(k+1, n-i)):
        dp[i+j] = min(dp[i+j], dp[i]+abs(a[i+j]-a[i]))

print(dp[-1])

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

dp = [float("inf") for i in range(n)]
dp[0] = 0
for i in range(n-1):
    for j in range(1, min(k+1, n-i)):
        dp[i+j] = min(dp[i+j], dp[i]+abs(a[i+j]-a[i]))

print(dp[-1])