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=input()
S=list(input().split())
count=0
for i in range(1,len(S)-1):
    if (S[i-1]<S[i] and S[i+1]>S[i]):
        count+=1
        break
    if(S[i-1]>S[i] and S[i+1]<S[i]):
        count+=1
print(count)

n=input()
if n>20 or n<2:
  print(0)
else:
  S=list(input().split())
  count=0
  for i in range(1,len(S)-1):
      if (S[i-1]<S[i] and S[i+1]>S[i]):
          count+=1
          break
      if(S[i-1]>S[i] and S[i+1]<S[i]):
          count+=1
  print(count)

ソースコード 拡げる

Copy
Copy
n=input()
S=list(input().split())
count=0
for i in range(1,len(S)-1):
    if (S[i-1]<S[i] and S[i+1]>S[i]) or (S[i-1]>S[i] and S[i+1]<S[i]):
        count+=1
print(count)

n=input()
S=list(input().split())
count=0
for i in range(1,len(S)-1):
    if (S[i-1]<S[i] and S[i+1]>S[i]):
          if(S[i-1]>S[i] and S[i+1]<S[i]):
              count+=1
print(count)


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

Verdicts: Wrong Answer

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


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


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

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


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

count = 0
for i in range(1,n-1):
    nums = p[(i-1):(i+1)]
    nums.sort()
    if p[i] == nums[1]
        count += 1
print(count)


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: Runtime Error

Wrong Answer

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):
inp0=input()
inp=[int(x) for x in input().split(" ")]
 
ans=0
for index in range(1,len(inp)-1):
  a =sorted([inp[index-1],inp[index],inp[index+1]])
  chk =list(set(a))
  if not len(chk)==1:
    if inp[1]==a[1]:
      ans =ans+1
print(ans)

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

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


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

ans = 0
for index in range(1, len(inp)-1):
    a = sorted([inp[index-1], inp[index], inp[index+1]])
    if min(a) == inp[index]:
        pass
    chk = list(set(a))
    # if not len(chk) == 2 and inp[index] == a[1]:
    if inp[index] == a[1]:
            ans = ans+1
    # elif  and inp[1] == a[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())
a=list(map(int,input().split()))
ans=0
for i in range(1,n-1):
  max = max(p[i-1],p[i],p[i+1])
  min = min(p[i-1],p[i],p[i+1])
  if p[i] != max and p[i] != min:
    ans += 1
print(ans)

n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(1,n-1):
  maxi = max(p[i-1],p[i],p[i+1])
  mini = min(p[i-1],p[i],p[i+1])
  if p[i] != maxi and p[i] != mini:
    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]>p[i-1] and p[i]<p[i+1]:
		count+=1
print('{}'.format(count))

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

Verdicts: Wrong Answer

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

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

num = 0
for i in range(n):
    list_i = P[i:i+3]
    if list_i[1] == sorted(list_i)[-2]:
        num += 1
    else:
        num += 0

print(num)

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

num = 0
for i in range(n-2):
    list_i = P[i:i+3]
    if list_i[1] == sorted(list_i)[-2]:
        num += 1
    else:
        num += 0

print(num)

Verdicts: Runtime Error

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

Submission attempts (in order):
A = int(input())
x = list(map(int, input().split()))
count=0
for i in range(A-2):
    b=x[i:i+3]
    a=sorted(b)
    print(a)
    if a[1] == b[1]:
        count=count+1
print(count)


A = int(input())
x = list(map(int, input().split()))
count=0
for i in range(A-2):
    b=x[i:i+3]
    a=sorted(b)
    if a[1] == b[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):
N = int(input())
num_list = list(map(int,input().split()))

cnt=0
for i in range(1,N-1):
  temp_list = num_list[i-1:i+2]
  print(temp_list)
  sort_list = sorted(temp_list)
  if temp_list[1] == sort_list[1]:
    cnt+=1
print(cnt)

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

cnt=0
for i in range(1,N-1):
  temp_list = num_list[i-1:i+2]
  sort_list = sorted(temp_list)
  if temp_list[1] == sort_list[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):
a = int(input())
ar = list(map(int,input().split(" ")))
count = 0
for i in range(1,a):
  if ar[i] < ar[i-1] and ar > ar[i+1]:
    count += 1
  elif ar[i] < ar[i+1] and ar > ar[i-1]:
    count += 1
print(count)

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


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

n = int(input())
a = [int(k) for k in input().split()]
cnt = 0
for i in range(n-2):
  if a[i] < a[i+1] and a[i+1] < a[i+2]:cnt += 1
  elif a[i] > a[i+1] and a[i+1] > a[i+2]: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 = input().split(" ")
a = 0
for i in range(len(n)):
    pf = p[i]
    ps = p[i+1]
    pt = p[i+2]
    il = [int(pf),int(ps),int(pt)]
    max_p = max(il)
    il.remove(max_p)
    if int(ps) = max(il):
        a += 1
print(a)

n = int(input())
p = input().split(" ")
a = 0
for i in range(len(n)):
    pf = p[i]
    ps = p[i+1]
    pt = p[i+2]
    il = [int(pf),int(ps),int(pt)]
    max_p = max(il)
    il.remove(max_p)
    if int(ps) == max(il):
        a += 1
print(a)

n = int(input())
p = input().split(" ")
a = 0
for i in range(len(p)):
    try:
        pf = p[i]
        ps = p[i+1]
        pt = p[i+2]
        il = [int(pf),int(ps),int(pt)]
        max_p = max(il)
        il.remove(max_p)
        if int(ps) == max(il):
            a += 1
    except:
        pass
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().split()))

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

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

ans = set()
for i in range(1, n-1):
	print(i)
	a = []
	a.append(p[i-1])
	a.append(p[i])
	a.append(p[i+1])
	a.sort()
	if a[0] < a[1] and a[1] < a[2]:
	  ans.add(a[1])
	elif a[0] == a[1]:
	 	ans.add(a[2])
	elif a[1] == a[2]:
		ans.add(a[1])
	
print(len(ans))

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

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

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):
a=int(input())
seqS=input().split(" ")
num=[]
for q in seqS:
    num.append(int(q))
contador=0


#if num[0] > num[1]:
    

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


#if num[-1] > num[-2]:
    
print(contador)


n=int(input())
numeros=[int (x) for x in input().split()]
cont=0
for x in range(0,n-2):
    if (numeros[x+1]>numeros[x] and numeros[x+1]<numeros[x+2]) or (numeros[x+1]<numeros[x] and numeros[x+1]>numeros[x+2]):
        if x==n-2:
            break
        cont+=1
print(cont)

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):
#b.py
n = int(input())
lis = list(map(int,input()))
ans = 0
for x,y,z in zip(lis,lis[1:],lis[2:]):
    if x < y < z:
        ans += 1
print(ans)

#b.py
n = int(input())
lis = list(map(int,input().split()))
ans = 0
for x,y,z in zip(lis,lis[1:],lis[2:]):
    if x < y < z or z < y < 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,*p=[int(t.split())for t in open(0)]
print(sum([(p[i+1]-p[i])*(p[i]-p[i-1]) < 0 for i in range(1,n)]))


n = int(input())
p = list(map(int,input().split()))
print(sum([max(p[i+1],p[i],p[i-1]) != p[i] and min(p[i+1],p[i],p[i-1]) != p[i] for i in range(1,n-1)]))

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

print(sum)

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

print(sum)

Verdicts: Wrong Answer

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

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

a = len(d)/2
l = d[a+1] - d[a]

print(l)


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

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

print(l)


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):
if __name__ == '__main__':
    input()
    a = list(map(int, input().split()))
    count = 0
    for i in range(0, len(a) - 2):
        old = a[i:i + 3]
        new = sorted(old)
        print(old, new, old[1], new[1])
        if old[1] == new[1]:
            count += 1
    print(count)


if __name__ == '__main__':
    input()
    a = list(map(int, input().split()))
    count = 0
    for i in range(0, len(a) - 2):
        old = a[i:i + 3]
        new = sorted(old)
        print(old, new, old[1], new[1])
        if old[1] == new[1]:
            count += 1
    print(count)


if __name__ == '__main__':
    input()
    a = list(map(int, input().split()))
    count = 0
    for i in range(0, len(a) - 2):
        old = a[i:i + 3]
        new = sorted(old)
        if old[1] == new[1]:
            count += 1
    print(count)


Verdicts: Wrong Answer

Wrong Answer

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

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

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


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

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

collect = 0
for i in range(n - 2):
    p_small = p[i: i + 2]
    p_min = min(p_small)
    p_max = max(p_small)
    pi = p_small[1]
    
    if pi > p_min and pi < p_max:
        collect += 1
        
print(collect)

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

collect = 0
for i in range(n - 2):
    p_small = p[i: i + 3]
    p_min = min(p_small)
    p_max = max(p_small)
    pi = p_small[1]
    
    if pi > p_min and pi <= p_max:
        collect += 1
        
print(collect)

n = int(input())
p = list(map(int, input().split()))
#n = 9
#p = [9, 6, 3, 2, 5, 8, 7, 4, 1]

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

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

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

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

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

c = 0
for i in range(1, n-1):
  if sorted([ns[i-1], ns[i], ns[i+1]])[1] == ns[i]:
    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()
nums = input().split(' ')
print(nums)
nums = [int(num) for num in nums]
cnt=0

for i in range(1,len(nums)-1):
  
  print(nums[i-1], nums[i], nums[i+1])
  if nums[i-1] < nums[i] and nums[i] < nums[i+1]:
    cnt += 1
    print('OK')
  if nums[i+1] < nums[i] and nums[i] < nums[i-1]:
    cnt += 1
    print('OK')
      
print(cnt)
  

n = input()
nums = input().split()

cnt=0

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

n = input()
nums = input().split(' ')

nums = [int(num) for num in nums]
cnt=0

for i in range(1,len(nums)-1):
  if nums[i-1] < nums[i] and nums[i] < nums[i+1]:
    cnt += 1
  if nums[i+1] < nums[i] and nums[i] < nums[i-1]:
    cnt += 1
      
print(cnt)
  

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

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

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

Verdicts: Runtime Error

Runtime Error

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

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

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


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

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

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

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

import collections

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

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

n = int(input())
t = list(map(int, input().split()))
result = 0

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

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

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


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

cnt = 0
for n in range(1, len(p) - 1):

    if p[n - 1] > p[n + 1]:
        if p[n - 1] > p[n] and p[n] > p[n + 1]:
  
            cnt = cnt + 1
    elif p[n - 1] < p[n] and p[n] < p[n + 1]:
        cnt = 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):
  if li[i-1] > li[i] and li[i+1] < li[i]:
    ans += 1
  if if li[i-1] < li[i] and li[i+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):
  if li[i-1] > li[i] and li[i+1] < li[i]:
    ans += 1
  if li[i-1] < li[i] and li[i+1] > li[i]:
    ans += 1
print(ans)


Verdicts: Runtime Error

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

Submission attempts (in order):
n = int(input())
p = list(map(input().split()))
i = 1
cnt = 0
while i < len(p):
  if p[i] > p[i - 1] and p[i] < p[i + 1] :
    cnt += 1
  i += 1

n = int(input())
if n == 1:
  p = int(input())
else:
  p = list(map(input().split()))
i = 1
cnt = 0
while i < len(p):
  if p[i] > p[i - 1] and p[i] < p[i + 1] :
    cnt += 1
  i += 1

n = int(input())
p = list(map(int, input().split()))
i = 1
cnt = 0
while i < len(p) - 1:
  l = sorted([p[i - 1], p[i], p[i + 1]])
  if l[1] == p[i]:
    cnt += 1
  i += 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().rstrip())
p = [int(x) for x in input().rstrip().split()]

print(p)

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


n = int(input().rstrip())
p_string = input().rstrip().split()
p = [int(x) for x in p_string]

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


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

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

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

Verdicts: Runtime Error

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

Submission attempts (in order):
N = int(input())
P = list(map(int,input().split(' ')))
num = 0
for i in range(1,N-1):
    if min(P[i-1],P[i+1]) < P[i]  and P[i] <max(P[i-1],P[i+1]):
    num += 1
print(num)

N = int(input())
P = list(map(int,input().split(' ')))
num = 0
for i in range(1,N-1):
	if min(P[i-1],P[i+1]) < P[i]  and P[i] <max(P[i-1],P[i+1]):
    	num += 1
print(num)


N = int(input())
P = list(map(int,input().split(' ')))
num = 0
for i in range(1,N-1):
  if min(P[i-1],P[i+1]) < P[i]  and P[i] <max(P[i-1],P[i+1]):
    num += 1
print(num)


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

a=int(input())
li = list(map(int,input().split()))	
count = 0
for i in range(1:a):
  if li[i-1]<li[i] and li[i]<li[i+1]:
    count += 1
  else:
    pass
print(count)

a=int(input())
li = list(map(int,input().split()))	
count = 0
for i in range(1,a-1):
  if li[i-1]<li[i] and li[i]<li[i+1]:
    count += 1
  elif li[i-1]>li[i] and li[i]>li[i+1]:
    count += 1
  else:
    pass
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):
def second_smallest(numbers):
    m1, m2 = float('inf'), float('inf')
    for x in numbers:
        if x <= m1:
            m1, m2 = x, m1
        elif x < m2:
            m2 = x
    return m2

n = int(input())
numbers = input()

numbers = [int(x)  for x in numbers.split()]

print(numbers)
smallest = set()
for i in range(len(numbers)):
    if (i + 2) >= len(numbers):
        break
    
    min_number = second_smallest([numbers[i], numbers[i+1], numbers[i+2]])
    if not(min_number in smallest):
        smallest.add(min_number)
        
print(len(smallest))



def second_smallest(numbers):
    m1, m2 = float('inf'), float('inf')
    for x in numbers:
        if x <= m1:
            m1, m2 = x, m1
        elif x < m2:
            m2 = x
    return m2

n = int(input())
numbers = input()

numbers = [int(x)  for x in numbers.split()]

print(numbers)
smallest = set()
for i in range(len(numbers)):
    if (i + 2) >= len(numbers):
        break
    
    min_number = second_smallest([numbers[i], numbers[i+1], numbers[i+2]])
    if not(min_number in smallest):
        smallest.add(min_number)
        
print(len(smallest))



n = int(input())
numbers = input()

numbers = [int(x)  for x in numbers.split()]

smallest = set()
for i in range(1,len(numbers) - 1):
    #print(numbers[i])
    if (numbers[i] < numbers[i -1] and numbers[i] > numbers[i + 1] ) or (numbers[i] < numbers[i +1] and numbers[i] > numbers[i - 1] ):
        if not(numbers[i] in smallest):
            smallest.add(numbers[i])
    
        
print(len(smallest))



Verdicts: Wrong Answer

Wrong Answer

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

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

#ABC132 B

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

#ABC132 B

n = int(input())
K = 0
for i in range(n-2):
    if (P[i]<P[i+1] and P[i+1] < P[i+2]) or (P[i+2]<P[i+1] and P[i+1]<P[i]):
        K += 1
        
print(K)

#ABC132 B

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

Verdicts: Runtime Error

Wrong Answer

Runtime Error

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

Submission attempts (in order):
n = int(input())
lis = list(map(int,input().split()))
count = 0
i = 0
while(i < n-2):
  temp = lis[i:i+3]
  if temp[1] == sorted(temp)[1]:
    count += 1
print(count)

n = int(input())
lis = list(map(int,input().split()))
count = 0
i = 0
while(i < n-2):
  temp = lis[i:i+3]
  if temp[1] == sorted(temp)[1]:
    count += 1
  i += 1
  
print(count)

Verdicts: Time Limit Exceeded

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

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

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

n = int(input())
A = list(map(int, input().strip().split()))
count = 0
for i in range(1,N):
  if A[i]!=max(A[i-1],A[i],A[i+1]) and A[i]!=min(A[i-1],A[i],A[i+1]):
    count += 1
  else:
    count += 0
print(count)
  

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

Verdicts: Runtime Error

Runtime Error

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

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

a = 0
for i in range(2,n,1):
  if p[i-1]<p[i]:
    if p[i]<=p[i+1]:
      a +=1
  if p[i+1]<p[i]:
    if 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,1):
  if p[i-1]<p[i]:
    if p[i]<=p[i+1]:
      a +=1
  if p[i+1]<p[i]:
    if p[i]<=p[i-1]:
      a +=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):
ss = input()
s = int(ss)

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

count = 0
for val in range(s -2):
    if list[val] > list[val + 1] > list[val + 1] or list [val] < list[val + 1] < list[val + 2]:
        count += 1
        
print(count)

s = input()
all[20]

for val int range(s):
    all[val] = input()
    
count = 0
for val in range(s - 2)
    if all[val] < all[val + 1] and all[val + 1] < all[val + 2]
        count += 1

ss = input()
s = int(ss)
nums = input().split()
type(nums)
type(nums[0])
print(nums)

count = 0
for val in range(s -2):
    if nums[val + 1] > nums[val ] and nums[val + 1] < nums[val + 2]:
        count += 1
    elif nums[val + 1] > nums[val + 2] and nums[val + 1] < nums[val]:
        count += 1
        
print(count)

ss = input()
s = int(ss)
nums = list(map(int,input().split()))
count = 0
for val in range(s -2):
    if nums[val] > nums[val + 1] > nums[val + 2] or nums[val] < nums[val + 1] < nums[val + 2]:
        count += 1
        
print(count)

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

ans = 0
for i in range(N-2):
  if list[i+1] > List[i] and list[i+1] < List[i+2]:
    ans+=1
  if list[i+1] < List[i] and list[i+1] > List[i+2]:
    ans+=1
  else:
    pass

print(ans)

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

ans = 0
for i in range(N-2):
  if list[i+1] > List[i] and list[i-1] < List[i]:
    ans+=1
  if list[i+1] < List[i] and list[i-1] > List[i]:
     ans+=1

print(ans)

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

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

ans=0

for i in range(N-2):
  if L[i] < L[i+1] and  L[i+1] < L[i+2]:
    ans +=1 
  if L[i] > L[i+1] and  L[i+1] > L[i+2]:
    ans +=1 
  else:
    pass

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

cnt = 0

for i in range(1,N-1):
  if p_list[i-1] < p_list[i] and p_list[i] < p_list[i+1]
  	cnt += 1

  if p_list[i+1] < p_list[i] and p_list[i] < p_list[i-1]
  	cnt += 1
    
print(cnt)

N = int(input())
p_list = [int(s) for s in input.split()]
 
cnt = 0
 
for i in range(1,N-1):
  if p_list[i-1] < p_list[i] and p_list[i] < p_list[i+1]:
  	cnt += 1
 
  if p_list[i+1] < p_list[i] and p_list[i] < p_list[i-1]:
  	cnt += 1
    
print(cnt)

N = int(input())

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

cnt = 0

for i in range(1,N-1):
  if p_list[i-1] < p_list[i] and p_list[i] < p_list[i+1]:
  	cnt += 1

  if p_list[i+1] < p_list[i] and p_list[i] < p_list[i-1]:
  	cnt += 1

print(cnt)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Takahashi made N problems for competitive programming. The problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).  He is dividing the problems into two categories by choosing an integer K, as follows:    * A problem with difficulty K or higher will be _for ARCs_.   * A problem with difficulty lower than K will be _for ABCs_.  How many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?

Submission attempts (in order):
n=int(input())
d=list(map(int,input().split()))
d.sort()
gn=0
a=d[int(n/2)]-d[int((n/2)-1)]-1

if d[int(n/2)]!=d[int((n/2)-1)]:
  for i in d:
    if i==d[int(n/2)]:
      gn+=1
  if gn==1:
    a+=1
  print(a)
  print(d)
     
else:
  print(0)

n=int(input())
d=list(map(int,input().split()))
d.sort()
x=d[int((n-1)/2)]+1
y=d[int(n/2)]

print(y-x+1)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi made N problems for competitive programming. The problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).  He is dividing the problems into two categories by choosing an integer K, as follows:    * A problem with difficulty K or higher will be _for ARCs_.   * A problem with difficulty lower than K will be _for ABCs_.  How many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?

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

same = N / 2



# distribution = [0] * d[len(d) - 1]


#     num = d.count(di)


table = {}
for di in d:
    table[di] = 0 if table[di] is None else table[di] + 1








#     if totals[i] == same:


#         break

print(1)


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

same = N / 2



# distribution = [0] * d[len(d) - 1]


#     num = d.count(di)


table = {}
for di in d:
    table[di] = 1 if table.get(di) is None else table.get(di) + 1
print(table)







#     if totals[i] == same:


#         break

print(1)


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

same = N / 2



# distribution = [0] * d[len(d) - 1]


#     num = d.count(di)


table = {}
for di in d:
    table[di] = 1 if table.get(di) is None else table.get(di) + 1
table = sorted(table.items())

total = 0
for difficulty, num in table:
    total += num








#     if totals[i] == same:


#         break

print(1)


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

same = N / 2

d.sort()

distribution = [0] * d[len(d) - 1]
total = 0
for di in d:
    num = d.count(di)
    distribution[di - 1] = num








#     if totals[i] == same:


#         break

print(1)


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

same = N / 2

d.sort()

distribution = [0] * d[len(d) - 1]
total = 0
for di in d:
    num = d.count(di)
    distribution[di - 1] = num

print(distribution)

total = 0
totals = [0] * d[len(d) - 1]
num = 0
for i in range(len(distribution)):
    total += distribution[i]
    totals[i] = total

    if totals[i] == same:
        num += 1
    elif num >= 1:
        break

print(num)


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

same = N / 2



# distribution = [0] * d[len(d) - 1]


#     num = d.count(di)


table = {}
for di in d:
    table[di] = 0 if table[di] is None else table[di] += 1








#     if totals[i] == same:


#         break

print(1)


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

same = N / 2



# distribution = [0] * d[len(d) - 1]


#     num = d.count(di)


table = {}
for di in d:
    table[di] = 1 if table.get(di) is None else table.get(di) + 1
table = sorted(table.items())

total = 0
start = 0
end = 0
for difficulty, num in table:
    total += num

    if start == 0 and total == same:
        start = difficulty
    elif start != 0:
        end = difficulty
        break

# print(table, start, end)

answer = end - start
print(answer)


Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: Takahashi made N problems for competitive programming. The problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).  He is dividing the problems into two categories by choosing an integer K, as follows:    * A problem with difficulty K or higher will be _for ARCs_.   * A problem with difficulty lower than K will be _for ABCs_.  How many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?

Submission attempts (in order):
N = int(input())
D = input()
D =  D.split(' ')
D = [int(d) for d in D]
D_sort = np.sort(D)

k = int(N/2)
count = 0

low_d = D_sort[k-1]
hight_D = D_sort[k]
dis = hight_D - (low_d+1) + 1

print(dis)
    

import numpy as np

N = int(input())
D = input()
D =  D.split(' ')
D = [int(d) for d in D]
D_sort = np.sort(D)

k = int(N/2)
count = 0

low_d = D_sort[k-1]
hight_D = D_sort[k]
dis = hight_D - (low_d+1) + 1

print(dis)
    

Verdicts: Runtime Error

Accepted
Problem: Takahashi made N problems for competitive programming. The problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).  He is dividing the problems into two categories by choosing an integer K, as follows:    * A problem with difficulty K or higher will be _for ARCs_.   * A problem with difficulty lower than K will be _for ABCs_.  How many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?

Submission attempts (in order):
m = int(input()) // 2
a = sorted(map(int, input().split()))
print(a[n] - a[m - 1])


m = int(input()) // 2
a = sorted(map(int, input().split()))
print(a[m] - a[m - 1])


Verdicts: Runtime Error

Accepted