


from __future__ import annotations

def 						_UpperCAmelCase    (      SCREAMING_SNAKE_CASE__      : list[int]    ):  # This function is recursive
					__UpperCamelCase   							=len(SCREAMING_SNAKE_CASE__    )
					# If the array contains only one element, we return it (it's the stop condition of
					# recursion)
					if array_length <= 1:
										return array
										# Else
					__UpperCamelCase   							=array[0]
					__UpperCamelCase   							=False
					__UpperCamelCase   							=1
					__UpperCamelCase   							=[]
					while not is_found and i < array_length:
										if array[i] < pivot:
															__UpperCamelCase   							=True
															__UpperCamelCase   							=[element for element in array[i:] if element >= array[i]]
															__UpperCamelCase   							=longest_subsequence(SCREAMING_SNAKE_CASE__    )
															if len(SCREAMING_SNAKE_CASE__    ) > len(SCREAMING_SNAKE_CASE__    ):
																				__UpperCamelCase   							=temp_array
										else:
															i += 1

					__UpperCamelCase   							=[element for element in array[1:] if element >= pivot]
					__UpperCamelCase   							=[pivot, *longest_subsequence(SCREAMING_SNAKE_CASE__    )]
					if len(SCREAMING_SNAKE_CASE__    ) > len(SCREAMING_SNAKE_CASE__    ):
										return temp_array
					else:
										return longest_subseq


if __name__ == "__main__":
			import doctest

			doctest.testmod()









from __future__ import annotations

from typing import Any

def 						_UpperCAmelCase    (      SCREAMING_SNAKE_CASE__      : list[Any]    ):
     create_state_space_tree(SCREAMING_SNAKE_CASE__      ,					[]      ,					0    )

def 						_UpperCAmelCase    (      SCREAMING_SNAKE_CASE__      : list[Any]      ,					SCREAMING_SNAKE_CASE__      : list[Any]      ,					SCREAMING_SNAKE_CASE__      : int    ):

     if index == len(SCREAMING_SNAKE_CASE__    ):
          print(SCREAMING_SNAKE_CASE__    )
          return

     create_state_space_tree(SCREAMING_SNAKE_CASE__      ,					SCREAMING_SNAKE_CASE__      ,					index + 1    )
     current_subsequence.append(sequence[index]    )
     create_state_space_tree(SCREAMING_SNAKE_CASE__      ,					SCREAMING_SNAKE_CASE__      ,					index + 1    )
     current_subsequence.pop()


if __name__ == "__main__":
   _A			=						[3, 1, 2, 4]
   generate_all_subsequences(seq)

   seq.clear()
   seq.extend(['A', 'B', 'C'])
   generate_all_subsequences(seq)





