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: Runtime Error

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

Submission status: Runtime Error

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)]
    nums.sort()
    if p[i] == nums[1]
        count += 1
print(count)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
int count = 0
p[] = map(int,input(),split())
for (i=0; i < n-2; i++){
  if p[i] < p[i+1] < p[i+2]: count ++;}
print(count)

Submission status: Runtime Error

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

print(n)
print(P)

counter = 0
for i in range(1, n-1):
    buff = []
    buff = P[i-1:i+2]
    buff.sort()
    if P[i] == buff[1]:
        counter += 1


print(counter)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
m=int(input())
a=[]
for i in range(m):
    a.append(int(input()))

b=1
c=0

for i in range(m-2):
    
    if a[b-1]<a[b] and a[b]<a[b+1]:
        c=c+1
    elif a[b+1]<a[b] and a[b]<a[b-1]:
        c=c+1
        
    b=b+1
print(c)

Submission status: Runtime Error

Solution code:
n = int(input())

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

ans = 0
for i in range(len(X) - 2):
  if (X[i] > X[i+1] > X[i+2]) or (X[i] < X[i+1] < X[i+2])
  	ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
A = int(input())
B = list(map(int, input().split()))
ans = 0

for i in range(1, A-1):
  if B[i-1] > B[i] > B[i+1]:
    s += 1
  elif B[i-1] < B[i] < B[i+1]:
    s+=1
    
print(s)

Submission status: Runtime Error

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

for i in range(1,A-1):
  if B[i-1] > B[i] > B[i+1]:
    s += 1
  elif B[i-1] < B[i] < B[i+1]:
    s += 1
    
print(s)

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

p = list(map(int,x[1:]))

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

print(c)

Submission status: Runtime Error

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

p = list(map(int,x[1:]))
c = 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]):
    c += 1
      

print(c)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
a = list (int(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
    
print(cnt)

Submission status: Runtime Error

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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

print(s)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
data = list(map(int, input().split()))
pn = [x for x in range(1, N-1)]

cnt = 0
for p in pn:
    p_t = np.sort([data[p - 1], data[p], data[p + 1]])
    cnt = cnt + 1 if p_t[1] == data[p] else cnt
    
print(cnt)

Submission status: Runtime Error

Solution code:
def solve():
  n = int(input())
  p = list(int(i) for i in input().split())
  ans = 0
  try:
    for i in range(n):
      if p[i-1]>p[i]>p[i+1]:
        ans += 1
      elif p[i-1]<p[i]<p[i+1]:
        ans += 1
  finally:
   print(ans)
solve()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def myInput():
  n=input()
  s=input()
  return(n,[int(i) for i in s.split()])

def func():
  n, lst1 = nyInput()
  cnt = 0
  for i in range(1, int(n)-1):
    if min(lst[i+1],max(lst1[i],lst1[i-1])) == lst1[i]:
      cnt+=1
    elif min(lst1[i-1], max(lst1[i],lst1[i+1])) == lst1[i]:
      cnt+=1
  return cnt
print(func())

Submission status: Runtime Error

Solution code:
n=int(input())
b=list(map(int,input().split()))
c=0
d=0
while c<=n-2 :
    if b[c+1]>b[c] and b[c+1]<b[c+2] or b[c+1]<b[c] and b[c+1]>b[c+2]:
        d +=1
        c +=1
    else:
        c+=1

print(d)

Submission status: Runtime Error

Solution code:
n = int(input())

ls = list(map(int, input().split()))
 
count = 0

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

print count

Submission status: Runtime Error

Solution code:
ss = input()
s = int(ss)

nums = input().split()
type(nums)
type(nums[0])

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

Submission status: Runtime Error

Solution code:
N = int(input())
num = input().sprit()

count = 0

for i in range(N-3):
  if num[i] < num[i+1] < num[i+2]:
    count += 1
  elif num[i] > num[i+1] > num[i+2]:
    count += 1

print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
p = list(int,input().split())
ans = 0
for i in range(1,N-1):
  if (p[i]<p[i+1])and(p[i]>p[i-1]):
    ans += 1
  elif(p[i]>p[i+1])and(p[i]<p[i-1]):
    ans += 1
  else:
    None
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
arrayP = [int(s) for s in input().split()]

cnt = 0

for i in range(0, n-2):
    threeNums = arrayP[i:i+3].sort()
    if threeNums[1] == arrayP[i+1]:
        cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
n = int(input())
p = list(map(int,input().split()))
i = 1
ans = 0
while i =< n-2:
  if (p[i]-p[i-1])*(p[i]-p[i+1]) < 0:
    ans += 1
  if (p[i]-p[i-1])*(p[i]-p[i+1]) = 0:
    if p[i] < p[i-1] or p[i] < p[i+1]:
      ans += 1
  i += 1
print("%d",ans)

Submission status: Runtime Error

Solution code:
n = input()
p = [int(i) for i in input().split()]
ans = 0
for i in range(n-3):
  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)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

ans = 0
for i in range(N-2):
  if list[i+1] > List[i] and list[i+1] < List[i+2]:
    ans+=1
  if list[i+1] < List[i] and list[i+1] > List[i+2]:
    ans+=1
  else:
    pass

print(ans)

Submission status: Runtime Error

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

ans = 0
for i in range(N-2):
  if list[i+1] > List[i] and list[i-1] < List[i]:
    ans+=1
  if list[i+1] < List[i] and list[i-1] > List[i]:
     ans+=1

print(ans)

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
  z = input()
  num_list = input()
  count = 0
  for i in range(z-3):
    hoge = num_list[i:i+3]
    hoge_sort = hoge.sort()
    if hoge[1]=hoge_sort[1]:
      count += 1
  print(count)

Submission status: Runtime Error

Solution code:
n = 5
num_list = [1,2,3,2,1]
count = 0
for i in range(len(num_list)-3):
	hoge = num_list[i:i+3].sort_values()
    if hoge[1] = num_list[1]:
      count += 1
 
print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
l = [*map(int, input().split())]
cnt = 0

for i in range(1, len(l)-1):
    sub = sorted([l[i-1], l[i], l[i+1]])
    
    if sub[1] == l[i]:
        cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
N = int(input())
P= [int(x) for x in input().split]

answer=0
for i in range(1,N-1):
  a,b,c=P[i-1:i+2]
  if b != max(a,b,c) and b!= min(a,b,c):
    answer+=1

print(answer)

Submission status: Runtime Error

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

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

print (cnt)

Submission status: Runtime Error

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

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

print (cnt)

Submission status: Runtime Error

Solution code:
 = input()
p = []
input_first = input()
for ki in range(int(n)):
    p = input_first.rstrip().split(' ')
count = 0
print(p)
for i in range(1,int(n)-1):
    if (int(p[i]) > int(p[i-1]) and int(p[i]) < int(p[i+1])) or (int(p[i]) < int(p[i-1]) and p[i] > p[i+1]):
        count += 1
    else:
        pass
print(count)

Submission status: Runtime Error

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

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

print (cnt)

Submission status: Runtime Error

Solution code:
s = input()
all[20]

for val int range(s):
    all[val] = input()
    
count = 0
for val in range(s - 2)
    if all[val] < all[val + 1] and all[val + 1] < all[val + 2]
        count += 1

Submission status: Runtime Error

Solution code:
n = int(input())

li = list(map(int, input().split()))
cnt = 0
for i in range(n):
    li2 = li[i-2: i+1]
    if li2[1] == sorted(li2)[1]:
        cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
n = int(input())

li = list(map(int, input().split()))
cnt = 0
for i in range(n+1):
    li2 = li[i-2: i+1]
    if li2[1] == sorted(li2)[1]:
        cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
n = int(input())
l = list(input)
cnt = 0
for i in range(1,n):
    three = [l[i-1],l[i],l[i+1]]
    three.sort()
    if three[1] == list[i]:
        cnt += 1

print(cnt)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
plist = list(map(int, input().split()))
counter = 0

for i in range(2, n):
    a = plist[i - 1]
    b = plist[i]
    c = plist[i+1]
    if a < b < c or c < b < a:
        counter += 1

print(counter)

Submission status: Runtime Error

Solution code:
n = int(input())
plist = list(map(int, input().split()))
counter = 0

for i in range(2, n):
    a, b, c = plist[i - 1:i + 2]
    if a < b < c or c < b < a:
        counter += 1

print(counter)

Submission status: Runtime Error

Solution code:
n = int(input())

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

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)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int answer = 0;
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];

    for (int i = 1; i < n - 1; i++) {
        if ((p[i] < p[i + 1] && p[i - 1] < p[i]) ||
            (p[i] > p[i + 1] && p[i - 1] > p[i]))
            answer += 1;
    }

    printf("%d", answer);
}

Submission status: Runtime Error

Solution code:
n = int(input())
p = input().split(" ")
answer = 0

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

print(answer)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a = int(input())
ar = list(map(int,input().split(" ")))
count = 0
for i in range(1,a):
  if ar[i] < ar[i-1] and ar[i] > ar[i+1]:
    count += 1
  elif ar[i] < ar[i+1] and ar[i] > ar[i-1]:
    count += 1
print(count)

Submission status: Runtime Error

Solution code:
a = int(input())
ar = list(map(int,input().split(" ")))
count = 0
for i in range(1,a):
  if ar[i] < ar[i-1] and ar > ar[i+1]:
    count += 1
  elif ar[i] < ar[i+1] and ar > ar[i-1]:
    count += 1
print(count)

Submission status: Runtime Error

Solution code:
def counting(numbers: int[]): 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(numbers_str.split(' '))
print(result)

Submission status: Runtime Error

Solution code:
x = int(input())
suji=[]
for i in range(x):
    nyuryoku=int(input())
    suji.append(nyuryoku)
ans=0
for i in range(x-1):
    if suji[i-1]<suji[i] and suji[i]<suji[i+1]:
        ans+=1
    elif suji[i-1]>suji[i] and suji[i]>suji[i+1]:
        ans+=1

print(str(ans))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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=1+a
print(a)

Submission status: Runtime Error

Solution code:
def calc(n, p):
    count = 0
    for i in range(1, n-1):
        if p[i-1] < p[i] and p[i] < p[i+1]:
            count += 1
            continue
        if p[i-1] > p[i] and p[i] > p[i+1]:
            count += 1
            continue

    return count
print(calc(input(), list(input().split())))

Submission status: Runtime Error

Solution code:
a=int(input())
li = list(map(int,input().split()))	
count = 0
for i in range(1:a):
  if li[i-1]<li[i] and li[i]<li[i+1]:
    count += 1
  else:
    pass
print(count)

Submission status: Runtime Error

Solution code:
long = int(input())
p = input()
plng = []
pstr = p.split(" ")
n = 0

for i in range(long):
    plng.append(int(pstr[i]))


for i in range(long-2):
    three = [plng[i],plng[i+1],plng[i+2]]
    three.sort()

    if three[1] == plng[i + 1]:
     n = n +　1

print(n)

Submission status: Runtime Error

Solution code:
n = int(input())
#L =list(map(int,input().split))
L = [input() for i in range(n)]
f = 0

for i in range(1,n-2):
    if L[i-1]<L[i]<L[i+1] or L[i-1]>L[i]>L[i+1] :
        f =f + 1
    else :
        f = f   
    i = i + 1

print(f)

Submission status: Runtime Error

Solution code:
long = int(input())
p = input()
plng = []
pstr = p.split(" ")
n = 0

for i in range(long):
    plng.append(int(pstr[i]))

print(plng)

for i in range(long-2):
    three = [plng[i],plng[i+1],plng[i+2]]
    three.sort()

    if three[1] == plng[i + 1]:
     n = n +　1

print(n)

Submission status: Runtime Error

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

a = 9999
b = 9999
c = 9999
cnt = 0

for i in range(n):
	c = pn[i]
	if i >= 2
		if (a<b and b<c) or (c<b and b<a) or (a==b and b>c) or (b==a and b>c)or(a==c and b>a):
			cnt += 1
	a = b
	b = c

print(cnt)

Submission status: Runtime Error

Solution code:
n = input()
nums = input().split()

cnt=0

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

Submission status: Runtime Error

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

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

print(a)

Submission status: Runtime Error

Solution code:
N = int(input())
P = list(input().split())
cnt = 0
for n in range(1,N-1):
     if P[n-1] < P[n] and P[n] < P[n+1]:
        cnt += 1
    elif P[n-1] > P[n] and P[n] > P[n+1]:
        cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
count=0

su_list = input().split()
for i  in range(1,len(su_list)-1):
    if su_list[i-1]<= su_list[i] and su_list[i] < su_list[i+1] or su_list[i-1] > su_list[i] and su_list[i]=>su_list[i+1]:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
N = input()
D = map(int, raw_input().split())

cnt=0
lop=0

while lop<N-2:
  if max(D[lop],D[lop+1],D[lop+2])!=D[lop+1] and min(D[lop],D[lop+1],D[lop+2])!=D[lop+1]:
    cnt=cnt+1
  else:
  lop=lop+1
print (cnt)

Submission status: Runtime Error

Solution code:
#include <iostream>
using namespace std;

bool submin(int a, int b, int c) {
    if (a < b && b < c || c < b && b < a) return true;
    else return false;
}

int main() {
    int n;
    cin >> n;
    int p[n];
    int cnt = 0;

    for (int i = 0;i < n;i++) cin >> p[i];
    for (int i = 1;i < n-1;i++) {
        if (submin(p[i-1], p[i], p[i+1])) cnt++;
    }

    cout << cnt << endl;
}

Submission status: Runtime Error

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

a = len(d)/2
l = d[a+1] - d[a]

print(l)

Submission status: Runtime Error

Solution code:
s = sorted(input())

if s[0] == s[1] and s[2] == s[3] and s[0] != s[2]:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
from sys import stdin


def main():
    n = int(input())

    p = stdin.readline().split()
    count = 0

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


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include<stdio.h>

int main(void){
  int i,n,count=0;
  scanf("%d\n",&n);
  int p[n];
  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
  }

  for(i=0;i<n-1;i++){
    if((p[i]<p[i+1])&&(p[i+1]<p[i+2])){
      count+=1;
    }
    else if((p[i]>p[i+1])&&(p[i+1]>p[i+2])){
      count+=1;
    }
  }

  printf("%d\n",count);

  return 0;
}

Submission status: Runtime Error

Solution code:
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
%matplotlib inline

#{1, 2, ..., n} の順列 p = {p1,p2, ..., pn } があります。
#以下の条件を満たすような pi (1<i<n) がいくつあるかを出力してください。
#pi−1, pi, pi+1 の 3 つの数の中で、pi が 2 番目に小さい。

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

Submission status: Runtime Error

Solution code:
n=int(input())
p=[]
count=0
for i in range(n):
    p.append(int(input()))
for i in range(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)

Submission status: Runtime Error

Solution code:
n=input()
if n>20 or n<2:
  print(0)
else:
  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]):
          count+=1
          break
      if(S[i-1]>S[i] and S[i+1]<S[i]):
          count+=1
  print(count)

Submission status: Runtime Error

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

count = 0

for i in range(1,len(p)-1):
  if s[i] == max(min(s[i-1],s[i]),min(s[i],s[i+1])):
    count += 1
    
    
print(count)

Submission status: Runtime Error

Solution code:
ソースコード 拡げる

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

Submission status: Runtime Error

Solution code:
N=input()
P=[int(i) for i in input().split()]
mes=[]

for i in range(len(P)):

	if i!=1 and i!=N-1:
		if (P[i+1]<P[i] and P[i+1]<=P[i-1]) or (P[i+1]<P[i] and P[i+1]<=P[i-1]):
			mes+=mes+P[i]

for n in mes:
	print(mes[n])

Submission status: Runtime Error

Solution code:
N = [int(i) for i in input().split()][0]
P = [i for i in input().split()]

count=0
for i in range(0,N-2):
  tmp = [P[i],P[i+1],P[i+2]]
  tmp.sort()
  if P[i+1]==tmp[1]:
    count+=1
  if tmp[0]==tmp[1] or tmp[1]=tmp[2] or tmp[0]==tmp[2]:
    count+=1

print(count)

Submission status: Runtime Error

Solution 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.index(m)
  if min(lst)==P:
    cnt+=1
print(cnt)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
nump = input().split()
nump = [int(i) for i in nump]

count = 0
for i in range(1,8):
  p = nump[i]
  tmp = sorted([nump[i-1],nump[i],nump[i+1]])
  if tmp[1] == p:
    count+=1
print(count)

Submission status: Runtime Error

Solution code:
def code_for_B(test=None):

    n = int(input)
    list_p = list(map(int, input().split()))
    
    pre = list_p[0]
    count = 0

    for i in range(1,n-1):
        cur = list_p[i]
        nxt = list_p[i+1]
        
        if pre >= cur > nxt:
            count += 1
        elif pre < cur < nxt:
            count += 1
        
        pre, cur = cur, nxt

    print(count)

code_for_B()

Submission status: Runtime Error

Solution code:
N=input()
P=[int(i) for i in input().split()]
mes=[]

for i in range(len(P)):

	if i!=1 and i!=N-1:
		if (P[i+1]<P[i] and P[i+1]<=P[i-1]) or (P[i+1]<P[i] and P[i+1]<=P[i-1]):
			mes+=mes+P[i]

for n in mes:
	print(mes)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
nump = input().split()
nump = [int(i) for i in nump]

count = 0
for i in range(1,8):
  p = nump[i]
  tmp = sorted([p[i-1],p[i],[i+1]])
  if tmp[1] == p:
    count+=1
print(count)

Submission status: Runtime Error

Solution code:
n = int(input())

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

count = 0

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

Submission status: Runtime Error

Solution code:
n = int(input())

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

count = 0

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

Submission status: Runtime Error

Solution code:
N = int(input())
nump = input().split()
nump = [int(i) for i in nump]

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())

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

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

Submission status: Runtime Error

Solution code:
n = int(input())

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

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

Submission status: Runtime Error

Solution code:
S = input()
if (S[0] == S[1] and S[2] == S[3] and S[0] != S[2]) or (S[0] == S[2] and S[1] == S[3] and S[0] != S[3]) or (S[0] == S[3] and S[1] == S[2] and S[0] != S[1]):
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#!/usr/bin/python3

import sys
from typing import List

def min2nd(ls: List[int]):
    return sorted(ls)[1]

def solve(input: List[int]):
    count = 0
    for i in range(0, len(input) - 2):
        slice_ = input[i:i+3]
        if slice_[1] == min2nd(slice_):
            count += 1
    return count

def main():
    sys.stdin.readline()
    inputs = [int(s) for s in sys.stdin.readline().rstrip().split(" ")]
    print(solve(inputs))

main()

Submission status: Runtime Error

Solution code:
N = int(input())
P = [map(int, input().split())]

c = 0
for i in range(N-2):
  if P[i] < P[i+1] <= P[i+2]:
    c += 1
  elif P[i+2] < P[i+1] <= P[i]:
    c += 1
  else:
    pass
  
print(c)

Submission status: Runtime Error

Solution code:
N = int(input())
P = [map(int, input.split())]

c = 0
for i in range(N-2):
  if P[i] < P[i+1] <= P[i+2]:
    c += 1
  elif P[i+2] < P[i+1] <= P[i]:
    c += 1
  else:
    pass
  
print(c)