

"""simple docstring"""
from __future__ import annotations

from collections import deque

class       lowerCamelCase	:


  '''simple docstring'''







  def __init__(self							,       _lowerCamelCase	):


        """simple docstring"""

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

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



  def  _a      (self							,       _lowerCamelCase							,       _lowerCamelCase	):


        """simple docstring"""

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



  def  _a      (self							,       _lowerCamelCase	):


        """simple docstring"""

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



  def  _a      (self	):


        """simple docstring"""

        UpperCAmelCase__			:							deque							=    deque()
        for node in self.adlist[0]["next_states"]:
              q.append(_lowerCamelCase	)
              UpperCAmelCase__			:							List[Any]							=    0
        while q:
              UpperCAmelCase__			:							Optional[Any]							=    q.popleft()
              for child in self.adlist[r]["next_states"]:
                    q.append(_lowerCamelCase	)
                    UpperCAmelCase__			:							Union[str, Any]							=    self.adlist[r]["""fail_state"""]
                    while (
                        self.find_next_state(_lowerCamelCase							,       self.adlist[child]["""value"""]	) is None
                        and state != 0
                    ):
                          UpperCAmelCase__			:							List[Any]							=    self.adlist[state]["""fail_state"""]
                    UpperCAmelCase__			:							Tuple							=    self.find_next_state(
                        _lowerCamelCase							,       self.adlist[child]["""value"""]	)
                    if self.adlist[child]["fail_state"] is None:
                          UpperCAmelCase__			:							List[Any]							=    0
                    UpperCAmelCase__			:							Union[str, Any]							=    (
                        self.adlist[child]["""output"""]
                        + self.adlist[self.adlist[child]["""fail_state"""]]["""output"""]
                    )




  def  _a      (self							,       _lowerCamelCase	):


        """simple docstring"""

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


if __name__ == "__main__":
    import doctest

    doctest.testmod()




"""simple docstring"""
import math




def 					a__						(						lowerCAmelCase    )	-> list[int]:
      UpperCAmelCase__			:							Optional[int]							=    []
      UpperCAmelCase__			:							Union[str, Any]							=    2
      UpperCAmelCase__			:							List[Any]							=    int(math.sqrt(lowerCAmelCase    )    )  # Size of every segment
      UpperCAmelCase__			:							Dict							=    [True] * (end + 1)
      UpperCAmelCase__			:							str							=    []

      while start <= end:
            if temp[start] is True:
                  in_prime.append(lowerCAmelCase    )
                  for i in range(start * start			,	end + 1			,	lowerCAmelCase    ):
                        UpperCAmelCase__			:							Optional[Any]							=    False
            start += 1
      prime += in_prime

      UpperCAmelCase__			:							Optional[Any]							=    end + 1
      UpperCAmelCase__			:							Dict							=    min(2 * end			,	lowerCAmelCase    )

      while low <= n:
            UpperCAmelCase__			:							Optional[int]							=    [True] * (high - low + 1)
            for each in in_prime:
                  UpperCAmelCase__			:							Optional[int]							=    math.floor(low / each    ) * each
                  if t < low:
                        t += each

                  for j in range(lowerCAmelCase			,	high + 1			,	lowerCAmelCase    ):
                        UpperCAmelCase__			:							int							=    False

            for j in range(len(lowerCAmelCase    )    ):
                  if temp[j] is True:
                        prime.append(j + low    )

            UpperCAmelCase__			:							Dict							=    high + 1
            UpperCAmelCase__			:							int							=    min(high + end			,	lowerCAmelCase    )

      return prime





print(sieve(10**6))

