
from __future__ import annotations

__a  			=					[-1_0, -5, 0, 5, 5.1, 1_1, 1_3, 2_1, 3, 4, -2_1, -1_0, -5, -1, 0]
__a  			=					[-5, 0, 5, 5.1, 1_1, 1_3, 2_1, -1, 4, -1, -1_0, -5, -1, 0, -1]




def 				a						(							snake_case__:					list[float]					):


				'''simple docstring'''
				lowercase_       =					[]
				lowercase_       =					len(__lowerCAmelCase					)

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




def 				a						(							snake_case__:					list[float]					):


				'''simple docstring'''
				lowercase_       =					[]
				for i, outer in enumerate(__lowerCAmelCase					):
								lowercase_       =					-1
								for inner in arr[i + 1 :]:
												if outer < inner:
																lowercase_       =					inner
																break
								result.append(__lowerCAmelCase					)
				return result




def 				a						(							snake_case__:					list[float]					):


				'''simple docstring'''
				lowercase_       =					len(__lowerCAmelCase					)
				lowercase_       =					[]
				lowercase_       =					[-1] * arr_size

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

						__a  			=					(
						    '''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),
						)








def 							__lowercase   ( __lowerCAmelCase							:				list[int]   ):
							a__             =     []
							if len(__lowerCAmelCase   ) == 1:
														return [nums.copy()]
							for _ in range(len(__lowerCAmelCase   )   ):
														a__             =     nums.pop(0   )
														a__             =     permute(__lowerCAmelCase   )
														for perm in permutations:
																					perm.append(__lowerCAmelCase   )
														result.extend(__lowerCAmelCase   )
														nums.append(__lowerCAmelCase   )
							return result






def 							__lowercase   ( __lowerCAmelCase							:				Optional[int]   ):

							def backtrack(__lowerCAmelCase							:				Any   ):
														if start == len(__lowerCAmelCase   ) - 1:
																					output.append(nums[:]   )
														else:
																					for i in range(__lowerCAmelCase					,    len(__lowerCAmelCase   )   ):
																												a__      ,					a__             =     nums[i], nums[start]
																												backtrack(start + 1   )
																												a__      ,					a__             =     nums[i], nums[start]  # backtrack

							a__             =     []
							backtrack(0   )
							return output


if __name__ == "__main__":
						import doctest

						# use res to print the data in permute2 function
						snake_case							:       Optional[Any]     			=      permutea([1, 2, 3])
						print(res)
						doctest.testmod()




