Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a, b = int(input().split())
if a*b % 2 == 0:
  print("Even")
else:
  print("Odd")

Fixed submission:
a, b = map(int, input().split())
if a*b % 2 == 0:
  print("Even")
else:
  print("Odd")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lt=input().split(" ")
ans=1
for i in range(n):
    ans*=int(lt[i])
if(ans<=10**18):
    print(ans)
else:
    print(-1)

Fixed submission:
n = int(input())
A = [*map(int,input().split())]
ok = 0
ans = 1
lim = 10**18
for i in range(n):
  ans *= A[i]
  if(ans>lim):
      ok =1
      break
if(ok and 0 not in A):
    print(-1)
elif(0 in A):
    print(0)
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
ok=True
i=0
a,b,c,d=map(int,input().split())
k=c//b
c-=bk
a-=d(k)
if(a<=0 and c!=0):
    print("No")
else:
    print("Yes")

Fixed submission:
ok=True
i=0
a,b,c,d=map(int,input().split())
k=c//b
c-=b*k
a-=d*(k)
if(a<=0 and c!=0):
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
n = int(input())
*a, = map(int,input().split())
g = []
M = 10**5+1
for i in range(1,5):
    g.append((i,0))
g = dict(g); s = 0
for A in a:
    g[A] += 1
    s += A
q = int(input())
for loop in range(q):
    b,c = map(int,input().split())
    if g[b] == 0:
        print(s)
        continue
    s += g[b] * (c - b)
    g[c] += g[b]
    g[b] == 0
    print(s)


Fixed submission:
n = int(input())
*a, = map(int,input().split())
M = 10**5+1
g = [0] * M
s = 0
for A in a:
    g[A] += 1
    s += A

q = int(input())
for loop in range(q):
    b,c = map(int,input().split())
    if g[b] == 0:
        print(s)
        continue
    s += g[b] * (c - b)
    g[c] += g[b]
    g[b] = 0
    print(s)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque,Counter
import bisect
n,*a = map(int,open(0).read().split())
c = Counter(a)
c = sorted(c.items())
a = deque(c)
p_set = set()
ans,r = 0,0
while a:
    f,count = a.popleft()
    z = []
    for u in range(len(a)):
        if a[u][0]%f != 0:
            z.append(a[u])
    a = deque(z[:])
    if count != 1:
        r += 1
    p_set.add(f)
print(len(p_set)-r)


Fixed submission:
_,*a = map(int,open(0).read().split())
a.sort()
ans = 0
#M = 30
M = 10**6 + 1
l = [0] * (M)
ans = 0
for i in range(len(a)):
    if l[a[i]] == 0:
        l[a[i]] = 2
        ans += 1
        for x in range(a[i]*2, M, a[i]):
            l[x] = 1
    elif l[a[i]] == 2:
        ans -= 1
        l[a[i]] -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque,Counter
n,*a = map(int,open(0).read().split())
c = Counter(a)
c = sorted(c.items())
a = deque(c)
p_set = set()
ans = 0
while a:
    f,count = a.popleft()
    if count == 1:
        for ff in p_set:
            if f%ff == 0: 
                break
        else:
            ans += 1
    p_set.add(f)
print(ans)


Fixed submission:
_,*a = map(int,open(0).read().split())
a.sort()
ans = 0
#M = 30
M = 10**6 + 1
l = [0] * (M)
ans = 0
for i in range(len(a)):
    if l[a[i]] == 0:
        l[a[i]] = 2
        ans += 1
        for x in range(a[i]*2, M, a[i]):
            l[x] = 1
    elif l[a[i]] == 2:
        ans -= 1
        l[a[i]] -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b = map(str,input().split())
a = int(a)
b1,b2 = map(int,b.split("."))
ans = a* (b1 * 100 + b2)
print(ans//100)


Fixed submission:
a,b = map(int,input().split())
print(a*b)
Buggy python submission (verdict: Runtime Error):
from collections import deque
n,m = map(int,input().split())

net = [[] for _ in range(n+1)]
for _ in range(m):
    a,b = map(int,input().split())

    net[a].append(b)
    net[b].append(a)

a = [-1] * (n+1)
d = deque()
d.append(1)
while d:
    u = d.popleft()
    for child in net[u]:
        if a[child] != -1:continue
        a[child] = u
        d.append(child)
print("Yes")
print(*a[2:], seq = " ")


Fixed submission:
from collections import deque
n,m = map(int,input().split())

path = []
net = [[] for _ in range(n+1)]
for _ in range(m):
    a,b = map(int,input().split())

    net[a].append(b)
    net[b].append(a)

a = [-1] * (n+1)
d = deque()
d.append(1)
while d:
    u = d.popleft()
    for child in net[u]:
        if a[child] != -1:continue
        a[child] = u
        d.append(child)
a = a[2:]
for z in a:
    if z == -1:
        print("No")
        exit()
print("Yes")
for z in a:
    print(z)
Buggy python submission (verdict: Runtime Error):
n,k =map(int,input().split())
a=list(map(int,input().split()))
a = [1] + a
def next(i):
    return a[i]

z = [0] * (n+1)

place = 1
T = 0
interval = 0
if k < n:
    for i in range(k):
        place = next(place)
    print(place);exit()
place = 0
for i in range(n):
    place = next(place)
    if z[place] != 0:
        interval = T - z[place]
        break
    z[place] = T
    T += 1
m = (k-z[place])%interval
for i in range(m):
    place = next(place)
print(place)


Fixed submission:
n,k =map(int,input().split())
a=list(map(int,input().split()))
a = [1] + a
def next(i):
    return a[i]

z = [0] * (n+1)

place = 1
T = 0
interval = 0
if k < n:
    for i in range(k):
        place = next(place)
    print(place);exit()
place = 0
k += 1
for i in range(n):
    place = next(place)
    if z[place] != 0:
        interval = T - z[place]  + 1
        break
    z[1] = 1 
    T += 1
    z[place] = T

m = (k-z[place])%interval
for i in range(m):
    place = next(place)
print(place)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
sum = 0
if n < 4:
    print(0);exit()
for i in range(n):
    for j in range(i+1,n):
        if s[i] == s[j]:
            continue
        dis = j - i
        for k in range(j+ 1,n):

            if s[k] == s[i] or s[k] == s[j] or k - j == dis:
                continue
            sum += 1
print(sum)



Fixed submission:
n = int(input())
s = input()
sum = 0
if n < 4:print(0);exit()
r = 0;g = 0; b = 0;
for i in range(len(s)):
    if s[i] == "R":
        r += 1
    if s[i] == "G":
        g += 1
    if s[i] == "B":
        b += 1
sum = r*g*b
for i in range(n):
    for j in range(i+1,n):
        dis = j - i
        k = j + dis
        if k >= n:break
#        print(i,j,k)
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i] :
            sum -= 1
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
x,y,a,b,c = map(int,input().split())

p = deque(sorted(list(map(int,input().split()))))
q = deque(sorted(list(map(int,input().split()))))
r = deque(sorted(list(map(int,input().split()))))

ans = deque(maxlen=(x+y))

def insertion(z):
	global x,y
	if z == p:
		x -= 1
	else:
		y -= 1
	return ans.append(z.pop())

while x > 0 or y > 0:
	if x and y:
		if p[-1] > q[-1] :
			insertion(p)
		else:
			insertion(q)
	elif not x:
		insertion(q)
	else:
		insertion(p)

while r:
	if ans[-1] < r[-1]:
		ans.appendleft(r.pop())

print(sum(ans))



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

p = deque(sorted(list(map(int,input().split()))))
q = deque(sorted(list(map(int,input().split()))))
r = deque(sorted(list(map(int,input().split()))))

ans = deque(maxlen=(x+y))

def insertion(z):
	global x,y
	if z == p:
		x -= 1
	else:
		y -= 1
	return ans.append(z.pop())

while x > 0 or y > 0:
	if x and y:
		if p[-1] > q[-1] :
			insertion(p)
		else:
			insertion(q)
	elif not x:
		insertion(q)
	else:
		insertion(p)

while r:
	if ans[-1] < r[-1]:
		ans.appendleft(r.pop())
	else:
		break

print(sum(ans))

Buggy python submission (verdict: Runtime Error):
from collections import deque
x,y,a,b,c = map(int,input().split())

p = deque(sorted(list(map(int,input().split()))))
q = deque(sorted(list(map(int,input().split()))))
r = deque(sorted(list(map(int,input().split()))))

ans = deque(maxlen=(x+y))

def insertion(z):
	global x,y
	if z == p:
		x -= 1
	else:
		y -= 1
	return ans.append(z.pop())

while x > 0 or y > 0:
	if x and y:
		if p[-1] > q[-1] :
			insertion(p)
		else:
			insertion(q)
	elif not x:
		insertion(q)
	else:
		insertion(p)


while ans[-1] < r[-1]:
		ans.pop()
		ans.appendleft(r.pop())

print(sum(ans))



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

p = deque(sorted(list(map(int,input().split()))))
q = deque(sorted(list(map(int,input().split()))))
r = deque(sorted(list(map(int,input().split()))))

ans = deque(maxlen=(x+y))

def insertion(z):
	global x,y
	if z == p:
		x -= 1
	else:
		y -= 1
	return ans.append(z.pop())

while x > 0 or y > 0:
	if x and y:
		if p[-1] > q[-1] :
			insertion(p)
		else:
			insertion(q)
	elif not x:
		insertion(q)
	else:
		insertion(p)

while r:
	if ans[-1] < r[-1]:
		ans.appendleft(r.pop())
	else:
		break

print(sum(ans))
Buggy python submission (verdict: Runtime Error):
import math as m
a,b,c = map(int,input().split())
if (c - a - b)**2 < 10**9:
	print("Yes" if 4*a*b < (c - a - b)**2 else "No")
else:
	print("Yes" if m.log(4*a*b) < 2*m.log((c - a - b)) else "No")



Fixed submission:
import math as m
a,b,c = map(int,input().split())
print("Yes" if 4*(a*b) < (c - a - b)**2 and c-a-b > 0 else "No")

Buggy python submission (verdict: Runtime Error):
import math as m
a,b,c = map(int,input().split())
if (c - a - b)**2 < 10**9:
	print("Yes" if 4*a*b < (c - a - b)**2 else "No")
else:
	print("Yes" if m.log(4*a*b) < 2*log((c - a - b)) else "No")



Fixed submission:
import math as m
a,b,c = map(int,input().split())
print("Yes" if 4*(a*b) < (c - a - b)**2 and c-a-b > 0 else "No")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
s = input()
flag = 0
for i in range(int(input())):
	X = sys.stdin.readline().split()
	if int(X[0]) == 1:
		flag = flag^1	
	elif (int(X[1])-1)^flag == 0:
		s = X[2] + s
	else:
		s = s + X[2]
if flag == 1:
	print(s[::-1])
else:
	print(s)


Fixed submission:
import sys
s = input()
flag = 0
s1 = ""
s2 = ""

for i in range(int(input())):
	X = sys.stdin.readline().split()
	if int(X[0]) == 1:
		flag = flag^1	
	elif (int(X[1])-1)^flag == 0:
		s1 += X[2]
	else:
		s2 += X[2]
s3 = s1[::-1]+s+s2
if flag:
	print(s3[::-1])
else:
	print(s3)
Buggy python submission (verdict: Runtime Error):
n,k,s = map(int,input().split())

a = [0] * n
a[0] = s
a[k] = s+1+(s==1)-(s==10**9)*s
print(*a)



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

a = [s] * n
for i in range(k,n):
    a[i] +=1-(s==10**9)*s
print(*a)

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

a = [0] * n
a[0] = s
a[k] = s+1+(s==1)
print(*a)



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

a = [s] * n
for i in range(k,n):
    a[i] +=1-(s==10**9)*s
print(*a)
Buggy python submission (verdict: Runtime Error):
from collections import deque
p = 10**9+7
x,y = map(int,input().split())
x += 1 ; y += 1
map_a=[[0]*y for _ in range(x)]
d = [(2,1),(1,2)]
que = deque()
que.append((0,0))

map_a[0][0] = 1

while que:
    a,b = que.popleft()
    for u,v in d:
        m = a + u ; n = b + v
        if 0<=m<x and 0<=n<y:
            map_a[m][n] += map_a[a][b]%p
            que.append((m,n))

print(map_a[-1][-1])


Fixed submission:
x,y = map(int,input().split())
m = 10**9+7
if not((x+y)%3== 0 and abs(x-y)<=(x+y)//3):
    print(0);exit()

def comb(n,k):
    #if 2 * k > n:
        #k = n - k
    a = 1
    for i in range(1,k+1):
        a *= (n - ( i - 1)) * pow(i,m-2,m)
        a = a%m
    return a

n = (x+y)//3
k = x-n
print(comb(n,k))

Buggy python submission (verdict: Runtime Error):
from collections import deque
p = 10**9+7
x,y = map(int,input().split())
x += 1 ; y += 1
map_a=[[0]*y for _ in range(x)]
d = [(2,1),(1,2)]
que = deque()
que.append((0,0))

map_a[0][0] = 1

print(map_a)
while que:
    a,b = que.popleft()
    for u,v in d:
        m = a + u ; n = b + v
        if 0<=m<x and 0<=n<y:
            map_a[m][n] += map_a[a][b]%p
            que.append((m,n))

print(map_a[-1][-1])


Fixed submission:
x,y = map(int,input().split())
m = 10**9+7
if not((x+y)%3== 0 and abs(x-y)<=(x+y)//3):
    print(0);exit()

def comb(n,k):
    #if 2 * k > n:
        #k = n - k
    a = 1
    for i in range(1,k+1):
        a *= (n - ( i - 1)) * pow(i,m-2,m)
        a = a%m
    return a

n = (x+y)//3
k = x-n
print(comb(n,k))
Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q = map(int,input().split())
A = [int(input()) for x in range(Q)]
for i in range(N):
  z = 0
  for j in range(Q):
    if A[j] == i + 1:
      z += 1
  if z > Q - K:
    print('Yes')
  else:
    print('No')
 
    


Fixed submission:
N,K,Q = map(int,input().split())
A = [int(input()) for x in range(Q)]
ans = [K - Q] * N


for j in range(Q):
  ans[A[j] - 1] += 1
  
for i in range(N):
  print('Yes' if ans[i] > 0 else 'No')
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a = [int(c) for c in input().split()]
a.sort()
for i in range(m):
	a[-1] = a[-1]//2
	a.sort()
	
print(sum(a))


Fixed submission:
n,m = map(int,input().split())
a = [int(c) for c in input().split()]
from heapq import *
from math import *
a = [-i for i in a]
heapify(a)
while m > 0:
	heappush(a,-((-heappop(a))//2))
	m -=1
print(-sum(a))
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int,input().split()))
c,ans= 0
if N == 1:
    print(0)
else:
    for i in range(N-1):
        if H[i+1] <= H[i]:
            c += 1
        else:
            ans = max(c,ans)
            c = 0
print(c)

Fixed submission:
N = int(input())
H = list(map(int,input().split()))
c = 0
ans = 0
if N == 1:
    print(0)
else:
    for i in range(N-1):
        if H[i+1] <= H[i]:
            c += 1
        else:
            ans = max(c,ans)
            c = 0
    ans = max(c,ans)
    print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
#S = [input() for _ in range(N)]
S = ["".join(sorted(input())) for _ in range(N)]

ans = 0
for i in range(N):
    for j in range(i+1,N):
        if S[i] == S[j]:
            ans += 1
            S.pop(j)
            break
        break
print(ans)

Fixed submission:
N = int(input())
S =  ["".join(sorted(input())) for _ in range(N)]

Sdic = {}
ans = 0

for i in range(N):
    if S[i] not in Sdic.keys():
        Sdic[S[i]] = 1
    else:
        ans += Sdic[S[i]]
        Sdic[S[i]] += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
#S = [input() for _ in range(N)]
S = ["".join(sorted(input())) for _ in range(N)]

ans = 0
for i in range(N):
    for j in range(i+1,N):
        if S[i] == S[j]:
            ans += 1
            S.pop(j)
            break
print(ans)

Fixed submission:
N = int(input())
S =  ["".join(sorted(input())) for _ in range(N)]

Sdic = {}
ans = 0

for i in range(N):
    if S[i] not in Sdic.keys():
        Sdic[S[i]] = 1
    else:
        ans += Sdic[S[i]]
        Sdic[S[i]] += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
#S = [input() for _ in range(N)]
S = ["".join(sorted(input())) for _ in range(N)]

ans = 0
for i in range(N):
    for j in range(i+1,N):
        if S[i] == S[j]:
            ans += 1
    
print(ans)

Fixed submission:
N = int(input())
S =  ["".join(sorted(input())) for _ in range(N)]

Sdic = {}
ans = 0

for i in range(N):
    if S[i] not in Sdic.keys():
        Sdic[S[i]] = 1
    else:
        ans += Sdic[S[i]]
        Sdic[S[i]] += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
for i in range(n-1):
    if h[i] < h[i+1]:
        h[i+1] -= 1

    elif h[i] > h[i+1]:
        print('No')
        exit()

print('Yes')

Fixed submission:
n = int(input())
h = list(map(int,input().split()))
h[0] -= 1
for i in range(n-1):
    if h[i] < h[i+1]:
        h[i+1] -= 1

    elif h[i] > h[i+1]:
        print('No')
        exit()

print('Yes')

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

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

    elif h[i] > h[i+1]:
        print('No')
        exit()

print('Yes')

Fixed submission:
n = int(input())
h = list(map(int,input().split()))
h[0] -= 1
for i in range(n-1):
    if h[i] < h[i+1]:
        h[i+1] -= 1

    elif h[i] > h[i+1]:
        print('No')
        exit()

print('Yes')
Buggy python submission (verdict: Runtime Error):
 a = list(map(int,input().split()))
if sum(a)%2 == 0:
    print(sum(a)//2)
else:
    print('IMPOSSIBLE')

Fixed submission:
a = list(map(int,input().split()))
if sum(a)%2 == 0:
    print(sum(a)//2)
else:
    print('IMPOSSIBLE')

Buggy python submission (verdict: Runtime Error):
n,*p = map(int,open(0).read().split())
ans = 0
for i in range(n):
    if i+1 != p[i]:
        if i+1 == p[p[i]-1]:
            ans += 1

print('YES' if ans == 0 or 2 else 'NO')

Fixed submission:
a = list(map(int,input().split()))
if sum(a)%2 == 0:
    print(sum(a)//2)
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
n,*p = map(int,open().read().split())
ans = 0
for i in range(n):
    if i+1 != p[i]:
        ans += 1
print('YES' if ans == 2 else 'NO')

Fixed submission:
n,*p = map(int,open(0).read().split())
ans = 0
for i in range(n):
    if i+1 != p[i]:
        ans += 1
print('YES' if ans == 2 or ans == 0 else 'NO')

Buggy python submission (verdict: Runtime Error):
n,*p = map(int,open('abc135.txt').read().split())
ans = 0
for i in range(n):
    if i+1 != p[i]:
        if i+1 == p[p[i]-1]:
            ans += 1

print('YES' if ans == 0 or 2 else 'NO')

Fixed submission:
n,*p = map(int,open(0).read().split())
ans = 0
for i in range(n):
    if i+1 != p[i]:
        ans += 1
print('YES' if ans == 2 or ans == 0 else 'NO')

Buggy python submission (verdict: Runtime Error):
n,*p = map(int,open('abc135.txt').read().split())
ans = 0
for i in range(n):
    if i+1 != p[i]:
        if i+1 == p[p[i]-1]:
            ans += 1

print('Yes' if ans == 0 or 2 else 'No')

Fixed submission:
n,*p = map(int,open(0).read().split())
ans = 0
for i in range(n):
    if i+1 != p[i]:
        ans += 1
print('YES' if ans == 2 or ans == 0 else 'NO')
Buggy python submission (verdict: Runtime Error):
def main():

    n,*a = map(int,open('abc134_c.txt').read().split())
    b = sorted(a)
    max = b[-1]
    maxs= b[-2]

    for i in range(n):
        if a[i] == max:
            print(maxs)
        else:
            print(max)
    return()

if __name__=='__main__':
    main()

Fixed submission:
n,*a = map(int,open(0).read().split())
b = sorted(a)
max = b[-1]
maxs= b[-2]

for i in range(n):
    if a[i] == max:
        print(maxs)
    else:
        print(max)
Buggy python submission (verdict: Runtime Error):
cat ./atcoder/ABC133A.py
n,a,b = map(int,raw_input().split())
print (min(a*n,b))

Fixed submission:
n,a,b = map(int,raw_input().split())
print (min(a*n,b))

Buggy python submission (verdict: Runtime Error):
cat ./atcoder/ABC133A.py
n,a,b = map(int,raw_input().split())
print (min(a*n,b))

Fixed submission:
n,a,b = map(int,raw_input().split())
print (min(a*n,b))
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7
input = sys.stdin.readline

def inp():
    return int(input())
def inpl():
    return list(map(int,input().split()))
def inpm():
    return map(int,input().split())

n,m = inpm()
dp = [0] * (n+2)
for _ in range(m):
    a = int(input())
    dp[a] = -1

# init
dp[0] = 1
# start
print(a)
for i in range(n):
    if dp[i] == -1:continue
    dp[i] %= mod
    if dp[i+1] != -1:
        dp[i+1] += dp[i]
    if dp[i+2] != -1:
        dp[i+2] += dp[i]

print(dp[n]%mod)


Fixed submission:
import sys
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7
input = sys.stdin.readline

def inp():
    return int(input())
def inpl():
    return list(map(int,input().split()))
def inpm():
    return map(int,input().split())

n,m = inpm()
dp = [0] * (n+2)
for _ in range(m):
    a = int(input())
    dp[a] = -1

# init
dp[0] = 1
# start
for i in range(n):
    if dp[i] == -1:continue
    dp[i] %= mod
    if dp[i+1] != -1:
        dp[i+1] += dp[i]
    if dp[i+2] != -1:
        dp[i+2] += dp[i]
print(dp[n]%mod)
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(input())
h = np.array(read().split(),dtype=np.int32)
dp = np.zeros(n,dtype=np.int32)
k = 2

for i in range(1,n):

    l = max(i-k,0)
    dp[i] = np.min(np.abs(h[i]-h[l:i])+dp[l:i])

print(dp[-1])


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,*H = list(map(int,read().split()))
h = [0]
h.extend(H)

dp = [100] * (n+1)
dp[1] = 0
dp[2] = abs(h[2]-h[1])

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

print(dp[-1])

Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,*h = list(map(int,read().split()))
h = [0,*h]

dp = [100] * (n+1)
dp[1] = 0
dp[2] = abs(h[2]-h[1])

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

print(dp[-1])


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,*H = list(map(int,read().split()))
h = [0]
h.extend(H)

dp = [100] * (n+1)
dp[1] = 0
dp[2] = abs(h[2]-h[1])

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

print(dp[-1])

Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,*h = list(map(int,read().split()))
h = [0,*h]

dp = [100] * (n+1)
dp[1] = 0
dp[2] = abs(h[2]-h[1])

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

print(dp[-1])


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,*H = list(map(int,read().split()))
h = [0]
h.extend(H)

dp = [100] * (n+1)
dp[1] = 0
dp[2] = abs(h[2]-h[1])

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

print(dp[-1])

Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

h = list(map(int,read().split()))
n = len(h)-1
if n == 2:
    print(abs(h[1]-h[-1]));exit()

dp = [-1]*(n+1)

dp[2] = 20
dp[3] = 30

def sdp(j):
    if j == 2:
        return 20
    elif j == 3:
        return 30
    elif dp[j] != -1:
        return dp[j]
    else:
        dp[j] = min(sdp(j-2)+abs(h[j]-h[j-2]),sdp(j-1)+abs(h[j]-h[j-1]))
        return dp[j]
sdp(n)
print(dp[-1])


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,*H = list(map(int,read().split()))
h = [0]
h.extend(H)

dp = [100] * (n+1)
dp[1] = 0
dp[2] = abs(h[2]-h[1])

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

print(dp[-1])