TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

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

X1by2 = 0
for i in range(N):
  if i%2 ==0:
    X1by2 += A[i]
  else:
    X1by2 -= A[i]

X = []

X.append(X1by2)
for i in range(len(A-1)):
  X.append((A[i]-X[i]/2)*2)

print(" ".join(repr(int(e)) for e in X))


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

X1by2 = 0
for i in range(N):
  if i%2 ==0:
    X1by2 += A[i]
  else:
    X1by2 -= A[i]

X = []

X.append(X1by2)
for i in range(1,len(A)):
  X.append((A[i]-X1by2/2)*2)

print(" ".join(repr(e) for e in X))


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

X1by2 = 0
for i in range(N):
  if i%2 ==0:
    X1by2 += A[i]
  else:
    X1by2 -= A[i]

X = []

X.append(X1by2)
for i in range(len(A)-1):
  X.append((A[i]-X[i]/2)*2)

print(" ".join(repr(int(e)) for e in X))


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an _odd_ number.  Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).  When Mountain i (1 \leq i \leq N) receives 2x liters of rain, Dam i-1 and Dam i each accumulates x liters of water (Dam 0 is Dam N).  One day, each of the mountains received a non-negative **even** number of liters of rain.  As a result, Dam i (1 \leq i \leq N) accumulated a total of A_i liters of water.  Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Submission attempts (in order):
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 20 13:50:17 2019

@author: yama
"""

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

l = l+l
xl = []
for i in range(2):
    a = 0
    m = False
    for j in range(i, n+i):
        if m is False:
            a += l[j]
            m = True
        else:
            a -= l[j]
            m = False
    xl.append(a)
    
for i in range(2, n):
    xl.append3(xl[-2] - l[i-2]*2 + l[i-1]*2)
    
print(" ".join(map(str, xl)))

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

l = l+l
xl = []
for i in range(2):
    a = 0
    m = False
    for j in range(i, n+i):
        if m is False:
            a += l[j]
            m = True
        else:
            a -= l[j]
            m = False
    xl.append(a)
    
for i in range(2, n):
    xl.append3(xl[-2] - l[i-2]*2 + l[i-1]*2)
    
print(" ".join(map(str, xl)))

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

l = l+l
xl = []
for i in range(2):
    a = 0
    m = False
    for j in range(i, n+i):
        if m is False:
            a += l[j]
            m = True
        else:
            a -= l[j]
            m = False
    xl.append(a)
    
for i in range(2, n):
    xl.append(xl[-2] - l[i-2]*2 + l[i-1]*2)
    
print(" ".join(map(str, xl)))

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()))
c=0
for i in range(n-3):
    a=p[i:i+3]
    b=sorted(a)
    if a[1]==b[1]:
        c+=1
print(c)


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

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):
x = input().split()
n = int(x[0])

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

c = 0

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

print(c)

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

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

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

print(c)

x = input().split()
n = x[0]
p = x[1:]

c = 0

for (i,pi) in enumerate(p):
  if i>0 and i<len(p)-1:
    if (int(p[i-1]) < int(pi) and int(pi) < int(p[i+1])) or (int(p[i-1]) > int(pi) and int(pi) > int(p[i+1])) :
      c += 1
      
print(c)
  

x = input().split()

n = x[0]
p = x[1:]
c = 0

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

print(c)

#x = input().split()
#print (x)
#n = int(x[0])
n = int(input())

#print(n)

#p = list(map(int,x[1:]))
p = list(map(int,input().split()))

#print(p)

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

print(c)

Verdicts: Runtime Error

Runtime Error

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

ans = 0

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

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

Verdicts: Runtime Error

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

  count = 0
  p1 = P[0]
  p2 = P[1]
  for i in range(2, n):
    p3 = P[i]
    if p1 < p2 < p3 or p1 > p2 > p3:
      count += 1
    p1 = p2
    p2 = p3

main()


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

    count = 0
    p1 = P[0]
    p2 = P[1]
    for i in range(2, n):
        p3 = P[i]
        if p1 < p2 < p3 or p1 > p2 > p3:
            count += 1
        p1 = p2
        p2 = p3

    print(count)


main()


Verdicts: Runtime Error

Accepted
Problem: We have a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n}.  Print the number of elements p_i (1 < i < n) that satisfy the following condition:    * p_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.

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

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

print(ans)

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

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

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: We have a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n}.  Print the number of elements p_i (1 < i < n) that satisfy the following condition:    * p_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.

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

large_small = -1
ans = 2
for i in range(n-1):
    if p[i] > p[i+1]:
        if large_small == 1:
            ans += 1
        large_small = 1
    elif p[i] < p[i+1]:
        if large_small == -1:
            ans += 1
        large_small = -1
    else:
        large_small = 0

print(ans)


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

large_small = 2
ans = 0
for i in range(n-1):
    if p[i] > p[i+1]:
        if large_small == 1:
            ans += 1
        large_small = 1
    elif p[i] < p[i+1]:
        if large_small == -1:
            ans += 1
        large_small = -1
    else:
        large_small = 0

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


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


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):
# -*- coding: utf-8 -*-

def main():
    
    # a = int(input())
    
    # b, c = map(int, input().split())
    
    
    
    # print("{} {}".format(a+b+c, s))
    n = int(input())
    p_list = list(map(int, input().split()))
    cnt = 0
    for i in range(1, n-1):
        if min(p_list[i-1:i+2])<p_list[i] and p_list[i]<=max(p_list[i-1:i+2]):
            cnt += 1
        else:
            pass
    print(cnt)



if __name__=='__main__':
    main()


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

def main():
    
    # a = int(input())
    
    # b, c = map(int, input().split())
    
    
    
    # print("{} {}".format(a+b+c, s))
    n = int(input())
    p_list = list(map(int, input().split()))
    cnt = 0
    for i in range(1, n-1):
        if min(p_list[i-1],p_list[i+1])<p_list[i] and p_list[i]<=max(p_list[i-1],p_list[i+1]):
            cnt += 1
        else:
            pass
    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())
A=list(map(int,input().split()))
ans=0
for i in range(n-2):
  if A[i]<A[i+1]<A[i+2]:
    ans+=1
print(ans)

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

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

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

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

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]) or (p[i-1]>p[i] and p[i]>p[i+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 = input()
p = input().split()

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

print(s)

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

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

print(s)


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

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

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

	a = b
	b = c

print(cnt)

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

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

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

print(cnt)

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

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

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

	a = b
	b = c

print(cnt)

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

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

Verdicts: Wrong Answer

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

import numpy
p = np.array(p)
cnt = 0
for i in range(1, n-1):
    pi = np.array(p[i-1:i+2])
    #print(pi)
    if np.argsort(pi)[1] == 1:
        cnt += 1
print(cnt)

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

import numpy
p = np.array(p)
cnt = 0
for i in range(1, n-1):
    pi = np.array(p[i-1:i +2])
    #print(pi)
    if np.argsort(pi)[1] == 1:
        cnt += 1
print(cnt)

n = int(input())
p = list(map(int, input().split()))
import numpy as np
p = np.array(p)
cnt = 0
for i in range(1, n-1):
    pi = np.array(p[i-1:i+2])
    #print(pi)
    if np.argsort(pi)[1] == 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()))
p = [0]*3
cnt = 0
for i in range(1,n-1):
    for j in range(0,len(p)):
        p[j] = P[i+(j-1)] - P[i]
    p.sort()
    if p.index(0) == 1:
        cnt += 1

n = int(input())
P = list(map(int,input().split()))
p = [0]*3
cnt = 0
for i in range(1,n-1):
    for j in range(0,len(p)):
        p[j] = P[i+(j-1)] - P[i]
    p.sort()
    if p.index(0) == 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):
from sys import stdin


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

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

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


if __name__ == "__main__":
    main()

from sys import stdin


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

    p = [int(x) for x in stdin.readline().split()]
    count = 0

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


if __name__ == "__main__":
    main()

from sys import stdin


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

    p = [int(x) for x in stdin.readline().split()]
    count = 0

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


if __name__ == "__main__":
    main()

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

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

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

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

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):
s = sorted(input())

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


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

n=int(input())
p = [int(x) for x in 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=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=count+1
print(count)

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



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

n

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

Verdicts: Runtime Error

Runtime Error

Runtime Error

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):
N = int(input())
data = list(map(int, input().split()))
pn = [x for x in range(1, N-1)]

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

import numpy as np

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

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

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

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

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

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


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

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


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: We have a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n}.  Print the number of elements p_i (1 < i < n) that satisfy the following condition:    * p_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.

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

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

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

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

Verdicts: Wrong Answer

Accepted
Problem: We have a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n}.  Print the number of elements p_i (1 < i < n) that satisfy the following condition:    * p_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.

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

cnt = 0
for i in range(1,len(l)-1):
    l_tmp = [l[i-1], l[i], l[i+1]]
    l_tmp.sort()
    if l_tmp[1]==l[i]:
        cnt += 1


import numpy as np

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

cnt = 0
for i in range(1,len(l)-1):
    l_tmp = [l[i-1], l[i], l[i+1]]
    l_tmp.sort()
    arr_tmp = np.array(l_tmp)
    if len(arr_tmp[arr_tmp>l[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=[int(i) for i in input().split()]
ans=0
for x in range(2,n):
    a=p[x-1]
    b=p[x]
    c=p[x+1]
    if a<b<c or c<b<a:
        ans+=1
print(ans)

n=int(input())
p=[int(i) for i in input().split()]
ans=0
for x in range(1,n-1):
    a=p[x-1]
    b=p[x]
    c=p[x+1]
    if a<b<c or c<b<a:
        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()))
c = 0
for i in range(0,n-2):
  if p[i] * p[i+2] < p[i+1] ** 2:
    c += 1
print(c)   

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

Verdicts: Wrong Answer

Accepted
Problem: We have a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n}.  Print the number of elements p_i (1 < i < n) that satisfy the following condition:    * p_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.

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

count = 0

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


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

count = 0

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

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

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

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
  elif p[i-1] > p[i] and p[i] > p[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):
def counting(numbers) -> int:
    count = 0
    for i in range(1, len(numbers) - 1):
        pre = numbers[i-1]
        curr = numbers[i]
        next_ = numbers[i+1]
        if pre < curr < next_:
            count += 1
    return count
 
_ = input()
numbers_str = input()
result = counting(numbers_str.split(' '))
print(result)


def counting(numbers: int[]): int:
    count = 0
    for i in range(1, len(numbers) - 1):
        pre = numbers[i-1]
        curr = numbers[i]
        next_ = numbers[i+1]
        if pre < curr < next_:
          count += 1
      return count

_ = input()
numbers_str = input()
result = counting(numbers_str.split(' '))
print(result)


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


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


Verdicts: Wrong Answer

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

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

Verdicts: Wrong Answer

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

from bisect import bisect

for _ in range(int(input())):
    N, D = map(int, input().split())
    P = list(map(int, input().split()))
    swaps = 0
    possible = True
    for m in range(D):
        order = []
        for i in range(m, N, D):
            if (P[i]-(i+1)) % D:
                possible = False
                break
            idx = bisect(order, P[i])
            swaps += len(order) - idx
            order.insert(idx, P[i])
    if possible:
        print(swaps)
    else:
        print(-1)
    

n=int(input())
a=list(map(int,input().split()))
count=0
i=1
while i<len(a)-1:
    if (a[i]>a[i+1] and a[i]<a[i-1]) or (a[i]<a[i+1] and a[i]>a[i-1]):
        count+=1
    i+=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):
l = list(map(int, input().split()))
count = 0
for i in range(1, l-1):
  ll = l[i-1:i+1]
  ll.sort()
  if ll[1]==l[i]:
    count+=1
print(count)


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

N = int(input())
l = [int(i) for i in input().split()]
count = 0
for i in range(len(l) - 2):
    ll = l[i:i + 3]
    ll.sort()
    if ll[1] == l[i+1]:
        count += 1
print(count)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: We have a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n}.  Print the number of elements p_i (1 < i < n) that satisfy the following condition:    * p_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.

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

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

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

print count

n = int(input())

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

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

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

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

Verdicts: Wrong Answer

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

ans= 0

for i in range(1,n-1):
    lis= sorted([li[i],li[i-1],li[i+1]])
    print(lis)
    if lis[1]==li[i]:
        ans +=1
print(ans)

n=int(input())

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

ans= 0

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

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

ans = 0
for i in range(1, n - 1):
  if l[i - 1] < l[i] and l[i] < l[i + 1]:
    ans += 1

print(ans)


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

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

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):
long = int(input())
p = input()
plng = []
pstr = p.split(" ")
n = 0

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


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

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

print(n)


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

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


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

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

print(n)


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

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

print(plng)

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

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

print(n)


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

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

print(plng)

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

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

print(n)


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

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


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

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

print(n)


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

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



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

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

print(n)


Verdicts: Runtime Error

Runtime Error

Runtime Error

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

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


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

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


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

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

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)

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

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

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

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

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())
arrayP = [int(s) for s in input().split()]

cnt = 0

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

print(cnt)


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

n = int(input())
arrayP = [int(s) for s in input().split()]
 
cnt = 0
 
for i in range(0, n-2):
    threeNums = arrayP[i:i+3]
    threeNums.sort()
    if threeNums[1] == arrayP[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):
 = input()
p = []
input_first = input()
for ki in range(int(n)):
    p = input_first.rstrip().split(' ')
count = 0
print(p)
for i in range(1,int(n)-1):
    if (int(p[i]) > int(p[i-1]) and int(p[i]) < int(p[i+1])) or (int(p[i]) < int(p[i-1]) and p[i] > p[i+1]):
        count += 1
    else:
        pass
print(count)


n = input()
p = []
input_first = input()
for ki in range(int(n)):
    p = input_first.rstrip().split(' ')
count = 0
for i in range(1,int(n)-1):
    if int(p[i]) > int(p[i-1]) and int(p[i]) < int(p[i+1]):
        count += 1
    elif int(p[i]) < int(p[i-1]) and int(p[i]) > int(p[i+1]):
        count += 1
    else:
        pass
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):
p = list(map(int,input().split()))
count = 0
for i in range(len(p)-2):
  if p[i]<=p[i+1]<p[i+2]:
    count = count + 1
  elif p[i]>p[i+1]>=p[i+2]:
    count = count + 1
else:
  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 = count + 1
  elif p[i]>p[i+1]>=p[i+2]:
    count = count + 1
else:
  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=input().split()
p=[int(s) for s in p]

print(n,p)
count=0

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

print(count)


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

#print(n,p)
count=0

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

print(count)


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())
seq_str = input().split(" ")
seq = [int(s) for s in seq_str]
counter = 0

for i in range(1,n-1):
    if seq[i-1] < sqe[i] and seq[i] < seq[i+1]
    counter =+ 1
print(counter)

n = int(input())
seq_str = input().split(" ")
seq = [int(s) for s in seq_str]
counter = 0

for i in range(1,n-1):
    if (seq[i-1]-seq[i])*(seq[i+1]-seq[i]) < 0:
        counter =+ 1
print(counter)

n = int(input())
seq_str = input().split(" ")
seq = [int(s) for s in seq_str]
counter = 0

for i in range(1,n-1):
    if (seq[i-1]-seq[i])*(seq[i+1]-seq[i]) < 0:
        counter += 1
print(counter)


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

for i in range(n-2): 
    if s[i] < s[i+1] and s[i+1] < s[i+2]:
        num = num+1 
    else: 
        pass

print(num)

n = int(input())
s = list(map(int, input().split())) 
num = 0

for i in range(n-2): 
    if s[i] < s[i+1] and s[i+1] < s[i+2]:
        num = num+1 
    elif s[i] > s[i+1] and s[i+1] > s[i+2]:
        num = num + 1
    else: 
        pass

print(num)

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())
lst = [int, input().split()]
cnt = 0

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

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

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

Verdicts: Runtime Error

Accepted