


from __future__ import annotations

def 			_a  (				SCREAMING_SNAKE_CASE	:				list[int]    , SCREAMING_SNAKE_CASE	:				int     ):







 """simple docstring"""



 if len(SCREAMING_SNAKE_CASE     ) < k or k < 0:
  raise ValueError('''Invalid Input'''     )
 UpperCamelCase__					:    Tuple          =   sum(array[:k]     )
 for i in range(len(SCREAMING_SNAKE_CASE     ) - k     ):
  UpperCamelCase__					:    List[Any]          =   current_sum - array[i] + array[i + k]
  UpperCamelCase__					:    str          =   max(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     )
 return max_sum


if __name__ == "__main__":
      from doctest import testmod
      from random import randint

      testmod()
      __UpperCamelCase       :       int						       =				[randint(-1000, 1000) for i in range(100)]
      __UpperCamelCase       :       Optional[int]						       =				randint(0, 110)
      print(f"The maximum sum of {k} consecutive elements is {max_sum_in_array(array,k)}")






__UpperCamelCase       :       List[Any]						       =				256
# Modulus to hash a string
__UpperCamelCase       :       Union[str, Any]						       =				100_0003

def 			_a  (				SCREAMING_SNAKE_CASE	:				str    , SCREAMING_SNAKE_CASE	:				str     ):







 """simple docstring"""



 UpperCamelCase__					:    Optional[int]          =   len(SCREAMING_SNAKE_CASE     )
 UpperCamelCase__					:    List[Any]          =   len(SCREAMING_SNAKE_CASE     )
 if p_len > t_len:
  return False

 UpperCamelCase__					:    Any          =   0
 UpperCamelCase__					:    str          =   0
 UpperCamelCase__					:    List[Any]          =   1

 # Calculating the hash of pattern and substring of text
 for i in range(SCREAMING_SNAKE_CASE     ):
  UpperCamelCase__					:    Any          =   (ord(pattern[i]     ) + p_hash * alphabet_size) % modulus
  UpperCamelCase__					:    List[str]          =   (ord(text[i]     ) + text_hash * alphabet_size) % modulus
  if i == p_len - 1:
   continue
  UpperCamelCase__					:    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
  UpperCamelCase__					:    Optional[int]          =   (
      (text_hash - ord(text[i]     ) * modulus_power) * alphabet_size
      + ord(text[i + p_len]     )
  ) % modulus
 return False

def 			_a  (				):







 """simple docstring"""



 UpperCamelCase__					:    Tuple          =   '''abc1abc12'''
 UpperCamelCase__					:    Dict          =   '''alskfjaldsabc1abc1abc12k23adsfabcabc'''
 UpperCamelCase__					:    List[str]          =   '''alskfjaldsk23adsfabcabc'''
 assert rabin_karp(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     ) and not rabin_karp(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     )

 # Test 2)
 UpperCamelCase__					:    Optional[int]          =   '''ABABX'''
 UpperCamelCase__					:    int          =   '''ABABZABABYABABX'''
 assert rabin_karp(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     )

 # Test 3)
 UpperCamelCase__					:    int          =   '''AAAB'''
 UpperCamelCase__					:    str          =   '''ABAAAAAB'''
 assert rabin_karp(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     )

 # Test 4)
 UpperCamelCase__					:    Union[str, Any]          =   '''abcdabcy'''
 UpperCamelCase__					:    List[str]          =   '''abcxabcdabxabcdabcdabcy'''
 assert rabin_karp(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     )

 # Test 5)
 UpperCamelCase__					:    Tuple          =   '''Lü'''
 UpperCamelCase__					:    Any          =   '''Lüsai'''
 assert rabin_karp(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     )
 UpperCamelCase__					:    Dict          =   '''Lue'''
 assert not rabin_karp(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     )
 print('''Success.'''     )


if __name__ == "__main__":
       test_rabin_karp()


