



'''simple docstring'''



from __future__ import annotations

from collections import deque
class 				UpperCAmelCase__     :



 def __init__(     self						,		lowercase	)     ->							Tuple:
  __UpperCamelCase 					=     []
  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       __lowerCamelCase (     self						,		lowercase						,		lowercase	)     ->							int | None:
  for state in self.adlist[current_state]["next_states"]:
   if char == self.adlist[state]["value"]:
    return state
  return None



 def       __lowerCamelCase (     self						,		lowercase	)     ->							None:
  __UpperCamelCase 					=     0
  for character in keyword:
   __UpperCamelCase 					=     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	)
    __UpperCamelCase 					=     len(self.adlist	) - 1
   else:
    __UpperCamelCase 					=     next_state
  self.adlist[current_state]["output"].append(SCREAMING_SNAKE_CASE_	)



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




 def       __lowerCamelCase (     self						,		lowercase	)     ->							dict[str, list[int]]:
  __UpperCamelCase 					=     {}  # returns a dict with keywords and list of its occurrences
  __UpperCamelCase 					=     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
   ):
    __UpperCamelCase 					=     self.adlist[current_state]['fail_state']
   __UpperCamelCase 					=     self.find_next_state(SCREAMING_SNAKE_CASE_						,		string[i]	)
   if next_state is None:
    __UpperCamelCase 					=     0
   else:
    __UpperCamelCase 					=     next_state
    for key in self.adlist[current_state]["output"]:
     if key not in result:
      __UpperCamelCase 					=     []
     result[key].append(i - len(SCREAMING_SNAKE_CASE_	) + 1	)
  return result


if __name__ == "__main__":
 import doctest

 doctest.testmod()









'''simple docstring'''



A__		:					Any												=  8.3_1_4_4_6_2  # Unit - J mol-1 K-1



def 			UpperCAmelCase__					(	UpperCAmelCase_    :				float      ,    UpperCAmelCase_    :				float      ,    UpperCAmelCase_    :				float							)     ->		float:
     if moles < 0 or kelvin < 0 or volume < 0:
          raise ValueError('Invalid inputs. Enter positive value.'							)
     return moles * kelvin * UNIVERSAL_GAS_CONSTANT / volume



def 			UpperCAmelCase__					(	UpperCAmelCase_    :				float      ,    UpperCAmelCase_    :				float      ,    UpperCAmelCase_    :				float							)     ->		float:
     if moles < 0 or kelvin < 0 or pressure < 0:
          raise ValueError('Invalid inputs. Enter positive value.'							)
     return moles * kelvin * UNIVERSAL_GAS_CONSTANT / pressure


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

      testmod()






