




import itertools
import string
from collections.abc import Generator, Iterable





def 				A__ (snake_case   :		Iterable[str]		,	snake_case   :		int				)     ->						Generator[tuple[str, ...], None, None]:
					__UpperCamelCase					:	Optional[Any]             =      iter(snake_case				)
					while True:
										__UpperCamelCase					:	Union[str, Any]             =      tuple(itertools.islice(snake_case		,	snake_case				)				)
										if not chunk:
															return
										yield chunk





def 				A__ (snake_case   :		str				)     ->						str:
					__UpperCamelCase					:	str             =      """""".join([c.upper() for c in dirty if c in string.ascii_letters]				)
					__UpperCamelCase					:	List[str]             =      """"""

					if len(snake_case				) < 2:
										return dirty

					for i in range(len(snake_case				) - 1				):
										clean += dirty[i]

										if dirty[i] == dirty[i + 1]:
															clean += "X"

					clean += dirty[-1]

					if len(snake_case				) & 1:
										clean += "X"

					return clean





def 				A__ (snake_case   :		str				)     ->						list[str]:
					# I and J are used interchangeably to allow
					# us to use a 5x5 table (25 letters)
					__UpperCamelCase					:	Tuple             =      """ABCDEFGHIKLMNOPQRSTUVWXYZ"""
					# we're using a list instead of a '2d' array because it makes the math
					# for setting up the table and doing the actual encoding/decoding simpler
					__UpperCamelCase					:	List[Any]             =      []

					# copy key chars into the table if they are in `alphabet` ignoring duplicates
					for char in key.upper():
										if char not in table and char in alphabet:
															table.append(snake_case				)

    # fill the rest of the table in with the remaining alphabet chars
					for char in alphabet:
										if char not in table:
															table.append(snake_case				)

					return table





def 				A__ (snake_case   :		str		,	snake_case   :		str				)     ->						str:
					__UpperCamelCase					:	int             =      generate_table(snake_case				)
					__UpperCamelCase					:	Optional[int]             =      prepare_input(snake_case				)
					__UpperCamelCase					:	int             =      """"""

					# https://en.wikipedia.org/wiki/Playfair_cipher#Description
					for chara, chara in chunker(snake_case		,	2				):
										__UpperCamelCase      ,			__UpperCamelCase					:	Tuple             =      divmod(table.index(snake_case				)		,	5				)
										__UpperCamelCase      ,			__UpperCamelCase					:	int             =      divmod(table.index(snake_case				)		,	5				)

										if rowa == rowa:
															ciphertext += table[rowa * 5 + (cola + 1) % 5]
															ciphertext += table[rowa * 5 + (cola + 1) % 5]
										elif cola == cola:
															ciphertext += table[((rowa + 1) % 5) * 5 + cola]
															ciphertext += table[((rowa + 1) % 5) * 5 + cola]
										else:  # rectangle
															ciphertext += table[rowa * 5 + cola]
															ciphertext += table[rowa * 5 + cola]

					return ciphertext







def 				A__ (snake_case   :		str		,	snake_case   :		str				)     ->						str:
					__UpperCamelCase					:	List[str]             =      generate_table(snake_case				)
					__UpperCamelCase					:	int             =      """"""

					# https://en.wikipedia.org/wiki/Playfair_cipher#Description
					for chara, chara in chunker(snake_case		,	2				):
										__UpperCamelCase      ,			__UpperCamelCase					:	Optional[Any]             =      divmod(table.index(snake_case				)		,	5				)
										__UpperCamelCase      ,			__UpperCamelCase					:	int             =      divmod(table.index(snake_case				)		,	5				)

										if rowa == rowa:
															plaintext += table[rowa * 5 + (cola - 1) % 5]
															plaintext += table[rowa * 5 + (cola - 1) % 5]
										elif cola == cola:
															plaintext += table[((rowa - 1) % 5) * 5 + cola]
															plaintext += table[((rowa - 1) % 5) * 5 + cola]
										else:  # rectangle
															plaintext += table[rowa * 5 + cola]
															plaintext += table[rowa * 5 + cola]

					return plaintext












import logging
import os
from logging import (
    CRITICAL,  # NOQA
    DEBUG,  # NOQA
    ERROR,  # NOQA
    FATAL,  # NOQA
    INFO,  # NOQA
    NOTSET,  # NOQA
    WARN,  # NOQA
    WARNING,  # NOQA
)
from typing import Optional

from tqdm import auto as tqdm_lib


a__		     =     {
    '''debug''': logging.DEBUG,
    '''info''': logging.INFO,
    '''warning''': logging.WARNING,
    '''error''': logging.ERROR,
    '''critical''': logging.CRITICAL,
}

a__		     =     logging.WARNING





def 				A__ ()     ->						Any:
					__UpperCamelCase					:	Union[str, Any]             =      os.getenv("""DATASETS_VERBOSITY"""		,	snake_case				)
					if env_level_str:
										if env_level_str in log_levels:
															return log_levels[env_level_str]
										else:
															logging.getLogger().warning(
															    F'''Unknown option DATASETS_VERBOSITY={env_level_str}, '''
															    F'''has to be one of: { ", ".join(log_levels.keys()				) }'''				)
					return _default_log_level





def 				A__ ()     ->						str:
					return __name__.split("""."""				)[0]





def 				A__ ()     ->						logging.Logger:
					return logging.getLogger(_get_library_name()				)





def 				A__ ()     ->						None:
					# Apply our default configuration to the library root logger.
					__UpperCamelCase					:	Any             =      _get_library_root_logger()
					library_root_logger.setLevel(_get_default_logging_level()				)





def 				A__ ()     ->						None:
					__UpperCamelCase					:	List[Any]             =      _get_library_root_logger()
					library_root_logger.setLevel(logging.NOTSET				)





def 				A__ (snake_case   :		Optional[str] = None				)     ->						logging.Logger:
					if name is None:
										__UpperCamelCase					:	Optional[int]             =      _get_library_name()
					return logging.getLogger(snake_case				)





def 				A__ ()     ->						int:
					return _get_library_root_logger().getEffectiveLevel()





def 				A__ (snake_case   :		int				)     ->						None:
					_get_library_root_logger().setLevel(snake_case				)





def 				A__ ()     ->						Dict:
					return set_verbosity(snake_case				)





def 				A__ ()     ->						Any:
					return set_verbosity(snake_case				)





def 				A__ ()     ->						Dict:
					return set_verbosity(snake_case				)





def 				A__ ()     ->						str:
					return set_verbosity(snake_case				)





def 				A__ ()     ->						None:
					__UpperCamelCase					:	str             =      False





def 				A__ ()     ->						None:
					__UpperCamelCase					:	List[str]             =      True


# Configure the library root logger at the module level (singleton-like)
_configure_library_root_logger()


class    SCREAMING_SNAKE_CASE_				:



	"""simple docstring"""


	def __init__(					self		:						Optional[int]					,     *lowerCAmelCase		:						str					,     **lowerCAmelCase		:						List[str]	)	->       Union[str, Any]:  # pylint: disable=unused-argument







						"""simple docstring"""







						__UpperCamelCase					:	List[str]             =      args[0] if args else None






	def __iter__(					self		:						List[Any]	)	->       List[Any]:







						"""simple docstring"""







						return iter(self._iterator	)






	def __getattr__(					self		:						int					,     lowerCAmelCase		:						List[str]	)	->       Dict:







						"""simple docstring"""







						def empty_fn(*lowerCAmelCase		:						List[Any]					,     **lowerCAmelCase		:						Dict	):  # pylint: disable=unused-argument
											return

						return empty_fn






	def __enter__(					self		:						Tuple	)	->       Any:







						"""simple docstring"""







						return self






	def __exit__(					self		:						str					,     lowerCAmelCase		:						Dict					,     lowerCAmelCase		:						Dict					,     lowerCAmelCase		:						List[str]	)	->       Tuple:







						"""simple docstring"""







						return






a__		     =     True


class    SCREAMING_SNAKE_CASE_				:



	"""simple docstring"""


	def __call__(					self		:						str					,     *lowerCAmelCase		:						List[Any]					,     lowerCAmelCase		:						Dict=False					,     **lowerCAmelCase		:						Tuple	)	->       Optional[Any]:







						"""simple docstring"""







						if _tqdm_active and not disable:
											return tqdm_lib.tqdm(*lowerCAmelCase					,     **lowerCAmelCase	)
						else:
											return EmptyTqdm(*lowerCAmelCase					,     **lowerCAmelCase	)






	def 					lowerCamelCase__     (					self		:						Any					,     *lowerCAmelCase		:						List[str]					,     **lowerCAmelCase		:						str	)	->       Dict:







						"""simple docstring"""







						__UpperCamelCase					:	Any             =      None
						if _tqdm_active:
											return tqdm_lib.tqdm.set_lock(*lowerCAmelCase					,     **lowerCAmelCase	)






	def 					lowerCamelCase__     (					self		:						Dict	)	->       Union[str, Any]:







						"""simple docstring"""







						if _tqdm_active:
											return tqdm_lib.tqdm.get_lock()






a__		     =     _tqdm_cls()





def 				A__ ()     ->						bool:
					global _tqdm_active
					return bool(_tqdm_active				)





def 				A__ ()     ->						List[str]:
					global _tqdm_active
					__UpperCamelCase					:	Tuple             =      True







def 				A__ ()     ->						int:
					global _tqdm_active
					__UpperCamelCase					:	Any             =      False






