from decimal import Decimal, getcontext
from math import ceil, factorial





def 	__lowerCamelCase							(UpperCAmelCase__     :							int  ):

					if not isinstance(UpperCAmelCase__      , UpperCAmelCase__  ):
										raise TypeError("Undefined for non-integers"  )
					elif precision < 1:
										raise ValueError("Undefined for non-natural numbers"  )

					SCREAMING_SNAKE_CASE    			=       precision
					SCREAMING_SNAKE_CASE    			=       ceil(precision / 1_4  )
					SCREAMING_SNAKE_CASE    			=       4_2_6_8_8_0 * Decimal(1_0_0_0_5  ).sqrt()
					SCREAMING_SNAKE_CASE    			=       1
					SCREAMING_SNAKE_CASE    			=       1_3_5_9_1_4_0_9
					SCREAMING_SNAKE_CASE    			=       Decimal(UpperCAmelCase__  )
					for k in range(1      , UpperCAmelCase__  ):
										SCREAMING_SNAKE_CASE    			=       factorial(6 * k  ) // (factorial(3 * k  ) * factorial(UpperCAmelCase__  ) ** 3)
										linear_term += 5_4_5_1_4_0_1_3_4
										exponential_term *= -2_6_2_5_3_7_4_1_2_6_4_0_7_6_8_0_0_0
										partial_sum += Decimal(multinomial_term * linear_term  ) / exponential_term
					return str(constant_term / partial_sum  )[:-1]


if __name__ == "__main__":
			_lowerCamelCase					:   List[str]							=		50
			print(f"""The first {n} digits of pi is: {pi(n)}""")





import functools





def 	__lowerCamelCase							(UpperCAmelCase__     :							list[int]      , UpperCAmelCase__     :							list[int]  ):

					# 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"  )

					SCREAMING_SNAKE_CASE    			=       set(UpperCAmelCase__  )

					@functools.cache
					def dynamic_programming(UpperCAmelCase__     :							int  ) -> 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()




