Harryxun/stf_run huggingface dataset:
from heapq import heapify, heappop

N, K = map(int, input().split())
vl = list(map(int, input().split()))
vr = list(reversed(vl))
sum_L = [0]
for vv in vl:
    sum_L.append(sum_L[-1] + vv)

sum_R = [0]
for vv in vr:
    sum_R.append(sum_R[-1] + vv)

ans = 0
for pick in range(K, -1, -1):
    put = K - pick
    if pick < put: break
    for left in range(pick + 1):
        m_put = put
        right = pick - left
        t = sum_L[left] + sum_R[right]
        q = vl[:left] + vr[:right]
        heapify(q)
        while m_put > 0:
            t -= heappop(q)
            m_put -= 1
        ans = max(ans, t)
print(ans)


### FIXED CODE ###

from heapq import heapify, heappop

N, K = map(int, input().split())
vl = list(map(int, input().split()))
vr = list(reversed(vl))
sum_L = [0]
for vv in vl:
    sum_L.append(sum_L[-1] + vv)

sum_R = [0]
for vv in vr:
    sum_R.append(sum_R[-1] + vv)

ans = 0
for pick in range(min(K, N) + 1):
    for to_remove in range(K + 1):
        if pick + to_remove > K: break
        for left in range(pick + 1):
            right = pick - left

            t = sum_L[left] + sum_R[right]

            q = vl[:left] + vr[:right]
            heapify(q)

            cnt = 0
            while cnt < to_remove and q:
                t -= heappop(q)
                cnt += 1
            ans = max(ans, t)
print(ans)
A=int(input())
B=int(input())
for i in raneg(3):
  if i+1 !=A && i+1 != B:
    print(i+1)

### FIXED CODE ###

A=int(input())
B=int(input())
for i in range(3):
  if i+1 !=A and i+1 != B:
    print(i+1)
n = input()

color = [0 for i in range(n)]
d = [0 for i in range(n)]
f = [0 for i in range(n)]
M = [[0 for i in range(n)] for j in range(n)]
X = [0 for i in range(n)]
t = 0

def DFSv(u):
  color[u] = 1
  t += 1
  d[u] = t
  for v in range(n):
    if M[u][v] == 1 and color[v] == 0:
      DFSv(v)
  color[u] = 2
  t += 1
  f[u] = t

def DFS():
  for u in range(n):
    if color[u] == 0:
      DFSv(u)
  for u in range(n):
    print u+1, d[u], f[u]

for i in range(n):
  X = map(int, raw_input().split())
  for j in range(X[1]):
    M[X[0]-1][X[2+j]-1] = 1

DFS()
    

### FIXED CODE ###

n = int(raw_input())
 
d = [0 for i in range(n)]
f = [0 for i in range(n)]
G = [0 for i in range(n)]
M = [[0 for i in range(n)] for j in range(n)]
col = [0 for i in range(n)]
t = [0]
 
def DFS_visit(u):
    col[u] = 1
    t[0] += 1
    d[u] = t[0]
    for v in range(n):
        if M[u][v] == 1 and col[v] == 0:
            DFS_visit(v)
    col[u] = 2
    t[0] += 1
    f[u] = t[0]
 
def DFS():
    for u in range(n):
        if col[u] == 0:
            DFS_visit(u)
    for u in range(n):
        print'{0} {1} {2}'.format(u+1, d[u], f[u])
     
for i in range(n):
    X = map(int, raw_input().split())
    for j in range(X[1]):
        M[X[0]-1][X[2+j]-1] = 1
 
DFS()
n, k, q = map(int, input().split())
A = [k-q]*n
for i in range(q):
    ans = int(input())
    A[ans] += 1
for i in A:
    print('Yes' if i>0 else 'No')

### FIXED CODE ###

N, K, Q = map(int, input().split())
points = [K-Q]*N
for i in range(Q):
    points[int(input())-1] += 1

for p in points:
    print('Yes' if p>0 else 'No')
a=input()
print(["No","Yes"][a[0]==a[1]==a[2]and[a[3]==a[1]==a[2]])

### FIXED CODE ###

a=input()
print(["No","Yes"][a[0]==a[1]==a[2] or a[3]==a[1]==a[2]])
s = input()

core = []

for c in s:
    if c != 'x':
        core.append(c)
l = 0
r = -1 if core == [] else len(core) - 1
while l <= r:
    if core[l] != core[r]:
        print(-1)
        exit()
    l += 1
    r -= 1

ans = 0
l = 0
r = len(s) - 1
while l <= r:
    lx = 0
    rx = 0
    while s[l] == 'x':
        l += 1
        lx += 1
    while s[r] == 'x':
        r -= 1
        rx += 1
    ans += abs(lx - rx)
    l += 1
    r -= 1
print(ans)


### FIXED CODE ###

s = input()

core = []

for c in s:
    if c != 'x':
        core.append(c)
if core == []:
    print(0)
    exit()
l = 0
r = len(core) - 1

while l <= r:
    if core[l] != core[r]:
        print(-1)
        exit()
    l += 1
    r -= 1

ans = 0
l = 0
r = len(s) - 1

while l <= r:
    lx = 0
    rx = 0
    while s[l] == 'x':
        l += 1
        lx += 1
    while s[r] == 'x':
        r -= 1
        rx += 1
    ans += abs(lx - rx)
    l += 1
    r -= 1
print(ans)
a = input()
a.sort()

if a[0]==a[1] and a[2]==a[3] and a[1]!=a[3]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a = input()
a = sorted(a)

if a[0] == a[1] and a[2] == a[3] and a[1] != a[3]:
    print("Yes")
else:
    print("No")
n = int(input())
t = list(map(int,input(),split()))
m = int(input())
p = [0]* m 
x = [0]* m 
for i in range(m):
    p[i],x[i]= map(int(input(),split()))
for i in range(m):
    print(sum(t)-t[p[i]-1]+x[i])

### FIXED CODE ###

n=int(input())
t=list(map(int,input().split()))
m=int(input())
p=[0]*m
x=[0]*m
for i in range(m):
  p[i],x[i]=map(int,input().split())  
for i in range(m):
  print(sum(t)-t[p[i]-1]+x[i])
K, N = map(int, input().split())
A = list(map(int, input().split()))
A.append(A[0]+K)
max_d = A[1] - A[0]
for i in range(n):
  d = A[i+1] - A[i]
  if max_d < d:
    max_d = d
print(K - max_d)


### FIXED CODE ###

K, N = map(int, input().split())
A = list(map(int, input().split()))
A.append(A[0]+K)
max_d = A[1] - A[0]
for i in range(N):
  d = A[i+1] - A[i]
  if max_d < d:
    max_d = d
print(K - max_d)
N = int(input())
A = list(map(int,input().split()))
if N == 1:
    print(1)
    exit()
d = [A[i+1] - A[i] for i in range(N-1)]
def judge(list_hoge = d,count = 1):
    if len(list_hoge) == 1:
        print(count)
        return
    for i in range(1,len(list_hoge)):
        if list_hoge[i] * list_hoge[0] < 0:
            if i == len(list_hoge) - 1:
                print(count + 1)
                return
            else:
                return judge(list_hoge[i+1:],count + 1)
    print(count)
    return
judge()

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
state = 0
count = 1
for i in range(1,N):
    note = state
    d = A[i] - A[i-1]
    if d > 0:
        state = 1
    elif d == 0:
        pass
    elif d < 0:
        state = -1
    if (state,note) == (1,-1) or (state,note) == (-1,1):
        count += 1
        state = 0
print(count)
n = int(input())
a = list(map(int, input().split()))

mp = [0] * n
#right = [0] * n

ans = 0

for i in range(n):
    ans += mp[i-a[i]]
    if n > a[i]+i:
        mp[a[i]+i] += 1

print(ans)

### FIXED CODE ###

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

mp = [0] * n

ans = 0

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

print(ans)
a,b,c = map(int, input().split())
if a % 2 == 1 and b % 2 == 1:
	print('Yes')
else:
	print('No')

### FIXED CODE ###

a,b = map(int, input().split())
if a % 2 == 1 and b % 2 == 1:
	print('Yes')
else:
	print('No')
N,A,B=map(int,input().split())
S="b"*A+"r"*B
ans=(N//(A+B))*A+S[:N%(A+B)].count("b")
print(ans)

### FIXED CODE ###

N,A,B=map(int,input().split())
ans=N//(A+B)*A
ans+=min(N%(A+B),A)
print(ans)
N, L = map(int, input().split())
s = []
for i in range(N):
    line = input()
    s.append(line)
s.sort()
ans="".join(s)
print(ans)

### FIXED CODE ###

A, B, C = map(int, input().split())

arr = [A, B, C]
fives = 0
sevens = 0

for num in arr:
    if num == 5:
        fives += 1
    if num == 7:
        sevens += 1

if fives == 2 and sevens == 1:
    print("YES")
else:
    print("NO")
in = input()

if in.isupper():
  print("A")
else:
  print("a")

### FIXED CODE ###

tmp = input()

if tmp.isupper():
    print("A")
else:
    print("a")
import sys
n,k = map(int,input().split())
x_ls = list(map(int, input().split()))
x_ls.sort()
if x_ls[0] >= 0:
    print(x_ls[k-1])
    sys.exit()
elif x_ls[-1] <= 0:
    x_ls.sort(reverse=True)
    print(abs(x_ls[k-1]))
    sys.exit()
l = 0
r = k - 1
while True:
    if x_ls[r+1] > 0:
        break
    l += 1
    r += 1
ans = float('inf')
while r < n:
    cost_1 = 2*abs(x_ls[l]) + abs(x_ls[r])
    cost_2 = abs(x_ls[l]) + 2*abs(x_ls[r])
    cost = min(cost_1,cost_2)
    ans = min(cost, ans)
    r += 1
    l += 1
print(ans)
    

### FIXED CODE ###

n,k = map(int,input().split())
x_ls = list(map(int, input().split()))
ans = float('inf')
for i in range(n-k+1):
    if x_ls[i+k-1] < 0:
        ans = min(ans, abs(x_ls[i]))
    elif x_ls[i] < 0 and x_ls[i+k-1] >= 0:
        near = min(abs(x_ls[i]),abs(x_ls[i+k-1]))
        far = max(abs(x_ls[i]),abs(x_ls[i+k-1]))
        ans = min(ans, 2 * near + far)
    elif x_ls[i] >= 0:
        ans = min(ans, x_ls[i+k-1])
print(ans)
def get_cost(arr, n, k, dp):
  if dp[n] is not None:
    return dp[n]
  elif k >= n-1:
    return abs(arr[-1] - arr[0])
  elif n == 0:
    dp[0] = 0
    return dp[0]
  elif n == 1:
    dp[1] = abs(arr[1] - arr[0])
    return dp[1]

N, K = input().split()
N = int(N)
K = int(K)

dp = [None]*N
print(get_cost(arr, N-1, K, dp)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

def get_cost(arr, n, k, dp):
  min_ = -1
  for i in range(2, n):
    dp[i] = min([(abs(arr[s] - arr[i]) + dp[s]) for s in range(max(0, i-k), i)])
  return dp[-1]
    

N, K = input().split()
N = int(N)
K = int(K)
arr = [int(num) for num in input().split()]

dp = [0]*N
dp[1] = abs(arr[1] - arr[0])
print(get_cost(arr, N, K, dp))
N, M = list(map(int,input().split()))
s = []
c = []
for i in range(M):
    in1, in2 = list(map(int,input().split()))
    s.append(in1 - 1)
    c.append(in2)

if M > N:
    print(-1)
else:
    solve()
    
def solve():
    
    res = [-1 for _ in range(N)]

    for i in range(M):
        if res[s[i]] != -1 and res[s[i]] != c[i]:
            print(-1)
            return
        if s[i] == 0 and c[i] == 0:
            print(-1)
            return
        res[s[i]] = c[i] 

    ans = ""
    for i in range(N):
        if res[i] == -1:
            if i == 0:
                ans += "1"
            else:
                ans += "0"
        else:
            ans += str(res[i])
    print(ans)

### FIXED CODE ###

N, M = list(map(int,input().split()))
s = []
c = []
for i in range(M):
    in1, in2 = list(map(int,input().split()))
    s.append(in1 - 1)
    c.append(in2)
    
def solve():
    
    res = [-1 for _ in range(N)]

    for i in range(M):
        if res[s[i]] != -1 and res[s[i]] != c[i]:
            print(-1)
            return
        if s[i] == 0 and c[i] == 0 and N != 1:
            print(-1)
            return
        res[s[i]] = c[i] 

    ans = ""
    
    if N == 1:
        if res[0] == -1:
            print(0)
        else:
            print(res[0])
        return
    
    for i in range(N):
        if res[i] == -1:
            if i == 0:
                ans += "1"
            else:
                ans += "0"
        else:
            ans += str(res[i])
    print(ans)

solve()
#include <string>
#include <iostream>

using namespace std;

const int nmax = 50;
const int mmax = 50;
char N_sq[nmax][nmax], M_sq[mmax][mmax];


bool judge_match(int x, int y, int M){
	for(int i=0;i<M;i++){
		for(int j=0;j<M;j++){
			if(N_sq[y+i][x+j] != M_sq[y+i][x+j]) return false;
		}
	}
	return true;
}


int main(void){
	int N,M;

	cin >> N >> M;
	bool exist = false;

	for(int y=0;y < N;y++){
		for(int x;x < N;x++){
			cin >> N_sq[y][x];
		}
	}

	for(int y=0;y < M;y++){
		for(int x;x < M;x++){
			cin >> M_sq[y][x];
		}
	}

	for(int y=0;y <= N - M;y++){
		for(int x=0;x <= N - M;x++){
			if(judge_match(x, y, M)) exist=true;
		}
	}

	if(exist)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;

}

### FIXED CODE ###

import sys

count = 0
N_list = []
M_list = []
for line in sys.stdin:
    line = line.rstrip("\n")
    if count == 0:
        line = line.split(" ")
        N = int(line[0])
        M = int(line[1])
    elif count <= N:
        N_list.append(line)
    else:
        M_list.append(line)
    count+=1
    
    
def judge_match(N_l, M_l):
    slide_count = len(N_l[0]) - len(M_l[0]) + 1
    count = 0
    for j in range(slide_count):
        count = 0
        for i in range(len(N_l)):
            if N_l[i][j:j+len(M_l[0])] == M_l[i]:
                count += 1
                if count == len(M_l):
                    return count
    return count

m_count = 0
for i in range(len(N_list)):
    m_count = judge_match(N_list[i:i+len(M_list)], M_list)
    if m_count == len(M_list):
        print("Yes")
        exit(0)
print("No")
N = int(input())
L = map(int, input().split())
cnt = 0
for i in range(N-2):
        # L[i]
    for j in range(i+1,N-1):
        # L[j]
        for k in range(j+1,N):
            print(i,j,k)
            if L[i] == L[j] or L[i] == L[k] or L[j] == L[k]:
                continue
            if L[i] + L[j] <= L[k] or L[i] + L[k] <= L[j] or L[j] + L[k] <= L[i]:
                continue
            cnt += 1
print(cnt)

### FIXED CODE ###

N = int(input())
L = list(map(int, input().split()))
cnt = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if L[i] == L[j] or L[i] == L[k] or L[j] == L[k]:
                continue
            if L[i] + L[j] <= L[k] or L[i] + L[k] <= L[j] or L[j] + L[k] <= L[i]:
                continue
            cnt += 1
print(cnt)
n,m,k = map(int,input().split())
a = [0]+list(map(int,input().split()))
b = [0]+list(map(int,input().split()))
s = [0]*(n+1)
t = [0]*(m+1)
x = 0
for i in range(n+1):
    s[i] += x + a[i]
    x = s[i]
for i in range(n+1):
    if(s[i] >= k):
        p = i
        break
x = 0
for i in range(m+1):
    t[i] += x + b[i]
    x = t[i]
for i in range(m+1):
    if(t[i] >= k):
        p = max(p,i)
        break
#print(s,t)
while(1):
    f = 0
    for j in range(p-min(p,m),min(p,n)+1):
        #print(j,p-j)
        if(s[j]+t[p-j] <= k):
            #print(j,x-j)
                f = 1
                break
    if(f == 0):
        break
    p += 1
print(p-1)

### FIXED CODE ###

n,m,k = map(int,input().split())
a = [0]+list(map(int,input().split()))
b = [0]+list(map(int,input().split()))
s = [0]*(n+1)
t = [0]*(m+1)
x = 0
for i in range(n+1):
    s[i] += x + a[i]
    x = s[i]
if(s[-1] <= k):
    p = n
else:
    for i in range(n+1):
        if(s[i] >= k):
            p = i
            break
x = 0
for i in range(m+1):
    t[i] += x + b[i]
    x = t[i]
if(t[-1] <= k):
    p = min(p,m)
else:
    for i in range(m+1):
        if(t[i] >= k):
            p = max(p,i)
            break
#print(s,t)
while(1):
    f = 0
    for j in range(p-min(p,m),min(p,n)+1):
        #print(j,p-j)
        if(s[j]+t[p-j] <= k):
            #print(j,x-j)
                f = 1
                break
    if(f == 0):
        break
    p += 1
print(p-1)
a_list = [chr(ord('a') + i) for i in range(26)]
n = int(input())

l_list = []
ans = ''
while n > 0:
    
    if n % 26 == 0:
        l_list.append(25)
        n = n // 26 - 1
    else:
        l_list.append(n%26)
        n = n // 26
l_list = l_list[::-1]
for i in l_list:
    ans += a_list[i]
print(ans)

### FIXED CODE ###

alpha = input()
if alpha == alpha.upper():
    print('A')
else:
    print('a')
#At coder 2020/2/9 D

# 入力
N,K= map(int, input().split())
p = list(map(int, input().split())) 
#p2 = sorted(p, reverse=True)
#print(p2)
kk=[0] * (N-K+1)

if N==K:
    kk=sum(p)
else:
    for ii in range(N-K+1):
        kk[ii]=sum(p[ii:K+ii])
kk=max(kk)
K=float(K)
kk=float(kk)
ans=0.5*(kk+K)

print(ans)

### FIXED CODE ###

#At coder 2020/2/9 D
#import numpy as np

# 入力
N,K= map(int, input().split())
p = list(map(int, input().split())) 
#p2 = sorted(p, reverse=True)
#print(p2)
kk=[0] * (N-K+1)
#p=np.array(p)
kk[0]=sum(p[0:K])
for ii in range(1,N-K+1):
    kk[ii]=kk[ii-1]-p[ii-1]+p[K+ii-1]
kk=max(kk)
K=float(K)
kk=float(kk)
ans=0.5*(kk+K)

print(ans)
N=int(input())
total=1
A=list(map(int,input().split()))
if A.count(0)>=1:
  total=0
else:
  for i in range(x):
    total*=A[i]

if 1*(10**18)+1<=total:
  print("-1")
else:
  print(total)

### FIXED CODE ###

N=int(input())
total=1
A=list(map(int,input().split()))
flag=True
high=1*(10**18)+1
if A.count(0)>=1:
  total=0
else:
  for i in range(N):
    total*=A[i]
    if high<=total:
      flag=False
      break

if not flag:
  print("-1")
else:
  print(total)
a,b=int,input().split()
if a==3,b==1 :
  print(2)
elif a==1,b==2 :
  print(3)
elif a==2,b==3 :
  print(1)


### FIXED CODE ###

a=int(input())
b=int(input())
if a==3 and b==1 :
  print(2)
elif a==1 and b==2 :
  print(3)
elif a==2 and b==3 :
  print(1)
elif a==3 and b==2 :
  print(1)
elif a==1 and b==3 :
  print(2)
elif a==2 and b==1 :
  print(3)
n = int(input())
maxn = int(n ** 0.5)
for i in range(maxn):
    p = maxn - i
    if n % p == 0:
        q = n // p
        break
print(p + q - 2)

### FIXED CODE ###

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

if (1 <= a <= 9) & (1 <= b <= 9):
    print(a * b)
else:
    print('-1')
#!/usr/bin/env python

A = [input() for i in range(5)]
min = 9
min_dish = ''
for a in A:
    if int(a[-1]) < min and int(a[-1]) != 0:
        min = int(a[-1])
        min_dish = a
sum = int(min_dish)
A.remove(min_dish)
for a in A:
    if a[-1] == '0':
        sum += int(a)
    else:
        sum += int(a) + 10 - int(a[-1])
print(int(sum))

### FIXED CODE ###

#!/usr/bin/env python

A = [input() for i in range(5)]
m = 9
flag = True
for a in A:
    if int(a[-1]) == 0:
        pass
    elif int(a[-1]) <= m:
        flag = False
        m = int(a[-1])
        min_dish = a
B = [int(i) for i in A]
if flag:
    min_dish = str(min(B))
sum = int(min_dish)
A.remove(min_dish)
for a in A:
    if int(a[-1]) == 0:
        sum += int(a)
    else:
        sum += int(a) + int(10) - int(a[-1])
print(int(sum))
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

import numpy as np
from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
from scipy.sparse import csr_matrix

# strlist = "abcdefghijklmnopqrstuvwxyz"
n,x,y = map(int,input().split())

length = n
d = [1 for _ in range(n)]
i = list(range(0,n-1)) + [x]
j = list(range(1,n)) + [y]
# print(d,i,j,sep="\n")

graph = csr_matrix((d, (i, j)), shape=(n, n)) # 頂点i,jはゼロスタートである必要ある
# print(type(csr),csr,sep="\n")

#返り値は各頂点間の距離の値を含んだ隣接行列(float64型のnp.array)
dist = shortest_path(graph, directed=False).astype(int)
# dist = dijkstra(graph, directed=False).astype(int)
# print(type(dist),dist,sep="\n")

dist = dist.ravel() #配列の一次元化
# print(type(dist),dist,sep="\n")

ans = np.bincount(dist, minlength=n) // 2  #bincountは[0の個数,1の個数,2の個数…nの個数]を返す
# print(type(ans),ans,sep="\n")

print(*ans[1:], sep='\n')

### FIXED CODE ###

# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

import numpy as np
# import scipy as scp

# strlist = "abcdefghijklmnopqrstuvwxyz"
n,x,y = map(int,input().split())

ans = [0 for _ in range(n)]

for i in range(1,n):
    for j in range(i+1,n+1):
        kyori = min(j-i,abs(x-i)+1+abs(y-j),abs(i-y)+1+abs(x-j))
        ans[kyori] +=1

print(*ans[1:],sep="\n")
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
N = int(input())
act = [tuple(map(int,input().split())) for _ in range(N)]
dp = [[0]*N for _ in range(N+1)]

for i in range(1,N+1):
  for j in range(3):
    for k in range(3):
      if j != k:
        dp[i][j] = max(dp[i][j], dp[i-1][k] + act[i-1][j])

print(max(dp[N]))

### FIXED CODE ###

N = int(input())
act = [list(map(int,input().split())) for _ in range(N)]
dp = [[0]*3 for _ in range(N+1)]

for i in range(N):
  dp[i+1][0] = max(dp[i][1], dp[i][2]) + act[i][0]
  dp[i+1][1] = max(dp[i][0], dp[i][2]) + act[i][1]
  dp[i+1][2] = max(dp[i][0], dp[i][1]) + act[i][2]
  
print(max(dp[N]))
import sys
import numpy as np

input = sys.stdin.readline

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

X = [0 for _ in range(N)]



X = np.array(X)
A = np.array(A)
for i in range(N):
    B  = np.hstack((A[i:N+i], A[:i]))
    X = X + (-1)**i * B
 
print(*X)

### FIXED CODE ###

import sys

input = sys.stdin.readline

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

X = [0 for _ in range(N)]


for i in range(N):
    X[0] += (-1)**i * A[i]
for i in range(1, N):
    X[i] = -X[i-1] + 2*A[i-1]
 
 
print(*X)
n = int(input())
a = tuple(map(int, input().split(" ")))

color_types = [False]*7
pro_count = 0
if a < 3200:
	color_types[a//400] = True
else:
	pro_count += 1
print(min(8, sum(color_types)+pro_count))

### FIXED CODE ###

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

color_types = [False]*8
pro_count = 0
for a_i in a:
	if a_i < 3200:
		color_types[a_i//400] = 1
	else:
		pro_count += 1
print(max(1, sum(color_types)), sum(color_types)+pro_count)
la=[]
lb=[]
n=int(input())
kari=[]
tak=0
ao=0
for i in range(n):
    a,b=map(int,input().split())
    la.append(a)
    lb.append(b)
    kari.append(a-b)
while la!=[]:
    if max(kari)+min(kari)>0:
        tak+=la[kari.index(max(kari))]
        kari.remove(max(kari))
        la.remove(la[kari.index(max(kari))])
        lb.remove(lb[kari.index(max(kari))])
    else:
        tak+=la[kari.index(min(kari))]
        kari.remove(min(kari))
        la.remove(la[kari.index(min(kari))])
        lb.remove(lb[kari.index(min(kari))])
    if max(kari)+min(kari)>0:
        ao+=la[kari.index(min(kari))]
        kari.remove(max(kari))
        la.remove(la[kari.index(min(kari))])
        lb.remove(lb[kari.index(min(kari))])
    else:
        ao+=la[kari.index(min(kari))]
        kari.remove(max(kari))
        la.remove(la[kari.index(max(kari))])
        lb.remove(lb[kari.index(max(kari))])
print(int(tak-ao))

### FIXED CODE ###

la=[]
lb=[]
n=int(input())
kari=[]
tak=0
ao=0
s=-1
for i in range(n):
    a,b=map(int,input().split())
    la.append(a)
    lb.append(b)
    kari.append(a+b)
    ao+=b
kari.sort()
if n%2==0:
    for v in range(int(n/2)):
        tak+=kari[s]
        s+=-2
else:
    for k in range(int(n/2)+1):
        tak+=kari[s]
        s+=-2
print(tak-ao)
k,x = input()

text = "No"

if k*500>=x:
  text = "Yes"
  
print(text)

### FIXED CODE ###

k,x = input().split(" ")
k = int(k)
x = int(x)



text = "No"
 
if k*500>=x:
  text = "Yes"
  
print(text +"\n")
N = input()
h = list(map(str, input().split()))
c = []
tmp = 0
for x in range(len(h)-1, -1, -1):
  if h[x] <= h[x-1]:
    tmp += 1
  else:
    c.append(tmp)
    tmp = 0
print(max(c))


### FIXED CODE ###

N = int(input())
h = list(map(int, input().split()))
c = []
tmp = 0
for x in reversed(range(len(h))):
  if len(h) == 1:
    c.append(0)
  elif h[x] <= h[x-1]:
    tmp += 1
  else:
    c.append(tmp)
    tmp = 0
if len(c) == 0:
  c.append(tmp-1)
print(sorted(c)[-1])
import numpy as np

class Tropical():
    def __init__(self, values):
        self.values = values

    def __add__(self, x):
        return min(self.values, x.values)

    def __mul__(self, x):
        return self.values + x.values

    def Tropical_sum(self):
        return min(self.values)

# INF
INF = float('inf')
Infty = Tropical(INF)

# Tropical Product
def Tropical_Product(A, B):
    return [[(lambda x: Tropical(x).Tropical_sum())(list(map(lambda x: Tropical(x[0]) * Tropical(x[1]), zip(A[i], [[B[j][i] for j in range(len(B))] for i in range(len(B))][j])))) for j in range(len(A))] for i in range(len(B))]

def Tropical_Pow(A, num):
    tmp = A
    B = A
    for _ in range(num-1):
        B = Tropical_Product(B,tmp)
    return B

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

Z = np.full((N,N),INF)
for i in range(N):
    for j in range(i+1,i+3):
        #print(i,j)
        if j <= N:
            #print(i,j)
            if abs(i-j)==1 and i+1 < N:
                Z[i][j] = abs(h[i]-h[i+1])
            elif abs(i-j)==2 and i+2 < N:
                Z[i][j] = abs(h[i]-h[i+2])

for i in range(N):
    tmp = Tropical_Pow(Z,i)
    if tmp[0][-1] != INF:
        print(int(tmp[0][-1]))
        exit()

### FIXED CODE ###

def chmin(a, b):
    if a > b:
        return b
    else:
        return a

# input
N = int(input())
h = list(map(int, input().split()))

# dp table
dp = [float('inf')]*(10**5 + 10)

# 初期条件
dp[0] = 0

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

# ans
print(dp[N-1])