






"""simple docstring"""
def 							snake_case (  A__		):
			UpperCAmelCase_	:					str     	=   len(A__		)
			UpperCAmelCase_	:					Dict     	=   sum(A__		)

			UpperCAmelCase_	:					Any     	=   [[False for x in range(s + 1		)] for y in range(n + 1		)]

			for i in range(1      ,n + 1		):
						UpperCAmelCase_	:					List[Any]     	=   True

			for i in range(1      ,s + 1		):
						UpperCAmelCase_	:					Optional[Any]     	=   False

			for i in range(1      ,n + 1		):
						for j in range(1      ,s + 1		):
									UpperCAmelCase_	:					Optional[int]     	=   dp[i][j - 1]

									if arr[i - 1] <= j:
												UpperCAmelCase_	:					Optional[Any]     	=   dp[i][j] or dp[i - 1][j - arr[i - 1]]

			for j in range(int(s / 2		)      ,-1      ,-1		):
						if dp[n][j] is True:
									UpperCAmelCase_	:					List[str]     	=   s - 2 * j
									break

			return diff











"""simple docstring"""
def 							snake_case (  A__		):
			UpperCAmelCase_	:					int     	=   [0 for i in range(len(A__		)		)]

			# initialize interval's left pointer and right pointer
			UpperCAmelCase_	,      UpperCAmelCase_	:					Optional[int]     	=   0, 0

			for i in range(1      ,len(A__		)		):
						# case when current index is inside the interval
						if i <= right_pointer:
									UpperCAmelCase_	:					Any     	=   min(right_pointer - i + 1      ,z_result[i - left_pointer]		)
									UpperCAmelCase_	:					Union[str, Any]     	=   min_edge

						while go_next(A__      ,A__      ,A__		):
									z_result[i] += 1

						# if new index's result gives us more right interval,
						# we've to update left_pointer and right_pointer
						if i + z_result[i] - 1 > right_pointer:
									UpperCAmelCase_	,      UpperCAmelCase_	:					Union[str, Any]     	=   i, i + z_result[i] - 1

			return z_result

def 							snake_case (  A__      ,A__      ,A__		):
			return i + z_result[i] < len(A__		) and s[z_result[i]] == s[i + z_result[i]]

def 							snake_case (  A__      ,A__		):
			UpperCAmelCase_	:					Optional[int]     	=   0
			# concatenate 'pattern' and 'input_str' and call z_function
			# with concatenated string
			UpperCAmelCase_	:					Tuple     	=   z_function(pattern + input_str		)

			for val in z_result:
						# if value is greater then length of the pattern string
						# that means this index is starting position of substring
						# which is equal to pattern string
						if val >= len(A__		):
									answer += 1

			return answer


if __name__ == "__main__":
			import doctest

			doctest.testmod()



