Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
light_position =1
light_position = a[light_position-1]
count = 1
while True:
    if light_position == 2:
        break
    elif light_position == 1:
        count = -1
        break        
    light_position = a[light_position-1]
    count += 1
print(count)

Fixed submission:
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
light_position =1
light_position = a[light_position-1]
count = 1
while True:
    if light_position == 2:
        break
    elif light_position == 1 or count > n:
        count = -1
        break        
    light_position = a[light_position-1]
    count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
light_position =1
light_position = a[light_position-1]
count = 1
while True:
    if light_position == 2:
        break
    elif light_position == 1:
        count = -1
        break        
    light_position = a[light_position-1]
    count += 1
print(count)

Fixed submission:
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
light_position =1
light_position = a[light_position-1]
count = 1
while True:
    if light_position == 2:
        break
    elif light_position == 1 or count > n:
        count = -1
        break        
    light_position = a[light_position-1]
    count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
n, m = [int(e) for e in input().split()]
map_dict = {}
for i in range(n):
    map_dict[str(i+1)] = 0
for _ in range(m):
    cities = [e for e in input().split()]
    map_dict[cities[0]]+=1
    map_dict[cities[1]]+=1
for i in range(m):
    print(map_dict[str(i+1)])

Fixed submission:
n, m = [int(e) for e in input().split()]
map_dict = {}
for i in range(n):
    map_dict[str(i+1)] = 0
for _ in range(m):
    cities = [e for e in input().split()]
    map_dict[cities[0]]+=1
    map_dict[cities[1]]+=1
for i in range(n):
    print(map_dict[str(i+1)])
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
elem = list(map(int, input().split()))
elem.sort()
ans = 0
while len(elem) > 0:
    elem.pop(0)
    ans = ans + elem.pop(-2)
    elem.pop(-1)
print(ans)

Fixed submission:
n = int(input())
elem = list(map(int, input().split()))
elem.sort()
ans = sum(elem[n::2])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# atcoder
import math

def get_number_of_digits(n):
    return int(math.log10(n) + 1)

def get_larger_digits(a, b):
    return max(get_number_of_digits(a), get_number_of_digits(b))

n = int(input())
min_digit = float('inf')
for a in range(1, n+1):
    if n % a != 0:
        continue
    b = int(n / a)
    if n == a * b:
        temp_digit = get_larger_digits(a, b)
        min_digit = min(min_digit, temp_digit)
print(min_digit)

Fixed submission:
# atcoder
import math

def get_number_of_digits(n):
    return int(math.log10(n) + 1)

def get_larger_digits(a, b):
    return max(get_number_of_digits(a), get_number_of_digits(b))

n = int(input())
min_digit = float('inf')
for a in range(1, int(math.sqrt(float(n))+5.0)):
    if n % a != 0:
        continue
    b = int(n / a)
    if n == a * b:
        temp_digit = get_larger_digits(a, b)
        min_digit = min(min_digit, temp_digit)
print(min_digit)

Buggy python submission (verdict: Time Limit Exceeded):
def choose_larger_digit(a, b):
    return max(number_of_digits(a), number_of_digits(b))


def number_of_digits(n):
    digit = 0
    while n>0:
        digit = digit + 1
        n = int(n/10)
    return digit


n = int(input())
min_digits_diff = float('inf')
for a in range(1, n+1):
    b = int(n / a)
    if n == a * b:
        min_digits_diff = min(min_digits_diff, choose_larger_digit(a, b))
print(min_digits_diff)

Fixed submission:
# atcoder
import math

def get_number_of_digits(n):
    return int(math.log10(n) + 1)

def get_larger_digits(a, b):
    return max(get_number_of_digits(a), get_number_of_digits(b))

n = int(input())
min_digit = float('inf')
for a in range(1, int(math.sqrt(float(n))+5.0)):
    if n % a != 0:
        continue
    b = int(n / a)
    if n == a * b:
        temp_digit = get_larger_digits(a, b)
        min_digit = min(min_digit, temp_digit)
print(min_digit)
Buggy python submission (verdict: Time Limit Exceeded):
def is_same(x, y, z, s):
    return x+y+z == s


k, s = [int(e) for e in input().split()]
ans = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if is_same(x,y,z,s):
                ans += 1
print(ans)

Fixed submission:
k, s = [int(e) for e in input().split()]
ans = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if 0 <= z and z <= k:
            ans = ans + 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(e) for e in input().split()]
ans = float("inf")
MIN, MAX = min(a), max(a)
for i in range(MIN, MAX):
    cost = 0
    for j in a:
        cost = cost + (i-j)**2
    ans = min(ans, cost)
print(cost)

Fixed submission:
n = int(input())
a = [int(e) for e in input().split()]
ans = float("inf")
MIN, MAX = min(a), max(a)
for i in range(MIN, MAX+1):
    cost = 0
    for j in a:
        cost = cost + (i-j)**2
    ans = min(ans, cost)
print(ans)
Buggy python submission (verdict: Runtime Error):
d = int(input())

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

sd = np.zeros((d, 26), dtype=np.int)
for i in range(d):
  s = list(map(int, input().split()))
  s_array = np.array(s)
  sd[i, :] = s_array

pp = np.zeros(26, dtype=np.int)
  
for i in range(d):
  pp += c
  pp_max = np.argmax(pp)+1
  pp_max_val = np.max(pp)
  print(np.sum(pp), pp_max, pp_max_val)
  sd_max = np.argmax(sd[i,:])+1
  sd_max_val = np.max(sd[i,:])
  print(sd_max, sd_max_val)
  if np.sum(pp) >= sd_max_val:
    t = pp_max
    pp[pp_max-1] = 0
  else:
    t = sd_max
  print(t)

Fixed submission:
import numpy as np

d = int(input())

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

sd = np.zeros((d, 26), dtype=np.int)
for i in range(d):
  s = list(map(int, input().split()))
  s_array = np.array(s)
  sd[i, :] = s_array
  
for i in range(d):
  print(np.argmax(sd[i, :])+1)
Buggy python submission (verdict: Runtime Error):
x, n = map(int, input().split())
c_list = []

for i in range (-100, 100, 1):
  c_list.append(i)

if n == 0:
  ans = x
else:
  p = list(map(int, input().split()))
  for i in range(len(p)):
    c_list[c_list.index(p[i])] = 250
  # print(c_list)
  diff = 500
  for i in range(len(c_list)):
    if abs(x - c_list[i]) < diff:
      diff = x - c_list[i]
      ans = c_list[i]

print(ans)

Fixed submission:
x, n = map(int, input().split())
c_list = []

for i in range (-101, 102, 1):
  c_list.append(i)

if n == 0:
  ans = x
else:
  p = list(map(int, input().split()))
  for i in range(len(p)):
    c_list[c_list.index(p[i])] = 250
  # print(c_list)
  diff = 500
  for i in range(len(c_list)):
    if abs(x - c_list[i]) < diff:
      diff = x - c_list[i]
      ans = c_list[i]

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

a_sorted=sorted(a)
ans = 1

if a_sorted[len(a_sorted)-1] == 0:
  ans = 0
else:
  for i in range(len(a_sorted)):
    ans = ans * a_sorted[i]
    if ans > 1000000000000000000:
      ans = -1
      break

print(ans)

Fixed submission:
a, b = map(int, input().split())

print(a*b)
Buggy python submission (verdict: Runtime Error):
import numpy as np

s = input()

# print(s)

ans = np.zeros((len(s)+1, len(s)+1), dtype = np.int)

# print(ans)

if len(s) >= 4:
  for i in range (0, len(s) - 3):
    for j in range (i + 4, len(s)+1):
      num = int(s[i:j])
      # print(num)
      if num % 2019 == 0:
        ans[i, j] += 1

# print(ans)

print(np.sum(ans))

Fixed submission:
s, w = map(int, input().split())

ans = 'unsafe'

if s > w:
  ans = 'safe'

print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

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

a_array = np.array(a)

ans_array = np.zeros((n//2, n), dtype = np.int)

if n >=4:

  ans_array[0, 0] = a_array[0]
  ans_array[0, 1] = a_array[1]
  ans_array[0, 2] = a_array[2]

  for i in range(1, n//2):
    j = 2*(i+1)
    # print(i, j)
    ans_array[i, j-2] = ans_array[i-1, j-4] + a_array[j-2]
    ans_array[i, j-1] = max(ans_array[i-1, j-4], ans_array[i-1, j-3]) + a_array[j-1]
    if j < n:
      ans_array[i, j]  = max(ans_array[i-1, j-3], ans_array[i-1, j-2]) + a_array[j]
  # print(ans_array)

  print(np.max(ans_array[-1, -3:]))

else:
  print(max(a_array))

Fixed submission:
n = list(input())

# print(n)
ans = "No"

for i in range(3):
  if n[i] == '7':
    ans = 'Yes'

print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np

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

a_array = np.array(a)

if n % 2 == 3:
  sum_1 = np.sum(a_array[0:-1:2])
  sum_2 = np.sum(a_array[1::2])
  ans = max(sum_1, sum_2)

else:
  max_value = np.zeros((2, n), dtype = np.int)
  max_value[0, 0] = a_array[0]
  max_value[1, 0] = 1
  max_value[0, 1] = a_array[1]
  max_value[1, 1] = 1
  max_value[0, 2] = max((max_value[0,0] + a_array[2]), a_array[2])
  if (max_value[0, 0] + a_array[2]) > a_array[2]:
    max_value[1, 2] = 2
  else:
    max_value[1, 2] = 1 

  for i in range (3, n):
    if (a_array[i] + max_value[0, i-2]) >= (a_array[i] + max_value[0, i-3]):
      if ((i-1) // 2) <= (max_value[1, i-2] + 1) == (i+1) // 2:
        max_value[0, i] = a_array[i] + max_value[0, i-2]
        max_value[1, i] = max_value[1, i-2] + 1
      else:
        max_value[0, i] = a_array[i] + max_value[0, i-3]
        max_value[1, i] = max_value[1, i-3] + 1
    else:
      if ((i-1) //2) <= (max_value[1, i-3] + 1) == (i+1) // 2:        
        max_value[0, i] = a_array[i] + max_value[0, i-3]
        max_value[1, i] = max_value[1, i-3] + 1
      else:
        max_value[0, i] = a_array[i] + max_value[0, i-2]
        max_value[1, i] = max_value[1, i-2] + 1
  # print(max_value)
  # print(max_value[1, -1], max_value[1, -2], max_value[1, -3])
  # print(max_value[0, -1], max_value[0, -2], max_value[0, -3])
  if max_value[1, -1] == n // 2:
    ans_1 = max_value[0, -1]
  else: 
    ans_1 = -9999999999999999
  if max_value[1, -2] == n // 2:
    ans_2 = max_value[0, -2]
  else: 
    ans_1 = -9999999999999999
  if max_value[1, -3] == n // 2:
    ans_3 = max_value[0, -3]
  else: 
    ans_3 = -9999999999999999
  ans = max(max(ans_1, ans_2), ans_3)

print(ans)

Fixed submission:
n = list(input())

# print(n)
ans = "No"

for i in range(3):
  if n[i] == '7':
    ans = 'Yes'

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import math
from functools import reduce

# def gcd(*numbers):
#     return reduce(math.gcd, numbers)

# def gcd_list(numbers):
#     return reduce(math.gcd, numbers)

k = int(input())

# ans_array = np.zeros((k, k, k), dtype = np.int)

ans = 0

for i in range(k):
  for j in range(k):
    for h in range(k):
      ans += math.gcd(math.gcd(i+1, j+1), h+1)

# print(ans_array)

# ans = np.sum(ans_array)

print(ans)

Fixed submission:
import math

k = int(input())

ans = 0

for i in range(k):
  for j in range(i,k):
    for h in range(j, k):
      if i == j == h:
        ans += math.gcd(math.gcd(i+1, j+1), h+1)
      elif (i != j) and (j != h) and (i != h):
        ans += math.gcd(math.gcd(i+1, j+1), h+1) * 6
      else:
      	ans += math.gcd(math.gcd(i+1, j+1), h+1) * 3
      
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import math
from functools import reduce

# def gcd(*numbers):
#     return reduce(math.gcd, numbers)

# def gcd_list(numbers):
#     return reduce(math.gcd, numbers)

k = int(input())

ans_array = np.zeros((k, k, k), dtype = np.int)

for i in range(k):
  for j in range(k):
    for h in range(k):
      ans_array[i, j, h] = math.gcd(math.gcd(i+1, j+1), h+1)

# print(ans_array)

ans = np.sum(ans_array)

print(ans)

Fixed submission:
import math

k = int(input())

ans = 0

for i in range(k):
  for j in range(i,k):
    for h in range(j, k):
      if i == j == h:
        ans += math.gcd(math.gcd(i+1, j+1), h+1)
      elif (i != j) and (j != h) and (i != h):
        ans += math.gcd(math.gcd(i+1, j+1), h+1) * 6
      else:
      	ans += math.gcd(math.gcd(i+1, j+1), h+1) * 3
      
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

k = int(input())

ans_array = np.zeros((k, k, k), dtype = np.int)

for i in range(k):
  for j in range(k):
    for h in range(k):
      if ans_array[i, j, h] == 0:
        m_gcd = gcd(i+1, j+1, h+1)
        ans_array[i, j, h] = m_gcd
        if ans_array[i, h, j] == 0:
          ans_array[i, h, j] = m_gcd
        if ans_array[h, j, i] == 0:
          ans_array[h, j, i] = m_gcd

# print(ans_array)
ans = np.sum(ans_array)

print(ans)

Fixed submission:
import math

k = int(input())

ans = 0

for i in range(k):
  for j in range(i,k):
    for h in range(j, k):
      if i == j == h:
        ans += math.gcd(math.gcd(i+1, j+1), h+1)
      elif (i != j) and (j != h) and (i != h):
        ans += math.gcd(math.gcd(i+1, j+1), h+1) * 6
      else:
      	ans += math.gcd(math.gcd(i+1, j+1), h+1) * 3
      
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())

ans = abs(n - k)

i = False

if n % k == 0:
  ans = 0
  i = True

while not i:
  if ans > abs(ans - k):
    ans = abs(ans - k)
  else:
    i = True

print(ans)

Fixed submission:
n, k = map(int, input().split())

ans = n % k

i = False

if ans == 0:
  i = True

while not i:
  if ans > abs(ans - k):
    ans = abs(ans - k)
  else:
    i = True

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

ans = 0

for i in range(n-2):
  if s[i:i+3] == "ABC":
    ans +=1

print(ans)

Fixed submission:
k, x = map(int, input().split())

total = k * 500
ans = "No"

if total >= x:
  ans = "Yes"

print(ans)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
d = list(map(int, input().split()))

n_str = str(n)
# print(n_str)

l = list(({0, 1, 2, 3, 4, 5, 6, 7, 8, 9} - set(d)))

# print(l)
ans_list = []

for i in range(len(n_str)):
  if int(n_str[i]) in l:
    ans_list.append(n_str[i])
  elif int(n_str[i]) < l[-1]:
    for j in range(len(l)):
      if l[j] > int(n_str[i]):
        ans_list.append(l[j])
        break
    for k in range(i+1, len(n_str)):
      ans_list.append(l[0])
    break

# print(ans_list)

ans = ''
for i in range(len(ans_list)):
  ans += str(ans_list[i])

print(int(ans))

Fixed submission:
n, k = map(int, input().split())
d = list(map(int, input().split()))

n_str = str(n)
# print(n_str)

l = list(({0, 1, 2, 3, 4, 5, 6, 7, 8, 9} - set(d)))

# print(l)

ans = n
found = False
while not found:
  found = True
  ans_str = str(ans)
  for i in range(len(ans_str)):
    if int(ans_str[i]) not in l:
      # print("NOT FOUND", ans_str[i])
      found = False
  ans +=1

ans -= 1

print(ans)
Buggy python submission (verdict: Runtime Error):
x=input()
if 400<=x and x<600:
 rank=8
elif 600<=x and x<800:
  rank=7
elif 800<=x and x<1000:
  rank=6
elif 1000<=x and x<1200:
  rank=5
elif 1200<=x and x<1400:
  rank=4
elif 1400<=x and x<1600:
  rank=3
elif 1600<=x and x<1800:
  rank=2
elif 1800<=x and x<2000:
  rank =1
print(rank)


Fixed submission:
x=input()
x=int(x)
if x>=400 and x<600:
  rank=8
elif 600<=x and x<800:
  rank=7
elif 800<=x and x<1000:
  rank=6
elif 1000<=x and x<1200:
  rank=5
elif 1200<=x and x<1400:
  rank=4
elif 1400<=x and x<1600:
  rank=3
elif 1600<=x and x<1800:
  rank=2
elif 1800<=x and x<2000:
  rank =1
print(rank)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
As = list(map(int, input().split()))

result = As[0]
for i in range(n-1):
    result = result*As[i+1]

if result <= 10**18:
    print(result)
else:
    print(-1)

Fixed submission:
n = int(input())
As = list(map(int, input().split()))

result = As[0]
if 0 in As:
    print(0)
else:
    for i in range(n-1):
        result = result*As[i+1]
        if result > 10**18 :
            print(-1)
            break
        else:
            continue
    if result <= 10**18 :
        print(result)
Buggy python submission (verdict: Runtime Error):
import math


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

if n[0] % 2 == 0:
  print(math.ceil(n[0] / 2 * n[1]))
  
elif n[1] % 2 ==0:
  print(math.ceil(n[1]/ 2 * n[0]))
  
  elif n[0] == 1 or n[1] == 1:
    print('1')
else:
  result = math.ceil(n[0] / 2) * math.ceil(n[1] / 2) + math.floor(n[0] / 2) *math.floor(n[1] / 2)
  print(result)

Fixed submission:
import math


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

if n[0] == 1 or n[1] == 1:
  print('1')
  
else:
  print(math.floor((n[0] * n[1] + 1)/ 2))

Buggy python submission (verdict: Runtime Error):
import math


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

if n[0] % 2 == 0:
  print(math.ceil(n[0] / 2 * n[1]))
  
elif n[1] % 2 ==0:
  print(math.ceil(n[1]/ 2 * n[0]))
  
  elif n[0] == 1 or n[1] == 1
else:
  result = math.ceil(n[0] / 2) * math.ceil(n[1] / 2) + math.floor(n[0] / 2) *math.floor(n[1] / 2)
  print(result)

Fixed submission:
import math


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

if n[0] == 1 or n[1] == 1:
  print('1')
  
else:
  print(math.floor((n[0] * n[1] + 1)/ 2))
Buggy python submission (verdict: Runtime Error):
(N,M) = list(map(int,input().split()))
Aorg = list(map(int,input().split()))

A = Aorg

A.sort(reverse=True)

for m in range(M):
  #print(int(A[0]/2))
  A[0] = int(A[0]/2)
  if A[0]<A[1]:
    A.sort(reverse=True)

print(sum(A))

Fixed submission:
S = input()

if S=='Sunny':
  print('Cloudy')
else:
  if S=='Cloudy':
    print('Rainy')
  else:
    print('Sunny')

Buggy python submission (verdict: Runtime Error):
S = input()

if S=='Sunny':
  print('Cloudy')
else:
  if S=='Cloudy':
    print('Rainy')
  else:
    print('Sunny')

Fixed submission:
S = input()

if S=='Sunny':
  print('Cloudy')
else:
  if S=='Cloudy':
    print('Rainy')
  else:
    print('Sunny')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

A = []
max1 = 0
max2 = 0

for i in range(N):
  B = int(input())
  if B>max1:
    max1 = B
  else:
    if B>max2:
      max2 = B
      
  A.append(B) 

for i in range(N):
  if A[i] == max(A):
    print(max2)
  else:
    print(max1)


Fixed submission:
N = int(input())

A = []
max1 = 0
max1i = 0
max2 = 0
max2i = 0

for i in range(N):
  B = int(input())
  if B>max1:
    max1i = i
    max1 = B
  else:
    if B>max2:
      max2 = B
      max2i = i

for i in range(N):
  A.append(max1)
A[max1i] = max2

for i in range(N):
  print(A[i])
Buggy python submission (verdict: Runtime Error):
L,R = map(int,input().split())

ans = 0
min_mod = 2019

if R-L+1<2019 :
  if R % 2019 > 0:
    if R-L == 0:
      min_mod = (L*R) % 2019
    else :
      for i in range(L,R) :
        print(i)
        for j in range(i+1,R):
          if min_mod > (i*j) % 2019:
            min_mod = (i*j) % 2019

    ans = min_mod
    
print(ans)

Fixed submission:
n,a,b = map(int,input().split())

print(min(n*a,b))

Buggy python submission (verdict: Runtime Error):
L,R = map(int,input().split())

ans = 0
min_mod = 2019

if R-L+1<2019 :
  if R % 2019 > 0:
    for i in range(L,R) :
      if L+1 == R :
        min_mod = (L*R) % 2019
      else :
        for j in range(L+1,R):
          if min_mod > (i*j) % 2019:
            min_mod = (i*j) % 2019

    ans = min_mod
    
print(ans)

Fixed submission:
n,a,b = map(int,input().split())

print(min(n*a,b))

Buggy python submission (verdict: Runtime Error):
L,R = map(int,input().split())

ans = 0
min_mod = 2019

if R-L<2019-1 :
  if R % 2019 > 0:
    for i in range(R-L) :
      if min_mod > (L + i) % 2019 :
        min_mod = (L + i) % 2019
    
    ans = min_mod * (min_mod + 1)

print(ans)

Fixed submission:
n,a,b = map(int,input().split())

print(min(n*a,b))
Buggy python submission (verdict: Runtime Error):
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)

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

Buggy python submission (verdict: Runtime Error):
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)

Fixed submission:
#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)
Buggy python submission (verdict: Runtime Error):
li = list(map(int,input().split()))
if sum(li) <22:
  print('win')
  else:
    print('bust')

Fixed submission:
li = list(map(int,input().split()))
if sum(li) <22:
  print('win')
else:
  print('bust')
Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
les = 0
for i in range(n):
  if s[i] != s[n - i - 1]:
    les++;
print(les / 2)

Fixed submission:
s=input()
n=len(s)
res = 0
for i in range(n):
  if s[i] != s[n - i - 1]:
    res += 1
print(int(res / 2))
Buggy python submission (verdict: Runtime Error):
import sys

n = int(input())
s = input()
if n == 1:
  print("No")
  sys.exit()
n = n / 2
if s[:n]  == s[n:]:
    print("Yes")
else:
    print ("No")

Fixed submission:
import sys

n = int(input())
s = input()
if n == 1:
  print("No")
  sys.exit()
n = n // 2
if s[:n]  == s[n:]:
    print("Yes")
else:
    print ("No")

Buggy python submission (verdict: Runtime Error):
n = int(input())
input(s)
if s == s[n - 1:]:
    print("Yes")
    else
    print ("No")

Fixed submission:
import sys

n = int(input())
s = input()
if n == 1:
  print("No")
  sys.exit()
n = n // 2
if s[:n]  == s[n:]:
    print("Yes")
else:
    print ("No")

Buggy python submission (verdict: Runtime Error):
n = int(input())
input(s)
if s == s[n - 1:]:
  print("Yes")
else
  print ("No")    

Fixed submission:
import sys

n = int(input())
s = input()
if n == 1:
  print("No")
  sys.exit()
n = n // 2
if s[:n]  == s[n:]:
    print("Yes")
else:
    print ("No")

Buggy python submission (verdict: Runtime Error):
n = int(input())
input(s)
if (s == s[n - 1:])
  print("Yes")
else
  print ("No")    

Fixed submission:
import sys

n = int(input())
s = input()
if n == 1:
  print("No")
  sys.exit()
n = n // 2
if s[:n]  == s[n:]:
    print("Yes")
else:
    print ("No")

Buggy python submission (verdict: Runtime Error):
n = int(input())
input(s)
s1 = [s[i : i + n / 2] for i in range(0, len(s), n / 2)]
if (s == s1)
  print("Yes")
else
  print ("No")    

Fixed submission:
import sys

n = int(input())
s = input()
if n == 1:
  print("No")
  sys.exit()
n = n // 2
if s[:n]  == s[n:]:
    print("Yes")
else:
    print ("No")

Buggy python submission (verdict: Runtime Error):
n = int(input())
input(s)
s1 = [s[i : i + n / 2] for i in range(0, len(s), n / 2)]
if (s1 == s2)
  print("Yes")
else
  print ("No")    

Fixed submission:
import sys

n = int(input())
s = input()
if n == 1:
  print("No")
  sys.exit()
n = n // 2
if s[:n]  == s[n:]:
    print("Yes")
else:
    print ("No")