


'''simple docstring'''



from manim import *


class 						_snake_case   (       a__		):




					def 			snake_case__  ( self):
								UpperCAmelCase__					:   Optional[int]       				=       Rectangle(height=0.5							,							width=0.5)
								UpperCAmelCase__					:   Union[str, Any]       				=       Rectangle(height=0.46							,							width=0.46).set_stroke(width=0)

								UpperCAmelCase__					:   Union[str, Any]       				=       [mem.copy() for i in range(6)]
								UpperCAmelCase__					:   int       				=       [mem.copy() for i in range(6)]
								UpperCAmelCase__					:   Tuple       				=       VGroup(*_lowerCamelCase).arrange(_lowerCamelCase							,							buff=0)
								UpperCAmelCase__					:   str       				=       VGroup(*_lowerCamelCase).arrange(_lowerCamelCase							,							buff=0)
								UpperCAmelCase__					:   Union[str, Any]       				=       VGroup(_lowerCamelCase							,							_lowerCamelCase).arrange(_lowerCamelCase							,							buff=0)
								UpperCAmelCase__					:   List[Any]       				=       Text("""CPU"""							,							font_size=24)
								UpperCAmelCase__					:   Optional[int]       				=       Group(_lowerCamelCase							,							_lowerCamelCase).arrange(_lowerCamelCase							,							buff=0.5							,							aligned_edge=_lowerCamelCase)
								cpu.move_to([-2.5, -0.5, 0])
								self.add(_lowerCamelCase)

								UpperCAmelCase__					:   List[str]       				=       [mem.copy() for i in range(4)]
								UpperCAmelCase__					:   Tuple       				=       VGroup(*_lowerCamelCase).arrange(_lowerCamelCase							,							buff=0)
								UpperCAmelCase__					:   Dict       				=       Text("""GPU"""							,							font_size=24)
								UpperCAmelCase__					:   str       				=       Group(_lowerCamelCase							,							_lowerCamelCase).arrange(_lowerCamelCase							,							buff=0.5							,							aligned_edge=_lowerCamelCase)
								gpu.move_to([-1, -1, 0])
								self.add(_lowerCamelCase)

								UpperCAmelCase__					:   List[str]       				=       [mem.copy() for i in range(6)]
								UpperCAmelCase__					:   Optional[int]       				=       VGroup(*_lowerCamelCase).arrange(_lowerCamelCase							,							buff=0)

								UpperCAmelCase__					:   List[str]       				=       Text("""Model"""							,							font_size=24)
								UpperCAmelCase__					:   List[str]       				=       Group(_lowerCamelCase							,							_lowerCamelCase).arrange(_lowerCamelCase							,							buff=0.5							,							aligned_edge=_lowerCamelCase)
								model.move_to([3, -1.0, 0])
								self.add(_lowerCamelCase)

								UpperCAmelCase__					:   Tuple       				=       []
								for i, rect in enumerate(_lowerCamelCase):
											rect.set_stroke(_lowerCamelCase)
											# target = fill.copy().set_fill(YELLOW, opacity=0.7)
											# target.move_to(rect)
											# self.add(target)

											UpperCAmelCase__					:   Optional[Any]       				=       Rectangle(height=0.46 / 4							,							width=0.46 / 3).set_stroke(width=0.0).set_fill(_lowerCamelCase							,							opacity=0.7)

											if i == 0:
														cpu_target.next_to(cpu_left_col_base[0].get_corner(DOWN + LEFT)							,							buff=0.02							,							direction=_lowerCamelCase)
														cpu_target.set_x(cpu_target.get_x() + 0.1)
											elif i == 3:
														cpu_target.next_to(cpu_targs[0]							,							direction=_lowerCamelCase							,							buff=0.0)
											else:
														cpu_target.next_to(cpu_targs[i - 1]							,							direction=_lowerCamelCase							,							buff=0.0)
											self.add(_lowerCamelCase)
											cpu_targs.append(_lowerCamelCase)

								UpperCAmelCase__					:   List[str]       				=       [mem.copy() for i in range(6)]
								UpperCAmelCase__					:   Any       				=       VGroup(*_lowerCamelCase).arrange(_lowerCamelCase							,							buff=0)

								UpperCAmelCase__					:   Dict       				=       Text("""Loaded Checkpoint"""							,							font_size=24)
								UpperCAmelCase__					:   str       				=       Group(_lowerCamelCase							,							_lowerCamelCase).arrange(_lowerCamelCase							,							aligned_edge=_lowerCamelCase							,							buff=0.4)
								checkpoint.move_to([3, 0.5, 0])

								UpperCAmelCase__					:   Tuple       				=       Square(side_length=2.2)
								key.move_to([-5, 2, 0])

								UpperCAmelCase__					:   Dict       				=       MarkupText(
								    f'''<b>Key:</b>\n\n<span fgcolor=\'{YELLOW}\'>●</span> Empty Model'''							,							font_size=18							,							)

								key_text.move_to([-5, 2.4, 0])

								self.add(_lowerCamelCase							,							_lowerCamelCase)

								UpperCAmelCase__					:   List[str]       				=       MarkupText(
								    f'''<span fgcolor=\'{BLUE}\'>●</span> Checkpoint'''							,							font_size=18							,							)

								blue_text.next_to(_lowerCamelCase							,							DOWN * 2.4							,							aligned_edge=key_text.get_left())

								UpperCAmelCase__					:   List[Any]       				=       MarkupText(
								    f'''Next, a <i><span fgcolor="{BLUE}">second</span></i> model is loaded into memory,\nwith the weights of a <span fgcolor="{BLUE}">single shard</span>.'''							,							font_size=24							,							)
								step_a.move_to([2, 2, 0])
								self.play(Write(_lowerCamelCase)							,							Write(_lowerCamelCase))

								self.play(Write(_lowerCamelCase							,							run_time=1)							,							Create(_lowerCamelCase							,							run_time=1))

								UpperCAmelCase__					:   Optional[Any]       				=       []
								UpperCAmelCase__					:   Tuple       				=       []
								for i, rect in enumerate(_lowerCamelCase):
											UpperCAmelCase__					:   List[Any]       				=       fill.copy().set_fill(_lowerCamelCase							,							opacity=0.7)
											target.move_to(_lowerCamelCase)
											first_animations.append(GrowFromCenter(_lowerCamelCase							,							run_time=1))

											UpperCAmelCase__					:   Dict       				=       target.copy()
											cpu_target.generate_target()
											if i < 5:
														cpu_target.target.move_to(cpu_left_col_base[i + 1])
											else:
														cpu_target.target.move_to(cpu_right_col_base[i - 5])
											second_animations.append(MoveToTarget(_lowerCamelCase							,							run_time=1.5))

								self.play(*_lowerCamelCase)
								self.play(*_lowerCamelCase)
								self.wait()



'''simple docstring'''



import functools







def       _UpperCamelCase (						UpperCamelCase__	, UpperCamelCase__   ):

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

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

			if len(UpperCamelCase__   ) == 0:
						return 0

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

			if max(UpperCamelCase__   ) >= 3_6_6:
						raise ValueError("""All days elements should be less than 366"""   )

			UpperCAmelCase__					:   Union[str, Any]       				=       set(UpperCamelCase__   )

			@functools.cache
			def dynamic_programming(UpperCamelCase__   ) -> int:
						if index > 3_6_5:
									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 + 3_0   )	, )

			return dynamic_programming(1   )


if __name__ == "__main__":
		import doctest

		doctest.testmod()