ZhenlongDai/ACPR huggingface dataset:
Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = input().strip()
n = int(n)
i = list(map(int, input().split()))
ans = 0
for a in range(n):
    if a == 0:
        pass
    if a == n-1:
        pass
    else:
        if i[a-1] > i[a] and i[a] > i[a+1] or i[a-1]<i[a] and i[a]< i[a+1]:
            ans += 1
        if i[a-1] == i[a] and i[a] > i[a+1] or i[a+1] == i[a] and i[a] > i[a-1]:
            ans += 1
        else:
            pass
print(ans)

Failing test case input:
9
3 6 3 2 5 14 7 4 2

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
n = input().strip()
n = int(n)
i = list(map(int, input().split()))
ans = 0
for a in range(n):
    if a == 0:
        pass
    elif a == n-1:
        pass
    else:
        if i[a-1] > i[a] and i[a] > i[a+1] or i[a-1]<i[a] and i[a]< i[a+1]:
            ans += 1
        if i[a-1] == i[a] and i[a] > i[a+1] or i[a+1] == i[a] and i[a] > i[a-1]:
            ans += 1
        else:
            pass
print(ans)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input().strip())
P = input().split()

count = 0

listP = list(P)
for i in range(n-2):
    if (listP[i] < listP[i+1] and listP[i+1] < listP[i+2]) or (listP[i] > listP[i+1] and listP[i+1] > listP[i+2]):
        count += 1
    else:
        count += 0

print(count)




Failing test case input:
9
14 12 3 2 3 14 1 4 0

Expected output:
3


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input().strip())
listP = list(map(int, input().split()))
count = 0


for i in range(n-2):
    if (listP[i] < listP[i+1]) and (listP[i+1] < listP[i+2]):
      	count += 1
    elif (listP[i] > listP[i+1]) and (listP[i+1] > listP[i+2]):
        count += 1
    else:
        count += 0

print(count)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
if __name__ == '__main__':
    input()
    a = list(map(int, input().split()))
    count = 0
    for i in range(0, len(a) - 2):
        old = a[i:i + 3]
        new = sorted(old)
        print(old, new, old[1], new[1])
        if old[1] == new[1]:
            count += 1
    print(count)


Failing test case input:
5
1 3 5 4 3

Expected output:
2


Actual output:
[1, 3, 5] [1, 3, 5] 3 3
[3, 5, 4] [3, 4, 5] 5 4
[5, 4, 3] [3, 4, 5] 4 4
2


Fixed submission (verdict: Accepted):
if __name__ == '__main__':
    input()
    a = list(map(int, input().split()))
    count = 0
    for i in range(0, len(a) - 2):
        old = a[i:i + 3]
        new = sorted(old)
        if old[1] == new[1]:
            count += 1
    print(count)
Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
p = list(map(int, input().split()))

collect = 0
for i in range(n - 2):
    p_small = p[i: i + 3]
    p_min = min(p_small)
    p_max = max(p_small)
    pi = p_small[1]
    
    if pi > p_min and pi <= p_max:
        collect += 1
        
print(collect)

Failing test case input:
5
2 3 5 4 2

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
p = list(map(int, input().split()))



collect = 0
for i in range(n - 2):
    p_small = p[i: i + 3]
    
    
    if (p_small[0] < p_small[1] and p_small[2] >= p_small[1]) or (p_small[2] < p_small[1] and p_small[0] >= p_small[1]):
        collect += 1
        
print(collect)

Problem: p02988
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N=int(input())
L=list(map(int,input().split()))
ans=0
for i in range(N-2):
  A=L[i:i+4]
  t=A[2]
  A.sort()
  ans+=1 if t==A[1] else 0
print(ans)

Failing test case input:
5
1 3 5 4 3

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
N=int(input())
L=list(map(int,input().split()))
ans=0
for i in range(N-2):
  A=L[i:i+3]
  t=A[1]
  A.sort()
  
  ans+=1 if t==A[1] else 0
print(ans)

Problem: p02988
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
p = [int(i) for i in input().split()]
temp = 0

for i in range(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]):
        temp += 1

print(temp)


Failing test case input:
9
14 17 3 4 5 25 7 4 0

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
N = int(input())
p = [int(i) for i in input().split()]
temp = 0

for i in range(N-2):
    if (p[i]<=p[i+1] and p[i+1]<p[i+2]) or (p[i]>p[i+1] and p[i+1]>=p[i+2]):
        temp += 1

print(temp)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(2, n):
    p_n = p[i-2:i]
    p_n_sort = sorted(p_n)
    if p_n_sort[1] == p_n[1]:
        cnt += 1
print(cnt)

Failing test case input:
9
25 6 3 2 5 12 7 4 2

Expected output:
5


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(2, n):
    p_n = p[i-2:i+1]
    p_n_sort = sorted(p_n)
    if p_n_sort[1] == p_n[1]:
        cnt += 1
print(cnt)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
p = input().split()
i = 0
result = 0
for x in p:
  if (i+1)<n:
    if sorted([p[i-1],p[i],p[i+1]])[1] == p[i]:
      result+=1
    i+=1
  else:
    break
print(result)

Failing test case input:
5
2 0 5 4 3

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
p = input().split()
i = 1
result = 0
while p:
  if (i+1)<n:
    if sorted([int(p[i-1]),int(p[i]),int(p[i+1])])[1] == int(p[i]):
      result+=1
    i+=1
  else:
    break
print(result)
Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=map(int, input().split())
b=list(a)
c=len(b)

count=0
for i in range(c-1):
  if (b[i-1] < b[i]) and (b[i] < b[i+1]):
    count=count+1
  else:
    next
    
print(count)




Failing test case input:
9
16 12 3 2 9 15 7 4 0

Expected output:
5


Actual output:
0


Fixed submission (verdict: Accepted):
x=map(int, input())
a=map(int, input().split())
b=list(a)
c=len(b)

count=0
for i in range(1,c-1):
  tree= [b[i-1], b[i], b[i+1]]
  if (min(tree) != b[i]) and (max(tree) != b[i]):

  	count=count+1
  else:
  	next
    
print(count)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
list=list(map(int,input().split()))
ans=0
for i in range(1,n-1):
  if list[i-1] < list[i] <list[i+1]:
    ans += 1
print(ans)

Failing test case input:
9
3 6 3 2 5 14 7 4 2

Expected output:
4


Actual output:
1


Fixed submission (verdict: Accepted):
n=int(input())
list=list(map(int,input().split()))
ans=0
for i in range(1,n-1):
  if (list[i-1] < list[i] <list[i+1]) or (list[i+1] < list[i] <list[i-1]):
    ans += 1
print(ans)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
p = map(int, input().split())
p = list(p)
n = len(p)
n = n - 1

i = 1
i0 = i -1
i1 = i + 1
c = 0
for i in range(1, n):
    if (p[i] >= p[i0]) & (p[i] < p[i1]):
        c += 1
    elif (p[i] < p[i0]) & (p[i] >= p[i1]):
        c += 1
    else:
        c += 0    
print(c)

Failing test case input:
9
13 12 6 2 6 0 7 4 0

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
n = int(input())
p = map(int, input().split())
p = list(p)
n = len(p)
n = n - 1

c = 0
for i in range(1, n):
    i0 = i -1
    i1 = i + 1
    if (p[i] > p[i0]) & (p[i] < p[i1]):
        c += 1
    elif (p[i] < p[i0]) & (p[i] > p[i1]):
        c += 1
    else:
        c += 0    
print(c)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
p = list(map(int,input().split())) 
cnt = 0
for i in range(n-1):
    if p[i-1]<p[i] and p[i]<p[i+1]:
        cnt += 1
    elif p[i-1]>p[i] and p[i]>p[i+1]:
        cnt += 1
    else:
        cnt =cnt
print(cnt)

Failing test case input:
9
14 21 3 4 5 25 7 4 0

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
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]:
        cnt += 1
    elif p[i-1]>p[i] and p[i]>p[i+1]:
        cnt += 1
    else:
        cnt = cnt
print(cnt)
Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
ss = input()
s = int(ss)
nums = input().split()
type(nums)
type(nums[0])
print(nums)

count = 0
for val in range(s -2):
    if nums[val + 1] > nums[val ] and nums[val + 1] < nums[val + 2]:
        count += 1
    elif nums[val + 1] > nums[val + 2] and nums[val + 1] < nums[val]:
        count += 1
        
print(count)

Failing test case input:
9
14 12 3 2 5 12 9 4 0

Expected output:
5


Actual output:
['14', '12', '3', '2', '5', '12', '9', '4', '0']
1


Fixed submission (verdict: Accepted):
ss = input()
s = int(ss)
nums = list(map(int,input().split()))
count = 0
for val in range(s -2):
    if nums[val] > nums[val + 1] > nums[val + 2] or nums[val] < nums[val + 1] < nums[val + 2]:
        count += 1
        
print(count)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = input()
a = list( input().split())
cnt = 0
for i in range ( 1, len(a)-1):
  if (a[i-1]<a[i]<a[i+1]) or (a[i+1]<a[i]<a[i-1]):
    cnt += 1
    
print (cnt)    

Failing test case input:
9
14 7 3 7 5 43 7 4 0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
n = int( input())
a = list( map( int, input().split()))
cnt = 0

for i in range ( 1, len(a)-1):
  if (a[i-1]<a[i]<a[i+1]) or (a[i+1]<a[i]<a[i-1]):
    cnt += 1
    
print (cnt)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

p = [int(i) for i in input().split()]
ans = 0
for i in range(n-2):
  if p[i+1] == max(p[i],p[i+1],p[i+2]):
    pass
  else:
    ans += 1

print(ans)
    	

Failing test case input:
9
14 12 5 2 0 9 16 7 0

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):
n = int(input())
p = [int(i) for i in input().split()]
ans = 0
for i in range(n-2):
  if p[i+1] == max(p[i], p[i+1], p[i+2]) or p[i+1] == min(p[i], p[i+1], p[i+2]):
    ans += 0
  else:
    ans += 1
print(ans)

Problem: p02988
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import os, sys, re, math

N = int(input())
s = input().split(' ')

cnt = 0
for i in range(N-2):
    temp = s[i:i+3]
    temp.sort()
    if temp[1] == s[i+1]:
        cnt += 1
print(cnt)


Failing test case input:
9
14 12 3 2 5 6 9 4 0

Expected output:
5


Actual output:
3


Fixed submission (verdict: Accepted):
import os, sys, re, math

N = int(input())
s = [int(n) for n in input().split(' ')]

cnt = 0
for i in range(1,N-1):
    temp = s[i-1:i+2]
    temp.sort()
    if temp[1] == s[i]:
        cnt += 1
print(cnt)

Problem: p02988
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import os, sys, re, math

N = int(input())
s = input().split(' ')

cnt = 0
for i in range(N-2):
    temp = set(s[i:i+3])
    temp = list(temp)
    temp.sort()
    if len(temp) > 1:
        if temp[1] == s[i+1]:
            cnt += 1
print(cnt)


Failing test case input:
9
14 4 3 4 5 25 7 4 0

Expected output:
5


Actual output:
2


Fixed submission (verdict: Accepted):
import os, sys, re, math

N = int(input())
s = [int(n) for n in input().split(' ')]

cnt = 0
for i in range(1,N-1):
    temp = s[i-1:i+2]
    temp.sort()
    if temp[1] == s[i]:
        cnt += 1
print(cnt)
Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
p = list(map(int,input().split()))
 
cnt = 0
 
for i in range(1,n-2):
  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)

Failing test case input:
9
14 17 3 2 5 25 7 4 0

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
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)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n-2):
    if p[i] > p[i+1] > p[i+1] or p[i+1] > p[i+1] > p[i]:
        ans += 1
print(ans)

Failing test case input:
9
25 6 3 2 5 12 7 4 2

Expected output:
5


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
p = list(map(int, input().split()))
ans = 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]:
        ans += 1
print(ans)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
pp = list(map(int,input().split()))
three = [pp[0],pp[1],pp[2]]
cou = 0
th = 0

for i in range(n-2):
    th = three[1]
    three.sort()
    if three[1] == th:
        cou += 1
    three[0] = pp[i]
    three[1] = pp[i+1]
    three[2] = pp[i+2]
print(cou)

Failing test case input:
9
14 21 2 7 5 25 7 4 0

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
pp = list(map(int,input().split()))
three = [pp[0],pp[1],pp[2]]
cou = 0
th = 0

for i in range(n-2):
    three[0] = pp[i]
    three[1] = pp[i+1]
    three[2] = pp[i+2]
    th = three[1]
    three.sort()
    if three[1] == th:
        cou += 1
   
print(cou)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
p = input().split()

cnt = 0
for i in range(1, n - 1):
    if (p[i] != min(p[i - 1], p[i], p[i + 1])):
        if (p[i] != max(p[i - 1], p[i], p[i + 1])):
            cnt += 1

print(cnt)


Failing test case input:
9
13 12 6 2 5 0 7 4 0

Expected output:
3


Actual output:
1


Fixed submission (verdict: Accepted):
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)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
p = list(map(int,input().split()))
i = 0
c = 0
while(i<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])):
        c += 1
    i += 1
print(c)

Failing test case input:
9
14 17 3 4 5 25 7 4 0

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
n = int(input())
p = list(map(int,input().split()))
i = 1
c = 0
while(i<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])):
        c += 1
    i += 1
print(c)
Problem: p02988
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
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(p[i:i+3],sorted_p)

print(count)


Failing test case input:
5
1 3 5 4 0

Expected output:
2


Actual output:
[1, 3, 5] [1, 3, 5]
[3, 5, 4] [3, 4, 5]
[5, 4, 0] [0, 4, 5]
2


Fixed submission (verdict: Accepted):
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)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
p = list(map(int, input().split()))

count = 0
for i in range(1,n-2):
    nums = p[(i-1):(i+2)]
    nums.sort()
    if p[i] == nums[1]:
        count += 1
print(count)


Failing test case input:
9
18 6 3 2 5 8 7 4 1

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
n = int(input())
p = list(map(int, input().split()))

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

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

L = [int(i) for i in input().split()]

Answer = int(0)
for i in range(n-2):
     if L[i]<L[i+1] and L[i+1]<L[i+2]:
             Answer = Answer +1
             continue
print(Answer)


Failing test case input:
9
14 12 3 2 5 25 16 4 0

Expected output:
5


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())

L = [int(i) for i in input().split()]

Answer = int(0)
for i in range(n-2):
     if L[i]<L[i+1] and L[i+1]<L[i+2]:
             Answer = Answer + 1
             continue
     if L[i+2]<L[i+1] and L[i+1]<L[i]:
             Answer = Answer + 1
             continue
print(Answer)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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
  else:
    continue

print(c)

Failing test case input:
9
25 6 3 2 5 14 7 4 2

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
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)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(1,n-2):
    if p[i-1]<p[i]<p[i+1]:
        ans+=1
    else :
        ans+=0
print(ans)

Failing test case input:
9
14 12 5 2 1 25 16 7 0

Expected output:
5


Actual output:
0


Fixed submission (verdict: Accepted):
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 :
        ans+=0
print(ans)
Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = input
a = list (input())

cnt = 0
for i in range (1, len(a)-1):
  if (a[i-1]<a[i]<a[i+1]) and (a[i-1]>a[i]>a[i+1]):
    cnt += 1
    
if len(a)==3:
  if a[1] == 2:
    cnt = 1
  else :
    cnt = 0
    
print(cnt)    

Failing test case input:
5
2 0 5 4 3

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n = int( input())
a = list( map( int, input().split()))
cnt = 0

for i in range ( 1, len(a)-1):
  if (a[i-1]<a[i]<a[i+1]) or (a[i+1]<a[i]<a[i-1]):
    cnt += 1
    
print (cnt)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
t = input().split(' ')
result = 0

for i in range(n-2):
  l = [t[i], t[i+1], t[i+2]]
  if min(l) != l[1] and max(l) != l[1]:
    result += 1
    
print(result)

Failing test case input:
9
25 6 1 2 5 12 10 4 2

Expected output:
5


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
t = list(map(int, input().split()))
result = 0

for i in range(n-2):
  l = [t[i], t[i+1], t[i+2]]
  if min(l) != l[1] and max(l) != l[1]:
    result += 1
    
print(result)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
p = list(map(int,input().split()))
count = n-4
if p[0]==1 or p[0]==n:
  count+=1
if p[n-1]==1 or p[n-1]==n:
  count+=1
print(max(count,0))

Failing test case input:
5
0 1 2 4 3

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
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]-p[i+1]) < 0:
    count+=1
print(count)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
k = 0
a = input()

lista = input().split()

for c in range(1, len(lista)-1):

    if lista[c-1] > lista[c] > lista[c+1] or lista[c-1] < lista[c] < lista[c+1]:
        k += 1

print(k)

Failing test case input:
9
14 12 5 2 0 9 16 7 0

Expected output:
5


Actual output:
1


Fixed submission (verdict: Accepted):
k = 0
a = input()

lista = input().split()

for c in range(1, len(lista)-1):

    if int(lista[c-1]) > int(lista[c]) > int(lista[c+1]) or int(lista[c-1]) < int(lista[c]) < int(lista[c+1]):
        k += 1

print(k)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import math

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

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



Failing test case input:
9
13 2 3 2 5 6 7 3 0

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):

import math

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

ans = 0
for i in range(1, n-1):
    l = p[i-1:i+2]
    if l[1] == sorted(l)[1]:
        ans += 1
print(ans)
Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
Pn = list(input().split(' '))

count_pn = 0
for i in range(1,N-1):
    if ( Pn[i-1] < Pn[i] and Pn[i] <= Pn[i+1] ) or ( Pn[i+1] < Pn[i] and Pn[i] <= Pn[i-1] ):
        count_pn += 1
print(count_pn)


Failing test case input:
9
14 21 3 7 5 25 7 4 0

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
N = int(input())
Pn = list(map(int,input().split(' ')))

count_pn = 0
for i in range(1,N-1):
    if ( Pn[i-1] < Pn[i] < Pn[i+1] ) or ( Pn[i+1] < Pn[i] < Pn[i-1] ):
        count_pn += 1
print(count_pn)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
list=list(map(int,input().split()))
ans=0
for i in range(1,n-1):
  if list[i-1] <= list[i] <=list[i+1]:
    ans += 1
print(ans)


Failing test case input:
9
14 12 5 2 5 25 16 7 0

Expected output:
5


Actual output:
1


Fixed submission (verdict: Accepted):
n=int(input())
list=list(map(int,input().split()))
ans=0
for i in range(1,n-1):
  if (list[i-1] < list[i] <list[i+1]) or (list[i+1] < list[i] <list[i-1]):
    ans += 1
print(ans)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
p = [i for i in input().split()]
ans = 0
for i in range(1,n-2):
  if p[i] != max(p[i-1:i+2]) and p[i] != min(p[i-1:i+2]):
    ans += 1
print(ans)

Failing test case input:
9
13 12 6 2 6 0 7 4 0

Expected output:
3


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
p = [int(i) for i in input().split()]
ans = 0
for i in range(1,n-1):
  if p[i] != max(p[i-1:i+2]) and p[i] != min(p[i-1:i+2]):
    ans += 1
print(ans)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
count=0

p=list(map(int,input().split()))
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+=1
print(count)

Failing test case input:
9
25 6 3 2 5 12 10 4 2

Expected output:
5


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
count=0

p=list(map(int,input().split()))
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
print(count)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
p = list(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)

Failing test case input:
9
13 2 3 2 5 6 7 3 0

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
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)
Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
if __name__ == '__main__':
    input()
    a = list(input().split())
    count = 0
    for i in range(0, len(a) - 2):
        old = a[i:i + 3]
        new = sorted(old)
        if old[1] == new[1]:
            count += 1
    print(count)


Failing test case input:
9
13 12 6 2 6 0 7 4 0

Expected output:
3


Actual output:
1


Fixed submission (verdict: Accepted):
if __name__ == '__main__':
    input()
    a = list(map(int, input().split()))
    count = 0
    for i in range(0, len(a) - 2):
        old = a[i:i + 3]
        new = sorted(old)
        if old[1] == new[1]:
            count += 1
    print(count)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
p = list(input().split())
count = 0
for i in range(1, len(p) - 1):
    p_part = p[i-1:i+2]
    if p[i] != max(p_part) and p[i] != min(p_part):
        count += 1
print(count)

Failing test case input:
9
18 6 3 2 5 8 7 4 1

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(n - 2):
    p_part = p[i:i+3]
    if p[i+1] != max(p_part) and p[i+1] != min(p_part):
        count += 1
print(count)

Problem: p02988
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
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] > p[i+1]):
        count += 1
print(count)

Failing test case input:
5
0 1 2 4 3

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
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]) | (p[i+2] > p[i+1] > p[i]):
        count += 1
print(count)

Problem: p02988
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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)


Failing test case input:
9
9 6 3 2 5 14 7 4 1

Expected output:
5


Actual output:
7


Fixed submission (verdict: Accepted):
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)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=input()
S=list(input().split())
count=0
for i in range(1,len(S)-1):
    if (S[i-1]<S[i] and S[i+1]>S[i]) or (S[i-1]>S[i] and S[i+1]<S[i]):
        count+=1
print(count)

Failing test case input:
9
18 6 3 2 5 8 11 4 1

Expected output:
5


Actual output:
2


Fixed submission (verdict: Accepted):
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
print(cnt)
Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
lst = [int, input().split()]
cnt = 0

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

Failing test case input:
9
14 12 3 2 5 14 7 4 -1

Expected output:
5


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
lst = list(map(int,input().split()))
cnt = 0

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

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
    
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
    
    print(cnt)

Failing test case input:
9
14 17 0 2 5 25 7 4 0

Expected output:
4


Actual output:
0
0
1
2
2
3
4


Fixed submission (verdict: Accepted):
    
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
    
print(cnt)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = input()
numbers = input().split()

result = 0

number_list = []

for i in numbers:
	number_list.append(i)
	if len(number_list) < 3:
		continue
	elif len(number_list) > 3:
		number_list.pop(0)

	sorted_list = sorted(number_list)
	
	if sorted_list[1] == number_list[1]:
		result += 1

print(result)


Failing test case input:
9
9 6 3 2 5 14 7 4 1

Expected output:
5


Actual output:
3


Fixed submission (verdict: Accepted):
n = input()
numbers = [int(n) for n in input().split()]

result = 0

number_list = []

for i in numbers:
	number_list.append(i)
	if len(number_list) < 3:
		continue
	elif len(number_list) > 3:
		number_list.pop(0)

	sorted_list = sorted(number_list)
	
	if sorted_list[1] == number_list[1]:
		result += 1

print(result)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)


Failing test case input:
9
14 12 3 2 5 6 9 4 0

Expected output:
5


Actual output:
2


Fixed submission (verdict: Accepted):
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)
Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = int(input())
list = [int(n) for n in input().split()]

sum = 0

for i in range(1, s - 1):
    if list[i - 1] < list[i] < list[i + 1]:
        sum += 1

print(sum)


Failing test case input:
9
14 12 5 2 1 25 16 7 0

Expected output:
5


Actual output:
0


Fixed submission (verdict: Accepted):
s = int(input())
list = [int(n) for n in input().split()]

sum = 0

for i in range(1, s - 1):
    if (list[i] - list[i - 1]) * (list[i + 1] - list[i]) > 0:
        sum += 1

print(sum)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
P = list(map(int,input().split()))
cnt=0
for i in range(n-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)


Failing test case input:
9
14 18 3 2 5 3 7 4 0

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
P = list(map(int,input().split()))
cnt=0
for i in range(1,n-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)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
p = list(map(int, input().split()))

count=0
for name in range(len(p)-1):
  if (p[name+1] > p[name] > p[name-1]) or (p[name-1] > p[name] > p[name+1]):
    count+=1
print(count)

Failing test case input:
5
1 3 5 4 0

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
p = list(map(int, input().split()))

count=0
for name in range(1, n-1):
  if ((p[name+1] > p[name]) and (p[name] > p[name-1])) or ((p[name-1] > p[name])and (p[name] > p[name+1])):
    count+=1
print(count)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
p=list(input().split())
cnt=0
for i in range(1,n-1):
    if p[i]!=max(p[i-1],max(p[i],p[i+1])) and p[i]!=min(p[i-1],min(p[i],p[i+1])):
        cnt+=1
    elif p[i+1]==p[i-1] and p[i-1]>p[i]:
        cnt+=1

print(cnt)

Failing test case input:
9
14 17 3 4 2 25 7 4 0

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
n=int(input())
p=list(input().split())
p=[int(i) for i in p]
cnt=0
for i in range(1,n-1):
    if p[i]!=max(p[i-1],max(p[i],p[i+1])) and p[i]!=min(p[i-1],min(p[i],p[i+1])):
        cnt+=1
print(cnt)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
l = list(map(int, input().split()))

ans = 0
for i in range(1, n - 1):
  if l[i - 1] < l[i] and l[i] < l[i + 1]:
    ans += 1

print(ans)


Failing test case input:
9
14 12 3 1 5 25 16 4 0

Expected output:
5


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
l = list(map(int, input().split()))
 
ans = 0
for i in range(1, n - 1):
  if l[i - 1] < l[i] and l[i] < l[i + 1]:
    ans += 1
  elif l[i + 1] < l[i] and l[i] < l[i - 1]:
    ans += 1
print(ans)
Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
p = list(map(int, input().split()))

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


Failing test case input:
5
1 3 5 4 2

Expected output:
2

Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
p = list(map(int, input().split()))

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

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def secc(a,b,c):
    k =[]
    k.append(a)
    k.append(b)
    k.append(c)
    k.sort()
    if(k[1]==b):
        return True
    else:
        return False
n = int(input())
a = list(map(int,input().split()))
c =0 
for i in range(2,n-1):
    if(secc(a[i-1],a[i],a[i+1])):
        c+=1 
print(c+1)
    

Failing test case input:
9
14 21 3 7 5 25 7 4 0

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
def secc(a,b,c):
    k =[]
    k.append(a)
    k.append(b)
    k.append(c)
    k.sort()
    if(k[1]==b):
        return True
    else:
        return False
n = int(input())
a = list(map(int,input().split()))
c =0 
for i in range(1,n-1):
    if(secc(a[i-1],a[i],a[i+1])):
        c+=1 
print(c)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())

p=input().split()

A=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]:
        A=A+1

print(A)


Failing test case input:
9
25 6 3 2 5 14 7 8 2

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
n=int(input())

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

A=0

for i in range(1,n-1):
    if p[i-1]<p[i]<p[i+1] :
        A=A+1
    elif p[i-1]>p[i]>p[i+1]:
        A=A+1

print(A)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import math

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

ans = 0
for i in range(1, n-1):
    l = p[i-1:i+2]
    print(l)
    if l[1] == sorted(l)[1]:
        ans += 1
print(ans)



Failing test case input:
9
14 3 5 2 5 25 16 4 0

Expected output:
3


Actual output:
[14, 3, 5]
[3, 5, 2]
[5, 2, 5]
[2, 5, 25]
[5, 25, 16]
[25, 16, 4]
[16, 4, 0]
3


Fixed submission (verdict: Accepted):

import math

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

ans = 0
for i in range(1, n-1):
    l = p[i-1:i+2]
    if l[1] == sorted(l)[1]:
        ans += 1
print(ans)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input()) 
t = input().split(' ')
c = 0

for i in range(1, n-1):
  l = [t[i-1], t[i], t[i+1]]
  if l[0]>l[1]>l[2] or l[0]<l[1]<l[2]:
    c += 1
    
print(c)

Failing test case input:
9
18 6 3 2 5 8 7 4 1

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
n = int(input())
t = list(map(int, input().split()))
result = 0

for i in range(n-2):
  l = [t[i], t[i+1], t[i+2]]
  if min(l) != l[1] and max(l) != l[1]:
    result += 1
    
print(result)
Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
p = input().split()

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

print(cnt)


Failing test case input:
9
18 6 3 2 5 8 7 4 1

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
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)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
p = list(map(int, input().split()))

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


Failing test case input:
5
2 1 5 4 3

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
p = list(map(int, input().split()))

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

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
P = list(input().split())
a = 0
for i in range(0,n-1):
  p1 = int(P[i-1])
  p2 = int(P[i])
  p3 = int(P[i+1])
  if (p1 < p2 < p3) or (p1 > p2 > p3):
    a = a + 1
print(a)

Failing test case input:
9
14 21 3 4 5 25 7 4 0

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
n = int(input())
P = list(input().split())
a = 0
for i in range(1,n-1):
  p1 = int(P[i-1])
  p2 = int(P[i])
  p3 = int(P[i+1])
  if (p1 < p2 < p3) or (p1 > p2 > p3):
    a = a + 1
print(a)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

n = int(input())
list = [int(i) for i in input().split(' ')]
print(n,list)
ans = 0
for i in range(1,n-1):
	tmp = list[i-1:i+2]
	tmp.sort()
	print(tmp)
	if tmp[0] != list[i] and  tmp[1] == list[i]:
		ans = ans + 1
print(ans)


Failing test case input:
9
14 12 3 2 9 14 1 4 0

Expected output:
3


Actual output:
9 [14, 12, 3, 2, 9, 14, 1, 4, 0]
[3, 12, 14]
[2, 3, 12]
[2, 3, 9]
[2, 9, 14]
[1, 9, 14]
[1, 4, 14]
[0, 1, 4]
3


Fixed submission (verdict: Accepted):

n = int(input())
list = [int(i) for i in input().split(' ')]

ans = 0
for i in range(1,n-1):
	tmp = list[i-1:i+2]
	tmp.sort()
	
	if tmp[0] != list[i] and  tmp[1] == list[i]:
		ans = ans + 1
print(ans)
Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


def main():
	n = int(input())
	p = list(map(int,input().split()))
	count = 0
	for i in range(1, n-1):
		if check(p, i):
			count += 1
	print(count)

def check(p, i):
	if ((p[i -1] < p[i]) and (p[i] > p[i + 1])) or ((p[i -1] > p[i]) and (p[i] > p[i + 1])):
		return True
	else:
		return False

main()

Failing test case input:
9
7 6 3 2 5 14 7 8 2

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):


def main():
	n = int(input())
	p = list(map(int,input().split()))
	count = 0
	for i in range(1, n-1):
		if check(p, i):
			count += 1
	print(count)

def check(p, i):
	if ((p[i -1] < p[i]) and (p[i] < p[i + 1])) or ((p[i -1] > p[i]) and (p[i] > p[i + 1])):
		return True
	else:
		return False

main()

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
p = input().split()
cnt = 0
for i in range(1, n-1):
    if p[i-1] < p[i] and p[i] <= p[i+1]:
        cnt += 1
    elif p[i-1] >= p[i] and p[i] > p[i+1]:
        cnt += 1

print(cnt)

Failing test case input:
9
25 6 3 2 5 25 7 4 2

Expected output:
5


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
p = [int(i) for i in input().split()]
cnt = 0
for i in range(1, n-1):
    
    if p[i-1] < p[i] and p[i] <= p[i+1]:
        cnt += 1
    elif p[i-1] >= p[i] and p[i] > p[i+1]:
        cnt += 1

print(cnt)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
5
4 0 5 4 2

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
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)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)


Failing test case input:
5
2 3 5 8 3

Expected output:
2


Actual output:
[2, 3, 5]
[3, 5, 8]
[5, 8, 3]
2


Fixed submission (verdict: Accepted):
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)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

p = [int(i) for i in input().split()]
ans = 0

for i in range(n):
  if i == 0 or i == n-1:
    continue
  x = p[i-1:i+2]
  y = sorted(x)

  if print(y[1]) == p[i]:
    ans +=1
    
print(ans)

Failing test case input:
9
14 12 3 2 5 14 7 4 -1

Expected output:
5


Actual output:
12
3
3
5
7
7
4
0


Fixed submission (verdict: Accepted):
n = int(input())
p = [int(i) for i in input().split()]
ans = 0

for i in range(n):
  if i == 0 or i == n-1:
    continue
  
  x = p[i-1:i+2]
  y = sorted(x)

  if y[1] == p[i]:
    ans +=1
    
print(ans)
Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = input()
nums = input().split(' ')

cnt=0

for i in range(1,len(nums)-1):
  if nums[i-1] < nums[i] and nums[i] < nums[i+1]:
    cnt += 1  
  if nums[i+1] < nums[i] and nums[i] < nums[i-1]:
    cnt += 1
      
print(cnt)
  

Failing test case input:
9
14 12 3 2 7 39 7 4 0

Expected output:
5


Actual output:
1


Fixed submission (verdict: Accepted):
n = input()
nums = input().split(' ')

nums = [int(num) for num in nums]
cnt=0

for i in range(1,len(nums)-1):
  if nums[i-1] < nums[i] and nums[i] < nums[i+1]:
    cnt += 1
  if nums[i+1] < nums[i] and nums[i] < nums[i-1]:
    cnt += 1
      
print(cnt)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(n-2):
  if a[i]<a[i+1]<a[i+2]:
    cnt+=1
print(cnt)

Failing test case input:
9
14 12 5 2 5 25 16 7 0

Expected output:
5


Actual output:
1


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(n-2):
  if a[i]<a[i+1]<a[i+2]:
    cnt+=1
  elif a[i]>a[i+1]>a[i+2]:
    cnt+=1
print(cnt)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(len(p)-3):
  if p[i]<p[i+1] and p[i+1]<p[i+2] or p[i]<p[i+1] and p[i+1]<p[i+2]:
    ans=ans+1
print(ans)

Failing test case input:
9
14 21 3 7 5 25 7 4 0

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(n-2):
  if p[i]<p[i+1] and p[i+1]<p[i+2] or p[i]>p[i+1] and p[i+1]>p[i+2]:
    ans=ans+1
print(ans)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
p = [int(e) for e in input().split()]
result = 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]:
    result += 1


Failing test case input:
9
14 21 2 7 5 25 7 4 0

Expected output:
2


Actual output:

Fixed submission (verdict: Accepted):
n = int(input())
p = [int(e) for e in input().split()]
result = 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]:
    result += 1
print(result)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=int(input())
b=list(map(int,input().split()))
i=0
c=0
for i in range(a-1):
  if b[i-1]<b[i]<b[i+1]:
    c+=1
  i+=1
print(c)

Failing test case input:
9
14 12 5 2 0 9 16 7 0

Expected output:
5


Actual output:
1


Fixed submission (verdict: Accepted):
a=int(input())
b=list(map(int,input().split()))
c=0
for i in range(a-2):
  if b[i]<b[i+1] and b[i+1]<b[i+2] or b[i]>b[i+1] and b[i+1]>b[i+2]:
    c+=1
print(c)
Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input().split() 
num = 0

for i in range(n-2): 
    if (s[i] < s[i+1] and s[i+1] < s[i+2]) or (s[i] > s[i+1] and s[i+1] > s[i+2]):
        num = num+1 
    else: 
        pass

print(num)

Failing test case input:
9
14 12 3 2 7 21 7 4 0

Expected output:
5


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
s = list(map(int, input().split())) 
num = 0

for i in range(n-2): 
    if s[i] < s[i+1] and s[i+1] < s[i+2]:
        num = num+1 
    elif s[i] > s[i+1] and s[i+1] > s[i+2]:
        num = num + 1
    else: 
        pass

print(num)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
P_list = list(map(int,(input().split(" "))))

count = 0
i = 1
for i in range(n-1):
    if P_list[i-1] > P_list[i] > P_list[i+1] or P_list[i-1] < P_list[i] < P_list[i+1]:
        count = count + 1



print(count)


Failing test case input:
9
3 6 3 2 5 14 7 4 0

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
n = int(input())
P_list = list(map(int,(input().split(" "))))

count = 0
i = 0
for i in range(n-2):
    if P_list[i] > P_list[i+1] > P_list[i+2] or P_list[i] < P_list[i+1] < P_list[i+2]:
        count = count + 1


print(count)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=input()
S=list(input().split())
count=0
for i in range(1,len(S)-1):
    if (S[i-1]<=S[i] and S[i+1]>=S[i]) or (S[i-1]>=S[i] and S[i+1]<=S[i]):
        count+=1
print(count)

Failing test case input:
9
14 12 3 2 7 21 7 4 0

Expected output:
5


Actual output:
1


Fixed submission (verdict: Accepted):
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
print(cnt)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
count=0

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

Failing test case input:
9
14 12 3 2 5 14 7 4 -1

Expected output:
5


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
count=0

p=list(map(int,input().split()))
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
print(count)

Problem: p02988
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
Plist = list(map(int,input().split()))
ctr = 0
 
for i in range(1,N-2):
  if (Plist[i] > Plist[i-1]) or (Plist[i] > Plist[i+1]):
    ctr += 1
 
print(ctr)

Failing test case input:
9
25 6 3 2 5 14 7 8 2

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
N = int(input())
Plist = list(map(int,input().split()))
ctr = 0
 
for i in range(1,N-1):
  if (Plist[i+1] > Plist[i] > Plist[i-1]) or (Plist[i+1] < Plist[i] < Plist[i-1]):
    ctr += 1
 
print(ctr)