'''simple docstring'''


def       lowerCAmelCase					(		UpperCamelCase__				:   Tuple    ,					UpperCamelCase__				:   Dict       ):


	"""simple docstring"""
	__UpperCAmelCase							=			''''''
	for i in table:
		res += inp[i - 1]
	return res





def       lowerCAmelCase					(		UpperCamelCase__				:   Optional[int]       ):


	"""simple docstring"""
	return data[1:] + data[0]





def       lowerCAmelCase					(		UpperCamelCase__				:   Union[str, Any]    ,					UpperCamelCase__				:   List[Any]       ):


	"""simple docstring"""
	__UpperCAmelCase							=			''''''
	for i in range(len(UpperCamelCase__       )       ):
		if a[i] == b[i]:
			res += "0"
		else:
			res += "1"
	return res





def       lowerCAmelCase					(		UpperCamelCase__				:   Tuple    ,					UpperCamelCase__				:   str       ):


	"""simple docstring"""
	__UpperCAmelCase							=			int('''0b''' + data[0] + data[-1]    ,					2       )
	__UpperCAmelCase							=			int('''0b''' + data[1:3]    ,					2       )
	return bin(s[row][col]       )[2:]





def       lowerCAmelCase					(		UpperCamelCase__				:   List[str]    ,					UpperCamelCase__				:   Optional[int]    ,					UpperCamelCase__				:   Optional[Any]    ,					UpperCamelCase__				:   Optional[int]    ,					UpperCamelCase__				:   int       ):


	"""simple docstring"""
	__UpperCAmelCase							=			message[:4]
	__UpperCAmelCase							=			message[4:]
	__UpperCAmelCase							=			apply_table(UpperCamelCase__    ,					UpperCamelCase__       )
	__UpperCAmelCase							=			xor(UpperCamelCase__    ,					UpperCamelCase__       )
	__UpperCAmelCase							=			apply_sbox(UpperCamelCase__    ,					temp[:4]       )  # noqa: E741
	__UpperCAmelCase							=			apply_sbox(UpperCamelCase__    ,					temp[4:]       )
	__UpperCAmelCase							=			'''0''' * (2 - len(UpperCamelCase__       )) + l  # noqa: E741
	__UpperCAmelCase							=			'''0''' * (2 - len(UpperCamelCase__       )) + r
	__UpperCAmelCase							=			apply_table(l + r    ,					UpperCamelCase__       )
	__UpperCAmelCase							=			xor(UpperCamelCase__    ,					UpperCamelCase__       )
	return temp + right


if __name__ == "__main__":
					__lowerCAmelCase	:       Union[str, Any]						       =	input("Enter 10 bit key: ")
					__lowerCAmelCase	:       str						       =	input("Enter 8 bit message: ")

					__lowerCAmelCase	:       List[str]						       =	[6, 3, 7, 4, 8, 5, 10, 9]
					__lowerCAmelCase	:       Tuple						       =	[3, 5, 2, 7, 4, 10, 1, 9, 8, 6]
					__lowerCAmelCase	:       Optional[Any]						       =	[2, 4, 3, 1]
					__lowerCAmelCase	:       int						       =	[2, 6, 3, 1, 4, 8, 5, 7]
					__lowerCAmelCase	:       int						       =	[4, 1, 3, 5, 7, 2, 8, 6]
					__lowerCAmelCase	:       Dict						       =	[4, 1, 2, 3, 2, 3, 4, 1]
					__lowerCAmelCase	:       Tuple						       =	[[1, 0, 3, 2], [3, 2, 1, 0], [0, 2, 1, 3], [3, 1, 3, 2]]
					__lowerCAmelCase	:       str						       =	[[0, 1, 2, 3], [2, 0, 1, 3], [3, 0, 1, 0], [2, 1, 0, 3]]

					# key generation
					__lowerCAmelCase	:       Dict						       =	apply_table(key, paa_table)
					__lowerCAmelCase	:       str						       =	temp[:5]
					__lowerCAmelCase	:       str						       =	temp[5:]
					__lowerCAmelCase	:       Tuple						       =	left_shift(left)
					__lowerCAmelCase	:       Union[str, Any]						       =	left_shift(right)
					__lowerCAmelCase	:       Union[str, Any]						       =	apply_table(left + right, pa_table)
					__lowerCAmelCase	:       Union[str, Any]						       =	left_shift(left)
					__lowerCAmelCase	:       int						       =	left_shift(right)
					__lowerCAmelCase	:       Any						       =	left_shift(left)
					__lowerCAmelCase	:       List[str]						       =	left_shift(right)
					__lowerCAmelCase	:       Optional[Any]						       =	apply_table(left + right, pa_table)

					# encryption
					__lowerCAmelCase	:       int						       =	apply_table(message, IP)
					__lowerCAmelCase	:       Dict						       =	function(expansion, sa, sa, keya, temp)
					__lowerCAmelCase	:       Dict						       =	temp[4:] + temp[:4]
					__lowerCAmelCase	:       Dict						       =	function(expansion, sa, sa, keya, temp)
					__lowerCAmelCase	:       Union[str, Any]						       =	apply_table(temp, IP_inv)
					print("Cipher text is:", CT)

					# decryption
					__lowerCAmelCase	:       Optional[Any]						       =	apply_table(CT, IP)
					__lowerCAmelCase	:       Union[str, Any]						       =	function(expansion, sa, sa, keya, temp)
					__lowerCAmelCase	:       str						       =	temp[4:] + temp[:4]
					__lowerCAmelCase	:       Tuple						       =	function(expansion, sa, sa, keya, temp)
					__lowerCAmelCase	:       Tuple						       =	apply_table(temp, IP_inv)
					print("Plain text after decypting is:", PT)

'''simple docstring'''


def       lowerCAmelCase					(		UpperCamelCase__				:   Tuple       ):


	"""simple docstring"""
	# if the collection is empty, returns empty
	if collection == []:
		return []

	# get some information about the collection
	__UpperCAmelCase							=			len(UpperCamelCase__       )
	__UpperCAmelCase							=			max(UpperCamelCase__       )
	__UpperCAmelCase							=			min(UpperCamelCase__       )

	# create the counting array
	__UpperCAmelCase							=			coll_max + 1 - coll_min
	__UpperCAmelCase							=			[0] * counting_arr_length

	# count how much a number appears in the collection
	for number in collection:
		counting_arr[number - coll_min] += 1

	# sum each position with it's predecessors. now, counting_arr[i] tells
	# us how many elements <= i has in the collection
	for i in range(1    ,					UpperCamelCase__       ):
		__UpperCAmelCase							=			counting_arr[i] + counting_arr[i - 1]

	# create the output collection
	__UpperCAmelCase							=			[0] * coll_len

	# place the elements in the output, respecting the original order (stable
	# sort) from end to begin, updating counting_arr
	for i in reversed(range(0    ,					UpperCamelCase__       )       ):
		__UpperCAmelCase							=			collection[i]
		counting_arr[collection[i] - coll_min] -= 1

	return ordered





def       lowerCAmelCase					(		UpperCamelCase__				:   Any       ):


	"""simple docstring"""
	return "".join([chr(UpperCamelCase__       ) for i in counting_sort([ord(UpperCamelCase__       ) for c in string]       )]       )


if __name__ == "__main__":
					# Test string sort
					assert counting_sort_string("thisisthestring") == "eghhiiinrsssttt"

					__lowerCAmelCase	:       str						       =	input("Enter numbers separated by a comma:\n").strip()
					__lowerCAmelCase	:       List[Any]						       =	[int(item) for item in user_input.split(",")]
					print(counting_sort(unsorted))
