





'''simple docstring'''






from __future__ import annotations

from itertools import permutations
from random import randint
from timeit import repeat







def 					_a						(       ) ->				tuple[list[int], int]:



			"""simple docstring"""


			__snake_case					:      str							      =     [randint(-1000    ,	1000 ) for i in range(10 )]
			__snake_case					:      str							      =     randint(-5000    ,	5000 )
			return (arr, r)


__UpperCamelCase					    =	make_dataset()







def 					_a						(       _lowerCamelCase    ,	_lowerCamelCase ) ->				tuple[int, ...]:



			"""simple docstring"""


			for triplet in permutations(_lowerCamelCase    ,	3 ):
						if sum(_lowerCamelCase ) == target:
									return tuple(sorted(_lowerCamelCase ) )
			return (0, 0, 0)







def 					_a						(       _lowerCamelCase    ,	_lowerCamelCase ) ->				tuple[int, int, int]:



			"""simple docstring"""


			arr.sort()
			__snake_case					:      Any							      =     len(_lowerCamelCase )
			for i in range(n - 1 ):
						__snake_case      ,     __snake_case					:      Optional[int]							      =     i + 1, n - 1
						while left < right:
									if arr[i] + arr[left] + arr[right] == target:
												return (arr[i], arr[left], arr[right])
									elif arr[i] + arr[left] + arr[right] < target:
												left += 1
									elif arr[i] + arr[left] + arr[right] > target:
												right -= 1
			return (0, 0, 0)







def 					_a						(       ) ->				tuple[float, float]:



			"""simple docstring"""


			__snake_case					:      Tuple							      =     """
from __main__ import dataset, triplet_sum1, triplet_sum2
"""
			__snake_case					:      int							      =     """
triplet_sum1(*dataset)
"""
			__snake_case					:      List[Any]							      =     """
triplet_sum2(*dataset)
"""
			__snake_case					:      str							      =     repeat(setup=_lowerCamelCase    ,	stmt=_lowerCamelCase    ,	repeat=5    ,	number=1_0000 )
			__snake_case					:      int							      =     repeat(setup=_lowerCamelCase    ,	stmt=_lowerCamelCase    ,	repeat=5    ,	number=1_0000 )
			return (min(_lowerCamelCase ), min(_lowerCamelCase ))


if __name__ == "__main__":
	from doctest import testmod

	testmod()
	__UpperCamelCase					    =	solution_times()
	print(f"""The time for naive implementation is {times[0]}.""")
	print(f"""The time for optimized implementation is {times[1]}.""")









'''simple docstring'''






from unittest import TestCase

from datasets import Sequence, Value
from datasets.arrow_dataset import Dataset




class  _A (					__lowercase		):

		def 	lowercase__     (   self					:   Any			)					->    str:


					"""simple docstring"""

					return [
					    {"col_1": 3, "col_2": "a"},
					    {"col_1": 2, "col_2": "b"},
					    {"col_1": 1, "col_2": "c"},
					    {"col_1": 0, "col_2": "d"},
					]

		def 	lowercase__     (   self					:   str			)					->    int:


					"""simple docstring"""

					__snake_case					:      Union[str, Any]							      =     {"""col_1""": [3, 2, 1, 0], """col_2""": ["""a""", """b""", """c""", """d"""]}
					return Dataset.from_dict(__magic_name__			)

		def 	lowercase__     (   self					:   str			)					->    List[Any]:


					"""simple docstring"""

					__snake_case					:      Any							      =     self._create_example_records()
					__snake_case					:      str							      =     Dataset.from_list(__magic_name__			)
					self.assertListEqual(dset.column_names  ,      ["""col_1""", """col_2"""]			)
					for i, r in enumerate(__magic_name__			):
								self.assertDictEqual(__magic_name__  ,      example_records[i]			)

		def 	lowercase__     (   self					:   Optional[Any]			)					->    List[Any]:


					"""simple docstring"""

					__snake_case					:      List[Any]							      =     self._create_example_records()
					__snake_case					:      Dict							      =     Dataset.from_list(__magic_name__			)
					__snake_case					:      List[Any]							      =     Dataset.from_dict({k: [r[k] for r in example_records] for k in example_records[0]}			)
					self.assertEqual(dset.info  ,      dset_from_dict.info			)

		def 	lowercase__     (   self					:   str			)					->    List[Any]:  # checks what happens with missing columns


					"""simple docstring"""

					__snake_case					:      Union[str, Any]							      =     [{"""col_1""": 1}, {"""col_2""": """x"""}]
					__snake_case					:      Optional[int]							      =     Dataset.from_list(__magic_name__			)
					self.assertDictEqual(dset[0]  ,      {"""col_1""": 1}			)
					self.assertDictEqual(dset[1]  ,      {"""col_1""": None}			)  # NB: first record is used for columns

		def 	lowercase__     (   self					:   List[str]			)					->    Optional[Any]:  # checks if the type can be inferred from the second record


					"""simple docstring"""

					__snake_case					:      List[Any]							      =     [{"""col_1""": []}, {"""col_1""": [1, 2]}]
					__snake_case					:      int							      =     Dataset.from_list(__magic_name__			)
					self.assertEqual(dset.info.features["""col_1"""]  ,      Sequence(Value("""int64"""			)			)			)

		def 	lowercase__     (   self					:   int			)					->    Union[str, Any]:


					"""simple docstring"""

					__snake_case					:      Tuple							      =     Dataset.from_list([]			)
					self.assertEqual(len(__magic_name__			)  ,      0			)
					self.assertListEqual(dset.column_names  ,      []			)


