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:
import numpy as np
import math
cnt = 0
n = int(input())
if n<=20 and n>=3:
    p = list(range(1, n))
    p_ = np.random.permutation(p)
    print(p_)
    for i in range(n-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]:
            cnt+=1
print(cnt)

Submission status: Wrong Answer

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

a=sorted(li)

print(a[1])

Submission status: Wrong Answer

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

a=sorted(li)

print(a[1])

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 sorted(p[i-1:i+1]).index(p[i]) == 1:
        count += 1

print(count)

Submission status: Wrong Answer

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
  except IndexError:
    pass
  finally:
   print(ans)
solve()

Submission status: Wrong Answer

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

for i in range(n):
    p[i] = int(p[i])

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

print(ans)

Submission status: Wrong Answer

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

for i in range(n):
    p[i] = int(p[i])

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

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
P_list = list(map(int,(input().split(" "))))
#print(P_list)
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(n)
#print(P_list)
print(count)

Submission status: Wrong Answer

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

#print(n)
#print(P_list)
print(count)

Submission status: Wrong Answer

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

#print(n)
#print(P_list)
print(count)

Submission status: Wrong Answer

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

print(n)
print(P_list)
print(count)

Submission status: Wrong Answer

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

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

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)

Submission status: Wrong Answer

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

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

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)

Submission status: Wrong Answer

Solution code:
ss = input()
s = int(ss)
nums = input().split()
type(nums)
type(nums[0])
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)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
num = input().split()
 
count = 0
 
for i in range(N-2):
  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: Wrong Answer

Solution code:
N = int(input())
num = input().split()
 
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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
num = [int(i) for i in range(N)]

count = 0

for i in range(N-2):
  num_ = num[i:i+3]
  if max(num_) != num_[1] and min(num_) != num_[1]:
    count += 1

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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]:
        num = num+1 
    else: 
        pass

print(num)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = input().split()
C = 0
for i in range(1, N - 1):
    C += 1 if sorted(L[i-1:i+2])[1] == L[i] else 0
print(C)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = input().split()
C = 0
for i in range(1, N - 1):
    if L[i - 1] > L[i + 1] and L[i - 1] > L[i] and L[i] > L[i + 1]:
        C += 1
    elif L[i + 1] > L[i - 1] and L[i + 1] > L[i] and L[i] > L[i - 1]:
        C += 1
print(C)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = input().split()
C = 0
for i in range(1, N - 2):
  C += 1 if sorted(L[i-1:i+1])[1] == L[i] else 0
print(C)

Submission status: Wrong Answer

Solution code:
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]:
      	count += 1
    elif listP[i] > listP[i+1] and listP[i+1] > listP[i+2]:
        count += 1
    else:
        count += 0

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = []
count = 0
for i in range(len(A)-2):
  a = ''
  for j in range(i,i+3):
    a += str(A[j])
  ans.append(a)
for k in range(len(ans)):
  if ans[k][0] < ans[k][1] < ans[k][2] or ans[k][0] > ans[k][1] > ans[k][2]:
    count += 1
print(count)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

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

print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
list_A = list(map(int,input().split()))
 
ans = 0
for i in range(N-3):
  if list_A[i+1] > list_A[i] and list_A[i+1] < list_A[i+2]:
    ans+=1
  if list_A[i+1] < list_A[i] and list_A[i+1] > list_A[i+2]:
    ans+=1
  else:
    pass
 
print(ans)

Submission status: Wrong Answer

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

c = 0
i = 1
while i < n-1:
  if p[i] < p[i-1] and p[i] > p[i+1]:
    c = c +1
    i=i+1
    continue
  if p[i] > p[i-1] and p[i] < p[i+1]:
    c = c +1
    i=i+1
    continue
  i=i+1

print(c)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
  
  z = int(input())
  if 20 >= z and z >= 3:
    num_list = list(map(int, input().strip().split()))
    count = 0
    for i in range(len(num_list)-3):
      hoge = num_list[i:i+3]
      hoge_sort = sorted(hoge)
      if hoge[1]==hoge_sort[1]:
        count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
  
  z = int(input())
  if 20>= z >=3:
    num_list = list(map(int, input().strip().split()))
    count = 0
    for i in range(len(num_list)-3):
      hoge = num_list[i:i+3]
      hoge_sort = sorted(hoge)
      if hoge[1]==hoge_sort[1]:
        count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
  z = int(input())
  num_list = list(map(int, input().strip().split()))
  count = 0
  for i in range(len(num_list)-3):
    hoge = num_list[i:i+3]
    hoge_sort = sorted(hoge)
    if hoge[1]==hoge_sort[1]:
      count += 1
  print(count)

Submission status: Wrong Answer

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

cnt = 0
for n in range(1, len(p) - 1):
    print("p[n-1]={}  p[n]={}  p[n+1]={}".format(p[n - 1], p[n], p[n + 1]))
    print("------------------")
    if p[n - 1] > p[n + 1]:
        if p[n - 1] > p[n] and p[n] > p[n + 1]:
            print("True")
            cnt = cnt + 1
    elif p[n - 1] < p[n] and p[n] < p[n + 1]:
        cnt = cnt + 1
        print("True")
    print("\n")
print(cnt)

Submission status: Wrong Answer

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

print(n,p)
count=0

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

print(count)

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

index = 0
count = 0
while index < n - 2:
    mini_list = nums[index:index + 3]
    print(mini_list)
    if mini_list[1] == sorted(mini_list)[1]:
        count += 1
    index += 1
print(count)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

def check(i,j,k):
    if i < j < k:
        return True
    elif k < j < i:
        return True
    else:
        return False

def ordinary_number(n, array):
    r = 0
    for i in range(1, n-1):
        if check(array[i-1],array[i],array[i+1]):
            r += 1
    return r

n = int(input())
a = list(input().replace(' ',''))

print(ordinary_number(n, a))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

def check(i,j,k):
    if i < j <= k:
        return True
    elif k < j <= i:
        return True
    else:
        return False

def ordinary_number(n, array):
    r = 0
    for i in range(1, n-1):
        if check(array[i-1],array[i],array[i+1]):
            r += 1
    return r

n = int(input())
a = list(input().replace(' ',''))

print(ordinary_number(n, a))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

def check(i,j,k):
    if i < j and j < k:
        return True

def ordinary_number(n, array):
    r = 0
    for i in range(1, n-1):
        if check(array[i-1],array[i],array[i+1]):
            r += 1
    return r

n = int(input())
a = list(input().replace(' ',''))
print(ordinary_number(n, a))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

def check(i,j,k):
    print(i,j,k)
    if i < j and j < k:
        return True

def ordinary_number(n, array):
    r = 0
    for i in range(1, n-1):
        if check(array[i-1],array[i],array[i+1]):
            r += 1
    return r

n = int(input())
a = list(input().replace(' ',''))
print(ordinary_number(n, a))

Submission status: Wrong Answer

Solution code:
n=int(input())

p=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)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())

p=input().split()

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

print(A)

Submission status: Wrong Answer

Solution code:
n=int(input())

p=input().split()

A=0

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

print(A)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    n = int(raw_input())

    num = map(int,raw_input().split())
    cnt = 0
    print(num)
    for i in range(n - 2):
        if num[i] < num[i+1] and num[i+1] < num[i+2]:
            cnt += 1
        if num[i] > num[i+1] and num[i+1] > num[i+2]:
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
p = input().split()
i = 1
result = 0
for x in p:
  if (i+1)<n:
    sorted_p = sorted([p[i-1],p[i],p[i+1]])
    if sorted_p[1] == p[i]:
      result+=1
    i+=1
print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
input()
p = input().split()
print(sum([p[i] == sorted(p[i - 1:i + 2])[1] for i in range(1, len(p) - 1)]))

Submission status: Wrong Answer

Solution code:
n = int(input().rstrip())
p = [int(x) for x in input().rstrip().split()]

print(p)

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

Submission status: Wrong Answer

Solution code:
n = input()
p = []
input_first = input()
for ki in range(int(n)):
    p = input_first.rstrip().split(' ')
count = 0
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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

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

print(cnt)

Submission status: Wrong Answer

Solution code:
k = int(input())

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

print(cnt)

Submission status: Wrong Answer

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

print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections

n = int(input()) 
t = input().split(' ')
c = 0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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 (t[i] >= t[i-1] and t[i] <= t[i+1]) \
  or (t[i] <= t[i-1] and t[i] >= t[i+1]) \
  and (not t[i] == t[i-1] and not t[i] == t[i+1]):
    c = c + 1
    
print(c)

Submission status: Wrong Answer

Solution code:
import collections

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 (t[i] >= t[i-1] and t[i] <= t[i+1]) \
  	or (t[i] <= t[i-1] and t[i] >= t[i+1]) \
    or (not t[i] == t[i-1] and not t[i] == t[i+1]):
    c = c + 1
    
print(c)

Submission status: Wrong Answer

Solution code:
import collections

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 (t[i] >= t[i-1] and t[i] <= t[i+1]) \
  	or (t[i] <= t[i-1] and t[i] >= t[i+1]) \
    or not (t[i] == t[i-1] and t[i] == t[i+1]):
    c += 1
    
print(c)

Submission status: Wrong Answer

Solution code:
import collections

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

Submission status: Wrong Answer

Solution code:
import collections

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

Submission status: Wrong Answer

Solution code:
import collections

n = int(input()) 
t = input().split(' ')
c = 0

for i in range(1, n-1):
  l = [t[i-1], t[i], t[i+1]]
  l.sort()
  if l.index(t[i]) == 1:
    c += 1
    
print(c)

Submission status: Wrong Answer

Solution code:
inp0=input()
inp=[int(x) for x in input().split(" ")]
 
ans=0
for index in range(1,len(inp)-1):
  a =sorted([inp[index-1],inp[index],inp[index+1]])
  chk =list(set(a))
  if not len(chk)==1:
    if inp[1]==a[1]:
      ans =ans+1
print(ans)

Submission status: Wrong Answer

Solution code:
inp0=input()
inp=[int(x) for x in input().split(" ")]

ans=0
for index in range(1,len(inp)-1):
  a =sorted([inp[index-1],inp[index],inp[index+1]])
  if inp[1]==a[1]:
    ans =ans+1
print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
import math
def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft



def main():
    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] <= p[i]:
            ans += 1

    print(ans)
main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(2, n):
    tmp = plist[i - 1:i + 2]
    tmpsorted = sorted(tmp, reverse=True)
    if tmp[1] == tmpsorted[1]:
        counter += 1

print(counter)

Submission status: Wrong Answer

Solution code:
n = int(input())

p_list = [int(p) for p in input().split()]

c = 0
for i, p in enumerate(p_list[1:]):
    p_1 = p_list[i-1]
    p_2 = p_list[i]
    p_3 = p_list[i+1]

    if p_1 <= p_2 <= p_3 or p_3 <= p_2 <= p_1:
        c += 1
        #print(i,c)                                                                      

print(c)

Submission status: Wrong Answer

Solution code:
n = int(input())

p_list = [int(p) for p in input().split()]

c = 0
for i, p in enumerate(p_list[1:]):
    p_1 = p_list[i-1]
    p_2 = p_list[i]
    p_3 = p_list[i+1]

    if p_1 < p_2 < p_3 or p_3 < p_2 < p_1:
        c += 1
        #print(i,c)                                                                      

print(c)

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

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: Wrong Answer

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

for i in range(1, n-1):
    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: Wrong Answer

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

for i in range(1, n-1):
    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: Wrong Answer

Solution code:
n = int(input())
p = input().split(' ')
for i in p:
  i = int(i)
count = 0
for i in range(len(p)-2):
    list = [p[i], p[i+1], p[i+2]]
    list = sorted(list)
    if p[i+1] == list[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):
	if p[i]>p[i-1] and p[i]<p[i+1]:
		count+=1
print('{}'.format(count))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = input()
Ns = input()
numbers = Ns.split()

ans = 0
for a in range(len(numbers)-2):
    n1 = numbers[a]
    n2 = numbers[a +1]
    n3 = numbers[a +2]
    if n1 < n2 < n3 or n3 < n2 < n1:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
N = input()
Ns = input()
numbers = Ns.split()

ans = 0
for a in range(len(numbers)-2):
    n1 = numbers[a]
    n2 = numbers[a +1]
    n3 = numbers[a +2]
    if n1 < n2 < n3 or n3 < n2 < n1:
        ans += 1
    a += 1

print(ans)

Submission status: Wrong Answer

Solution code:
N = input()
Ns = input()
numbers = Ns.split()

a = 2
ans = 0
for a in range(len(numbers)-2):
    n1 = numbers[a]
    n2 = numbers[a +1]
    n3 = numbers[a +2]
    if n1 < n2 < n3 or n3 < n2 < n1:
        ans += 1
    a += 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
_ = int(input())
input_arr = [int(x) for x in input().split()]

for i_ in range(len(input_arr)-2):
    arr_list = [input_arr[i] for i in range(i_,i_+3)]
    sorted_arr = sorted(arr_list)
    if sorted_arr[1] == arr_list[1]:
        print("Yes")

Submission status: Wrong Answer

Solution code:
def counting(numbers) -> int:
    count = 0
    for i in range(1, len(numbers) - 1):
        pre = numbers[i-1]
        curr = numbers[i]
        next_ = numbers[i+1]
        if pre < curr < next_:
            count += 1
    return count
 
_ = input()
numbers_str = input()
result = counting([int(c) for c in numbers_str.split(' ')])
print(result)

Submission status: Wrong Answer

Solution code:
def counting(numbers) -> int:
    count = 0
    for i in range(1, len(numbers) - 1):
        pre = numbers[i-1]
        curr = numbers[i]
        next_ = numbers[i+1]
        if pre < curr < next_:
            count += 1
    return count
 
_ = input()
numbers_str = input()
result = counting(numbers_str.split(' '))
print(result)

Submission status: Wrong Answer

Solution code:
def prob_b():
    n = int(input())
    p_list = [int(a) for a in input().split()]
    ans = 0
    for i in range(n - 2):
        if min(p_list[i], p_list[i+2]) < p_list[i+1] < max(p_list[i], p_list[i+2]):
            ans += 1
    return ans

prob_b()

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

Submission status: Wrong Answer

Solution code:
n = int(input())
p = [int(x) for x in input().split()]
count = 0
for i in range(1,n-1):
  sor = sorted(p[i-1:i+2])
  print(sor)
  if p[i] == sor[1]:
    count += 1

print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
p = [int(x) for x in input().split()]
count = 0
for i in range(1,n):
  sor = sorted(p[i-1:i+2])
  if p[i] == sor[1]:
    count += 1

print(count)

Submission status: Wrong Answer

Solution code:
#https://atcoder.jp/contests/abc132/tasks/abc132_b

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

cnt = 0
for i in range(1,n-1):
    q = [p[i-1],p[i],p[i+1]]
    q.sort()
    if p[i] == q[1]:
        print('y')
        cnt += 1

print(cnt)

Submission status: Wrong Answer

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]:
#     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] or \
#        lst[1][i] == lst[1][i+2] > lst[1][i+1]:
    cnt += 1
    
print(cnt)

Submission status: Wrong Answer

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] or \
        lst[1][i] == lst[1][i+2] < lst[1][i+1]:
    cnt += 1
    
print(cnt)

Submission status: Wrong Answer

Solution code:
_,p=open(0);p=p.split();print(sum(sorted(a)[1]==a[1]for a in zip(p,p[1:],p[2:])))

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] 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: Wrong Answer

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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

Solution code:
n=int(input())
p=list(map(int,input().split()))
print(n)
print(p)
a=0
i=1

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)
    #sumir=vie(i)+sumir
#print("")
#print(sumir)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
size=input()
P=input()

p=P.split(" ")

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

print(counter)

Submission status: Wrong Answer

Solution code:
import numpy as np

size=input()
pro=input()

p=np.array(pro.split(" "),dtype=np.int32)
p=np.sort(p)

me=int(len(p)/2)

print(p[me]-p[me-1])

Submission status: Wrong Answer

Solution code:
import numpy as np

size=input()
pro=input()

p=np.array(pro.split(" "),dtype=np.int32)
p=np.sort(p)

me=int(len(p)/2)+1

print(p[me]-p[me-1])