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


if K > N:
    print(N)
    exit()

a = abs(N - K)
ans = N % a

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

### FIXED CODE ###

N, K = map(int, input().split())
tmp = N % K
print(min(tmp, abs(tmp - K)))
def calc_lcs(X, Y):
    from array import array
    max_lcs = 0
    m = len(X)
    n = len(Y)
    X = ' ' + X
    Y = ' ' + Y
    c = array('b', [0] * (1001 * 1001))
    for i in range(1, m+1):
        for j in range(1, n+1):
            if X[i] == Y[j]:
                c[i*1001 + j] = c[(i-1)*1001 + j - 1] + 1
            elif c[(i-1)*1001 + j] >= c[i*1001 + j - 1]:
                c[i*1001 + j] = c[(i-1)*1001 + j]
            else:
                c[i*1001 + j] = c[i*1001 + j - 1]
            max_lcs = max(max_lcs, c[i*1001 + j])
    return max_lcs


if __name__ == '__main__':
    # ??????????????\???
    num = int(input())
    # num = 1

    for _ in range(num):
        X = input()
        Y = input()
        # X = 'abcbdab'
        # Y = 'bdcaba'


        # ???????????????
        result = calc_lcs(X, Y)

        # ???????????¨???
        print(result)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_C

最長共通部分列
"""


c = []
def prep_array(X, Y):
    global c
    """ 値が0の2次元配列を用意する。サイズは入力データの最大値を想定して縦横(1000+1)以上必要。 """
    # from array import array
    # c = [array('I', [0] * (len(X)+1)) for _ in range(len(Y)+1)]  #  arrayで用意
    c = [[0]*(len(Y)+2) for _ in range(len(X)+2)] #  リストで用意
    return c


def check_max(array):
    """ 2次元配列の中の最大の値を返す """
    max_lcs = 0
    for row in array:
        temp_max = max(row)
        if temp_max > max_lcs:
            max_lcs = temp_max
    return max_lcs


def calc_lcs4(X, Y, c):
    """
    Y[j]のアクセス方法を変更
    リストの値を一旦変数に保存するように変更
    最長共通部分長を関数内で計算するように変更
    4/5 のテストデータを使用してプロファイリングすると実効時間は 5.6秒
    """
    X = ' ' + X
    Y = ' ' + Y
    m = len(X)
    n = len(Y)
    max_lcs = 0

    pre_row = c[0]
    for i in range(1, m):
        row = c[i]
        XX = X[i]
        for j, YY in enumerate(Y):
            if XX == YY:
                pr_j1 = pre_row[j - 1]
                row[j] = pr_j1 + 1
                if pr_j1+1 > max_lcs:
                   max_lcs = pr_j1 + 1
            else:
                pr_j = pre_row[j]
                r_j1 = row[j-1]
                if pr_j >= r_j1:
                    row[j] = pr_j
                else:
                    row[j] = r_j1
        pre_row = row
    return max_lcs


if __name__ == '__main__':
    # データの入力
    num = int(input())
    #f = open('input.txt')
    #num = int(f.readline())

    for _ in range(num):
        X = input().strip()
        Y = input().strip()

        # 処理の実行
        result = calc_lcs4(X, Y, prep_array(X, Y))

        # 結果の表示
        print(result)
N, L = map(int, input().split())

a = [input() for i in range(L)]

a.sort()

c = ''

for x in a:
    
    c = c+x
    

print(str(c))

### FIXED CODE ###

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

a = [input() for x in range(N)]

a.sort()

print(''.join(a))
N,K,X,Y = map(int, input().split())

result = 0
if N > K:
  result = K * X + (N - K) * Y
else:
  result = N * X

print(result)

### FIXED CODE ###

N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if(N<=K):
  print(X*N)
else:
  print(X*K+(N-K)*Y)
#abc056 b 
a,b,c=map(int,input().split())
num=[]
i=1
n=a
while True:
    n=n*i 
    x=n%b 
    if x not in num:
        num.append(x)
    else:
        break
if c in x:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

#abc056 b
a,b,c=map(int,input().split())
num=[]
i=1
n=a
while True:
    n=a*i
    x=n%b
    if x not in num:
        num.append(x)
    else:
        break
    i+=1

if c in num:
    print("YES")
else:
    print("NO")
def main():
    N = int(input())
    nums = [int(input()) for _ in range(N)]
    counter = 0
    loop = True
    while loop:
        for i, n in enumerate(nums):
            if n % 2 == 0:
                nums[i] = n / 2
            else:
                loop = False
                break
        if loop:
            counter += 1
    print(counter)


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    _ = int(input())
    nums = [int(i) for i in input().split()]
    # nums = map(int, input().split())
    counter = 0
    loop = True
    while loop:
        for i, n in enumerate(nums):
            if n % 2 == 0:
                nums[i] = n / 2
            else:
                loop = False
                break
        if loop:
            counter += 1
    print(counter)


if __name__ == '__main__':
    main()
x = int(input())
lst = list(map(int, input().split()))
i = 1
cnt = 0
a = lst[0]
while True:
    b = lst[i]
    if b < a:
        cnt += abs(b - a)
        a = a
    else:
        a = b
    if i == x - 1:
        break
    i += 1
print(cnt)

### FIXED CODE ###

x = int(input())
lst = list(map(int, input().split()))
i = 1
cnt = 0
a = lst[0]
if x == 1:
    print(0)
else:
    while True:
        b = lst[i]
        if b < a:
            cnt += abs(b - a)
            a = a
        else:
            a = b
        if i >= x - 1:
            break
        i += 1
    print(cnt)
import sys
input = sys.stdin.readline

import numpy as np

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

#2次元配列を作る
#[j][0]で数字の個数を、[j][1]で数字自体を取り出す
BC = []
for _ in range(M):
  BC.append(list(map(int, input().split())))

BC = np.array(BC)
BC = BC[BC[:,1].argsort()[::-1],:]


ans = 0
nowaindex = 0
for i, bc in enumerate(BC):
  #continueflagが0のままならループ全体を抜ける
  continueflag = 0
  b = bc[0]
  c = bc[1]
  for j in range(b):
    if A[nowaindex]<c:
      ans += c
      nowaindex += 1
      continueflag += 1
    else: break
  if continueflag == 0: break
    
print(ans + sum(A[nowaindex:]))

### FIXED CODE ###

import sys
input = sys.stdin.readline

import numpy as np

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

#2次元配列を作る
#[j][0]で数字の個数を、[j][1]で数字自体を取り出す
BC = []
for _ in range(M):
  BC.append(list(map(int, input().split())))

BC = np.array(BC)
BC = BC[BC[:,1].argsort()[::-1],:]


ans = 0
nowaindex = 0
for i, bc in enumerate(BC):
  #continueflagが0のままならループ全体を抜ける
  continueflag = 0
  b = bc[0]
  c = bc[1]
  for j in range(b):
    if A[nowaindex]<c:
      ans += c
      nowaindex += 1
      continueflag += 1
      if nowaindex > N-1:
        continueflag = 0
        break
    else: break
  if continueflag == 0: break
    
print(ans + sum(A[nowaindex:]))
import math
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
if max(a)==0:
  print(0)
  exit()
m=math.floor(math.log2(max(a)))+1
ans=0
for i in range(m):
  cnt0=0
  cnt1=0
  for j in range(n):
    if a[j]>>i&1:
      cnt1+=1
    else:
      cnt0+=1
  ans+=(2**i)*(cnt1*cnt0)
  ans%=mod
print(ans)

### FIXED CODE ###

import numpy as np
n=int(input())
a=np.array([int(i) for i in input().split()])
mod=int(1e9+7)
ans=0
for k in range(60):
  b=(a>>k)&1
  m=np.count_nonzero(b)
  ans+=m*(n-m)*2**k
  ans%=mod
print(ans)
a=list(map(int,input())).sort()
print("Yes") if max(a[2]==a[1]+a[0]) else print("No")

### FIXED CODE ###

a=list(map(int,input().split()))
a.sort()
print("Yes") if a[0]+a[1]==a[2] else print("No")
white = 0
black = 1
temp = []
def resolve(board, H, W):
    now = [0, 0]
    while now != [H-1, W-1]:
        now = check(board, now)
    return len(temp)
def check(board, now):
    if now[0] > len(board) -1 or board[now[0]+1][now[1]]==black:
        if now[1] > len(board[0]) -1 or board[now[0]][now[1]+1]==black:
            temp.append([now[0], now[1]+1])
            return [now[0], now[1]+1]
        else:
            return [now[0], now[1]+1]
    else:
        return [now[0]+1, now[1]]
def change(board, r0, c0, r1, c1):
    for r in range(r0, r1 + 1):
        for c in range(c0, c1 + 1):
            board[r][c] = 1 - board[r][c]
def main():
    H, W = map(int, input().split())
    board = [[white for i in range(W)] for j in range(H)]
    for i in range(H):
        s = input()
        for j in range(W):
            if s[j] == ".":
                board[i][j] = white
            else:
                board[i][j] = black
    n = resolve(board, H, W)
    print(n)
if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
def main():
    h, w = map(int, input().split())
    s = [input() for _ in range(h)]
    dp = [[10**5] * w for _ in range(h)]
    def func(temp, now, flag):
        x, y = now
        if y > h - 1 or x > w - 1:
            return 10**6
        if s[y][x] == "#":
            if not flag:
                temp += 1
            flag = True
        else:
            flag = False
        if x == w-1 and y == h-1:
            return temp
        if dp[y][x] <= temp:
            return 10**6
        dp[y][x] = temp
        piyo = []
        return min(func(temp, (x + 1, y), flag), func(temp, (x, y + 1), flag))
    print(func(0, (0, 0), False))
main()
from itertools import groupby

n,k = map(int,input().split())
s = input()

grouped = groupby(s)

res = []

if s[0] == '0':
	res.append((1,0))

for l,v in grouped:
	res.append( (l,len(list(v))) )

if s[len(s)-1] == '0':
	res.append((1,0))

now = 0
ans = 0
for i in range(2*k+1):
	now += res[i][1]

ans = max(ans,now)

for i in range(2*k+1,len(res),2):
	now -= res[i-2*k-1][1]
	now -= res[i-2*k][1]

	now += res[i][1]
	now += res[i+1][1]

	ans = max(ans,now)

print(ans)



### FIXED CODE ###

from itertools import groupby

n,k = map(int,input().split())
s = input()


grouped = groupby (s)
res = []

if s[0] == '0':
	res.append((1,0))

for l,v in grouped:
	res.append( (l,len(list(v))) )

if s[len(s)-1] == '0':
	res.append((1,0))

#for d in res:
	#print(d)

if len(res) <= 2*k + 1:
	ans = 0;
	for d in res:
		ans += d[1];

	print(ans)
	exit()

now = 0
ans = 0
for i in range(2*k+1):
	now += res[i][1]

ans = max(ans,now)

for i in range(2*k+1,len(res),2):
	now -= res[i-2*k-1][1]
	now -= res[i-2*k][1]

	now += res[i][1]
	now += res[i+1][1]

	ans = max(ans,now)

print(ans)
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split
     
a.sort()
b.sort()
c.sort()
     
     
from bisect import bisect_left,bisect_right
ans = 0
for i in b:
    count_a = bisect_right(a,i)
    count_c = n - bisect_right(c,i)
    ans += count_a * count_c
print(ans)

### FIXED CODE ###

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

a = sorted(a)
b = sorted(b)
c = sorted(c)

import bisect
count = 0
for i in b:
    a_count = bisect.bisect_left(a, i)
    c_count = n - bisect.bisect_right(c, i)
    count += a_count * c_count
    
print(count)
import math
a, b, c = map(float, input().split())
sqa = sqrt(a)
sqb = sqrt(b)
sqc = sqrt(c)
if sqa + sqb < sqc:
  print(Yes)
else:
  print(No)

### FIXED CODE ###

import math

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


if c-a-b > 0 and 4*a*b < (c-a-b)**2:
  print("Yes")
else:
  print("No")
N, M = list(map(int, input().split(' ')))
result_list = [input().split(' ') for i in range(M)]
AC_total = 0
WA_total = 0
ac_list = []
wa_dict = {}
for p, s in result_list:
    if p not in ac_list:
        if s == 'WA':
            if p in wa_dict:
                wa_dict[p] += 1
            else:
                wa_dict[p] = 1
        else:
            AC_total += 1
            WA_total += wa_dict[p]
            ac_list.append(p)
print('{} {}'.format(AC_total, WA_total))

### FIXED CODE ###

N, M = list(map(int, input().split(' ')))
AC_total = 0
WA_total = 0
ac_list = [False] * N
wa_list = [0] * N
for i in range(M):
    p, s = input().split(' ')
    p = int(p) - 1
    if not ac_list[p]:
        if s == 'WA':
            wa_list[p] += 1
        else:
            AC_total += 1
            WA_total += wa_list[p]
            ac_list[p] = True
print('{} {}'.format(AC_total, WA_total))
S = input()
T = input()
new = T + S
print(new)
#####################################

### FIXED CODE ###

string_1, string_2 = input("").split()
print(string_2+string_1)
# O(N*sqrt(A))
n,*a=map(int,open(0).read().split())
from collections import defaultdict, deque
import sympy

dd=defaultdict(set)

for q in a:
    dd[q]=set(sympy.divisors(q))
cnt=0
a.sort()
b=deque(a)
while b:
    p=b.pop()
    if len(dd[p]&set(b))==0:
        cnt+=1
print(cnt)


### FIXED CODE ###

n,*a=map(int,open(0).read().split())

ma=1001001
nums=[0]*ma

for i in a:
    nums[i]+=1
    if nums[i]==1: # 一回だけ出てきた場合
        for j in range(i+i,ma,i):
            nums[j]+=2
            
ans=nums.count(1)
print(ans)
import itertools
import sys
 
def readline():
    return sys.stdin.readline()
 
def read_int_list():
    return list(map(int, readline().split()))
 
def read_int():
    return int(readline())
 
def main():
    N, M, R = read_int_list()
 
    r = [a-1 for a in read_int_list()]
 
    d = [[float('inf')]*N for _ in range(N)]
 
    for _ in range(M):
        a, b, c = read_int_list()
        d[a-1][b-1] = c
        d[b-1][a-1] = c
 
    for a in range(N):
        d[a][a] = 0
 
    res = float('inf')
 
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if d[i][k]+d[k][j] < d[i][j]:
                    d[i][j] = dd
 
    for perm in itertools.permutations(r):
        a = 0
        for i in range(len(perm)-1):
            a += d[perm[i]][perm[i+1]]
        res = min(a, res)
 
    print(res)
 
if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import defaultdict
from itertools import permutations
import heapq

INF = float('inf')
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
memo = [[INF for _ in range(N)] for _ in range(N)]

Adj_list = defaultdict(set)

for i in range(M):
    a, b, c = map(int, input().split())
    if memo[a-1][b-1]:
        memo[a-1][b-1] = min(memo[a-1][b-1], c)
        
    Adj_list[a-1].add((b-1, memo[a-1][b-1]))
    Adj_list[b-1].add((a-1, memo[a-1][b-1]))


def dijkstra(x, vertex):
    d = [INF] * x
    d[vertex] = 0
    hq = [(0, vertex)]
    
    while hq:
        u = heapq.heappop(hq)[1]
        for (v, c) in Adj_list[u]:
            if d[v] > d[u] + c:
                d[v] = d[u] + c
                heapq.heappush(hq, (d[u]+c, v))

    return d

ans = INF
t_dis = 0

table = {}
for i in r:
    table[i-1] = dijkstra(N, i-1)

for each in permutations(r):
    t_dis = 0
    for i in range(R-1):
        t_dis += table[each[i]-1][each[i+1]-1]
    #print(each, t_dis)
    ans = min(ans, t_dis)

print(ans)
#まさかまたこの分けわからん式入れたらいいんか・・・？
A,B= map(int, input().split())

pai=int((3*A+P)//2)
print(pai)

### FIXED CODE ###

A,P= map(int, input().split())
print((3*A+P)//2)
input_tap = input()

for i in range(0,len(input_tap),2):
    if input_tap[i] == 'R' or input_tap[i] == 'U' or input_tap[i] == 'D':
        flag = 'Yes'
    elif input_tap[i+1] == 'R' or input_tap[i+1] == 'U' or input_tap[i+1] == 'D':
        flag = 'Yes'
    else:
        flag = 'No'
print(flag)


### FIXED CODE ###

input_tap = input()
flag = 'No'
input_tap1 = input_tap[0::2]
input_tap2 = input_tap[1::2]

if 'L' in input_tap1:
    flag = 'No'
elif 'R' in input_tap2:
    flag = 'No'
else:
    flag = 'Yes'
print(flag)
# coding: utf-8
 
w, h, N = list(map(int, input().split()))
 
rect = [0, w, 0, h]
for i in range(N):
    x, y, a = list(map(int, input().split()))
    if [1, -1][a % 2] * ([a > 2] - rect[a - 1]) < 0:
        rect[a - 1] = [x, y][a > 2]
 
length = lambda x: [x, 0][x < 0]
print(length(rect[1] - rect[0]) * length(rect[3] - rect[2]))

### FIXED CODE ###

# coding: utf-8

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

rect = [0, w, 0, h]
for i in range(N):
    x, y, a = list(map(int, input().split()))
    rect[a - 1] = (lambda c, r, p: [r, c][[c < r, c > r][p]])([x, y][a > 2], rect[a - 1], a % 2)

length = lambda x: [x, 0][x < 0]
print(length(rect[1] - rect[0]) * length(rect[3] - rect[2]))
n,x = map(int,input().split())
li = list(map(int,input().split()))

li2 = [i-x for i in li]
li3 = [abs(i) for i in li2]
a = min(li3)
flag = 1
b = li3[0]

import math

for i in li3:
    b = math.gcd(b,i)

print(b)


### FIXED CODE ###

n,x = map(int,input().split())
li = list(map(int,input().split()))

li2 = [i-x for i in li]
li3 = [abs(i) for i in li2]
b = li3[0]

def gcd(x,y):
    if x < y:
        x,y = y,x
    if y == 0:
        return x
    z = x % y
    return gcd(y,z)

for i in li3:
    b = gcd(b,i)

print(b)
A,B,C,D=map(int,input().split())
win=A/D
lose=C/B
if win=>lose:
  print("Yes")
else:
  if lose<=1:
    print("Yes")
  else:
    if lose-win<1 and A%D!=0:
      print("Yes")
    else:
      print("No")

### FIXED CODE ###


import math
A,B,C,D=map(int,input().split())
win=math.ceil(A/D)
lose=math.ceil(C/B)
if lose<=win:
  print("Yes")
else:
  print("No")
str = input()
if str = "A":
  print("T")
elif str = "T":
  print("A")
elif str = "C":
  print("G")
elif str = "G":
  print("C")

### FIXED CODE ###

str = input()
if str == "A":
  print("T")
elif str == "T":
  print("A")
elif str == "C":
  print("G")
elif str == "G":
  print("C")
import math
N, M = map(int, input().split())
tmp = [1]
if N == 1:
    print(M)
else:
    for i in range(2, math.ceil(M**0.5)):
        if M % i == 0:
            tmp.append(i)
            tmp.apend(M/i)
    ans = 1
    for x in tmp:
        if m / x >= N:
            ans = max(ans, x)
    print(ans)


### FIXED CODE ###

import math
N, M = map(int, input().split())
tmp = [1]
if N == 1:
    print(M)
else:
    for i in range(2, int(math.ceil(M**0.5))):
        if M % i == 0:
            tmp.append(i)
            tmp.append(int(M/i))
    ans = 1
    for x in tmp:
        if M / x >= N:
            ans = max(ans, x)
    print(ans)
from collections import Counter

S = input()
counter = Counter(S)
if len(counter) == 1:
    k = counter.keys()[0]
    if counter[k] > 1:
        print('NO')
    else:
        print('YES')
elif len(counter) == 2:
    print('NO')
else:
    # 通らない気がする
    print('YES')


### FIXED CODE ###

from collections import Counter

S = input()
counter = Counter(S)
if len(counter) == 1:
    k = list(counter.keys())[0]
    if counter[k] > 1:
        print('NO')
    else:
        print('YES')
elif len(counter) == 2:
    # a, b → OK
    # a, a, b, b → NG
    for k in counter.keys():
        if counter[k] != 1:
            print('NO')
            exit()
    print('YES')
else:
    # abcabcb → bacbacb OK
    # abbccc → cabc これのどこにcを追加してもNG
    # abcba → abcab OK
    # aabc → abca OK
    min_v = 10 ** 5
    max_v = 0
    for k in counter.keys():
        min_v = min(min_v, counter[k])
        max_v = max(max_v, counter[k])
    if max_v - min_v > 1:
        print('NO')
    else:
        print('YES')
A, B, C = map(int, input().split())
if A+B >= C:
  print('Yes')
else:
  print('No)

### FIXED CODE ###

A, B, C = map(int, input().split())
if A+B >= C:
  print('Yes')
else:
  print('No')
N = input()
L = map(int, input().split())

if N < 3:
    print(0)
    exit()

ans = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            arr = [L[i], L[j], L[k]]
            arr.sort()
            if (arr[0] != arr[1] & arr[1] != arr[2]):
                if (arr[2] < arr[0] + arr[1]):
                    ans = ans + 1

print(ans)


### FIXED CODE ###

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

if N < 3:
    print(0)
    exit()

ans = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            arr = [L[i], L[j], L[k]]
            arr.sort()
            if (arr[0] != arr[1] & arr[1] != arr[2]):
                if (arr[2] < arr[0] + arr[1]):
                    ans = ans + 1

print(ans)
from fractions import gcd

n, m = map(int, input().split())

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

ans = -1
b = [0] * n
for i in range(n):
    if a[i] % 2 != 0:
        print(0)
        exit()

    else:
        b[i] = a[i] // 2


    if i == 0:
        num = format(a[i], 'b')[::-1].find('1')

    else:
        if format(a[i], 'b')[::-1].find('1') != num:

            print(0)
            exit()
        else: num = format(a[i], 'b')[::-1].find('1')




bs = b[0]
for i in range(1,n):
    bs *= b[i]
g = bs // gcd(*b)

if g > m:
    print(0)
    exit()

ans = 1
g1 = g
while 1:
    g += 2*g1
    if g > m:
        break
    else:
        ans += 1

print(ans)

### FIXED CODE ###

from fractions import gcd
n, m = map(int, input().split())

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

ans = -1
b = [0] * n
for i in range(n):
    if a[i] % 2 != 0:
        ans = 0
        break

    else:
        b[i] = a[i] // 2


    if i == 0:
        num = format(a[i], 'b')[::-1].find('1')

    else:
        if format(a[i], 'b')[::-1].find('1') != num:
            ans = 0
            break
        else:
            num = format(a[i], 'b')[::-1].find('1')


if ans != 0:
    g = b[0]
    for i in range(1,n):

        g = (g*b[i]) // gcd(b[i],g)

    if g > m: ans = 0
    else:
        ans = (1 + (m-g)//(2*g))

print(ans)
def dp_func(n,dp,h):
    dp[0]=0
    dp[1]=abs(h[1]-h[0])

    if n==0:
        return 0
    elif n==1:
        return dp[1]
    
    else:
        if dp[n-1]==-1:
            dp[n-1]=dp_func(n-1,dp,h)

        c1=dp[n-1]+abs(h[n]-h[n-1])

        if dp[n-2]==-1:
            dp[n-2]=dp_func(n-2,dp,h)
            
        c2=dp[n-2]+abs(h[n]-h[n-2])
        
        dp[n]=min(c1,c2)
        return dp[n]

def main():
    #input
    N=int(input())
    h=list(map(int,input().strip().split()))

    dp=[-1 for n in range(N)]

    return dp_func(N-1,dp,h)

if __name__=="__main__":
    print(main())


### FIXED CODE ###

import sys
sys.setrecursionlimit(200000)

def dp_func(n,dp,h):
    if n==0:
        return 0
    elif n==1:
        return dp[1]
    
    else:
        if dp[n-1]==-1:
            dp[n-1]=dp_func(n-1,dp,h)

        c1=dp[n-1]+abs(h[n]-h[n-1])

        if dp[n-2]==-1:
            dp[n-2]=dp_func(n-2,dp,h)
            
        c2=dp[n-2]+abs(h[n]-h[n-2])
        
        dp[n]=min(c1,c2)
        return dp[n]

def main():
    #input
    N=int(input())
    h=list(map(int,input().strip().split()))
    # N=10000
    # h=[n**2 for n in range(N)]

    dp=[-1 for n in range(N)]
    dp[0]=0
    dp[1]=abs(h[1]-h[0])

    return dp_func(N-1,dp,h)

if __name__=="__main__":
    print(main())
import statistics
while 0!=int(input()):
	s = list(map(int, input().split()))
	print(stdev(s))

### FIXED CODE ###

import math
while True:
	n = int(input())
	if n==0: break
	s = list(map(float, input().split()))
	t = sum(s)
	a = t / n
	b = sum(map(lambda x: (x-a)**2, s))
	print(math.sqrt(b/n))
N = int(input())
Node = [[] for i in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    Node[a].append(b)
    Node[b].append(a)


Route = [1]
def dfs(n, np):
    for nc in Node[n]:
        if nc == np:
            continue
        elif nc == N:
            Route.append(N)
            return True
        else:
            Route.append(nc)
            if dfs(nc, n):
                return True
            else:
                Route.pop()
    return False

dfs(1, 0)
b = (len(Route)+1)//2
Node[Route[b-1]].remove(Route[b])
Node[Route[b]].remove(Route[b-1])

cnt = 0
def dfs2(n, np):
    global cnt
    for nc in Node[n]:
        if nc == np:
            continue
        else:
            cnt += 1
            dfs2(nc, n)

dfs2(1, 0)
cnt = -cnt
dfs2(N, 0)
if cnt >= 0:
    print("Snuke")
else:
    print("Fennec")


### FIXED CODE ###

import sys
sys.setrecursionlimit(500000)
N = int(input())
Node = [[] for i in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    Node[a].append(b)
    Node[b].append(a)
Route = [1]
def dfs(n, np):
    for nc in Node[n]:
        if nc == np:
            continue
        elif nc == N:
            Route.append(N)
            return True
        else:
            Route.append(nc)
            if dfs(nc, n):
                return True
            else:
                Route.pop()
    return False

dfs(1, 0)
b = (len(Route)+1)//2
Node[Route[b-1]].remove(Route[b])
Node[Route[b]].remove(Route[b-1])

cnt = 0
def dfs2(n, np):
    global cnt
    for nc in Node[n]:
        if nc == np:
            continue
        else:
            cnt += 1
            dfs2(nc, n)

dfs2(1, 0)
cnt = -cnt
dfs2(N, 0)
if cnt >= 0:
    print("Snuke")
else:
    print("Fennec")