Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

a = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

arr0 = factorization(a) 


arr1 = [arr0[i][0] for i in range(len(arr0))]
arr2 = [arr0[i][1] for i in range(len(arr0))]

ab = []
for i in range(len(arr1)):
    for j in range(arr2[i]):
        ab.append(arr1[i])

abc = []
for i in range(1,sum(arr2)+1):
    abc.extend(list(itertools.combinations(ab, i)))

abcd = []

for i in range(len(abc)):
    g = 1
    for j in range(len(abc[i])):
        g *= abc[i][j]
    
    abcd.append(g)


abcde = [[i,a//i] for i in abcd]
abcdef = [sum(abcde[i]) for i in range(len(abcde))]
print(min(abcdef)-2)

Fixed submission:
import itertools

a = int(input())

def md(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)

    # divisors.sort()
    return divisors

ab = [[i,a//i] for i in md(a)]
abc = [sum(ab[i]) for i in range(len(ab))]

print(min(abc)-2)
Buggy python submission (verdict: Runtime Error):
import math

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

if x < a*a*b/2:
    print(90-math.degrees(math.atan(2*x/(a * (b**2)))))
    
else:
    print(90-math.degrees(math.atan(a**3 / (2*(a*a*b-x)))))


Fixed submission:
import math

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

if (a ==1 and b==1 and x ==1) or (a*a*b == x):
    print(0)    

elif x < a*a*b/2:
    print(90-math.degrees(math.atan(2*x/(a * (b**2)))))
    
else:
    print(90-math.degrees(math.atan(a**3 / (2*(a*a*b-x)))))
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

arr = []
arr.append(s[1])
for i in range(n-1):
    if s[i+1] != s[i]:
        arr.append(s[i+1])


c = len(arr)
print(c)

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

arr = []
arr.append(s[0])
for i in range(n-1):
    if s[i+1] != s[i]:
        arr.append(s[i+1])


c = len(arr)
print(c)

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

arr = []
arr.append(s[1])
for i in range(n-1):
    if s[i+1] != s[i]:
        arr.append(s[i+1])
        
c = len("".join(arr))
if c == 0:
    print(1)
else:
    print(c)



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

arr = []
arr.append(s[0])
for i in range(n-1):
    if s[i+1] != s[i]:
        arr.append(s[i+1])


c = len(arr)
print(c)

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

arr = []
arr.append(s[1])
for i in range(n-1):
    if s[i+1] != s[i]:
        arr.append(s[i+1])



        
c = len("".join(arr))
print(arr)
if c == 0:
    print(1)
else:
    print(c)

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

arr = []
arr.append(s[0])
for i in range(n-1):
    if s[i+1] != s[i]:
        arr.append(s[i+1])


c = len(arr)
print(c)

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

arr = []

for i in range(n-1):
    if s[i+1] != s[i]:
        arr.append(s[i+1])
        

if s[-1] != s[-2]:
    arr.append(s[-1])

c = len("".join(arr))

if c == 0:
    print(1)
else:
    print(c)

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

arr = []
arr.append(s[0])
for i in range(n-1):
    if s[i+1] != s[i]:
        arr.append(s[i+1])


c = len(arr)
print(c)

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

arr = []

for i in range(n-1):
    if s[i] != s[i+1]:
        arr.append(s[i])
        

if s[-1] != s[-2]:
    arr.append(s[-1])

c = len("".join(arr))

if c == 0:
    print(1)
else:
    print(c)




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

arr = []
arr.append(s[0])
for i in range(n-1):
    if s[i+1] != s[i]:
        arr.append(s[i+1])


c = len(arr)
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
arr = sorted(list(map(int,input().split())))

count = 0

for a in range(n-2):
    for b in range(a+1,n-1):
        for c in range(b+1,n):
            if arr[a]<arr[b]+arr[c] and arr[b]<arr[c]+arr[a] and arr[c]<arr[a]+arr[b]:
                count +=1
            else:
                break

print(count)

Fixed submission:

n = int(input())
arr = list(map(int,input().split()))
arr.sort()

count = 0

for a in range(n-2):
    k = a+2
    for j in range(a+1,n):
        while (k < n and arr[a] + arr[j] > arr[k]):
            k+=1
        
        if k>j:
            count += k-j-1
        
print(count)

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

count = 0

for a in range(n-2):
    for b in range(a+1,n-1):
        for c in range(b+1,n):
            if arr[a]<arr[b]+arr[c] and arr[b]<arr[c]+arr[a] and arr[c]<arr[a]+arr[b]:
                count +=1

print(count)

Fixed submission:

n = int(input())
arr = list(map(int,input().split()))
arr.sort()

count = 0

for a in range(n-2):
    k = a+2
    for j in range(a+1,n):
        while (k < n and arr[a] + arr[j] > arr[k]):
            k+=1
        
        if k>j:
            count += k-j-1
        
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
num,k,q = map(int,input().split())

arr = [k]*num


for i in range(q):
    a = int(input())
    arr = [i-1 for i in arr]
    arr[a-1] +=1


for i in range(len(arr)):
    if arr[i] > 0:
        print("Yes")
    else:
        print("No")
    

Fixed submission:
num,k,q = map(int,input().split())

arr = [0]*num


for i in range(q):
    a = int(input())
    arr[a-1] +=1

arr = [i-(q-k) for i in arr]

for i in range(len(arr)):
    if arr[i] > 0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())

arra = list(input())
arr = arra[:]
count = []
count0 = 0
for i in range(len(arr)-1):
    if arr[i]==arr[i+1]:
        count0+=1
count.append(count0)

        
for _ in range(k):
    whl = [i for i, x in enumerate(arr) if x == 'L']
    whr = [i for i, x in enumerate(arr) if x == 'R']
    suma=[]
    for i in range(1,len(whl)-1):
        suma.append(whl[i+1]-whl[i-1])
    
    sumb=[]
    for i in range(1,len(whr)-1):
        sumb.append(whr[i+1]-whr[i-1])

    
    if len(suma)==0:
        suma = [0]
    if len(sumb)==0:
        sumb = [0]
        
    
    if max(suma) > max(sumb):
        na = suma.index(max(suma))
        
        arr[whl[na]+1:whl[na+2]] = arr[whl[na]+1:whl[na+2]][::-1]
        for i in range(whl[na]+1,whl[na+2]):
            if arr[i] == "L":
                arr[i] = "R"
            else:
                arr[i] = "L"

    
    else:
        nb = sumb.index(max(sumb))
        
        arr[whr[nb]+1:whr[nb+2]-1] = arr[whr[nb]+1:whr[nb+2]-1][::-1]
        for i in range(whr[nb]+1,whr[nb+2]):
            if arr[i] == "L":
                arr[i] = "R"
            else:
                arr[i] = "L"

    count0 = 0
    for i in range(len(arr)-1):
        if arr[i]==arr[i+1]:
            count0+=1
    count.append(count0)

print(max(count))

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

ans = 0
for i in range(n-1):
    if arr[i] == arr[i+1]:
        ans +=1

ans +=k*2

if ans>n-1:
    ans = n-1

print(ans)

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

arr = list(input())

for _ in range(k):
    whl = [i for i, x in enumerate(arr) if x == 'L']
    whr = [i for i, x in enumerate(arr) if x == 'R']
    a=[]
    for i in range(1,len(whl)):
        a.append(whl[i]-whl[i-1])
    
    b=[]
    for i in range(1,len(whr)):
        b.append(whr[i]-whr[i-1])
    
    suma = []
    for i in range(len(a)-1):
        suma.append(a[i]+a[i+1])
    
    sumb = []
    for i in range(len(b)-1):
        sumb.append(b[i]+b[i+1])
    
    
    
    if max(suma) > max(sumb):
        na = suma.index(max(suma))
        
        arr[whl[na]+1:whl[na+2]] = arr[whl[na]+1:whl[na+2]][::-1]
        for i in range(whl[na]+1,whl[na+2]):
            if arr[i] == "L":
                arr[i] = "R"
            else:
                arr[i] = "L"

    
    else:
        nb = sumb.index(max(sumb))
        
        arr[whr[nb]+1:whr[nb+2]-1] = arr[whr[nb]+1:whr[nb+2]-1][::-1]
        for i in range(whr[nb]+1,whr[nb+2]):
            if arr[i] == "L":
                arr[i] = "R"
            else:
                arr[i] = "L"

count = 0
for i in range(len(arr)-1):
    if arr[i]==arr[i+1]:
        count+=1
print(count)

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

ans = 0
for i in range(n-1):
    if arr[i] == arr[i+1]:
        ans +=1

ans +=k*2

if ans>n-1:
    ans = n-1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
num = int(input())

arr = [i for i in range(1,num+1)]

print(sum(arr[:-1]))

Fixed submission:
num = int(input())
     
print(int(num*(num-1)//2))
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,q=mii()
mat = [[] for _ in range(n)]

for i in range(n-1):
    mat[a-1].append(b-1)

cnt=[0]*n

for i in range(q):
    p,x=mii()
    cnt[p-1]+=x

ans=[0]*n

def dfs(point,now,parent):
    ans[now]+=point+cnt[now]

    for visit in mat[now]:
        if visit==parent:continue
        dfs(ans[now],visit,now)

print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,q=mii()
mat = [[] for _ in range(n)]

for i in range(n-1):
    a,b=mii()
    mat[a-1].append(b-1)
    mat[b-1].append(a-1)
cnt=[0]*n

for i in range(q):
    p,x=mii()
    cnt[p-1]+=x

ans=[0]*n

def dfs(point,now,parent):
    point+=cnt[now]
    ans[now]=point
    for visit in mat[now]:
        if visit==parent:continue
        dfs(ans[now],visit,now)
dfs(0,0,0)
for i in ans:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
arr = list(input())

ans = [0]*len(arr)

for i in range(len(arr)):
    if arr[i] == "R":
        move = 0
        
        while arr[i + move] == "R":
            move +=1
        
        if move % 2 ==0:
            ans[i + move] +=1
        else:
            ans[i+move-1] +=1

    if arr[i] == "L":
        move = 0
        
        while arr[i + move] == "L":
            move -=1
        
        if move % 2 ==0:
            ans[i + move] +=1
        else:
            ans[i+move+1] +=1       

        
print(" ".join(map(str,ans)))

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
arr=list(ss())
temp=0
centr=0
centl=0
ans=[0]*len(arr)

childeven=0
childodd=0

for i in range(len(arr)):
    if arr[i]=="R":
        if temp==0:
            centr=i
            if i%2==0:
                childeven+=1
            else:
                childodd+=1
        else:
            childeven=0
            childodd=0
            centr=i
            temp=0
            if i%2==0:
                childeven+=1
            else:
                childodd+=1

    else:
        if temp==0:
            temp=1
            centl=i

            if i%2==1:
                ans[centr]+=childeven
                ans[centr+1]+=childodd
            else:
                ans[centr]+=childodd
                ans[centr+1]+=childeven
                
            if (i-centl)%2==0:
                ans[centl]+=1
            else:
                ans[centl-1]+=1

        else:
            if (i-centl)%2==0:
                ans[centl]+=1
            else:
                ans[centl-1]+=1
    #print(ans,childeven,childodd)

print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

num = int(input())

arr = deque([])

for i in range(num):
    arr.append(int(input()))

for i in range(num):
    a = arr.popleft()
    print(max(list(arr)))
    arr.append(a)

Fixed submission:
from collections import deque

num = int(input())

arr = []

for i in range(num):
    arr.append(int(input()))

arr0 = sorted(arr,reverse=True)
arr00 = arr0[0]
arr01 = arr0[1]

for i in range(num):
    if arr[i] != arr00:
        print(arr00)
    else:
        print(arr01)

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

arr = []

for i in range(num):
    arr.append(int(input()))

for i in range(num):
    if i == 0:
        print(int(max(arr[1:])))
    elif i == num-1:
        print(int(max(arr[:-1])))
    else:  
        print(int(max(arr[:i]+arr[i+1:])))

Fixed submission:
from collections import deque

num = int(input())

arr = []

for i in range(num):
    arr.append(int(input()))

arr0 = sorted(arr,reverse=True)
arr00 = arr0[0]
arr01 = arr0[1]

for i in range(num):
    if arr[i] != arr00:
        print(arr00)
    else:
        print(arr01)
Buggy python submission (verdict: Runtime Error):
import numpy as np

num, k = map(int,input().split())

count = 0.

for i in range(1,num+1):
    if i <= k-1:
        times = np.log2(10/i)
        times = int(times) +1
        count += (1/num) * (1/2)**times
    elif i >= k:
        count += 1/num
print(count)



Fixed submission:
import numpy as np

num, k = map(int,input().split())

count = 0.

for i in range(1,num+1):
    if i <= k-1:
        times = np.log2(k/i)
        if times != int(times):
            times = int(times) +1
        else:
            times = int(times)
        count += (1/num) * (1/2)**times
    elif i >= k:
        count += 1/num
print(count)

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

num, k = map(int,input().split())

count = 0

for i in range(1,num+1):
    if i <= k-1:
        times = np.log2(10/i)
        times = int(times) +1
        count += (1/num) * (1/2)**times
    elif i >= k:
        count += (1/num)
print(count)

Fixed submission:
import numpy as np

num, k = map(int,input().split())

count = 0.

for i in range(1,num+1):
    if i <= k-1:
        times = np.log2(k/i)
        if times != int(times):
            times = int(times) +1
        else:
            times = int(times)
        count += (1/num) * (1/2)**times
    elif i >= k:
        count += 1/num
print(count)

Buggy python submission (verdict: Runtime Error):
import math

num, k = map(int,input().split())

count = 0

for i in range(1,num+1):
    if i <= k-1:
        times = math.log2(10/i)
        times = int(times) +1
        count += (1/num) * (1/2)**times
    elif i >= k:
        count += (1/num)
print(count)



Fixed submission:
import numpy as np

num, k = map(int,input().split())

count = 0.

for i in range(1,num+1):
    if i <= k-1:
        times = np.log2(k/i)
        if times != int(times):
            times = int(times) +1
        else:
            times = int(times)
        count += (1/num) * (1/2)**times
    elif i >= k:
        count += 1/num
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

r,g,b,n=mii()

rr=n//r +1
gg=n//g +1
bb=n//b +1
ans=0
for i in range(rr):
    for j in range(gg):
        for k in range(bb):
            if i*r+j*g+k*b==n:
                ans+=1
print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

r,g,b,n=mii()
arr=sorted([r,g,b])

gg=n//arr[1] +1
bb=n//arr[2] +1
ans=0



for i in range(gg):
    for j in range(bb):
        if (n-(arr[1]*i+arr[2]*j))%arr[0]==0 and (n-(arr[1]*i+arr[2]*j))>=0:
            ans+=1


print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
n=ii()
a,b,c=[],[],[]

for i in range(n):
    x,y,z=mii()
    a.append(x)
    b.append(y)
    c.append(z)

dp=[[0]*n for i in range(3)]
dp[0][0],dp[1][0],dp[2][0]=a[0],b[0],c[0]
for i in range(1,n):
    for j in [0,1,2]:
        if j==0:dp[0][i]=max(dp[1][i-1]+a[i],dp[2][i-1]+a[i])
        elif j==1:dp[1][i]=max(dp[0][i-1]+b[i],dp[2][i-1]+b[i])
        elif j==2:dp[2][i]=max(dp[1][i-1]+c[i],dp[0][i-1]+c[i])

print(max(dp[0][-1],dp[1][-1],dp[2][-1]))



Fixed submission:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #整数1つinput
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii())
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #文字列1つinput
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

n = ii()
arr = limii()
dp = [0]*n
chk=True
cnt=1
while chk:
    if cnt==1:
        dp[cnt] = abs(arr[cnt]-arr[cnt-1])
    else:
        dp[cnt] = min(abs(arr[cnt]-arr[cnt-1])+dp[cnt-1],abs(arr[cnt]-arr[cnt-2])+dp[cnt-2])

    if cnt==n-1:
        chk=False
    cnt+=1
print(dp[-1])