

from collections.abc import Sequence






def        snake_case__		(    lowerCamelCase_     ,				lowerCamelCase_ = False		):
							if not arr:
														return 0

							A      :					Optional[Any]      		=					0 if allow_empty_subarrays else float('''-inf'''		)
							A      :					Tuple      		=					0.0
							for num in arr:
														A      :					int      		=					max(0 if allow_empty_subarrays else num     ,				curr_sum + num		)
														A      :					Tuple      		=					max(__UpperCamelCase     ,				__UpperCamelCase		)

							return max_sum


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

		testmod()

		lowercase			:				str   =     [-2, 1, -3, 4, -1, 2, 1, -5, 4]
		print(F"{max_subarray_sum(nums) = }")











import unittest

from knapsack import knapsack as k


class 				_a						(       unittest.TestCase			):





							'''simple docstring'''

							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							List[str]      						= 0
											a__	:							Union[str, Any]      						= [0]
											a__	:							Optional[Any]      						= [0]
											a__	:							Tuple      						= len(__UpperCAmelCase				)
											self.assertEqual(k.knapsack(__UpperCAmelCase ,					__UpperCAmelCase ,					__UpperCAmelCase ,					__UpperCAmelCase				) ,					0				)

											a__	:							Optional[Any]      						= [60]
											a__	:							Tuple      						= [10]
											a__	:							Optional[Any]      						= len(__UpperCAmelCase				)
											self.assertEqual(k.knapsack(__UpperCAmelCase ,					__UpperCAmelCase ,					__UpperCAmelCase ,					__UpperCAmelCase				) ,					0				)



							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							Dict      						= 3
											a__	:							Optional[int]      						= [1, 2, 3]
											a__	:							List[Any]      						= [3, 2, 1]
											a__	:							List[Any]      						= len(__UpperCAmelCase				)
											self.assertEqual(k.knapsack(__UpperCAmelCase ,					__UpperCAmelCase ,					__UpperCAmelCase ,					__UpperCAmelCase				) ,					5				)




							def 		_A	(							self				):







											"""simple docstring"""



											a__	:							List[Any]      						= 50
											a__	:							Union[str, Any]      						= [60, 100, 120]
											a__	:							str      						= [10, 20, 30]
											a__	:							Union[str, Any]      						= len(__UpperCAmelCase				)
											self.assertEqual(k.knapsack(__UpperCAmelCase ,					__UpperCAmelCase ,					__UpperCAmelCase ,					__UpperCAmelCase				) ,					220				)


if __name__ == "__main__":
						unittest.main()


