Harryxun/stf_run huggingface dataset:
n=int(input())
p=map(int, input().split())
q=map(int, input().split())

import math

a=0
for i in range(n-1):
  a +=(p[i]-1) * math.factorial(n-1-i)
  
b=0
for i in range(n-1):
  b +=(p[i]-1) * math.factorial(n-1-i)
  
print( abs(a-b) )


### FIXED CODE ###

from itertools import permutations
n=int(input())
v=list(permutations(range(1,n+1),n))
print(abs(v.index(tuple(map(int,input().split())))-v.index(tuple(map(int,input().split())))))
a=input()
if a="Sunny":
  print("Cloudy")
elif a="Cloudy":
  print("Rainy")
else:
  print("Sunny")
  

### FIXED CODE ###

a=input()
if a=="Sunny":
  print("Cloudy")
elif a=="Cloudy":
  print("Rainy")
else:
  print("Sunny")
n, x = map(int, input().split())
m = [int(input()) for i in range(n)]
ans, x = n, x - sum(m)
while (x - min(m) >= 0):
    x, ans -= min(m), ans + 1
print(ans)


### FIXED CODE ###

n, x = map(int, input().split())
m = [int(input()) for i in range(n)]
ans, x = n, x - sum(m)
while (x - min(m) >= 0):
    x -= min(m)
    ans += 1
print(ans)
a,b = map(int,input().split)
print(a+b//2)

### FIXED CODE ###

a,b = map(int,input().split())
print(a+b//2)
from functools import reduce
from math import gcd

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

c=max(A)+1
D=[0]*c
div=[0]*c
P=[]

for i in range(2,c):
    if D[i]==0:
        P.append(i)
        D[i]=i
    for j in P:
        if i*j>=c  or j>D[i] :
           break
        D[i*j]=j

for i in A:
    if i==1:
        continue
    temp=i
    while temp!=1:
        div[D[temp]]+=1
        temp2=D[temp]
        while temp%temp2==0 and temp>=temp2:
            temp=temp//temp2


if max(div)<=1:
    print('pairwise coprime')
    hoge

elif reduce(gcd, A) == 1:
    print('setwise coprime')

else:
    print('not coprime')

### FIXED CODE ###

from functools import reduce
from math import gcd

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

c=max(A)+1
D=[0]*c
div=[0]*c
P=[]

for i in range(2,c):
    if D[i]==0:
        P.append(i)
        D[i]=i
    for j in P:
        if i*j>=c  or j>D[i] :
           break
        D[i*j]=j
f=0
for i in A:
    if i==1:
        continue
    temp=i
    while temp!=1:
        if div[D[temp]]==1:
            f=1
            break
        div[D[temp]]+=1
        temp2=D[temp]
        while temp%temp2==0 and temp>=temp2:
            temp=temp//temp2
    if f==1:
        break
        


if max(div)<=1 and f==0:
    print('pairwise coprime')

elif reduce(gcd, A) == 1:
    print('setwise coprime')

else:
    print('not coprime')
if A>=0 and A<=5:
  print(0);
elif A>5 and A<=12:
  print(B/2);
else:
  print(B);

### FIXED CODE ###

read=input();
A,B=read.split(' ')
A=int(A)
B=int(B)
if A>12:
  print(B);
elif A>5:
  print(int(B/2));
else:
  print(0);
n , k = [ (int) i for i in input().split()]
s =input()
a =0
for i , ch in enumerate(s[1:] , 1):
  if ch == s[i-1]:
   	a+=1
print( min( n -1, a +2*k))


### FIXED CODE ###

n , k = [ int(i) for i in input().split()]
s =input()
a =0
for i , ch in enumerate(s[1:] , 1):
  if ch == s[i-1]:
   	a+=1
print( min( n -1, a +2*k))
import math
tate =int(input())
yoko=int(input())
arr = [i+1 for i in range(tate)]
for j in range(yoko):
    rep1,rep2=input().split();
    rep1=int(rep1)-1
    rep2=int(rep2)-1
    arr[rep1],arr[rep2] = arr[rep2],arr[rep1]

for k in range(tate):
    print(arr[k])


### FIXED CODE ###

tate =int(input())
yoko=int(input())
arr = [i+1 for i in range(tate)]
for j in range(yoko):
    rep1,rep2=input().split(",")
    rep1=int(rep1)-1
    rep2=int(rep2)-1
    arr[rep1],arr[rep2] = arr[rep2],arr[rep1]

for k in range(tate):
    print(arr[k])
A,B,H,M = list(map(int,input().split()))

import math
#得られる三角形の中心の角度を求める

H_rad = 2*math.pi()/12*H
M_rad = 2*math.pi()/60*M
rad = abs(H_rad - M_rad)

#二項定理
C = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(rad))
print(C)

### FIXED CODE ###

A,B,H,M = list(map(int,input().split()))

import math
#得られる三角形の中心の角度を求める
M_rad = (2*math.pi/60)*M
H_rad = (2*math.pi/12)*(H + 1/60*M)
rad = abs(H_rad - M_rad)

#三角形が成立する条件
#長針と短針が被ったとき
if math.degrees(M_rad)-0.1 < math.degrees(H_rad) < math.degrees(M_rad)+0.1:
  print(abs(A-B))
  exit()
#長針と短針が180度の時
elif 180-0.1 < math.degrees(rad) < 180+0.1:
  print(abs(A+B))
  exit()
else:
  #二項定理
  C = math.sqrt(abs(A*A + B*B - 2*A*B*math.cos(rad)))
  print(abs(C))
import sys
S = input()
a = "Sunny"
b = 'Cloudy'
c = 'Rainy'
if S == a:
    print(b)
elif S == b:
        print(c)
elif S == b:
        print(a)
else:
    sys.exit()
sys.exit()

### FIXED CODE ###

import sys
S = input()
a = "Sunny"
b = 'Cloudy'
c = 'Rainy'
if S == a:
    print(b)
elif S == b:
        print(c)
elif S == c:
        print(a)
else:
    sys.exit()
sys.exit()
S = input()
K = int(input())
L=set()
for i in range(5):
    for j in range(len(S)-i):
        L.add((S[j:j+i+1]))
L = sorted(list(L))
print(L[K-1])

### FIXED CODE ###

X = int(input())
L=[]
for i in range(2,11):
    for j in range(1001):
        if j**i > 1000:
            break
        if  j**i not  in L:
            L.append(j**i)
L=sorted(L)

if  X not in L:
    L.append(X)
    L=sorted(L)
    n = L.index(X)
    print(L[n-1])
else:
    print(X)
aaaa

### FIXED CODE ###

x,y = map(int,input().split())

result = x * y

if (result % 2) == 0 :
    print('Even')
else:
    print('Odd')
import itertools

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

even = [i for i in range(2, 100, 2)]

odd = [i for i in range(1, 100, 2)]


seq = []


for i in range(n):
    seq.append(even[i])

for i in range(m):
    seq.append(odd[i])



cnt = 0

for v1, v2 in itertools.combinations(seq,2):
    tmp = int(v1) + int(v2)
    if tmp % 2 == 0:
        cnt += 1

print(cnt)


### FIXED CODE ###

import itertools

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

even = [i for i in range(2, 333, 2)]

odd = [i for i in range(1, 333, 2)]


seq = []


for i in range(n):
    seq.append(even[i])

for i in range(m):
    seq.append(odd[i])



cnt = 0

for v1, v2 in itertools.combinations(seq,2):
    tmp = int(v1) + int(v2)
    if tmp % 2 == 0:
        cnt += 1

print(cnt)
#おかしの問題
n,m = int(input().split())
number = list(int(input().split()))
a = []
#ここから書きかえ
for i in range(n):
    for j in range(n-i):
            b=[]
            for k range(n):
                b.append(number[j+k+1])
            if sum(b)%m == 0:
                a.append(1)
            else:
                pass
print(len(a))

#








### FIXED CODE ###

n,m = map(int,input().split())
a = list(map(int,input().split()))
check = {};ios = [a[0]%m]*n
for i in range(n-1):
    ios[i+1] = (a[i+1] + ios[i])%m
    check[ios[i]] = 0
check[ios[n-1]] = 0
for i in range(len(ios)):
    check[ios[i]%m] += 1
ans = 0
for i in range(n):
    num = check[ios[i]];check[ios[i]] = 'finish'
    if num == 'finish':continue
    if ios[i] % m == 0:ans += num
    ans += (num * (num - 1))//2
print(ans)
a,b,c=map(int,input().split())
d=[]
d.append(a)
d.append(b)
d.append(c)
d.sort()
if a[0]+a[1]==a[2]:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

a,b,c=sorted(map(int,input().split()))
if a+b==c:
  print('Yes')
else:
  print('No')
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
c = [1] * N
s = [C[P[i]-1] for i in range(N+1)]
m = [[0] * (N+1) for i in range(N)]
for i in range(N):
    m[i][1] = (C[P[i]-1])
for i in range(N):
    j = i
    while P[j]-1 != i:
        j = P[j]-1
        c[i] += 1
        s[i] += C[P[j]-1]
        if  c[i] <= K:
            if s[i] > m[i][c[i]-1]:
                m[i][c[i]] = s[i]
            else:
                m[i][c[i]] = m[i][c[i]-1]
ans = min(C)
for i in range(N):
    if s[i] > 0:
        if  s[i] * (K//c[i]) + m[i][K%c[i]] > ans:
            ans = s[i] * (K//c[i]) + m[i][K%c[i]]
    else:
        if max(m[i][1:min(c[i],K+1)]) > ans:
            ans = max(m[i][1:min(c[i],K+1)])
print(ans)


### FIXED CODE ###

N, K = map(int, input().split())
P, C = [list(map(int, input().split())) for _ in range(2)]
c = [1] * N
m = [[0] * (N+1) for i in range(N)]
for i in range(N):
    m[i][1] = (C[P[i]-1])
ans = max(C)
for i in range(N):
    j = i
    while P[j]-1 != i:
        j = P[j]-1
        c[i] += 1
        m[i][c[i]] = m[i][c[i]-1] + C[P[j]-1]
    if m[i][c[i]] > 0:
        ans = max(ans, m[i][c[i]] * (K//c[i]-1) + max(m[i] + [m[i][c[i]] + m[i][j+1] for j in range(K%c[i])]))
    else:
        ans = max(ans, max(m[i][1:min(c[i],K)+1]))
print(ans)
a=int(input())
b=int(input())
Z=list[1,2,3]
X=Z.remove(a,b)

print(X)

### FIXED CODE ###

a=int(input())
b=int(input())
Z=[1,2,3]
Z.remove(a)
Z.remove(b)

print(Z[0])
letters = eval(input("Enter: "))
for i in letters:
	print(["Yes" if i[2]==i[3] and i[4]==i[5] else "No"])

### FIXED CODE ###

l = input()
print("Yes" if (l[2]==l[3] and l[4]==l[5]) else "No")
h, n = map(int, input().split())
a = []
b = []
for _ in range(n):
    ai, bi = map(int, input().split())
    a.append(ai)
    b.append(bi)
 
dp = [float("inf")] * (2 * 10000 + 1)
dp[0] = 0
for i in range(h):
    for j in range(n):
        if (i + a[j]) > 2 * 10000:
            dp[2 * 10000] = min(dp[2 * 10000], dp[i] + b[j])
            continue
        dp[i + a[j]] = min(dp[i + a[j]], dp[i] + b[j])
 
ans = float('inf')
for j in range(h, 2 * 10000 + 1):
    ans = min(ans, dp[j])
print(ans)

### FIXED CODE ###

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

if h%a:
       print(h//a+1)
else:
       print(h//a)
N = int(input())
V = list(map(int, input().split()))
alist = []
tmp = 0
i = 0

def cook(N, V, alist, tmp, i):
    if N = 1:
        print(V[0])
    
    else:
        V.sort()
        while i < N:
            if i + 1 > N - 1:
                alist.append(V[i])
                
            else:
                tmp = (V[i] + V[i +1]) / 2
                alist.append(tmp)
                
                i += 2
            
        N = len(alist)
        V = alist
        alist = []
        tmp = 0
        i = 0
        cook(N, V, alist, tmp, i)
        
cook(N, V, alist, tmp, i)

### FIXED CODE ###

N = int(input())
v = list(map(float, input().split()))

v.sort()

r = v[0]

for i in v[1::]:
    r = (r + i) / 2

print(r)
N, M = map(int, input().split())
a = 0
b = 0
sp = dict()
correct = []
wrong = dict()
for _ in range(M):
    s, p = input().split()
    if not s in sp.keys():
        if p == "AC":
            a +=1
            correct.append(s)
        else:
            wrong[s] = 1
        sp[s] = p
    else:
        if sp[s] == "AC":
            continue
        else:
            if p == "AC":
                a += 1
                correct.append(s)
            else:
                wrong[s] = 1
            sp[s] = p
for c in set(correct):
    b += wrong[c]
print(a, b)

### FIXED CODE ###

N, M = map(int, input().split())
a = 0
b = 0
sp = dict()
for _ in range(M):
    s, p = input().split()
    if int(s) not in sp.keys():
        sp[int(s)] = [p]
    else:
        sp[int(s)].append(p)
        
a = 0
b = 0
for i, result in sp.items():
    if "AC" in result:
        a += 1
        b += result.index("AC")
    else:
        continue
print(a, b)
x = int(input)
print x**3

### FIXED CODE ###

x = int(input())
print (x ** 3)
s=input()
for i in range(len(s)):
    s[i]="x"
print(s)

### FIXED CODE ###

s=input()
print("x"*len(s))
H , A = input().split()
H , A = int(H), int(A)
answer = H // A
if H % A == 0:
    print(answer)
else:
    print(anser + 1)

### FIXED CODE ###

H , A = input().split()
H , A = int(H), int(A)
answer = H // A
if H % A == 0:
    print(answer)
else:
    print(answer + 1)
import math
a, b = map(int,input().split())
e = 10**-7
mi = max(math.ceil(a*12.5),b*10)
ma = min(int((a-1)+*12.5),b*10-1)
if mi > ma:
    print(-1)
else:
    print(mi)


### FIXED CODE ###

import math
a, b = map(int,input().split())
e = 10**-7
mi = max(math.ceil(a*12.5),b*10)
ma = min(int(math.ceil((a+1)*12.5)-1),(b+1)*10-1)
if mi > ma:
    print(-1)
else:
    print(mi)
import math
import functools

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

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

l = []
for i in range(n):
    l.append(abs(xi[i] - x))

ans = functools.reduce(math.gcd, l)

print(ans)


### FIXED CODE ###

import fractions
import functools

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

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

l = []
for i in range(n):
    l.append(abs(xi[i] - x))

ans = functools.reduce(fractions.gcd, l)

print(ans)
N*(N-1)*(N-2)

### FIXED CODE ###

N=int(input())
print(N*N*N)
#文字列の入力
S_list = list(input())

#最後の文字はD
if(S_list[len(S_list)-1] == "?"):
  S_list[len(S_list)-1] = "D"
  print("1",S_list)

for i in range(len(S_list)-1):
  if(S_list[i] == "?"):
    if(S_list[i+1] == "D"):
      S_list[i] = "P"
      print("2",S_list)
    elif(S_list[i+1] == "?"):
      S_list[i] = "D"
      S_list[i+1] = "D"
      print("3",S_list)
    else:
      S_list[i] = "D"
      print("4",S_list)

print(*S_list, sep="")



### FIXED CODE ###

#文字列の入力
S_list = list(input())

for i in range(len(S_list)):
  if(S_list[i] == "?"):
    S_list[i] = "D"
      
print(*S_list, sep="")
import math
# from scipy.special import factorial, poch
ppp=10**9+7
x,y =map(int, input().split())
a=[-(x-2*y)//3,-(-2*x+y)//3]
b=[-(x-2*y)%3,-(-2*x+y)%3]
if b[0]==0 and b[1]==0:
    print(math.factorial(a[0]+a[1])//math.factorial(a[0])//math.factorial(a[1])%ppp)
    
else:
    print(0)

### FIXED CODE ###

X,Y = map(int, input().split())

mod=10 ** 9 + 7
def binomial(n,k):
    x=1
    y=1
    for i in range(k):
        x=x*(n-i)%mod
        y=y*(i+1)%mod
    return x*pow(y,mod-2,mod)%mod

if (2*X-Y)%3==0 and  (2*Y-X)%3==0:
    a=(2*X-Y)//3
    b=(2*Y-X)//3
    if a<0 or b<0:
        print(0)        
    else:
        print(binomial(a+b,a)%mod)
else:
    print(0)
def PrimeNumber(N):
    ans = list(range(2, N + 1))
    i = 0
    while ans[i] < N ** 0.5 + 1:
        j = 2
        temp = ans[i]
        while temp * j <= ans[-1]:
            if temp * j in ans:
                ans.remove(temp * j)
            j += 1
        i += 1
    return ans


N=int(input())

PN=PrimeNumber(N)
c=[0]*(N+1)

for i in range(2,N+1):
    temp=i
    for j in PN:
        if j>i:
            break
        while temp>=j:
            if temp%j==0:
                c[j]+=1
                temp=temp//j
            else:
                break

ans=1
for i in PN:
    ans*=(c[i]+1)
    ans%=(10**9+7)

print(ans)

### FIXED CODE ###

def PrimeNumber(N):
    if N==2:
        ans=[2]
        return ans
    ans = list(range(2, N + 1))
    i = 0
    while ans[i] < N ** 0.5 + 1:
        j = 2
        temp = ans[i]
        while temp * j <= ans[-1]:
            if temp * j in ans:
                ans.remove(temp * j)
            j += 1
        i += 1
    return ans

N=int(input())

if N==1:
    print(1)
    exit()

mod=10**9+7
PN=PrimeNumber(N)
P=[0]*(N+1)

for i in range(2,N+1):
    temp=i
    for j in PN:
        if temp<j:
            break
        cnt=0
        while temp%j==0:
            cnt+=1
            temp=temp//j
        P[j]+=cnt

ans=1

for i in range(1,N+1):
    if P[i]!=0:
        ans=(ans*(P[i]+1))%mod
print(ans)
import numpy as np
import sys

mod = 10 ** 9 + 7

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

if N == K:
    print(numpy.cumprod(A))
    sys.exit()

plus = A[A>=0]
minus = A[A<0]

if len(minus) == N:
    np.sort(minus)[::-1]
    print(numpy.cumprod(A[:K]))
    sys.exit()

print(0)
sys.exit()

ans = 1
flag = 0
if K % 2 == 1:
    flag = 1
    K -= 1
    ans *= plus[0]

n_plus = [(plus[i+flag] * plus[i+flag+1]) % mod for i in range((len(plus)-flag)//2)]
n_minus = [(minus[i] * minus[i+1]) % mod for i in range(len(minus)//2)]

p = 0
m = 0
for i in range(K//2):
    if p == len(n_plus):
        ans *= n_minus[m]
        ans %= mod
        m += 1
    elif m == len(n_minus):
        ans *= n_plus[p]
        ans %= mod
        p += 1
    elif n_plus[p] > n_minus[m]:
        ans *= n_plus[p]
        ans %= mod
        p += 1
    else:
        ans *= n_minus[m]
        ans %= mod
        m += 1

print(ans)

### FIXED CODE ###

import sys

mod = 10 ** 9 + 7

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

A.sort(reverse = True)

if A[0] < 0 and K % 2 == 1:
    ans = 1
    for i in range(K):
        ans *= A[i]
        ans %= mod
    print(ans)
    sys.exit()

l = 0
r = N-1

ans = 1
if K % 2 == 1:
    ans *= A[0]
    l += 1

for _ in range(K // 2):
    if A[l] * A[l+1] > A[r] * A[r-1]:
        ans *= A[l] * A[l+1]
        ans %= mod
        l += 2
    else:
        ans *= A[r] * A[r-1]
        ans %= mod
        r -= 2

print(ans)
A = int(input("A"))
B = int(input("B"))
C = int(input("C"))

if A >= B + C:
    print(0)
else:
    print((B + C) - A)

### FIXED CODE ###

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

if A >= B + C:
    print(0)
else:
    print(B + C - A)
N = input()
A = input()

rest = N % A
if rest <= A:
	print "Yes"
else:
	print "No"


### FIXED CODE ###

N = input()
A = input()

rest = N % 500
if rest <= A:
	print "Yes"
else:
	print "No"
chr = input().split(" 0 ")
print(chr)
a = (int(chr[1])-int(chr[0]))*60 - int(chr[-1])
print(a)

### FIXED CODE ###

chr = input().split()
a = (int(chr[2]) - int(chr[0]))*60 + (int(chr[3]) - int(chr[1])) - int(chr[-1])
print(a)
a, b, c = map(int, input().split())

import math
if math.log((c-a-b)/2) - math.log(a*b)/2 > 0:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

a, b, c = map(int, input().split())
if c-a-b < 0:
  print('No')
elif (c-a-b)**2 > 4*a*b:
  print('Yes')
else:
  print('No')
import sys
sys.setrecursionlimit(10**9)

n, m = map(int, input().split())
root = [-1] * n

def find_root(x):
    if root[x] < 0:
        return x
    else:
        root[x] == find_root(root[x])
        return root[x]

def unite(x, y):
    x = find_root(x)  
    y = find_root(y)
    if x == y:
        return
    root[x] += root[y]
    root[y] = x

def size(x):
    x = find_root(x)
    return -root[x]

for i in range(m):
    x, y = map(int,input().split())
    x -= 1
    y -= 1
    unite(x, y)

max_size = max(map(size, range(n)))

print(max_size)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

n, m = map(int, input().split())
root = [-1] * n

def find_root(x):
    if root[x] < 0:
        return x
    else:
        root[x] = find_root(root[x])
        return root[x]

def unite(x, y):
    x = find_root(x)  
    y = find_root(y)
    if x == y:
        return
    root[x] += root[y]
    root[y] = x

def size(x):
    x = find_root(x)
    return -root[x]

for i in range(m):
    x, y = map(int,input().split())
    x -= 1
    y -= 1
    unite(x, y)

max_size = max(map(size, range(n)))

print(max_size)
def getdigit(N):
  cnt = 0
  while(N>0):
    cnt++
    N //= 10
  return cnt

N = int(input())
for i in reversed(range(1,sqrt(N)+1)):
  if(N % i == 0):
    print(max(getdigit(i), getdigit(N/i)))
    exit()
          
  


### FIXED CODE ###

def getdigit(N):
  cnt = 0
  while(N>0):
    cnt += 1
    N //= 10
  return cnt

N = int(input())
for i in reversed(range(1,int(pow(N, 1/2))+1)):
  if(N % i == 0):
    print(max(getdigit(i), getdigit(N/i)))
    exit()
N = int(input())
a = list(map(int,input().split()))

def ave(c1,c2):
  av = (c1 + c2)/2
  return av

for i in range(N-1):
  for j in range(i+1,N):
    if a[j] <= a[i]:
      tmp = a[i]
      a[i] = a[j]
      a[j] =tmp
print(a)

for i in range(N-1):
  average = ave(a[0],a[1])
  a.pop(0)
  a.pop(0)
  a.insert(0,average)

print(int(a[0]))



### FIXED CODE ###

N = int(input())
s = input()
 
if N >= 3200:
  print(s)
else:
  print('red')
x,y = map(raw_input().split())
x = int(x,16)
y = int(y,16)
if x>y :
	print ">"
elif x<y :
	print "<"
else :
	print"="

### FIXED CODE ###

x,y = map(str,raw_input().split())
x = int(x,16)
y = int(y,16)
if x>y:
	print ">"
elif x<y:
	print "<"
else:
	print "="
def cost(h, length):
    if length == 1:
        return 0
    elif length == 2:
        return abs(h[1] - h[0])
    else:
        variants = [cost(h, length - 1) + abs(h[length - 1] - h[length - 2]), cost(h, length - 2) + abs(h[length - 1] - h[length - 3])]
        return min(variants)

n = int(input()) # n >= 2
h = list(map(int, input().split())) # h_i >= 1
print(cost(h, n))

### FIXED CODE ###

n = int(input()) # n >= 2
h = list(map(int, input().split())) # h_i >= 1

cost2 = 0;
cost1 = abs(h[1] - h[0]);

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

print(cost1)
n, k = map(int, input().split())

def gcd(a, b):
    if a % b == 0:
        return b
    return gcd(b, a % b)

cnt = gcd(n, k)

if n == 1 or k == 1:
    print(0)
else:
    a = max((n % k, k % n))
    print(min(a, gcd(n, k)))


### FIXED CODE ###

n, k = map(int, input().split())
print(min(k - n % k, n % k))
n,m=map(int,input().split())

a=[1,1]
for i in range(2,10001):
    a.append((a[i-1]+a[i-2])%1000000007)

bad=[]
for i in range(m):
    bad.append(int(input()))
num=[]
before=0
bad_flag=0

if m!=0:
    for i in range(len(bad)):
        nxt=bad[i]-before-1
        if nxt==-1:
            bad_flag=1
            break
        num.append(nxt)
        before=bad[i]+1
    num.append(n-bad[len(bad)-1]-1)
else:
    num.append(n)
if bad_flag:
    print(0)
else:
    ans=0
    last=1
    for i in num:
        ans=a[i]*last
        last=ans%1000000007
    print(last)

### FIXED CODE ###

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

a=[1,1]
for i in range(2,100001):
    a.append((a[i-1]+a[i-2])%1000000007)

bad=[]
for i in range(m):
    bad.append(int(input()))
num=[]
before=0
bad_flag=0

if m!=0:
    for i in range(len(bad)):
        nxt=bad[i]-before-1
        if nxt==-1:
            bad_flag=1
            break
        num.append(nxt)
        before=bad[i]+1
    num.append(n-bad[len(bad)-1]-1)
else:
    num.append(n)
if bad_flag:
    print(0)
else:
    ans=0
    last=1
    for i in num:
        ans=a[i]*last
        last=ans%1000000007
    print(last)
a, b, c, d, e, k = (int(i) for i in input().split())
_dis=[a,b,c,d,e]
if a-e>k:
  print(":(")
else:
  print("Yay!")
  

### FIXED CODE ###

a, b, c, d, e, k = [int(input()) for i in range(6)]
if e-a<=k:
  print('Yay!')
else:
  print(':(')
N,M = map(int,input().split())

A = [[0]]*(N+1)
B = [[0]]*M

for i in range(N):
    A[i] = input()
for j in range(M):
    B[j] = input()
 
count = 0   
for i in range(N-M+1):
    for j in range(M):
        if B[j]==A[i][i:i+M] and B[j+1]==A[i+1][i:i+M]:
            count += 1
            
            if count == M - 1:
                print("Yes")
                break
if count != M-1 or count==0:
    print("No")

### FIXED CODE ###

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

A = [[0]]*N
B = [[0]]*M

for i in range(N):
    A[i] = input()
for j in range(M):
    B[j] = input()

judge = False 

#行同士で比較していく
for k in range(N-M+1):
    for i in range(N-M+1):
        count = 0
        for j in range(M):
            if B[j]==A[j+i][k:k+M]:
                count += 1
                
                if count == M:
                    judge = True
                    break
            
if judge == True:
    print("Yes")
else:
    print("No")
import numpy as np
N, M = [int(a) for a in input().split()]

A = []
B = []

for _ in range(N):
    a, b = input().split()
    A.append(int(a))
    B.append(int(b))

used_ind = []
sum = 0

for remained_days in range(M+1):
    max_B = 0
    max_ind = -1

    for i in range(N):
        if i in used_ind:
            continue
        if A[i] > remained_days:
            continue
        if B[i] > max_B:
            max_ind = i
            max_B = B[i]
    remained_days -= A[max_ind]
    sum += max_B
    used_ind.append(max_ind)

print(sum)

### FIXED CODE ###

import heapq
import numpy as np

N, M = [int(a) for a in input().split()]

jobs = [[] for _ in range(M)]

for _ in range(N):
    a, b = map(lambda x: int(x), input().split())
    if a > M:
      continue
    jobs[M-a].append(b)

heap = []
ans = 0
for i in range(M-1, -1, -1):
    for b in jobs[i]:
        # 降順にするためにマイナスをつけて入れる
        heapq.heappush(heap, -b)
    if len(heap) != 0:
        # 取り出した値にマイナスをつけて元に戻す
        ans += -heapq.heappop(heap)
print(ans)
a, b = map(int, raw_input()/split())
if a > b:
    print a > b
elif a < b:
    print a < b
else:
    print a == b

### FIXED CODE ###

a, b = map(int, raw_input().split())
if a > b:
    print "a > b"
elif a < b:
    print "a < b"
else:
    print "a == b"
x,a,b=map(int,input().split())
if b-a>x:print("dangerous")
elif b-a<=0:print("delicious")
else:print("safe")

### FIXED CODE ###

a,b,c=map(int,input().split())
if b>=c:print("delicious")
elif a<c-b:print("dangerous")
else:print("safe")