


'''simple docstring'''




from __future__ import annotations

from collections import deque

class 		UpperCAmelCase_      :





     def __init__( self       :      List[Any]    ,      UpperCAmelCase__       :      List[Any]    )				->  Tuple:
        lowerCAmelCase     =			[]
        self.adlist.append(
            {'value': '', 'next_states': [], 'fail_state': 0, 'output': []}    )

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





     def 							__UpperCAmelCase      ( self       :      int    ,      UpperCAmelCase__       :      Dict    ,      UpperCAmelCase__       :      Optional[Any]    )				->  int | None:
        for state in self.adlist[current_state]["next_states"]:
           if char == self.adlist[state]["value"]:
              return state
        return None





     def 							__UpperCAmelCase      ( self       :      List[Any]    ,      UpperCAmelCase__       :      Union[str, Any]    )				->  None:
        lowerCAmelCase     =			0
        for character in keyword:
           lowerCAmelCase     =			self.find_next_state(UpperCAmelCase__    ,      UpperCAmelCase__    )
           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     =			len(self.adlist    ) - 1
           else:
              lowerCAmelCase     =			next_state
        self.adlist[current_state]["output"].append(UpperCAmelCase__    )





     def 							__UpperCAmelCase      ( self       :      str    )				->  None:
        lowerCAmelCase     =			deque()
        for node in self.adlist[0]["next_states"]:
           q.append(UpperCAmelCase__    )
           lowerCAmelCase     =			0
        while q:
           lowerCAmelCase     =			q.popleft()
           for child in self.adlist[r]["next_states"]:
              q.append(UpperCAmelCase__    )
              lowerCAmelCase     =			self.adlist[r]['''fail_state''']
              while (
                  self.find_next_state(UpperCAmelCase__    ,      self.adlist[child]['value']    ) is None
                  and state != 0
              ):
                 lowerCAmelCase     =			self.adlist[state]['''fail_state''']
              lowerCAmelCase     =			self.find_next_state(
                  UpperCAmelCase__    ,      self.adlist[child]['value']    )
              if self.adlist[child]["fail_state"] is None:
                 lowerCAmelCase     =			0
              lowerCAmelCase     =			(
                  self.adlist[child]['''output''']
                  + self.adlist[self.adlist[child]['''fail_state''']]['''output''']
              )





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


if __name__ == "__main__":
       import doctest

       doctest.testmod()












def 		lowerCAmelCase_    (  __UpperCAmelCase:			float		,   __UpperCAmelCase:			int      )      ->	float:
    if digit_amount > 0:
        return round(number - int(__UpperCAmelCase      )		,   __UpperCAmelCase      )
    return number - int(__UpperCAmelCase      )


if __name__ == "__main__":
  print(decimal_isolate(1.53, 0))
  print(decimal_isolate(35.345, 1))
  print(decimal_isolate(35.345, 2))
  print(decimal_isolate(35.345, 3))
  print(decimal_isolate(-14.789, 3))
  print(decimal_isolate(0, 2))
  print(decimal_isolate(-14.123, 1))
  print(decimal_isolate(-14.123, 2))
  print(decimal_isolate(-14.123, 3))

