"""simple docstring"""







from collections.abc import Iterable
from typing import Generic, TypeVar

SCREAMING_SNAKE_CASE									=						TypeVar('_T')



class  _lowerCamelCase			(Generic[_T]     ):







	def __init__( self    :       Tuple			,					lowerCamelCase_    :       List[str] = None						):

		"""simple docstring"""






		_lowercase :    List[str]							=							list(iterable or []						)
		_lowercase :    Optional[Any]							=							[]







	def __len__( self    :       Tuple						):

		"""simple docstring"""






		return len(self._stacka						) + len(self._stacka						)







	def __repr__( self    :       Any						):

		"""simple docstring"""






		return F'''Queue({tuple(self._stacka[::-1] + self._stacka						)})'''







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

		"""simple docstring"""






		self._stacka.append(__lowerCAmelCase						)







	def 							__UpperCAmelCase					( self    :       List[str]						):

		"""simple docstring"""






		_lowercase :    Tuple							=							self._stacka.pop
		_lowercase :    Optional[Any]							=							self._stacka.append

		if not self._stacka:
			while self._stacka:
				stacka_append(stacka_pop()						)

		if not self._stacka:
			raise IndexError('Queue is empty'						)
		return self._stacka.pop()


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

						testmod()




"""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()



