





import collections
import json
import os
import re
from typing import TYPE_CHECKING, List, Optional, Tuple

import numpy as np

from ...tokenization_utils_fast import PreTrainedTokenizer
from ...utils import logging


if TYPE_CHECKING:
					from transformers.pipelines.conversational import Conversation


UpperCAmelCase_ 							=       logging.get_logger(__name__)

UpperCAmelCase_ 							=       {"""vocab_file""": """vocab.txt""", """emoji_file""": """emoji.json"""}

UpperCAmelCase_ 							=       {
    """vocab_file""": {
        """abeja/gpt-neox-japanese-2.7b""": """https://huggingface.co/abeja/gpt-neox-japanese-2.7b/resolve/main/vocab.txt""",
    },
    """emoji_file""": {
        """abeja/gpt-neox-japanese-2.7b""": """https://huggingface.co/abeja/gpt-neox-japanese-2.7b/resolve/main/emoji.json""",
    },
}

UpperCAmelCase_ 							=       {
    """abeja/gpt-neox-japanese-2.7b""": 2048,
}





def   lowerCamelCase__       (       UpperCamelCase__     :    Any    ,      UpperCamelCase__     :    Any  )     ->	Optional[int]:



					'''simple docstring'''




					with open(UpperCamelCase__    ,      'r'    ,      encoding='utf-8'  ) as f:
										_snake_case													=			json.loads(f.read()  )

					_snake_case													=			collections.OrderedDict()
					_snake_case													=			collections.OrderedDict()
					_snake_case													=			collections.OrderedDict()
					with open(UpperCamelCase__    ,      'r'    ,      encoding='utf-8'  ) as f:
										_snake_case													=			f.readlines()
					_snake_case													=			[[t.rstrip('\n'  )] if (t == ',' or ',' not in t) else t.rstrip('\n'  ).split(','  ) for t in token]
					for idx, b in enumerate(UpperCamelCase__  ):
										_snake_case													=			b
										_snake_case													=			idx
										for wd in b:
															_snake_case													=			idx

					return vocab, raw_vocab, ids_to_tokens, emoji
class      UpperCamelCase_						(					_lowerCamelCase   ):
					lowerCAmelCase_							=		VOCAB_FILES_NAMES
					lowerCAmelCase_							=		PRETRAINED_VOCAB_FILES_MAP
					lowerCAmelCase_							=		PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
					lowerCAmelCase_							=		['''input_ids''', '''attention_mask''']




					def __init__(						self			,  lowerCAmelCase_			,  lowerCAmelCase_			,  lowerCAmelCase_="<|endoftext|>"			,  lowerCAmelCase_="<|endoftext|>"			,  lowerCAmelCase_="<|startoftext|>"			,  lowerCAmelCase_="<|endoftext|>"			,  lowerCAmelCase_=False			,  **lowerCAmelCase_			,  )						->							List[Any]:
										super().__init__(
										    unk_token=lowerCAmelCase_			,  pad_token=lowerCAmelCase_			,  bos_token=lowerCAmelCase_			,  eos_token=lowerCAmelCase_			,  do_clean_text=lowerCAmelCase_			,  **lowerCAmelCase_			,  )
										if not os.path.isfile(lowerCAmelCase_					):
															raise ValueError(
															    F'''Can\'t find a vocabulary file at path \'{vocab_file}\'. To load the vocabulary from a Google pretrained'''
															    ' model use `tokenizer = GPTNeoXJapaneseokenizer.from_pretrained(PRETRAINED_MODEL_NAME)`'					)
										if not os.path.isfile(lowerCAmelCase_					):
															raise ValueError(
															    F'''Can\'t find a emoji file at path \'{emoji_file}\'. To load the emoji information from a Google'''
															    ' pretrained model use `tokenizer = GPTNeoXJapaneseokenizer.from_pretrained(PRETRAINED_MODEL_NAME)`'					)
										_snake_case													=			do_clean_text
										_snake_case							,       _snake_case							,       _snake_case							,       _snake_case													=			load_vocab_and_emoji(lowerCAmelCase_			,  lowerCAmelCase_					)
										_snake_case													=			SubWordJapaneseTokenizer(
										    vocab=self.vocab			,  ids_to_tokens=self.ids_to_tokens			,  emoji=self.emoji					)




					@property
					def 		lowerCAmelCase     (						self					)						->							str:
										# self.vocab contains support for character fluctuation unique to Japanese, and has a large number of vocab
										return len(self.raw_vocab					)




					def 		lowerCAmelCase     (						self					)						->							List[str]:
										return dict(self.raw_vocab			,  **self.added_tokens_encoder					)




					def 		lowerCAmelCase     (						self			,  lowerCAmelCase_					)						->							Dict:
										return self.subword_tokenizer.tokenize(lowerCAmelCase_			,  clean=self.do_clean_text					)




					def 		lowerCAmelCase     (						self			,  lowerCAmelCase_					)						->							List[str]:
										return self.vocab.get(lowerCAmelCase_			,  self.vocab.get(self.unk_token					)					)




					def 		lowerCAmelCase     (						self			,  lowerCAmelCase_					)						->							Tuple:
										return self.subword_tokenizer.convert_id_to_token(lowerCAmelCase_					)




					def 		lowerCAmelCase     (						self			,  lowerCAmelCase_					)						->							Any:
										_snake_case													=			''.join(lowerCAmelCase_					).strip()
										return out_string




					def 		lowerCAmelCase     (						self			,  lowerCAmelCase_					)						->							List[int]:
										_snake_case													=			[]
										for is_user, text in conversation.iter_texts():
															input_ids.extend(self.encode(lowerCAmelCase_			,  add_special_tokens=lowerCAmelCase_					) + [self.eos_token_id]					)

										if len(lowerCAmelCase_					) > self.model_max_length:
															_snake_case													=			input_ids[-self.model_max_length :]
										return input_ids






					def 		lowerCAmelCase     (						self			,  lowerCAmelCase_			,  lowerCAmelCase_ = None					)						->							Tuple[str]:
										_snake_case													=			0
										if os.path.isdir(lowerCAmelCase_					):
															_snake_case													=			os.path.join(
															    lowerCAmelCase_			,  (filename_prefix + '-' if filename_prefix else '') + VOCAB_FILES_NAMES['vocab_file']					)
															_snake_case													=			os.path.join(
															    lowerCAmelCase_			,  (filename_prefix + '-' if filename_prefix else '') + VOCAB_FILES_NAMES['emoji_file']					)
										else:
															_snake_case													=			(
															    (filename_prefix + '-' if filename_prefix else '') + save_directory + VOCAB_FILES_NAMES['vocab_file']
															)
															_snake_case													=			(
															    (filename_prefix + '-' if filename_prefix else '') + save_directory + VOCAB_FILES_NAMES['emoji_file']
															)
										with open(lowerCAmelCase_			,  'w'			,  encoding='utf-8'					) as writer:
															for token_index, token in self.ids_to_tokens.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!'					)
																									_snake_case													=			token_index
																				writer.write(','.join(lowerCAmelCase_					) + '\n'					)
																				index += 1
										with open(lowerCAmelCase_			,  'w'			,  encoding='utf-8'					) as writer:
															json.dump(self.emoji			,  lowerCAmelCase_					)
										return vocab_file, emoji_file





class      UpperCamelCase_						(					_lowerCamelCase   ):




					def __init__(						self			,  lowerCAmelCase_			,  lowerCAmelCase_			,  lowerCAmelCase_					)						->							int:
										_snake_case													=			vocab  # same as swe
										_snake_case													=			ids_to_tokens  # same as bpe
										_snake_case													=			emoji
										_snake_case													=			np.max([len(lowerCAmelCase_					) for w in self.vocab.keys()]					)
										_snake_case													=			re.compile(r'(https?|ftp)(:\/\/[-_\.!~*\'()a-zA-Z0-9;\/?:\@&=\+$,%#]+)'					)
										_snake_case													=			re.compile(r'[A-Za-z0-9\._+]*@[\-_0-9A-Za-z]+(\.[A-Za-z]+)*'					)
										_snake_case													=			re.compile(r'[\(]{0,1}[0-9]{2,4}[\)\-\(]{0,1}[0-9]{2,4}[\)\-]{0,1}[0-9]{3,4}'					)
										_snake_case													=			re.compile(
										    r'([12]\d{3}[/\-年])*(0?[1-9]|1[0-2])[/\-月]((0?[1-9]|[12][0-9]|3[01])日?)*(\d{1,2}|:|\d{1,2}時|\d{1,2}分|\(日\)|\(月\)|\(火\)|\(水\)|\(木\)|\(金\)|\(土\)|㈰|㈪|㈫|㈬|㈭|㈮|㈯)*'					)
										_snake_case													=			re.compile(
										    r'(明治|大正|昭和|平成|令和|㍾|㍽|㍼|㍻|\u32ff)\d{1,2}年(0?[1-9]|1[0-2])月(0?[1-9]|[12][0-9]|3[01])日(\d{1,2}|:|\d{1,2}時|\d{1,2}分|\(日\)|\(月\)|\(火\)|\(水\)|\(木\)|\(金\)|\(土\)|㈰|㈪|㈫|㈬|㈭|㈮|㈯)*'					)
										_snake_case													=			re.compile(
										    r'((0|[1-9]\d*|[1-9]\d{0,2}(,\d{3})+)*億)*((0|[1-9]\d*|[1-9]\d{0,2}(,\d{3})+)*万)*((0|[1-9]\d*|[1-9]\d{0,2}(,\d{3})+)*千)*(0|[1-9]\d*|[1-9]\d{0,2}(,\d{3})+)*(千円|万円|千万円|円|千ドル|万ドル|千万ドル|ドル|千ユーロ|万ユーロ|千万ユーロ|ユーロ)+(\(税込\)|\(税抜\)|\+tax)*'					)
										_snake_case													=			'─━│┃┄┅┆┇┈┉┊┋┌┍┎┏┐┑┒┓└┕┖┗┘┙┚┛├┝┞┟┠┡┢┣┤┥┦┧┨┩┪┫┬┭┮┯┰┱┲┳┴┵┶┷┸┹┺┻┼┽┾┿╀╁╂╃╄╅╆╇╈╉╊╋╌╍╎╏═║╒╓╔╕╖╗╘╙╚╛╜╝╞╟╠╡╢╣╤╥╦╧╨╩╪╫╬╭╮╯╰╱╲╳╴╵╶╷╸╹╺╻╼╽╾╿'
										_snake_case													=			'▀▁▂▃▄▅▆▇█▉▊▋▌▍▎▏▐░▒▓▔▕▖▗▘▙▚▛▜▝▞▟'
										_snake_case													=			str.maketrans({k: '<BLOCK>' for k in keisen + blocks}					)




					def __len__(						self					)						->							str:
										return len(self.ids_to_tokens					)




					def 		lowerCAmelCase     (						self			,  lowerCAmelCase_					)						->							Union[str, Any]:
										_snake_case													=			self.content_repattera.sub('<URL>'			,  lowerCAmelCase_					)
										_snake_case													=			self.content_repattera.sub('<EMAIL>'			,  lowerCAmelCase_					)
										_snake_case													=			self.content_repattera.sub('<TEL>'			,  lowerCAmelCase_					)
										_snake_case													=			self.content_repattera.sub('<DATE>'			,  lowerCAmelCase_					)
										_snake_case													=			self.content_repattera.sub('<DATE>'			,  lowerCAmelCase_					)
										_snake_case													=			self.content_repattera.sub('<PRICE>'			,  lowerCAmelCase_					)
										_snake_case													=			content.translate(self.content_transa					)
										while "<BLOCK><BLOCK>" in content:
															_snake_case													=			content.replace('<BLOCK><BLOCK>'			,  '<BLOCK>'					)
										return content




					def 		lowerCAmelCase     (						self			,  lowerCAmelCase_			,  lowerCAmelCase_=False					)						->							Tuple:
										_snake_case													=			text.replace(' '			,  '<SP>'					)
										_snake_case													=			text.replace('　'			,  '<SP>'					)
										_snake_case													=			text.replace('\r\n'			,  '<BR>'					)
										_snake_case													=			text.replace('\n'			,  '<BR>'					)
										_snake_case													=			text.replace('\r'			,  '<BR>'					)
										_snake_case													=			text.replace('\t'			,  '<TAB>'					)
										_snake_case													=			text.replace('—'			,  'ー'					)
										_snake_case													=			text.replace('−'			,  'ー'					)
										for k, v in self.emoji["emoji"].items():
															if k in text:
																				_snake_case													=			text.replace(lowerCAmelCase_			,  lowerCAmelCase_					)
										if clean:
															_snake_case													=			self.clean_text(lowerCAmelCase_					)

										def check_simbol(lowerCAmelCase_					):
															_snake_case													=			x.encode()
															if len(lowerCAmelCase_					) == 1 and len(lowerCAmelCase_					) == 2:
																				_snake_case													=			(int(e[0]					) << 8) + int(e[1]					)
																				if (
																				    (c >= 0Xc2a1 and c <= 0Xc2bf)
																				    or (c >= 0Xc780 and c <= 0Xc783)
																				    or (c >= 0Xcab9 and c <= 0Xcbbf)
																				    or (c >= 0Xcc80 and c <= 0Xcda2)
																				):
																									return True
															return False

										def checkuae(lowerCAmelCase_					):
															_snake_case													=			x.encode()
															if len(lowerCAmelCase_					) == 1 and len(lowerCAmelCase_					) == 3:
																				_snake_case													=			(int(e[0]					) << 16) + (int(e[1]					) << 8) + int(e[2]					)
																				if c >= 0Xe28080 and c <= 0Xe2b07f:
																									return True
															return False

										_snake_case													=			0
										_snake_case													=			[]
										while pos < len(lowerCAmelCase_					):
															_snake_case													=			min(len(lowerCAmelCase_					)			,  pos + self.maxlen + 1					) if text[pos] == '<' else pos + 3
															_snake_case													=			[]  # (token_id, token, pos)
															for e in range(lowerCAmelCase_			,  lowerCAmelCase_			,  -1					):
																				_snake_case													=			text[pos:e]
																				if wd in self.vocab:
																									if wd[0] == "<" and len(lowerCAmelCase_					) > 2:
																														_snake_case													=			[(self.vocab[wd], wd, e)]
																														break
																									else:
																														candidates.append((self.vocab[wd], wd, e)					)
															if len(lowerCAmelCase_					) > 0:
																				# the smallest token_id is adopted
																				_snake_case							,       _snake_case							,       _snake_case													=			sorted(lowerCAmelCase_			,  key=lambda lowerCAmelCase_					: x[0]					)[0]
																				result.append(lowerCAmelCase_					)
																				_snake_case													=			e
															else:
																				_snake_case													=			pos + 1
																				_snake_case													=			text[pos:end]
																				if check_simbol(lowerCAmelCase_					):
																									result.append('<KIGOU>'					)
																				elif checkuae(lowerCAmelCase_					):
																									result.append('<U2000U2BFF>'					)
																				else:
																									for i in wd.encode('utf-8'					):
																														result.append('<|byte%d|>' % i					)
																				_snake_case													=			end
										return result






					def 		lowerCAmelCase     (						self			,  lowerCAmelCase_			,  lowerCAmelCase_="\n"					)						->							Optional[Any]:
										_snake_case													=			[]
										_snake_case													=			[]
										_snake_case													=			self.ids_to_tokens[index][0]
										if word[:6] == "<|byte" and word[-2:] == "|>":
															byte_tokens.append(int(word[6:-2]					)					)
										else:
															if len(lowerCAmelCase_					) > 0:
																				words.append(bytearray(lowerCAmelCase_					).decode('utf-8'			,  errors='replace'					)					)
																				_snake_case													=			[]
															if word[:7] == "<|emoji" and word[-2:] == "|>":
																				words.append(self.emoji['emoji_inv'][word]					)
															elif word == "<SP>":
																				words.append(' '					)
															elif word == "<BR>":
																				words.append(lowerCAmelCase_					)
															elif word == "<TAB>":
																				words.append('\t'					)
															elif word == "<BLOCK>":
																				words.append('▀'					)
															elif word == "<KIGOU>":
																				words.append('ǀ'					)
															elif word == "<U2000U2BFF>":
																				words.append('‖'					)
															else:
																				words.append(lowerCAmelCase_					)
										if len(lowerCAmelCase_					) > 0:
															words.append(bytearray(lowerCAmelCase_					).decode('utf-8'			,  errors='replace'					)					)
										_snake_case													=			''.join(lowerCAmelCase_					)
										return text










def   lowerCamelCase__       (       )     ->	int:



					'''simple docstring'''




					return 1





def   lowerCamelCase__       (       UpperCamelCase__     :    int  )     ->	int:



					'''simple docstring'''




					return 0 if x < 0 else two_pence(x - 2  ) + one_pence()





def   lowerCamelCase__       (       UpperCamelCase__     :    int  )     ->	int:



					'''simple docstring'''




					return 0 if x < 0 else five_pence(x - 5  ) + two_pence(UpperCamelCase__  )





def   lowerCamelCase__       (       UpperCamelCase__     :    int  )     ->	int:



					'''simple docstring'''




					return 0 if x < 0 else ten_pence(x - 10  ) + five_pence(UpperCamelCase__  )





def   lowerCamelCase__       (       UpperCamelCase__     :    int  )     ->	int:



					'''simple docstring'''




					return 0 if x < 0 else twenty_pence(x - 20  ) + ten_pence(UpperCamelCase__  )





def   lowerCamelCase__       (       UpperCamelCase__     :    int  )     ->	int:



					'''simple docstring'''




					return 0 if x < 0 else fifty_pence(x - 50  ) + twenty_pence(UpperCamelCase__  )





def   lowerCamelCase__       (       UpperCamelCase__     :    int  )     ->	int:



					'''simple docstring'''




					return 0 if x < 0 else one_pound(x - 100  ) + fifty_pence(UpperCamelCase__  )





def   lowerCamelCase__       (       UpperCamelCase__     :    int  )     ->	int:



					'''simple docstring'''




					return 0 if x < 0 else two_pound(x - 200  ) + one_pound(UpperCamelCase__  )





def   lowerCamelCase__       (       UpperCamelCase__     :    int = 200  )     ->	int:



					'''simple docstring'''




					return two_pound(UpperCamelCase__  )


if __name__ == "__main__":
					print(solution(int(input().strip())))



