





from __future__ import annotations

from collections import deque

class  __A:

     def __init__(      self,       A      ):





            """simple docstring"""

            _UpperCamelCase              =						[]
            self.adlist.append(
                {'''value''': '''''', '''next_states''': [], '''fail_state''': 0, '''output''': []}      )

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

     def 	_UpperCamelCase     (      self,       A,       A      ):





            """simple docstring"""

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

     def 	_UpperCamelCase     (      self,       A      ):





            """simple docstring"""

            _UpperCamelCase              =						0
            for character in keyword:
                   _UpperCamelCase              =						self.find_next_state(a_,       a_      )
                   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(a_      )

     def 	_UpperCamelCase     (      self      ):





            """simple docstring"""

            _UpperCamelCase              =						deque()
            for node in self.adlist[0]["next_states"]:
                   q.append(a_      )
                   _UpperCamelCase              =						0
            while q:
                   _UpperCamelCase              =						q.popleft()
                   for child in self.adlist[r]["next_states"]:
                          q.append(a_      )
                          _UpperCamelCase              =						self.adlist[r]["""fail_state"""]
                          while (
                              self.find_next_state(a_,       self.adlist[child]['''value''']      ) is None
                              and state != 0
                          ):
                                 _UpperCamelCase              =						self.adlist[state]["""fail_state"""]
                          _UpperCamelCase              =						self.find_next_state(
                              a_,       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 	_UpperCamelCase     (      self,       A      ):





            """simple docstring"""

            _UpperCamelCase              =						{}  # returns a dict with keywords and list of its occurrences
            _UpperCamelCase              =						0
            for i in range(len(a_      )      ):
                   while (
                       self.find_next_state(a_,       string[i]      ) is None
                       and current_state != 0
                   ):
                          _UpperCamelCase              =						self.adlist[current_state]["""fail_state"""]
                   _UpperCamelCase              =						self.find_next_state(a_,       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(a_      ) + 1      )
            return result


if __name__ == "__main__":
       import doctest

       doctest.testmod()













def     SCREAMING_SNAKE_CASE			(      lowerCAmelCase = 1_000					):
       _UpperCamelCase              =						3
       _UpperCamelCase              =						0
       while a < n:
              if a % 3 == 0 or a % 5 == 0:
                     result += a
              elif a % 15 == 0:
                     result -= a
              a += 1
       return result


if __name__ == "__main__":
       print(F'''{solution() = }''')






