




import json
import os
import tempfile

import datasets
from utils import generate_example_dataset, get_duration


__UpperCamelCase      : List[Any]					      =   500_000

__UpperCamelCase      : Union[str, Any]					      =   os.path.split(__file__)
__UpperCamelCase      : Optional[Any]					      =   os.path.join(RESULTS_BASEPATH, "results", RESULTS_FILENAME.replace(".py", ".json"))





@get_duration
def 	__A	(			__lowerCamelCase					)   -> Dict:
					a		       =							dataset.select(range(0							,    len(__lowerCamelCase					)							,    2					)					)





@get_duration
def 	__A	(			__lowerCamelCase					)   -> List[str]:
					a		       =							dataset.sort("""numbers"""					)





@get_duration
def 	__A	(			__lowerCamelCase					)   -> Tuple:
					a		       =							dataset.shuffle()





@get_duration
def 	__A	(			__lowerCamelCase					)   -> Dict:
					a		       =							dataset.train_test_split(0.1					)





@get_duration
def 	__A	(			__lowerCamelCase							,    __lowerCamelCase=10					)   -> Optional[int]:
					for shard_id in range(__lowerCamelCase					):
										a		       =							dataset.shard(__lowerCamelCase							,    __lowerCamelCase					)





def 	__A	(			)   -> Union[str, Any]:
					a		       =							{"""num examples""": SPEED_TEST_N_EXAMPLES}
					a		       =							(select, sort, shuffle, train_test_split, shard)
					with tempfile.TemporaryDirectory() as tmp_dir:
										print("""generating dataset"""					)
										a		       =							datasets.Features({"""text""": datasets.Value("""string"""					), """numbers""": datasets.Value("""float32"""					)}					)
										a		       =							generate_example_dataset(
										    os.path.join(__lowerCamelCase							,    """dataset.arrow"""					)							,    __lowerCamelCase							,    num_examples=__lowerCamelCase					)
										print("""Functions"""					)
										for func in functions:
															print(func.__name__					)
															a		       =							func(__lowerCamelCase					)

					with open(__lowerCamelCase							,    """wb"""					) as f:
										f.write(json.dumps(__lowerCamelCase					).encode("""utf-8"""					)					)


if __name__ == "__main__":  # useful to run the profiler
		benchmark_indices_mapping()







from itertools import combinations, product





def 	__A	(			__lowerCamelCase							,    __lowerCamelCase							,    __lowerCamelCase							,    __lowerCamelCase					)   -> bool:
	if xa == ya == 0 or xa == ya == 0:
		return False
	a		       =							xa * xa + ya * ya
	a		       =							xa * xa + ya * ya
	a		       =							(xa - xa) * (xa - xa) + (ya - ya) * (ya - ya)
	return (
	    a_square + b_square == c_square
	    or a_square + c_square == b_square
	    or b_square + c_square == a_square
	)





def 	__A	(			__lowerCamelCase = 50					)   -> int:
	return sum(
	    1
	    for pta, pta in combinations(product(range(limit + 1					)							,    repeat=2					)							,    2					)
	    if is_right(*__lowerCamelCase							,    *__lowerCamelCase					)					)


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

