


'''simple docstring'''


import dataclasses
import enum
import functools
import math
import re

# The following script is adapted from the script of TaPas.
# Original: https://github.com/google-research/tapas/master/wikisql_utils.py
from typing import Any, List, Text


_UpperCamelCase          =     "none"
_UpperCamelCase          =     "none"


def 		_lowercase   (SCREAMING_SNAKE_CASE					,				SCREAMING_SNAKE_CASE       ):




     '''simple docstring'''





     __A  :					Optional[int]						     =       value.split(_UpperCamelCase       )
     return len(_UpperCamelCase       ) > 1 and any((len(_UpperCamelCase       ) == 3 for x in split)       )


def 		_lowercase   (SCREAMING_SNAKE_CASE       ):




     '''simple docstring'''





     if isinstance(_UpperCamelCase					,				_UpperCamelCase       ):
          return value
     if isinstance(_UpperCamelCase					,				_UpperCamelCase       ):
          return float(_UpperCamelCase       )
     if not isinstance(_UpperCamelCase					,				_UpperCamelCase       ):
          raise ValueError("Argument value is not a string. Can't parse it as float"       )
     __A  :					Optional[Any]						     =       value

     try:
          # Example: 1,000.7
          if "." in sanitized and "," in sanitized:
               return float(sanitized.replace(","					,				""       )       )
          # 1,000
          if "," in sanitized and _split_thousands(","					,				_UpperCamelCase       ):
               return float(sanitized.replace(","					,				""       )       )
          # 5,5556
          if "," in sanitized and sanitized.count(","       ) == 1 and not _split_thousands(","					,				_UpperCamelCase       ):
               return float(sanitized.replace(","					,				"."       )       )
          # 0.0.0.1
          if sanitized.count("."       ) > 1:
               return float(sanitized.replace("."					,				""       )       )
          # 0,0,0,1
          if sanitized.count(","       ) > 1:
               return float(sanitized.replace(","					,				""       )       )
          return float(_UpperCamelCase       )
     except ValueError:
          # Avoid adding the sanitized value in the error message.
          raise ValueError("Unable to convert value to float"       )


def 		_lowercase   (SCREAMING_SNAKE_CASE       ):




     '''simple docstring'''





     if answer is None:
          return None
     try:
          __A  :					int						     =       convert_to_float(_UpperCamelCase       )
          if isinstance(_UpperCamelCase					,				_UpperCamelCase       ) and math.isnan(_UpperCamelCase       ):
               return None
          return value
     except ValueError:
          return answer.lower()


_UpperCamelCase          =     {
    "text": lambda x: x,
    "real": convert_to_float,
}







class        __magic_name__  (					enum.Enum   ):

     """simple docstring"""






     lowerCamelCase__						=							0
     lowerCamelCase__						=							1
     lowerCamelCase__						=							2
     lowerCamelCase__						=							3
     lowerCamelCase__						=							4
     lowerCamelCase__						=							5







class        __magic_name__  (					enum.Enum   ):

     """simple docstring"""






     lowerCamelCase__						=							0
     lowerCamelCase__						=							1
     lowerCamelCase__						=							2







@dataclasses.dataclass
class        __magic_name__  :

     """simple docstring"""






     lowerCamelCase__						=							42
     lowerCamelCase__						=							42
     lowerCamelCase__						=							42


_UpperCamelCase          =     re.compile(r"""\w+|[^\w\s]+""", re.UNICODE | re.MULTILINE | re.DOTALL)


def 		_lowercase   (SCREAMING_SNAKE_CASE       ):




     '''simple docstring'''





     return list(_TOKENIZER.findall(x.lower()       )       )


def 		_lowercase   (SCREAMING_SNAKE_CASE					,				SCREAMING_SNAKE_CASE					,				SCREAMING_SNAKE_CASE       ):




     '''simple docstring'''





     if operator == _Operator.EQUALS:
          return src == tgt
     elif operator == _Operator.GREATER:
          return src > tgt
     elif operator == _Operator.LESSER:
          return src < tgt
     raise ValueError(f"Unknown operator: {operator}"       )


def 		_lowercase   (SCREAMING_SNAKE_CASE					,				SCREAMING_SNAKE_CASE					,				SCREAMING_SNAKE_CASE       ):




     '''simple docstring'''





     __A  :					str						     =       table["types"]
     return _TYPE_CONVERTER[types[column]](_UpperCamelCase       )


def 		_lowercase   (SCREAMING_SNAKE_CASE       ):




     '''simple docstring'''





     return isinstance(_UpperCamelCase					,				_UpperCamelCase       )


def 		_lowercase   (SCREAMING_SNAKE_CASE					,				SCREAMING_SNAKE_CASE					,				SCREAMING_SNAKE_CASE       ):




     '''simple docstring'''





     for cond in conditions:
          __A  :					List[str]						     =       row[cond.column]

          __A  :					Tuple						     =       _parse_value(_UpperCamelCase					,				cond.column					,				cond.cmp_value       )

          if _is_string(_UpperCamelCase       ) and _is_string(_UpperCamelCase       ):
               __A  :					str						     =       _normalize_for_match(_UpperCamelCase       )
               __A  :					Optional[Any]						     =       _normalize_for_match(_UpperCamelCase       )

          if not isinstance(_UpperCamelCase					,				type(_UpperCamelCase       )       ):
               raise ValueError("Type difference {} != {}".format(type(_UpperCamelCase       )					,				type(_UpperCamelCase       )       )       )

          if not _compare(cond.operator					,				_UpperCamelCase					,				_UpperCamelCase       ):
               return False
     return True


def 		_lowercase   (SCREAMING_SNAKE_CASE					,				SCREAMING_SNAKE_CASE					,				SCREAMING_SNAKE_CASE       ):




     '''simple docstring'''





     if not answer_coordinates:
          if aggregation_op == _Aggregation.COUNT:
               return 0.0
          else:
               return EMPTY_ANSWER_AGG

    # Count can support non numeric answers.
     if aggregation_op == _Aggregation.COUNT:
          return float(len(_UpperCamelCase       )       )

     # If we have just one answer, if float returns it or try a conversion.
     __A  :					Union[str, Any]						     =       [table["rows"][i][j] for (i, j) in answer_coordinates]
     if len(_UpperCamelCase       ) == 1:
          try:
               return convert_to_float(values[0]       )
          except ValueError as e:
               if aggregation_op != _Aggregation.NONE:
                    raise e

     if aggregation_op == _Aggregation.NONE:
          return None

     # Other aggregation only support numeric values. Bail out if we have strings.
     if not all((isinstance(_UpperCamelCase					,				(int, float)       ) for v in values)       ):
          return None

     if aggregation_op == _Aggregation.SUM:
          return float(sum(_UpperCamelCase       )       )
     elif aggregation_op == _Aggregation.AVERAGE:
          return sum(_UpperCamelCase       ) / len(_UpperCamelCase       )
     else:
          raise ValueError(f"Unknown aggregation: {aggregation_op}"       )


def 		_lowercase   (SCREAMING_SNAKE_CASE					,				SCREAMING_SNAKE_CASE       ):




     '''simple docstring'''





     __A  :					str						     =       sql_query["agg"]
     if aggregation_op_index >= 3:
          __A  :					List[Any]						     =       _Aggregation(_UpperCamelCase       )
     else:
          __A  :					str						     =       _Aggregation.NONE

     __A  :					Dict						     =       sql_query["sel"]
     __A  :					Tuple						     =       [
         _Condition(_UpperCamelCase					,				_Operator(_UpperCamelCase       )					,				_UpperCamelCase       )
         for column, operator, cmp_value in zip(
             sql_query["conds"]["column_index"]					,				sql_query["conds"]["operator_index"]					,				sql_query["conds"]["condition"]       )
     ]

     __A  :					Optional[Any]						     =       []
     for row in range(len(table["rows"]       )       ):
          if _respect_conditions(_UpperCamelCase					,				table["rows"][row]					,				_UpperCamelCase       ):
               indices.append((row, target_column)       )

     if not indices:
          return [], aggregation_op

     if len(_UpperCamelCase       ) == 1:
          return indices, aggregation_op

     # Parsing of MIN/MAX.
     if aggregation_op_index in (1, 2):
          __A  :					List[Any]						     =       {2: min, 1: max}
          __A  :					Tuple						     =       [(table["rows"][i][j], index) for index, (i, j) in enumerate(_UpperCamelCase       )]
          __A  :					Dict						     =       functools.reduce(operators[sql_query["agg"]]					,				_UpperCamelCase       )

          __A  :					int						     =       [indices[reduced[1]]]
          return ret, _Aggregation.NONE

     return indices, aggregation_op


def 		_lowercase   (SCREAMING_SNAKE_CASE					,				SCREAMING_SNAKE_CASE					,				SCREAMING_SNAKE_CASE       ):




     '''simple docstring'''





     if float_answer is not None:
          return [str(_UpperCamelCase       )]
     return [str(table["real_rows"][r][c]       ) for r, c in answer_coordinates]






def 		_lowercase   (SCREAMING_SNAKE_CASE					,				SCREAMING_SNAKE_CASE       ):




     '''simple docstring'''





     __A     ,__A  :					Any						     =       _get_answer_coordinates(_UpperCamelCase					,				_UpperCamelCase       )
     __A  :					Optional[Any]						     =       _get_float_answer(_UpperCamelCase					,				_UpperCamelCase					,				_UpperCamelCase       )
     __A  :					int						     =       _get_answer_text(_UpperCamelCase					,				_UpperCamelCase					,				_UpperCamelCase       )
     # keep the original data the same with TaPas
     if len(_UpperCamelCase       ) == 0:
          __A  :					List[str]						     =       [EMPTY_ANSWER]
     return answer_text





'''simple docstring'''


import math
from collections.abc import Generator


def 		_lowercase   (SCREAMING_SNAKE_CASE       ):




     '''simple docstring'''





     __A  :					Generator						     =       (i for i in range(1					,				(max_n + 1)       ))
     for i in (n for n in numbers if n > 1):
          for j in range(2					,				SCREAMING_SNAKE_CASE       ):
               if (i % j) == 0:
                    break
          else:
               yield i


def 		_lowercase   (SCREAMING_SNAKE_CASE       ):




     '''simple docstring'''





     __A  :					Generator						     =       (i for i in range(1					,				(max_n + 1)       ))
     for i in (n for n in numbers if n > 1):
          # only need to check for factors up to sqrt(i)
          __A  :					Optional[Any]						     =       int(math.sqrt(SCREAMING_SNAKE_CASE       )       ) + 1
          for j in range(2					,				SCREAMING_SNAKE_CASE       ):
               if (i % j) == 0:
                    break
          else:
               yield i


def 		_lowercase   (SCREAMING_SNAKE_CASE       ):




     '''simple docstring'''





     __A  :					Generator						     =       (i for i in range(1					,				(max_n + 1)					,				2       ))
     # It's useless to test even numbers as they will not be prime
     if max_n > 2:
          yield 2  # Because 2 will not be tested, it's necessary to yield it now
     for i in (n for n in numbers if n > 1):
          __A  :					List[str]						     =       int(math.sqrt(SCREAMING_SNAKE_CASE       )       ) + 1
          for j in range(3					,				SCREAMING_SNAKE_CASE					,				2       ):
               # As we removed the even numbers, we don't need them now
               if (i % j) == 0:
                    break
          else:
               yield i


def 		_lowercase   ():




     '''simple docstring'''





     from timeit import timeit

     __A  :					List[str]						     =       "from __main__ import slow_primes, primes, fast_primes"
     print(timeit("slow_primes(1_000_000_000_000)"					,				setup=SCREAMING_SNAKE_CASE					,				number=100_0000       )       )
     print(timeit("primes(1_000_000_000_000)"					,				setup=SCREAMING_SNAKE_CASE					,				number=100_0000       )       )
     print(timeit("fast_primes(1_000_000_000_000)"					,				setup=SCREAMING_SNAKE_CASE					,				number=100_0000       )       )


if __name__ == "__main__":
      _UpperCamelCase          =     int(input("""Calculate primes up to:\n>> """).strip())
      for ret in primes(number):
            print(ret)
      benchmark()

