"""simple docstring"""







from collections import deque

from .hash_table import HashTable



class  _lowerCamelCase			(__lowerCamelCase     ):







				def __init__( self    :       List[Any]			,					*lowerCamelCase_    :       List[Any]			,					**lowerCamelCase_    :       Union[str, Any]						):

					"""simple docstring"""






					super().__init__(*lowerCamelCase_			,					**lowerCamelCase_						)







				def 							__UpperCAmelCase					( self    :       Union[str, Any]			,					lowerCamelCase_    :       int			,					lowerCamelCase_    :       Optional[int]						):

					"""simple docstring"""






					_lowercase :    Dict							=							deque([]						) if self.values[key] is None else self.values[key]
					self.values[key].appendleft(lowerCamelCase_						)
					_lowercase :    str							=							self.values[key]







				def 							__UpperCAmelCase					( self    :       int						):

					"""simple docstring"""






					return (
					    sum(self.charge_factor - len(lowerCamelCase_						) for slot in self.values						)
					    / self.size_table
					    * self.charge_factor
					)







				def 							__UpperCAmelCase					( self    :       Optional[Any]			,					lowerCamelCase_    :       Any			,					lowerCamelCase_    :       Optional[Any]=None						):

					"""simple docstring"""






					if not (
					    len(self.values[key]						) == self.charge_factor and self.values.count(lowerCamelCase_						) == 0
					):
						return key
					return super()._collision_resolution(lowerCamelCase_			,					lowerCamelCase_						)




"""simple docstring"""







def      __lowerCAmelCase(		__UpperCAmelCase			):






	"""simple docstring"""





	_lowercase :    str							=							[0 for i in range(len(__UpperCAmelCase			)			)]

	# initialize interval's left pointer and right pointer
	_lowercase				,      _lowercase :    str							=							0, 0

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

		while go_next(__UpperCAmelCase     ,__UpperCAmelCase     ,__UpperCAmelCase			):
			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:
			_lowercase				,      _lowercase :    Optional[int]							=							i, i + z_result[i] - 1

	return z_result


def      __lowerCAmelCase(		__UpperCAmelCase     ,__UpperCAmelCase     ,__UpperCAmelCase			):






	"""simple docstring"""





	return i + z_result[i] < len(__UpperCAmelCase			) and s[z_result[i]] == s[i + z_result[i]]


def      __lowerCAmelCase(		__UpperCAmelCase     ,__UpperCAmelCase			):






	"""simple docstring"""





	_lowercase :    Union[str, Any]							=							0
	# concatenate 'pattern' and 'input_str' and call z_function
	# with concatenated string
	_lowercase :    List[str]							=							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(__UpperCAmelCase			):
			answer += 1

	return answer


if __name__ == "__main__":
						import doctest

						doctest.testmod()



