peterverebics/CodeNet_Python_118 huggingface dataset:
s = list(input())
m = 0
for i in range(len(s)):
    c = 0
    if s[i] == "A" or s[i] == "T" or s[i] == "G" or s[i] == "C":
        c += 1
        for j in range(1,len(s)-i):
            if s[i+j] == "A" or s[i+j] == "T" or s[i+j] == "G" or s[i+j] == "C":
                c += 1
            else:
                if c > m:
                    m = c
print(m)
S = input()

tmp = 0
atcgmax = 0
for i in range(len(S)):
    if S[i] == 'A' or  S[i] == 'T' or S[i] == 'C' or S[i] == 'G':
        tmp += 1
    else:
        atcgmax = max(tmp,atcgmax)
        tmp = 0

print(atcgmax)
S = input()

ans = 0
for i in range(len(S)):
    for j in range(i+1, len(S)):
        ok = True
        for k in range(i, j+1):
            if not (S[k] == "A" or S[k] == "C" or S[k] == "G" or S[k] == "T"):
                ok = False
                break
        if ok:
            ans = max(ans, j - i + 1)

print(ans)
s = input()
count = 0
max_count = 0
for c in s:
  if c in ['A','C','D','T']:
    count = 0
  else:
    count += 1
    if max_count < count:
      max_count = count
print(max_count)
import sys

input = sys.stdin.readline

def main():
    t = 'ATGC'
    ans = 0
    S = input()
    temp = 0
    for s in S:
        if s in t:
            temp += 1
        else:
            ans = max(ans, temp)

    print(ans)

if __name__ == '__main__':
    main()
def readinput():
    s=input()
    return s

def main(s):
    
    maxlen=0
    templen=0
    for i in range(len(s)):
        if(s[i]=='A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T'):
            templen+=1
        else:
            if maxlen<templen:
                maxlen=templen
                templen=0
        
    return maxlen

if __name__=='__main__':
    s=readinput()
    ans=main(s)
    print(ans)
S = input()
C = ['A','T','G','C']
ans = 0
tmp = 0
for i in range(len(S)):
	if S[i] in C:
		tmp += 1
	else:
		ans = max(ans, tmp)
		tmp = 0

print(ans)
S = input()

acgt = ['A', 'C', 'G', 'T']
ans, cnt = 0, 0
for i in range(len(S)):
    if S[i] in acgt:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0
print(ans)
S=input()
cnt=0

for i in range(len(S)):
    if S[i]=='A' or S[i]=='C' or S[i]=='G' or S[i]=='T':
        cnt+=1
print(cnt)
s = input()
l = len(s)
ans = 0
for i in range(l-1):
    for j in range(i+1, l):
        for ss in s[i:j]:
            if ss not in 'ACGT':
                break
        else:
            ans = max(ans, len(s[i:j]))
print(ans)
s = input()

x = []

for i in range(2**(len(s)-1)):
  tmp = [0]*(len(s)-1)
  for j in range(len(s)-1):
    if i >> j & 1:
      tmp[j] = 1
  x.append(tmp)
    
ans = []
temp = []
#print(x)
ss = ["A","T","G","C"]
for i in range(len(x)):
  temp = []
  for j in range(len(x[i])):
    if(x[i][j] == 1 and s[j] in ss):
      temp.append(s[j])
  ans.append(len(temp))

print(max(ans))
S = input()

s = []

for i in range(len(S)):
    if S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] == 'T':
        s.append(i)

ans = 0

count = 1
for i in range(len(s)-1):
    if s[i] + 1 == s[i+1]:
        count += 1
    else:
        count = 1
    if ans < count:
        ans = count
print(ans)
s = input()
ACGT = 'ACGT'
ans = 0
cnt = 0
for i in s:
  if i in ACGT:
    cnt += 1
  else:
    ans = max(ans,cnt)
    cnt = 0
print(ans,cnt)
S = input()
n = len(S)

length = 0

for s in range(n-1):
    if S[s] not in ["A", "C", "G", "T"]:
        continue
    for e in range(s+1, n):
        if S[e] not in ["A", "C", "G", "T"]:
            break
        length = max(length, e-s+1)

print(length)
import sys
import math
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

s = ns()
ans = 0
c = 0
acgt = ["A", "C", "G", "T"]
for si in s:
    if si in acgt:
        c += 1
    else:
        ans = max(c, ans)
        c = 0
print(ans)
s=input()
c=0
m=0
acgt=['A','C','G','T']
for e in s:
  if e in acgt:
    c+=1
  else:
    if c > m:
      m=c
    c=0
print(m)
s = input()

from re import findall

res = findall('[ACGT]*', s)
print(res)
S = list(input())
maxIndex = len(S)

result = 0
for index in range(len(S)):
    counter = 0
    for tmp in range(index, maxIndex):
        if S[tmp] in ["A", "C", "G", "T"]:
            counter += 1
            if tmp + 1 == maxIndex:
                if counter > result:
                    result = counter
                    break
            continue
        if counter > result:
            result = counter
            break
    if result == maxIndex: break

print(result)
s = input()
n = len(s)

ans = 0
cnt = 0
for i in range(n):
    if s[i] in ['A', 'C', 'G', 'T']:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0 

print(ans)
import re

split = re.split('[^ACGT]', input())
print(split)
print(max(map(len, split)))
S = input()

cnt = 0
mcnt = 0
for i in S:
    print(i)
    if i == 'A' or i == 'C' or i == 'G' or i == 'T':
        cnt += 1
        mcnt = max(mcnt,cnt)

print(mcnt)
import sys
import re
S = input()
if not ( 1 <= len(S) <= 10 ): sys.exit()
if not S.isupper: sys.exit()

result = 0
max = max(re.findall('[A|T|G|C]+', S)) if re.findall('[A|T|G|C]+', S) else ''
if len(max) > 0:result = len(max)
print(result)
S=input()
ACGT=['A','C','G','T']
ans=0
tmp=0
for s in S:
  if tmp==0:
    if s in ACGT: tmp+=1
  else:
    if s in ACGT:
      tmp+=1
      if tmp>ans: ans=tmp
    else:
      tmp=0
print(ans)
S = input()
ans = 0
l = 0
for s in S:
    if s in ['A', 'T', 'C', 'G']:
        l += 1
    else:
        ans = max(ans, l)
        l = 0
print(ans)
checklist=["A","C","G","T"]
sn = list(input())

answer = 0
count = 0
for i in range(len(sn)) :
  if sn[i] in checklist:
    count += 1
  else :
    answer = max(answer,count)
    count = 0

print(answer)
s=input()
ans=0
ctn=0
for i in range(len(s)):
  if s[i]=="A" or s[i]=="T" or s[i]=="G" or s[i]=="C":
    ctn+=1
  else:
    ans=max(ans,ctn)
    ctn=0
print(ans)
s = input()

l,r = 0,0
ma = 0
for l in range(len(s)):
    if(s[l] not in ['A','C','G','T']):continue
    for r in range(l,len(s)):
        if(s[r] not in ['A','C','G','T']):break
    ma = max(ma,len(s[l:r]))
print(ma)
N = int(input())
H = list(map(int, input().split()))
dp = [float('inf')] * N
dp[0] = 0
for i in range(1, N):
    dp[i] = min(dp[i-1] + abs(H[i]-H[i-1]), dp[i-2] + abs(H[i]-H[i-2])
                ) if i >= 2 else dp[i-1] + abs(H[i] - H[i-1])
#print(*dp)
print(dp[N-1])
n = int(input())
h = list(map(int, input().split()))
dp = [0] * n
dp[1] = abs(h[0] - h[1])
for i in range(2, n):
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))
print(dp[-1])
n = int(input())
h = list(map(int, input().split()))

dp = [10**18] * (10**5+10)
dp[0] = 0

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

print(dp[n-1])
import numpy as np
n=int(input())
h=np.array(list(map(int,input().split()))+[0]*2)
dp = np.full(n+2, 10 ** 10, dtype=np.int64)
dp[0] = 0
for i in range(1,n):
    dp[i:i+2]=np.minimum(dp[i:i+2],np.abs(h[i:i+2]-h[i-1])+dp[i-1])
print(dp[n-1])
n = int(input())
H = list(map(int,input().split()))

Dp = [0] * n

Dp[1] = abs(H[1] - H[0])     

for i in range(2, n):
    Dp[i] = min(Dp[i-1] + abs(H[i] - H[i-1]), Dp[i-2] + abs(H[i] - H[i-2]))
    
print(Dp[-1])
n = int(input())
h = tuple(map(int, input().split()))

c = [0] * n
c[0] = 0
c[1] = abs(h[0] - h[1])

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

print(c[-1])
n = int(input())
h = list(map(int, input().split()))
h = [0] + h

a = [0] * (n+1)
a[1] = 0
a[2] = abs(h[1]-h[2])
for i in range(3, n+1):
    a[i] = min(a[i-2]+abs(h[i-2]-h[i]), a[i-1]+abs(h[i-1]-h[i]))
print(a[n])
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys

# import itertools
# import math

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *H = map(int, read().split())
dp = [0] * N
dp[1] = abs(H[1] - H[0])

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

ans = dp[-1]
print(ans)
N = int(input())
h_list = list(map(int, input().split()))

dp = [0] * N # DPテーブルの作成
dp[1] = abs(h_list[1] - h_list[0])

if N>= 3:
    for i in range(2, N):
        dp[i] = min(dp[i-1]+abs(h_list[i]-h_list[i-1]), dp[i-2]+abs(h_list[i]-h_list[i-2]))

print(dp[N-1])
N = int(input())
h = list(map(int, input().split()))
list = [0 for _ in range(N)]
list[0] = 0
list[1] = abs(h[1]-h[0])
for i in range(2, N):
  list[i] = min(abs(h[i] - h[i-1]) + list[i-1], abs(h[i] - h[i-2]) + list[i-2])
print(list[N-1])
n = int(input())
h = list(map(int, input().split()))
dp = [0]*n
dp[1] = abs(h[1]-h[0])
for i in range(2, n):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])
import sys
sys.setrecursionlimit(200000)
 
n = int(input())
 
h = [int(i) for i in input().split()]
 
d = {}
 
def dp(p):
  if p in d:
    return d[p]
  if p == n-1:
    return 0
  if p < n-2:
    m = min(dp(p+1)+abs(h[p]-h[p+1]), dp(p+2)+abs(h[p]-h[p+2]))
    d[p] = m
    return m
  if p == n-2:
    return dp(p+1)+abs(h[p]-h[p+1])

print(dp(0))
def DP_A() :
    N = int(input())
    h = [int(x) for x in input().split()]
    dp = [10**10]*(N+1)

    dp[0] = 0
    dp[1] = abs(h[1] - h[0])
    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]))

    return dp[N-1]


print(DP_A())
n=int(input())
h=list(map(int,input().split()))
dp=[0]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
  dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N = int(input())
    h = list(map(int, input().split()))
    INF = 10**12
    dp = [INF] * (N+1)
    dp[1] = 0
    for i in range(1,N):
        dp[i+1] = min(dp[i+1],dp[i]+abs(h[i-1]-h[i]))
        if i < N-1:
            dp[i+2] = min(dp[i+2],dp[i]+abs(h[i-1]-h[i+1]))
    print(dp[N])

if __name__ == "__main__":
    main()
n = int(input())
H = list(map(int, input().split()))

memo = [0 for _ in range(n)]
memo[1] = abs(H[1] - H[0])
for i in range(2, n):
  memo[i] = min(memo[i-1] + abs(H[i] - H[i-1]), memo[i-2] + abs(H[i] - H[i-2]))
print(memo[-1])
def resolve():
    N = int(input())
    h = [int(i) for i in input().split()]
    dp = [float("inf")] * N
    dp[0] = 0
    dp[1] = abs(h[1] - h[0])
    for i in range(2, N):
        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]),
                    dp[i - 1] + abs(h[i] - h[i - 1]))
    print(dp[-1])


resolve()
n = int(input())
h = list(map(int, input().split()))

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

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

print(dp[n-1])
N = int(input())
H = list(map(int, input().split()))

cost = [0] * N
for i in range(1, N):
  d1 = cost[i-1] + abs(H[i] - H[i-1])
  d2 = cost[i-2] + abs(H[i] - H[i-2]) if i > 1 else 1e6
  cost[i] = min(d1, d2)
#print(cost)
ans = cost[N-1]
print(ans)
def main():
    footing = int(input())
    height = list(map(int, input().split()))
    answer = [0] * footing
    answer[1] = abs(height[1] - height[0])
    for i in range(2, footing):
        answer[i] = min(answer[i - 2] + abs(height[i] - height[i - 2]), answer[i - 1] + abs(height[i] - height[i - 1]))
    print(answer[-1])


if __name__ == '__main__':
    main()
n=int(input())
arr=[int(i) for i in input().split()]
dp=[0]*(n)
dp[0]=0
dp[1]=abs(arr[1]-arr[0])

for i in range(2,n):
    dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2])
print(dp[-1])
n=int(input())
a=list(map(int,input().split()))
b=10**10
c=[b]*n
c[0]=0
c[1]=abs(a[1]-a[0])
for i in range(n-2):
    for j in range(1,3):
        c[i+j]=min(c[i+j],c[i]+abs(a[i+j]-a[i]))
c[-1]=min(c[-1],c[-2]+abs(a[-2]-a[-1]))
print(c[-1])
n = int(input())
h = list(map(int, input().split()))
INF = 10**8
dp = [INF]*n
dp[0] = 0
for i in range(n-1):
    if i == 0:
        dp[i+1] = abs(h[i+1]-h[i])
    else:
        dp[i+1] = min(dp[i]+abs(h[i+1]-h[i]), dp[i-1]+abs(h[i+1]-h[i-1]))
print(dp[n-1])
n=int(input())
h=list(map(int, input().split()))
dp=[0]*n
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
  dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])
N = int(input())
h = list(map(int, input().split()))

dp = [0]*N
dp[N-1], dp[N-2] = 0, abs(h[N-1] - h[N-2])
for i in range(N-3,-1,-1):
    dp[i] = min(abs(h[i] - h[i+1]) + dp[i+1], abs(h[i] - h[i+2]) + dp[i+2])
print(dp[0])
n = int(input())
h = list(map(int,input().split()))

dp = [float("inf")]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(1,n-1):
    dp[i+1] = min(dp[i]+abs(h[i+1]-h[i]),dp[i-1]+abs(h[i+1]-h[i-1]))
print(dp[n-1])
n = int(input())
h = [int(i) for i in input().split()]
INF = float("INF")
dp = [INF]*n
dp[0] = 0
dp[1] = abs(h[0]-h[1])
for i in range(2,n):
    dp[i] = min(dp[i-2]+abs(h[i-2]-h[i]),dp[i-1]+abs(h[i-1]-h[i]))
print(dp[n-1])
n = int(input())
h = list(map(int, input().split()))

cnt = [float('inf')]*n
cnt[0], cnt[1] = 0, abs(h[0]-h[1])
for i in range(2,n):
    cnt[i]=min(abs(h[i-1]-h[i])+cnt[i-1],abs(h[i-2]-h[i])+cnt[i-2])

print(cnt[n-1])
# A Frog 1

n = int(input())
h_list = [int(x) for x in input().split()]

dp = [float('Inf')]*(n)
dp[0] = 0
dp[1] = abs(h_list[1] - h_list[0])

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

print(dp[n-1])
N = int(input())
h = [int(x) for x in input().split()]

Cost = [0] * N
Cost[1] = abs(h[1] - h[0])

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

print(Cost[-1])
def main():
    N = int(input())
    field = list(map(int, input().split()))

    dpList = [0] * N
    dpList[1] = abs(field[0] - field[1])

    for i in range(2, N):
        dpList[i] = min([dpList[i - 1] + abs(field[i] - field[i - 1]), dpList[i - 2] + abs(field[i] - field[i - 2])])
        
    print(dpList[-1])

if __name__ == "__main__":
    main()
N = int(input())
H = list(map(int, input().split()))

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

for n in range(1,N):
  dp[n] = min(dp[n], dp[n-1]+abs(H[n]-H[n-1])) 
  if n >= 2:
    dp[n] = min(dp[n], dp[n-2]+abs(H[n]-H[n-2]))
  
print(dp[-1])
N = int(input())
H = [int(i) for i in input().split()]

dp = [float("inf")] * N
dp[0], dp[1] = 0, abs(H[1]-H[0])
for i in range(2, N):
    dp[i] = min(dp[i], dp[i-1]+abs(H[i]-H[i-1]), dp[i-2]+abs(H[i]-H[i-2]))
    
print(dp[N-1])
def main():
    n = int(input())
    h = list(map(int, input().split()))
    dp = [0] * n

    def cost(i,j):
        return abs(h[i]-h[j])

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

if __name__ == '__main__':
    main()
n = int(input())
h = list(map(int,input().split()))
dp = [10**7]*n
dp[0] = 0
for i in range(1,n):
  dp[i] = min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,min(3,i+1))])
print(dp[n-1])
def jumpCost(array):
    size = len(array)

    memo = [99999999999] * (size)

    memo[0] = 0

    for i in range(size):
        j = i+1

        while j < i + 2 + 1 and j < size:
            memo[j] = min(memo[j], memo[i] + abs(array[i] - array[j]))

            j += 1

    return memo[size - 1]


if __name__ == '__main__':
    n = int(input())

    a = list(map(int, input().rstrip().split()))
    print(jumpCost(a))
import itertools
import math
import sys
from collections import Counter
from fractions import gcd
from functools import reduce
import sys
sys.setrecursionlimit(4100000)

INF = 1 << 60

n = int(input())
h = list(map(int, input().split()))
dp = [INF] * n
dp[0] = 0
for i in range(1, n):
    dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
    if i != 1:
        dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))
    # print(dp[i], h[i], h[i - 1], h[i - 2])
# for i in dp:
#     print(i)
print(dp[-1])
import sys
sample = sys.stdin.read().splitlines()
n, stones = int(sample[0]), list(map(int, sample[1].split()))
dp = [float('inf')] * n
jumps = (1, 2)
dp[0] = 0
for idx in range(len(dp)):
  for jump in jumps:
    if idx+jump < len(dp):
      dp[idx+jump] =  min(dp[idx]+abs(stones[idx+jump]-stones[idx]), dp[idx+jump])
print(dp[-1])
N = int(input())
H = list(map(int,input().split()))
dp = [float('inf') for i in range(N)]
#全ノードを取り敢えずinfにしておく
dp[0] = 0
for i in range(N-1):
    #足場を一個飛んだ時
    dp[i+1] = min(dp[i+1],dp[i] + abs(H[i+1] - H[i]))
    #足場を二個飛んだ時
    if i <= N-3:
        dp[i+2] = min(dp[i+2], dp[i] + abs(H[i + 2]-H[i]))
print(dp[N-1])
n=int(input())
h=list(map(int,input().split()))
dp=[10**9]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(n-1):
    dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]))
    if i+2<n:
        dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]))
print(dp[-1])
import sys
sys.setrecursionlimit(10**6)

N = int(input())
h = list(map(int, input().split()))
dp = [-1] * (N+1)

def rec(i):
    if i == 0:
        return 0
    if dp[i] != -1:
        return dp[i]
    dp[i] = 2**60 # 十分大きな値
    if i - 1 >= 0:
        dp[i] = min(dp[i], rec(i - 1) + abs(h[i - 1] - h[i]))
    if i - 2 >= 0:
        dp[i] = min(dp[i], rec(i - 2) + abs(h[i - 2] - h[i]))
    return dp[i]

print(rec(N-1))
def solve(N, heights):
  dp = [float('inf')] * N
  dp[0] = 0
  for i in range(N - 1):
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(heights[i] - heights[i + 1]))
    if i + 2 < N:
      dp[i + 2] = min(dp[i + 2], dp[i] + abs(heights[i] - heights[i + 2]))

  print(dp[N-1])

def iin(): return int(input())
def iln(): return list(map(int, input().split()))

solve(iin(), iln())
N = int(input())
h = list(map(int,input().split()))
dp = [0] * N
dp[1] = abs(h[0]-h[1])
for i in range(2,N):
    dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]))
print(dp[-1])
n = int(input())
h = list(map(int,input().split()))
cost = [0]*n
cost[1] = abs(h[1]-h[0])
for i in range(2,n):
    cost[i] = min(cost[i-1] + abs(h[i]-h[i-1]) , cost[i-2] + abs(h[i]-h[i-2]))
print(cost[n-1])
N=110000
dp=[0]*N

n=int(input()) 
h=list(map(int,input().split()))
now=[0,0,0]
for i in range(1,n):
    if i==1:
        dp[i]=dp[i-1]+abs(h[i]-h[i-1])
    else:
        now=[i,i-1,i-2]
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))

print(dp[n-1])
N = int(input())
[*h] = map(int, input().split())
dp = [0 for _ in range(N)]
dp[1] = abs(h[0]-h[1])
for i in range(2, N):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
 
print(dp[N-1])
mod=10**9+7
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a=ii()
l=list(mi())
dp=[0,abs(l[0]-l[1])]
for i in range(2,a):
  dp.append(min(abs(l[i]-l[i-1])+dp[i-1],abs(l[i]-l[i-2])+dp[i-2]))
print(dp[-1])
_ = int(input())

stones = [int(i) for i in input().split()]

cost = [0, abs(stones[1] -stones[0])]

for i in range(2, len(stones)):
    jump_1 = cost[i-1] + abs(stones[i] - stones[i-1])
    jump_2 = cost[i-2] + abs(stones[i] - stones[i-2])
    cost.append(min(jump_1, jump_2))

print(cost[-1])
n = int(input())
li = list(map(int,input().split()))

dp = [0,abs(li[1]-li[0])]

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

print(dp[-1])
n = int(input())
h = list(map(int, input().split()))
p0, p1 = 0, abs(h[1] - h[0])
for i in range(2, n):
    p2 = min(p1 + abs(h[i] - h[i - 1]), p0 + abs(h[i] - h[i - 2]))
    p0, p1 = p1, p2
print(p1)
def resolve():
    n = int(input())
    h = list(map(int, input().split()))
    dp = [float("inf") for i in range(n)]
    dp[0] = 0

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

    print(dp[n-1])
    
resolve()
n = int(input())
h = list(map(int,input().split()))

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

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

print(dp[n])
n = int(input())
h = list(map(int, input().split()))
dp = [float("inf") for i in range(n)]
dp[0] = 0
dp[1] = dp[0] + (h[1] - h[0])
for i in range(1, n):
    dp[i] = min(dp[i - 2] + (abs(h[i] - h[i - 2])), dp[i - 1] + (abs(h[i] - h[i - 1])))
print(dp[n - 1])
n = int(input())
h = list(map(int,input().split()))
dp = [0]*n
dp[1] = abs(h[0] -h[1])
for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(h[i] - h[i-1]),dp[i-2]+abs(h[i] - h[i-2]))
print(dp[n-1])
import sys,queue,math,copy,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

N = NI()
h = LI()
dp = [INF for _ in range(N)]
dp[0] = 0
for i in range(N-1):
    dp[i+1] = min(dp[i+1],dp[i]+abs(h[i+1]-h[i]))
    if i < N-2:
        dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2]-h[i]))
print(dp[-1])
n=int(input())
h=list(map(int,input().split()))

dp=[10**9]*(n+1)


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

print(dp[n-1])
N = int(input())
H = list(map(int,input().split()))

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

for i in range(1,N):
    if i == 1:
        dp[i] = min(dp[i],dp[i-1] + abs(H[i]-H[i-1]))
    else:
        dp[i] = min(dp[i],dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]))

print(dp[N-1])
# Flog 1

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

cost_list = [0 for i in range(N+1)]

# ステップiへたどり着くためのコスト最小値
for i in range(1,N):
    if i==1:
        cost_list[i+1] = abs(h_list[i] - h_list[i-1])
        continue

    step_1 = cost_list[i] + abs(h_list[i]-h_list[i-1])
    step_2 = cost_list[i-1] + abs(h_list[i]-h_list[i-2])
    min_cost = min(step_1, step_2)
    cost_list[i+1] = min_cost


print(cost_list[N])
N = int(input())
steps = list(map(int, input().split()))
costs = [0]*(N+1)
for i in range(1, N):
  if i==1:
    costs[1] = abs(steps[1]-steps[0])
    continue
  a = costs[i-1]+abs(steps[i]-steps[i-1])
  b = costs[i-2]+abs(steps[i]-steps[i-2])
  costs[i] = min(a, b)
print(costs[N-1])
n=int(input())
h=list(map(int,input().split()))
res=[-1]*n
res[0]=0
res[1]=abs(h[0]-h[1])
for i in range(2,n):
  res[i]=min(abs(h[i-1]-h[i])+res[i-1],abs(h[i-2]-h[i])+res[i-2])

print(res[-1])
N=int(input()) # 足場の数
H=list(map(int,input().split(" "))) # 足場の高さ
C=[0 for _ in range(N)] # 各足場までの最小コスト

for i in range(1,N):
    if i==1: # 2つ目のは1つ目から移るしかない
        C[1]=C[0]+abs(H[1]-H[0])
    else: # 3つ目以降
        C[i]=min(C[i-1]+abs(H[i]-H[i-1]),C[i-2]+abs(H[i]-H[i-2]))

print(C[-1]) # 最後の足場に行く最小コスト
import sys
sys.setrecursionlimit(200000) #追加
S = [-1]*(101010)
def opt_S(h,n):
    if(n == 0):return 0
    elif(n == 1):return abs(h[1]-h[0])
    else :
        if(S[n] != -1):return S[n]
        s1 = opt_S(h,n-1) + abs(h[n-1]-h[n])
        s2 = opt_S(h,n-2) + abs(h[n-2]-h[n])
        S[n] = min(s1,s2)
        return S[n]



N = int(input())
h = list(map(int,input().split()))
print(opt_S(h,N-1))
N = int(input())
[*h] = map(int, input().split())
dp = [float('inf') for _ in range(N)]
dp[0] = 0
dp[1] = abs(h[0]-h[1])
for i in range(2, N):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))

print(dp[N-1])
n=int(input())
lis=list(map(int,input().split(' ')))
node=[0,abs(lis[1]-lis[0])]+[0]*(n-2)
for i in range(2,n):
    x=abs(lis[i]-lis[i-1])+node[i-1]
    y=abs(lis[i]-lis[i-2])+node[i-2]
    node[i]=min(x,y)
print(node[-1])
N = int(input())
*h, = map(int, input().split())
dp = [0] * N
dp[0] = 0
dp[1] = abs(h[0] - h[1])
for i in range(2, N):
    dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]))
print(dp[-1])
N = int(input())
h = list(map(int,input().split()))
inf = float("inf")

dp = [inf]*N
dp[0] = 0 #initial situation
dp[1] = abs(h[1]-h[0])


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

print(dp[N-1])