


from collections.abc import Generator
from math import sin
def 				UpperCAmelCase_					(							__snake_case						)     ->			bytes:







 """simple docstring"""


 if len(__snake_case						) != 32:
  raise ValueError('''Input must be of length 32'''						)

 _lowercase							      =b''''''
 for i in [3, 2, 1, 0]:
  little_endian += string_aa[8 * i : 8 * i + 8]
 return little_endian
def 				UpperCAmelCase_					(							__snake_case						)     ->			bytes:







 """simple docstring"""


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

 _lowercase							      =format(__snake_case     ,						'''08x'''						)[-8:]
 _lowercase							      =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 				UpperCAmelCase_					(							__snake_case						)     ->			bytes:







 """simple docstring"""


 _lowercase							      =b''''''
 for char in message:
  bit_string += format(__snake_case     ,						'''08b'''						).encode('''utf-8'''						)
 _lowercase							      =format(len(__snake_case						)     ,						'''064b'''						).encode('''utf-8'''						)

 # Pad bit_string to a multiple of 512 chars
 bit_string += b"1"
 while len(__snake_case						) % 512 != 448:
  bit_string += b"0"
 bit_string += to_little_endian(start_len[32:]						) + to_little_endian(start_len[:32]						)

 return bit_string
def 				UpperCAmelCase_					(							__snake_case						)     ->			Generator[list[int], None, None]:







 """simple docstring"""


 if len(__snake_case						) % 512 != 0:
  raise ValueError('''Input must have length that\'s a multiple of 512'''						)

 for pos in range(0     ,						len(__snake_case						)     ,						512						):
  _lowercase							      =bit_string[pos : pos + 512]
  _lowercase							      =[]
  for i in range(0     ,						512     ,						32						):
   block_words.append(int(to_little_endian(block[i : i + 32]						)     ,						2						)						)
  yield block_words
def 				UpperCAmelCase_					(							__snake_case						)     ->			int:







 """simple docstring"""


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

 _lowercase							      =format(__snake_case     ,						'''032b'''						)
 _lowercase							      =''''''
 for c in i_str:
  new_str += "1" if c == "0" else "0"
 return int(__snake_case     ,						2						)
def 				UpperCAmelCase_					(							__snake_case     ,						__snake_case						)     ->			int:







 """simple docstring"""


 return (a + b) % 2**32
def 				UpperCAmelCase_					(							__snake_case     ,						__snake_case						)     ->			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 >> (32 - shift))) % 2**32
def 				UpperCAmelCase_					(							__snake_case						)     ->			bytes:







 """simple docstring"""


 _lowercase							      =preprocess(__snake_case						)

 _lowercase							      =[int(2**32 * abs(sin(i + 1						)						)						) for i in range(64						)]

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

 _lowercase							      =[
     7,
     12,
     17,
     22,
     7,
     12,
     17,
     22,
     7,
     12,
     17,
     22,
     7,
     12,
     17,
     22,
     5,
     9,
     14,
     20,
     5,
     9,
     14,
     20,
     5,
     9,
     14,
     20,
     5,
     9,
     14,
     20,
     4,
     11,
     16,
     23,
     4,
     11,
     16,
     23,
     4,
     11,
     16,
     23,
     4,
     11,
     16,
     23,
     6,
     10,
     15,
     21,
     6,
     10,
     15,
     21,
     6,
     10,
     15,
     21,
     6,
     10,
     15,
     21,
 ]

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

  # Hash current chunk
  for i in range(64						):
   if i <= 15:
    # f = (b & c) | (not_32(b) & d)     # Alternate definition for f
    _lowercase							      =d ^ (b & (c ^ d))
    _lowercase							      =i
   elif i <= 31:
    # f = (d & b) | (not_32(d) & c)     # Alternate definition for f
    _lowercase							      =c ^ (d & (b ^ c))
    _lowercase							      =(5 * i + 1) % 16
   elif i <= 47:
    _lowercase							      =b ^ c ^ d
    _lowercase							      =(3 * i + 5) % 16
   else:
    _lowercase							      =c ^ (b | not_aa(__snake_case						))
    _lowercase							      =(7 * i) % 16
   _lowercase							      =(f + a + added_consts[i] + block_words[g]) % 2**32
   _lowercase							      =d
   _lowercase							      =c
   _lowercase							      =b
   _lowercase							      =sum_aa(__snake_case     ,						left_rotate_aa(__snake_case     ,						shift_amounts[i]						)						)

  # Add hashed chunk to running total
  _lowercase							      =sum_aa(__snake_case     ,						__snake_case						)
  _lowercase							      =sum_aa(__snake_case     ,						__snake_case						)
  _lowercase							      =sum_aa(__snake_case     ,						__snake_case						)
  _lowercase							      =sum_aa(__snake_case     ,						__snake_case						)

 _lowercase							      =reformat_hex(__snake_case						) + reformat_hex(__snake_case						) + reformat_hex(__snake_case						) + reformat_hex(__snake_case						)
 return digest


if __name__ == "__main__":
  import doctest

  doctest.testmod()




from collections.abc import Callable

class 				UpperCAmelCase_		:
							"""simple docstring"""







							def __init__(			self       ,							_a = None       )    ->    None:
												# Stores actual heap items.
												_a	:    list         =		[]
												# Stores indexes of each item for supporting updates and deletion.
												_a	:    dict         =		{}
												# Stores current size of heap.
												_a	:    Tuple         =		0
												# Stores function used to evaluate the score of an item on which basis ordering
												# will be done.
												_a	:    Dict         =		key or (lambda _a       : x)


							def 				__lowercase				(			self       ,							_a       )    ->    int | None:
												return int((i - 1) / 2       ) if i > 0 else None


							def 				__lowercase				(			self       ,							_a       )    ->    int | None:
												_a	:    Optional[int]         =		int(2 * i + 1       )
												return left if 0 < left < self.size else None


							def 				__lowercase				(			self       ,							_a       )    ->    int | None:
												_a	:    int         =		int(2 * i + 2       )
												return right if 0 < right < self.size else None


							def 				__lowercase				(			self       ,							_a       ,							_a       )    ->    None:
												_a      ,					_a	:    Union[str, Any]         =		(
												    self.pos_map[self.arr[j][0]],
												    self.pos_map[self.arr[i][0]],
												)
												# Then swap the items in the list.
												_a      ,					_a	:    List[Any]         =		self.arr[j], self.arr[i]


							def 				__lowercase				(			self       ,							_a       ,							_a       )    ->    bool:
												return self.arr[i][1] < self.arr[j][1]


							def 				__lowercase				(			self       ,							_a       )    ->    int:
												_a	:    Dict         =		self._left(_a       )
												_a	:    str         =		self._right(_a       )
												_a	:    str         =		i

												if left is not None and not self._cmp(_a       ,							_a       ):
																	_a	:    Optional[Any]         =		left
												if right is not None and not self._cmp(_a       ,							_a       ):
																	_a	:    Any         =		right

												return valid_parent


							def 				__lowercase				(			self       ,							_a       )    ->    None:
												_a	:    List[str]         =		self._parent(_a       )
												while parent is not None and not self._cmp(_a       ,							_a       ):
																	self._swap(_a       ,							_a       )
																	_a      ,					_a	:    Any         =		parent, self._parent(_a       )


							def 				__lowercase				(			self       ,							_a       )    ->    None:
												_a	:    List[Any]         =		self._get_valid_parent(_a       )
												while valid_parent != index:
																	self._swap(_a       ,							_a       )
																	_a      ,					_a	:    int         =		valid_parent, self._get_valid_parent(_a       )


							def 				__lowercase				(			self       ,							_a       ,							_a       )    ->    None:
												if item not in self.pos_map:
																	return
												_a	:    str         =		self.pos_map[item]
												_a	:    List[Any]         =		[item, self.key(_a       )]
												# Make sure heap is right in both up and down direction.
												# Ideally only one of them will make any change.
												self._heapify_up(_a       )
												self._heapify_down(_a       )


							def 				__lowercase				(			self       ,							_a       )    ->    None:
												if item not in self.pos_map:
																	return
												_a	:    Tuple         =		self.pos_map[item]
												del self.pos_map[item]
												_a	:    Tuple         =		self.arr[self.size - 1]
												_a	:    str         =		index
												self.size -= 1
												# Make sure heap is right in both up and down direction. Ideally only one
												# of them will make any change- so no performance loss in calling both.
												if self.size > index:
																	self._heapify_up(_a       )
																	self._heapify_down(_a       )


							def 				__lowercase				(			self       ,							_a       ,							_a       )    ->    None:
												_a	:    Union[str, Any]         =		len(self.arr       )
												if arr_len == self.size:
																	self.arr.append([item, self.key(_a       )]       )
												else:
																	_a	:    Optional[int]         =		[item, self.key(_a       )]
												_a	:    Tuple         =		self.size
												self.size += 1
												self._heapify_up(self.size - 1       )


							def 				__lowercase				(			self       )    ->    tuple | None:
												return self.arr[0] if self.size else None




							def 				__lowercase				(			self       )    ->    tuple | None:
												_a	:    Tuple         =		self.get_top()
												if top_item_tuple:
																	self.delete_item(top_item_tuple[0]       )
												return top_item_tuple



def    __UpperCAmelCase (	)			->     None:

					"""simple docstring"""



if __name__ == "__main__":
			import doctest

			doctest.testmod()



