peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
c=[]

for i in range(3):
    c.append(list(map(int, input().split())))

c_sum = sum(c[0] + c[1] + c[2])

if c_sum//3 >= 100 and c_sum % 3 == 0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n, T = map(int, input().split())
ans = 'TLE'
for _ in range(n):
  c, t = map(int, input().split())
  if t <= T:
    if ans == 'TLE' or c < ans:
      ans = c
print(ans)
# Judge status: Wrong Answer
def resolve():
    x, y = map(int, input().split())
    if 1<= (4*x-y) / 2 <= (x-1):
        print("Yes")
    else:
        print("No")
resolve()
# Judge status: Accepted
N = int(input())
lis = list(map(int, input().split()))

for i in range(N-1):
    if lis[i] < lis[i+1]:
        lis[i+1] -= 1
    elif lis[i] == lis[i+1]:
        continue
    else:
        print("No")
        exit()

print("Yes")
# Judge status: Accepted
a, b = map(int,input().split())
print(a*b)
# Judge status: Accepted
a,b,c = input().split()

print("A"+b[0]+"C")
# Judge status: Accepted
a, b, c = map(int, input().split())
if a+b>= c:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))

s = [0]*(n-1)
s[0] = a[0]
A = sum(a)
ans = 1e100
for i in range(n-2):
  s[i+1] = s[i] + a[i+1]

for t in s:
  ans = min(ans, abs(2*t - A))
print(ans)
# Judge status: Accepted
#%%
from collections import defaultdict

n = int(input())

d = defaultdict(list)
for i in range(n):
    k, v = input().split()
    v = int(v)
    d[k].append([v, i+1])

#%%
ks = sorted(d.keys())
for k in ks:
    vs = d[k]
    score_d = {}
    for v in vs:
        score_d[v[0]] = v[1]

    score_keys = sorted(score_d.keys(), reverse=True)
    for sk in score_keys:
        print(score_d[sk])
# Judge status: Accepted
x,y = list(map(int,input().split()))
MIN = float('inf')
for i in [1,-1]:
    for j in [1,-1]:
        ans = 0
        tmpx = x
        if i == -1:
            tmpx = i*tmpx
            ans += 1
        tmpx += abs(abs(x)-abs(y))
        ans += abs(abs(x)-abs(y))
        if j == -1:
            tmpx = j*tmpx
            ans += 1
        if tmpx == y:
            MIN = min(MIN,ans)
print(MIN)
# Judge status: Accepted
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if abs(e-a)<=k:
  print('Yay!')
else:
  print(':(')
# Judge status: Accepted
S = str(input())
L = []

for i in range(len(S)):
    try:
        L.append(abs(int(S[i]+S[i+1]+S[i+2])-753)) 
    except:
        break

print(min(L))
# Judge status: Accepted
import collections
N = int(input())
S = [input() for n in range(N)]

cnt = collections.Counter(S)
m = max(cnt.values())

ans = []
for k, v in cnt.items():
    if v == m:
        ans.append(k)
        
ans.sort()
for a in ans:
    print(a)
# Judge status: Wrong Answer
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
from math import ceil
def main(N, K, A):
    def cut_times(longest):
        return sum(a // longest for a in A)
    under = 0
    r = 10**9
    for i in range(100):
        m = (under + r) / 2
        if cut_times(m) > K: under = m
        else: r = m
    print(ceil(r - 10**-5))

if __name__ == '__main__':
    input = sys.stdin.readline
    N, K = map(int, input().split())
    *A, = map(int, input().split())
    main(N, K, A)
# Judge status: Accepted
N,K=map(int,input().split())
l=[0]*K
for i in range(1,N+1):
    l[i%K]+=1
l.sort(key=int)
print(abs(l[0]-l[-1]))
# Judge status: Accepted
S = input()
if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
    print('Bad')
else:
    print('Good')
# Judge status: Accepted
n = int(input())
h = list(map(int, input().split()))

dp=[0] * n
for i in range(1, n):
  if i - 2 < 0:
    dp[i] = dp[i-1] + abs(h[i] - h[i-1])
  else:
    dp[i] = min(dp[i-2]+abs(h[i] - h[i-2]) ,dp[i-1]+abs(h[i]-h[i-1]) )
  
print(dp[n-1])
# Judge status: Accepted
S = input()
y = int(S[:4])
m = int(S[5:7])
d = int(S[8:])
if y < 2019:
    print("Heisei")
elif y == 2019 and m < 4:
    print("Heisei")
elif y == 2019 and m == 4 and d <= 30:
    print("Heisei")
else:
    print("TBD")
# Judge status: Accepted
a, b = map(str, input().split())
ans = [i*i for i in range(1, 1001)]
t = a+b
if int(t) in ans:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
l = list(map(int,input().split()))
l.sort()
if (2*l[2]-l[1]-l[0])%2 == 0:
  print((2*l[2]-l[1]-l[0])//2)
else:
  print((2*l[2]-l[1]-l[0]+3)//2)
# Judge status: Accepted
n,m,k = map(int, input().split())

for i in range(n+1):
  for j in range(m+1):
    a = (m*i+n*j)-2*(i*j)
    if a == k:
      print ('Yes')
      exit()
print ('No')
# Judge status: Accepted
k=int(input())
a,b=[int(i) for i in input().split()]
print("OK" if 0<len([i for i in range(a,b+1) if i%k==0]) else "NG")
# Judge status: Accepted
A,B,C,X,Y=map(int,input().split())
cost=A*X+B*Y
Z=max(X,Y)
for i in range(0,2*Z+1,2):
    x=max(0,X-(i//2))
    y=max(0,Y-(i//2))
    cost=min(cost,C*i+A*x+B*y)
print(cost)
# Judge status: Accepted
import math
n, d = map(int, input().split())
print(math.ceil(n / (1 + 2*d) ))
# Judge status: Accepted
#ABC048.B
a,b,x = map(int,input().split())

print(b//x - (a-1)//x)
# Judge status: Accepted
n, k = map(int, input().split())
l = []
ans = 0

for i in range(1,n+1):
    for j in range(20):
        if 2**j >= k/i:
            l.append(j)
            break

for i in l:
    ans += 1/n * (1/2)**i
print(ans)
# Judge status: Wrong Answer
l,r=map(int,input().split())
s=10000
for i in range(l,r+1):
    if i%2019==0:
        s=0
    elif (i%673==0 and r-l!=1) or (i%673==0 and (r%3==0 or l%3==0)):
        s=0
if s==0:
    print(0)
else:
    print(((l%2019)*((l+1)%2019))%2019)
# Judge status: Accepted
import math

n, m = map(int, input().split())
a = list(map(int, input().split()))
b = {}
for i in range(n):
    count = 0
    temp = a[i]
    while temp % 2 == 0:
        count += 1
        temp //= 2
    b.setdefault(count, 0)
    b[count] += 1
if len(b.keys()) >= 2:
    ans = 0
else:
    temp = 1
    for i in range(n):
        temp = temp * a[i] // math.gcd(temp, a[i])
    temp2 = temp // 2
    ans = m // temp2 - m // temp
print(ans)
# Judge status: Accepted
import math

h, a = list(map(int, input().split()))
result = math.ceil(h / a)
print(result)
# Judge status: Wrong Answer
s = input()

flag = True
for i in range(len(s)):
    if i%2 == 0:
        if s[i] != "h":
            flag =False
            break
    else:
        if s[i] != "i":
            flag = False
            break

if flag:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def actual(k, s):
    if len(s) > k:
        return f'{s[:k]}...'

    return s

k = int(input())
s = input()

print(actual(k, s))
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
ans = 0
ans_list = []
for i in a:
  s = str(bin(i))
  s = s[2:]
  ans_list.append(int(s))
  ans += int(s)
z = []
for i in ans_list:
  z.append(ans - i)
f = []
for i in z:
  e = []
  for j in str(i):
    if int(j) % 2 == 0:
      j = 0
    if int(j) % 2 == 1:
      j = 1
    e.append(str(j))
  f.append(''.join(e))
h = []
for i in f:
  h.append(int(i, 2))
print(h)
# Judge status: Accepted
n,a,b = map(int,input().split())

if (b-a)%2==0:
    print((b-a)//2) 
else:
    M = min(a-1,n-b)+(b-a-1)//2+1
    print(M)
# Judge status: Accepted
"""
- Nを素因数分解する
- N = p[i]^1*p[i]^2...*p[k]^1*p[k]^2...
"""
from collections import Counter
N = int(input())
factors = []
i = 2

while N > 1:
  if N < i * i:
    factors.append(N)
    break
  while N % i == 0:
    factors.append(i)
    N //= i
  i += 1
# N == 1
ans = 0
# print(factors)
for count in Counter(factors).values():
  i = 1
  while count >= i:
    count -= i
    i += 1
    ans += 1
print(ans)
# Judge status: Wrong Answer
a = int(input())

if a >= 3200:
    print('pink')

elif a < 3200:
    print('red')
# Judge status: Wrong Answer
from collections import defaultdict
from heapq import heappush, heappop, merge

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

day = defaultdict(list)
for a, b in ab:
    heappush(day[a], -b)

work, ans = [], 0
for i in range(1, m + 1):
    work = list(merge(work, sorted(day[i])))
    if len(work) > 0:
        ans -= heappop(work)
print(ans)
# Judge status: Wrong Answer
a,b,c,d=map(int, input().split())
if a//d<c//b:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
x,y=map(int, input().split())

if x<=y:
    ans=min(y-x, y-(-x)+1)

else:
    #xの方が大きい
    ans=1+abs(abs(x)-abs(y))
    if x<0:
        ans+=1
print(ans)
# Judge status: Wrong Answer
n = int(input())
A = [int(x) for x in input().split()]
ans = 0
mod = 10 ** 9 + 7
# 制約がai <= 2^60なので
for d in range(30):
    # d桁目ごとに考える
    x = 0
    for a in A:
        if (a >> d) & 1:
            x += 1
    ans += x * (n-x) * 2**d
    ans %= mod
print(ans)
# Judge status: Accepted
# -*- coding: utf-8 -*-

def input_one_number():
    return int(input())

def input_multiple_number():
    return map(int, input().split())

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


h1,m1,h2,m2,k = input_multiple_number()

m = 0
m += (h2-h1)*60
m += (m2-m1)

print(m-k)
# Judge status: Accepted
w,a,b=map(int,input().split())
if a<=b<=a+w or b<=a<=b+w:
    print(0)
else:
    print(min(abs(a+w-b),abs(b+w-a)))
# Judge status: Accepted
n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

x = sorted(x)
y = sorted(y)

#X < x[-1]では境界値が抜けている。
if x[-1] < y[0] and X <= x[-1] and y[0] <= Y:
    print("No War")
else:
    print("War")
# Judge status: Accepted
if len(set(input())) == 3:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N=int(input())
D=[list(map(int, input().split())) for i in range(N)]
count=0
for j in range(N-2):
    if D[j][0]==D[j][1]:
        if D[j+1][0]==D[j+1][1]:
            if D[j+2][0]==D[j+2][1]:
                count = 1
if count==0:
    print('NO')
else:
    print('Yes')
# Judge status: Wrong Answer
#!/usr/bin/env python3
import bisect

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

for i in range(m):
    value = a.pop()
    value //= 2
    insert_index = bisect.bisect_left(a, value)

    a.insert(insert_index, value)
print(sum(a))
# Judge status: Accepted
n = int(input())
s = input()

ans = s.count("E")

tmp = ans

for i in s:
    tmp += (-1 if i == "E" else 1)
    ans = min(ans, tmp)

print(ans)
# Judge status: Wrong Answer
n=int(input())
count=0
for i in range(1,9):
    for j in range(1,9):
        if i*j==n:
            count=1
            break
    else:
        continue
print("Yes"if count==1 else"No")
# Judge status: Accepted
s = input()
t = []

for x in s:
    if x == "0":
        t.append("0")
    elif x == "1":
        t.append("1")
    else:
        if len(t) > 0:
            t.pop()
print(*t,sep='')
# Judge status: Accepted
n = int(input())
s = input()
ls = list(s)
all = ls.count('R')* ls.count('G')* ls.count('B')

cnt = 0

for i in range(n):
    for j in range(i+1, n):
        if 2*j - i < n:
            if s[i] != s[j] and s[i] != s[2*j-i] and s[j] != s[2*j -i]:
                cnt +=1

print(all - cnt)
# Judge status: Accepted
s = input()
if(s == 'Sunny'):
  print('Cloudy')
elif(s == 'Cloudy'):
  print('Rainy')
else:
  print('Sunny')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
c = 0
k = 0
for i in range(N):
    if A[i] < 0:
        c += 1
        A[i] *= -1
    elif A[i] == 0:
        k = 1

if c % 2 == 0:
    print(sum(A))
elif k == 1:
    print(sum(A))
else:
    print(sum(A)-2*min(A))
# Judge status: Wrong Answer
a,b=map(int,input().split())
c,d=map(int,input().split())
e=int(input())
if a<0 and c<0:
  if a>c:
    print('NO')
  else:
    if  a+b*e>=c+d*e:
      print('YES')
  
    else:
      print('NO')
      
else:
  if  a+b*e>=c+d*e:
    print('YES')
  
  else:
    print('NO')
# Judge status: Accepted
from math import sqrt

n = int(input())

for i in range(int(sqrt(n)), 0, -1):
    if n % i == 0:
        print(n//i + i - 2)
        break
# Judge status: Accepted
a,b=map(int,input().split())
print((b-a)*(b-a-1)//2-a)
# Judge status: Accepted
a = input()
if a[3] == a[2] and a[4] == a[5]:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
N,K = list(map(int, input().split()))
p = list(map(int, input().split()))
p.sort()
print(sum(p[:3]))
# Judge status: Accepted
def main():
    x = int(input())
    jump_sum = 0
    for i in range(1, x+1):
        jump_sum += i
        if jump_sum >= x:
            break
    print(i)


if __name__ == "__main__":
    main()
# Judge status: Accepted
n,m = map(int,input().split())
ans = 0

if n > m//2:
    ans += m//2
else:
    ans += n
    m = m-(2*n)
    if m > 3:
        ans += m//4

print(ans)
# Judge status: Wrong Answer
from itertools import combinations
s = list(int(i) for i in input().split())
com = list(combinations(s , 3))
arr = []
for i in com:
    com.append(list(i))
    com = com[1:]
for i in com:
    if i[0]!=i[1] and i[2]!=i[1] and i[0]!=i[2]:
        arr.append(i)

newlist = []
seen  = set()
for item in arr:
    t = tuple(item)
    if t not in seen:
        newlist.append(item)
        seen.add(t)
print(len(newlist))
# Judge status: Wrong Answer
N = int(input())
A = [int(input()) for i in range(N)]
ans = 0
for i in range(N-1):
    ans += (A[i] + A[i+1])//2
    A[i+1] = min(A[i+1], (A[i] + A[i+1]) % 2)
print(ans)
# Judge status: Accepted
a = input()

count=0
while len(a) > 1:
  if a[0] != a[-1]:
    count+=1
  a=a[1:-1]

print(count)
# Judge status: Accepted
a, b = input().split()
a = int(a)
# b = int(float(b) * 100 +0.1)
b = int(b.replace(".", ""))
print(int(a*b) // 100)
# Judge status: Wrong Answer
s = list(input())
a = 0
for i in range(len(s)):
  if i%2 == 0:
    if s[i] == "h":
      continue
    else:
      a += 1
  elif i%2 == 1:
    if s[i] == "i":
      continue
    else:
      a += 1
if a == 0:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
s=input()
a=int(s[0:2])
b=int(s[2:])
if 1<=a<=12 and 1<=b<=12:
    print('AMBIGUOUS')
elif 1<=b<=12:
    print('YYMM')
elif 1<=a<=12:
    print('MMYY')
else:
    print('NA')
# Judge status: Wrong Answer
import math
a, b, c = map(int,input().split())

for i in range(10**7):
    n = a * i
    if n % b == c:
        print('Yes')
        quit()
print('No')
# Judge status: Accepted
n,m=map(int,input().split())
if n*2<m:
	print(n+(m-2*n)//4)
else:
	print(min(n,m//2))
# Judge status: Accepted
n = int(input())
a= list(map(int,input().split()))

dp=[0]*n
dp[0] =1000
for i in range(1,n):
    if a[i-1]< a[i]:
        dp[i]= (dp[i-1]//a[i-1])* (a[i]-a[i-1])+ dp[i-1]
    else:
        dp[i]=dp[i-1]
print(dp[n-1])
# Judge status: Accepted
S=input()
s=list(set(S))
print("Yes" if len(s)==2 and S.count(s[0])==S.count(s[1])==2 else "No")
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
# n=2
# a=[4,8]
minimum=10000000
for i in range(-100,101):
    cost=0
    for j in range(n):
        cost+=(i-(a[j]))**2
        if j==n-1:
            if cost<minimum:
                minimum=cost

print(minimum)
# Judge status: Accepted
n=int(input())

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

s = 0
mini = 10000000000000
count = 0
for i in t:
    if i < 0:
        count += 1
    s += abs(i)
    mini = min(mini, abs(i))
if count%2 == 0:
    print(s)
else:
    print(s-mini*2)
# Judge status: Wrong Answer
n, m = map(int, input().split())
 
ln = [2*i for i in range(1, n+1)]
lm = [2*i+1 for i in range(m)]
 
c = 0
for i in ln:
  for j in lm:
    if (i+j)%2==0:
      c+=1
c+= n*(n-1)/2
c+= m*(m-1)/2
print(c)
# Judge status: Accepted
import copy
n = int(input())
r = []
for _ in range(n):
    city, x = input().split()
    x = int(x)
    r.append((city, x))

d = copy.deepcopy(r)
d = sorted(d, key=lambda x: -x[1])
d = sorted(d, key=lambda x: x[0])

for k in d:
    print(r.index(k) + 1)
# Judge status: Wrong Answer
a, b = map(int, input().split())
c = a+b
if c%2==0:
    print((a+b)/2)
else:
    print("IMPOSSIBLE")
# Judge status: Wrong Answer
n = int(input())
a = [int(e) for e in input().split()]
i = 0
count = 0
while n > i+2:
    if a[i] == a[i+1] and n > i+2:
        i+=1
        continue
    elif a[i] < a[i+1]:
        while a[i] <= a[i+1] and n > i+2:
            i += 1
    elif a[i] > a[i+1]:
        while a[i] >= a[i+1] and n > i+2:
            i += 1
    count += 1
    i+=1
print(count + 1)
# Judge status: Wrong Answer
N = int(input("何食食べた？："))
x = N * 800
y = (N // 15) * 200

A = x - y
print(A)
# Judge status: Accepted
n,m=map(int,input().split())
if n>=3 and m>=3:
  print((n-2)*(m-2))
elif n==1 and m>=3:
  print(m-2)
elif m==1 and n>=3:
  print(n-2)
elif n==1 and m==1:
  print(1)
else:
  print(0)
# Judge status: Accepted
check = {"SUN":7,"MON":6,"TUE":5,"WED":4,"THU":3,"FRI":2,"SAT":1}
s = input()
print(check[s])
# Judge status: Accepted
X=int(input())

j = 400
for i in range(8):
    if X >= j and X <= (j+199):
        print(8-i)
    j = j + 200
# Judge status: Accepted
s=input()
s=s[::-1]
n=len(s)
count=[0]*2019
count[0]=1
num,d=0,1

for i in s:
  num+=int(i)*d
  num%=2019
  d*=10
  d%=2019
  count[num]+=1

ans=0
for i in count:
  ans+=i*(i-1)//2
  
print(ans)
# Judge status: Wrong Answer
N = int(input())

if N % 9 == 0:
  print('YES')
else:
  print('NO')
# Judge status: Accepted
n = int(input())

zenbu = n * (n + 1) / 2

A = (sum(i for i in range(1, n + 1) if i % 3 == 0))
B = (sum(i for i in range(1, n + 1) if i % 5 == 0))
C = (sum(i for i in range(1, n + 1) if i % 15 == 0))

D = zenbu - A - B + C

print(int(D))
# Judge status: Accepted
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
x, y = map(int, input().split())
if (x in a) and (y in a):
    print("Yes")
elif (x in b) and (y in b):
    print("Yes")
elif (x in c) and (y in c):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def q2():
    N = int(input())
    S = input()
    ans = 'Yes'
    d, m = divmod(N, 2)

    if m == 1:
        ans = 'No'
    elif S[:d] != S[d:]:
        ans = 'No'

    print(ans)


if __name__ == '__main__':
    q2()
# Judge status: Accepted
# B - Bingo

import numpy as np

A = np.zeros((3,3), dtype=np.int64)

for i in range(3):
    A[i] = [int(x) for x in input().split()]

N = int(input())

for _ in range(N):
    b = int(input())
    A = np.where(A==b, 0, A)

if sum(A[0])==0 or sum(A[1])==0 or sum(A[2])==0 or \
    sum(A[:,0])==0 or sum(A[:,1])==0 or sum(A[:,2])==0 or \
    A[0,0]+A[1,1]+A[2,2]==0 or \
    A[2,0]+A[1,1]+A[0,2]==0:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N=int(input())
A=list(map(int,input().strip().split()))
money=1000
stock=0
for n in range(N):
    if n<N-1:
        if A[n]<A[n+1]:
            if money>=A[n]:
                stock+=money//A[n]
                money%=A[n]
        else:
            money+=A[n]*stock
            stock=0
    else:
        money+=A[n]*stock
print(money)
# Judge status: Accepted
N,K = map(int,input().split())
print(1 if N%K else 0)
# Judge status: Wrong Answer
N,M,X,Y=list(map(int, input().split()))
xc=list(map(int, input().split()))
yc=list(map(int, input().split()))
xc.sort()
yc.sort()
if xc[-1]>=yc[0]:
  print('War')
else:
  print('No War')
# Judge status: Wrong Answer
w,h,n=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
a,b,c,d=0,w,0,h
for x,y,A in l:
    if A==1:
        a=max(a,x)
    elif A==2:
        b=min(b,x)
    elif A==3:
        c=max(c,y)
    else:
        d=min(d,y)
if b-a >= 0 and b-c >= 0:
    print((b-a)*(d-c))
else:
    print(0)
# Judge status: Accepted
def main():
    N = int(input())

    S = []
    for _ in range(N):
        x, l = map(int, input().split())
        S.append([x-l, x+l])
    S.sort(key=lambda x:x[1])

    r = -10**10
    ans = 0
    for s in S:
        if s[0] >= r and s[1] >= r:
            r = s[1]
            ans += 1

    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
#!/usr/local/bin/python3
import math

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

print(math.ceil((B-1) / (A-1)))
# Judge status: Wrong Answer
N, L = [int(i) for i in input().split(' ')]

words = [input() for i in range(N)]

words.sort(key=lambda x: x[0])

for word in words:
    print(word, end = '')
# Judge status: Wrong Answer
n, k = map(int, input().split())
h = list(map(int, input().split()))
cost = [-1] * n

cost[0] = 0
for i in range(1, k):
  if i >= n:
    break
  tmp = 100000
  for j in range(0, i):
    tmp = min(tmp, abs(h[j] - h[i]) + cost[j])
  cost[i] = tmp

for i in range(k, n):
  tmp = 100000
  for j in range(i-k, i):
    tmp = min(tmp, abs(h[j] - h[i]) + cost[j])
  cost[i] = tmp

print(cost[n-1])
# Judge status: Accepted
N = int(input())
A = [int(a) for a in input().split()]
d = 0
ans = 1
for i in range(1, N):
    if A[i-1] < A[i]:
        if d < 0:
            ans += 1
            d = 0
        elif d == 0:
            d = 1
    elif A[i-1] > A[i]:
        if d > 0:
            ans += 1
            d = 0
        elif d == 0:
            d = -1
print(ans)
# Judge status: Wrong Answer
import math
n,k = map(int, input().split())

ans = 0
for i in range(n-k+1):
    ans += math.factorial(n+1)//math.factorial(k+i)//math.factorial(n+1-k-i)

print(int(ans))
# Judge status: Accepted
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = iss()
    print('Yes' if '9' in N else 'No')



if __name__ == '__main__':
    main()
# Judge status: Accepted
words = lambda t : list(map(t, input().split()))
n = int(input())
xs = words(int)
minx = n+1
ans = 0
for i in range(n):
    if xs[i] < minx:
        minx = xs[i]
        ans += 1
print(ans)
# Judge status: Wrong Answer
S = input()

if S[0] != "A":
  print("WA")
  exit()
if S[1] == "C":
  print("WA")
  exit() 
if "C" not in S:
  print("WA")
  exit()
x = S.index("C")
if "C" in S[x+1:]:
  print("WA")
  exit()
if S[1:x]+S[x+1:] != (S[1:x]+S[x+1:]).lower():
  print("WA")
  exit()

print("AC")
# Judge status: Accepted
l = [int(input()) for _ in range(5)]
m = [(x+9)//10*10 for x in l]
s = sum(m)
print(min([s-m[i]+l[i] for i in range(5)]))
# Judge status: Accepted
n=int(input())
import math
ans=1
for i in range(n):
    t=int(input())
    ans=(ans//math.gcd(ans,t))*t
    
print(ans)
# Judge status: Accepted
# Vicfred
# https://atcoder.jp/contests/abc132/tasks/abc132_b
# implementation
n = int(input())
p = list(map(int,input().split()))

answer = 0
for i in range(1, n-1):
    if p[i-1] < p[i] < p[i+1] or p[i-1] > p[i] > p[i+1]:
        answer += 1

print(answer)
# Judge status: Accepted
if( input().isupper()):
    print('A')
else:
    print('a')
# Judge status: Wrong Answer
import itertools
import math
K = [i for i in range(1, int(input()) + 1)]
numbers = itertools.combinations_with_replacement(K, 3)

sum_gcd = 0
for i in numbers:
    a = math.gcd(i[0], i[1])
    b = math.gcd(a, i[2])

    if i[0] != i[1] or i[1] != i[2] or i[0] != i[2]:
        sum_gcd += b * 3
    else:
        sum_gcd += b

print(sum_gcd)
# Judge status: Accepted

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

print(abs((n-2)*(m-2)))
# Judge status: Wrong Answer
N = int(input())
C = {i:0 for i in range(60)}
A = input().split()
for i in range(N):
    a = bin(int(A[i]))[2:]
    n = len(a)
    for j in range(n):
        if a[j]=="1":
            C[n-1-j] += 1
cnt = 0
for i in range(60):
    if C[i]>0:
        cnt += C[i]*(N-C[i])*2**i
print(cnt)
# Judge status: Wrong Answer
a=input()
b=int(len(a))
c="x"
d="x"
for i in range(b):
  d=d+c
print(d)
# Judge status: Accepted
inp = [int(s) for s in input().split()]

ans = sum(inp) - max(inp)

print(ans)
# Judge status: Accepted
N, M = map(int, input().split())
H = input().split()

Evaluation = [0] * N

for i in range(M):
  A, B = map(int, input().split())
  if int(H[A-1]) > int(H[B-1]):
    Evaluation[B-1] += 1
  elif int(H[A-1]) < int(H[B-1]):
    Evaluation[A-1] += 1
  else:
    Evaluation[A-1] += 1
    Evaluation[B-1] += 1

count = 0    
for i in range(N):
  if Evaluation[i] == 0:
    count += 1

print(count)