
'''simple docstring'''







from __future__ import annotations

_lowercase :  List[str]    							=       [-1_0, -5, 0, 5, 5.1, 1_1, 1_3, 2_1, 3, 4, -2_1, -1_0, -5, -1, 0]
_lowercase :  List[Any]    							=       [-5, 0, 5, 5.1, 1_1, 1_3, 2_1, -1, 4, -1, -1_0, -5, -1, 0, -1]
def 					snake_case_		(				__SCREAMING_SNAKE_CASE					: list[float]							):



						"""simple docstring"""





						lowercase_	:     Dict													=       []
						lowercase_	:     int													=       len(__SCREAMING_SNAKE_CASE							)

						for i in range(__SCREAMING_SNAKE_CASE							):
												lowercase_	:     float													=       -1
												for j in range(i + 1      ,      __SCREAMING_SNAKE_CASE							):
																		if arr[i] < arr[j]:
																								lowercase_	:     int													=       arr[j]
																								break
												result.append(__SCREAMING_SNAKE_CASE							)
						return result
def 					snake_case_		(				__SCREAMING_SNAKE_CASE					: list[float]							):



						"""simple docstring"""





						lowercase_	:     Optional[Any]													=       []
						for i, outer in enumerate(__SCREAMING_SNAKE_CASE							):
												lowercase_	:     float													=       -1
												for inner in arr[i + 1 :]:
																		if outer < inner:
																								lowercase_	:     Tuple													=       inner
																								break
												result.append(__SCREAMING_SNAKE_CASE							)
						return result
def 					snake_case_		(				__SCREAMING_SNAKE_CASE					: list[float]							):



						"""simple docstring"""





						lowercase_	:     Optional[Any]													=       len(__SCREAMING_SNAKE_CASE							)
						lowercase_	:     list[float]													=       []
						lowercase_	:     list[float]													=       [-1] * arr_size

						for index in reversed(range(__SCREAMING_SNAKE_CASE							)							):
												if stack:
																		while stack[-1] <= arr[index]:
																								stack.pop()
																								if not stack:
																														break
												if stack:
																		lowercase_	:     Tuple													=       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))

							_lowercase :  Union[str, Any]    							=       (
							    "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 functools
from typing import Any
def 		UpperCamelCase	(   snake_case__       :    str       ,     snake_case__       :    list[str]	)	->     bool:

   # Validation
   if not isinstance(snake_case__       ,     snake_case__	) or len(snake_case__	) == 0:
      raise ValueError('the string should be not empty string'	)

   if not isinstance(snake_case__       ,     snake_case__	) or not all(
       isinstance(snake_case__       ,     snake_case__	) and len(snake_case__	) > 0 for item in words	):
      raise ValueError('the words should be a list of non-empty strings'	)

   # Build trie
   UpperCamelCase    :  dict[str, Any]							=	{}
   UpperCamelCase    :  List[str]							=	'WORD_KEEPER'

   for word in words:
      UpperCamelCase    :  List[str]							=	trie
      for c in word:
         if c not in trie_node:
            UpperCamelCase    :  int							=	{}

         UpperCamelCase    :  str							=	trie_node[c]

      UpperCamelCase    :  Tuple							=	True

   UpperCamelCase    :  List[Any]							=	len(snake_case__	)

   # Dynamic programming method
   @functools.cache
   def is_breakable(snake_case__       :    int	) -> bool:
      if index == len_string:
         return True

      UpperCamelCase    :  Dict							=	trie
      for i in range(snake_case__       ,     snake_case__	):
         UpperCamelCase    :  List[Any]							=	trie_node.get(string[i]       ,     snake_case__	)

         if trie_node is None:
            return False

         if trie_node.get(snake_case__       ,     snake_case__	) and is_breakable(i + 1	):
            return True

      return False

   return is_breakable(0	)


if __name__ == "__main__":
    import doctest

    doctest.testmod()



