


'''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


__lowercase			:		Optional[int] =			"""none"""
__lowercase			:		Optional[int] =			"""none"""






def 						lowerCamelCase							(_SCREAMING_SNAKE_CASE   :     Optional[int]		,   _SCREAMING_SNAKE_CASE   :     Optional[Any]     ):
					__a    : int      					=						value.split(_SCREAMING_SNAKE_CASE     )
					return len(_SCREAMING_SNAKE_CASE     ) > 1 and any((len(_SCREAMING_SNAKE_CASE     ) == 3 for x in split)     )






def 						lowerCamelCase							(_SCREAMING_SNAKE_CASE   :     Any     ):
					if isinstance(_SCREAMING_SNAKE_CASE		,   _SCREAMING_SNAKE_CASE     ):
										return value
					if isinstance(_SCREAMING_SNAKE_CASE		,   _SCREAMING_SNAKE_CASE     ):
										return float(_SCREAMING_SNAKE_CASE     )
					if not isinstance(_SCREAMING_SNAKE_CASE		,   _SCREAMING_SNAKE_CASE     ):
										raise ValueError('Argument value is not a string. Can\'t parse it as float'     )
					__a    : 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(','		,   _SCREAMING_SNAKE_CASE     ):
															return float(sanitized.replace(','		,   ''     )     )
										# 5,5556
										if "," in sanitized and sanitized.count(','     ) == 1 and not _split_thousands(','		,   _SCREAMING_SNAKE_CASE     ):
															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(_SCREAMING_SNAKE_CASE     )
					except ValueError:
										# Avoid adding the sanitized value in the error message.
										raise ValueError('Unable to convert value to float'     )






def 						lowerCamelCase							(_SCREAMING_SNAKE_CASE   :     Union[str, Any]     ):
					if answer is None:
										return None
					try:
										__a    : int      					=						convert_to_float(_SCREAMING_SNAKE_CASE     )
										if isinstance(_SCREAMING_SNAKE_CASE		,   _SCREAMING_SNAKE_CASE     ) and math.isnan(_SCREAMING_SNAKE_CASE     ):
															return None
										return value
					except ValueError:
										return answer.lower()


__lowercase			:		Tuple =			{
    """text""": lambda x: x,
    """real""": convert_to_float,
}





class 							__UpperCamelCase       (	enum.Enum      ):
	A_			    =					0
	A_			    =					1
	A_			    =					2
	A_			    =					3
	A_			    =					4
	A_			    =					5





class 							__UpperCamelCase       (	enum.Enum      ):
	A_			    =					0
	A_			    =					1
	A_			    =					2





@dataclasses.dataclass
class 							__UpperCamelCase       :
	A_			    =					42
	A_			    =					42
	A_			    =					42



__lowercase			:		Tuple =			re.compile(R'\w+|[^\w\s]+', re.UNICODE | re.MULTILINE | re.DOTALL)






def 						lowerCamelCase							(_SCREAMING_SNAKE_CASE   :     Optional[int]     ):
					return list(_TOKENIZER.findall(x.lower()     )     )






def 						lowerCamelCase							(_SCREAMING_SNAKE_CASE   :     Union[str, Any]		,   _SCREAMING_SNAKE_CASE   :     Any		,   _SCREAMING_SNAKE_CASE   :     List[str]     ):
					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 						lowerCamelCase							(_SCREAMING_SNAKE_CASE   :     List[str]		,   _SCREAMING_SNAKE_CASE   :     str		,   _SCREAMING_SNAKE_CASE   :     str     ):
					__a    : Optional[int]      					=						table["types"]
					return _TYPE_CONVERTER[types[column]](_SCREAMING_SNAKE_CASE     )






def 						lowerCamelCase							(_SCREAMING_SNAKE_CASE   :     Any     ):
					return isinstance(_SCREAMING_SNAKE_CASE		,   _SCREAMING_SNAKE_CASE     )






def 						lowerCamelCase							(_SCREAMING_SNAKE_CASE   :     int		,   _SCREAMING_SNAKE_CASE   :     List[str]		,   _SCREAMING_SNAKE_CASE   :     int     ):
					for cond in conditions:
										__a    : Tuple      					=						row[cond.column]

										__a    : List[Any]      					=						_parse_value(_SCREAMING_SNAKE_CASE		,   cond.column		,   cond.cmp_value     )

										if _is_string(_SCREAMING_SNAKE_CASE     ) and _is_string(_SCREAMING_SNAKE_CASE     ):
															__a    : Any      					=						_normalize_for_match(_SCREAMING_SNAKE_CASE     )
															__a    : Union[str, Any]      					=						_normalize_for_match(_SCREAMING_SNAKE_CASE     )

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

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






def 						lowerCamelCase							(_SCREAMING_SNAKE_CASE   :     Tuple		,   _SCREAMING_SNAKE_CASE   :     Optional[Any]		,   _SCREAMING_SNAKE_CASE   :     List[Any]     ):
					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(_SCREAMING_SNAKE_CASE     )     )

					# If we have just one answer, if float returns it or try a conversion.
					__a    : Tuple      					=						[table["rows"][i][j] for (i, j) in answer_coordinates]
					if len(_SCREAMING_SNAKE_CASE     ) == 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(_SCREAMING_SNAKE_CASE		,   (int, float)     ) for v in values)     ):
										return None

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






def 						lowerCamelCase							(_SCREAMING_SNAKE_CASE   :     List[Any]		,   _SCREAMING_SNAKE_CASE   :     int     ):
					__a    : Union[str, Any]      					=						sql_query["agg"]
					if aggregation_op_index >= 3:
										__a    : Dict      					=						_Aggregation(_SCREAMING_SNAKE_CASE     )
					else:
										__a    : Any      					=						_Aggregation.NONE

					__a    : Optional[Any]      					=						sql_query["sel"]
					__a    : Optional[int]      					=						[
					    _Condition(_SCREAMING_SNAKE_CASE		,   _Operator(_SCREAMING_SNAKE_CASE     )		,   _SCREAMING_SNAKE_CASE     )
					    for column, operator, cmp_value in zip(
					        sql_query['conds']['column_index']		,   sql_query['conds']['operator_index']		,   sql_query['conds']['condition']     )
					]

					__a    : Optional[int]      					=						[]
					for row in range(len(table['rows']     )     ):
										if _respect_conditions(_SCREAMING_SNAKE_CASE		,   table['rows'][row]		,   _SCREAMING_SNAKE_CASE     ):
															indices.append((row, target_column)     )

					if not indices:
										return [], aggregation_op

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

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

										__a    : List[Any]      					=						[indices[reduced[1]]]
										return ret, _Aggregation.NONE

					return indices, aggregation_op






def 						lowerCamelCase							(_SCREAMING_SNAKE_CASE   :     List[str]		,   _SCREAMING_SNAKE_CASE   :     str		,   _SCREAMING_SNAKE_CASE   :     Optional[Any]     ):
					if float_answer is not None:
										return [str(_SCREAMING_SNAKE_CASE     )]
					return [str(table['real_rows'][r][c]     ) for r, c in answer_coordinates]






def 						lowerCamelCase							(_SCREAMING_SNAKE_CASE   :     Optional[Any]		,   _SCREAMING_SNAKE_CASE   :     str     ):
					__a    : Union[str, Any]      					=						_get_answer_coordinates(_SCREAMING_SNAKE_CASE		,   _SCREAMING_SNAKE_CASE     )
					__a    : Dict      					=						_get_float_answer(_SCREAMING_SNAKE_CASE		,   _SCREAMING_SNAKE_CASE		,   _SCREAMING_SNAKE_CASE     )
					__a    : Union[str, Any]      					=						_get_answer_text(_SCREAMING_SNAKE_CASE		,   _SCREAMING_SNAKE_CASE		,   _SCREAMING_SNAKE_CASE     )
					# keep the original data the same with TaPas
					if len(_SCREAMING_SNAKE_CASE     ) == 0:
										__a    : Dict      					=						[EMPTY_ANSWER]
					return answer_text







'''simple docstring'''



import itertools






def 						lowerCamelCase							(_SCREAMING_SNAKE_CASE   :     int = 1_000_000     ):
					__a    : str      					=						[1]

					for i in itertools.count(len(_SCREAMING_SNAKE_CASE     )     ):
										__a    : Dict      					=						0
										for j in itertools.count(1     ):
															__a    : int      					=						-1 if j % 2 == 0 else +1
															__a    : Optional[int]      					=						(j * j * 3 - j) // 2
															if index > i:
																				break
															item += partitions[i - index] * sign
															item %= number
															index += j
															if index > i:
																				break
															item += partitions[i - index] * sign
															item %= number

										if item == 0:
															return i
										partitions.append(_SCREAMING_SNAKE_CASE     )

					return 0


if __name__ == "__main__":
	import doctest

	doctest.testmod()

	print(f'''{solution() = }''')



