__magic_name__								='''ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'''







def  __UpperCamelCase    (						A							):
     # Make sure the supplied data is a bytes-like object
     if not isinstance(A ,							A							):
          UpperCamelCase__										=      f"a bytes-like object is required, not '{data.__class__.__name__}'"
          raise TypeError(A							)

     UpperCamelCase__										=      ''''''.join(bin(A							)[2:].zfill(8							) for byte in data							)

     UpperCamelCase__										=      len(A							) % 6 != 0

     if padding_needed:
          # The padding that will be added later
          UpperCamelCase__										=      B'''=''' * ((6 - len(A							) % 6) // 2)

          # Append binary_stream with arbitrary binary digits (0's by default) to make its
          # length a multiple of 6.
          binary_stream += "0" * (6 - len(A							) % 6)
     else:
          UpperCamelCase__										=      B''''''

     # Encode every 6 binary digits to their corresponding Base64 character
     return (
         "".join(
             B64_CHARSET[int(binary_stream[index : index + 6] ,							2							)]
             for index in range(0 ,							len(A							) ,							6							)							).encode()
         + padding
     )







def  __UpperCamelCase    (						A							):
     # Make sure encoded_data is either a string or a bytes-like object
     if not isinstance(A ,							A							) and not isinstance(A ,							A							):
          UpperCamelCase__										=      (
              '''argument should be a bytes-like object or ASCII string, '''
              f"not '{encoded_data.__class__.__name__}'"
          )
          raise TypeError(A							)

     # In case encoded_data is a bytes-like object, make sure it contains only
     # ASCII characters so we convert it to a string object
     if isinstance(A ,							A							):
          try:
               UpperCamelCase__										=      encoded_data.decode('''utf-8'''							)
          except UnicodeDecodeError:
               raise ValueError('''base64 encoded data should only contain ASCII characters'''							)

     UpperCamelCase__										=      encoded_data.count('''='''							)

     # Check if the encoded string contains non base64 characters
     if padding:
          assert all(
              char in B64_CHARSET for char in encoded_data[:-padding]							), "Invalid base64 character(s) found."
     else:
          assert all(
              char in B64_CHARSET for char in encoded_data							), "Invalid base64 character(s) found."

     # Check the padding
     assert len(A							) % 4 == 0 and padding < 3, "Incorrect padding"

     if padding:
          # Remove padding if there is one
          UpperCamelCase__										=      encoded_data[:-padding]

          UpperCamelCase__										=      ''''''.join(
              bin(B64_CHARSET.index(A							)							)[2:].zfill(6							) for char in encoded_data							)[: -padding * 2]
     else:
          UpperCamelCase__										=      ''''''.join(
              bin(B64_CHARSET.index(A							)							)[2:].zfill(6							) for char in encoded_data							)

     UpperCamelCase__										=      [
         int(binary_stream[index : index + 8] ,							2							)
         for index in range(0 ,							len(A							) ,							8							)
     ]

     return bytes(A							)


if __name__ == "__main__":
     import doctest

     doctest.testmod()




from __future__ import annotations







def  __UpperCamelCase    (						A ,							A							):
     UpperCamelCase__										=      get_failure_array(A							)

     # 2) Step through text searching for pattern
     UpperCamelCase__						,       UpperCamelCase__										=      0, 0  # index into text, pattern
     while i < len(A							):
          if pattern[j] == text[i]:
               if j == (len(A							) - 1):
                    return True
               j += 1

          # if this is a prefix in our pattern
          # just go back far enough to continue
          elif j > 0:
               UpperCamelCase__										=      failure[j - 1]
               continue
          i += 1
     return False







def  __UpperCamelCase    (						A							):
     UpperCamelCase__										=      [0]
     UpperCamelCase__										=      0
     UpperCamelCase__										=      1
     while j < len(A							):
          if pattern[i] == pattern[j]:
               i += 1
          elif i > 0:
               UpperCamelCase__										=      failure[i - 1]
               continue
          j += 1
          failure.append(A							)
     return failure


if __name__ == "__main__":
     # Test 1)
     __magic_name__								='''abc1abc12'''
     __magic_name__								='''alskfjaldsabc1abc1abc12k23adsfabcabc'''
     __magic_name__								='''alskfjaldsk23adsfabcabc'''
     assert kmp(pattern, texta) and not kmp(pattern, texta)

     # Test 2)
     __magic_name__								='''ABABX'''
     __magic_name__								='''ABABZABABYABABX'''
     assert kmp(pattern, text)

     # Test 3)
     __magic_name__								='''AAAB'''
     __magic_name__								='''ABAAAAAB'''
     assert kmp(pattern, text)

     # Test 4)
     __magic_name__								='''abcdabcy'''
     __magic_name__								='''abcxabcdabxabcdabcdabcy'''
     assert kmp(pattern, text)

     # Test 5)
     __magic_name__								='''aabaabaaa'''
     assert get_failure_array(pattern) == [0, 1, 0, 1, 2, 3, 4, 5, 2]



