
from __future__ import annotations

_UpperCAmelCase      :				Any          = [-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0]
_UpperCAmelCase      :				Any          = [-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1]


def    A (      lowercase				)     ->						list[float]:
		'''simple docstring'''

		UpperCamelCase						=  []
		UpperCamelCase						=  len(lowercase				)

		for i in range(lowercase				):
				UpperCamelCase						=  -1
				for j in range(i + 1					, lowercase				):
						if arr[i] < arr[j]:
								UpperCamelCase						=  arr[j]
								break
				result.append(lowercase				)
		return result


def    A (      lowercase				)     ->						list[float]:
		'''simple docstring'''

		UpperCamelCase						=  []
		for i, outer in enumerate(lowercase				):
				UpperCamelCase						=  -1
				for inner in arr[i + 1 :]:
						if outer < inner:
								UpperCamelCase						=  inner
								break
				result.append(lowercase				)
		return result


def    A (      lowercase				)     ->						list[float]:
		'''simple docstring'''

		UpperCamelCase						=  len(lowercase				)
		UpperCamelCase						=  []
		UpperCamelCase						=  [-1] * arr_size

		for index in reversed(range(lowercase				)				):
				if stack:
						while stack[-1] <= arr[index]:
								stack.pop()
								if not stack:
										break
				if stack:
						UpperCamelCase						=  stack[-1]
				stack.append(arr[index]				)
		return result


if __name__ == "__main__":
					from doctest import testmod
					from timeit import timeit

					testmod()
					print(next_greatest_element_slow(arr))
					print(next_greatest_element_fast(arr))
					print(next_greatest_element(arr))

					_UpperCAmelCase      :				List[str]          = (
					    "from __main__ import arr, next_greatest_element_slow, "
					    "next_greatest_element_fast, next_greatest_element"
					)
					print(
					    "next_greatest_element_slow():",
					    timeit("next_greatest_element_slow(arr)", setup=setup),
					)
					print(
					    "next_greatest_element_fast():",
					    timeit("next_greatest_element_fast(arr)", setup=setup),
					)
					print(
					    "     next_greatest_element():",
					    timeit("next_greatest_element(arr)", setup=setup),
					)


import os

_UpperCAmelCase      :				int          = {"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1_000}


def    A (      lowercase				)     ->						int:
		'''simple docstring'''

		UpperCamelCase						=  0

		UpperCamelCase						=  0
		while index < len(lowercase				) - 1:
				UpperCamelCase						=  SYMBOLS[numerals[index]]
				UpperCamelCase						=  SYMBOLS[numerals[index + 1]]
				if current_value < next_value:
						total_value -= current_value
				else:
						total_value += current_value
				index += 1
		total_value += SYMBOLS[numerals[index]]

		return total_value


def    A (      lowercase				)     ->						str:
		'''simple docstring'''

		UpperCamelCase						=  ''

		UpperCamelCase						=  num // 1_000
		numerals += m_count * "M"
		num %= 1_000

		UpperCamelCase						=  num // 100
		if c_count == 9:
				numerals += "CM"
				c_count -= 9
		elif c_count == 4:
				numerals += "CD"
				c_count -= 4
		if c_count >= 5:
				numerals += "D"
				c_count -= 5
		numerals += c_count * "C"
		num %= 100

		UpperCamelCase						=  num // 10
		if x_count == 9:
				numerals += "XC"
				x_count -= 9
		elif x_count == 4:
				numerals += "XL"
				x_count -= 4
		if x_count >= 5:
				numerals += "L"
				x_count -= 5
		numerals += x_count * "X"
		num %= 10

		if num == 9:
				numerals += "IX"
				num -= 9
		elif num == 4:
				numerals += "IV"
				num -= 4
		if num >= 5:
				numerals += "V"
				num -= 5
		numerals += num * "I"

		return numerals


def    A (      lowercase = "/p089_roman.txt"				)     ->						int:
		'''simple docstring'''

		UpperCamelCase						=  0

		with open(os.path.dirname(lowercase				) + roman_numerals_filename				) as filea:
				UpperCamelCase						=  filea.readlines()

		for line in lines:
				UpperCamelCase						=  line.strip()
				UpperCamelCase						=  parse_roman_numerals(lowercase				)
				UpperCamelCase						=  generate_roman_numerals(lowercase				)
				savings += len(lowercase				) - len(lowercase				)

		return savings


if __name__ == "__main__":
					print(F'''{solution() = }''')
