
"""simple docstring"""





from __future__ import annotations

from collections import deque


class A_	:




  '''simple docstring'''







  def __init__(		self				,   lowercase_  ):

     """simple docstring"""
     UpperCAmelCase_					:					list[dict]			     =    []
     self.adlist.append(
         {"value": "", "next_states": [], "fail_state": 0, "output": []}  )

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







  def        UpperCamelCase__					(		self				,   lowercase_				,   lowercase_  ):

     """simple docstring"""
     for state in self.adlist[current_state]["next_states"]:
        if char == self.adlist[state]["value"]:
           return state
     return None







  def        UpperCamelCase__					(		self				,   lowercase_  ):

     """simple docstring"""
     UpperCAmelCase_					:					Union[str, Any]			     =    0
     for character in keyword:
        UpperCAmelCase_					:					int			     =    self.find_next_state(lowercase_				,   lowercase_  )
        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  )
           UpperCAmelCase_					:					int			     =    len(self.adlist  ) - 1
        else:
           UpperCAmelCase_					:					Optional[Any]			     =    next_state
     self.adlist[current_state]["output"].append(lowercase_  )







  def        UpperCamelCase__					(		self  ):

     """simple docstring"""
     UpperCAmelCase_					:					deque			     =    deque()
     for node in self.adlist[0]["next_states"]:
        q.append(lowercase_  )
        UpperCAmelCase_					:					Dict			     =    0
     while q:
        UpperCAmelCase_					:					List[Any]			     =    q.popleft()
        for child in self.adlist[r]["next_states"]:
           q.append(lowercase_  )
           UpperCAmelCase_					:					Dict			     =    self.adlist[r]["fail_state"]
           while (
               self.find_next_state(lowercase_				,   self.adlist[child]["value"]  ) is None
               and state != 0
           ):
              UpperCAmelCase_					:					Dict			     =    self.adlist[state]["fail_state"]
           UpperCAmelCase_					:					Dict			     =    self.find_next_state(
               lowercase_				,   self.adlist[child]["value"]  )
           if self.adlist[child]["fail_state"] is None:
              UpperCAmelCase_					:					Any			     =    0
           UpperCAmelCase_					:					Optional[Any]			     =    (
               self.adlist[child]["output"]
               + self.adlist[self.adlist[child]["fail_state"]]["output"]
           )







  def        UpperCamelCase__					(		self				,   lowercase_  ):

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


if __name__ == "__main__":
    import doctest

    doctest.testmod()




"""simple docstring"""





from __future__ import annotations

import math







def 	__a     (		__lowerCamelCase,		__lowerCamelCase  ):
   UpperCAmelCase_					:					Any			     =    u
   for i in range(1,		__lowerCamelCase  ):
      UpperCAmelCase_					:					int			     =    temp * (u - i)
   return temp







def 	__a     (		):
   UpperCAmelCase_					:					str			     =    int(input("enter the numbers of values: "  )  )
   UpperCAmelCase_					:					list[list[float]]			     =    []
   for _ in range(__lowerCamelCase  ):
      y.append([]  )
   for i in range(__lowerCamelCase  ):
      for j in range(__lowerCamelCase  ):
         y[i].append(__lowerCamelCase  )
         UpperCAmelCase_					:					Tuple			     =    0

   print("enter the values of parameters in a list: "  )
   UpperCAmelCase_					:					Union[str, Any]			     =    list(map(__lowerCamelCase,		input().split()  )  )

   print("enter the values of corresponding parameters: "  )
   for i in range(__lowerCamelCase  ):
      UpperCAmelCase_					:					int			     =    float(input()  )

   UpperCAmelCase_					:					Tuple			     =    int(input("enter the value to interpolate: "  )  )
   UpperCAmelCase_					:					Tuple			     =    (value - x[0]) / (x[1] - x[0])

   # for calculating forward difference table

   for i in range(1,		__lowerCamelCase  ):
      for j in range(n - i  ):
         UpperCAmelCase_					:					Union[str, Any]			     =    y[j + 1][i - 1] - y[j][i - 1]

   UpperCAmelCase_					:					Optional[int]			     =    y[0][0]
   for i in range(1,		__lowerCamelCase  ):
      summ += (ucal(__lowerCamelCase,		__lowerCamelCase  ) * y[0][i]) / math.factorial(__lowerCamelCase  )

   print(f"""the value at {value} is {summ}"""  )


if __name__ == "__main__":
    main()


