"""simple docstring"""






def SCREAMING_SNAKE_CASE__			(   __UpperCAmelCase       ,    __UpperCAmelCase       ,    __UpperCAmelCase       ,    __UpperCAmelCase       ,    __UpperCAmelCase )  ->  int:
   if index == number_of_items:
      return 0
   lowercase__:   Any					=      0
   lowercase__:   List[Any]					=      0
   lowercase__:   Any					=      knapsack(__UpperCAmelCase       ,    __UpperCAmelCase       ,    __UpperCAmelCase       ,    __UpperCAmelCase       ,    index + 1 )
   if weights[index] <= max_weight:
      lowercase__:   str					=      values[index] + knapsack(
          __UpperCAmelCase       ,    __UpperCAmelCase       ,    __UpperCAmelCase       ,    max_weight - weights[index]       ,    index + 1 )
   return max(__UpperCAmelCase       ,    __UpperCAmelCase )


if __name__ == "__main__":
       import doctest

       doctest.testmod()

"""simple docstring"""






from collections.abc import Sequence



def SCREAMING_SNAKE_CASE__			(   __UpperCAmelCase       ,    __UpperCAmelCase = False )  ->  float:
   if not arr:
      return 0

   lowercase__:   Any					=      0 if allow_empty_subarrays else float('''-inf''' )
   lowercase__:   Union[str, Any]					=      0.0
   for num in arr:
      lowercase__:   List[str]					=      max(0 if allow_empty_subarrays else num       ,    curr_sum + num )
      lowercase__:   int					=      max(__UpperCAmelCase       ,    __UpperCAmelCase )

   return max_sum


if __name__ == "__main__":
       from doctest import testmod

       testmod()

       __A			   = [-2, 1, -3, 4, -1, 2, 1, -5, 4]
       print(f'''{max_subarray_sum(nums) = }''')
