






'''simple docstring'''
def 		__SCREAMING_SNAKE_CASE					(  _UpperCamelCase						,		_UpperCamelCase							):


   """simple docstring"""




   _enforce_args(_A						,		_A							)
   if n == 0:
      return 0
   lowercase_	:    Optional[Any]           =     float("-inf"							)
   for i in range(1						,		n + 1							):
      lowercase_	:    Optional[Any]           =     max(
          _A						,		prices[i - 1] + naive_cut_rod_recursive(n - i						,		_A							)							)

   return max_revue




def 		__SCREAMING_SNAKE_CASE					(  _UpperCamelCase						,		_UpperCamelCase							):


   """simple docstring"""




   _enforce_args(_A						,		_A							)
   lowercase_	:    List[Any]           =     [float("-inf"							) for _ in range(n + 1							)]
   return _top_down_cut_rod_recursive(_A						,		_A						,		_A							)




def 		__SCREAMING_SNAKE_CASE					(  _UpperCamelCase						,		_UpperCamelCase						,		_UpperCamelCase							):


   """simple docstring"""




   if max_rev[n] >= 0:
      return max_rev[n]
   elif n == 0:
      return 0
   else:
      lowercase_	:    List[Any]           =     float("-inf"							)
      for i in range(1						,		n + 1							):
         lowercase_	:    Tuple           =     max(
             _A						,		prices[i - 1] + _top_down_cut_rod_recursive(n - i						,		_A						,		_A							)						,		)

      lowercase_	:    int           =     max_revenue

   return max_rev[n]




def 		__SCREAMING_SNAKE_CASE					(  _UpperCamelCase						,		_UpperCamelCase							):


   """simple docstring"""




   _enforce_args(_A						,		_A							)

   # length(max_rev) = n + 1, to accommodate for the revenue obtainable from a rod of
   # length 0.
   lowercase_	:    Optional[int]           =     [float("-inf"							) for _ in range(n + 1							)]
   lowercase_	:    Tuple           =     0

   for i in range(1						,		n + 1							):
      lowercase_	:    Union[str, Any]           =     max_rev[i]
      for j in range(1						,		i + 1							):
         lowercase_	:    Optional[int]           =     max(_A						,		prices[j - 1] + max_rev[i - j]							)

      lowercase_	:    int           =     max_revenue_i

   return max_rev[n]




def 		__SCREAMING_SNAKE_CASE					(  _UpperCamelCase						,		_UpperCamelCase							):


   """simple docstring"""




   if n < 0:
      lowercase_	:    Dict           =     F"""n must be greater than or equal to 0. Got n = {n}"""
      raise ValueError(_A							)

   if n > len(_A							):
      lowercase_	:    Union[str, Any]           =     (
          "Each integral piece of rod must have a corresponding price. "
          F"""Got n = {n} but length of prices = {len(_A							)}"""
      )
      raise ValueError(_A							)




def 		__SCREAMING_SNAKE_CASE					(  ):


   """simple docstring"""




   lowercase_	:    Optional[int]           =     [6, 10, 12, 15, 20, 23]
   lowercase_	:    Optional[int]           =     len(_A							)

   # the best revenue comes from cutting the rod into 6 pieces, each
   # of length 1 resulting in a revenue of 6 * 6 = 36.
   lowercase_	:    Dict           =     36

   lowercase_	:    Optional[int]           =     top_down_cut_rod(_A						,		_A							)
   lowercase_	:    int           =     bottom_up_cut_rod(_A						,		_A							)
   lowercase_	:    str           =     naive_cut_rod_recursive(_A						,		_A							)

   assert expected_max_revenue == max_rev_top_down
   assert max_rev_top_down == max_rev_bottom_up
   assert max_rev_bottom_up == max_rev_naive


if __name__ == "__main__":
      main()












'''simple docstring'''
def 		__SCREAMING_SNAKE_CASE					(  _UpperCamelCase							):


   """simple docstring"""




   if number < 0:
      raise ValueError("number must not be negative"							)
   return number & (number - 1) == 0


if __name__ == "__main__":
 import doctest

 doctest.testmod()




