





'''simple docstring'''




import collections
import os
from typing import List, Optional, Tuple

from transformers.utils import is_jieba_available, requires_backends


if is_jieba_available():
							import jieba

from ...tokenization_utils import PreTrainedTokenizer
from ...utils import logging


__UpperCAmelCase            =       logging.get_logger(__name__)

__UpperCAmelCase            =       {"""vocab_file""": """vocab.txt"""}

__UpperCAmelCase            =       {
    """vocab_file""": {
        """openbmb/cpm-ant-10b""": """https://huggingface.co/openbmb/cpm-ant-10b/blob/main/vocab.txt""",
    },
}

__UpperCAmelCase            =       {
    """openbmb/cpm-ant-10b""": 1024,
}



def 		__A		(  lowerCamelCase_	):


		"""simple docstring"""



		SCREAMING_SNAKE_CASE :				int		=			collections.OrderedDict()
		with open(lowerCamelCase_			,			"""r"""			,			encoding="""utf-8"""	) as reader:
				SCREAMING_SNAKE_CASE :				Any		=			reader.readlines()
		for index, token in enumerate(lowerCamelCase_	):
				SCREAMING_SNAKE_CASE :				Optional[Any]		=			token.rstrip("""\n"""	)
				SCREAMING_SNAKE_CASE :				Optional[Any]		=			index
		return vocab




class      UpperCamelCase__					(					lowercase_			):




					"""simple docstring"""


					def __init__(						self				:			Union[str, Any]      ,						lowerCamelCase_				:			List[Any]      ,						lowerCamelCase_				:			Tuple="<unk>"      ,						lowerCamelCase_				:			str=2_00						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				Any		=			vocab
							SCREAMING_SNAKE_CASE :				List[str]		=			unk_token
							SCREAMING_SNAKE_CASE :				Optional[Any]		=			max_input_chars_per_word



					def lowerCamelCase_			(						self				:			int      ,						lowerCamelCase_				:			List[str]						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				Union[str, Any]		=			list(lowerCamelCase_						)
							if len(lowerCamelCase_						) > self.max_input_chars_per_word:
									return [self.unk_token]

							SCREAMING_SNAKE_CASE :				Any		=			0
							SCREAMING_SNAKE_CASE :				Optional[Any]		=			[]
							while start < len(lowerCamelCase_						):
									SCREAMING_SNAKE_CASE :				Any		=			len(lowerCamelCase_						)
									SCREAMING_SNAKE_CASE :				Optional[int]		=			None
									while start < end:
											SCREAMING_SNAKE_CASE :				List[str]		=			"""""".join(chars[start:end]						)
											if substr in self.vocab:
													SCREAMING_SNAKE_CASE :				Union[str, Any]		=			substr
													break
											end -= 1
									if cur_substr is None:
											sub_tokens.append(self.unk_token						)
											start += 1
									else:
											sub_tokens.append(lowerCamelCase_						)
											SCREAMING_SNAKE_CASE :				Optional[Any]		=			end

							return sub_tokens







class      UpperCamelCase__					(					lowercase_			):




					"""simple docstring"""
					SCREAMING_SNAKE_CASE__				=	VOCAB_FILES_NAMES
					SCREAMING_SNAKE_CASE__				=	PRETRAINED_VOCAB_FILES_MAP
					SCREAMING_SNAKE_CASE__				=	PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
					SCREAMING_SNAKE_CASE__				=	['''input_ids''', '''attention_mask''']
					SCREAMING_SNAKE_CASE__				=	False


					def __init__(						self				:			Union[str, Any]      ,						lowerCamelCase_				:			List[str]      ,						lowerCamelCase_				:			str="<d>"      ,						lowerCamelCase_				:			Dict="</d>"      ,						lowerCamelCase_				:			Tuple="<s>"      ,						lowerCamelCase_				:			Optional[int]="</s>"      ,						lowerCamelCase_				:			int="<pad>"      ,						lowerCamelCase_				:			Union[str, Any]="<unk>"      ,						lowerCamelCase_				:			Dict="</n>"      ,						lowerCamelCase_				:			Dict="</_>"      ,						lowerCamelCase_				:			Dict="left"      ,						**lowerCamelCase_				:			int      ,						):

							'''simple docstring'''



							requires_backends(self      ,						["""jieba"""]						)
							super().__init__(
							    bod_token=lowerCamelCase_      ,						eod_token=lowerCamelCase_      ,						bos_token=lowerCamelCase_      ,						eos_token=lowerCamelCase_      ,						pad_token=lowerCamelCase_      ,						unk_token=lowerCamelCase_      ,						line_token=lowerCamelCase_      ,						space_token=lowerCamelCase_      ,						padding_side=lowerCamelCase_      ,						**lowerCamelCase_      ,						)
							SCREAMING_SNAKE_CASE :				int		=			bod_token
							SCREAMING_SNAKE_CASE :				str		=			eod_token
							SCREAMING_SNAKE_CASE :				Dict		=			load_vocab(lowerCamelCase_						)
							SCREAMING_SNAKE_CASE :				Union[str, Any]		=			self.encoder[space_token]
							SCREAMING_SNAKE_CASE :				List[Any]		=			self.encoder[line_token]

							del self.encoder[space_token]
							del self.encoder[line_token]

							SCREAMING_SNAKE_CASE :				Tuple		=			collections.OrderedDict(sorted(self.encoder.items()      ,						key=lambda lowerCamelCase_						: x[1]						)						)
							SCREAMING_SNAKE_CASE :				List[Any]		=			{v: k for k, v in self.encoder.items()}

							SCREAMING_SNAKE_CASE :				str		=			WordpieceTokenizer(vocab=self.encoder      ,						unk_token=self.unk_token						)


					@property
					def lowerCamelCase_			(						self				:			List[Any]						):

							'''simple docstring'''



							return self.encoder[self.bod_token]


					@property
					def lowerCamelCase_			(						self				:			int						):

							'''simple docstring'''



							return self.encoder[self.eod_token]


					@property
					def lowerCamelCase_			(						self				:			Optional[Any]						):

							'''simple docstring'''



							return self.encoder["\n"]


					@property
					def lowerCamelCase_			(						self				:			List[Any]						):

							'''simple docstring'''



							return len(self.encoder						)


					def lowerCamelCase_			(						self				:			Union[str, Any]						):

							'''simple docstring'''



							return dict(self.encoder      ,						**self.added_tokens_encoder						)


					def lowerCamelCase_			(						self				:			Tuple      ,						lowerCamelCase_				:			Optional[int]						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				List[str]		=			[]
							for x in jieba.cut(lowerCamelCase_      ,						cut_all=lowerCamelCase_						):
									output_tokens.extend(self.wordpiece_tokenizer.tokenize(lowerCamelCase_						)						)
							return output_tokens


					def lowerCamelCase_			(						self				:			Dict      ,						lowerCamelCase_				:			Tuple      ,						**lowerCamelCase_				:			Dict						):

							'''simple docstring'''



							SCREAMING_SNAKE_CASE :				Union[str, Any]		=			[i for i in token_ids if i >= 0]
							SCREAMING_SNAKE_CASE :				Any		=			[
							    x for x in token_ids if x != self.pad_token_id and x != self.eos_token_id and x != self.bos_token_id
							]
							return super()._decode(lowerCamelCase_      ,						**lowerCamelCase_						)


					def lowerCamelCase_			(						self				:			Tuple      ,						lowerCamelCase_				:			List[str]						):

							'''simple docstring'''



							return token in self.encoder


					def lowerCamelCase_			(						self				:			int      ,						lowerCamelCase_				:			List[str]						):

							'''simple docstring'''



							return "".join(lowerCamelCase_						)


					def lowerCamelCase_			(						self				:			List[Any]      ,						lowerCamelCase_				:			Dict						):

							'''simple docstring'''



							return self.encoder.get(lowerCamelCase_      ,						self.encoder.get(self.unk_token						)						)


					def lowerCamelCase_			(						self				:			Any      ,						lowerCamelCase_				:			Union[str, Any]						):

							'''simple docstring'''



							return self.decoder.get(lowerCamelCase_      ,						self.unk_token						)


					def lowerCamelCase_			(						self				:			List[str]      ,						lowerCamelCase_				:			str      ,						lowerCamelCase_				:			Optional[str] = None						):

							'''simple docstring'''



							if os.path.isdir(lowerCamelCase_						):
									SCREAMING_SNAKE_CASE :				Any		=			os.path.join(
									    lowerCamelCase_      ,						(filename_prefix + """-""" if filename_prefix else """""") + VOCAB_FILES_NAMES["""vocab_file"""]						)
							else:
									SCREAMING_SNAKE_CASE :				Dict		=			(filename_prefix + """-""" if filename_prefix else """""") + save_directory
							SCREAMING_SNAKE_CASE :				str		=			0
							if " " in self.encoder:
									SCREAMING_SNAKE_CASE :				Optional[Any]		=			self.encoder[""" """]
									del self.encoder[" "]
							if "\n" in self.encoder:
									SCREAMING_SNAKE_CASE :				Optional[Any]		=			self.encoder["""\n"""]
									del self.encoder["\n"]
							SCREAMING_SNAKE_CASE :				Any		=			collections.OrderedDict(sorted(self.encoder.items()      ,						key=lambda lowerCamelCase_						: x[1]						)						)
							with open(lowerCamelCase_      ,						"""w"""      ,						encoding="""utf-8"""						) as writer:
									for token, token_index in self.encoder.items():
											if index != token_index:
													logger.warning(
													    f'''Saving vocabulary to {vocab_file}: vocabulary indices are not consecutive.'''
													    """ Please check that the vocabulary is not corrupted!"""						)
													SCREAMING_SNAKE_CASE :				Any		=			token_index
											writer.write(token + """\n"""						)
											index += 1
							return (vocab_file,)


					def lowerCamelCase_			(						self				:			str      ,						lowerCamelCase_				:			List[int]      ,						lowerCamelCase_				:			List[int] = None						):

							'''simple docstring'''



							if token_ids_a is None:
									return [self.bos_token_id] + token_ids_a
							return [self.bos_token_id] + token_ids_a + [self.bos_token_id] + token_ids_a



					def lowerCamelCase_			(						self				:			Optional[Any]      ,						lowerCamelCase_				:			List[int]      ,						lowerCamelCase_				:			Optional[List[int]] = None      ,						lowerCamelCase_				:			bool = False						):

							'''simple docstring'''



							if already_has_special_tokens:
									return super().get_special_tokens_mask(
									    token_ids_a=lowerCamelCase_      ,						token_ids_a=lowerCamelCase_      ,						already_has_special_tokens=lowerCamelCase_						)

							if token_ids_a is not None:
									return [1] + ([0] * len(lowerCamelCase_						)) + [1] + ([0] * len(lowerCamelCase_						))
							return [1] + ([0] * len(lowerCamelCase_						))










'''simple docstring'''




def 		__A		(  lowerCamelCase_			,			lowerCamelCase_	):


		"""simple docstring"""



		SCREAMING_SNAKE_CASE :				str		=			1  # To kept the Calculated Value
		# Since C(n, k) = C(n, n-k)
		if k > (n - k):
				SCREAMING_SNAKE_CASE :				Dict		=			n - k
		# Calculate C(n,k)
		for i in range(lowerCamelCase_	):
				result *= n - i
				result //= i + 1
		return result



def 		__A		(  lowerCamelCase_	):


		"""simple docstring"""



		return binomial_coefficient(2 * node_count			,			lowerCamelCase_	) // (node_count + 1)



def 		__A		(  lowerCamelCase_	):


		"""simple docstring"""



		if n < 0:
				raise ValueError("""factorial() not defined for negative values"""	)
		SCREAMING_SNAKE_CASE :				Dict		=			1
		for i in range(1			,			n + 1	):
				result *= i
		return result



def 		__A		(  lowerCamelCase_	):


		"""simple docstring"""



		return catalan_number(lowerCamelCase_	) * factorial(lowerCamelCase_	)


if __name__ == "__main__":
							__UpperCAmelCase            =       int(input("""Enter the number of nodes: """).strip() or 0)
							if node_count <= 0:
														raise ValueError("""We need some nodes to work with.""")
							print(
							    f'''Given {node_count} nodes, there are {binary_tree_count(node_count)} '''
							    f'''binary trees and {catalan_number(node_count)} binary search trees.'''
							)



