qyliang/CodeNanoFix huggingface dataset:
# Buggy code:
import math
N, D = map(int,input().split())
X = [0] * N
for i in range(N):
    X[i] = list(map(int,input().split()))
count = 0
def func(A,B):
    a = 0
    for k in range(D):
        a += (A[k] - B[k])**2
    a = math.sqrt(a)
    return a
for i in range(N):
    for j in range(i,N):
        sum_x = 0
        int_x = 0
        if i == j:
            continue
         sum_x = func(X[i],X[j])
         int_x = int(sum_x)
         if sum_x == int_x:
             count += 1

# Fixed code:
import math
N, D = map(int,input().split())
X = [0] * N
for i in range(N):
    X[i] = list(map(int,input().split()))
count = 0
def func(A,B):
    a = 0
    for k in range(D):
        a += (A[k] - B[k])**2
    a = math.sqrt(a)
    return a
for i in range(N):
    for j in range(i,N):
        sum_x = 0
        int_x = 0
        if i == j:
            continue
        sum_x = func(X[i],X[j])
        int_x = int(sum_x)
        if sum_x == int_x:
            count += 1
print(count)
# Buggy code:
n, d=map(int, input().split())
x=[]
for i in range(n):
    x.append([int(i) for i in input().split()])

for i in range(n-1): #0-n
  for j in range(i+1,n):
    s = 0
    for k in range(d):
      s += (x[i][k]-x[j][k])**2
    a = math.sqrt(s)
    if a.is_integer():
      ans += 1
print(ans)

# Fixed code:
import math

n, d=map(int, input().split())
x=[]
for i in range(n):
    x.append([int(i) for i in input().split()])

ans=0
for i in range(n-1): #0-n
  for j in range(i+1,n):
    s = 0
    for k in range(d):
      s += (x[i][k]-x[j][k])**2
    a = math.sqrt(s)
    if a.is_integer():
      ans += 1
print(ans)
# Buggy code:
import math
n,d=map(int,input().split())
x=[list(map(int,input().split())) for _ in range(n)]
cnt=0
for i in range(n):
  for j in range(i+1,n):
    sum=0
    for k in range(n):
      sum+=(x[i][k]-x[j][k])**2
    z=pow(sum,0.5)
    if math.ceil(z)==math.floor(z):
      cnt+=1
print(cnt)

# Fixed code:
import math
n,d=map(int,input().split())
x=[list(map(int,input().split())) for _ in range(n)]
cnt=0
for i in range(n):
  for j in range(i+1,n):
    sum=0
    for k in range(d):
      sum+=(x[i][k]-x[j][k])**2
    z=pow(sum,0.5)
    if math.ceil(z)==math.floor(z):
      cnt+=1
print(cnt)
# Buggy code:
import math
n,d=map(int,input().split())
d_list=[]
ans=0
for i in range(n):
    d_list.append(list(map(int,input().split())))
for i in range(n-1):
    kyori=0
    for j in range(i+1,n):
        for k in range(d):
            kyori+=(d_list[i][k]-d_list[j][k])**2
    if math.sqrt(kyori)**2==kyori:
        ans+=1
print(ans)

# Fixed code:
import math
n,d=map(int,input().split())
d_list=[]
ans=0
for i in range(n):
    d_list.append(list(map(int,input().split())))
for i in range(n-1):
    for j in range(i+1,n):
        kyori=0
        #print(i,j)
        for k in range(d):
            kyori+=(d_list[i][k]-d_list[j][k])**2
        #print(kyori)
        if int(math.sqrt(kyori))**2==kyori:
            ans+=1
print(ans)
# Buggy code:
import math as mt
n,d = map(int,input().split())
x = []
count = 0
for i in range(n):
    x.append(list(map(int,input().split())))

for i in range(n-1):
    dist = 0
    for j in range(d):
        dist += (x[i][j]-x[i+1][j])**2
    dist = mt.sqrt(dist)
    if dist.is_integer()==True:
        count += 1
print(count)

# Fixed code:
import math as mt
n,d = map(int,input().split())
x = []
count = 0
for i in range(n):
    x.append(list(map(int,input().split())))

for i in range(n-1):
    for s in range(i+1,n):
        dist = 0
        for j in range(d):
            dist += (x[i][j]-x[s][j])**2
        dist = mt.sqrt(dist)
        if dist.is_integer()==True:
            count += 1
print(count)
# Buggy code:

url = "https://atcoder.jp//contests/abc133/tasks/abc133_b"

def main():
    n,d = list(map(int, input().split()))
    lis = []
    for i in range(n):
        t = list(map(int, input().split()))
        lis.append(t)
    count = 0
    for i in range(len(lis)-1):
        if float.is_integer(ret(lis[i], lis[i+1])):
            count += 1
    print(count)


import math
def ret(a,b):
    retval = 0
    idx = 0
    while True:
        if idx == len(a):
            break
        retval += abs(a[idx]-b[idx])**2
        idx += 1
    return math.sqrt(retval)

if __name__ == '__main__':
    main()


# Fixed code:

url = "https://atcoder.jp//contests/abc133/tasks/abc133_b"
import itertools
def main():
    n,d = list(map(int, input().split()))
    lis = []
    for i in range(n):
        t = list(map(int, input().split()))
        lis.append(t)
    count = 0
    for i in range(len(lis)):
        for j in range(i+1, len(lis)):
            if i == j:
                continue
            if float.is_integer(ret(lis[i], lis[j])):
                count += 1
    print(count)


import math
def ret(a,b):
    retval = 0
    idx = 0
    while True:
        if idx == len(a):
            break
        retval += abs(a[idx]-b[idx])**2
        idx += 1
    return math.sqrt(retval)

if __name__ == '__main__':
    main()
# Buggy code:
import math

N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N))]
cnt = 0

for i in range(N - 1):
    for j in range(i + 1, N):
    tmp = 0
    for k in range(D):
        tmp += ((X[i][k] - X[j][k])** 2)
    tmp = math.sqrt(tmp)
    if tmp.is_integer:
        cnt += 1

print(cnt)


# Fixed code:
import math

N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
cnt = 0

for i in range(N - 1):
    for j in range(i + 1, N):
        tmp = 0
        for k in range(D):
            tmp += ((X[i][k] - X[j][k])** 2)
        tmp = math.sqrt(tmp)
        if tmp.is_integer():
            cnt += 1

print(cnt)
# Buggy code:
import numpy as np
n, d = map(int, input().split())
x = np.array([[int(i) for i in input().split(" ")] for j in range(n)])
t = x[:-1,:]-x[1:,:]
t = np.sqrt(np.sum(t*t, axis=1))
print(np.sum(t%1==0))

# Fixed code:
import numpy as np
n, d = map(int, input().split())
x = np.array([[int(i) for i in input().split(" ")] for j in range(n)])
c = 0
for i in range(1,n):
    t = x[:-1*i,:]-x[1*i:,:]
    t = np.sqrt(np.sum(t*t, axis=1))
    c += np.sum(t%1==0)
print(c)
# Buggy code:
n, d = map(int, input().split())
distances = [list(map(int, input().split())) for _ in range(n)]
ans = 0

for i in range(n):
    for j in range(i + 1, n):
        diff_total = 0
        for k in range(d):
            diff = abs(distances[i][k] - distances[j][k])
            diff_total = diff * diff

        flag = False
        for k in range(diff_total + 1):
            if (k ** 2) == diff_total:
                flag = True
        if flag:
            ans += 1
print(ans)


# Fixed code:
n, d = map(int, input().split())
distances = [list(map(int, input().split())) for _ in range(n)]
ans = 0

for i in range(n):
    for j in range(i + 1, n):
        diff_total = 0
        for k in range(d):
            diff = abs(distances[i][k] - distances[j][k])
            diff_total += diff * diff

        flag = False
        for k in range(diff_total + 1):
            if (k * k) == diff_total:
                flag = True
        if flag:
            ans += 1
print(ans)
# Buggy code:
N, D = map(int,input().split())
li = []
for _ in range(N):
    li.append(list(map(int,input().split())))

s = 0
c = 0
for n in range(-1,N-1):
    for d in range(D):
        s = s + abs(li[n][d] - li[n+1][d]) ** 2
    s_float = float(s**(1/2))
    if s_float.is_integer():
        c += 1
    s = 0
print(c)

# Fixed code:
N, D = map(int,input().split())
li = []
for _ in range(N):
    li.append(list(map(int,input().split())))

s = 0
c = 0
for n1 in range(-1,N-1):
    for n2 in range(n1+1,N-1):
        for d in range(D):
            s = s + abs(li[n1][d] - li[n2][d]) ** 2
        s_float = float(s**(1/2))
        if s_float.is_integer():
            c += 1
        s = 0
print(c)
# Buggy code:
import math
import itertools

N,D= map(int,input().split())
X = []
count=0
for x in range(N):
    X.append(list(map(int,input().split()))) 

print(X)
listArray = list(itertools.combinations(X, 2))

print(listArray)
for X in listArray:
    sumX = 0
    for x in range(D):
        subX = X[0][x] - X[1][x]
        sumX += subX**2
     
    if math.sqrt(sumX).is_integer():
        count += 1
    
print(count)

    

# Fixed code:
import math
import itertools

N,D= map(int,input().split())
X = []
count=0
for x in range(N):
    X.append(list(map(int,input().split()))) 

listArray = list(itertools.combinations(X, 2))

for X in listArray:
    sumX = 0
    for x in range(D):
        subX = X[0][x] - X[1][x]
        sumX += subX**2
     
    if math.sqrt(sumX).is_integer():
        count += 1
    
print(count)
# Buggy code:
def issq(n):
    for i in range(2 * n):
        if i * i == n:
            return True
    return False
    

n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]

count = 0

for i in range(n - 1):
    for j in range(i + 1, n):
        for k in range(d):
            sqdist = 0
            sqdist = sqdist + (x[i][k] - x[j][k]) ** 2
        if issq(sqdist) == True:
            count = count + 1

print(count)

# Fixed code:
def issq(n):
    for i in range(2 * n):
        if i * i == n:
            return True
    return False
    

n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]

count = 0

for i in range(n - 1):
    for j in range(i + 1, n):
        sqdist = 0
        for k in range(d):
            sqdist = sqdist + ((x[i][k] - x[j][k]) ** 2)
        if issq(sqdist) == True:
            count = count + 1

print(count)
# Buggy code:
import numpy as np

n,d=map(int,input().split())
arr=np.array(n)
for i in range(n):
  arr[i]=np.array(list(map(float,input().split())))
ans=0
for i in range(n):
  for j in range(i,n):
    if j!=i:
      k = np.linalg.norm(arr[i]-arr[j],ord=2)
    else:
      k=np.nan
    if k==int(k):
      ans +=1
print(ans)

# Fixed code:
import numpy as np

n,d=map(int,input().split())
arr=[]
for i in range(n):
  arr.append(list(map(int,input().split())))
arr =np.array(arr)
ans=0
for i in range(n):
  for j in range(i,n):
    if j!=i:
      k = np.linalg.norm(arr[i]-arr[j],ord=2)
    else:
      k=0.5
    if k==int(k):
      ans +=1
print(ans)
# Buggy code:
import math
N,D=map(int,input().split())
X = [list(map(int,input().split())) for i in range(N)]
count = 0
for j in range(N-1):
    for k in range(j+1,N):
        L = 0
        for l in range(D):
            L += (X[j][l]-X[k][l])**2
            print(L)
        if math.sqrt(L).is_integer() == True:
            count += 1
print(count)

# Fixed code:
import math
N,D=map(int,input().split())
X = [list(map(int,input().split())) for i in range(N)]
count = 0
for j in range(N-1):
    for k in range(j+1,N):
        L = 0
        for l in range(D):
            L += (X[j][l]-X[k][l])**2
        if math.sqrt(L).is_integer() == True:
            count += 1
print(count)
# Buggy code:
n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(1,n-1):
  if a[i]<a[i+1] and a[i+1]<a[i+2]:
    c+=1
print(c)

# Fixed code:
n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(0,n-2):
  if a[i]<a[i+1] and a[i+1]<a[i+2]:
    c+=1
  elif a[i]>a[i+1] and a[i+1]>a[i+2]:
    c+=1
print(c)
# Buggy code:
n = int(input())
p = list(map(int, input().split()))
c = 0
for i in range(0,n-2):
  if p[i] * p[i+2] < p[i+1] ** 2:
    c += 1
print(c)   

# Fixed code:
n = int(input())
p = list(map(int, input().split()))
c = 0
for i in range(0,n-2):
  if p[i] < p[i+1] < p[i+2] or p[i] > p[i+1] > p[i+2]:
    c += 1
print(c)
# Buggy code:
n = int(input())
p = list(map(int,input().split()))
c = 0
for i in range(1,n-1):
  if p[i-1] < p[i] < p[i+1]:
    c += 1
print(c)

# Fixed code:
n = int(input())
p = list(map(int,input().split()))
c = 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]:
    c += 1
print(c)
# Buggy code:
n = int(input())
p = list(map(int, input().split()))

cnt = 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]:
        cnt += 1
    else:
        continue

print(cnt)


# Fixed code:
n = int(input())
p = list(map(int, input().split()))

ans = 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]:
        ans += 1
    else:
        continue

print(ans)
# Buggy code:
n=int(input())
p = list(map(int, input().split()))
count=0
for i in p
	if p[i]>p[i+1]>p[i+2] or p[i+2]>p[i+1]>p[i]:
    	count=count+1
print(count)

# Fixed code:
n=int(input())
p = list(map(int, input().split()))
count=0
for i in range (n-2):
  if p[i]>p[i+1]>p[i+2] or p[i+2]>p[i+1]>p[i]:
        count = count+1
print(count)
# Buggy code:
def counting(numbers) -> int:
    count = 0
    for i in range(1, len(numbers) - 1):
        pre = numbers[i-1]
        curr = numbers[i]
        next_ = numbers[i+1]
        if pre < curr < next_:
            count += 1
    return count
 
_ = input()
numbers_str = input()
result = counting([int(c) for c in numbers_str.split(' ')])
print(result)


# Fixed code:
def counting(numbers) -> int:
    count = 0
    for i in range(1, len(numbers) - 1):
        pre = numbers[i-1]
        curr = numbers[i]
        next_ = numbers[i+1]
        if pre < curr and curr == next_:
            count += 1
        elif next_ < curr and curr == pre:
            count += 1
        elif pre < curr < next_ or next_ < curr < pre:
            count += 1
    return count
 
_ = input()
numbers_str = input()
result = counting([int(c) for c in numbers_str.split(' ')])
print(result)
# Buggy code:
def main():
    n = int(input())
    p = list(map(int, input().split()))
    cnt = 0

    for i in range(1, n-1):
        print(p[i-1], p[i], p[i+1])
        if  (p[i-1] < p[i] and p[i] < p[i+1]) \
            or (p[i-1] > p[i] and p[i] > p[i+1]):
            cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

# Fixed code:
def main():
    n = int(input())
    p = list(map(int, input().split()))
    cnt = 0

    for i in range(1, n-1):
        if  (p[i-1] < p[i] and p[i] < p[i+1]) \
            or (p[i-1] > p[i] and p[i] > p[i+1]):
            cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()
# Buggy code:

n = int(input())
p = input().split()

print(p)
cnt = 0

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

# Fixed code:
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(1, n-1):
    if (p[i-1] < p[i] and p[i] < p[i+1]) or (p[i-1] > p[i] and p[i] > p[i+1]):
        cnt += 1
print(cnt)
# Buggy code:
input()
p=list(map(int,input().split()))
a=0
for i in range(1,n-1):
	a+=p[i]>min(p[i-1],p[i+1]) and p[i]<max(p[i-1],p[i+1])
print(a)

# Fixed code:
n=int(input())
p=list(map(int,input().split()))
a=0
for i in range(1,n-1):
	a+=p[i]>min(p[i-1],p[i+1]) and p[i]<max(p[i-1],p[i+1])
print(a)
# Buggy code:
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(n-2):
  if p[i] < p[i+1] < p[i+2]:
    count += 1
  else:
    pass

# Fixed code:
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(n-2):
  if p[i] < p[i+1] < p[i+2] or p[i] > p[i+1] > p[i+2]:
    count += 1
  else:
    pass
  
print(count)
# Buggy code:
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(1, n):
    if p[i - 1] < p[i] < p[i + 1]:
        count += 1
print(count)


# Fixed code:
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(1, n - 1):
    if p[i - 1] < p[i] < p[i + 1]:
        count += 1
    elif p[i + 1] < p[i] < p[i - 1]:
        count += 1
print(count)
# Buggy code:
    n = int(input())
    p_list = list(map(int, input().split()))
    count = 0
    for i in range(len(p_list)-2):
    	if (p_list[i]<p_list[i+1] and p_list[i+1]<p_list[i+2]) or (p_list[i]>p_list[i+1] and p_list[i+1]>p_list[i+2]):
    		count += 1
    print(count)

# Fixed code:
n = int(input())
p_list = list(map(int, input().split()))
count = 0
for i in range(len(p_list)-2):
  if (p_list[i]<p_list[i+1] and p_list[i+1]<p_list[i+2]) or (p_list[i]>p_list[i+1] and p_list[i+1]>p_list[i+2]):
    count += 1
print(count)
# Buggy code:
n = int(input())
p = [int(i) for i in range(n)]
s = 0
for i in range(1,n-1):
  l1 = p[i-1,i+2]
  l2 = l1.copy()
  l2.sort()
  if l1[1] == l2[2]:
    s += 1
print(s)
  

# Fixed code:
n = int(input())
p = [int(i) for i in input().split()]
s = 0
for i in range(1,n-1):
  l1 = p[i-1:i+2]
  l2 = l1.copy()
  l2.sort()
  if l1[1] == l2[1]:
    s += 1
print(s)
# Buggy code:
def main():
  n = int(input())
  P = map(int, input().split())

  count = 0
  p1 = P[0]
  p2 = P[1]
  for i in range(2, n):
    p3 = P[i]
    if p1 < p2 < p3 or p1 > p2 > p3:
      count += 1
    p1 = p2
    p2 = p3

main()


# Fixed code:
def main():
    n = int(input())
    P = list(map(int, input().split()))

    count = 0
    p1 = P[0]
    p2 = P[1]
    for i in range(2, n):
        p3 = P[i]
        if p1 < p2 < p3 or p1 > p2 > p3:
            count += 1
        p1 = p2
        p2 = p3

    print(count)


main()
# Buggy code:
N = int(input())
N_List = sorted(list(map(int,input().split())))
ct = 0
for i in range(1,N-1):
    if (N_List[i] > N_List[i-1]) & (N_List[i] < N_List[i+1]):
        ct += 1

print(ct)


# Fixed code:
N = int(input())
N_List = list(map(int,input().split()))
ct = 0
for i in range(1,N-1):
    if (N_List[i] > N_List[i-1]) & (N_List[i] < N_List[i+1]):
        ct += 1
    elif (N_List[i] < N_List[i-1]) & (N_List[i] > N_List[i+1]):
        ct += 1


print(ct)
# Buggy code:
cnt = int(input())
l = list(map(int, input().split()))
count = 0
 
for i in range(cnt-2):
  a,b, c = l[i], l[i+1], l[i+2]
  if a < b and b < c:
    count += 1
print(count)

# Fixed code:
cnt = int(input())
l = list(map(int, input().split()))
count = 0
 
for i in range(cnt-2):
  a,b, c = l[i], l[i+1], l[i+2]
  if (a < b and b < c) or( a>b and b> c):
    count += 1
print(count)
# Buggy code:
N = int(input())
num_list = list(map(int,input().split()))

cnt=0
for i in range(1,N-1):
  temp_list = num_list[i-1:i+2]
  print(temp_list)
  sort_list = sorted(temp_list)
  if temp_list[1] == sort_list[1]:
    cnt+=1
print(cnt)

# Fixed code:
N = int(input())
num_list = list(map(int,input().split()))

cnt=0
for i in range(1,N-1):
  temp_list = num_list[i-1:i+2]
  sort_list = sorted(temp_list)
  if temp_list[1] == sort_list[1]:
    cnt+=1
print(cnt)
# Buggy code:
N = int(input())
numbers = [list(map(int, input().split()))]

numbers = numbers[0]
aaa = []
count = 0


for i in range(N-2):
    number_a = int(numbers[i])
    aaa.append(number_a)
    number_b = int(numbers[i+1])
    aaa.append(number_b)
    number_c = int(numbers[i+2])
    aaa.append(number_c)
    if number_b == sorted(aaa)[-2]:
        count += 1
    else:
        continue

print(count)

# Fixed code:
N = int(input())
numbers = [list(map(int, input().split()))]

numbers = numbers[0]

count = 0


for i in range(N-2):
    aaa = []
    number_a = int(numbers[i])
    aaa.append(number_a)
    number_b = int(numbers[i+1])
    aaa.append(number_b)
    number_c = int(numbers[i+2])
    aaa.append(number_c)
    if number_b == sorted(aaa)[-2]:
        count += 1
    else:
        continue

print(count)
# Buggy code:
def main():
    n = int(input())
    ans = []
    p = list(map(int,input().split()))
    cnt = 0

    for i in range(1,len(p)-2):
        if p[i] < p[i+1] and p[i] > p[i-1]:
            cnt += 1
        elif p[i] > p[i+1] and p[i] < p[i-1]:
            cnt += 1

    print(cnt)



main()

# Fixed code:
def main():
    n = int(input())
    p = list(map(int,input().split()))
    cnt = 0

    for i in range(1,len(p)-1):
        if p[i] < p[i+1] and p[i] > p[i-1]:
            cnt += 1
        elif p[i] > p[i+1] and p[i] < p[i-1]:
            cnt += 1

    print(cnt)

main()
# Buggy code:
n = int(input())
p = map(int, input().split())

count = 0

for i in range(1, n-1):
    if sorted(p[i-1:i+1]).index(p[i]) == 1:
        count += 1

print(count)

# Fixed code:
n = int(input())
p = list(map(int, input().split()))

count = 0

for i in range(1, n-1):
    if sorted(p[i-1:i+2]).index(p[i]) == 1:
        count += 1

print(count)
# Buggy code:
n = int(input())
p = [int(i) for i in input().split()]
ctn = 0
for j in range(1, n-2):
    if p[j -1] < p[j] < p[j + 1]
        ctn += 1
print(ctn)

# Fixed code:
n = int(input())
p = [int(i) for i in input().split()]
ctn = 0
for j in range(1, n-1):
    if p[j - 1] < p[j] < p[j + 1] or p[j + 1] < p[j] < p[j - 1]:
        ctn += 1
print(ctn)
# Buggy code:
n=int(input())
l = [*map(int, input().split())]
res = 0
for i in range(1,n-1):
  if l[i-1]<l[i] and l[i]<l[i+1] or l[i-1]>l[i]andl[i]>l[i+1]: res+=1
print(res)

# Fixed code:
n=int(input())
l = list(map(int, input().split()))
res = 0
for i in range(1,n-1):
  if l[i-1]<l[i] and l[i]<l[i+1] or l[i-1]>l[i] and l[i]>l[i+1]: res+=1
print(res)
# Buggy code:
n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(n):
    r = p[i:i+3]
    if len(r) == 3:
        if max(r)> p[1] < min(r):
            count += 1

print(str(count))


# Fixed code:
n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(n):
    r = p[i:i+3]
    if len(r) == 3:
        if max(r) > r[1] and r[1] > min(r):
            count += 1
print(str(count))
# Buggy code:
N = int(input())
P = list(map(int,input().split()))
ans = 0
for i in range(N-2):
    p = P[i:i+3]
    print(p)
    if min(p)!=p[1] and max(p)!=p[1]:
        ans += 1
print(ans)


# Fixed code:
N = int(input())
P = list(map(int,input().split()))
ans = 0
for i in range(N-2):
    p = P[i:i+3]
    if min(p)!=p[1] and max(p)!=p[1]:
        ans += 1
print(ans)
# Buggy code:
n=int(input())
p=list(map(int,input().split()))
a=0
for i in range(1,n-1):
    if (p[i-1]>p[i] and p[i]>p[i+1]) or (p[i+1]>p[i] and p[i]>p[i-1]):
        a+1
print(a)

# Fixed code:
n = int(input())
p = list(map(int, input().split()))
a = 0
for i in range(n - 2):
    if p[i] > p[i + 1] > p[i + 2] or p[i] < p[i + 1] < p[i + 2]:
        a += 1
print(a)
# Buggy code:
n = int(input())
l = list(map(int,input().split()))
c = 0
for i in range(1,n-2):
  if l[i] > l[i-1] and l[i] < l[i+1]:
    c = c+1
  elif l[i] < l[i-1] and l[i] > l[i+1]:
    c = c+1

print(c)

# Fixed code:
n = int(input())
l = list(map(int,input().split()))
c = 0
for i in range(1,n-1):
    if l[i] > l[i-1] and l[i] < l[i+1]:
        c = c+1
    elif l[i] < l[i-1] and l[i] > l[i+1]:
        c = c+1
    else:
        continue

print(c)
# Buggy code:
N = int(input())
p = list(map(int, input().split()))
count = 0


for i in range(0,N-2):
    if p[i] < p[i+1] and p[i+1] < p[i+2]:
        count += 1
print(count)

# Fixed code:
N = int(input())
p = list(map(int, input().split()))
count = 0


for i in range(0,N-2):
    if p[i] < p[i+1] and p[i+1] < p[i+2]:
        count += 1
    elif p[i] > p[i+1] and p[i+1] > p[i+2]: 
        count += 1
print(count)
# Buggy code:
n=int(input())
p=list(input().split())

count=0
for i in range(n-2):
    sorted_p=sorted(p[i:i+3])
    if p[i+1]==sorted_p[1]:
        count+=1
        print(sorted_p)

print(count)


# Fixed code:
n=int(input())
p=list(map(int,input().split()))

count=0
for i in range(n-2):
    sorted_p=sorted(p[i:i+3])
    if p[i+1]==sorted_p[1]:
        count+=1

print(count)
# Buggy code:
n=int(input())
p=list(map(int,input().split()))
cnt=0
for i in range(n-2):
  lst=[p[i],p[i+1],p[i+2]]
  m=max(lst)
  P=p[i+1]
  del m
  if max(lst)==P:
    cnt+=1
print(cnt)

# Fixed code:
n=int(input())
p=list(map(int,input().split()))
cnt=0
for i in range(n-2):
  lst=[p[i],p[i+1],p[i+2]]
  m=min(lst)
  P=p[i+1]
  del lst[lst.index(m)]
  if min(lst)==P:
    cnt+=1
print(cnt)
# Buggy code:
n = int(input())
p = list(map(int,input().split()))

ans = 0

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

# Fixed code:
n = int(input())
p = list(map(int, input().split()))
c = 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]:
    c += 1
print(c)
# Buggy code:
n, k = map(int, input().split())
ans = n-k if k > 1 else 0

# Fixed code:
n,k=map(int,input().split())
ans=n-k if k>1 else 0
print(ans)
# Buggy code:
n,k = map(int,input().split())
if n >= 2: print(n-k)
else: print(0)

# Fixed code:
n, k = map(int, input().split())

if k >= 2:
    print(n - k)
else:
    print(0)