





from collections.abc import Generator
from math import sin





def 					lowerCAmelCase_			(	__a		)					->		bytes:







  """simple docstring"""





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

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





def 					lowerCAmelCase_			(	__a		)					->		bytes:







  """simple docstring"""





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

  lowerCamelCase__:				List[Any]        =format(__a     ,   "08x"		)[-8:]
  lowerCamelCase__:				Optional[int]        =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		)					->		bytes:







  """simple docstring"""





  lowerCamelCase__:				Any        =b""
  for char in message:
    bit_string += format(__a     ,   "08b"		).encode("utf-8"		)
  lowerCamelCase__:				Union[str, Any]        =format(len(__a		)     ,   "064b"		).encode("utf-8"		)

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

  return bit_string





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







  """simple docstring"""





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

  for pos in range(0     ,   len(__a		)     ,   512		):
    lowerCamelCase__:				Optional[Any]        =bit_string[pos : pos + 512]
    lowerCamelCase__:				List[Any]        =[]
    for i in range(0     ,   512     ,   32		):
      block_words.append(int(to_little_endian(block[i : i + 32]		)     ,   2		)		)
    yield block_words





def 					lowerCAmelCase_			(	__a		)					->		int:







  """simple docstring"""





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

  lowerCamelCase__:				str        =format(__a     ,   "032b"		)
  lowerCamelCase__:				Tuple        =""
  for c in i_str:
    new_str += "1" if c == "0" else "0"
  return int(__a     ,   2		)





def 					lowerCAmelCase_			(	__a     ,   __a		)					->		int:







  """simple docstring"""





  return (a + b) % 2**32





def 					lowerCAmelCase_			(	__a     ,   __a		)					->		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 					lowerCAmelCase_			(	__a		)					->		bytes:







  """simple docstring"""





  lowerCamelCase__:				str        =preprocess(__a		)

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

  # Starting states
  lowerCamelCase__:				Any        =0X6_7_4_5_2_3_0_1
  lowerCamelCase__:				Tuple        =0XE_F_C_D_A_B_8_9
  lowerCamelCase__:				Optional[Any]        =0X9_8_B_A_D_C_F_E
  lowerCamelCase__:				int        =0X1_0_3_2_5_4_7_6

  lowerCamelCase__:				List[Any]        =[
      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(__a		):
    lowerCamelCase__:				str        =aa
    lowerCamelCase__:				str        =ba
    lowerCamelCase__:				List[str]        =ca
    lowerCamelCase__:				List[str]        =da

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

    # Add hashed chunk to running total
    lowerCamelCase__:				List[Any]        =sum_aa(__a     ,   __a		)
    lowerCamelCase__:				Optional[Any]        =sum_aa(__a     ,   __a		)
    lowerCamelCase__:				str        =sum_aa(__a     ,   __a		)
    lowerCamelCase__:				List[str]        =sum_aa(__a     ,   __a		)

  lowerCamelCase__:				Dict        =reformat_hex(__a		) + reformat_hex(__a		) + reformat_hex(__a		) + reformat_hex(__a		)
  return digest


if __name__ == "__main__":
   import doctest

   doctest.testmod()








from math import pow





def 					lowerCAmelCase_			(	__a     ,   __a     ,   __a     ,   __a     ,   __a     ,   )					->		tuple[int, int]:







  """simple docstring"""





  if current_sum == needed_sum:
    # If the sum of the powers is equal to needed_sum, then we have a solution.
    solutions_count += 1
    return current_sum, solutions_count

  lowerCamelCase__:				Optional[Any]        =int(pow(__a     ,   __a		)		)
  if current_sum + i_to_n <= needed_sum:
    # If the sum of the powers is less than needed_sum, then continue adding powers.
    current_sum += i_to_n
    lowerCamelCase__  , lowerCamelCase__:				int        =backtrack(
        __a     ,   __a     ,   current_number + 1     ,   __a     ,   __a		)
    current_sum -= i_to_n
  if i_to_n < needed_sum:
    # If the power of i is less than needed_sum, then try with the next power.
    lowerCamelCase__  , lowerCamelCase__:				Dict        =backtrack(
        __a     ,   __a     ,   current_number + 1     ,   __a     ,   __a		)
  return current_sum, solutions_count





def 					lowerCAmelCase_			(	__a     ,   __a		)					->		int:







  """simple docstring"""





  if not (1 <= needed_sum <= 1000 and 2 <= power <= 10):
    raise ValueError(
        "Invalid input\n"
        "needed_sum must be between 1 and 1000, power between 2 and 10."		)

  return backtrack(__a     ,   __a     ,   1     ,   0     ,   0		)[1]  # Return the solutions_count


if __name__ == "__main__":
     import doctest

     doctest.testmod()

