peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import itertools
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

permutations = list(itertools.permutations(range(1, N+1)))
p = permutations.index(P)
q = permutations.index(Q)
print(abs(p-q))
# Judge status: Wrong Answer
import decimal
import numpy
[a, b, c] = list(map(int, input().split()))

flg = 'No'
if decimal.Decimal(numpy.sqrt(a)) + decimal.Decimal(numpy.sqrt(b)) < decimal.Decimal(numpy.sqrt(c)):
    flg = 'Yes'

print(flg)
# Judge status: Accepted
a,b=list(map(int, input().split()))
from math import log
if True:
  print(int(log(a,b)+1))
# Judge status: Wrong Answer
N = int(input())
ans = ""
while N:
    if N % 2:
        ans += "1"
        N = -((N - 1) // 2)
    else:
        ans += "0"
        N = -(N // 2)
print(ans[::-1])
# Judge status: Accepted
a = input().split()
print(*[h[0] for h in a], sep='')
# Judge status: Wrong Answer
X = int(input())
def hoge(X):
    if 1+ ((X%100)//5) <= X//100:
        return 1
    else:
        return 0
print(hoge(X))
# Judge status: Accepted
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

if __name__ == "__main__":
    n,x,y = map(int,input().split())
    x-=1
    y-=1
    ans = [0]*(n)
    for i in range(n):
        for j in range(i+1,n):
            d = min(abs(i-j),abs(x-i) + abs(y-j) + 1)
            ans[d] += 1
    for i in range(1,n):
        print(ans[i])
# Judge status: Accepted
K,A,B=map(int,input().split())

if (B-A)/2>1 and K>=A+1:
    print(A+(B-A)*((K-A+1)//2)+(K-A+1)%2)
else:
    print(K+1)
# Judge status: Accepted
# B - Bingo
A = []
for _ in range(3):
    tmp = list(map(int,input().split()))
    A.extend(tmp)
B = [0]*9
N = int(input())
for _ in range(N):
    tmp = int(input())
    for i in range(9):
        if tmp==A[i]:
            B[i] = 1
ans = 'No'
for i,j,k in [(0,1,2),(3,4,5),(6,7,8),(0,3,6),(1,4,7),(2,5,8),(0,4,8),(2,4,6)]:
    if B[i]+B[j]+B[k]==3:
        ans = 'Yes'
print(ans)
# Judge status: Accepted
n=int(input())
ans=float('inf')
for a in range(1,int(n**0.5+1)):
  if n%a==0:
    ans=min(ans,a+n//a-2)
print(ans)
# Judge status: Accepted
import numpy as np

n = int(input())
a = list(map(int, input().split()))
total = sum(a)
Min = np.inf
s = 0
for i in range(len(a)-1):
    s += a[i]
    Min = min(Min, abs(2 * s- total))
print(Min)
# Judge status: Accepted
import itertools
import sys

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

if P == Q:
    print(0)
else:
    M = [0]*N
    for i in range(N):
        M[i] = i+1

    ans = []
    for i, v in enumerate(itertools.permutations(M, N)):
        if v in [P, Q]:
            ans.append(i)

    print(abs(ans[0] - ans[1]))
# Judge status: Accepted
N = input()
if N[-1:] == "2" or N[-1:] == "4" or N[-1:] == "5" or N[-1:] == "7" or N[-1:] == "9":
    print('hon')
elif N[-1:] == "0" or N[-1:] == "1" or N[-1:] == "6" or N[-1:] == "8":
    print('pon')
else:
    print("bon")
# Judge status: Accepted
l = int(input())
v = 0

r = l/3
vr = r ** (3)

for i in range(0,l+1):
    for j in range(0,l-i+1):
       if v < i*j*(l-i-j):
           v = i*j*(l-i-j)
    
if vr >= v:
    print(vr)
else:
    print(v)
# Judge status: Accepted
import fractions
A, B, C, D = map(int, input().split(" "))
W = (B-A+1)
x = C*D//fractions.gcd(C,D)

c = (B//C) - ((A-1)//C)
d = (B//D) - ((A-1)//D)
j = (B//x) - ((A-1)//x)

div = (c+d-j)
print(W-div)
# Judge status: Accepted
n=int(input())
a,b=[],[]
for _ in range(n):
    i,j=map(int,input().split())
    a+=[i]
    b+=[j]
a.sort()
b.sort()
c=n//2
if n%2==1:
    print(b[c]-a[c]+1)
else:
    print(b[c]-a[c]+b[c-1]-a[c-1]+1)
# Judge status: Accepted
l = input()
if l[-1] == 's':
  print(l+'es')
else:
  print(l+'s')
# Judge status: Accepted
week =input()

if week=="SUN":
  print("7")
elif week=="MON":
  print("6")
elif week=="TUE":
  print("5")
elif week=="WED":
  print("4")  
elif week=="THU":
  print("3")
elif week=="FRI":
  print("2")
else:
  print("1")
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))
A=sorted(A)
i=len(A)
i//=2
print(sum(A[-i-2:-2])*2+A[-1])
# Judge status: Wrong Answer
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
d = abs(A - B)
v = V - W
ans = 'YES'

if v <= 0:
  ans = 'NO'
else: 
  if d / v > T:
    ans = 'NO'
    
if (A % 2 != B % 2 and V % 2 == W % 2) or (A % 2 == B % 2 and V % 2 != W % 2):
  ans = 'NO'

  
print(ans)
# Judge status: Accepted
a,b=input().split()
a=int(a)
b=int(b.replace(".",""))
print(a*b//100)
# Judge status: Accepted
n = int(input())

if (n < 1000):
   print('ABC')
else:
   print('ABD')
# Judge status: Accepted
import itertools

n, m, k = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))

A = list(itertools.accumulate(A))
B = list(itertools.accumulate(B))

count = 0
j = m
for i in range(n+1):
    if A[i] > k:
        break
    
    while A[i]+B[j] > k:
        j -= 1
        
    count = max(count, i+j)
    
print(count)
# Judge status: Accepted
n = int(input())
H = list(map(int,input().split()))
if n==1: print('Yes');exit()
H[0]-=1
for i in range(n-1):
    if H[i]>H[i+1]:
        print('No');exit()
    elif H[i]==H[i+1]:
        continue
    else:
        H[i+1]-=1
print('Yes')
# Judge status: Accepted
A, B = [int(s) for s in input().split()]
if (A - B) % 2 == 0:
    print((A+B)//2)
else:
    print("IMPOSSIBLE")
# Judge status: Accepted
def resolve():
    a,b,c  = map(int,input().split())
    print("YES" if b-a==c-b else "NO")
resolve()
# Judge status: Accepted
n,m=map(int,input().split())
A=[int(i)//2 for i in input().split()]

def gcd(a,b):
  while b:
    a,b=b,a%b
  return a

def div2(x):
  ret=0
  while x%2==0:
    ret+=1
    x//=2
  return ret

s=div2(A[0])
chk=True

mul=A[0]
for i in range(1,n):
  if s!=div2(A[i]) or mul>m:
    chk=False
  else:
    mul=mul*A[i]//gcd(mul,A[i])
if not chk:
  print(0)
else:
  print(m//mul-m//(mul*2))
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
i = 10**9
s = 0
z = 0
c = 0
for b in a:
  if b < 0:
    s += 1
  elif b == 0:
    z += 1
  if abs(b) < i:
    i = abs(b)
  c += abs(b)
if z > 0 or s%2 == 0:
  print(c)
else:
  print(c-2*i)
# Judge status: Wrong Answer
N = int(input())
S = input()

from collections import Counter

c = Counter(S)

ans = 1
for v in c.values():
    # print(v)
    ans *= v+1
print(ans-1)
# Judge status: Wrong Answer
def main():
    n, k = map(int, input().split())
    A = [int(a) for a in input().split()]

    score = 1
    # for i in range(k):
    #     score *= A[i]

    for i in range(n - k):
        tmp = ((score // A[i]) * A[k + i])

        if tmp > score:
            print("Yes")
        else:
            print("No")

        score = tmp

if __name__ == "__main__":
    main()
# Judge status: Accepted
import sys
n=int(input())
l=[list(map(int,input().split())) for i in range(n)] 
t=0
x=0
y=0
for i in range(n):
    
    t1=l[i][0]
    x1=l[i][1]
    y1=l[i][2]
    dt=t1-t
    md=abs(x-x1)+abs(y-y1)

    if dt >= md and (dt - md) % 2 == 0:
        t=t1
        x=x1
        y=y1
    else:
        print("No")
        sys.exit()

print("Yes")
# Judge status: Wrong Answer


def solve():
    if n > b:
        print((b-1)*a//b)
    else:
        print((a*n)//b- a*(n//b))
    return


# n = int(input())
a, b, n = [int(s) for s in input().split(" ")]
solve()
# Judge status: Wrong Answer
n=input()

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

ma=max(l)
mi=min(l)

print(int(ma-mi))
# Judge status: Accepted
a=list(input())
b=list(input())
c=list(input())
order='a'
while True:
  if order=='a':
    if len(a)==0:
      print('A')
      break
    else:
      order=a[0]
      a=a[1:]
  elif order=='b':
    if len(b)==0:
      print('B')
      break
    else:
      order=b[0]
      b=b[1:]
  elif order=='c':
    if len(c)==0:
      print('C')
      break
    else:
      order=c[0]
      c=c[1:]
# Judge status: Wrong Answer
A, B, M = map(int, input().split())

price_A = list(map(int, input().split()))
price_B = list(map(int, input().split()))

ans = 10**6

for m in range(M):
  x, y, c = map(int, input().split())
  p1 = price_A[x-1] + price_B[y-1] - c
  p2 = price_A[x-1] + price_B[y-1]
  if p1 <= p2 and p1 <= ans: ans=p1
  elif p2 <= p1 and p2<= ans: ans=p2

print(ans)
# Judge status: Accepted
s = input()

t = len(s)//2

for i in range(1,t):
  u = s[:-2*i]
  if u[:len(u)//2] == u[len(u)//2:]:
    print(len(u))
    exit()
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split())) 

kabu = 0
money = 1000
for i in range(n):
    if i == n-1:
        money += kabu*a[i]
        kabu = 0
    elif a[i] < a[i+1]:
        if money >= a[i]:
            kabu = money // a[i]
            money = money - a[i]*kabu
    else:
        money += kabu*a[i]
        kabu = 0
    
print(money)
# Judge status: Wrong Answer
def has_duplicates(seq):
    if len(seq) == len(set(seq)):
        print("Yes")
    else:
        print("No")
    #return len(seq) != len(set(seq))
N = int(input())
A = list(map(int,input().split()))
has_duplicates(A)
# Judge status: Accepted
N,K = map(int,input().split())
result = 0
for i in range(1,N+1):
    prob = 1
    count = i 
    while count < K:
        prob *= 0.5
        count *= 2
    result += prob /N
print(result)
# Judge status: Accepted
N=int(input())
List=[int(input()) for i in range(N)]
List.sort()
LIst=[]
total=sum(List)
for i in List:
  if i % 10 != 0:
      LIst.append(i)
      
if total % 10 != 0:
    print(total)
elif LIst == []:
    print(0)
else:
    print(total-LIst[0])
# Judge status: Wrong Answer
color=input()
iro=color.split(" ")
i=0

if int(iro[0])==int(iro[1]):
    i=i+0
else:
    i=i+1

if int(iro[0])==int(iro[2]):
    i=i+0
else:
    i=i+1
  
if int(iro[1])==int(iro[2]):
    i=i+0
else:
    i=i+1
    
print(str(i))
    
print(str(i))
# Judge status: Accepted
A, B = map(int, input().split())
for i in range(500000):
    a = i * 8 // 100
    b = i // 10
    if (a, b) == (A, B):
        print(i)
        exit()
print(-1)
# Judge status: Wrong Answer
N, C, K = map(int, input().split())
bus_count = 0
waiting_count = 0
time_limit = 0
for _ in range(N):
    T = int(input())
    waiting_count += 1
    if waiting_count == 1:
        time_limit = T + K
    else:
        if T > time_limit:
            time_limit = T + K
            bus_count += 1
            waiting_count = 1
        if waiting_count == C:
            bus_count += 1
            waiting_count = 0
            time_limit = 0

print(bus_count+1)
# Judge status: Wrong Answer
a=int(input())	

if 400 <= a < 600:
  print(8)
elif 600 <= a < 799:
  print(7)
elif 800 <= a < 999:
  print(6)
elif 1000 <= a < 1199:
  print(5)
elif 1200 <= a < 1399:
  print(4)
elif 1400 <= a < 1599:
  print(3)
elif 1600 <= a < 1799:
  print(2)
elif 1800 <= a < 2000:
  print(1)
# Judge status: Accepted
n, y = map(int, input().split())
count = 5000*n
work = [0, n, 0]
for i in range(n):
    if y > count:
        count += 5000
        work[0] += 1
        work[1] -= 1
    elif y < count:
        work[2] += 1
        work[1] -= 1
        count -= 4000
    else:
        break
if y == count:
    print(" ".join(map(str, work)))
else:
    print("-1 -1 -1")
# Judge status: Accepted
x, y = map(int, input().split())
cnt = 0
while x <= y:
    cnt += 1
    x *= 2
print(cnt)
# Judge status: Accepted
A, B = map(int, input().split())
if A >= 13:
  print(B)
elif 6 <= A <= 12:
  print(B//2)
else:
  print(0)
# Judge status: Wrong Answer
n,d = map(int,input().split(" "))
d *= d
c = 0
for i in range(n):
  a,b =map(int,input().split(" "))
  if(a**2 + b**2 == d):
    c += 1
print(c)
# Judge status: Wrong Answer
c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))
if (sum(c1)+sum(c2)+sum(c3))%3 == 0:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
w, a, b = map(int, input().split())
if a <= b and b <= a+w:
    print(0)
elif b <= a+w and a <= b:
    print(0)
elif b + w < a:
    print(min(a-b-w, b-a-w))
# Judge status: Accepted
N,X = map(int,input().split())
list = list(map(int, input().split()))

cnt = 1
sum = 0

for i in list:
    sum += i
    if sum <= X:
        cnt += 1

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

ans=""

for i in range(len(s)):
    num=ord(s[i])+n
    if num>90:
        num-=26
    ans+=chr(num)
print(ans)
# Judge status: Wrong Answer
s = input()
if s[0]==s[0].upper()and s[2]==s[2].upper() and s[3:-1]==s[3:-1].lower()and s[1]==s[1].lower()and s[-1]==s[-1].lower():
    print("AC")
else:
    print("WA")
# Judge status: Wrong Answer
import numpy as np
import math

n = int(input())
lst = list(map(int, input().split()))

avg = np.mean(lst)
avg= math.ceil(avg)

ans = 0
for _ in lst:
    ans += (_ - avg) ** 2
    
print(ans)
# Judge status: Wrong Answer
n = int(input())
s = list(input().split())
res = ""
for i in range(n):
    if i%2 == 0:
        res+=str(i)
    else:
        res = str(i)+res
ans = ""
if n%2:
    res =res[::-1]
for x in res:
    ans += s[int(x)]
    
    
p = list(ans)
print(*p)
# Judge status: Accepted
s = input()
if s == "RRR":
    print(3)
elif "RR" in s:
    print(2)
elif "R" in s:
    print(1)
else:
    print(0)
# Judge status: Wrong Answer
n,m=map(int,input().split())
check=[False]*n
check[0]=True
for i in range(m):
    x,y=map(int,input().split())
    x-=1
    y-=1
    if check[x]:
        check[y]=True
    else:
        continue

ans=0

for i in range(n):
    if check[i]:
        ans+=1

print(ans-1)
# Judge status: Accepted
# AtCoder Beginner Contest 161: C (2020/04/04)
N, K = map(int, input().split())
A = abs(N-K*(N//K))
B = abs(N-K*(N//K+1))
if A < B:
    print(A)
else:
    print(B)
# Judge status: Accepted
def main():
    n, m = list(map(int, input().split()))
    ans = set([1, ])
    balls = [1] * n
    for _ in range(m):
        x, y = list(map(int, input().split()))
        if x in ans:
            ans.add(y)
        if balls[x - 1] == 1 and x in ans:
            ans.remove(x)
        balls[x - 1] -= 1
        balls[y - 1] += 1
    print(len(ans))

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
x = int(input())

if x%11<=6:
    print(2*(x//11)+1)
else:
    print(2*(-(-x//11)))
# Judge status: Accepted
S = input()

res = [0] * 2019
res[0] = 1

d = 1
a = 0

for c in reversed(S):
    a += int(c) * d
    a %= 2019
    res[a] += 1
    d *= 10
    d %= 2019

ans = 0
for r in res:
    ans += r*(r-1) // 2
print(ans)
# Judge status: Wrong Answer
import numpy as np
import math as mt
N=int(input())
#R=map(int, input().split())
A=list(map(int,input().split()))
count=1
p_count=0
for i in range(0,N-1):
    if i==N-2:
        print(count)
        for i in range(0,N-p_count-1):
            print(0)
    elif A[i]!=A[i+1]:
        print(count)
        count=1
        p_count=p_count+1
    else:
        count=count+1
# Judge status: Wrong Answer
hmk = input('')

h1 = int(hmk.split(' ')[0])
m1 = int(hmk.split(' ')[1])
h2 = int(hmk.split(' ')[2])
m2 = int(hmk.split(' ')[3])
k = int(hmk.split(' ')[4])

h = h2 - h1
m = m2 - m1
if m < 0:
    m = m1 - m2
    h-=1

a = h*60 + m - k
print(a)
# Judge status: Wrong Answer
s = input()
if s == 'AAA' and 'BBB':
  print('No')
else:
  print('Yes')
# Judge status: Accepted
s = input()

if s == 'ABC':
  print('ARC')
else:
  print('ABC')
# Judge status: Wrong Answer
a = int(input())
b = int(input())
if a % 500 <= b:
  print("Yes")
else:
  print("NO")
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
kill = 0

for i in range(N):
    if A[i] < B[i] :
        kill += A[i]
        B[i] = B[i] - A[i]
        kill += min(B[i] , A[i+1])
        A[i+1] =max(0, A[i+1] - B[i]) 
    else : kill += B[i]

print(kill)
# Judge status: Accepted
import sys
input = sys.stdin.readline
def main():
  n=int(input())
  l=tuple(tuple(map(int,input().split())) for i in range(n-1))
  for i in range(n):
    now=0
    for a,s,d in l[i:]:
      if now<=s:now=s+a
      else:now=(now+d-1)//d*d+a
    print(now)
if __name__=="__main__":
  main()
# Judge status: Accepted
N, K = map(int, input().split())

print(min(N%K, K-N%K))
# Judge status: Accepted
n = input()

ans = 0
for i in range(len(n)):
    ans += int(n[i])

if ans % 9 == 0:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
from sys import exit

w = list(input())

w_set = list(set(w))

for i in range(len(w_set)):
  if w.count(w_set[i]) % 2 != 0:
    print("No")
    exit()
  else:
    print("Yes")
    exit()
# Judge status: Accepted
N = int(input())
P = list(map(int, input().split()))

mn = N+1
c = 0
for pi in P:
    if pi <= mn:
        c += 1
        mn = pi

print(c)
# Judge status: Wrong Answer
n = int(input())
s = ""
current_num = 0
max_num = 0
for c in s:
  current_num += 1 if c == 'I' else -1
  max_num = max(max_num, current_num)
print(max_num)
# Judge status: Wrong Answer
n,m=map(int,input().split())
if n==1 or m==1:
  print(n*m-2)
else:
  print((n-2)*(m-2))
# Judge status: Wrong Answer
import math
N = int(input())
A = list(map(int, input().split()))

A.sort()

se = set(A)
if len(se) == 1 and N > 1:
    print(0)
    exit()

for i in range(N):
    tmp = set()
    for s in se:
        if s == A[i] or s % A[i] != 0:
            tmp.add(s)
    se = tmp

print(len(se))
# Judge status: Accepted
N = int(input())
dp = [0] * (N+1)
for i in range(1,N+1):
    dp[i] = float('inf')
    power = 1
    while power <= i:
        dp[i] = min(dp[i], dp[i-power] +1)
        power *= 6
    power = 9
    while power <= i:
        dp[i] = min(dp[i], dp[i-power] + 1)
        power *= 9
print(dp[N])
# Judge status: Accepted
x = int(input())

print(10 - x//200)
# Judge status: Accepted

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def gcd(a, b):
    """
    return gcd of a,b
    ユークリッド
    """
    a,b =max(a,b),min(a,b)
    while b:
        a, b = b, a % b
    return a



K = int(input())
ans=0
for i in range(1,K+1):
    for j in range(1,K+1):
        i_j = gcd(i,j)
        for k in range(1,K+1):
            ans+=gcd(i_j,k)
print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    ans = 0
    for i in range(N - 1):
        ans += B[A[i] - 1]

        if A[i] + 1 == A[i+1]:
            ans += C[A[i] - 1]

    ans += B[A[-1] -1]

    print(ans)



if __name__ == "__main__":
    main()
# Judge status: Accepted
X=int(input())
acc=0
cnt=0
t=0
while True:
    if acc>=X:
        break
    t+=1
    acc+=t
    cnt+=1
print(cnt)
# Judge status: Wrong Answer
import math

a,b,x = map(int,input().split())
if 2*(a**2)*b <= 2*(a**2)*x:
    print(math.degrees(math.atan(2*((a**2)*b-x)/a**3)))
else:
    print(math.degrees(math.atan(a*(b**2)/2*x)))
# Judge status: Accepted
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())


dishes = [A, B, C, D, E]
tens = 0
ones = 10
muda = 10
for d in dishes:
    if d % 10 == 0:
        tens += d // 10
    else:
        tens += d // 10 + 1
        if d % 10 < ones:
            muda = d
            ones = d % 10

#%%
if muda % 10 == 0:
    ans = tens * 10
else:
    ans = tens * 10 - (10 - muda % 10)
print(ans)
# Judge status: Accepted
import math
r = float(input())
s = r * 2 * math.pi
print (s)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
B = []
for a in A:
  i = 0
  while a % 2 ** i == 0:
    i += 1
  B.append(i - 1)
B.sort()
print(B[0])
# Judge status: Wrong Answer
n, k, s = map(int, input().split())
a = [s] * k + [s + 1] * (n - k)
print(*a)
# Judge status: Accepted
n = input()
a = list(map(int, input().split()))

sum = 0
for i in a:
    sum ^= i
for i in a:
    print(sum^i)
# Judge status: Accepted
a=int(input())
b=int(input())
h=int(input())
print(int((a+b)*h/2))
# Judge status: Accepted
N = int(input())
A = [int(input()) for i in range(N)]
A_sorted = list(sorted(A, reverse=True))

for i in range(N):
    if A[i] == A_sorted[0]:
        print(A_sorted[1])
    else:
        print(A_sorted[0])
# Judge status: Accepted
N=int(input())
cnt=0
for i in range(1,N+1):
    if(len(str(i))%2==1):
        cnt+=1
print(cnt)
# Judge status: Accepted
n=int(input())
L=list(map(int,input().split()))
M=[]
ans=0
for i in range(1,n-1):
    M.append(L[i-1])
    M.append(L[i])
    M.append(L[i+1])
    M.sort()
    if M[1]==L[i]:
        ans+=1
    M=[]
print(ans)
# Judge status: Accepted
n,m=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(m)]
count=[1]*(n+1)
flag=[False]*(n+1)
flag[1]=True
for a,b in arr:
  count[b]+=1
  count[a]-=1
  if flag[a]==True:
    flag[b]=True
  if count[a]==0:
    flag[a]=False
print(flag.count(True))
# Judge status: Wrong Answer
#a = list(map(int,input().split()))
#b = list(map(int,input().split()))

a = int(input())
x = int(100)
count= 0
while a >= x:
    x += int(x/100)
    count+=1
print(count)
# Judge status: Accepted
import sys

l, r = map(int, input().split())

if 2019 <= r - l:
    print(0)
    sys.exit()

ans = 2019
for i in range(l, r):
    for j in range(i + 1, r + 1):
        i %= 2019
        j %= 2019
        ans = min(ans, (i * j) % 2019)

print(ans)
# Judge status: Accepted
N = int(input())
A = []
B = list(map(int, input().split()))
A.append(B[0])
for i in range(N - 2):
    if B[i] > B[i + 1]:
        A.append(B[i + 1])
    else:
        A.append(B[i])
A.append(B[-1])
print(sum(A))
# Judge status: Accepted
n=int(input())
if n>=15:
    x=n//15
    print(800*n-200*x)
else:
    print(800*n)
# Judge status: Accepted
def cumsum(n,A):
    s = [0]*(n+1)
    s[0] = A[0]
    for i in range(len(A)):
        s[i+1] = (s[i] + A[i])/2
    return s

n = int(input())
v = sorted(list(map(int,input().split())))

for i in range(n-1):
    s = cumsum(n,v)
print(s[-1])
# Judge status: Accepted
ch = ['a','b','c','d','e','f','g','h','i','j','k','l','m',
      'n','o','p','q','r','s','t','u','v','w','x','y','z']

n = int(input())

import queue
q=queue.Queue()
l = 1
q.put(["a", 0])

while True:
  temp = q.get()
  l=len(temp[0])
  if l==n:
    break
    
  for i in range(temp[1]+2):
    ne = temp[0]+ch[i]
    nn = max(temp[1], i)
    q.put([ne, nn])

print(temp[0])
while not q.empty():
  print(q.get()[0])
# Judge status: Wrong Answer
# 入力
N = int(input())

# 処理
total = 0
for i in range(1, N+1):
    print(total)
    # total = total + i

# 出力
print(total)
# Judge status: Wrong Answer
s=input()
ans,skip='',0
for c in reversed(s):
    if c == 'B':
        skip+=1
    elif skip>0:
        skip-=1
    else:
        ans+=c

print(ans)
# Judge status: Wrong Answer
N, K = map(int, input().split())
S = list(input())
r_cnt = 0
answer = 0
before = ''
for s in S:
  if s == before:
    answer += 1
  else:
    r_cnt += 1
    before = s
if r_cnt%2 == 0:
  print(answer+min(r_cnt//2, K)*2)
elif r_cnt//2 <= K:
  print(answer+r_cnt)
else:
  print(answer+K*2-1)
# Judge status: Accepted
x, y, z = map(int, input().split())
print((x - z) // (y + z))
# Judge status: Wrong Answer
n, m = input().split()
n, m = int(n), int(m)

data = []

for _ in range(m):
    temp_p, temp_y = input().split()
    temp_p, temp_y = int(temp_p), int(temp_y)
    data.append([temp_p, temp_y])

data.sort()

result = ""

for temp_data in data:
    result += "{:0>6}".format(temp_data[0]) + "{:0>6}".format(temp_data[1]) + "\n"

print(result)
# Judge status: Accepted
S = input()
print(min(S.count('0'), S.count('1'))*2)
# Judge status: Wrong Answer
L = input()
if L == 'ABC':
  print('ARC')
else:
  print('ARC')
# Judge status: Accepted
N = int(input())
L = list(map(int, input().split()))
import copy
U = copy.copy(L)
for i in range (0, N):
	L[i]+=(i+1)
	U[i]= -U[i]+(i+1)


L = sorted(L)
U = sorted(U)

import bisect

count = 0
for i in range (0, N):
	count+= bisect.bisect_right(U, L[i])-bisect.bisect_left(U, L[i])
    
print(count)
# Judge status: Accepted
n=int(input())
alphabet="abcdefghijklmnopqrstuvwxyz"
ans=[]
while n>0:
    n-=1
    ans.append(alphabet[n%26])
    n=n//26
ans.reverse()
print("".join(ans))
# Judge status: Accepted
N = int(input())
*h, = map(int, input().split())
dp = [0] * N
dp[0] = 0
dp[1] = abs(h[0] - h[1])
for i in range(2, N):
    dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]))
print(dp[-1])