






import io
import itertools
import json
from dataclasses import dataclass
from typing import Optional

import pyarrow as pa
import pyarrow.json as paj

import datasets
from datasets.table import table_cast
from datasets.utils.file_utils import readline


A        =   datasets.utils.logging.get_logger(__name__)


@dataclass
class 							__a							(  datasets.BuilderConfig						):





		'''simple docstring'''



		UpperCAmelCase__      :				Optional[datasets.Features]				    =						None
		UpperCAmelCase__      :				str				    =						"utf-8"
		UpperCAmelCase__      :				Optional[str]				    =						None
		UpperCAmelCase__      :				Optional[str]				    =						None
		UpperCAmelCase__      :				bool				    =						True  # deprecated
		UpperCAmelCase__      :				Optional[int]				    =						None  # deprecated
		UpperCAmelCase__      :				int				    =						10 << 20  # 10MB
		UpperCAmelCase__      :				Optional[bool]				    =						None






class 							__a							(  datasets.ArrowBasedBuilder						):





		'''simple docstring'''



		UpperCAmelCase__      :				List[Any]				    =						JsonConfig


		def   __snake_case			(						self       ):
						if self.config.block_size is not None:
										logger.warning('The JSON loader parameter `block_size` is deprecated. Please use `chunksize` instead'       )
										SCREAMING_SNAKE_CASE_   :	Union[str, Any]													=   self.config.block_size
						if self.config.use_threads is not True:
										logger.warning(
										    'The JSON loader parameter `use_threads` is deprecated and doesn\'t have any effect anymore.'       )
						if self.config.newlines_in_values is not None:
										raise ValueError('The JSON loader parameter `newlines_in_values` is no longer supported'       )
						return datasets.DatasetInfo(features=self.config.features       )


		def   __snake_case			(						self ,    UpperCamelCase__       ):
						if not self.config.data_files:
										raise ValueError(F'''At least one data file must be specified, but got data_files={self.config.data_files}'''       )
						SCREAMING_SNAKE_CASE_   :	str													=   dl_manager.download_and_extract(self.config.data_files       )
						if isinstance(UpperCamelCase__ ,    (str, list, tuple)       ):
										SCREAMING_SNAKE_CASE_   :	List[str]													=   data_files
										if isinstance(UpperCamelCase__ ,    UpperCamelCase__       ):
														SCREAMING_SNAKE_CASE_   :	Tuple													=   [files]
										SCREAMING_SNAKE_CASE_   :	int													=   [dl_manager.iter_files(UpperCamelCase__       ) for file in files]
										return [datasets.SplitGenerator(name=datasets.Split.TRAIN ,    gen_kwargs={'files': files}       )]
						SCREAMING_SNAKE_CASE_   :	str													=   []
						for split_name, files in data_files.items():
										if isinstance(UpperCamelCase__ ,    UpperCamelCase__       ):
														SCREAMING_SNAKE_CASE_   :	Any													=   [files]
										SCREAMING_SNAKE_CASE_   :	Union[str, Any]													=   [dl_manager.iter_files(UpperCamelCase__       ) for file in files]
										splits.append(datasets.SplitGenerator(name=UpperCamelCase__ ,    gen_kwargs={'files': files}       )       )
						return splits


		def   __snake_case			(						self ,    UpperCamelCase__       ):
						if self.config.features is not None:
										# adding missing columns
										for column_name in set(self.config.features       ) - set(pa_table.column_names       ):
														SCREAMING_SNAKE_CASE_   :	str													=   self.config.features.arrow_schema.field(UpperCamelCase__       ).type
														SCREAMING_SNAKE_CASE_   :	Any													=   pa_table.append_column(UpperCamelCase__ ,    pa.array([None] * len(UpperCamelCase__       ) ,    type=UpperCamelCase__       )       )
										# more expensive cast to support nested structures with keys in a different order
										# allows str <-> int/float or str to Audio for example
										SCREAMING_SNAKE_CASE_   :	Dict													=   table_cast(UpperCamelCase__ ,    self.config.features.arrow_schema       )
						return pa_table






		def   __snake_case			(						self ,    UpperCamelCase__       ):
						for file_idx, file in enumerate(itertools.chain.from_iterable(UpperCamelCase__       )       ):
										# If the file is one json object and if we need to look at the list of items in one specific field
										if self.config.field is not None:
														with open(UpperCamelCase__ ,    encoding=self.config.encoding ,    errors=self.config.encoding_errors       ) as f:
																		SCREAMING_SNAKE_CASE_   :	List[str]													=   json.load(UpperCamelCase__       )

														# We keep only the field we are interested in
														SCREAMING_SNAKE_CASE_   :	Tuple													=   dataset[self.config.field]

														# We accept two format: a list of dicts or a dict of lists
														if isinstance(UpperCamelCase__ ,    (list, tuple)       ):
																		SCREAMING_SNAKE_CASE_   :	Tuple													=   set().union(*[row.keys() for row in dataset]       )
																		SCREAMING_SNAKE_CASE_   :	List[Any]													=   {col: [row.get(UpperCamelCase__       ) for row in dataset] for col in keys}
														else:
																		SCREAMING_SNAKE_CASE_   :	str													=   dataset
														SCREAMING_SNAKE_CASE_   :	Optional[int]													=   pa.Table.from_pydict(UpperCamelCase__       )
														yield file_idx, self._cast_table(UpperCamelCase__       )

										# If the file has one json object per line
										else:
														with open(UpperCamelCase__ ,    'rb'       ) as f:
																		SCREAMING_SNAKE_CASE_   :	List[str]													=   0
																		# Use block_size equal to the chunk size divided by 32 to leverage multithreading
																		# Set a default minimum value of 16kB if the chunk size is really small
																		SCREAMING_SNAKE_CASE_   :	Any													=   max(self.config.chunksize // 32 ,    16 << 10       )
																		SCREAMING_SNAKE_CASE_   :	Optional[int]													=   (
																		    self.config.encoding_errors if self.config.encoding_errors is not None else 'strict'
																		)
																		while True:
																						SCREAMING_SNAKE_CASE_   :	List[str]													=   f.read(self.config.chunksize       )
																						if not batch:
																										break
																						# Finish current line
																						try:
																										batch += f.readline()
																						except (AttributeError, io.UnsupportedOperation):
																										batch += readline(UpperCamelCase__       )
																						# PyArrow only accepts utf-8 encoded bytes
																						if self.config.encoding != "utf-8":
																										SCREAMING_SNAKE_CASE_   :	List[Any]													=   batch.decode(self.config.encoding ,    errors=UpperCamelCase__       ).encode('utf-8'       )
																						try:
																										while True:
																														try:
																																		SCREAMING_SNAKE_CASE_   :	Dict													=   paj.read_json(
																																		    io.BytesIO(UpperCamelCase__       ) ,    read_options=paj.ReadOptions(block_size=UpperCamelCase__       )       )
																																		break
																														except (pa.ArrowInvalid, pa.ArrowNotImplementedError) as e:
																																		if (
																																		    isinstance(UpperCamelCase__ ,    pa.ArrowInvalid       )
																																		    and "straddling" not in str(UpperCamelCase__       )
																																		    or block_size > len(UpperCamelCase__       )
																																		):
																																						raise
																																		else:
																																						# Increase the block size in case it was too small.
																																						# The block size will be reset for the next file.
																																						logger.debug(
																																						    F'''Batch of {len(UpperCamelCase__       )} bytes couldn\'t be parsed with block_size={block_size}. Retrying with block_size={block_size * 2}.'''       )
																																						block_size *= 2
																						except pa.ArrowInvalid as e:
																										try:
																														with open(
																														    UpperCamelCase__ ,    encoding=self.config.encoding ,    errors=self.config.encoding_errors       ) as f:
																																		SCREAMING_SNAKE_CASE_   :	Optional[int]													=   json.load(UpperCamelCase__       )
																										except json.JSONDecodeError:
																														logger.error(F'''Failed to read file \'{file}\' with error {type(UpperCamelCase__       )}: {e}'''       )
																														raise e
																										# If possible, parse the file as a list of json objects and exit the loop
																										if isinstance(UpperCamelCase__ ,    UpperCamelCase__       ):  # list is the only sequence type supported in JSON
																														try:
																																		SCREAMING_SNAKE_CASE_   :	Union[str, Any]													=   set().union(*[row.keys() for row in dataset]       )
																																		SCREAMING_SNAKE_CASE_   :	Dict													=   {col: [row.get(UpperCamelCase__       ) for row in dataset] for col in keys}
																																		SCREAMING_SNAKE_CASE_   :	int													=   pa.Table.from_pydict(UpperCamelCase__       )
																														except (pa.ArrowInvalid, AttributeError) as e:
																																		logger.error(F'''Failed to read file \'{file}\' with error {type(UpperCamelCase__       )}: {e}'''       )
																																		raise ValueError(F'''Not able to read records in the JSON file at {file}.'''       ) from None
																														yield file_idx, self._cast_table(UpperCamelCase__       )
																														break
																										else:
																														logger.error(F'''Failed to read file \'{file}\' with error {type(UpperCamelCase__       )}: {e}'''       )
																														raise ValueError(
																														    F'''Not able to read records in the JSON file at {file}. '''
																														    F'''You should probably indicate the field of the JSON file containing your records. '''
																														    F'''This JSON file contain the following fields: {str(list(dataset.keys()       )       )}. '''
																														    F'''Select the correct one and provide it as `field=\'XXX\'` to the dataset loading method. '''       ) from None
                        # Uncomment for debugging (will print the Arrow table size and elements)
                        # logger.warning(f"pa_table: {pa_table} num rows: {pa_table.num_rows}")
                        # logger.warning('\n'.join(str(pa_table.slice(i, 1).to_pydict()) for i in range(pa_table.num_rows)))
																						yield (file_idx, batch_idx), self._cast_table(UpperCamelCase__       )
																						batch_idx += 1







from math import sqrt



def 					_lowerCamelCase(			lowerCAmelCase__				:		int      ):





				'''simple docstring'''







				assert isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      ) and (
				    number >= 0
				), "'number' must been an int and positive"

				SCREAMING_SNAKE_CASE_   :	Dict													=   True

				# 0 and 1 are none primes.
				if number <= 1:
								SCREAMING_SNAKE_CASE_   :	Optional[int]													=   False

				for divisor in range(2    ,    int(round(sqrt(lowerCAmelCase__      )      )      ) + 1      ):
								# if 'number' divisible by 'divisor' then sets 'status'
								# of false and break up the loop.
								if number % divisor == 0:
												SCREAMING_SNAKE_CASE_   :	Dict													=   False
												break

    # precondition
				assert isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      ), "'status' must been from type bool"

				return status



def 					_lowerCamelCase(			lowerCAmelCase__				:		int      ):





				'''simple docstring'''







				assert isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      ) and (n > 2), "'N' must been an int and > 2"

				# beginList: contains all natural numbers from 2 up to N
				SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   list(range(2    ,    n + 1      )      )

				SCREAMING_SNAKE_CASE_   :	Any													=   []  # this list will be returns.

				# actual sieve of erathostenes
				for i in range(len(lowerCAmelCase__      )      ):
								for j in range(i + 1    ,    len(lowerCAmelCase__      )      ):
												if (begin_list[i] != 0) and (begin_list[j] % begin_list[i] == 0):
																SCREAMING_SNAKE_CASE_   :	str													=   0

    # filters actual prime numbers.
				SCREAMING_SNAKE_CASE_   :	int													=   [x for x in begin_list if x != 0]

				# precondition
				assert isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      ), "'ans' must been from type list"

				return ans



def 					_lowerCamelCase(			lowerCAmelCase__				:		List[str]      ):





				'''simple docstring'''







				assert isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      ) and (n > 2), "'N' must been an int and > 2"

				SCREAMING_SNAKE_CASE_   :	int													=   []

				# iterates over all numbers between 2 up to N+1
				# if a number is prime then appends to list 'ans'
				for number in range(2    ,    n + 1      ):
								if is_prime(lowerCAmelCase__      ):
												ans.append(lowerCAmelCase__      )

    # precondition
				assert isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      ), "'ans' must been from type list"

				return ans



def 					_lowerCamelCase(			lowerCAmelCase__				:		Union[str, Any]      ):





				'''simple docstring'''







				assert isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      ) and number >= 0, "'number' must been an int and >= 0"

				SCREAMING_SNAKE_CASE_   :	Optional[int]													=   []  # this list will be returns of the function.

				# potential prime number factors.

				SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   2

				SCREAMING_SNAKE_CASE_   :	List[Any]													=   number

				if number == 0 or number == 1:
								ans.append(lowerCAmelCase__      )

				# if 'number' not prime then builds the prime factorization of 'number'
				elif not is_prime(lowerCAmelCase__      ):
								while quotient != 1:
												if is_prime(lowerCAmelCase__      ) and (quotient % factor == 0):
																ans.append(lowerCAmelCase__      )
																quotient /= factor
												else:
																factor += 1

				else:
								ans.append(lowerCAmelCase__      )

				# precondition
				assert isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      ), "'ans' must been from type list"

				return ans



def 					_lowerCamelCase(			lowerCAmelCase__				:		Any      ):





				'''simple docstring'''







				assert isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      ) and (
				    number >= 0
				), "'number' bust been an int and >= 0"

				SCREAMING_SNAKE_CASE_   :	int													=   0

				# prime factorization of 'number'
				SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   prime_factorization(lowerCAmelCase__      )

				SCREAMING_SNAKE_CASE_   :	Dict													=   max(lowerCAmelCase__      )

				# precondition
				assert isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      ), "'ans' must been from type int"

				return ans



def 					_lowerCamelCase(			lowerCAmelCase__				:		Optional[Any]      ):





				'''simple docstring'''







				assert isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      ) and (
				    number >= 0
				), "'number' bust been an int and >= 0"

				SCREAMING_SNAKE_CASE_   :	Optional[int]													=   0

				# prime factorization of 'number'
				SCREAMING_SNAKE_CASE_   :	Union[str, Any]													=   prime_factorization(lowerCAmelCase__      )

				SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   min(lowerCAmelCase__      )

				# precondition
				assert isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      ), "'ans' must been from type int"

				return ans



def 					_lowerCamelCase(			lowerCAmelCase__				:		Optional[int]      ):





				'''simple docstring'''







				assert isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      ), "'number' must been an int"
				assert isinstance(number % 2 == 0    ,    lowerCAmelCase__      ), "compare bust been from type bool"

				return number % 2 == 0



def 					_lowerCamelCase(			lowerCAmelCase__				:		Optional[int]      ):





				'''simple docstring'''







				assert isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      ), "'number' must been an int"
				assert isinstance(number % 2 != 0    ,    lowerCAmelCase__      ), "compare bust been from type bool"

				return number % 2 != 0



def 					_lowerCamelCase(			lowerCAmelCase__				:		Optional[Any]      ):





				'''simple docstring'''







				assert (
				    isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      ) and (number > 2) and is_even(lowerCAmelCase__      )
				), "'number' must been an int, even and > 2"

				SCREAMING_SNAKE_CASE_   :	Any													=   []  # this list will returned

				# creates a list of prime numbers between 2 up to 'number'
				SCREAMING_SNAKE_CASE_   :	int													=   get_prime_numbers(lowerCAmelCase__      )
				SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   len(lowerCAmelCase__      )

				# run variable for while-loops.
				SCREAMING_SNAKE_CASE_   :	Any													=   0
				SCREAMING_SNAKE_CASE_   :	List[str]													=   None

				# exit variable. for break up the loops
				SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   True

				while i < len_pn and loop:
								SCREAMING_SNAKE_CASE_   :	Optional[int]													=   i + 1

								while j < len_pn and loop:
												if prime_numbers[i] + prime_numbers[j] == number:
																SCREAMING_SNAKE_CASE_   :	List[str]													=   False
																ans.append(prime_numbers[i]      )
																ans.append(prime_numbers[j]      )

												j += 1

								i += 1

				# precondition
				assert (
				    isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      )
				    and (len(lowerCAmelCase__      ) == 2)
				    and (ans[0] + ans[1] == number)
				    and is_prime(ans[0]      )
				    and is_prime(ans[1]      )
				), "'ans' must contains two primes. And sum of elements must been eq 'number'"

				return ans



def 					_lowerCamelCase(			lowerCAmelCase__				:		str    ,    lowerCAmelCase__				:		List[Any]      ):





				'''simple docstring'''







				assert (
				    isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      )
				    and isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      )
				    and (numbera >= 0)
				    and (numbera >= 0)
				), "'number1' and 'number2' must been positive integer."

				SCREAMING_SNAKE_CASE_   :	int													=   0

				while numbera != 0:
								SCREAMING_SNAKE_CASE_   :	List[str]													=   numbera % numbera
								SCREAMING_SNAKE_CASE_   :	Optional[int]													=   numbera
								SCREAMING_SNAKE_CASE_   :	List[Any]													=   rest

				# precondition
				assert isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      ) and (
				    numbera >= 0
				), "'number' must been from type int and positive"

				return numbera



def 					_lowerCamelCase(			lowerCAmelCase__				:		int    ,    lowerCAmelCase__				:		Optional[Any]      ):





				'''simple docstring'''







				assert (
				    isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      )
				    and isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      )
				    and (numbera >= 1)
				    and (numbera >= 1)
				), "'number1' and 'number2' must been positive integer."

				SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   1  # actual answer that will be return.

				# for kgV (x,1)
				if numbera > 1 and numbera > 1:
								# builds the prime factorization of 'number1' and 'number2'
								SCREAMING_SNAKE_CASE_   :	Tuple													=   prime_factorization(lowerCAmelCase__      )
								SCREAMING_SNAKE_CASE_   :	List[Any]													=   prime_factorization(lowerCAmelCase__      )

				elif numbera == 1 or numbera == 1:
								SCREAMING_SNAKE_CASE_   :	List[Any]													=   []
								SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   []
								SCREAMING_SNAKE_CASE_   :	int													=   max(lowerCAmelCase__    ,    lowerCAmelCase__      )

				SCREAMING_SNAKE_CASE_   :	Union[str, Any]													=   0
				SCREAMING_SNAKE_CASE_   :	Any													=   0

				SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   []  # captured numbers int both 'primeFac1' and 'primeFac2'

				# iterates through primeFac1
				for n in prime_fac_a:
								if n not in done:
												if n in prime_fac_a:
																SCREAMING_SNAKE_CASE_   :	int													=   prime_fac_a.count(lowerCAmelCase__      )
																SCREAMING_SNAKE_CASE_   :	Tuple													=   prime_fac_a.count(lowerCAmelCase__      )

																for _ in range(max(lowerCAmelCase__    ,    lowerCAmelCase__      )      ):
																				ans *= n

												else:
																SCREAMING_SNAKE_CASE_   :	List[Any]													=   prime_fac_a.count(lowerCAmelCase__      )

																for _ in range(lowerCAmelCase__      ):
																				ans *= n

												done.append(lowerCAmelCase__      )

    # iterates through primeFac2
				for n in prime_fac_a:
								if n not in done:
												SCREAMING_SNAKE_CASE_   :	int													=   prime_fac_a.count(lowerCAmelCase__      )

												for _ in range(lowerCAmelCase__      ):
																ans *= n

												done.append(lowerCAmelCase__      )

    # precondition
				assert isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      ) and (
				    ans >= 0
				), "'ans' must been from type int and positive"

				return ans



def 					_lowerCamelCase(			lowerCAmelCase__				:		Any      ):





				'''simple docstring'''







				assert isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      ) and (n >= 0), "'number' must been a positive int"

				SCREAMING_SNAKE_CASE_   :	Optional[int]													=   0
				SCREAMING_SNAKE_CASE_   :	Optional[int]													=   2  # this variable holds the answer

				while index < n:
								index += 1

								ans += 1  # counts to the next number

								# if ans not prime then
								# runs to the next prime number.
								while not is_prime(lowerCAmelCase__      ):
												ans += 1

    # precondition
				assert isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      ) and is_prime(
				    lowerCAmelCase__      ), "'ans' must been a prime number and from type int"

				return ans



def 					_lowerCamelCase(			lowerCAmelCase__				:		List[str]    ,    lowerCAmelCase__				:		Optional[int]      ):





				'''simple docstring'''







				assert (
				    is_prime(lowerCAmelCase__      ) and is_prime(lowerCAmelCase__      ) and (p_number_a < p_number_a)
				), "The arguments must been prime numbers and 'pNumber1' < 'pNumber2'"

				SCREAMING_SNAKE_CASE_   :	str													=   p_number_a + 1  # jump to the next number

				SCREAMING_SNAKE_CASE_   :	List[Any]													=   []  # this list will be returns.

				# if number is not prime then
				# fetch the next prime number.
				while not is_prime(lowerCAmelCase__      ):
								number += 1

				while number < p_number_a:
								ans.append(lowerCAmelCase__      )

								number += 1

								# fetch the next prime number.
								while not is_prime(lowerCAmelCase__      ):
												number += 1

    # precondition
				assert (
				    isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      )
				    and ans[0] != p_number_a
				    and ans[len(lowerCAmelCase__      ) - 1] != p_number_a
				), "'ans' must been a list without the arguments"

				# 'ans' contains not 'pNumber1' and 'pNumber2' !
				return ans



def 					_lowerCamelCase(			lowerCAmelCase__				:		Optional[Any]      ):





				'''simple docstring'''







				assert isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      ) and (n >= 1), "'n' must been int and >= 1"

				SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   []  # will be returned.

				for divisor in range(1    ,    n + 1      ):
								if n % divisor == 0:
												ans.append(lowerCAmelCase__      )

    # precondition
				assert ans[0] == 1 and ans[len(lowerCAmelCase__      ) - 1] == n, "Error in function getDivisiors(...)"

				return ans



def 					_lowerCamelCase(			lowerCAmelCase__				:		int      ):





				'''simple docstring'''







				assert isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      ) and (
				    number > 1
				), "'number' must been an int and >= 1"

				SCREAMING_SNAKE_CASE_   :	int													=   get_divisors(lowerCAmelCase__      )

				# precondition
				assert (
				    isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      )
				    and (divisors[0] == 1)
				    and (divisors[len(lowerCAmelCase__      ) - 1] == number)
				), "Error in help-function getDivisiors(...)"

				# summed all divisors up to 'number' (exclusive), hence [:-1]
				return sum(divisors[:-1]      ) == number



def 					_lowerCamelCase(			lowerCAmelCase__				:		Dict    ,    lowerCAmelCase__				:		str      ):





				'''simple docstring'''







				assert (
				    isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      )
				    and isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      )
				    and (denominator != 0)
				), "The arguments must been from type int and 'denominator' != 0"

				# build the greatest common divisor of numerator and denominator.
				SCREAMING_SNAKE_CASE_   :	str													=   gcd(abs(lowerCAmelCase__      )    ,    abs(lowerCAmelCase__      )      )

				# precondition
				assert (
				    isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      )
				    and (numerator % gcd_of_fraction == 0)
				    and (denominator % gcd_of_fraction == 0)
				), "Error in function gcd(...,...)"

				return (numerator // gcd_of_fraction, denominator // gcd_of_fraction)



def 					_lowerCamelCase(			lowerCAmelCase__				:		Tuple      ):





				'''simple docstring'''







				assert isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      ) and (n >= 0), "'n' must been a int and >= 0"

				SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   1  # this will be return.

				for factor in range(1    ,    n + 1      ):
								ans *= factor

				return ans



def 					_lowerCamelCase(			lowerCAmelCase__				:		Tuple      ):





				'''simple docstring'''







				assert isinstance(lowerCAmelCase__    ,    lowerCAmelCase__      ) and (n >= 0), "'n' must been an int and >= 0"

				SCREAMING_SNAKE_CASE_   :	List[Any]													=   0
				SCREAMING_SNAKE_CASE_   :	Union[str, Any]													=   1
				SCREAMING_SNAKE_CASE_   :	int													=   1  # this will be return

				for _ in range(n - 1      ):
								SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   ans
								ans += fiba
								SCREAMING_SNAKE_CASE_   :	List[str]													=   tmp

				return ans