Harryxun/stf_run huggingface dataset:
N,M = map(int,input().split())

color = []
colorStorage = []
for i in range(N):
    color.append(i)
    colorStorage.append([i])

for _ in range(M):
    p,q = map(int,input().split())
    p -= 1
    q -= 1
    if color[p] == color[q]:
        continue
    else:
        x = color[p]
        y = color[q]
        if len(colorStorage[x]) >= len(colorStorage[y]):
            for elem in colorStorage[y]:
                color[elem] = x
                colorStorage[x].append(elem)
            colorStorage[y] = []
        else:
            for elem in colorStorage[y]:
                color[elem] = y
                colorStorage[y].append(elem)
            colorStorage[x] = []
maxL = 0
for colorList in colorStorage:
    if maxL < len(colorList):
        maxL = colorList
print(maxL)



### FIXED CODE ###

N,M = map(int,input().split())

color = []
colorStorage = []
for i in range(N):
    color.append(i)
    colorStorage.append([i])

for _ in range(M):
    p,q = map(int,input().split())
    p -= 1
    q -= 1
    if color[p] == color[q]:
        continue
    else:
        x = color[p]
        y = color[q]
        if len(colorStorage[x]) >= len(colorStorage[y]):
            for elem in colorStorage[y]:
                color[elem] = x
                colorStorage[x].append(elem)
            colorStorage[y] = []
        else:
            for elem in colorStorage[x]:
                color[elem] = y
                colorStorage[y].append(elem)
            colorStorage[x] = []
maxL = 0
for colorList in colorStorage:
    if maxL < len(colorList):
        maxL = len(colorList)
print(maxL)
N,M=map(int,input().split())
ans=['A']*(N+1)
for i in range(M):
    s,c=map(str,input().split())
    s=int(s)
    if ans[s]=='A' or ans[s]==c :
        ans[s]=c
    else:
        print('-1')
        exit()
if N>1 and ans[1]=='A':
    print('-1')
FA=''.join(FA)
FA=FA[1:]
if FA.count('A')>0:
    print(FA.replace('A','0'))
print(int(FA))


### FIXED CODE ###

N,M=map(int,input().split())
ans=[-1]*(N+1)
for i in range(M):
    s,c=map(int,input().split())
    if ans[s]==-1 :
        ans[s]=c
    elif ans[s]==c :
        pass
    else:
        print('-1')
        exit()

if N>=2 and ans[1]==0:
    print('-1')
    exit()
elif N>=2 and ans[1]==-1: #ここが間違ってた。
    ans[1]=1
else:
    pass

for j in range(len(ans)):
    if ans[j] == -1:
        ans[j] = 0

if N==1:
    FA=ans[-1]
elif N==2:
    FA=10*ans[-2]+ans[-1]
else:
    FA=100*ans[-3]+10*ans[-2]+ans[-1]
print(FA)
import math

N, M = map(int, input().split())
MOD = 10**9+7

def trial_division(n):
  #素因数を格納するリスト
  factor = []
  #2から√n以下の数字で割っていく
  tmp = int(math.sqrt(n)) + 1
  for num in range(2,tmp):
    cnt = 0
    while n % num == 0:
      n //= num
      cnt += 1 
    if cnt != 0:
      factor.append(cnt)
  #リストが空ならそれは素数
  if not factor:
    return factor
  else:
    if n != 1:
      factor.append(1)
    return factor

from operator import mul
from functools import reduce

def cmb(n,r):
  r = min(n-r,r)
  if r == 0: return 1
  over = reduce(mul, range(n, n - r, -1))
  under = reduce(mul, range(1,r + 1))
  return over // under

ans = 1
cnts = trial_division(M)
for cnt in cnts:
  ans = ans * (cmb(cnt+N-1, cnt))%MOD

print(cnts)
print(ans)

  
  

### FIXED CODE ###

nums = list(map(int, input().split()))
nums.sort(key=lambda x: -x)
print(int(str(nums[0]) + str(nums[1])) + nums[2])
N=int(input())
A=list(map(int,input().split()))

turn=A[1]-A[0]
ans=1

if N>2:
    for i in range(1,N-1):
        judge=turn * (A[i+1]-A[i])

        if judge<0:
            ans+=1
            turn=0
        else:
            turn=A[i+1]-A[i]

print(ans)

### FIXED CODE ###

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

ans=1
x=y=0
c=A[0]

for i in range(1,N):
    if c < A[i]:
        x=1
    elif c>A[i]:
        y=1
    
    if x==1 and y==1:
        ans+=1
        x=y=0
    
    c=A[i]

print(ans)
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read() for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


X, Y, Z, K = read_ints()
A = read_ints()
B = read_ints()
C = read_ints()
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)


import numpy as np
dp = np.zeros((X, Y, Z), dtype=int)
dp[0, 0, 0] = A[0] + B[0] + C[0]

from itertools import product
for a, b, c in product(range(X), range(Y), range(Z)):
    if a + 1 != X:
        dp[a+1, b, c] = dp[a, b, c] - A[a]+A[a+1]
    if b + 1 != Y:
        dp[a, b+1, c] = dp[a, b, c] - B[b]+B[b+1]
    if c + 1 != Z:
        dp[a, b, c + 1] = dp[a, b, c] - C[c] + C[c + 1]

for ans in np.sort(dp.reshape(-1))[::-1][:K]:
    print(ans)


### FIXED CODE ###

import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


X, Y, Z, K = read_ints()
A = read_ints()
B = read_ints()
C = read_ints()

from itertools import product

AB = [a + b for a, b in product(A, B)]
AB.sort(reverse=True)

ABC = [ab + c for ab, c in product(AB[:K], C)]
ABC.sort(reverse=True)

ABC = ABC[:K]

print(*ABC, sep='\n')
import functools as ft
import logging
import unittest
from collections import (
    namedtuple,
)
from heapq import (
    heappush,
    heappop,
)

debug = logging.getLogger(__name__).debug


def input_ints():
    return list(map(int, input().strip().split()))


@ft.total_ordering
class PrioritizedItem(namedtuple('PrioritizedItem', 'priority, value')):
    def __lt__(self, other):
        return self.priority < other.priority


def a_star(succ, cost, heuristic, start):
    cost_dict = {start: (heuristic(start), 0)}
    prev_dict = {}
    close = set()
    q = [PrioritizedItem(cost_dict[start], start)]

    while q:
        cost_u, u = heappop(q)
        if u not in close and cost_u <= cost_dict[u]:
            close.add(u)

            yield u, prev_dict, cost_dict

            for v in succ(u):
                cost_uv = cost(u, v)
                heuristic_v = heuristic(v)

                cost_v_old = cost_dict.get(v)
                cost_v_new = (
                    cost_u[1] + cost_uv + heuristic_v,
                    cost_u[1] + cost_uv,
                )
                if cost_v_old is None or cost_v_new < cost_v_old:
                    cost_dict[v] = cost_v_new
                    prev_dict[v] = u
                    heappush(q, PrioritizedItem(cost_v_new, v))
                    try:
                        close.remove(v)
                    except KeyError:
                        pass


def _main():
    n, = input_ints()
    xy = [tuple(input_ints()) for _ in range(n)]

    pq = [
        (x1 - x2, y1 - y2)
        for (x1, y1) in xy
        for (x2, y2) in xy
        if not (x1 == x2 and y1 == y2)
    ]

    ans = []
    for p, q in pq:
        result = a_star(
            succ=lambda u: [u + (xy_,) for xy_ in xy],
            cost=lambda u, v: int(
                v[-1][0] - u[-1][0] != p or v[-1][1] - u[-1][1] != q),
            heuristic=lambda u: 0,
            start=((float('inf'),) * 2,),
        )
        tail, prev_dict, cost_dict = (None,) * 3
        for tail, prev_dict, cost_dict in result:
            if len(tail) > len(xy):
                break
        ans.append(cost_dict[tail][0])

    print(min(ans))


class Test(unittest.TestCase):
    def setUp(self):
        import run
        self._test = run

    def test_main(self):
        self._test.test_files(self, _main)


if __name__ == '__main__':
    _main()


### FIXED CODE ###

from collections import (
    Counter,
)


def input_ints():
    return list(map(int, input().strip().split()))


def _main():
    n = input_ints()[0]
    xy = [input_ints() for _ in range(n)]

    if len(xy) == 1:
        print(1)
        return

    (_, count), = Counter(
        (x1 - x2, y1 - y2)
        for (x1, y1) in xy
        for (x2, y2) in xy
        if not (x1 == x2 and y1 == y2)
    ).most_common(1)

    print(len(xy) - count)


if __name__ == '__main__':
    _main()
# https://atcoder.jp/contests/abc174/tasks/abc174_e

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

if K == 0:
    print(max(A))
    exit()

# K回切って全ての長さをL未満にできるかどうか
def valid(L):
    # print(A, L)
    count = 0
    for a in A:
        # print(a, L, a // L, a % L)
        count += (a - 1) // L
    # print(count)
    return count <= K

# 長さLの二分探索
ng = -1
# ok = max(A) + 1
ok = 10 ** 9
while abs(ok - ng) > 1:
    m = (ok + ng) // 2
    # print(m, valid(m))
    if valid(m):
        ok = m
    else:
        ng = m
print(ok)

### FIXED CODE ###

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

def is_ok(L):
    count = 0
    for a in A:
        count += a // L
        if a % L == 0:
            count -= 1
    return count <= K

ng = 0
ok = max(A)
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if is_ok(mid):
        ok = mid
    else:
        ng = mid
print(ok)
import copy
h, w = map(int, input().split())

a = [list(map(lambda x: int(x) % 2, input().split())) for _ in range(h)]
# for v in a:
#     print(*v)

directions = [[0, 1], [1, 0], [0, -1], [-1, 0]]
visited = copy.deepcopy(a)
number = [[i * w + j for j in range(w)] for i in range(h)]
def bfs(x, y):
    graph = [[] for _ in range(h * w)]
    que = [(x, y)]
    visited[y][x] = 0
    while que:
        x, y = que.pop(0)
        n = number[y][x]

        for dx, dy in directions:
            nx, ny = x + dx, y + dy
            if 0 <= nx < w and 0 <= ny < h and visited[ny][nx] == 1:
                que.append((nx, ny))
                nn = number[ny][nx]
                graph[n].append(nn)
                visited[ny][nx] = 0
                # graph[nn].append(n)
    return graph


def dfs(i, slide):
    if not graph[i]:
        dp[slide][i] = slide, None
        return slide

    r = dp[slide].get(i)
    if r is not None:
        return r[0]

    none = [dfs(c, 0) for c in graph[i]]
    if slide:
        r = sum(none)
        dp[slide][i] = r, None
        return r + 1
    else:
        to = [dfs(c, 1) for c in graph[i]]
        r = 0
        merge = None
        for i_ in range(len(graph[i])):
            s = 0
            for j_ in range(len(graph[i])):
                if j_ == i_: # slide!!
                    s += to[j_]
                else:
                    s += none[j_]
            if s > r:
                r = s
                merge = graph[i][i_]
        s = sum(none)
        if s > r:
            r = s
            merge = None
        dp[slide][i] = r, merge
        return r


def yx(i):
    return i // w + 1, i % w + 1


answers = []
def dfs_answer(i, slide):
    _, to = dp[slide][i]
    for c in graph[i]:
        if c == to:
            answers.append(yx(i) + yx(to))
            dfs_answer(c, 1)
        else:
            dfs_answer(c, 0)


for i in range(h):
    for j in range(w):
        if visited[i][j]:
            graph = bfs(j, i)
            dp = [{}, {}]
            dfs(number[i][j], 0)
            # print(dfs(number[i][j], 0), ":", j, i, number[i][j])
            #
            # print("--------")
            dfs_answer(number[i][j], 0)
            # __import__("sys").exit()

print(len(answers))
for ans in answers:
    print(*ans)


### FIXED CODE ###

h, w = map(int, input().split())

a = [list(map(lambda x: int(x) % 2, input().split())) for _ in range(h)]

road = []
for i in range(h):
    for j in list(range(w))[::(i % 2) * -2 + 1]:
        road.append((i + 1, j + 1))

answer = []
for f, t in zip(road[:-1], road[1:]):
    if a[f[0] - 1][f[1] - 1] % 2:
        answer.append(f + t)
        a[t[0] - 1][t[1] - 1] += 1

print(len(answer))
for ans in answer:
    print(*ans)
n, m = map(int, input().split())
print((n-1)*(m-1))

### FIXED CODE ###

N = input()
print("ABC" + N )
H,W = map(int,input().split())

if H%3 == 0 or W%3 == 0:
    print(0)
    exit()

##縦方向の探索

ans = 1e10

for i in range(1,H-1):
    tate = W*i##上から切る
    mini = (H-i)*(W//2)##半分に分割したちっこいほう

    ans = min(ans,max(tate,mini,H*W-tate-mini)-min(tate,mini,H*W-tate-mini))

##横方向の探索
for i in range(1,W-1):
    yoko = H*i
    mini = (W-i)*(W//2)
    ans = min(ans,max(yoko,mini,H*W-tate-mini)-min(yoko,mini,H*W-tate-mini))

print(ans)

### FIXED CODE ###

H,W = map(int,input().split())

ans = 1e19
##縦方向の探索
for i in range(1,H):
    tate = W*i##上から横に切る
    ##横に切る
    if i < H-1:
        mini = W*((H-i)//2)##分割したやつ
        ##print(tate,mini,H*W-mini-tate)
        ans = min(ans,max(tate,mini,H*W-mini-tate)-min(tate,mini,H*W-mini-tate))

    ##縦に切る
    mini = (H-i)*(W//2)
    ##print(tate,mini,H*W-mini-tate)
    ans = min(ans,max(tate,mini,H*W-tate-mini)-min(tate,mini,H*W-tate-mini))

##横方向の探索
for i in range(1,W):
    yoko = H*i
    if i < W-1:
        mini = H*((W-i)//2)
        ##print(yoko,mini,H*W-mini-yoko)
        ans = min(ans,max(yoko,mini,H*W-mini-yoko)-min(yoko,mini,H*W-yoko-mini))
    mini = (W-i)*(H//2)
    ##print(yoko,mini,H*W-yoko-mini)
    ans = min(ans,max(yoko,mini,H*W-yoko-mini)-min(yoko,mini,H*W-yoko-mini))

print(ans)
N,Q=map(int,input().split())
tree=[[] for _ in range(N)]
counter=[0]*N
for _ in range(N-1):
    a,b=map(int, input().split())
    tree[a-1].append(b-1)
for _ in range(Q):
    p,x=map(int, input().split())
    counter[p-1]+=x
def f(t,x):
    for i in t:
        counter[i]+=x
        f(tree[i],counter[i])
f(tree[0],counter[0])
counter=list(map(str, counter))
print(' '.join(counter))


### FIXED CODE ###

from collections import deque

N,Q=map(int,input().split())
to=[[] for _ in range(N)]
count=[0]*N
for _ in range(N-1):
    a,b=map(int, input().split())
    to[a-1].append(b-1)
    to[b-1].append(a-1)
for _ in range(Q):
    p,x=map(int, input().split())
    count[p-1]+=x
q = deque()
q.append(0)
p=[True]*N
while q:
    i = q.pop()
    if p[i]:
        p[i]=False
        for j in to[i]:
            if p[j]:
                count[j]+=count[i]
                q.append(j)
print(*count)
import sys

def solve(n):
    if  a <= 8 and b <= 8 :
        return 'yay'
    else:
        return ':('
def readQuestion():
    line = sys.stdin.readline().rstrip()
    return int(line)

def main():
    n = readQuestion()
    answer = solve(n)
    print(answer)
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys

def solve(a, b):
    if  a <= 8 and b <= 8 :
        return 'Yay!'
    else:
        return ':('
    
def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_a, str_b] = line.split(' ')
    return (int(str_a), int(str_b))

def main():
    a, b = readQuestion()
    answer = solve(a, b)
    print(answer)
    
if __name__ == '__main__':
    main()
N,K = map(int,input().split())
number = 0
data = []
nolist = list(range(1,K+1))
for i in range(N):
  number = int(input())
  for j in range(number):
    data = input().split()
    nolist[int(data[j])-1] = 0
try:
  for i in range(N):
  	nolist.remove(0)
except:
  pass
print(len(nolist))

### FIXED CODE ###

N,K = map(int,input().split())
data = []
nolist = list(range(1,N+1))
for i in range(K):
  number = int(input())
  data = input().split()
  for j in range(number):
    nolist[int(data[j])-1] = 0
try:
  for i in range(N):
  	nolist.remove(0)
except:
  pass
print(len(nolist))
s = input()
if s[0] == 'Y' and s[1] == 'A' and s[2] == 'K' and s[3] == 'I':
    print('Yes')
    exit()
print('No')


### FIXED CODE ###

s = input()
s_list = []
ans = ['Y', 'A', 'K', 'I']
for i in s:
    s_list.append(i)
s_list = s_list[:4]
if s_list == ans:
    print('Yes')
else:
    print('No')
import numpy as np
N,M,C = map(int,input().split())
B = list(int,input().split())
for i in range(1,N)
    Ai = list(int,input().split())
    

ai = np.array(Ai)
b = np.array(B)

ait = ai.reshape([N,1])
cnt = 0
for i in range(1,N)
    if (np.dot(ait,b) + C >0)
         cnt += 1
print(cnt)




### FIXED CODE ###

import numpy as np
N,M,C = map(int,input().split())
B = [int(k) for k in input().split()]
A = [[int(j) for j in input().split()] for i in range(N)] 
b = np.array(B)
cnt = 0
for i in range(N):
    if (np.dot(np.array(A[i]),b) + C >0):
        cnt += 1
    else:
        cnt = cnt
        
print(cnt)
def unbalanced(s: str) -> tuple:
    for i in range(len(s) - 1):
        c1, c2 = s[i], s[i + 1]
        if c1 == c2:
            return i+1, i+2
        if i + 2 < len(s):
            c3 = s[i + 2]
            if c1 == c3:
                return i+1, i+3
    return False


if __name__ == "__main__":
    s = input()
    a, b = unbalanced(s)
    print(a, b)


### FIXED CODE ###

def unbalanced(s: str) -> tuple:
    for i in range(len(s) - 1):
        c1, c2 = s[i], s[i + 1]
        if c1 == c2:
            return i+1, i+2
        if i + 2 < len(s):
            c3 = s[i + 2]
            if c1 == c3:
                return i+1, i+3
    return -1, -1


if __name__ == "__main__":
    s = input()
    a, b = unbalanced(s)
    print(a, b)
N, K = map(int, input().split())
A = list(map(int, input().split()))

def f(X):
    return sum([X ^ a for a in A])

bin_K = '{:040b}'.format(K)
bin_A = ['{:040b}'.format(a) for a in A]
counter = [{'0': 0, '1': 0} for i in range(40)]
for ba in bin_A:
    for i in range(40):
        counter[i][ba[i]] += 1

cand = []
for i in range(40):
    if counter[i]['0'] <= counter[i]['1']:
        cand.append('0')
    else:
        cand.append('1')

i = 0
for i in range(40):
    if bin_K[i] == '1':
        break

bin_K = bin_K[i:]
cand = cand[i:]
counter = counter[i:]

candidate = []
for i in range(len(cand)):
    if bin_K[i] == '1':
        tmp = cand[i:]
        tmp[0] = '0'
        candidate.append(f(int(bin_K[:i]+''.join(tmp), 2)))

print(max(candidate))

### FIXED CODE ###

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

def f(X):
    return sum([X ^ a for a in A])

bin_K = '{:040b}'.format(K)
bin_A = ['{:040b}'.format(a) for a in A]
counter = [{'0': 0, '1': 0} for i in range(40)]
for ba in bin_A:
    for i in range(40):
        counter[i][ba[i]] += 1

cand = []
for i in range(40):
    if counter[i]['0'] < counter[i]['1']:
        cand.append('0')
    else:
        cand.append('1')

i = 0
for i in range(40):
    if bin_K[i] == '1':
        break

bin_K = bin_K[i:]
cand = cand[i:]
counter = counter[i:]

candidate = [f(0), f(K)]
for i in range(len(cand)):
    if bin_K[i] == '1':
        tmp = cand[i:]
        tmp[0] = '0'
        candidate.append(f(int(bin_K[:i]+''.join(tmp), 2)))

print(max(candidate))
mod = 10 ** 9 + 7

n,m = map(int,input().split())
lis = [int(input()) for x in range(m)]
if n == 1:
    print(1)
elif n == 2:
    print(2)
stairs = [0 for x in range(n)]
stairs[0] = 1
if 1 in lis:
    stairs[1] = 0
else:
    stairs[1] = 1
#print(stairs)
f = 0
for x in range(2,n):
    if x in lis:
        stairs[x] = 0
    else:
        stairs[x] = (stairs[x-1] + stairs[x-2]) % mod
    
#print(stairs)
print((stairs[n-1] + stairs[n-2]) % mod)
    


### FIXED CODE ###

import sys
mod = 10 ** 9 + 7

n,m = map(int,input().split())
if n in [0,1]:
    print(1)
    sys.exit()
    
if not m == 0: lis = [int(input()) for x in range(m)]
else: lis = [-1]
val1 = 1
if 1 in lis: val2 = 0
else: val2 = 1

if lis[0] == 1 and len(lis) >= 2:
    flg = lis[1]
    nex = 1
else:
    flg = lis[0]
    nex = 0
#print(lis)
for x in range(2,n):
    if x == flg: #x in lis
        #print(flg)
        nex += 1
        try: flg = lis[nex]
        except:flg = 0
        now = 0
    else:
        now = (val1 + val2) % mod
    val1,val2 = val2,now
    
print((val1 + val2) % mod)
n, m = map(int, input().split())
ipy = []
for i in range(m):
  p, y = map(int, input().split())
  ipy.append([i, p, y])

dict_p = {}
dict_c = {}

for i, p, y in sorted(ipy, key=lambda x: x[2]):
  if not p in dict_p:
    dict_p[p] = 0
  dict_p[p] += 1
  dict_c[p,i] = dict_p[p]

for i, p, y in ipy:
  print(f'{p:06}{dict_c[p,i]:06}')


### FIXED CODE ###

n, m = map(int, input().split())
ipy = []
for i in range(m):
  p, y = map(int, input().split())
  ipy.append([i, p, y])

dict_p = {}
dict_c = {}

for i, p, y in sorted(ipy, key=lambda x: x[2]):
  if not p in dict_p:
    dict_p[p] = 0
  dict_p[p] += 1
  dict_c[p,i] = dict_p[p]

for i, p, y in ipy:
  print('{0:06}{1:06}'.format(p, dict_c[p,i]))
import numpy as np
N, M = map(int, input().split())

A = np.zeros((N,M))
for i in range(N):
    a = list(map(int, input().split()))
    a = a[1:]
    A[i, 0:len(a)] = a

for i in range(N):
    a = A[i]
    a = a[(a != 0) & (a < M)]
    if i == 1:
        s = set(list(a))
    else:
        _s = set(list(a))
    s &= _s

print(len(s))

### FIXED CODE ###

import numpy as np
N, M = map(int, input().split())

A = np.zeros((N,M))
for i in range(N):
    a = list(map(int, input().split()))
    a = a[1:]
    A[i, 0:len(a)] = a

for i in range(N):
    a = A[i]
    a = a[(a != 0) & (a <= M)]
    if i == 0:
        s = set(list(a))
    else:
        _s = set(list(a))
        s &= _s

print(len(s))
n = int(input())
h = list(map(int, input().split()))

dp = [-1] * n

def dfs(i):
    if dp[i] != -1:
        return dp[i]
    if i == n - 1:
        return 0
    cost = 0
    if i == n - 2:
        cost = dfs(i + 1) + abs(h[i] - h[i + 1])
    else:
        cost = min(dfs(i + 1) + abs(h[i] - h[i + 1]), dfs(i + 2) + abs(h[i] - h[i + 2]))
    dp[i] = cost
    return cost

print(dfs(0))

### FIXED CODE ###

import sys
n = int(input())
h = list(map(int, input().split()))
dp = [-1] * n

sys.setrecursionlimit(n + 2)
def dfs(i):
    if dp[i] != -1:
        return dp[i]
    if i == n - 1:
        return 0
    cost = 0
    if i == n - 2:
        cost = dfs(i + 1) + abs(h[i] - h[i + 1])
    else:
        cost = min(dfs(i + 1) + abs(h[i] - h[i + 1]), dfs(i + 2) + abs(h[i] - h[i + 2]))
    dp[i] = cost
    return cost

print(dfs(0))
N, L = map(int, input().split())

#標準入力からリストの作成
a = map(str, input().split())
a = a.sort()

#リストの結合
mojiretu = ''join(a)

print(mojiretu)

### FIXED CODE ###

N, L = map(int, input().split())
 
#標準入力からリストの作成
list = []
for _ in range(N):
 i = str(input())
 list.append(i)

#リストのソート
list_a = sorted(list)
 
#リストの結合
mojiretu = ''.join(list_a)
 
print(mojiretu)
a = int(input())
print(2*a*pi)

### FIXED CODE ###

a = int(input())
print(2*a*3.14)