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

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

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

 
p_int = [int(s) for s in p]
     
     
cnt = 0
     
for i in range(1,n-1):
    if( (p_int[i-1] < p_int[i] and p_int[i] <= p_int[i+1] ) or (p_int[i-1] >= p_int[i] and p_int[i] > p_int[i+1]) or (p_int[i-1] == p_int[i+1] and p_int[i] > p_int[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):
def myInput():
  n=input()
  s=input()
  return(n,[int(i) for i in s.split()])

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

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

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

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(i) for i in input().split()][0]
P = [i for i in input().split()]

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

print(count)

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

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

print(count)

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

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

print(count)

Verdicts: 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())
nump = input().split()
nump = [int(i) for i in nump]

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


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

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


N = int(input())
nump = input().split()
nump = [int(i) for i in nump]
print(nump)

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

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

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


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

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

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())
x = list(map(int, input().split()))
cnt = 0
for i in range(n-2):
    y = sorted(x[i:i+3])
    print(y)
    if x[i+1] == y[1]:
        cnt += 1

print(cnt)

n = int(input())
x = list(map(int, input().split()))
cnt = 0
for i in range(n-2):
    y = sorted(x[i:i+3])
    if x[i+1] == y[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):
cnt = int(input())
l = list(map(int, input().split()))
count = 0
 
for i in range(cnt-2):
  a,b, c = l[i], l[i+1], l[i+2]
  if a < b and b < c:
    count += 1
print(count)

cnt = int(input())
l = list(map(int, input().split()))
count = 0
 
for i in range(cnt-2):
  a,b, c = l[i], l[i+1], l[i+2]
  if (a < b and b < c) or( a>b and b> c):
    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())
ps = list(map(int, input().split()))
ans = 0

for i in range(1, len(ps)-1):
    if ps[i] == min(ps[i-1], ps[i], ps[i+1]):
        ans += 1
print(ans)


n = int(input())
ps = list(map(int, input().split()))
ans = 0

for i in range(1, len(ps)-1):
    s1 = ps[i-1] < ps[i] and ps[i+1] > ps[i]
    s2 = ps[i-1] > ps[i] and ps[i+1] < ps[i]
    if s1 or s2:
        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())

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

print(cnt)

n = int(input())

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

print(cnt)

n = int(input())

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

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

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

print(ans)

n = int(input())

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

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

print(ans)

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

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


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

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


Verdicts: 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 = int(input())
p = list(int,input().split())
ans = 0
for i in range(1,N-1):
  if (p[i]<p[i+1])and(p[i]>p[i-1]):
    ans += 1
  elif(p[i]>p[i+1])and(p[i]<p[i-1]):
    ans += 1
  else:
    None
print(ans)

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
  elif(p[i]>p[i+1])and(p[i]<p[i-1]):
    ans += 1
  else:
    None
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(x) for x in input().split()]
count = 0
for i in range(1,n-1):
  sor = sorted(p[i-1:i+2])
  print(sor)
  if p[i] == sor[1]:
    count += 1

print(count)

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

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

    print(cnt)



main()

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

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

    print(cnt)

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())
l = list(input)
cnt = 0
for i in range(1,n):
    three = [l[i-1],l[i],l[i+1]]
    three.sort()
    if three[1] == list[i]:
        cnt += 1

print(cnt)



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

print(cnt)



n = int(input())
l = [int(i) for i in input().split()]
cnt = 0
for i in range(1,n-1):
    three = [l[i-1],l[i],l[i+1]]
    three_sort_list = sorted(three)
    if three[1] == three_sort_list[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 = list(map(int, input().split()))
cnt = 0
for i in range(2, n):
    p_n = p[i-2:i]
    if min(p_n) == p_n[1]:
        cnt += 1
print(cnt)

n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(2, n):
    p_n = p[i-2:i+1]
    p_n_sort = sorted(p_n)
    if p_n_sort[1] == p_n[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())
lis = list(map(int,input().split()))
ans = 0
for i in range(1,n-1):
  lis = sorted([lis[i-1],lis[i],lis[i+1]])
  if lis[1] == lis[i]:
    ans += 1
print(ans)

n = int(input())
lis = list(map(int,input().split()))
ans = 0
for i in range(1,n-1):
  li = sorted([lis[i-1],lis[i],lis[i+1]])
  if li[1] == lis[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= [int(x) for x in input().split]

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

print(answer)


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

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

print(answer)


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]:
    count += 1
  else:
    pass
  
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]:
    count += 1
  else:
    pass

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

A=0

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

print(A)


n=int(input())

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

A=0

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

print(A)


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 x in range(N-2):
  for y in range(x+1,x+1):
    for z in range(x+2,x+2):

n = int(input())
p = list(map(int,input().split()))
ans = 0
for x in range(n-2):
  for y in range(x+1,x+2):
    for z in range(x+2,x+3):
      if p[x] >= p[y] and p[y] >= p[z]:
        ans+=1
      elif p[z] >= p[y] and p[y] >= p[x]:
        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
for i in range(1,n-1):
  if p[i-1] < p[i] 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-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)


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

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

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

count=0
for i in range(0,len(a)-2):
    if a[i] < a[i+1] < a[i+2]:
        count+=1
    if a[i] > a[i+1] > a[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):
def solve():
    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]:
            cnt+=1
    print(cnt)
if __name__=='__main__':
    solve()

def solve():
    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)
if __name__=='__main__':
    solve()

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

n=int(input())
p=list(map(int,input().split()))
a=0
for i in range(1,n-1):
	a+=p[i]>min(p[i-1],p[i+1]) and p[i]<max(p[i-1],p[i+1])
print(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()))
ans=0
for i in range(1,n-1):
  pre=p[i-1]
  cur=p[i]
  nex=p[i+1]
  if (pre<cur and cur<nex) or(pre>cur and cur>nex):
    ans+=1
print(ans)

n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(1,n-1):
  pre=p[i-1]
  cur=p[i]
  nex=p[i+1]
  if (pre<cur and cur<nex) or(pre>cur and cur>nex):
    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=[int(i) for i in input().split()]
cnt=0
for i in range(1,N-1):
  if p[i-1]<p[i] and p[i]<p[i+1]:
    cnt+=1
print(cnt)

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

n = int(input())
num = list(map(int, input().split()))
cnt = 0
for i in range(1, n - 1) :
  if num[i - 1] > num[i] & num[i] > num[i + 1] :
    cnt += 1
  elif num[i - 1] < num[i] & num[i] < num[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 = input()
a = map(int, input().split())
ans = 0
for i in range(1:n-1):
  if a[i-1]<a[i]<a[i+1] :
    ans+=1 
print(ans)

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

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


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

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

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

cnt = 0
for i in range(1, n):
    if (p[i] - p[i - 1] > 0 and p[i + 1] - p[i] >= 0) or (p[i] - p[i - 1] <= 0 and p[i + 1] - p[i] < 0):
        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] > 0 and p[i + 1] - p[i] >= 0) or (p[i] - p[i - 1] <= 0 and p[i + 1] - p[i] < 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):
_,p=open(0);*p,=map(int,p.split());print(sum(a<b<c for a,b,c in zip(p,p[1:],p[2:])))

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

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

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

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

result=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]:
    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):
#5
#1 3 5 4 2
#2
N=int(input())
num=list(map(int,input().split()))
cnt=0
for i in range(N-2):
  if li[i]<li[i+1]<li[i+2] or li[i+2]<li[i+1]<li[i]:
    cnt+=1
print(cnt)    
    

#5
#1 3 5 4 2
#2
N=int(input())
li=list(map(int,input().split()))
cnt=0
for i in range(N-2):
  if li[i]<li[i+1]<li[i+2] or li[i+2]<li[i+1]<li[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):
# Vicfred

# implementation
n = int(input())
p = list(map(int,input()))

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

print(answer)



# Vicfred

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

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

print(answer)



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 sys
from collections import Counter
from operator import itemgetter, attrgetter
n=0
 
n = input()
d_list= list(map(int, input().split()))
cnt=0
for i in range(1,len(d_list)-1):
    print(d_list[i])
    b=d_list[i-1]
    m=d_list[i]
    a=d_list[i+1]
    if (b< m <a) or (a< m< b):
        cnt+=1
        
    
print(cnt)

import sys
from collections import Counter
from operator import itemgetter, attrgetter
n=0
 
n = input()
d_list= list(map(int, input().split()))
cnt=0
for i in range(1,len(d_list)-1):
    b=d_list[i-1]
    m=d_list[i]
    a=d_list[i+1]
    if (b< m <a) or (a< m< b):
        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):
import unittest


class TestB(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think([1, 3, 5, 4, 2]), 2)

    def test_2(self):
        self.assertEqual(think([9, 6, 3, 2, 5, 8, 7, 4, 1]), 5)


def solve():
    p = read()
    result = think(p)
    write(result)


def read():
    n = read_int(1)[0]
    return read_int(n)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(data):
    n = len(data)
    count = 0
    for i in range(n):
        if i + 2 >= n:
            break
        if data[i] < data[i + 1] < data[i + 2]:
            count += 1
    return count


def write(result):
    print(result)


if __name__ == '__main__':
    unittest.main()
    # solve()

import unittest


class TestB(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think([1, 3, 5, 4, 2]), 2)

    def test_2(self):
        self.assertEqual(think([9, 6, 3, 2, 5, 8, 7, 4, 1]), 5)


def solve():
    p = read()
    result = think(p)
    write(result)


def read():
    n = read_int(1)[0]
    return read_int(n)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(data):
    n = len(data)
    count = 0
    for i in range(n):
        if i + 2 >= n:
            break
        if data[i] < data[i + 1] < data[i + 2] or data[i] > data[i + 1] > data[i + 2]:
            count += 1
    return count


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

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(i) for i in range(n)]
s = 0
for i in range(1,n-1):
  l1 = p[i-1,i+2]
  l2 = l1.copy()
  l2.sort()
  if l1[1] == l2[2]:
    s += 1
print(s)
  

n = int(input())
p = [int(i) for i in input().split()]
s = 0
for i in range(1,n-1):
  l1 = p[i-1:i+2]
  l2 = l1.copy()
  l2.sort()
  if l1[1] == l2[1]:
    s += 1
print(s)
    

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(i) for i in input().split()]
ans = 0

for i in range(n):
  if i == 0 or i == n-1:
    continue
  x = p[i-1:i+2]
  y = sorted(x)

  if print(y[1]) == p[i]:
    ans +=1
    
print(ans)

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

for i in range(n):
  if i == 0 or i == n-1:
    continue
  
  x = p[i-1:i+2]
  y = sorted(x)

  if y[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):
a = int(input())
b = list(map(int,input().split()))
c = 0

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

N = int(input())
P = list(map(int,input().split()))
a = 0

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

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

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

for i in range(len(p)-2):
    q = sorted(p[i:i+3])

    if q[1] == 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):
def code_for_B(test=None):

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

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

    print(count)

code_for_B()

def code_for_B(test=None):

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

    pre = list_p[0]
    count = 0

    for i in range(1,n-1):
        cur = list_p[i]
        nxt = list_p[i+1]

        if pre >= cur > nxt:
            count += 1
        elif pre < cur < nxt:
            count += 1

        pre, cur = cur, nxt

    print(count)

code_for_B()


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-2):
    if p[i-1]<p[i]<p[i+1]:
        ans+=1
    else :
        ans+=0
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
    else :
        ans+=0
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(intput())
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)


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: 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())
N_List = list(map(int,input().split()))
ct = 0
for i in range(1,N-1):
    print(N_List[i])
    if (N_List[i] > N_List[i-1]) & (N_List[i] < N_List[i+1]):
        ct += 1
    elif (N_List[i] < N_List[i-1]) & (N_List[i] > N_List[i+1]):
        ct += 1


print(ct)


N = int(input())
N_List = sorted(list(map(int,input().split())))
ct = 0
for i in range(1,N-1):
    if (N_List[i] >= N_List[i-1]) & (N_List[i] <= N_List[i+1]):
        ct += 1

print(ct)


N = int(input())
N_List = sorted(list(map(int,input().split())))
ct = 0
for i in range(1,N-1):
    if (N_List[i] > N_List[i-1]) & (N_List[i] < N_List[i+1]):
        ct += 1

print(ct)


N = int(input())
N_List = list(map(int,input().split()))
ct = 0
for i in range(1,N-1):
    if (N_List[i] > N_List[i-1]) & (N_List[i] < N_List[i+1]):
        ct += 1
    elif (N_List[i] < N_List[i-1]) & (N_List[i] > N_List[i+1]):
        ct += 1


print(ct)


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):
_ = int(input())
input_arr = [int(x) for x in input().split()]

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

num_input = int(input())
input_arr = [int(x) for x in input().split()]
# print(input_arr)
count = 0
for i_ in range(len(input_arr)-2):
    arr_list = [input_arr[i] for i in range(i_,i_+3)]
    sorted_arr = sorted(arr_list)
    if sorted_arr[1] == arr_list[1]:
      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):
input()
ps = map(int, input().split())

def count(ps):
    if len(ps) <= 2:
        return 0
    qs = sorted(ps[0:3])
    res = 1 if qs[1] == ps[1] else 0
    return res + count(ps[1:])

print(count(ps))


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

def count(ps):
    if len(ps) <= 2:
        return 0
    qs = sorted(ps[0:3])
    res = 1 if qs[1] == ps[1] else 0
    return res + count(ps[1:])

print(count(ps))


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

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] or P[i] < P[i+1] and P[i+1] < P[i+2] or :
    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] or P[i] < P[i+1] and P[i+1] < P[i+2]:
    ans += 1

print(ans)


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

result = 0

if n >= "3":
	number_list = []

	for i in numbers:
		number_list.append(i)
		if len(number_list) < 3:
			continue
		elif len(number_list) > 3:
			number_list.pop(0)

		sorted_list = sorted(number_list)
		print(sorted_list, number_list)
		if sorted_list[1] == number_list[1]:
			result += 1

print(result)


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

result = 0

number_list = []

for i in numbers:
	number_list.append(i)
	if len(number_list) < 3:
		continue
	elif len(number_list) > 3:
		number_list.pop(0)

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

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


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


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

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

for i in range(1,n-1):
    a,b,c = p[i-1:i+2]
    if b != min(a,b,c,) and b != max(a,b,c):
        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=input()
ps=input()

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

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

n=input()
p=input()

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

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

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

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


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

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

co = 0

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

n = int(input())

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

co = 0

for i in range(1,len(li)-1):
  work = sort([li[i-1],li[i],li[i+1]])

  if work.index(li[i]) == 1:
    co += 1
print(co)

n = int(input())

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

co = 0

for i in range(1,len(li)-1):
  work = sorted([li[i-1],li[i],li[i+1]])

  if work.index(li[i]) == 1:
    co += 1
print(co)

Verdicts: 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(input().split())
cnt=0
print(p)
for i in range(1,n-1):
    if p[i]!=max(p[i-1],max(p[i],p[i+1])) and p[i]!=min(p[i-1],min(p[i],p[i+1])):
        cnt+=1
    elif p[i+1]==p[i-1] and p[i-1]>p[i]:
        cnt+=1

print(cnt)

n=int(input())
p=list(input().split())
p=[int(i) for i in p]
cnt=0
for i in range(1,n-1):
    if p[i]!=max(p[i-1],p[i],p[i+1]) and p[i]!=min(p[i-1],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):
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n-2):
    p1, p2, p3 = p[i], p[i+1], p[i+2]
    aaa = [p1,p2,p3]
    aaa.sort()
    print(p1,p2,p3)
    if aaa[1] == p2:
        ans += 1
print(ans)


n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n-2):
    p1, p2, p3 = p[i], p[i+1], p[i+2]
    aaa = [p1,p2,p3]
    aaa.sort()
    if aaa[1] == p2:
        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
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
li = rl()
cnt = 0
for i in range(1, n-1):
  if li[i-1] < li[i] < li[i+1]:
    cnt += 1
print(cnt)










import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
li = rl()
cnt = 0
for i in range(1, n-1):
  if li[i-1] <= li[i] <= li[i+1]:
    cnt += 1
print(cnt)










import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

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










Verdicts: Wrong Answer

Wrong Answer

Accepted