jiahuimbzuai/CoQuIR huggingface dataset:
//  [go]
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

type Pos struct {
	x int
	y int
}

func main() {
	Count := readLineInt()[0]
	PosArray := make([]Pos, Count)
	Loop(0, Count, func(i int) {
		in := readLineInt()
		PosArray[i] = Pos{in[0], in[1]}
	})

	var Sum float64
	Perm := getAllPermutation(getPermutationFromLength(Count)...)
	for _, v := range Perm {
		Length := len(v)
		for i, from := range v {
			if Length <= i+1 {
				continue
			}
			from--
			to := v[i+1] - 1
			Sum += math.Sqrt(math.Pow(float64(PosArray[from].x-PosArray[to].x), 2) + math.Pow(float64(PosArray[from].y-PosArray[to].y), 2))
		}
	}
	fmt.Println(Sum / float64(len(Perm)))
}

/////////////////////////////////////////

func readLineInt() []int {
	result := make([]int, 0)
	for _, v := range strings.Split(readLine(), " ") {
		i, _ := strconv.Atoi(v)
		result = append(result, i)
	}
	return result
}

var reader = bufio.NewReaderSize(os.Stdin, 1e6)

func readLine() string {
	result := make([]byte, 0, 1e6)
	for {
		line, remains, e := reader.ReadLine()
		if e != nil {
			panic(e)
		}
		result = append(result, line...)
		if !remains {
			break
		}
	}
	return string(result)
}

func Loop(start, end int, f func(i int)) {
	for i := start; i < end; i++ {
		f(i)
	}
}

func pow(a, b int) int {
	result := a
	Loop(0, b-1, func(i int) {
		result = result * a
	})

	return result
}

func sqrt(a int) int {
	return int(math.Sqrt(float64(a)))
}

func getPermutationFromLength(i int) []int {
	result := make([]int, i)
	Loop(0, i, func(i int) {
		result[i] = i + 1
	})
	return result
}

func getAllPermutation(source ...int) [][]int {
	Result := make([][]int, 0, len(source))
	for _, v := range source {
		excluded := excludeFromArray(source, v)
		if len(excluded) == 1 {
			Result = append(Result, []int{v, excluded[0]})
		} else {
			a := getAllPermutation(excluded...)
			for _, av := range a {
				o := make([]int, len(av)+1)
				o[0] = v
				for avi, avv := range av {
					o[avi+1] = avv
				}
				Result = append(Result, o)
			}
		}
	}

	return Result
}

func excludeFromArray(i []int, t int) []int {
	Result := make([]int, len(i)-1)
	index := 0
	for _, c := range i {
		if c != t {
			Result[index] = c
			index++
		}
	}
	return Result
}
//  [ruby]
include Math

N = gets.to_i
town = (0..N-1).to_a
x, y = N.times.map{gets.split.map(&:to_i)}.transpose
sum = 0

town.combination(2) do |i, j|
  sum += sqrt((x[i]-x[j])**2 + (y[i]-y[j])**2)
end

ans = 2*sum / N

puts sprintf("%.10f", ans)
//  [ruby]
def solve(n, xs, ys)
  len = [*0...n].combination(2).map do |i, j|
    dx = xs[i] - xs[j]
    dy = ys[i] - ys[j]
    Math.sqrt(dx ** 2 + dy ** 2)
  end.inject(:+)
  sprintf('%.10f', len / (n / 2.0))
end

n = gets.to_i
xs = []
ys = []
n.times do |_|
  xy = gets.chomp.split.map(&:to_i)
  xs << xy.first
  ys << xy.last
end

puts solve(n, xs, ys)
//  [ruby]
n = gets.to_i
cities = []
n.times { cities << gets.split.map(&:to_i) }
def distance(x1, y1, x2, y2)
  Math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
end

array = []
cities.combination(2).each do |c|
  array << distance(c[0][0], c[0][1], c[1][0], c[1][1])
end

sum = array.inject(:+)
ans = sum / array.size * (n - 1)
puts ans
//  [ruby]
N = gets.chomp.to_i
xy = []
N.times do |i|
  xy << gets.chomp.split(" ").map(&:to_i)
end


def dist(xy1, xy2)
  @dist ||= {}
  k = [xy1, xy2].sort
  @dist[k] ||= Math.sqrt((xy1[0] - xy2[0])**2 + (xy1[1] - xy2[1])**2)
end

sum_d = 0
n_pat = 0
(1..N).to_a.permutation(N).each do |pat|
  d = 0
  0.upto(pat.size - 2) do |x|
    i = pat[x]-1
    j = pat[x+1]-1
    d += dist(xy[i], xy[j])
  end
  sum_d += d
  n_pat += 1
end

puts sum_d / n_pat
//  [ruby]
N = gets.to_i
info = readlines

num = 1
arr = []
ans = []
sum = 0

N.times do
    arr.push(num)
    num += 1
end

paterns = arr.permutation(N).to_a
paterns.each do |patern|
    index = 0
    (N-1).times do
        x = info[patern[index]-1].split(" ")[0].to_i - info[patern[index+1]-1].split(" ")[0].to_i
        y = info[patern[index]-1].split(" ")[1].to_i - info[patern[index+1]-1].split(" ")[1].to_i
        sum += Math.sqrt(x*x + y*y)
        index += 1
    end
end

puts sum/paterns.count
//  [ruby]
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

require 'bigdecimal'

N = get_int
X = []
Y = []
N.times do |i|
  X[i], Y[i] = get_ints
end

sum = 0
[*0...N].permutation.each do |arr|
  s_sum = 0
  arr.each_cons(2) do |i, j|
    s_sum += Math.sqrt(BigDecimal((X[i] - X[j]) ** 2) + BigDecimal((Y[i] - Y[j]) ** 2))
  end
  sum += s_sum
end

puts sum / [*0...N].permutation.to_a.length
//  [rust]
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let arr:Vec<(f64, f64)> = (0..n).map(|_| (read(), read())).collect();
    let mut cnt = 0.0;
    for i in 0..n {
        for j in 0..n {
            cnt += ((arr[i].0 - arr[j].0).powf(2.0) + (arr[i].1 - arr[j].1).powf(2.0)).sqrt();
        }
    }
    println!("{}", cnt / n as f64);

}
//  [rust]
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! flush {
    () => {
        std::io::stdout().flush().unwrap();
    };
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let ps: Vec<_> = (0..n)
        .map(|_| {
            let x: f64 = sc.cin();
            let y: f64 = sc.cin();
            (x, y)
        })
        .collect();
    let mut dsum = 0.0;
    for i in 0..n {
        for j in 0..i {
            let d = (ps[i].0 - ps[j].0).hypot(ps[i].1 - ps[j].1);
            dsum += d;
        }
    }
    put!(dsum * 2.0 / n as f64);
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}
//  [rust]
fn main() {
    let n: usize = read();
    let mut v: Vec<(i32, i32)> = Vec::new();
    for _ in 0..n {
        v.push(read_tuple());
    }

    let mut cnt = 0.0;
    let mut ret = 0.0;
    for i in 0..n {
        for j in 0..n {
            if i == j { continue; }
            let (x1, y1) = v[i];
            let (x2, y2) = v[j];
            ret += d(x1, y1, x2, y2);
            cnt += 1.0;
        }
    }

    println!("{}", ret * (n as f64 - 1.0) / cnt);
}

fn d(x1: i32, y1: i32, x2: i32, y2: i32) -> f64 {
    let tmp = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
    (tmp as f64).sqrt()
}

fn read_tuple() -> (i32, i32) {
    let v: Vec<i32> = read_vec();
    (v[0], v[1])
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}
//  [swift]
import Foundation
// 第一引数には順列を生成したい配列を渡す
// 第二引数には順列を生成したい配列のサイズを渡す
func permutations(L:[[Int]],L_cnt:Int)->[[[Int]]]{
    // もしLが空なら[[]]を返す
    if L == []{
        return [[[]]]
    }
    // もしLのサイズが1なら[L]を返す
    else if L_cnt == 1{
        return [L]
    }
    //Lのサイズが2以上の時の処理
    else{
        //戻り値となる二次元配列を初期化
        var result:[[[Int]]] = []
        // Lの要素についてループを回す 
        for i in 0..<L_cnt{
            // 再帰
            for var x in permutations(L:Array(L[0..<i]+L[i+1..<L_cnt]),L_cnt:L_cnt-1){
                // 得られた二次元配列の要素である配列にL[i]を追加
                x.append(L[i])
                // 新しくできた順列をresultに追加
                result.append(x)
            }
        }
        // 生成した順列を返す
        return result
    }
}

// 2乗する関数
func pow2(n:Int)->Int{
    return n*n
}

// 標準入力からnを受け取る
let n = Int(readLine()!)!

// 標準入力からx,yを受け取る
// x,yを持っておく配列mを用意
var m:[[Int]] = []
for _ in 0..<n{

    // mに入力値を入れていく
    let xy = readLine()!.split(separator:" ").map{Int($0)!}
    m.append(xy)
}

// 順列の生成
var check = permutations(L:m,L_cnt:n)

// 答えを入れる変数を用意
var ans:Double = 0.0

// 順列全探索
for i in check{

    // iの要素について全探索
    for j in 0..<n-1{
    
        // i[j]とi[j+1]の距離をansに追加
        ans += sqrt(Double( pow2(n:i[j][0] - i[j+1][0]) + pow2(n:i[j][1] - i[j+1][1])))
    }
}

// n!で割って平均をとる
for i in 1...n{
    ans/=Double(i)
}

// ansの出力
print(ans)
//  [typescript]
'use strict'
const main = (input: string) => {
    const std: string[] = input.split('\n')
    const n: number = ~~std.shift()
    const xy = std.map(v => v.split(' ').map(Number))
    let sum: number = 0
    if (n === 2) {
        const x = (xy[0][0] - xy[1][0])**2
        const y = (xy[0][1] - xy[1][1])**2
        return console.log(Math.sqrt(x + y))
    }
    for (let i = 0; i < n; i++) {
        for (let j = 0; j < n; j++) {
            if (i === j) continue
            const x = (xy[i][0] - xy[j][0])**2
            const y = (xy[i][1] -xy[j][1])**2
            sum += Math.sqrt(x + y)
        }
    }
    console.log(sum/n)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim())
//  [typescript]
import * as fs from 'fs'

const reader = (data: string) =>
  data
    .split('\n')
    .join(' ')
    .split(' ')
    .map(t => parseInt(t, 10))

function Main(input) {
  const [N, ...xy] = reader(input)
  const x = xy.filter((_, ind) => ind % 2 !== 0)
  const y = xy.filter((_, ind) => ind % 2 === 0)
  let answer = 0

  for (let i = 0; i < N - 1; i++) {
    for (let j = i + 1; j < N; j++) {
      answer += Math.sqrt(Math.pow(x[i] - x[j], 2) + Math.pow(y[i] - y[j], 2))
    }
  }

  console.log((answer * 2) / N)
}

Main(fs.readFileSync('/dev/stdin', 'utf8'))
//  [typescript]
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [n]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    const pointList: [number, number][] = [];
    const nList = [];
    let prod = 1;
    for (let i = 0; i < n; i++) {
      const [x, y] = tmp.shift().split(" ").map(int => parseInt(int));
      pointList.push([x, y]);
      nList.push(i);
      prod *= i + 1;
    }
    return `${Main.culc(n, nList, [], pointList) / prod}`;
  }

  static culc(n: number, remainList: number[], numberList: number[], pointList: [number, number][]) {
    if (remainList.length == 0) {
      let dist = 0;
      for (let i = 0, len = n - 1; i < len; i++) {
        dist += Main.dist(pointList[numberList[i]], pointList[numberList[i + 1]]);
      }
      return dist;
    }
    let dist = 0;
    for (let i = 0, len = remainList.length; i < len; i++) {
      dist += Main.culc(n, remainList.slice(0, i).concat(remainList.slice(i + 1, len)), numberList.concat([remainList[i]]), pointList);
    }
    return dist;
  }

  static tmp = {};

  static dist(point1: [number, number], point2: [number, number]): number {
    const [[x1, y1], [x2, y2]] = point1[0] < point2[0] || (point1[0] == point2[0] && point1[1] < point2[1]) ? [point1, point2] : [point2, point1];
    const key = `${x1}-${y1}-${x2}-${y2}`;
    if (Main.tmp[key] == null) {
      Main.tmp[key] = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
    }
    return Main.tmp[key];
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));
//  [typescript]
{
  const main = (input: string) => {
    const r = reader(input)
    const N = r.n()
    const xys = r.lines.map(line => line.split(' ').map(Number))

    const patterns = permutation(_range(N))

    let sum = 0

    patterns.forEach(ns => {
      let sumi = 0

      for (let i = 0; i < N - 1; i++) {
        const p1 = ns[i]
        const p2 = ns[i + 1]

        const [x1, y1] = xys[p1]
        const [x2, y2] = xys[p2]

        sumi += _distance(x1, y1, x2, y2)
      }
      sum += sumi
    })

    console.log(sum / patterns.length)
  }
  const _range = (n: number) => Array.from(Array(n).keys())
  const _distance = (x1, y1, x2, y2) =>
    Math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)

  const permutation = <T>(
    post: T[],
    result: T[][] = [],
    pre: T[] = [],
    n: number = post.length
  ) => {
    if (n > 0) {
      post.forEach((_, i) => {
        const rest = [...post]
        const elem = rest.splice(i, 1)

        permutation(rest, result, [...pre, ...elem], n - 1)
      })
    } else {
      result.push(pre)
    }
    return result
  }

  const reader = (str: string) => {
    const lines = str.trim().split('\n')
    const s = () => lines.shift() || ''
    const n = () => Number(s())

    const ss = () => s().split(' ')
    const ns = () => ss().map(Number)
    const nls = () => lines.map(Number)

    return { lines, s, n, ss, ns, nls }
  }

  const getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')

  main(getInput())
}
//  [python]
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

s = LS2()

print(s[0]+str(len(s)-2)+s[-1])
//  [python]
s=input()
l=len(s)-2
print(str(s[0]),l,str(s[-1]),sep='')
//  [python]
import math
import calendar
import fractions
import itertools

s = input()
a = s[1:-1]
print(s[0] + str(len(a)) + s[-1])
//  [java]
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.nextLine();
            out.println(s.charAt(0) + "" + (s.length() - 2) + s.charAt(s.length() - 1));
        }

    }

    static class InputReader {
        BufferedReader br;

        public InputReader(InputStream is) {
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            this.br = br;
        }

        public String nextLine() {
            String str = null;
            try {
                str = br.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return str;
        }

    }
}
//  [java]
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String ns = sc.next();
    String[] s = ns.split("");
    System.out.println(s[0] + (s.length - 2) + s[s.length - 1]);
  }
}
//  [cpp]
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s;
    cin >> s;
    cout << s[0] << s.size()-2 << s[s.size()-1]<<endl;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh

map< int , int > mp[nax];
int main()
{
	string s;
	cin >> s;
	cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
	return 0;
}
//  [c]
#include<stdio.h>
#include<string.h>

int main(void){
	char S[110];
	int len;
	scanf("%100s",S);
	len=strlen(S)-2;
	printf("%c%d%c\n",S[0],len,S[strlen(S)-1]);
}
//  [c]
#include <stdio.h>
#include <string.h>
int main(void){
    
    char s[101];
    
    scanf("%s",s);
    
    printf("%c",s[0]);
    printf("%d",strlen(s)-2);
    printf("%c\n",s[strlen(s)-1]);
    
    return 0;
}
//  [c]
#include <stdio.h>

int main()
{
	int i;
	char s[101];
	scanf("%s", s);
	for (i = 0; s[i] != 0; i++);
	printf("%c%d%c\n", s[0], i - 2, s[i-1]);
	fflush(stdout);
	return 0;
}
//  [javascript]
function Main(input) {
var cText = input.length-3;
	var sText = input[0];
	var eText = input[input.length-2];
        var n = sText+cText+eText;
console.log(n)
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
const main = args => {
  const s = args.trim();
  const l = s.length;
  console.log(`${s[0]}${l - 2}${s[l - 1]}`)
};
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
// https://atcoder.jp/contests/abc069/tasks/abc069_b
"use strict"
function Main(input) {
  const str = input.split('\n')[0];
  const len = str.length;
  console.log(`${str[0]}${len-2}${str[len-1]}`);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	s := Scan()
	fmt.Print(string(s[0]))
	fmt.Print(len(s) - 2)
	fmt.Println(string(s[len(s)-1]))
}
//  [go]
package main

import (
	"fmt"
	"strconv"
)

func main() {
	// Code for B - i18n
	var s string
	fmt.Scanf("%s", &s)
	fmt.Println(s[0:1] + strconv.Itoa(len(s)-2) + s[len(s)-1:len(s)])
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanInit()

	s := nextStr()
	ans := fmt.Sprintf("%c%d%c", s[0], len(s)-2, s[len(s)-1])

	fmt.Println(ans)

}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}
//  [ruby]
s=gets.chomp
puts s[0]+(s.size-2).to_s+s[-1]
//  [ruby]
S = gets.chomp.chars

a = S.shift
z = S.pop
cnt = S.count.to_s
puts a + cnt + z
//  [ruby]
s = gets.chomp

print "#{s[0]}#{s.size - 2}#{s[-1]}"
//  [rust]
use itertools::Itertools;

fn main() {
    proconio::input! {
    a:String,
    }
    let a=a.chars().collect_vec();
    println!("{}{}{}",a[0],a.len()-2,a[a.len()-1])
}
//  [rust]
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		cs: Chars,
	}

	println!("{}{}{}", cs[0], cs.len()-2, cs.last().unwrap());
}
//  [swift]
import Foundation

let s = readLine()!
print("\(s.prefix(1))\(s.count - 2)\(s.suffix(1))")
//  [swift]
let s=readLine()!.characters.map{$0}
print("\(s[0])\(s.count-2)\(s[s.count-1])")
//  [typescript]
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const s = input[0][0];

  return `${s[0]}${s.length - 2}${s[s.length - 1]}`;
};

console.log(main(read()));
//  [typescript]
const text = require('fs').readFileSync('/dev/stdin', 'utf-8').toString().split('\n')[0];
console.log(text.slice(0, 1) + (text.length - 2) + text.slice(-1));
//  [python]
import sys
sys.setrecursionlimit(200000)
import numpy as np
N = int(input())
h = list(map(int, input().split()))
defa = np.inf
dp = [defa] * N

def rec(i):
  if dp[i] != defa:
    return dp[i]
  if i == 0:
    dp[i] = 0
    return 0
  res = defa
  res = min(res, rec(i-1)+np.abs(h[i] - h[i-1]))
  if i >= 2:
    res = min(res, rec(i-2)+np.abs(h[i] - h[i-2]))
  dp[i] = res
  return dp[i]
n = int(rec(N-1))
print(n)
//  [python]
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

for i in range(1,n):
    l = max(i-k,0)
    dp[i] = np.min(np.abs(h[i]-h[l:i])+dp[l:i])
print(dp[-1])
//  [python]
import numpy as np

N = int(input())
WIDTH = 2
hight_arr = np.array(list(map(int, input().split())))
cost_arr = np.zeros(N,dtype=int)

for i in range(1,N):
    start = max(i-WIDTH,0)
    cost_arr[i] = np.min(np.abs(hight_arr[i] - hight_arr[start:i]) + cost_arr[start:i])
print(cost_arr[-1])
//  [java]
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    // 頂点番号，各頂点から出る複数のエッジ
    static List<Edge>[] graph;

    // 最短コスト
    static long mindist[];

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();

        int[] dist = new int[N];
        for (int i = 0; i < N; i++) {
            dist[i] = scanner.nextInt();
        }

        graph = new List[N];
        for (int i = 0; i < N; i++) {
            graph[i] = new ArrayList<>();
            if (i <= N - 2) {
                graph[i].add(new Edge(i + 1, Math.abs(dist[i] - dist[i + 1])));
            }
            if (i <= N - 3) {
                graph[i].add(new Edge(i + 2, Math.abs(dist[i] - dist[i + 2])));
            }
        }

//        debug();

        mindist = new long[N];
        solve(0);
        System.out.println(mindist[N - 1]);
    }

    static void solve(int v) {
        Arrays.fill(mindist, Long.MAX_VALUE);
        mindist[v] = 0;

        PriorityQueue<Vertex> pq = new PriorityQueue<>(
                ((v1, v2) -> v1.dist < v2.dist ? -1 : 1)
        );

        pq.add(new Vertex(v, mindist[v]));
        while (!pq.isEmpty()) {
            Vertex now = pq.poll();

            if (now.dist > mindist[now.id]) {
                continue;
            }

            for (Edge edge : graph[now.id]) {
                if (mindist[edge.to] > mindist[now.id] + edge.cost) {
                    mindist[edge.to] = mindist[now.id] + edge.cost;
                    pq.add(new Vertex(edge.to, mindist[edge.to]));
                }
            }
        }

    }

    static void debug() {
        for (int i = 0; i < graph.length; i++) {
            for (Edge edge : graph[i]) {
                System.out.println(i + " -> " + edge.to + ": " + edge.cost);
            }
            System.out.println();
        }
    }
}

// エッジに関するクラス
class Edge {
    int to, cost;

    public Edge(int to, int cost) {
        this.to = to;
        this.cost = cost;
    }
}

// 頂点に関するクラス
class Vertex {
    int id;
    long dist;

    public Vertex(int id, long dist) {
        this.id = id;
        this.dist = dist;
    }
}
//  [java]

import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int num = sc.nextInt();
    static int[] h = new int[num];
    static int[] dp = new int[num];

    public static void main(String[] args) {
        for (int i = 0; i < num; i++){
            h[i] = sc.nextInt();
            dp[i] = 2147483647;
        }
        System.out.println(check(num - 1));
    }
    public static int check(int i){
        if(dp[i] < 2147483647)
            return dp[i];
        if (i == 0)
            return 0;
        if (i == 1)
            return Math.abs(h[1] - h[0]);
        dp[i] = chmin(check(i - 1) + Math.abs(h[i] - h[i - 1]), check(i - 2) + Math.abs(h[i] - h[i - 2]));
        return dp[i];
    }
    public static int chmin(int a, int b){
        if(a > b){
            return b;
        }else{
            return a;
        }
    }
}
//  [java]
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final Scanner sc  = new Scanner(System.in);
    static final int     MOD = (int) 1E9 + 7;

    public static void main(String[] args) {
        int N = nint();
        long[] h = nlongs(N, 1, 0);
        long[] cost = new long[N+1];
        cost[1] = 0;
        cost[2] = cost[1] + cost(h, 2, 1);
        
        for (int n = 3; n <= N; n++) {
            cost[n] = min(cost[n-1] + cost(h, n, n-1),
                          cost[n-2] + cost(h, n, n-2));
        }
        
        System.out.println(cost[N]);
    }
    
    static long cost(long[] h, int from, int to) {
        return abs(h[to] - h[from]);
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static double ndouble() {
        return sc.nextDouble();
    }

    private static double[] ndoubles(int n) {
        return ndoubles(n, 0, 0);
    }

    private static double[] ndoubles(int n, int padL, int padR) {
        double[] d = new double[n + padL + padR];
        for (int i = 0; i < n; i++) {
            d[padL + i] = ndouble();
        }
        return d;
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nchars() {
        return sc.next().toCharArray();
    }

    private static char[] nchars(int padL, int padR) {
        char[] temp = sc.next().toCharArray();
        char[] ret = new char[temp.length + padL + padR];
        System.arraycopy(temp, 0, ret, padL, temp.length);
        return ret;
    }

    private static char[][] nchars2(int h, int w) {
        return nchars2(h, w, 0, 0);
    }

    private static char[][] nchars2(int h, int w, int padLU, int padRD) {
        char[][] a2 = new char[h + padLU + padRD][w + padLU + padRD];
        for (int i = 0; i < h; i++)
            System.arraycopy(nchars(), 0, a2[padLU + i], padLU, w);
        return a2;
    }

    private static long min(long... ls) {
        return Arrays.stream(ls).min().getAsLong();
    }

    private static long max(long... ls) {
        return Arrays.stream(ls).max().getAsLong();
    }

    private static long abs(long a) {
        return Math.abs(a);
    }
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9 + 7;

int n;

int h[100001];
int memo[100001];

int dp (int pos) {
	cerr << "pos = " << pos << "\n";
	if (pos < 0 or pos >= n)
		return INF;
	if (memo[pos] != -1)
		return memo[pos];
	int ans = INF;
	if (pos >= 1) {
		ans = min(ans, (abs(h[pos] - h[pos - 1]) + dp(pos - 1)));
		cerr << "ans (pos >= 1) = " << ans << "\n";
	}
	if (pos >= 2) {
		ans = min(ans, (abs(h[pos] - h[pos - 2]) + dp(pos - 2)));
		cerr << "ans (pos >= 2) = " << ans << "\n";
	}
	memo[pos] = ans;
	return ans;
}

int main () {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> h[i];
	for (int i = 0; i < n; i++)
		memo[i] = -1;
	memo[0] = 0;
	cout << dp(n - 1) << "\n";
	for (int i = 0; i < n; i++)
		cerr << memo[i] << " ";
	return 0;
}
//  [cpp]

/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

using namespace std;
using ll = long long;

#define coutendl() (std::cerr << std::endl)
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabCout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headCout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabHeadCout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
//#define int long long
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divUp(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }

/*****/

int Main()
{
	int N;
	cin >> N;
	vector<int> h(N);
	rep(i, N)	cin >> h.at(i);

	vector<int> s(N);
	s.at(0) = 0;
	s.at(1) = abs(h.at(1) - h.at(0));

	for (int i = 2; i < N; i++)
	{
		int max = INF;
		chmin(max, s.at(i - 1) + abs(h.at(i) - h.at(i - 1)));
		chmin(max, s.at(i - 2) + abs(h.at(i) - h.at(i - 2)));
		s.at(i) = max;
		debug_cout(max);
	}

	for (int i = 0; i < N; i++)
	{
		debug_cout(i);
		debug_tabCout(1, s.at(i));
	}

	cout << s.at(N - 1) << endl;

	return 0;
}

/*****/

int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);

	//std::cout << std::fixed << std::setprecision(10);

	Main();

	return 0;
}
//  [c]
#include <stdio.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define mi(x,y) (x<y?x:y)
#define N 100010

int main() {
	//メモリーのテスト
	int*mem=(int*)calloc(3<<26,sizeof(int));
	for(int q=0;q<3<<26;q++)mem[q]=q;
  
	int n, h[N] = { 0 }, dp[N] = { 0 };
	scanf("%d", &n);
	rep(i, n)scanf("%d", &h[i+1]);
	dp[0] = N;
	Rep(i,2,n+1)dp[i]=mi(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
	printf("%d", dp[n]);
}
//  [c]
#include <stdio.h>
#include <stdlib.h>

#define INF 1010101010

int N;
int h[114514];

int satorina[114514];

int asumikana(int pos) {
	int kitaeri, kugyu;
	if (pos == N) return 0;
	if (pos > N) return INF;
	if (satorina[pos]) return ~satorina[pos];

	kitaeri = asumikana(pos + 1) + abs(h[pos] - h[pos + 1]);
	kugyu = asumikana(pos + 2) + abs(h[pos] - h[pos + 2]);
	if (kugyu < kitaeri) kitaeri = kugyu;

	return ~(satorina[pos] = ~kitaeri);
}

int main(void) {
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 1; i <= N; i++) {
		if (scanf("%d", &h[i]) != 1) return 1;
	}
	printf("%d\n", asumikana(1));
	return 0;
}
//  [c]
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define BUFSIZE 100000	


int n;
int h[BUFSIZE] = {0};
int dp[BUFSIZE] = {0}; 

int min(int a,int b){
  if(a > b) return b;
  else return a;
}


int main(void){
   scanf("%d",&n);
   for(int i = 0;i < n;i++) scanf("%d",&h[i]);
  
   dp[0] = 0; dp[1] = abs(h[1] - h[0]);
   for(int i = 2;i < n;i++)
	dp[i] = min(dp[i-1] + abs(h[i] - h[i - 1]),dp[i-2] + abs(h[i] - h[i-2]));


  
   printf("%d\n",dp[n-1]);

}
//  [javascript]
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var h = o.l();
  var dp = [0];
  dp[1] = Math.abs(h[1] - h[0]);
  for(var i = 2; i < n; i++){
    var t1 = dp[i-2] + Math.abs(h[i] - h[i-2]);
    var t2 = dp[i-1] + Math.abs(h[i] - h[i-1]);
    dp[i] = t1 > t2 ? t2 : t1;
  }
  return dp[n-1];
}
//  [javascript]
'use strict'

const INF = 900719925474099 // Number.MAX_SAFE_INTEGER / 10;

function chmin(a,b){
	if(a < b) return a;
	return b;
}

function Main(input){
	let temp = input.trim().split('\n');
	let n = parseInt(temp[0]);
	let h = temp[1].split(' ').map((v)=>parseInt(v));

	let step = new Array(n+10).fill(INF);
	step[0]=0;
	for(let i=0;i<n;i++){
		step[i+1] = chmin(step[i+1],step[i] + Math.abs(h[i]-h[i+1]));
		step[i+2] = chmin(step[i+2],step[i] + Math.abs(h[i]-h[i+2]));
	}
	console.log(step[n-1]);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var slice []int
var dp []float64

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	slice = make([]int, n+3)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}

	dp = make([]float64, 100000000)
	for i := 0; i < len(dp); i++ {
		dp[i] = math.Inf(1)
	}

	dp[0] = 0.0
	for i := 1; i < n; i++ {
		chmin(&dp[i], dp[i-1]+float64(abs(slice[i]-slice[i-1])))
		if i > 1 {
			chmin(&dp[i], dp[i-2]+float64(abs(slice[i]-slice[i-2])))
		}
	}

	fmt.Println(int(dp[n-1]))

}

func abs(a int) int {
	if a < 0 {
		return -1 * a
	}

	return a
}

func chmin(a *float64, b float64) bool {
	if *a > b {
		*a = b
		return true
	}
	return false
}

func chmax(a *float64, b float64) bool {
	if *a < b {
		*a = b
		return true
	}
	return false
}
//  [go]
package main
import "fmt"
var n int
var A []int
func min(a, b int) int {
	if a < b { return a }
	return b
}
func abs(a int) int {
	if a < 0 { return -a }
	return a
}
func main() {
	_,e := fmt.Scanf("%d", &n)
	if e!= nil { return }
	if n<=1 {
		fmt.Println(0)
		return
	}
	A = make([]int, n+1)
	for i:=1; i<=n; i++ {
		_,e := fmt.Scanf("%d", &A[i])
		if e != nil { return }
	}
	if n == 2 {
		fmt.Println(abs(A[2]-A[1]))
		return
	}
	dp := make([]int, n+1)
	dp[1] = 0
	dp[2] = abs(A[2]-A[1])
	for i:=3; i<=n; i++ {
		dp[i] = min(dp[i-1] + abs(A[i] - A[i-1]), dp[i-2]+abs(A[i] - A[i-2]))
	}
	fmt.Println(dp[n])
}
//  [go]
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	var h, dp []int
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scanf("%d", &tmp)
		h = append(h, tmp)
	}
	for i := 0; i < n; i++ {
		dp = append(dp, math.MaxInt64)
	}
	dp[0], dp[1] = 0, abs(h[1]-h[0])
	for i := 2; i < n; i++ {
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
	}
	fmt.Println(dp[n-1])
}
func abs(in int) int {
	if in >= 0 {
		return in
	} else {
		return -in
	}
}
func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}
//  [ruby]
require "numo/narray"

n = gets.to_i
h = Numo::Int64.parse(gets).reshape!(nil)
dp = Numo::Int64.new(n+10).fill(Numo::Int64::MAX)
dp[0] = 0

n.times do |i|
  1.upto(2) do |j|
    next unless i + j < n
    cost = (h[i+j] - h[i]).abs
    if dp[i+j] > dp[i] + cost
      dp[i+j] = dp[i] + cost
    end
  end
end
pp dp[n-1]
//  [ruby]
ENV[Z='RUBY_THREAD_VM_STACK_SIZE']||exec({Z=>'50000000'},'ruby',$0)

N = gets.to_i
@hh = gets.chomp.split.map(&:to_i)

@dparr = Array.new(N)

def dp(to, cost)
  return cost if to == 0
  return @dparr[to] if @dparr[to]

  if to - 2 < 0
    @dparr[to] = dp(to - 1, cost) + (@hh[to] - @hh[to - 1]).abs
  else
    @dparr[to] = [dp(to - 1, cost) + (@hh[to] - @hh[to - 1]).abs, dp(to - 2, cost) + (@hh[to] - @hh[to - 2]).abs].min
  end
  return @dparr[to]
end

puts dp(N- 1, 0)
//  [rust]
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use num_traits::real::Real;
use std::ops::Bound;
use text_io::*;

fn main() {
    let n: usize = read!();
    let mut hs = vec![0; n * 2];
    for i in 0..n {
        let h: isize = read!();
        hs[i] = h;
    }
    
    const INF: isize = 1000000000000000;
    
    let mut dp = vec![INF; n * 2];
    dp[0] = 0;
    
    for i in 0..n {
        dp[i + 1] = dp[i + 1].min(dp[i] + (hs[i] - hs[i + 1]).abs());
        dp[i + 2] = dp[i + 2].min(dp[i] + (hs[i] - hs[i + 2]).abs());
    }
    
    println!("{}", dp[n - 1]);
}
//  [rust]
use std::cmp::*;
use std::io::*; //Not mine.
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main() {
    let n: usize = read();
    let h: Vec<i64> = (0..n).map(|_| read()).collect();
    let mut ans_list: Vec<i64> = vec![1145141919810; n];
    ans_list[0] = 0;
    for i in 1..n {
        ans_list[i] = min(ans_list[i], (h[i] - h[i - 1]).abs() + ans_list[i - 1]);
        if i >= 2 {
            ans_list[i] = min(ans_list[i], (h[i] - h[i - 2]).abs() + ans_list[i - 2]);
        }
    }
    println!("{}", ans_list[n - 1]);
}
//  [rust]
use std::cmp::min;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let v:Vec<i64> = (0..n).map(|_| read()).collect();

    let mut dp = vec![std::i64::MAX; n+2];
    dp[0] = 0;
    for i in 1..n {
        dp[i] = min(dp[i], dp[i-1] + (v[i] - v[i-1]).abs());
        if i > 1 {
            dp[i] = min(dp[i], dp[i-2] + (v[i] - v[i-2]).abs());
        }
    }
    println!("{}", dp[n-1]);
}
//  [swift]
/// Swift5 -> Swift2.2
extension String {
    // split(separator:maxSplits:omittingEmptySubsequences:)
    func split(separator separator: Character) -> [String] {
        return self.characters.split(separator).map(String.init)
    }
}
extension Array {
    // init(repeating:count:)
    init(repeating: Element, count: Int) {
       self.init(count: count, repeatedValue: repeating)
    }
}
/// end

let N = Int(readLine()!)!
let h = [0] + readLine()!.split(separator: " ").map { Int($0)! }
var dp = Array(repeating: 0, count: N + 1)

for i in 1 ... N {
    switch i {
    case 1:
        continue
    case 2:
        dp[i] = abs(h[i] - h[i - 1])
    default:
        // Avoid "expression was too complex to be solved in reasonable time"
        let step1 = dp[i - 1] + abs(h[i] - h[i - 1])
        let step2 = dp[i - 2] + abs(h[i] - h[i - 2])
        dp[i] = min(step1, step2)
    }
}

print(dp.last!)
//  [typescript]
const lines: string[] = [];
const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});
reader.on("line", function (line: string) {
  lines.push(line);
});

reader.on("close", function () {
  const inputSize = lines[0];

  //数字の配列
  const input = lines[1].split(" ").map(Number);

  const dp: any = [input.length];
  for (let i = 0; i < input.length; i++)
    dp[i] = {
      value: Infinity,
    };

  dp[0] = { value: 0 };

  for (let i = 1; i < dp.length; i++) {
    chmin(dp[i], { value: dp[i - 1].value + abs(input[i] - input[i - 1]) });
    if (i > 1)
      chmin(dp[i], { value: dp[i - 2].value + abs(input[i] - input[i - 2]) });
  }

  console.log(dp[Number(inputSize) - 1].value);
});

function chmin(a: any, b: any): boolean {
  if (a.value > b.value) {
    a.value = b.value;
    return true;
  }
  return false;
}

function chmax(a: any, b: any): boolean {
  if (a.value < b.value) {
    a = b;
    return true;
  }
  return false;
}

function abs(value: number) {
  return Math.abs(value);
}
//  [typescript]
const lines: string[] = [];
const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});
reader.on("line", function (line: string) {
  lines.push(line);
});

let dp: any;
let inputSize;

//数字の配列
let input: any = [];

reader.on("close", function () {
  inputSize = Number(lines[0]);
  input = lines[1].split(" ").map(Number);

  dp = input.map(() => {
    return Infinity;
  });

  dp[0] = 0;

  for (let i = 1; i < inputSize; i++) {
    if (i > 0) {
      dp[i] = Math.min(dp[i], dp[i - 1] + abs(input[i - 1] - input[i]));
    }
    if (i > 1) {
      dp[i] = Math.min(dp[i], dp[i - 2] + abs(input[i - 2] - input[i]));
    }
  }
  console.log(dp[inputSize - 1]);
});

function abs(val: number) {
  return val < 0 ? -val : val;
}
//  [typescript]
class AtCoder {
  // 入力系
  input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);
  input_i=-1;
  n(){
    this.input_i++;
    return Number(this.input[this.input_i]);
  }
  nn(n){
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.n());
    }
    return a;
  }
  s(){
    this.input_i++;
    return String(this.input[this.input_i]);
  }
  ss(n){
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.s());
    }
    return a;
  }

  // コンソール
  o(...a:any){
    console.log(...a);
  }

  // Math
  abs(a:number){
    return Math.abs(a);
  }
  min(...a:number[]){
    return Math.min(...a);
  }
  max(...a:number[]){
    return Math.max(...a);
  }
  floor(a:number){
    return Math.floor(a);
  }
  ceil(a:number){
    return Math.ceil(a);
  }
  round(a:number){
    return Math.round(a);
  }

  // ソート
  asc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return a-b});
  }
  desc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return b-a});
  }

  // 自作
  gcd(...arr):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=x;
    }
    return arr[arr.length-1];
  };
  lcm(...arr):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=arr[i]*arr[i+1]/x;
    }
    return arr[arr.length-1];
  };
  isPrime(n:number):boolean{
    if(n < 2) return false;
    const suq=Math.sqrt(n);
    for(let i=2;i<=suq;i++){
      if(n%i==0){
        return false;
      }
    }return true;
  };
  deduplicate(a:any[]):any[]{
    return Array.from(new Set(a));
  };
}

const o = new AtCoder()
let n=o.n(),arr=[],c=new Array(n)
for(let i=0;i<n;i++)arr.push(o.n())
let now=arr[0]
c[0] = 0;
c[1] = o.abs(arr[1] - arr[0]);
for(let i=1;i<n;i++){
  c[i+1] = o.min(c[i-1] + o.abs(arr[i+1] - arr[i-1]), c[i] + o.abs(arr[i+1] - arr[i]))
}
o.o(c[n-1])
//  [python]
from networkx import *
n,m = map(int, input().split())
if m == 0: print(1);exit()
G = Graph()
for i in range(m):
    a,b = map(int, input().split())
    G.add_edges_from([(a,b)])

print(len(max(connected_components(G), key=len)))
//  [python]
import sys
sys.setrecursionlimit(10 ** 9)
n, m = map(int, input().split())

friend = [set() for i in range(n)]

for i in range(m):
  a = list(map(int, input().split()))
  a.sort()
  x, y = a[0]-1,a[1]-1
  friend[x].add(y)
  friend[y].add(x)

def dfs(s):
  if vis[s] == False:
    vis[s] = True
    ary.append(s)
    for j in friend[s]:
      dfs(j)
vis = [False for i in range(n)]
ans = 0
for i in range(n):
  ary = []
  dfs(i)
  ans = max(ans,len(ary))
print (ans)
//  [python]
import networkx as nx
import sys

G = nx.Graph()

n, m = map(int, input().split())
if m == 0:
    print(1)
    sys.exit()
for i in range(m):
    a, b = map(int, input().split())
    G.add_edge(a, b)

largest_cc = max(nx.connected_components(G), key=len)
print(len(largest_cc))