






"""simple docstring"""
import json
from typing import Iterator, List, Union

from tokenizers import AddedToken, Regex, Tokenizer, decoders, normalizers, pre_tokenizers, trainers
from tokenizers.implementations.base_tokenizer import BaseTokenizer
from tokenizers.models import Unigram
from tokenizers.processors import TemplateProcessing







class      UpperCamelCase_			(__A	):





	def __init__( self   :					List[str]      ,      lowerCAmelCase_   :					str = "▁"      ,      lowerCAmelCase_   :					bool = True      ,      lowerCAmelCase_   :					Union[str, AddedToken] = "<unk>"      ,      lowerCAmelCase_   :					Union[str, AddedToken] = "</s>"      ,      lowerCAmelCase_   :					Union[str, AddedToken] = "<pad>"      ,      )		->     int:
				UpperCAmelCase_	:					Any     	=   {
				    "pad": {"id": 0, "token": pad_token},
				    "eos": {"id": 1, "token": eos_token},
				    "unk": {"id": 2, "token": unk_token},
				}

				UpperCAmelCase_	:					Optional[int]     	=   [None] * len(self.special_tokens		)
				for token_dict in self.special_tokens.values():
							UpperCAmelCase_	:					Any     	=   token_dict["token"]

				UpperCAmelCase_	:					Any     	=   Tokenizer(Unigram()		)

				UpperCAmelCase_	:					Optional[Any]     	=   normalizers.Sequence(
				    [
				        normalizers.Nmt(),
				        normalizers.NFKC(),
				        normalizers.Replace(Regex(" {2,}"		)      ,      " "		),
				        normalizers.Lowercase(),
				    ]		)
				UpperCAmelCase_	:					List[str]     	=   pre_tokenizers.Sequence(
				    [
				        pre_tokenizers.Metaspace(replacement=lowerCAmelCase_      ,      add_prefix_space=lowerCAmelCase_		),
				        pre_tokenizers.Digits(individual_digits=lowerCAmelCase_		),
				        pre_tokenizers.Punctuation(),
				    ]		)
				UpperCAmelCase_	:					Dict     	=   decoders.Metaspace(replacement=lowerCAmelCase_      ,      add_prefix_space=lowerCAmelCase_		)

				UpperCAmelCase_	:					Union[str, Any]     	=   TemplateProcessing(
				    single=f"""$A {self.special_tokens['eos']['token']}"""      ,      special_tokens=[(self.special_tokens["eos"]["token"], self.special_tokens["eos"]["id"])]      ,      )

				UpperCAmelCase_	:					int     	=   {
				    "model": "SentencePieceUnigram",
				    "replacement": replacement,
				    "add_prefix_space": add_prefix_space,
				}

				super().__init__(lowerCAmelCase_      ,      lowerCAmelCase_		)





	def 	_SCREAMING_SNAKE_CASE ( self   :					int      ,      lowerCAmelCase_   :					Union[str, List[str]]      ,      lowerCAmelCase_   :					int = 8_000      ,      lowerCAmelCase_   :					bool = True      ,      )		->     List[str]:
				UpperCAmelCase_	:					List[Any]     	=   trainers.UnigramTrainer(
				    vocab_size=lowerCAmelCase_      ,      special_tokens=self.special_tokens_list      ,      show_progress=lowerCAmelCase_      ,      )

				if isinstance(lowerCAmelCase_      ,      lowerCAmelCase_		):
							UpperCAmelCase_	:					List[Any]     	=   [files]
				self._tokenizer.train(lowerCAmelCase_      ,      trainer=lowerCAmelCase_		)

				self.add_unk_id()





	def 	_SCREAMING_SNAKE_CASE ( self   :					Dict      ,      lowerCAmelCase_   :					Union[Iterator[str], Iterator[Iterator[str]]]      ,      lowerCAmelCase_   :					int = 8_000      ,      lowerCAmelCase_   :					bool = True      ,      )		->     Any:
				UpperCAmelCase_	:					Any     	=   trainers.UnigramTrainer(
				    vocab_size=lowerCAmelCase_      ,      special_tokens=self.special_tokens_list      ,      show_progress=lowerCAmelCase_      ,      )

				self._tokenizer.train_from_iterator(lowerCAmelCase_      ,      trainer=lowerCAmelCase_		)

				self.add_unk_id()





	def 	_SCREAMING_SNAKE_CASE ( self   :					Any		)		->     Dict:
				UpperCAmelCase_	:					Tuple     	=   json.loads(self._tokenizer.to_str()		)

				UpperCAmelCase_	:					Union[str, Any]     	=   self.special_tokens["unk"]["id"]

				UpperCAmelCase_	:					Tuple     	=   Tokenizer.from_str(json.dumps(lowerCAmelCase_		)		)







"""simple docstring"""




def       a_ (	lowercase__ :int = 10**9     ):
			__lowerCamelCase          =      1
			__lowerCamelCase          =      2

			__lowerCamelCase          =      0
			__lowerCamelCase          =      0
			__lowerCamelCase          =      0
			while perimeter <= max_perimeter:
						perimeters_sum += perimeter

						prev_value += 2 * value
						value += prev_value

						__lowerCamelCase          =      2 * value + 2 if i % 2 == 0 else 2 * value - 2
						i += 1

			return perimeters_sum


if __name__ == "__main__":
					print(f"""{solution() = }""")




