TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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}.

Submission attempts (in order):
n = int(input())
p = input().split()

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

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

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

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

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

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

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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
n = int(input())
p = list(map(int, input().split()))

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

print(c)
  

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

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

print(c)
  

Verdicts: Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):
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)

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

Verdicts: Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):
n=int(input())
a=list(map(int,input().split()))
print (a)
count=0
for i in range(1,n-1):
    if a[i-1]<a[i]and a[i]<a[i+1] or a[i-1]>a[i]and a[i]>a[i+1]:
        count+=1
print(count)

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

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
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)


n=int(input())
b=list(map(int,input().split()))
c=0
d=0
while c<=n-3 :
    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)


Verdicts: Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):
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)

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)

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

print(c)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
# 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)

import math
num = input()
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)
            

Verdicts: Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
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)

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

Verdicts: Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
import sys

input = sys.stdin.readline

def main():
    ans = 0
    n = int(input())
    d = list(map(int, input().split()))
    d.sort()
    ans += d[n//2] - d[n//2-1]
    print(ans)

if __name__ == '__main__':
    main()

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

ans = 0
n = int(input())
a = list(map(int, input().split()))
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]:
    ans += 1
print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
n = int(input())
count=0

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

n = int(input())
count=0

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

n = int(input())
count=0

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
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))

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



Verdicts: Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
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)


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

sum = 0

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

print(sum)


Verdicts: Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
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])


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

import numpy as np

size=input()
P=input()

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

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)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
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)

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)


Verdicts: Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):
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)

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

Verdicts: Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
n = int(input())
pis = list(map(int, input().split()))
m = 0
for i in range(n-2):
  if p[i] < p[i+1] < p[i+2] or p[i+2] < p[i+1] < p[i]:
    m += 1
print(m)

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

Verdicts: Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):
N, *L,  = [list(map(int, s.split())) for s in open(0)]
A = L[0]
p
cnt = 0
for i in range(len(A) - 2):
    ma = max(A[i], A[i+1], A[i+2])
    mi = min(A[i], A[i+1], A[i+2])
    if A[i+1] not in [ma, mi]:
        cnt += 1
print(cnt)

def main():
    _ = input()
    A = list(map(int, input().split()))
    cnt = 0
    for i in range(len(A)-2):
        A_sub = sorted(A[i:i+3])
        a = A[i+1]
        if a == A_sub[1]:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()


Verdicts: Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):
n = int(input())
P = [int(x) for x in input().split()]
cnt = 0
for i in range(1, n - 1):
  if p[i - 1] < p[i] and p[i + 1] < p[i]:
    continue
  if p[i] < p[i - 1] and p[i] < p[i + 1]:
    continue
  cnt += 1
print(cnt)

n = int(input())
P = [int(x) for x in input().split()]
cnt = 0
for i in range(1, n - 1):
  if P[i - 1] < P[i] and P[i + 1] < P[i]:
    continue
  if P[i] < P[i - 1] and P[i] < P[i + 1]:
    continue
  cnt += 1
print(cnt)

Verdicts: Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):
    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)
    

import sys
n = int(sys.stdin.readline())
p = list(int(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)

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)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):

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

count = 1

for i in range(n-2):
    num_id = i+1
    temp = [num_list[num_id-1], num_list[num_id], num_list[num_id+1]]
    list_sorted = sorted(temp)

    if list_sorted[1] == num_list[num_id]:
        count += 1

print(count)



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

count = 0

for i in range(n-2):
    num_id = i+1
    temp = [num_list[num_id-1], num_list[num_id], num_list[num_id+1]]
    list_sorted = sorted(temp, reverse=True)
    print(temp)
    if list_sorted[1] == num_list[num_id]:
        count += 1


print(count)



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

count = 0

for i in range(n-2):
    num_id = i+1
    temp = [num_list[num_id-1], num_list[num_id], num_list[num_id+1]]
    list_sorted = sorted(temp)
    print(temp)
    if max(temp) != num_list[num_id] and (min(temp) != num_list[num_id]):
        count += 1


print(count)



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

count = 0

for i in range(n-2):
    num_id = i+1
    temp = [num_list[num_id-1], num_list[num_id], num_list[num_id+1]]
    list_sorted = sorted(temp)
    print(num_list[num_id])
    print(temp)
    if list_sorted[1] == num_list[num_id]:
        count += 1

print(count)



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

count = 0

for i in range(n-2):
    num_id = i+1
    temp = [num_list[num_id-1], num_list[num_id], num_list[num_id+1]]
    list_sorted = sorted(temp, reverse=True)
    if list_sorted[1] == num_list[num_id]:
        count += 1


print(count)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
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)

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

Verdicts: Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
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)

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

Verdicts: Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
n=int(input())
p=list(map(int,input().split()))
print(p)
c=0
for i in range(1,n-1):
       if (p[i]-p[i-1])*(p[i+1]-p[i])>0:
                         c=c+1
print(c)

n=int(input())
p=list(map(int,input().split()))
c=0
for i in range(1,n-1):
       if (p[i]-p[i-1])*(p[i+1]-p[i])>0:
                         c=c+1
print(c)

Verdicts: Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
p = list(map(int,input().split()))
res = 0
for i, num in enumerate(p):
	if(1 <= i and i <= (len(p) - 2)):
		li = [p[i-1],p[i],p[i + 1]]
		li.sort()
		if((p[i-1] != p[i + 1]) and (p[i-1] != p[i]) and (p[i] != p[i + 1]) and (li[1] == p[i])):
			res = res + 1
print(res)

p = list(map(int,input().split()))
res = 0
for i, num in enumerate(p):
	if(1 <= i and i <= (len(p) - 1)):
		li = [p[i-1],p[i],p[i + 1]]
		li.sort()
		if((p[i-1] != p[i]) and (p[i] != p[i + 1]) and (li[1] == p[i])):
			res = res + 1
print(res)

p = list(map(int,input().split()))
res = 0
for i, num in enumerate(p):
	if(1 <= i and i <= (len(p) - 2)):
		li = [p[i-1],p[i],p[i + 1]]
		li.sort()
		if((p[i-1] != p[i]) and (p[i] != p[i + 1]) and (li[1] == p[i])):
			res = res + 1
print(res)

p = list(map(int,input().split()))
res = 0
for i, num in enumerate(p):
	if(len(p) < 3):
		break
	if(1 <= i and i <= (len(p) - 2)):
		li = [p[i-1],p[i],p[i + 1]]
		li.sort()
	if(li[1] == p[i]):
		res = res + 1
print(res)


n = input()
p = list(map(int,input().split()))
res = 0
for i, num in enumerate(p):
	if(1 <= i and i <= (len(p) - 2)):
		li = [p[i-1],p[i],p[i + 1]]
		li.sort()
		if((p[i-1] != p[i + 1]) and (p[i-1] != p[i]) and (p[i] != p[i + 1]) and (li[1] == p[i])):
			res = res + 1
print(res)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
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)


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


print(count)


Verdicts: Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
n, a* = map(int, open(0).read().split())
t = 0
for i in range(1, n-1):
  if sorted([i-1:i+2]).index(a[i]) == 1:
    t += 1
print(t)

n, a* = map(int, open(0).read().split())
t = 0
for i in range(1, n-1):
  if sorted(a[i-1:i+2]).index(a[i]) == 1:
    t += 1
print(t)

n = int(input())
a = list(map(int, input().split()))
t = 0
for i in range(1, n-1):
  if sorted(a[i-1:i+2]).index(a[i]) == 1:
    t += 1
print(t)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):
n = int(input())
number = list(map(int, input().split()))
count = 0
for i in range(1, len(number)-1):
    if((number[i] > number[i-1]) & (number[i] < number[i+1])):
        count += 1
print(count)

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

Verdicts: Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
#ABC 132 B
n = int(input())
p= [int(j) for j in input().split()]
ans =0
for i in range(0,n-3+1):
    if p[i:i+3][1] ==sorted(p[i:i+3])[1]:
        ans+=1
        print(p[i:i+3])
print(ans)  

#ABC 132 B
n = int(input())
p= [int(j) for j in input().split()]
ans =0
for i in range(0,n-3+1):
    if p[i:i+3][1] ==sorted(p[i:i+3])[1]:
        ans+=1
        
print(ans)  

Verdicts: Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
n=input()
p=list(map(int,input().split()))
a = 0
for i in range(n-2):
    a += 1*(0<((p[i] < p[i+1])*(p[i+1] < p[i+2])))
print(a)

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

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

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

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):
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)


n = int(input())
P = list(map(int, input().split()))
count = 0
for i in range(n-2):

    P_temp = [P[i], P[i+1], P[i+2]]
    P_temp.sort()
    if P_temp[1] == P[i+1]:
        count = count + 1

print(count)


Verdicts: Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
a=map(int, input().split())
b=list(a)
c=len(b)

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

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




a=map(int, input().split())
b=list(a)
c=len(b)

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




x=map(int, input())
a=map(int, input().split())
b=list(a)
c=len(b)

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

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



Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
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))


n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(n):
    r = p[i:i+3]
    if len(r) == 3:
        if max(r) > r[1] and r[1] > min(r):
            count += 1
print(str(count))


Verdicts: Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
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)

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)

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)

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)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):
n = int(input())
p = list(map(int,input().split()))
count=0

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

print(count)

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

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

print(count)

Verdicts: Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
# -*- coding: utf-8 -*-
import sys

n = int(input())
s = [int(c) for c in input()]

count = 0

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

print(count)

# -*- coding: utf-8 -*-
import sys

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

count = 0

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

print(count)

Verdicts: Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):
n=int(input())
p=list(map(int,input().split()))
print(p)

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

print(c)

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

print(c)

Verdicts: Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(1,n-1):
  if a[i]<a[i+1] and a[i+1]<a[i+2]:
    c+=1
print(c)

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


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

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):
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 m
  if min(lst)==P:
    cnt+=1
print(cnt)


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

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)


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


Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):
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)

n = int(input())
p_list = list(map(int, input().split()))
ans = 0
for i in range(1, n-1):
    mini_list = p_list[i-1:i+2]
    sorted_mini_list = sorted(mini_list)
    if mini_list[1] == sorted_mini_list[1]:
        ans += 1

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
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())))

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(int(input()), [int(a) for a in input().split()]))

Verdicts: Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):
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)

n=int(input())
l = list(map(int,input().split()))
sum=0
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)

Verdicts: Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
n = int(input())
A = list(map(int, input().split()))

cnt = 0

for num in range(0, n-2):
  print(num)
  if A[num+1] > A[num] and A[num+1] < A[num+2]:
    cnt += 1
    print(num+1, num, num+2)
  elif A[num+1] < A[num] and A[num+1] > A[num+2]:
    cnt +=1

print(cnt)

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

cnt = 0

for num in range(0, n-2):
  print(num)
  if A[num+1] > A[num] and A[num+1] < A[num+2]:
    cnt += 1
  elif A[num+1] < A[num] and A[num+1] > A[num+2]:
    cnt +=1

print(cnt)

I = int(input())
L = list(map(int, input().split()))

cnt = 0

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

print(cnt)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
n = int(input())
p = list(map(int, input().split()))

a = 0

for i in range(n - 1):
  p_l = [p[i], p[i + 1], p[i + 2]]
  p_l2 = sorted(p_l)
  if p_l2[1] == p_l[1]:
    a += 1
    
print(int(a))

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

a = 0

for i in range(n - 2):
  p_l = [p[i], p[i + 1], p[i + 2]]
  p_l2 = sorted(p_l)
  if p_l2[1] == p_l[1]:
    a += 1
    
print(int(a))

Verdicts: Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):
n = int(input())
p = list(map(int, input().split()))

count = 0
for i in range(1, n-2):
    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)

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
    elif (p[i] > p[i-1]) and (p[i] < p[i+1]):
        count += 1

print(count)


Verdicts: Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
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)


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)


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


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


Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):
n=int(input())
p=map(int,input().split())
count=0
for i in range(0,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]):
        count += 1
print(count)

n=int(input())
p=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]) or (p[i]>p[i+1] and p[i+1]>p[i+2]):
        count += 1
print(count)


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

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):
n=int(input())
p=list(map(int,input().split()))

count=0

for i in range(n-2):
    print(q)
    if q[1]==p[i+1]:
        count+=1

print(count)

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

count=0

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

print(count)

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

count=0

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

print(count)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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}.

Submission attempts (in order):
n = int(input())
p = [int(i) for i in input().split()]

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

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

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

Verdicts: Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):
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)

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)


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

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

print(counter)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):
n = int(input())
p = list(map(int,input().split()))
m=0

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

    
print(m)



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

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

    
print(m)



n = int(input())
p = list(map(int,input().split()))
m=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]):
    m +=1
  else:
    m +=0

    
print(m)



Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):
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)    

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

Verdicts: Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):
n = int(input())
a = list(map(int ,input().split()))
cnt = 0
for i in range(1, n-1):
  if(max(a[i-1:i+1]) != a[i] and min(a[i-1:i+1] != a[i]):
     cnt += 1
print(cnt)

n = int(input())
a = list(map(int ,input().split()))
cnt = 0
for i in range(1, n-1):
  hoge = [a[i-1], a[i], a[i+1]]
  if(max(hoge) != a[i] and min(hoge) != a[i]):
     cnt += 1
print(cnt)

Verdicts: Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):
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)

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)

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

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):
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)

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)

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)


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)


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
     if L[i+2]<L[i+1] and L[i+1]<L[i]:
             Answer = Answer + 1
print(Answer)


Verdicts: Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):
n = int(input())
p = list(map(int, input().split()))

ans = 0


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

print(ans)

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

ans = 0


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

print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):
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)

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)

Verdicts: Runtime Error

Accepted
Problem: 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}.

Submission attempts (in order):
n = int(input())
p = list(map(int,input().split()))
count=0
if n == 3:
  if p[0] < p[1] < p[2] or p[2] < p[1] < p[0]:
    count+=1
else:
  for i in range(n-2):
    pp = p[0+i:3+i]
    if pp[0] < pp[1] < pp[2] or p[2] < p[1] < p[0]:
      count+=1
print(count)


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

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] or p[i+1] < p[i] < p[i-1]:
    count+=1
print(count)

Verdicts: Wrong Answer

Wrong Answer

Accepted