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):
# ordinary number
n = int(input())
list = [int(i) for i in input().split(' ')]
print(n,list)
ans = 0
for i in range(1,n-1):
	tmp = list[i-1:i+2]
	tmp.sort()
	print(tmp)
	if tmp[0] != list[i] and  tmp[1] == list[i]:
		ans = ans + 1
print(ans)


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


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):
input()
a=list(map(int,input().split()))
b=0
for i in range(1,len(a)-1):
  b+=a[i-1]<i and i<a[i+1]
  b+=a[i-1]>i and i>a[i+1]
print(b)

input()
a=list(map(int,input().split()))
b=0
for i in range(1,len(a)-1):
  b+=a[i-1]<a[i] and a[i]<a[i+1]
  b+=a[i-1]>a[i] and a[i]>a[i+1]
print(b)

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()))
cnt = 0
for i in range(1, n-3+2):
    print(i, p[i])
    if (p[i-1] < p[i] and p[i] < p[i+1]) or (p[i-1] > p[i] and p[i] > p[i+1]):
        cnt += 1
print(cnt)

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

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:utf8 -*-
import math

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

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



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

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

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



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

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

ans = 0
for i in range(1, n-1):
    l = p[i-1:i+2]
    if l[1] == sorted(l)[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):
# -*- coding: utf-8 -*-

# main
n = int(input())
array_p = [int(i) for i in input().split(' ')]

def is_second(input_list):
    print(input_list)
    sort = sorted(input_list)
    print(sort)
    if input_list[1] == sort[1]:
        return True
    else:
        return False

count = 0
for i in range(1, n - 1):
    if is_second(array_p[i - 1 : i + 2]):
        count += 1

print(count)

# -*- coding: utf-8 -*-

# main
n = int(input())
array_p = [int(i) for i in input().split(' ')]

def is_second(input_list):
    sort = sorted(input_list)
    if input_list[1] == sort[1]:
        return True
    else:
        return False

count = 0
for i in range(1, n - 1):
    if is_second(array_p[i - 1 : i + 2]):
        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()))

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)



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

count=0

for i in range(n-2):
    if p[i]<p[i+1]<p[i+2] or p[i]>p[i+1]>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):
def main():
    n = int(input())
    p = list(map(int, input().split()))

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

    

def main():
    n = int(input())
    p = list(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
        if p[i-1] > p[i] and p[i] > p[i+1]:
            count += 1
    print(count)
    
if __name__ == '__main__':
    main()


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(n-2):
    if p[i] > p[i+1] > p[i+1] or p[i+1] > p[i+1] > p[i]:
        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 += 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())
P = [i for i in range(n)]
cnt = 0
for i in range(1:n-1):
    if (P[i-1] < P[i] < P[i+1]) or (P[i-1] > P[i] > P[i+1]):
        cnt += 1
print(cnt)

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

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

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 = input().split()

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

print(cnt)


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

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

print(cnt)


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

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

print(ans)


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

min1 = 20
min2 = 20
for pi in p:
  if min1 > pi:
    min2 = min1
    min1 = pi
print(min2)

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

c = 0
for i in range(1, len(p)-1):
  #print(p[i-1], p[i] ,p[i+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]):
    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):
import math
#import numpy


def readints():
    return list(map(int, input().split()))


n = int(input())
p = readints()
print(p)
sum = 0
for i in range(n-2):
    #print(p[i], end="")
    #print(p[i+1], end="")
    #print(p[i+2], end="")
    if p[i] < p[i+1] < p[i+2] or p[i] > p[i+1] > p[i+2]:
        sum += 1
print(sum)


import math
#import numpy


def readints():
    return list(map(int, input().split()))


n = int(input())
p = readints()
#print(p)
sum = 0
for i in range(n-2):
    #print(p[i], end="")
    #print(p[i+1], end="")
    #print(p[i+2], end="")
    if p[i] < p[i+1] < p[i+2] or p[i] > p[i+1] > p[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)
p = list(map(int, input().split()))
ans=0
x=0
for i in range(n+1):
	if p[x] < p[x+1]:
		ans+=1
		x+=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

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 math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


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

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

    print(count)


if __name__ == '__main__':
    main()


import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


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

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

    print(count)


if __name__ == '__main__':
    main()


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

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)

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)

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)

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)
    
    

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(z-2):
      hoge = num_list[i:i+3]
      hoge_sort = sorted(hoge)
      if hoge[1]==hoge_sort[1]:
        count += 1
    print(count)
    
    


Verdicts: Runtime Error

Runtime Error

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

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

count = 0

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

print(count)

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

s=input()
n=list(map(int,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)


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):
a=int(input())
b=list(map(int,input().split()))
i=0
c=0
for i in range(a-1):
  if b[i-1]<b[i]<b[i+1]:
    c+=1
  i+=1
print(c)

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

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 num in range(1, len(p)-1):
    print(p[num])
    if (p[num - 1] < p[num] < p[num + 1]) or (p[num - 1] > p[num] > p[num + 1]) :
        count+=1
print(count)

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


count = 0
for num in range(1, len(p)-1):

    if (p[num - 1] < p[num] < p[num + 1]) or (p[num - 1] > p[num] > p[num + 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):
def main():
    n = int(input())
    p = list(map(int, input().split()))
    cnt = 0

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

if __name__ == '__main__':
    main()

def main():
    n = int(input())
    p = list(map(int, input().split()))
    cnt = 0

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

if __name__ == '__main__':
    main()

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

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)

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)
    

N = int(input())
num = list(map(int,input().split()))

count = 0

for i in range(N-2):
  if num[i]>num[i+1]>num[i+2] or num[i]<num[i+1]<num[i+2]:
    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())
arr = list(map(int, input().split()))
count = 0
for i in range(1, n - 1):
    if arr[i - 1] < arr[i] < arr[i + 1]:
        count += 1

print(count)


n = int(input())
arr = list(map(int, input().split()))
count = 0
for i in range(1, n - 1):
    if arr[i - 1] < arr[i] < arr[i + 1] or arr[i - 1] > arr[i] > arr[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):
#ABC132 A
S = list(input())
S.sort()
if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
    print("Yes")
else:
    print("No")

#ABC132 B
n = int(input())
p = list(map(int, input().split()))
C = 0
for i in range(1, n - 1):
    L = [p[i - 1], p[i], p[i + 1]]
    L.sort()
    if p[i] == L[1]:
        C += 1
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())
Ps = list(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)

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

count = 0
for i in range(1, n - 1):
  if (Ps[i-1] < Ps[i]) and (Ps[i] < Ps[i+1]):
    count += 1
  elif (Ps[i-1] > Ps[i]) and (Ps[i] > Ps[i+1]):
    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())
arr = [map(int, input().split())]
print(sum([1 for i in range(len(arr)) if (((arr[i] < arr[i+1]) and (arr[i] > arr[i-1])) or ((arr[i] > arr[i+1]) and (arr[i] < arr[i-1])))]))


n = int(input())
arr = list(map(int, input().split()))
count = 0
for i in range(1, len(arr)-1):
  if (arr[i+1] - arr[i])* (arr[i] - arr[i-1]) > 0:
    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(N)
P = [int(i) for i in input().split()]
ans = 0
for i in range(N-2):
  if max(P[i:i+3]) != P[i+1] and min(P[i:i+3]) != P[i+1]:
    ans += 1
print(ans)

N = int(input())
P = [int(i) for i in input().split()]
ans = 0
for i in range(N-2):
  if max(P[i:i+3]) != P[i+1] and min(P[i:i+3]) != 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())
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)

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)

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)



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

for i in range(n-2):
  l=p[i:i+3]
  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)



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):
input();a=0
print([sorted(i)[1]==i[1]for i in [list(map(int,input().split()))[i:i+3] for i in range(len(list(map(int,input().split())))-4)]].count(True))

def c(x,s):
    return [x[i:i+s]for i in range(len(x)-s+1)]
input()
print([sorted(i)[1]==i[1]for i in c(list(map(int,input().split())),3)].count(True))

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

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

cnt = 0
l_ext = []

for i in range(n-2):
  l_ext.clear()
  l_ext.append(l[i])
  l_ext.append(l[i+1])
  l_ext.append(l[i+2])
  if not l_ext.index(max(l_ext)) and not l_ext.index(min(l_ext)):
    cnt += 1
  i += 1

print(cnt)

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

cnt = 0
l_ext = []

for i in range(n-2):
  l_ext.clear()
  l_ext.append(l[i])
  l_ext.append(l[i+1])
  l_ext.append(l[i+2])
  if sorted(l_ext)[-2] == l_ext[1]:
    cnt += 1
  i += 1

print(cnt)

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(N-2):
    p = P[i:i+3]
    print(p)
    if min(p)!=p[1] and max(p)!=p[1]:
        ans += 1
print(ans)


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


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-1):
  if 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] 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
  if p[i-1]>p[i] and p[i]>p[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):
def OrdinaryNumber(n,p,flag=None):
    
    
    if n < 3:
        return 0
    
    
    if flag == "LessThan":
        if p[1] < p[2]:
            count = OrdinaryNumber(n-1, p[1:], "LessThan")+1
        else:
            count = OrdinaryNumber(n-1, p[1:], "GreaterThan")
            
    
    elif flag == "GreaterThan":
        if p[1] < p[2]:
            count = OrdinaryNumber(n-1, p[1:], "LessThan")
        else:
            count = OrdinaryNumber(n-1, p[1:], "GreaterThan")+1
    
    
    else:
        if p[1] < p[2]:
            count = OrdinaryNumber(n-1, p[1:], "LessThan")+1
            if p[0] < p[1]:
                count +=1
        else:
            count = OrdinaryNumber(n-1, p[1:], "GreaterThan")
            if p[1] > p[2]:
                count +=1
                
    return count

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

def OrdinaryNumber(n,p,flag=None):
    
    
    if n < 3:
        return 0
    
    
    if flag == "LessThan":
        if p[1] < p[2]:
            count = OrdinaryNumber(n-1, p[1:], "LessThan")+1
        else:
            count = OrdinaryNumber(n-1, p[1:], "GreaterThan")
            
    
    elif flag == "GreaterThan":
        if p[1] < p[2]:
            count = OrdinaryNumber(n-1, p[1:], "LessThan")
        else:
            count = OrdinaryNumber(n-1, p[1:], "GreaterThan")+1
    
    
    else:
        if p[1] < p[2]:
            count = OrdinaryNumber(n-1, p[1:], "LessThan")
            if p[0] < p[1]:
                count +=1
        else:
            count = OrdinaryNumber(n-1, p[1:], "GreaterThan")
            if p[0] > p[1]:
                count +=1
                
    return count

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

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=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 max(p[i-1],p[i],p[i+1])!=p[i] and min(p[i-1],p[i],p[i+1])!=p[i]:
    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()))
sum = 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]:
    sum +=1
print(sum)


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

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

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)

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)


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)


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

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)



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

print(cnt)

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()))
c = 0
for i in range(1,n-1):
  if p[i-1] < p[i] < p[i+1] or (p[i-1] == p[i] and p[i] < p[i+1]):
    c += 1
print(c)

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

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

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

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 = input()
p = list(map(int, input().split()))
ans = 0
for i in p[2:]:
    if p[i] < p[i-1] < p[i-2] or p[i] > p[i-1] > p[i-2]:
        ans +=1
    else:
        continue
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

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

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)

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 = [*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)

n=int(input())
l = list(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] and l[i]>l[i+1]: res+=1
print(res)


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

ans = 0
for i in range(1, n-1):
  if p[i] > p[i-1] 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] >= p[i-1] 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] > p[i-1] 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] >= p[i-1] 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] > p[i+1] or p[i-1] < p[i] < p[i+1]: ans += 1

print(ans)

Verdicts: Runtime Error

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):
#132b
N = int(input())
p_list = list(map(int, input().split()))



ans = 0

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



ans = 0

for i in range(1,N-1):
    #print(p_list[i-1],p_list[i],p_list[i+1])
    if (p_list[i-1] < p_list[i] and p_list[i] < p_list[i+1]) or (p_list[i-1] > p_list[i] and p_list[i] > p_list[i+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())
p = list(map(int, input().split()))
ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if p[i]<p[j]<p[k] or p[k]<p[j]<p[i]:
                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]>p[i+1]>p[i+2]:
        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()
l=[map(int,input().strip().split())]
ans=0
for i in range(1,len(l)-2):
  gc=0;
  lc=0;
  if(l[i] >l[i-1] or l[i]>l[i+1]):
    gc=1
  if(l[i] <l[i-1] or l[i]<l[i+1]):
    lc=1
   ans+=gc & lc

n=input()
l=list(map(int,input().strip().split()))
ans=0
for i in range(1,len(l)-1):
  gc=0;
  lc=0;
  if(l[i] >l[i-1] or l[i]>l[i+1]):
    gc=1
  if(l[i] <l[i-1] or l[i]<l[i+1]):
    lc=1
  ans+=(gc & lc)
  #print(gc,lc,l[i])
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 = [int(e) for e in input().split()]
result = 0
for i in range(1, n - 1):
  if p[i - 1] < p[i] < p[i + 1] or p[i + 1] < p[i] < p[i - 1]:
    result += 1


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


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

n=int(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)

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

n = int(input())
p = list(map(int, input().split()))
ans = sum(1 for i in range(n-2) if p[i] < p[i+1] < p[i+2] or p[i] > p[i+1] > p[i+2])
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()))
c = 0

for i in range(1,n - 1):
    if p[n - 1] < p[n] and p[n] < p[n + 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] and 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] and p[i] < p[i+1]:
        c = c + 1

    if p[i-1] > p[i] and p[i] > p[i+1]:
        c = c + 1

print(c)

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

count = 0
for i in range(1, len(lstp)-1):
    lst = list(lstp[i-1], lstp[i], lstp[i+1])
    if (min(lst) != lstp[i]) and (max(lst) != lstp[i]):
        count = count + 1

print(count)

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

count = 0

for i in range(0, len(lst)-2):
    target = lst[i:i+3]
    minVal = min(target)
    maxVal = max(target)
    val = lst[i+1]
    if val != minVal and val != maxVal:
        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()))
count==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]:
    count += 1
print(count)

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

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)

    

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

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()))
t=0
for i in range(n):
  if i!=0 or i!=n-1:
    l=list(p[i-1], p[i], p[i+1])
    l.sort()
    if l[1]==p[i]:
      t+=1
print(t)

n=int(input())
p=list(map(int, input().split()))
t=0
for i in range(n):
  if i!=0 or i!=n-1:
    l=[p[i-1], p[i], p[i+1]]
    l.sort()
    if l[1]==p[i]:
      t+=1
print(t)

n=int(input())
p=list(map(int, input().split()))
t=0
for i in range(n):
    if i!=0 and i!=n-1:
      l=[p[i-1], p[i], p[i+1]]
      l.sort()
      if l[1]==p[i]:
          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())

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)

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)

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)

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)

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)

n = int(input())

p = [int(_) for _ in 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)

Verdicts: Runtime Error

Runtime Error

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

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

a = prob_b()
print(str(a))

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

cnt = 0

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


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

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

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

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

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

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

Verdicts: Wrong Answer

Runtime Error

Runtime Error

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, *p = map(int, open(0).read().split())
for i in range(2, n):
    t = p[i-2:i+1]
    c += sorted(t)[1] == t[1]
print(c)

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

Verdicts: Runtime Error

Accepted