Problem:


Score : 200 points

Problem Statement

We have a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n}.

Print the number of elements p_i (1 < i < n) that satisfy the following condition:

p_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.

Constraints

All values in input are integers.

3 \leq n \leq 20

p is a permutation of {1,\ 2,\ ...,\ n}.

Input

Input is given from Standard Input in the following format:

n
p_1 p_2 ... p_n

Output

Print the number of elements p_i (1 < i < n) that satisfy the condition.

Sample Input 1

5
1 3 5 4 2

Sample Output 1

2

p_2 = 3 is the second smallest number among p_1 = 1, p_2 = 3, and p_3 = 5. Also, p_4 = 4 is the second smallest number among p_3 = 5, p_4 = 4, and p_5 = 2. These two elements satisfy the condition.

Sample Input 2

9
9 6 3 2 5 8 7 4 1

Sample Output 2

5



Sample input:
5
1 3 5 4 2


Sample output:
2

Submission status: Wrong Answer

Solution code:
n=int(input())
P=list(map(int,input().split()))
ans=0
for i in range(1,n-2):
    if sorted(P[i-1:i+2])[1]==P[i]:ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
n = int(input())
p = list(map(int, input().split()))
x = 0
for i in range(n-1):
    if (max(p[i-1], p[i]) == p[i] and max(p[i+1],p[i]) == p[i+1]) or (max(p[i-1], p[i]) == p[i-1] and max(p[i+1],p[i]) == p[i]):
        x += 1
print(x)

Submission status: Wrong Answer

Solution 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
print(count)

Submission status: Wrong Answer

Solution code:
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]:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(1,n):
    q=sorted(p[i-1:i+2])
    if p[i]==q[1]:
        ans+=1

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
Pn = list(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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
n = int(input())
p = list(input().split())
count = 0
N = 0
for _ in range(n - 2):
  a = p[N: (N + 3)][1]
  if a != max(p[N:(N + 3)]) and a != min(p[N:(N + 3)]):
    count += 1
    N += 1
  else:
    N += 1
print(count)

Submission status: Wrong Answer

Solution 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
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
p = list(input().split())
l = []
a = 0
b = 0
count = 0
for i in range(n - 2):
  l.append(p[a: (a + 3)])
  a += 1
for i in range(n - 2):
  if l[b][1] != max(l[b]) and l[b][1] != min(l[b]):
    count += 1
    b += 1
  else:
    b += 1
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())

p = input().split()

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

Submission status: Wrong Answer

Solution code:
n = int(input())

p = input().split()

count = 0
for i in range(len(p) - 2):
    x = p[i:i+3]
    if x[1] == sorted(x, reverse=True)[1]:
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input().split()
ans = 0

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

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
p = list(map(int,input().split()))
count = 0

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

Submission status: Wrong Answer

Solution code:
n = int(input())
P = list(map(int,input().split()))
p = [0]*3
cnt = 0
for i in range(1,n-1):
    for j in range(0,len(p)):
        p[j] = P[i+(j-1)] - P[i]
    p.sort()
    if p.index(0) == 1:
        cnt += 1

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(p)
count = 0

for i in range(1, n-1):
    l = [p[i-1], p[i], p[i+1]]
    print(l)
    if p[i] < max(l) and p[i] > min(l):
        count += 1
    else:
        continue

print(count)

Submission status: Wrong Answer

Solution code:
p = list(map(int,input().split()))
count = 0
for i in range(len(p)-2):
  if p[i]<=p[i+1]<p[i+2]:
    count = count + 1
  elif p[i]>p[i+1]>=p[i+2]:
    count = count + 1
else:
  print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
p = 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)

Submission status: Wrong Answer

Solution code:
n = int(input())
p = input().split()
cnt = 0
 
for i in range(1,n-1):
    print(i)
    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)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

co = 0

for i in range(1,len(li)-1):
  a = li[i-1]
  b = li[i]
  c = li[i+1]
  
  if a < b and b < c:
    co += 1
print(co)

Submission status: Wrong Answer

Solution 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] or p[j + 1] < p[j] < p[j - 1]:
        ctn += 1
print(ctn)

Submission status: Wrong Answer

Solution 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)

Submission status: Wrong Answer

Solution 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] and p[i] < p[i+1]:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
l = list(map(int,input().split()))
sum=0
print(l)
for i in range(n-2):
  if l[i]<l[i+1]<l[i+2] or l[i]>l[i+1]>l[i+2]:
    sum+=1
print(sum)

Submission status: Wrong Answer

Solution code:
#132b
N = int(input())
p_list = list(map(int, input().split()))

#pi−1, pi, pi+1の 3 つの数の中で、pi が 2 番目に小さい。
#pi (1<i<n) がいくつあるかを出力してください。
ans = 0

Submission status: Wrong Answer

Solution code:
n = int(input())

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

score = 0
for i in range(1, n-1):
    list_p[i]

    if list_p[i] < list_p[i+1] and list_p[i] > list_p[i-1]:
        score += 1

    if list_p[i] < list_p[i+1] and list_p[i] > list_p[i-1]:
        score += 1

print(score)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution 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] and p[1] > min(r):
            count += 1
print(str(count))

Submission status: Wrong Answer

Solution 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] and p[1] > min(r):
            count += 1

print(str(count))

Submission status: Wrong Answer

Solution 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))

Submission status: Wrong Answer

Solution code:
# -*- coding:utf8 -*-
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)

Submission status: Wrong Answer

Solution code:
# -*- coding:utf8 -*-
import math

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

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

Submission status: Wrong Answer

Solution code:
# -*- coding:utf8 -*-
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)

Submission status: Wrong Answer

Solution 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
  else:
    continue

print(c)

Submission status: Wrong Answer

Solution 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)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = input().split()
c = 0
for i in range(n):
  if i == 0 or i == n-1:
    continue
  elif (x[i] < x[i-1] and x[i] > x[i+1]) or (x[i] < x[i+1] and x[i] > x[i-1]):
      c = c + 1
print(c)

Submission status: Wrong Answer

Solution code:
n = int(input())
lst = input().split()
m = 0
for i in range(n - 2):
  if lst[i+1] < max(lst[i], lst[i+2]) and lst[i+1] > min(lst[i], lst[i+2]):
    m += 1
  else:
    continue
print(int(m))

Submission status: Wrong Answer

Solution code:
n = int(input())
lst = input().split()
m = 0
for i in range(n - 2):
  if lst[i+1] < max(lst[i], lst[i+2]) and lst[i+1] > min(lst[i], lst[i+2]):
    m += 1
print(int(m))

Submission status: Wrong Answer

Solution code:
n = int(input())
lst = input().split()
m = 0
for i in range(n - 2):
  if lst[i+1] < max(lst[i], lst[i+2]) and lst[i+1] > min(lst[i], lst[i+2]):
    m += 1
print(m)

Submission status: Wrong Answer

Solution code:
N = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(N-3):
  ans += 1 if max(p[i],p[i+1],p[i+2])!=p[i+1] and min(p[i],p[i+1],p[i+2])!=p[i+1] else 0
print(ans)

Submission status: Wrong Answer

Solution 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] and p[i] < p[i+1]:
    ans += 1
  elif p[i-1] > p[i] and p[i] > p[i+1]:
    ans += 1

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution 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)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int, input().split()))
cnt = 0
for i in range(n-2):
    y = sorted(x[i:i+3])
    print(y)
    if x[i+1] == y[1]:
        cnt += 1

print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())

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

ans= 0

for i in range(1,n-1):
    lis= sorted([li[i],li[i-1],li[i+1]])
    print(lis)
    if lis[1]==li[i]:
        ans +=1
print(ans)

Submission status: Wrong Answer

Solution code:
input()
a = list(map(int,input().split()))

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

Submission status: Wrong Answer

Solution 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] and p[i] < p[i+1]):
    c += 1
print(c)

Submission status: Wrong Answer

Solution 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)

Submission status: Wrong Answer

Solution 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)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=input().split()
b=0
for i in range(1,n-1):
  if a[i-1]<a[i]<a[i+1] or a[i-1]>a[i]>a[i+1]:
    b+=1
print(b)

Submission status: Wrong Answer

Solution code:
def test():
    n = int(input())
    p = list(map(int,input().split()))
    count = 0
    for i in range(n-1):
        if p[i] > p[i-1] and p[i] < p[i+1]:
            count += 1
        elif p[i] < p[i-1] and p[i] > p[i+1]:
            count += 1

    print(count)


if __name__ == "__main__":
    test()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
li = list(map(int,input().split()))
cnt=0
for x in range(n-2): #for xxx in ~~の~~はrange()をいれる
    if max(li[x-1],li[x],li[x+1])!=li[x]and min(li[x-1],li[x],li[x+1]!=li[x]):
        cnt+=1
    else:
        pass
print(cnt)

Submission status: Wrong Answer

Solution code:
n=int(input())
li = list(map(int,input().split()))
cnt=0
for x in range(n-2): #for xxx in ~~の~~はrange()をいれる
    if max(li[x],li[x+1],li[x+2])!=li[x+1]and min(li[x],li[x+1],li[x+2]!=li[x+1]):
        cnt+=1
    else:
        pass
print(cnt)

Submission status: Wrong Answer

Solution code:
n=int(input())
li = list(map(int,input().split()))
cnt=0
for x in range(n-2): #for xxx in ~~の~~はrange()をいれる
    if max(li[x],li[x+1],li[x+2])!=li[x+1]and min(li[x],li[x+1],li[x+2]!=li[x]):
        cnt+=1
    else:
        pass
print(cnt)

Submission status: Wrong Answer

Solution code:
n=int(input())
li = list(map(int,input().split()))
cnt=0
for x in range(n-2): #for xxx in ~~の~~はrange()をいれる
    if (max(li[x],li[x+1],li[x+2])!=li[x+1])and(min(li[x],li[x+1],li[x+2]!=li[x])):
        cnt+=1
    else:
        pass
print(cnt)

Submission status: Wrong Answer

Solution code:
n=int(input())
li = list(map(int,input().split()))
cnt=0
for x in range(n-2): #for xxx in ~~の~~はrange()をいれる
    if (max(li[x-1],li[x],li[x+1])!=li[x])and(min(li[x-1],li[x],li[x+1]!=li[x])):
        cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
n=int(input())
li = list(map(int,input().split()))
cnt=0
for x in range(n-2): #for xxx in ~~の~~はrange()をいれる
    if (max(li[x-1],li[x],li[x+1])!=li[x])and(max(li[x-1],li[x],li[x+1]!=li[x])):
        cnt+=1
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
p = [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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
n = int(input())
p = map(int,input().split())
ans = 0
for i in range(3,n-1):
    if i-1 < i < i+1 :
        ans += 1
    elif i-1 > i > i+1 :
        ans += 1
    else:
        continue
print(ans)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

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

cnt = 0

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

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(2, n):
    p_n = p[i-2:i]
    if min(p_n) == p_n[1]:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
N = int(input())
Plist = list(map(int,input().split()))
ctr = 0

for i in range(0,N-2):
  if (Plist[i] > Plist[i-1]) and (Plist[i] < Plist[i+1]):
    ctr += 1

print(ctr)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(1,n-1):
    li = sorted(p[i-1:i+2])
    print(li)
    if li[1] == p[i]:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
max = int(raw_input())
nums = raw_input().split(" ")
score = 0
for i in range(0,max-2):
    if (nums[i] > nums[i+1] and nums[i+1] > nums[i+2]) or (nums[i] < nums[i+1] and nums[i+1] < nums[i+2]):
        score +=1


print score

Submission status: Wrong Answer

Solution code:
n = int(input())
p = [int(i) for i in input().split()]
temp = 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]):
        temp += 1

print(temp)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
A = int(input())
x = list(map(int, input().split()))
count=0
for i in range(A-2):
    b=x[i:i+3]
    a=sorted(b)
    print(a)
    if a[1] == b[1]:
        count=count+1
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
ls = list(input().replace(' ', ''))
lss = [int(s) for s in ls]

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

Submission status: Wrong Answer

Solution code:
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

Submission status: Wrong Answer

Solution 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)

Submission status: Wrong Answer

Solution code:
n=int(input())
p=list(map(int,input().split()))
print(n)
print(p)
i=1
l=[]
while i<n-1:
  if p[i-1]<p[i]<p[i+1] or p[i-1]>p[i]>p[i+1]:
    l.append(i)
  else:
    pass
  i+=1
print(len(l))

Submission status: Wrong Answer

Solution code:
n = int(input())
seq_str = input().split(" ")
seq = [int(s) for s in seq_str]
counter = 0

for i in range(1,n-1):
    if (seq[i-1]-seq[i])*(seq[i+1]-seq[i]) < 0:
        counter =+ 1
print(counter)

Submission status: Wrong Answer

Solution code:
n = int(input())                               
p = list(map(int, input().split()))
count = 0

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

print(count)

Submission status: Wrong Answer

Solution code:
import copy

S = input()

N = int(S)

S = input()

P = list(map(int, S.split()))

check = []

count = 0

for i in range(0, N-2, 1):
    check = P[i:i+3]
    if (check[1] > check[0]) and (check[1] < check[2]):
        count = count + 1

print(count)

Submission status: Wrong Answer

Solution code:
def OrdinaryNumber(n,p,flag=None):
    
    #リストの要素数が3未満なら０を返す（再帰終了）
    if n < 3:
        return 0
    
    #p[0]<p[1]の場合
    if flag == "LessThan":
        if p[1] < p[2]:
            count = OrdinaryNumber(n-1, p[1:], "LessThan")+1
        else:
            count = OrdinaryNumber(n-1, p[1:], "GreaterThan")
            
    #p[0]>p[1]の場合
    elif flag == "GreaterThan":
        if p[1] < p[2]:
            count = OrdinaryNumber(n-1, p[1:], "LessThan")
        else:
            count = OrdinaryNumber(n-1, p[1:], "GreaterThan")+1
    
    #最初のみ
    else:
        if p[1] < p[2]:
            count = OrdinaryNumber(n-1, p[1:], "LessThan")
            if p[0] < p[1]:
                count +=1
        else:
            count = OrdinaryNumber(n-1, p[1:], "GreaterThan")
            if p[1] > p[2]:
                count +=1
                
    return count

n = int(input())
print(OrdinaryNumber(n,list(map(int,input().split()))))

Submission status: Wrong Answer

Solution code:
def OrdinaryNumber(n,p,flag=None):
    
    #リストの要素数が3未満なら０を返す（再帰終了）
    if n < 3:
        return 0
    
    #p[0]<p[1]の場合
    if flag == "LessThan":
        if p[1] < p[2]:
            count = OrdinaryNumber(n-1, p[1:], "LessThan")+1
        else:
            count = OrdinaryNumber(n-1, p[1:], "GreaterThan")
            
    #p[0]>p[1]の場合
    elif flag == "GreaterThan":
        if p[1] < p[2]:
            count = OrdinaryNumber(n-1, p[1:], "LessThan")
        else:
            count = OrdinaryNumber(n-1, p[1:], "GreaterThan")+1
    
    #最初のみ
    else:
        if p[1] < p[2]:
            count = OrdinaryNumber(n-1, p[1:], "LessThan")+1
            if p[0] < p[1]:
                count +=1
        else:
            count = OrdinaryNumber(n-1, p[1:], "GreaterThan")
            if p[1] > p[2]:
                count +=1
                
    return count

n = int(input())
print(OrdinaryNumber(n,list(map(int,input().split()))))

Submission status: Wrong Answer

Solution code:
import sys
n = int(sys.stdin.readline())
p = list(sys.stdin.readline().rstrip().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
    
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
n = int(sys.stdin.readline())
p = list(sys.stdin.readline().rstrip().split())
lenth_p = n - 1
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
    
print(ans)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    p = list(map(int, input().split()))

    count = 0
    for i, p_i in enumerate(p):
        if i == n-2:
            break
        
        if p[i-1] < p_i and p_i < p[i+1]:
            count += 1
    print(count)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
p=list(map(int,input().split()))
c=0
for i in range(n-3):
    a=p[i:i+3]
    b=sorted(a)
    if a[1]==b[1]:
        c+=1
print(c)

Submission status: Wrong Answer

Solution code:
n = int(input())
pn = list(map(int,input().split()))

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())
p = input().rstrip().split(' ')
count = 0
for i in range(n-2):
  buf = []
  buf.append(p[i])
  buf.append(p[i+1])
  buf.append(p[i+2])
  buf.sort()
  if p[i+1] == buf[1]:
    count = count + 1
print(count)

Submission status: Wrong Answer

Solution code:
# Your code here!
import math
x =  [int(s) for s in input().split()]
sum = 0
for i in range(len(x)-2):
    center = x[i+1]
    three = [x[i], x[i+1], x[i+2]]
    if(x[i+1] == int(sorted(three)[1])):
        sum += 1
        
print(sum)

Submission status: Wrong Answer

Solution code:
n=input()
p=input()

n=int(n[0])
p=p.split()
p=list(map(int,p))
output=0
for i in range(n-2):
    if p[i]<p[i+1] and p[i+1]<p[i+2]:
        output=output+1
    elif p[i+2]<p[i+1] and p[i+1]<p[i]:
        output=output+1
    else:output=output+0
    
print(output)

Submission status: Wrong Answer

Solution code:
n=input()
p=input()

n=int(n[0])
p=p.split()
p=[int(p) for p in p]

output=0
for i in range(n-2):
    if p[i]<p[i+1] and p[i+1]<p[i+2]:
        output=output+1
    elif p[i+2]<p[i+1] and p[i+1]<p[i]:
        output=output+1
    else:output=output+0
    
print(output)

Submission status: Wrong Answer

Solution code:
x = input().split()

n = x[0]
p = x[1:]
c = 0

for i in range(1,len(p)-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
      

print(c)

Submission status: Wrong Answer

Solution code:
x = input().split()
n = x[0]
p = x[1:]

c = 0

for (i,pi) in enumerate(p):
  if i>0 and i<len(p)-1:
    if (int(p[i-1]) < int(pi) and int(pi) < int(p[i+1])) or (int(p[i-1]) > int(pi) and int(pi) > int(p[i+1])) :
      c += 1
      
print(c)

Submission status: Wrong Answer

Solution code:
n = input
a = list (input())

cnt = 0
if len(a)==3:
  if a[1] == 2:
    cnt = 1
  else :
    cnt = 0
    
else:
  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)

Submission status: Wrong Answer

Solution code:
n = input
a = list (input())

cnt = 0
if len(a)==3:
  if a[1] == 2:
    cnt = 1
  else :
    cnt = 0
    
else:
  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
    
print(cnt)

Submission status: Wrong Answer

Solution code:
n = input
a = list (input())

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
    
if len(a)==3:
  if a[1] == 2:
    cnt = 1
  else :
    cnt = 0
    
else:
  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
    
print(cnt)

Submission status: Wrong Answer

Solution code:
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
    
else:
  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
    
print(cnt)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
n = input
a = list (input())

cnt = 1
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)

Submission status: Wrong Answer

Solution code:
n = input()
a = list( input().split())
cnt = 0

if (len(a) == 3) and (a[1] == 2):
  cnt = 1

else:
  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)

Submission status: Wrong Answer

Solution code:
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)