

from collections.abc import Generator
from math import sin





def a(lowercase__						):





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

	snake_case_   		=			B''
	for i in [3, 2, 1, 0]:
		little_endian += string_aa[8 * i : 8 * i + 8]
	return little_endian





def a(lowercase__						):





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

	snake_case_   		=			format(lowercase__      ,			'08x'						)[-8:]
	snake_case_   		=			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 a(lowercase__						):





	'''simple docstring'''
	snake_case_   		=			B''
	for char in message:
		bit_string += format(lowercase__      ,			'08b'						).encode('utf-8'						)
	snake_case_   		=			format(len(lowercase__						)      ,			'064b'						).encode('utf-8'						)

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

	return bit_string





def a(lowercase__						):





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

	for pos in range(0      ,			len(lowercase__						)      ,			512						):
		snake_case_   		=			bit_string[pos : pos + 512]
		snake_case_   		=			[]
		for i in range(0      ,			512      ,			32						):
			block_words.append(int(to_little_endian(block[i : i + 32]						)      ,			2						)						)
		yield block_words





def a(lowercase__						):





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

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





def a(lowercase__      ,			lowercase__						):





	'''simple docstring'''
	return (a + b) % 2**32





def a(lowercase__      ,			lowercase__						):





	'''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 a(lowercase__						):





	'''simple docstring'''
	snake_case_   		=			preprocess(lowercase__						)

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

	# Starting states
	snake_case_   		=			0X67452301
	snake_case_   		=			0Xefcdab89
	snake_case_   		=			0X98badcfe
	snake_case_   		=			0X10325476

	snake_case_   		=			[
	    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(lowercase__						):
		snake_case_   		=			aa
		snake_case_   		=			ba
		snake_case_   		=			ca
		snake_case_   		=			da

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

		# Add hashed chunk to running total
		snake_case_   		=			sum_aa(lowercase__      ,			lowercase__						)
		snake_case_   		=			sum_aa(lowercase__      ,			lowercase__						)
		snake_case_   		=			sum_aa(lowercase__      ,			lowercase__						)
		snake_case_   		=			sum_aa(lowercase__      ,			lowercase__						)

	snake_case_   		=			reformat_hex(lowercase__						) + reformat_hex(lowercase__						) + reformat_hex(lowercase__						) + reformat_hex(lowercase__						)
	return digest


if __name__ == "__main__":
		import doctest

		doctest.testmod()



import functools





def a(lowercase__      ,			lowercase__						):





	'''simple docstring'''

	# Validation
	if not isinstance(lowercase__      ,			lowercase__						) or not all(isinstance(lowercase__      ,			lowercase__						) for day in days						):
		raise ValueError('The parameter days should be a list of integers'						)

	if len(lowercase__						) != 3 or not all(isinstance(lowercase__      ,			lowercase__						) for cost in costs						):
		raise ValueError('The parameter costs should be a list of three integers'						)

	if len(lowercase__						) == 0:
		return 0

	if min(lowercase__						) <= 0:
		raise ValueError('All days elements should be greater than 0'						)

	if max(lowercase__						) >= 366:
		raise ValueError('All days elements should be less than 366'						)

	snake_case_   		=			set(lowercase__						)

	@functools.cache
	def dynamic_programming(lowercase__						) -> int:
		if index > 365:
			return 0

		if index not in days_set:
			return dynamic_programming(index + 1						)

		return min(
		    costs[0] + dynamic_programming(index + 1						)      ,			costs[1] + dynamic_programming(index + 7						)      ,			costs[2] + dynamic_programming(index + 30						)      ,			)

	return dynamic_programming(1						)


if __name__ == "__main__":
		import doctest

		doctest.testmod()
