'''simple docstring'''

import os
import unicodedata
from shutil import copyfile
from typing import Any, Dict, List, Optional, Tuple

import sentencepiece as spm

from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...utils import SPIECE_UNDERLINE, logging


__a:			Optional[Any]	       =       logging.get_logger(__name__)

__a:			Any	       =       {"""vocab_file""": """spiece.model"""}

__a:			int	       =       {
    """vocab_file""": {
        """xlnet-base-cased""": """https://huggingface.co/xlnet-base-cased/resolve/main/spiece.model""",
        """xlnet-large-cased""": """https://huggingface.co/xlnet-large-cased/resolve/main/spiece.model""",
    }
}

__a:			Tuple	       =       {
    """xlnet-base-cased""": None,
    """xlnet-large-cased""": None,
}

# Segments (not really needed)
__a:			Tuple	       =       0
__a:			Optional[Any]	       =       1
__a:			Tuple	       =       2
__a:			List[Any]	       =       3
__a:			List[str]	       =       4



class       UpperCAmelCase  (						__UpperCamelCase ):





       '''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 		=   "left"

       def __init__(						self     ,       __lowerCAmelCase     ,       __lowerCAmelCase=False     ,       __lowerCAmelCase=True     ,       __lowerCAmelCase=False     ,       __lowerCAmelCase="<s>"     ,       __lowerCAmelCase="</s>"     ,       __lowerCAmelCase="<unk>"     ,       __lowerCAmelCase="<sep>"     ,       __lowerCAmelCase="<pad>"     ,       __lowerCAmelCase="<cls>"     ,       __lowerCAmelCase="<mask>"     ,       __lowerCAmelCase=["<eop>", "<eod>"]     ,       __lowerCAmelCase = None     ,       **__lowerCAmelCase     ,       )  ->  Any:
        # Mask token behave like a normal word, i.e. include the space before it
        lowercase__    :   Tuple						= AddedToken(_lowerCAmelCase     ,       lstrip=_lowerCAmelCase     ,       rstrip=_lowerCAmelCase			) if isinstance(_lowerCAmelCase     ,       _lowerCAmelCase			) else mask_token

        lowercase__    :   Optional[Any]						= {} if sp_model_kwargs is None else sp_model_kwargs

        super().__init__(
            do_lower_case=_lowerCAmelCase     ,       remove_space=_lowerCAmelCase     ,       keep_accents=_lowerCAmelCase     ,       bos_token=_lowerCAmelCase     ,       eos_token=_lowerCAmelCase     ,       unk_token=_lowerCAmelCase     ,       sep_token=_lowerCAmelCase     ,       pad_token=_lowerCAmelCase     ,       cls_token=_lowerCAmelCase     ,       mask_token=_lowerCAmelCase     ,       additional_special_tokens=_lowerCAmelCase     ,       sp_model_kwargs=self.sp_model_kwargs     ,       **_lowerCAmelCase     ,       )

        lowercase__    :   Union[str, Any]						= 3

        lowercase__    :   Optional[Any]						= do_lower_case
        lowercase__    :   Optional[int]						= remove_space
        lowercase__    :   Any						= keep_accents
        lowercase__    :   List[Any]						= vocab_file

        lowercase__    :   Optional[Any]						= spm.SentencePieceProcessor(**self.sp_model_kwargs			)
        self.sp_model.Load(_lowerCAmelCase			)

       @property
       def _lowerCAmelCase(						self			)  ->  List[Any]:
        return len(self.sp_model			)

       def _lowerCAmelCase(						self			)  ->  int:
        lowercase__    :   str						= {self.convert_ids_to_tokens(_lowerCAmelCase			): i for i in range(self.vocab_size			)}
        vocab.update(self.added_tokens_encoder			)
        return vocab

       def __getstate__(						self			)  ->  int:
        lowercase__    :   Optional[Any]						= self.__dict__.copy()
        lowercase__    :   Tuple						= None
        return state

       def __setstate__(						self     ,       __lowerCAmelCase			)  ->  Tuple:
        lowercase__    :   Dict						= d

        # for backward compatibility
        if not hasattr(self     ,       '''sp_model_kwargs'''			):
         lowercase__    :   List[Any]						= {}

        lowercase__    :   Optional[int]						= spm.SentencePieceProcessor(**self.sp_model_kwargs			)
        self.sp_model.Load(self.vocab_file			)

       def _lowerCAmelCase(						self     ,       __lowerCAmelCase			)  ->  Tuple:
        if self.remove_space:
         lowercase__    :   str						= """ """.join(inputs.strip().split()			)
        else:
         lowercase__    :   int						= inputs
        lowercase__    :   str						= outputs.replace('''``'''     ,       '''\"'''			).replace('''\'\''''     ,       '''\"'''			)

        if not self.keep_accents:
         lowercase__    :   str						= unicodedata.normalize('''NFKD'''     ,       _lowerCAmelCase			)
         lowercase__    :   int						= """""".join([c for c in outputs if not unicodedata.combining(_lowerCAmelCase			)]			)
        if self.do_lower_case:
         lowercase__    :   List[str]						= outputs.lower()

        return outputs

       def _lowerCAmelCase(						self     ,       __lowerCAmelCase			)  ->  str:
        lowercase__    :   Optional[Any]						= self.preprocess_text(_lowerCAmelCase			)
        lowercase__    :   Tuple						= self.sp_model.encode(_lowerCAmelCase     ,       out_type=_lowerCAmelCase			)
        lowercase__    :   List[str]						= []
        for piece in pieces:
         if len(_lowerCAmelCase			) > 1 and piece[-1] == str(''','''			) and piece[-2].isdigit():
          lowercase__    :   List[str]						= self.sp_model.EncodeAsPieces(piece[:-1].replace(_lowerCAmelCase     ,       ''''''			)			)
          if piece[0] != SPIECE_UNDERLINE and cur_pieces[0][0] == SPIECE_UNDERLINE:
           if len(cur_pieces[0]			) == 1:
            lowercase__    :   List[Any]						= cur_pieces[1:]
           else:
            lowercase__    :   Optional[Any]						= cur_pieces[0][1:]
          cur_pieces.append(piece[-1]			)
          new_pieces.extend(_lowerCAmelCase			)
         else:
          new_pieces.append(_lowerCAmelCase			)

        return new_pieces

       def _lowerCAmelCase(						self     ,       __lowerCAmelCase			)  ->  Dict:
        return self.sp_model.PieceToId(_lowerCAmelCase			)

       def _lowerCAmelCase(						self     ,       __lowerCAmelCase			)  ->  Any:
        return self.sp_model.IdToPiece(_lowerCAmelCase			)

       def _lowerCAmelCase(						self     ,       __lowerCAmelCase			)  ->  Union[str, Any]:
        lowercase__    :   int						= """""".join(_lowerCAmelCase			).replace(_lowerCAmelCase     ,       ''' '''			).strip()
        return out_string

       def _lowerCAmelCase(						self     ,       __lowerCAmelCase     ,       __lowerCAmelCase = False     ,       __lowerCAmelCase = None     ,       __lowerCAmelCase = True     ,       **__lowerCAmelCase     ,       )  ->  Union[str, Any]:
        lowercase__    :   Optional[int]						= kwargs.pop('''use_source_tokenizer'''     ,       _lowerCAmelCase			)

        lowercase__    :   str						= self.convert_ids_to_tokens(_lowerCAmelCase     ,       skip_special_tokens=_lowerCAmelCase			)

        # To avoid mixing byte-level and unicode for byte-level BPT
        # we need to build string separately for added tokens and byte-level tokens
        # cf. https://github.com/huggingface/transformers/issues/1133
        lowercase__    :   Optional[int]						= []
        lowercase__    :   Optional[int]						= []
        for token in filtered_tokens:
         if skip_special_tokens and token in self.all_special_ids:
          continue
         if token in self.added_tokens_encoder:
          if current_sub_text:
           sub_texts.append(self.convert_tokens_to_string(_lowerCAmelCase			)			)
           lowercase__    :   Dict						= []
          sub_texts.append(_lowerCAmelCase			)
         else:
          current_sub_text.append(_lowerCAmelCase			)
        if current_sub_text:
         sub_texts.append(self.convert_tokens_to_string(_lowerCAmelCase			)			)

        # Mimic the behavior of the Rust tokenizer:
        # By default, there are no spaces between special tokens
        lowercase__    :   Union[str, Any]						= """""".join(_lowerCAmelCase			)

        lowercase__    :   Tuple						= (
            clean_up_tokenization_spaces
            if clean_up_tokenization_spaces is not None
            else self.clean_up_tokenization_spaces
        )
        if clean_up_tokenization_spaces:
         lowercase__    :   Union[str, Any]						= self.clean_up_tokenization(_lowerCAmelCase			)
         return clean_text
        else:
         return text

       def _lowerCAmelCase(						self     ,       __lowerCAmelCase     ,       __lowerCAmelCase = None			)  ->  Tuple:
        lowercase__    :   int						= [self.sep_token_id]
        lowercase__    :   Dict						= [self.cls_token_id]
        if token_ids_a is None:
         return token_ids_a + sep + cls
        return token_ids_a + sep + token_ids_a + sep + cls

       def _lowerCAmelCase(						self     ,       __lowerCAmelCase     ,       __lowerCAmelCase = None     ,       __lowerCAmelCase = False			)  ->  List[str]:

        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 ([0] * len(_lowerCAmelCase			)) + [1] + ([0] * len(_lowerCAmelCase			)) + [1, 1]
        return ([0] * len(_lowerCAmelCase			)) + [1, 1]

       def _lowerCAmelCase(						self     ,       __lowerCAmelCase     ,       __lowerCAmelCase = None			)  ->  Union[str, Any]:
        lowercase__    :   List[Any]						= [self.sep_token_id]
        lowercase__    :   int						= [2]

        if token_ids_a is None:
         return len(token_ids_a + sep			) * [0] + cls_segment_id
        return len(token_ids_a + sep			) * [0] + len(token_ids_a + sep			) * [1] + cls_segment_id


       def _lowerCAmelCase(						self     ,       __lowerCAmelCase     ,       __lowerCAmelCase = None			)  ->  List[str]:
        if not os.path.isdir(_lowerCAmelCase			):
         logger.error(F"""Vocabulary path ({save_directory}) should be a directory"""			)
         return
        lowercase__    :   Dict						= os.path.join(
            _lowerCAmelCase     ,       (filename_prefix + '''-''' if filename_prefix else '''''') + VOCAB_FILES_NAMES['''vocab_file''']			)

        if os.path.abspath(self.vocab_file			) != os.path.abspath(_lowerCAmelCase			) and os.path.isfile(self.vocab_file			):
         copyfile(self.vocab_file     ,       _lowerCAmelCase			)
        elif not os.path.isfile(self.vocab_file			):
         with open(_lowerCAmelCase     ,       '''wb'''			) as fi:
          lowercase__    :   Optional[int]						= self.sp_model.serialized_model_proto()
          fi.write(_lowerCAmelCase			)

        return (out_vocab_file,)


'''simple docstring'''

def       __UpperCamelCase	(       ):
 lowercase__    :   Any						= [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

 lowercase__    :   Any						= 6
 lowercase__    :   Optional[Any]						= 1
 lowercase__    :   int						= 1901

 lowercase__    :   List[str]						= 0

 while year < 2001:
  day += 7

  if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
   if day > days_per_month[month - 1] and month != 2:
    month += 1
    lowercase__    :   List[Any]						= day - days_per_month[month - 2]
   elif day > 29 and month == 2:
    month += 1
    lowercase__    :   Any						= day - 29
  else:
   if day > days_per_month[month - 1]:
    month += 1
    lowercase__    :   List[Any]						= day - days_per_month[month - 2]

  if month > 12:
   year += 1
   lowercase__    :   Dict						= 1

  if year < 2001 and day == 1:
   sundays += 1
 return sundays


if __name__ == "__main__":
  print(solution())

