

from random import randint, random






def 					lowerCamelCase_     (							UpperCAmelCase_							:     int							,       UpperCAmelCase_							:     int							,       UpperCAmelCase_							:     int							,       UpperCAmelCase_							:     bool = False							,       UpperCAmelCase_							:     bool = False							,       UpperCAmelCase_							:     int = 5							,       )						->				str:




	'''simple docstring'''




	_UpperCamelCase   :		List[Any]			=						[[-1] * number_of_cells]  # Create a highway without any car
	_UpperCamelCase   :		Optional[Any]			=						0
	_UpperCamelCase   :		int			=						max(__lowercase							,       0	)
	while i < number_of_cells:
		_UpperCamelCase   :		Any			=						(
		    randint(0							,       __lowercase	) if random_speed else initial_speed
		)  # Place the cars
		i += (
		    randint(1							,       max_speed * 2	) if random_frequency else frequency
		)  # Arbitrary number, may need tuning
	return highway






def 					lowerCamelCase_     (							UpperCAmelCase_							:     list							,       UpperCAmelCase_							:     int	)						->				List[Any]:




	'''simple docstring'''




	_UpperCamelCase   :		Union[str, Any]			=						0
	_UpperCamelCase   :		str			=						highway_now[car_index + 1 :]
	for cell in range(len(__lowercase	)	):  # May need a better name for this
		if cells[cell] != -1:  # If the cell is not empty then
			return distance  # we have the distance we wanted
		distance += 1
	# Here if the car is near the end of the highway
	return distance + get_distance(__lowercase							,       -1	)






def 					lowerCamelCase_     (							UpperCAmelCase_							:     list							,       UpperCAmelCase_							:     float							,       UpperCAmelCase_							:     int	)						->				int:




	'''simple docstring'''




	_UpperCamelCase   :		Any			=						len(__lowercase	)
	# Beforce calculations, the highway is empty
	_UpperCamelCase   :		Tuple			=						[-1] * number_of_cells

	for car_index in range(__lowercase	):
		if highway_now[car_index] != -1:
			# Add 1 to the current speed of the car and cap the speed
			_UpperCamelCase   :		str			=						min(highway_now[car_index] + 1							,       __lowercase	)
			# Number of empty cell before the next car
			_UpperCamelCase   :		Optional[Any]			=						get_distance(__lowercase							,       __lowercase	) - 1
			# We can't have the car causing an accident
			_UpperCamelCase   :		Union[str, Any]			=						min(next_highway[car_index]							,       __lowercase	)
			if random() < probability:
				# Randomly, a driver will slow down
				_UpperCamelCase   :		int			=						max(next_highway[car_index] - 1							,       0	)
	return next_highway






def 					lowerCamelCase_     (							UpperCAmelCase_							:     list							,       UpperCAmelCase_							:     int							,       UpperCAmelCase_							:     float							,       UpperCAmelCase_							:     int	)						->				Union[str, Any]:




	'''simple docstring'''




	_UpperCamelCase   :		Dict			=						len(highway[0]	)

	for i in range(__lowercase	):
		_UpperCamelCase   :		Any			=						update(highway[i]							,       __lowercase							,       __lowercase	)
		_UpperCamelCase   :		List[Any]			=						[-1] * number_of_cells

		for car_index in range(__lowercase	):
			_UpperCamelCase   :		List[Any]			=						next_speeds_calculated[car_index]
			if speed != -1:
				# Change the position based on the speed (with % to create the loop)
				_UpperCamelCase   :		Any			=						(car_index + speed) % number_of_cells
				# Commit the change of position
				_UpperCamelCase   :		Union[str, Any]			=						speed
		highway.append(__lowercase	)

	return highway


if __name__ == "__main__":
							import doctest

							doctest.testmod()









def 					lowerCamelCase_     (							UpperCAmelCase_							:     list	)						->				list:




	'''simple docstring'''




	if len(UpperCAmelCase_	) <= 1:
		return [tuple(UpperCAmelCase_	)]

	_UpperCamelCase   :		List[Any]			=						[]

	def generate(UpperCAmelCase_							:     int							,       UpperCAmelCase_							:     list	):
		_UpperCamelCase   :		Optional[int]			=						[0] * n
		res.append(tuple(UpperCAmelCase_	)	)

		_UpperCamelCase   :		List[Any]			=						0
		while i < n:
			if c[i] < i:
				if i % 2 == 0:
					_UpperCamelCase	,		_UpperCamelCase   :		List[str]			=						arr[i], arr[0]
				else:
					_UpperCamelCase	,		_UpperCamelCase   :		List[str]			=						arr[i], arr[c[i]]
				res.append(tuple(UpperCAmelCase_	)	)
				c[i] += 1
				_UpperCamelCase   :		Tuple			=						0
			else:
				_UpperCamelCase   :		Tuple			=						0
				i += 1

	generate(len(UpperCAmelCase_	)							,       UpperCAmelCase_	)
	return res


if __name__ == "__main__":
							lowerCAmelCase__								=		input("""Enter numbers separated by a comma:\n""").strip()
							lowerCAmelCase__								=		[int(item) for item in user_input.split(""",""")]
							print(heaps(arr))




