





from collections.abc import Generator
from math import sin







def   __lowerCamelCase   (				__a  :Tuple       )						->							bytes:






		"""simple docstring"""

		if len(__lowerCAmelCase       ) != 3_2:
				raise ValueError("""Input must be of length 32"""       )

		A__     =  b""""""
		for i in [3, 2, 1, 0]:
				little_endian += string_aa[8 * i : 8 * i + 8]
		return little_endian







def   __lowerCamelCase   (				__a  :int       )						->							bytes:






		"""simple docstring"""

		if i < 0:
				raise ValueError("""Input must be non-negative"""       )

		A__     =  format(__lowerCAmelCase       ,	"""08x"""       )[-8:]
		A__     =  b""""""
		for i in [3, 2, 1, 0]:
				little_endian_hex += hex_rep[2 * i : 2 * i + 2].encode("""utf-8"""       )
		return little_endian_hex







def   __lowerCamelCase   (				__a  :Union[str, Any]       )						->							bytes:






		"""simple docstring"""

		A__     =  b""""""
		for char in message:
				bit_string += format(__lowerCAmelCase       ,	"""08b"""       ).encode("""utf-8"""       )
		A__     =  format(len(__lowerCAmelCase       )       ,	"""064b"""       ).encode("""utf-8"""       )

		# Pad bit_string to a multiple of 512 chars
		bit_string += b"1"
		while len(__lowerCAmelCase       ) % 5_1_2 != 4_4_8:
				bit_string += b"0"
		bit_string += to_little_endian(start_len[3_2:]       ) + to_little_endian(start_len[:3_2]       )

		return bit_string







def   __lowerCamelCase   (				__a  :Dict       )						->							Generator[list[int], None, None]:






		"""simple docstring"""

		if len(__lowerCAmelCase       ) % 5_1_2 != 0:
				raise ValueError("""Input must have length that's a multiple of 512"""       )

		for pos in range(0       ,	len(__lowerCAmelCase       )       ,	5_1_2       ):
				A__     =  bit_string[pos : pos + 5_1_2]
				A__     =  []
				for i in range(0       ,	5_1_2       ,	3_2       ):
						block_words.append(int(to_little_endian(block[i : i + 3_2]       )       ,	2       )       )
				yield block_words







def   __lowerCamelCase   (				__a  :List[Any]       )						->							int:






		"""simple docstring"""

		if i < 0:
				raise ValueError("""Input must be non-negative"""       )

		A__     =  format(__lowerCAmelCase       ,	"""032b"""       )
		A__     =  """"""
		for c in i_str:
				new_str += "1" if c == "0" else "0"
		return int(__lowerCAmelCase       ,	2       )







def   __lowerCamelCase   (				__a  :Union[str, Any]       ,	__a  :Union[str, Any]       )						->							int:






		"""simple docstring"""

		return (a + b) % 2**3_2







def   __lowerCamelCase   (				__a  :List[str]       ,	__a  :Any       )						->							int:






		"""simple docstring"""

		if i < 0:
				raise ValueError("""Input must be non-negative"""       )
		if shift < 0:
				raise ValueError("""Shift must be non-negative"""       )
		return ((i << shift) ^ (i >> (3_2 - shift))) % 2**3_2







def   __lowerCamelCase   (				__a  :Union[str, Any]       )						->							bytes:






		"""simple docstring"""

		A__     =  preprocess(__lowerCAmelCase       )

		A__     =  [int(2**3_2 * abs(sin(i + 1       )       )       ) for i in range(6_4       )]

		# Starting states
		A__     =  0X6_7_4_5_2_3_0_1
		A__     =  0XE_F_C_D_A_B_8_9
		A__     =  0X9_8_B_A_D_C_F_E
		A__     =  0X1_0_3_2_5_4_7_6

		A__     =  [
		    7,
		    1_2,
		    1_7,
		    2_2,
		    7,
		    1_2,
		    1_7,
		    2_2,
		    7,
		    1_2,
		    1_7,
		    2_2,
		    7,
		    1_2,
		    1_7,
		    2_2,
		    5,
		    9,
		    1_4,
		    2_0,
		    5,
		    9,
		    1_4,
		    2_0,
		    5,
		    9,
		    1_4,
		    2_0,
		    5,
		    9,
		    1_4,
		    2_0,
		    4,
		    1_1,
		    1_6,
		    2_3,
		    4,
		    1_1,
		    1_6,
		    2_3,
		    4,
		    1_1,
		    1_6,
		    2_3,
		    4,
		    1_1,
		    1_6,
		    2_3,
		    6,
		    1_0,
		    1_5,
		    2_1,
		    6,
		    1_0,
		    1_5,
		    2_1,
		    6,
		    1_0,
		    1_5,
		    2_1,
		    6,
		    1_0,
		    1_5,
		    2_1,
		]

		# Process bit string in chunks, each with 16 32-char words
		for block_words in get_block_words(__lowerCAmelCase       ):
				A__     =  aa
				A__     =  ba
				A__     =  ca
				A__     =  da

				# Hash current chunk
				for i in range(6_4       ):
						if i <= 1_5:
								# f = (b & c) | (not_32(b) & d)     # Alternate definition for f
								A__     =  d ^ (b & (c ^ d))
								A__     =  i
						elif i <= 3_1:
								# f = (d & b) | (not_32(d) & c)     # Alternate definition for f
								A__     =  c ^ (d & (b ^ c))
								A__     =  (5 * i + 1) % 1_6
						elif i <= 4_7:
								A__     =  b ^ c ^ d
								A__     =  (3 * i + 5) % 1_6
						else:
								A__     =  c ^ (b | not_aa(__lowerCAmelCase       ))
								A__     =  (7 * i) % 1_6
						A__     =  (f + a + added_consts[i] + block_words[g]) % 2**3_2
						A__     =  d
						A__     =  c
						A__     =  b
						A__     =  sum_aa(__lowerCAmelCase       ,	left_rotate_aa(__lowerCAmelCase       ,	shift_amounts[i]       )       )

				# Add hashed chunk to running total
				A__     =  sum_aa(__lowerCAmelCase       ,	__lowerCAmelCase       )
				A__     =  sum_aa(__lowerCAmelCase       ,	__lowerCAmelCase       )
				A__     =  sum_aa(__lowerCAmelCase       ,	__lowerCAmelCase       )
				A__     =  sum_aa(__lowerCAmelCase       ,	__lowerCAmelCase       )

		A__     =  reformat_hex(__lowerCAmelCase       ) + reformat_hex(__lowerCAmelCase       ) + reformat_hex(__lowerCAmelCase       ) + reformat_hex(__lowerCAmelCase       )
		return digest


if __name__ == "__main__":
					import doctest

					doctest.testmod()




"""simple docstring"""


from __future__ import annotations

from typing import Any






class   __UpperCAmelCase		:

				def __init__( self      ,					_lowerCamelCase      ,					_lowerCamelCase      ,					_lowerCamelCase = 0 ):
										lowerCamelCase__   , lowerCamelCase__   =row, column
										lowerCamelCase__   =[[default_value for c in range(_lowerCamelCase )] for r in range(_lowerCamelCase )]

				def __str__( self ):
										lowerCamelCase__   =F'''Matrix consist of {self.row} rows and {self.column} columns\n'''

										# Make string identifier
										lowerCamelCase__   =0
										for row_vector in self.array:
																for obj in row_vector:
																						lowerCamelCase__   =max(_lowerCamelCase      ,					len(str(_lowerCamelCase ) ) )
										lowerCamelCase__   =F'''%{max_element_length}s'''

										# Make string and return
										def single_line(_lowerCamelCase ) -> str:
																nonlocal string_format_identifier
																lowerCamelCase__   ="["
																line += ", ".join(string_format_identifier % (obj,) for obj in row_vector )
																line += "]"
																return line

										s += "\n".join(single_line(_lowerCamelCase ) for row_vector in self.array )
										return s

				def __repr__( self ):
										return str(self )

				def 						_a      ( self      ,					_lowerCamelCase ):
										if not (isinstance(_lowerCamelCase      ,					(list, tuple) ) and len(_lowerCamelCase ) == 2):
																return False
										elif not (0 <= loc[0] < self.row and 0 <= loc[1] < self.column):
																return False
										else:
																return True

				def __getitem__( self      ,					_lowerCamelCase ):
										assert self.validate_indicies(_lowerCamelCase )
										return self.array[loc[0]][loc[1]]

				def __setitem__( self      ,					_lowerCamelCase      ,					_lowerCamelCase ):
										assert self.validate_indicies(_lowerCamelCase )
										lowerCamelCase__   =value

				def __add__( self      ,					_lowerCamelCase ):
										assert isinstance(_lowerCamelCase      ,					_lowerCamelCase )
										assert self.row == another.row and self.column == another.column

										# Add
										lowerCamelCase__   =Matrix(self.row      ,					self.column )
										for r in range(self.row ):
																for c in range(self.column ):
																						lowerCamelCase__   =self[r, c] + another[r, c]
										return result

				def __neg__( self ):
										lowerCamelCase__   =Matrix(self.row      ,					self.column )
										for r in range(self.row ):
																for c in range(self.column ):
																						lowerCamelCase__   =-self[r, c]
										return result

				def __sub__( self      ,					_lowerCamelCase ):
										return self + (-another)

				def __mul__( self      ,					_lowerCamelCase ):

										if isinstance(_lowerCamelCase      ,					(int, float) ):  # Scalar multiplication
																lowerCamelCase__   =Matrix(self.row      ,					self.column )
																for r in range(self.row ):
																						for c in range(self.column ):
																												lowerCamelCase__   =self[r, c] * another
																return result
										elif isinstance(_lowerCamelCase      ,					_lowerCamelCase ):  # Matrix multiplication
																assert self.column == another.row
																lowerCamelCase__   =Matrix(self.row      ,					another.column )
																for r in range(self.row ):
																						for c in range(another.column ):
																												for i in range(self.column ):
																																		result[r, c] += self[r, i] * another[i, c]
																return result
										else:
																lowerCamelCase__   =F'''Unsupported type given for another ({type(_lowerCamelCase )})'''
																raise TypeError(_lowerCamelCase )

				def 						_a      ( self ):
										lowerCamelCase__   =Matrix(self.column      ,					self.row )
										for r in range(self.row ):
																for c in range(self.column ):
																						lowerCamelCase__   =self[r, c]
										return result






				def 						_a      ( self      ,					_lowerCamelCase      ,					_lowerCamelCase ):
										assert isinstance(_lowerCamelCase      ,					_lowerCamelCase ) and isinstance(_lowerCamelCase      ,					_lowerCamelCase )
										assert self.row == self.column == u.row == v.row  # u, v should be column vector
										assert u.column == v.column == 1  # u, v should be column vector

										# Calculate
										lowerCamelCase__   =v.transpose()
										lowerCamelCase__   =(v_t * self * u)[0, 0] + 1
										if numerator_factor == 0:
																return None  # It's not invertable
										return self - ((self * u) * (v_t * self) * (1.0 / numerator_factor))


# Testing
if __name__ == "__main__":





	def      lowerCamelCase_					(   )				->   None:




							'''simple docstring'''



							lowerCamelCase__   =Matrix(3  ,       3  ,       0							)
							for i in range(3							):
													lowerCamelCase__   =1
							print(F'''a^(-1) is {ainv}'''							)
							# u, v
							lowerCamelCase__   =Matrix(3  ,       1  ,       0							)
							lowerCamelCase__   , lowerCamelCase__   , lowerCamelCase__   =1, 2, -3
							lowerCamelCase__   =Matrix(3  ,       1  ,       0							)
							lowerCamelCase__   , lowerCamelCase__   , lowerCamelCase__   =4, -2, 5
							print(F'''u is {u}'''							)
							print(F'''v is {v}'''							)
							print(F'''uv^T is {u * v.transpose()}'''							)
							# Sherman Morrison
							print(F'''(a + uv^T)^(-1) is {ainv.sherman_morrison(__lowerCAmelCase  ,       __lowerCAmelCase							)}'''							)





	def      lowerCamelCase_					(   )				->   None:




							'''simple docstring'''



							import doctest

							doctest.testmod()





	testa()


