






"""simple docstring"""


from __future__ import annotations




def 				a      (     UpperCamelCase_							:				List[Any]     ,	UpperCamelCase_							:				int		)  ->		Union[str, Any]:
 __A	:       Any       =	[None] * (len(lowercase_		) + len(lowercase_		))

 __A	:       str       =	0  # pointer to current index for left Half
 __A	:       Optional[Any]       =	0  # pointer to current index for the right Half
 __A	:       Optional[Any]       =	0  # pointer to current index for the sorted array Half

 while pointera < len(lowercase_		) and pointera < len(lowercase_		):
  if left_half[pointera] < right_half[pointera]:
   __A	:       Optional[Any]       =	left_half[pointera]
   pointera += 1
   index += 1
  else:
   __A	:       Tuple       =	right_half[pointera]
   pointera += 1
   index += 1
 while pointera < len(lowercase_		):
  __A	:       int       =	left_half[pointera]
  pointera += 1
  index += 1

 while pointera < len(lowercase_		):
  __A	:       Optional[Any]       =	right_half[pointera]
  pointera += 1
  index += 1

 return sorted_array




def 				a      (     UpperCamelCase_							:				Any		)  ->		Any:







 if len(lowercase_		) <= 1:
  return array
 # the actual formula to calculate the middle element = left + (right - left) // 2
 # this avoids integer overflow in case of large N
 __A	:       Union[str, Any]       =	0 + (len(lowercase_		) - 0) // 2

 # Split the array into halves till the array length becomes equal to One
 # merge the arrays of single length returned by mergeSort function and
 # pass them into the merge arrays function which merges the array
 __A	:       Any       =	array[:middle]
 __A	:       Tuple       =	array[middle:]

 return merge(merge_sort(lowercase_		)     ,	merge_sort(lowercase_		)		)


if __name__ == "__main__":
   import doctest

   doctest.testmod()













"""simple docstring"""


from string import ascii_uppercase




def 				a (     UpperCamelCase_							:				str     ,	UpperCamelCase_							:				str     ,	UpperCamelCase_							:				bool = False     ,	UpperCamelCase_							:				str = ascii_uppercase		)  ->		str:
 __A	:       List[str]       =	keyword.upper()
 __A	:       str       =	plaintext.upper()
 __A	:       int       =	set(UpperCamelCase_		)

 # create a list of unique characters in the keyword - their order matters
 # it determines how we will map plaintext characters to the ciphertext
 __A	:       int       =	[]
 for char in keyword:
  if char in alphabet_set and char not in unique_chars:
   unique_chars.append(UpperCamelCase_		)
    # the number of those unique characters will determine the number of rows
 __A	:       Any       =	len(UpperCamelCase_		)

 # create a shifted version of the alphabet
 __A	:       str       =	unique_chars + [
     char for char in alphabet if char not in unique_chars
 ]

 # create a modified alphabet by splitting the shifted alphabet into rows
 __A	:       int       =	[
     shifted_alphabet[k : k + num_unique_chars_in_keyword]
     for k in range(0     ,	2_6     ,	UpperCamelCase_		)
 ]

 # map the alphabet characters to the modified alphabet characters
 # going 'vertically' through the modified alphabet - consider columns first
 __A	:       Any       =	{}
 __A	:       Union[str, Any]       =	0
 for column in range(UpperCamelCase_		):
  for row in modified_alphabet:
   # if current row (the last one) is too short, break out of loop
   if len(UpperCamelCase_		) <= column:
    break

   # map current letter to letter in modified alphabet
   __A	:       str       =	row[column]
   letter_index += 1

 if verbose:
  print(UpperCamelCase_		)
 # create the encrypted text by mapping the plaintext to the modified alphabet
 return "".join(mapping[char] if char in mapping else char for char in plaintext		)


if __name__ == "__main__":
   # example use
   print(mixed_keyword("""college""", """UNIVERSITY"""))





