
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


__SCREAMING_SNAKE_CASE     :				Dict             =       'none'
__SCREAMING_SNAKE_CASE     :				Union[str, Any]             =       'none'
def       UpperCAmelCase__							(    __magic_name__  :       int							,					__magic_name__  :       Optional[int]					):


					'''simple docstring'''

					lowerCAmelCase						:   Optional[int]							=       value.split(__magic_name__					)
					return len(__magic_name__					) > 1 and any((len(__magic_name__					) == 3 for x in split)					)
def       UpperCAmelCase__							(    __magic_name__  :       List[str]					):


					'''simple docstring'''

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


					'''simple docstring'''

					if answer is None:
										return None
					try:
										lowerCAmelCase						:   Optional[Any]							=       convert_to_float(__magic_name__					)
										if isinstance(__magic_name__							,					__magic_name__					) and math.isnan(__magic_name__					):
															return None
										return value
					except ValueError:
										return answer.lower()


__SCREAMING_SNAKE_CASE     :				List[Any]             =       {
    'text': lambda x: x,
    'real': convert_to_float,
}


class 						__magic_name__				(  enum.Enum      ):
		_lowerCAmelCase						=		0
		_lowerCAmelCase						=		1
		_lowerCAmelCase						=		2
		_lowerCAmelCase						=		3
		_lowerCAmelCase						=		4
		_lowerCAmelCase						=		5



class 						__magic_name__				(  enum.Enum      ):
		_lowerCAmelCase						=		0
		_lowerCAmelCase						=		1
		_lowerCAmelCase						=		2



@dataclasses.dataclass
class 						__magic_name__				:
		_lowerCAmelCase						=		42
		_lowerCAmelCase						=		42
		_lowerCAmelCase						=		42



__SCREAMING_SNAKE_CASE     :				List[Any]             =       re.compile(r'\w+|[^\w\s]+', re.UNICODE | re.MULTILINE | re.DOTALL)
def       UpperCAmelCase__							(    __magic_name__  :       List[str]					):


					'''simple docstring'''

					return list(_TOKENIZER.findall(x.lower()					)					)
def       UpperCAmelCase__							(    __magic_name__  :       List[str]							,					__magic_name__  :       str							,					__magic_name__  :       Optional[Any]					):


					'''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       UpperCAmelCase__							(    __magic_name__  :       List[str]							,					__magic_name__  :       int							,					__magic_name__  :       Optional[int]					):


					'''simple docstring'''

					lowerCAmelCase						:   Union[str, Any]							=       table['''types''']
					return _TYPE_CONVERTER[types[column]](__magic_name__					)
def       UpperCAmelCase__							(    __magic_name__  :       int					):


					'''simple docstring'''

					return isinstance(__magic_name__							,					__magic_name__					)
def       UpperCAmelCase__							(    __magic_name__  :       Optional[int]							,					__magic_name__  :       List[str]							,					__magic_name__  :       int					):


					'''simple docstring'''

					for cond in conditions:
										lowerCAmelCase						:   Optional[int]							=       row[cond.column]

										lowerCAmelCase						:   str							=       _parse_value(__magic_name__							,					cond.column							,					cond.cmp_value					)

										if _is_string(__magic_name__					) and _is_string(__magic_name__					):
															lowerCAmelCase						:   Dict							=       _normalize_for_match(__magic_name__					)
															lowerCAmelCase						:   Any							=       _normalize_for_match(__magic_name__					)

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

										if not _compare(cond.operator							,					__magic_name__							,					__magic_name__					):
															return False
					return True
def       UpperCAmelCase__							(    __magic_name__  :       int							,					__magic_name__  :       str							,					__magic_name__  :       List[Any]					):


					'''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(__magic_name__					)					)

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

					if aggregation_op == _Aggregation.SUM:
										return float(sum(__magic_name__					)					)
					elif aggregation_op == _Aggregation.AVERAGE:
										return sum(__magic_name__					) / len(__magic_name__					)
					else:
										raise ValueError(f'''Unknown aggregation: {aggregation_op}'''					)
def       UpperCAmelCase__							(    __magic_name__  :       Optional[Any]							,					__magic_name__  :       List[str]					):


					'''simple docstring'''

					lowerCAmelCase						:   int							=       sql_query['''agg''']
					if aggregation_op_index >= 3:
										lowerCAmelCase						:   Any							=       _Aggregation(__magic_name__					)
					else:
										lowerCAmelCase						:   Any							=       _Aggregation.NONE

					lowerCAmelCase						:   Any							=       sql_query['''sel''']
					lowerCAmelCase						:   str							=       [
					    _Condition(__magic_name__							,					_Operator(__magic_name__					)							,					__magic_name__					)
					    for column, operator, cmp_value in zip(
					        sql_query['''conds''']['''column_index''']							,					sql_query['''conds''']['''operator_index''']							,					sql_query['''conds''']['''condition''']					)
					]

					lowerCAmelCase						:   Tuple							=       []
					for row in range(len(table['''rows''']					)					):
										if _respect_conditions(__magic_name__							,					table['''rows'''][row]							,					__magic_name__					):
															indices.append((row, target_column)					)

					if not indices:
										return [], aggregation_op

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

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

										lowerCAmelCase						:   Tuple							=       [indices[reduced[1]]]
										return ret, _Aggregation.NONE

					return indices, aggregation_op
def       UpperCAmelCase__							(    __magic_name__  :       int							,					__magic_name__  :       List[str]							,					__magic_name__  :       Tuple					):


					'''simple docstring'''

					if float_answer is not None:
										return [str(__magic_name__					)]
					return [str(table['''real_rows'''][r][c]					) for r, c in answer_coordinates]
def       UpperCAmelCase__							(    __magic_name__  :       int							,					__magic_name__  :       Optional[int]					):


					'''simple docstring'''

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


def       UpperCAmelCase__							(    __magic_name__  :       int = 99_80_01					):


					'''simple docstring'''

					lowerCAmelCase						:   Tuple							=       0
					for i in range(9_99							,					99							,					-1					):  # 3 digit numbers range from 999 down to 100
										for j in range(9_99							,					99							,					-1					):
															lowerCAmelCase						:   Any							=       str(i * j					)
															if product_string == product_string[::-1] and i * j < n:
																				lowerCAmelCase						:   Optional[int]							=       max(__magic_name__							,					i * j					)
					return answer


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