



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__			:   int      			=    """none"""
UpperCAmelCase__			:   Optional[int]      			=    """none"""


def 	_A	(   _UpperCamelCase      ,					_UpperCamelCase			):
				_UpperCAmelCase						:  Dict     					=	value.split(__UpperCAmelCase			)
				return len(__UpperCAmelCase			) > 1 and any((len(__UpperCAmelCase			) == 3 for x in split)			)


def 	_A	(   _UpperCamelCase			):
				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'''			)
				_UpperCAmelCase						:  List[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 	_A	(   _UpperCamelCase			):
				if answer is None:
								return None
				try:
								_UpperCAmelCase						:  int     					=	convert_to_float(__UpperCAmelCase			)
								if isinstance(__UpperCAmelCase      ,					__UpperCAmelCase			) and math.isnan(__UpperCAmelCase			):
												return None
								return value
				except ValueError:
								return answer.lower()


UpperCAmelCase__			:   Any      			=    {
    """text""": lambda x: x,
    """real""": convert_to_float,
}





class 							lowerCAmelCase_		(		enum.Enum     ):
		SCREAMING_SNAKE_CASE_       :			Optional[Any]					       =	0
		SCREAMING_SNAKE_CASE_       :			List[str]					       =	1
		SCREAMING_SNAKE_CASE_       :			Dict					       =	2
		SCREAMING_SNAKE_CASE_       :			int					       =	3
		SCREAMING_SNAKE_CASE_       :			Any					       =	4
		SCREAMING_SNAKE_CASE_       :			List[Any]					       =	5





class 							lowerCAmelCase_		(		enum.Enum     ):
		SCREAMING_SNAKE_CASE_       :			Optional[Any]					       =	0
		SCREAMING_SNAKE_CASE_       :			Dict					       =	1
		SCREAMING_SNAKE_CASE_       :			Optional[int]					       =	2





@dataclasses.dataclass
class 							lowerCAmelCase_		:
		SCREAMING_SNAKE_CASE_       :			Text
		SCREAMING_SNAKE_CASE_       :			_Operator
		SCREAMING_SNAKE_CASE_       :			Any
UpperCAmelCase__			:   List[str]      			=    re.compile(R'\w+|[^\w\s]+', re.UNICODE | re.MULTILINE | re.DOTALL)


def 	_A	(   _UpperCamelCase			):
				return list(_TOKENIZER.findall(x.lower()			)			)


def 	_A	(   _UpperCamelCase      ,					_UpperCamelCase      ,					_UpperCamelCase			):
				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 	_A	(   _UpperCamelCase      ,					_UpperCamelCase      ,					_UpperCamelCase			):
				_UpperCAmelCase						:  Optional[int]     					=	table["""types"""]
				return _TYPE_CONVERTER[types[column]](__UpperCAmelCase			)


def 	_A	(   _UpperCamelCase			):
				return isinstance(__UpperCAmelCase      ,					__UpperCAmelCase			)


def 	_A	(   _UpperCamelCase      ,					_UpperCamelCase      ,					_UpperCamelCase			):
				for cond in conditions:
								_UpperCAmelCase						:  Optional[Any]     					=	row[cond.column]

								_UpperCAmelCase						:  List[Any]     					=	_parse_value(__UpperCAmelCase      ,					cond.column      ,					cond.cmp_value			)

								if _is_string(__UpperCAmelCase			) and _is_string(__UpperCAmelCase			):
												_UpperCAmelCase						:  List[str]     					=	_normalize_for_match(__UpperCAmelCase			)
												_UpperCAmelCase						:  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 	_A	(   _UpperCamelCase      ,					_UpperCamelCase      ,					_UpperCamelCase			):
				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.
				_UpperCAmelCase						:  int     					=	[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 	_A	(   _UpperCamelCase      ,					_UpperCamelCase			):
				_UpperCAmelCase						:  Tuple     					=	sql_query["""agg"""]
				if aggregation_op_index >= 3:
								_UpperCAmelCase						:  Tuple     					=	_Aggregation(__UpperCAmelCase			)
				else:
								_UpperCAmelCase						:  Optional[Any]     					=	_Aggregation.NONE

				_UpperCAmelCase						:  str     					=	sql_query["""sel"""]
				_UpperCAmelCase						:  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''']			)
				]

				_UpperCAmelCase						:  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):
								_UpperCAmelCase						:  Tuple     					=	{2: min, 1: max}
								_UpperCAmelCase						:  Union[str, Any]     					=	[(table["""rows"""][i][j], index) for index, (i, j) in enumerate(__UpperCAmelCase			)]
								_UpperCAmelCase						:  List[str]     					=	functools.reduce(operators[sql_query['''agg''']]      ,					__UpperCAmelCase			)

								_UpperCAmelCase						:  Dict     					=	[indices[reduced[1]]]
								return ret, _Aggregation.NONE

				return indices, aggregation_op


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






def 	_A	(   _UpperCamelCase      ,					_UpperCamelCase			):
				_UpperCAmelCase						:  Union[str, Any]     					=	_get_answer_coordinates(__UpperCAmelCase      ,					__UpperCAmelCase			)
				_UpperCAmelCase						:  List[Any]     					=	_get_float_answer(__UpperCAmelCase      ,					__UpperCAmelCase      ,					__UpperCAmelCase			)
				_UpperCAmelCase						:  Optional[Any]     					=	_get_answer_text(__UpperCAmelCase      ,					__UpperCAmelCase      ,					__UpperCAmelCase			)
				# keep the original data the same with TaPas
				if len(__UpperCAmelCase			) == 0:
								_UpperCAmelCase						:  Dict     					=	[EMPTY_ANSWER]
				return answer_text





"""simple docstring"""







import math
from collections.abc import Generator


def  __SCREAMING_SNAKE_CASE (  __UpperCAmelCase      ):
		_lowercase				: 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   ,				__UpperCAmelCase      ):
						if (i % j) == 0:
								break
				else:
						yield i


def  __SCREAMING_SNAKE_CASE (  __UpperCAmelCase      ):
		_lowercase				: 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)
				_lowercase				: Union[str, Any]     =   int(math.sqrt(__UpperCAmelCase      )      ) + 1
				for j in range(2   ,				__UpperCAmelCase      ):
						if (i % j) == 0:
								break
				else:
						yield i


def  __SCREAMING_SNAKE_CASE (  __UpperCAmelCase      ):
		_lowercase				: 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):
				_lowercase				: str     =   int(math.sqrt(__UpperCAmelCase      )      ) + 1
				for j in range(3   ,				__UpperCAmelCase   ,				2      ):
						# As we removed the even numbers, we don't need them now
						if (i % j) == 0:
								break
				else:
						yield i


def  __SCREAMING_SNAKE_CASE (  ):
		from timeit import timeit

		_lowercase				: Tuple     =   """from __main__ import slow_primes, primes, fast_primes"""
		print(timeit("""slow_primes(1_000_000_000_000)"""   ,				setup=__UpperCAmelCase   ,				number=1000000      )      )
		print(timeit("""primes(1_000_000_000_000)"""   ,				setup=__UpperCAmelCase   ,				number=1000000      )      )
		print(timeit("""fast_primes(1_000_000_000_000)"""   ,				setup=__UpperCAmelCase   ,				number=1000000      )      )


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



