






'''simple docstring'''

import random
def     __lowercase  (_lowercase,						_lowercase,						_lowercase     )   ->     Tuple:


     """simple docstring"""
     __lowerCamelCase						:       Union[str, Any]				   =				a[left_index]
     __lowerCamelCase						:       Any				   =				left_index + 1
     for j in range(left_index + 1,						_lowercase     ):
          if a[j] < pivot:
               __lowerCamelCase   ,      __lowerCamelCase						:       List[Any]				   =				a[i], a[j]
               i += 1
     __lowerCamelCase   ,      __lowerCamelCase						:       Optional[int]				   =				a[i - 1], a[left_index]
     return i - 1
def     __lowercase  (_lowercase,						_lowercase,						_lowercase     )   ->     List[str]:


     """simple docstring"""
     if left < right:
          __lowerCamelCase						:       List[str]				   =				random.randint(_lowercase,						right - 1     )
          __lowerCamelCase   ,      __lowerCamelCase						:       Optional[Any]				   =				(
              a[left],
              a[pivot],
          )  # switches the pivot with the left most bound
          __lowerCamelCase						:       Tuple				   =				partition(_lowercase,						_lowercase,						_lowercase     )
          quick_sort_random(
              _lowercase,						_lowercase,						_lowercase     )  # recursive quicksort to the left of the pivot point
          quick_sort_random(
              _lowercase,						pivot_index + 1,						_lowercase     )  # recursive quicksort to the right of the pivot point
def     __lowercase  ()   ->     Dict:


     """simple docstring"""
     __lowerCamelCase						:       List[Any]				   =				input("""Enter numbers separated by a comma:\n"""     ).strip()
     __lowerCamelCase						:       Tuple				   =				[int(_lowercase     ) for item in user_input.split(""","""     )]

     quick_sort_random(_lowercase,						0,						len(_lowercase     )     )

     print(_lowercase     )


if __name__ == "__main__":
   main()











'''simple docstring'''

UpperCAmelCase__						:List[Any]          =			256
# Modulus to hash a string
UpperCAmelCase__						:str          =			1_000_003
def     __lowercase  (_lowercase,						_lowercase     )   ->     bool:


     """simple docstring"""
     __lowerCamelCase						:       str				   =				len(_lowercase     )
     __lowerCamelCase						:       List[str]				   =				len(_lowercase     )
     if p_len > t_len:
          return False

     __lowerCamelCase						:       Optional[Any]				   =				0
     __lowerCamelCase						:       Tuple				   =				0
     __lowerCamelCase						:       Dict				   =				1

     # Calculating the hash of pattern and substring of text
     for i in range(_lowercase     ):
          __lowerCamelCase						:       Optional[int]				   =				(ord(pattern[i]     ) + p_hash * alphabet_size) % modulus
          __lowerCamelCase						:       Dict				   =				(ord(text[i]     ) + text_hash * alphabet_size) % modulus
          if i == p_len - 1:
               continue
          __lowerCamelCase						:       Dict				   =				(modulus_power * alphabet_size) % modulus

     for i in range(0,						t_len - p_len + 1     ):
          if text_hash == p_hash and text[i : i + p_len] == pattern:
               return True
          if i == t_len - p_len:
               continue
          # Calculate the https://en.wikipedia.org/wiki/Rolling_hash
          __lowerCamelCase						:       Dict				   =				(
              (text_hash - ord(text[i]     ) * modulus_power) * alphabet_size
              + ord(text[i + p_len]     )
          ) % modulus
     return False
def     __lowercase  ()   ->     None:


     """simple docstring"""
     __lowerCamelCase						:       List[Any]				   =				"""abc1abc12"""
     __lowerCamelCase						:       Optional[Any]				   =				"""alskfjaldsabc1abc1abc12k23adsfabcabc"""
     __lowerCamelCase						:       List[Any]				   =				"""alskfjaldsk23adsfabcabc"""
     assert rabin_karp(_lowercase,						_lowercase     ) and not rabin_karp(_lowercase,						_lowercase     )

     # Test 2)
     __lowerCamelCase						:       Optional[int]				   =				"""ABABX"""
     __lowerCamelCase						:       Dict				   =				"""ABABZABABYABABX"""
     assert rabin_karp(_lowercase,						_lowercase     )

     # Test 3)
     __lowerCamelCase						:       Any				   =				"""AAAB"""
     __lowerCamelCase						:       int				   =				"""ABAAAAAB"""
     assert rabin_karp(_lowercase,						_lowercase     )

     # Test 4)
     __lowerCamelCase						:       Any				   =				"""abcdabcy"""
     __lowerCamelCase						:       Dict				   =				"""abcxabcdabxabcdabcdabcy"""
     assert rabin_karp(_lowercase,						_lowercase     )

     # Test 5)
     __lowerCamelCase						:       str				   =				"""Lü"""
     __lowerCamelCase						:       str				   =				"""Lüsai"""
     assert rabin_karp(_lowercase,						_lowercase     )
     __lowerCamelCase						:       Tuple				   =				"""Lue"""
     assert not rabin_karp(_lowercase,						_lowercase     )
     print("""Success."""     )


if __name__ == "__main__":
   test_rabin_karp()



