

'''simple docstring'''





import os
import string
import sys


A_	= 1 << 8

A_	= {
    "tab": ord("\t"),
    "newline": ord("\r"),
    "esc": 27,
    "up": 65 + ARROW_KEY_FLAG,
    "down": 66 + ARROW_KEY_FLAG,
    "right": 67 + ARROW_KEY_FLAG,
    "left": 68 + ARROW_KEY_FLAG,
    "mod_int": 91,
    "undefined": sys.maxsize,
    "interrupt": 3,
    "insert": 50,
    "delete": 51,
    "pg_up": 53,
    "pg_down": 54,
}

A_	= KEYMAP["up"]
A_	= KEYMAP["left"]

if sys.platform == "win32":
				A_	= []
				A_	= {
				    B"\xe0H": KEYMAP["up"] - ARROW_KEY_FLAG,
				    B"\x00H": KEYMAP["up"] - ARROW_KEY_FLAG,
				    B"\xe0P": KEYMAP["down"] - ARROW_KEY_FLAG,
				    B"\x00P": KEYMAP["down"] - ARROW_KEY_FLAG,
				    B"\xe0M": KEYMAP["right"] - ARROW_KEY_FLAG,
				    B"\x00M": KEYMAP["right"] - ARROW_KEY_FLAG,
				    B"\xe0K": KEYMAP["left"] - ARROW_KEY_FLAG,
				    B"\x00K": KEYMAP["left"] - ARROW_KEY_FLAG,
				}

for i in range(10):
				A_	= ord(str(i))







def   _UpperCamelCase	(		)       ->			int:
					if os.name == "nt":
										import msvcrt

										lowerCamelCase_  				=      'mbcs'
										# Flush the keyboard buffer
										while msvcrt.kbhit():
															msvcrt.getch()
										if len(__UpperCamelCase	) == 0:
															# Read the keystroke
															lowerCamelCase_  				=      msvcrt.getch()

															# If it is a prefix char, get second part
															if ch in (b"\x00", b"\xe0"):
																				lowerCamelCase_  				=      ch + msvcrt.getch()
																				# Translate actual Win chars to bullet char types
																				try:
																									lowerCamelCase_  				=      chr(WIN_KEYMAP[cha]	)
																									WIN_CH_BUFFER.append(chr(KEYMAP['mod_int']	)	)
																									WIN_CH_BUFFER.append(__UpperCamelCase	)
																									if ord(__UpperCamelCase	) in (
																									    KEYMAP["insert"] - 1 << 9,
																									    KEYMAP["delete"] - 1 << 9,
																									    KEYMAP["pg_up"] - 1 << 9,
																									    KEYMAP["pg_down"] - 1 << 9,
																									):
																														WIN_CH_BUFFER.append(chr(1_26	)	)
																									lowerCamelCase_  				=      chr(KEYMAP['esc']	)
																				except KeyError:
																									lowerCamelCase_  				=      cha[1]
															else:
																				lowerCamelCase_  				=      ch.decode(__UpperCamelCase	)
										else:
															lowerCamelCase_  				=      WIN_CH_BUFFER.pop(0	)
					elif os.name == "posix":
										import termios
										import tty

										lowerCamelCase_  				=      sys.stdin.fileno()
										lowerCamelCase_  				=      termios.tcgetattr(__UpperCamelCase	)
										try:
															tty.setraw(__UpperCamelCase	)
															lowerCamelCase_  				=      sys.stdin.read(1	)
										finally:
															termios.tcsetattr(__UpperCamelCase    ,termios.TCSADRAIN    ,__UpperCamelCase	)
					return ch







def   _UpperCamelCase	(		)       ->			str:
					lowerCamelCase_  				=      get_raw_chars()
					if ord(__UpperCamelCase	) in [KEYMAP["interrupt"], KEYMAP["newline"]]:
										return char

					elif ord(__UpperCamelCase	) == KEYMAP["esc"]:
										lowerCamelCase_  				=      get_raw_chars()
										if ord(__UpperCamelCase	) == KEYMAP["mod_int"]:
															lowerCamelCase_  				=      get_raw_chars()
															if ord(__UpperCamelCase	) >= KEYMAP["arrow_begin"] - ARROW_KEY_FLAG and ord(__UpperCamelCase	) <= KEYMAP["arrow_end"] - ARROW_KEY_FLAG:
																				return chr(ord(__UpperCamelCase	) + ARROW_KEY_FLAG	)
															else:
																				return KEYMAP["undefined"]
										else:
															return get_raw_chars()

					else:
										if char in string.printable:
															return char
										else:
															return KEYMAP["undefined"]











'''simple docstring'''



__UpperCamelCase   :							List[Any]         =   """ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"""



def  __UpperCAmelCase						(					SCREAMING_SNAKE_CASE__:						bytes     )	->      bytes:

   """simple docstring"""
   # Make sure the supplied data is a bytes-like object
   if not isinstance(SCREAMING_SNAKE_CASE__,       SCREAMING_SNAKE_CASE__     ):
      __a					  =     f"""a bytes-like object is required, not '{data.__class__.__name__}'"""
      raise TypeError(SCREAMING_SNAKE_CASE__     )

   __a					  =     ''.join(bin(SCREAMING_SNAKE_CASE__     )[2:].zfill(8     ) for byte in data     )

   __a					  =     len(SCREAMING_SNAKE_CASE__     ) % 6 != 0

   if padding_needed:
      # The padding that will be added later
      __a					  =     b'=' * ((6 - len(SCREAMING_SNAKE_CASE__     ) % 6) // 2)

      # Append binary_stream with arbitrary binary digits (0's by default) to make its
      # length a multiple of 6.
      binary_stream += "0" * (6 - len(SCREAMING_SNAKE_CASE__     ) % 6)
   else:
      __a					  =     b''

   # Encode every 6 binary digits to their corresponding Base64 character
   return (
       "".join(
           B64_CHARSET[int(binary_stream[index : index + 6],       2     )]
           for index in range(0,       len(SCREAMING_SNAKE_CASE__     ),       6     )     ).encode()
       + padding
   )



def  __UpperCAmelCase						(					SCREAMING_SNAKE_CASE__:						str     )	->      bytes:

   """simple docstring"""
   # Make sure encoded_data is either a string or a bytes-like object
   if not isinstance(SCREAMING_SNAKE_CASE__,       SCREAMING_SNAKE_CASE__     ) and not isinstance(SCREAMING_SNAKE_CASE__,       SCREAMING_SNAKE_CASE__     ):
      __a					  =     (
          'argument should be a bytes-like object or ASCII string, '
          f"""not '{encoded_data.__class__.__name__}'"""
      )
      raise TypeError(SCREAMING_SNAKE_CASE__     )

   # In case encoded_data is a bytes-like object, make sure it contains only
   # ASCII characters so we convert it to a string object
   if isinstance(SCREAMING_SNAKE_CASE__,       SCREAMING_SNAKE_CASE__     ):
      try:
         __a					  =     encoded_data.decode('utf-8'     )
      except UnicodeDecodeError:
         raise ValueError('base64 encoded data should only contain ASCII characters'     )

   __a					  =     encoded_data.count('='     )

   # Check if the encoded string contains non base64 characters
   if padding:
      assert all(
          char in B64_CHARSET for char in encoded_data[:-padding]     ), "Invalid base64 character(s) found."
   else:
      assert all(
          char in B64_CHARSET for char in encoded_data     ), "Invalid base64 character(s) found."

   # Check the padding
   assert len(SCREAMING_SNAKE_CASE__     ) % 4 == 0 and padding < 3, "Incorrect padding"

   if padding:
      # Remove padding if there is one
      __a					  =     encoded_data[:-padding]

      __a					  =     ''.join(
          bin(B64_CHARSET.index(SCREAMING_SNAKE_CASE__     )     )[2:].zfill(6     ) for char in encoded_data     )[: -padding * 2]
   else:
      __a					  =     ''.join(
          bin(B64_CHARSET.index(SCREAMING_SNAKE_CASE__     )     )[2:].zfill(6     ) for char in encoded_data     )

   __a					  =     [
       int(binary_stream[index : index + 8],       2     )
       for index in range(0,       len(SCREAMING_SNAKE_CASE__     ),       8     )
   ]

   return bytes(SCREAMING_SNAKE_CASE__     )


if __name__ == "__main__":
 import doctest

 doctest.testmod()