


'''simple docstring'''



from __future__ import annotations

from collections import deque





class    UpperCAmelCase_  :





    """simple docstring"""






    def __init__(							self			,     SCREAMING_SNAKE_CASE_	)				->     Tuple:
         __lowerCamelCase   :	list[dict]								=		[]
         self.adlist.append(
             {'value': '', 'next_states': [], 'fail_state': 0, 'output': []}	)

         for keyword in keywords:
              self.add_keyword(SCREAMING_SNAKE_CASE_	)
         self.set_fail_transitions()







    def       lowercase_				(							self			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)				->     int | None:
         for state in self.adlist[current_state]["next_states"]:
              if char == self.adlist[state]["value"]:
                   return state
         return None







    def       lowercase_				(							self			,     SCREAMING_SNAKE_CASE_	)				->     None:
         __lowerCamelCase   :	Dict								=		0
         for character in keyword:
              __lowerCamelCase   :	List[Any]								=		self.find_next_state(SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)
              if next_state is None:
                   self.adlist.append(
                       {
                           'value': character,
                           'next_states': [],
                           'fail_state': 0,
                           'output': [],
                       }	)
                   self.adlist[current_state]["next_states"].append(len(self.adlist	) - 1	)
                   __lowerCamelCase   :	Optional[int]								=		len(self.adlist	) - 1
              else:
                   __lowerCamelCase   :	Union[str, Any]								=		next_state
         self.adlist[current_state]["output"].append(SCREAMING_SNAKE_CASE_	)







    def       lowercase_				(							self	)				->     None:
         __lowerCamelCase   :	deque								=		deque()
         for node in self.adlist[0]["next_states"]:
              q.append(SCREAMING_SNAKE_CASE_	)
              __lowerCamelCase   :	str								=		0
         while q:
              __lowerCamelCase   :	Any								=		q.popleft()
              for child in self.adlist[r]["next_states"]:
                   q.append(SCREAMING_SNAKE_CASE_	)
                   __lowerCamelCase   :	Tuple								=		self.adlist[r]['fail_state']
                   while (
                       self.find_next_state(SCREAMING_SNAKE_CASE_			,     self.adlist[child]['value']	) is None
                       and state != 0
                   ):
                        __lowerCamelCase   :	int								=		self.adlist[state]['fail_state']
                   __lowerCamelCase   :	int								=		self.find_next_state(
                       SCREAMING_SNAKE_CASE_			,     self.adlist[child]['value']	)
                   if self.adlist[child]["fail_state"] is None:
                        __lowerCamelCase   :	Union[str, Any]								=		0
                   __lowerCamelCase   :	Dict								=		(
                       self.adlist[child]['output']
                       + self.adlist[self.adlist[child]['fail_state']]['output']
                   )







    def       lowercase_				(							self			,     SCREAMING_SNAKE_CASE_	)				->     dict[str, list[int]]:
         __lowerCamelCase   :	dict								=		{}  # returns a dict with keywords and list of its occurrences
         __lowerCamelCase   :	Any								=		0
         for i in range(len(SCREAMING_SNAKE_CASE_	)	):
              while (
                  self.find_next_state(SCREAMING_SNAKE_CASE_			,     string[i]	) is None
                  and current_state != 0
              ):
                   __lowerCamelCase   :	Union[str, Any]								=		self.adlist[current_state]['fail_state']
              __lowerCamelCase   :	str								=		self.find_next_state(SCREAMING_SNAKE_CASE_			,     string[i]	)
              if next_state is None:
                   __lowerCamelCase   :	Union[str, Any]								=		0
              else:
                   __lowerCamelCase   :	Any								=		next_state
                   for key in self.adlist[current_state]["output"]:
                        if key not in result:
                             __lowerCamelCase   :	Dict								=		[]
                        result[key].append(i - len(SCREAMING_SNAKE_CASE_	) + 1	)
         return result


if __name__ == "__main__":
      import doctest

      doctest.testmod()










'''simple docstring'''



from numpy import exp, pi, sqrt



def 			UpperCAmelCase__					(	UpperCAmelCase_    :				Optional[int]      ,    UpperCAmelCase_    :				float = 0.0      ,    UpperCAmelCase_    :				float = 1.0							)     ->		int:
     return 1 / sqrt(2 * pi * sigma**2							) * exp(-((x - mu) ** 2) / (2 * sigma**2)							)


if __name__ == "__main__":
      import doctest

      doctest.testmod()






