






'''simple docstring'''







__lowerCAmelCase									=   {}





def 		_UpperCAmelCase (				__A				: int    ,		__A				: int    ,		__A				: int   ):

				# if we are absent twice, or late 3 consecutive days,
				# no further prize strings are possible
				if late == 3 or absent == 2:
								return 0

				# if we have no days left, and have not failed any other rules,
				# we have a prize string
				if days == 0:
								return 1

				# No easy solution, so now we need to do the recursive calculation

				# First, check if the combination is already in the cache, and
				# if yes, return the stored value from there since we already
				# know the number of possible prize strings from this point on
				a_		:	int									=   (days, absent, late)
				if key in cache:
								return cache[key]

				# now we calculate the three possible ways that can unfold from
				# this point on, depending on our attendance today

				# 1) if we are late (but not absent), the "absent" counter stays as
				# it is, but the "late" counter increases by one
				a_		:	Optional[int]									=   _calculate(days - 1    ,		__A    ,		late + 1   )

				# 2) if we are absent, the "absent" counter increases by 1, and the
				# "late" counter resets to 0
				a_		:	Optional[int]									=   _calculate(days - 1    ,		absent + 1    ,		0   )

				# 3) if we are on time, this resets the "late" counter and keeps the
				# absent counter
				a_		:	Dict									=   _calculate(days - 1    ,		__A    ,		0   )

				a_		:	Optional[int]									=   state_late + state_absent + state_ontime

				a_		:	Tuple									=   prizestrings
				return prizestrings





def 		_UpperCAmelCase (				__A				: int = 30   ):
				return _calculate(__A    ,		absent=0    ,		late=0   )


if __name__ == "__main__":
		print(solution())












'''simple docstring'''







import functools





def 		_UpperCAmelCase (				__A				: list[int]    ,		__A				: list[int]   ):

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

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

				if len(__A   ) == 0:
								return 0

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

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

				a_		:	List[Any]									=   set(__A   )

				@functools.cache
				def dynamic_programming(__A				: int   ) -> int:
								if index > 3_65:
												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()




