



'''simple docstring'''

import copy
import fnmatch
import json
import os
import pickle as pkl
import shutil
import sys
import tarfile
import tempfile
from collections import OrderedDict
from contextlib import contextmanager
from functools import partial
from hashlib import shaaaa
from io import BytesIO
from pathlib import Path
from urllib.parse import urlparse
from zipfile import ZipFile, is_zipfile

import cva
import numpy as np
import requests
import wget
from filelock import FileLock
from PIL import Image
from tqdm.auto import tqdm
from yaml import Loader, dump, load


try:
							import torch

							__lowerCAmelCase						      =       True
except ImportError:
							__lowerCAmelCase						      =       False


try:
							from torch.hub import _get_torch_home

							__lowerCAmelCase						      =       _get_torch_home()
except ImportError:
							__lowerCAmelCase						      =       os.path.expanduser(
							    os.getenv('''TORCH_HOME''', os.path.join(os.getenv('''XDG_CACHE_HOME''', '''~/.cache'''), '''torch'''))
							)

__lowerCAmelCase						      =       os.path.join(torch_cache_home, '''transformers''')

__lowerCAmelCase						      =       "https://cdn.huggingface.co"
__lowerCAmelCase						      =       "https://s3.amazonaws.com/models.huggingface.co/bert"
__lowerCAmelCase						      =       "/".join(str(Path(__file__).resolve()).split('''/''')[:-1])
__lowerCAmelCase						      =       os.path.join(PATH, '''config.yaml''')
__lowerCAmelCase						      =       os.path.join(PATH, '''attributes.txt''')
__lowerCAmelCase						      =       os.path.join(PATH, '''objects.txt''')
__lowerCAmelCase						      =       os.getenv('''PYTORCH_PRETRAINED_BERT_CACHE''', default_cache_path)
__lowerCAmelCase						      =       os.getenv('''PYTORCH_TRANSFORMERS_CACHE''', PYTORCH_PRETRAINED_BERT_CACHE)
__lowerCAmelCase						      =       os.getenv('''TRANSFORMERS_CACHE''', PYTORCH_TRANSFORMERS_CACHE)
__lowerCAmelCase						      =       "pytorch_model.bin"
__lowerCAmelCase						      =       "config.yaml"



def        __lowerCamelCase					(				lowerCAmelCase_=OBJECTS						,      lowerCAmelCase_=ATTRIBUTES  )      ->				Tuple:
		_a					:				Union[str, Any]				=							[]
		with open(lowerCAmelCase_  ) as f:
				for object in f.readlines():
						vg_classes.append(object.split(','  )[0].lower().strip()  )

		_a					:				int				=							[]
		with open(lowerCAmelCase_  ) as f:
				for object in f.readlines():
						vg_attrs.append(object.split(','  )[0].lower().strip()  )
		return vg_classes, vg_attrs



def        __lowerCamelCase					(				lowerCAmelCase_  )      ->				List[Any]:
		_a					:				str				=							OrderedDict()
		with open(lowerCAmelCase_						,      'rb'  ) as f:
				_a					:				List[Any]				=							pkl.load(lowerCAmelCase_  )['''model''']
		for k in copy.deepcopy(list(ckp.keys()  )  ):
				_a					:				Tuple				=							ckp.pop(lowerCAmelCase_  )
				if isinstance(lowerCAmelCase_						,      np.ndarray  ):
						_a					:				Optional[Any]				=							torch.tensor(lowerCAmelCase_  )
				else:
						assert isinstance(lowerCAmelCase_						,      torch.tensor  ), type(lowerCAmelCase_  )
				_a					:				Tuple				=							v
		return r

class      __magic_name__						:
							lowerCAmelCase	:   str           = {}







							def __init__(							self :	str     ,_UpperCAmelCase :	dict     ,_UpperCAmelCase :	str = "root"     ,_UpperCAmelCase :	Dict=0		):
									_a					:				Optional[int]				=							name
									_a					:				Union[str, Any]				=							level
									_a					:				Optional[Any]				=							{}
									for k, v in dictionary.items():
											if v is None:
													raise ValueError()
											_a					:				str				=							copy.deepcopy(__A		)
											_a					:				Any				=							copy.deepcopy(__A		)
											if isinstance(__A     ,__A		):
													_a					:				Optional[Any]				=							Config(__A     ,name=__A     ,level=level + 1		)
											_a					:				List[str]				=							v
											setattr(self     ,__A     ,__A		)

									_a					:				Any				=							d







							def __repr__(							self :	Union[str, Any]		):
									return str(list((self._pointer.keys())		)		)







							def __setattr__(							self :	Tuple     ,_UpperCAmelCase :	Optional[Any]     ,_UpperCAmelCase :	Dict		):
									_a					:				Tuple				=							val
									_a					:				str				=							val
									_a					:				List[Any]				=							key.split('.'		)
									_a					:				Tuple				=							len(__A		) - 1
									_a					:				List[Any]				=							self._pointer
									if len(__A		) > 1:
											for i, l in enumerate(__A		):
													if hasattr(self     ,__A		) and isinstance(getattr(self     ,__A		)     ,__A		):
															setattr(getattr(self     ,__A		)     ,'.'.join(levels[i:]		)     ,__A		)
													if l == last_level:
															_a					:				Tuple				=							val
													else:
															_a					:				Tuple				=							pointer[l]







							def 							__lowercase      (							self :	List[Any]		):
									return self._pointer







							def 							__lowercase      (							self :	int     ,_UpperCAmelCase :	Optional[int]     ,_UpperCAmelCase :	List[Any]		):
									with open(F"""{file_name}"""     ,'w'		) as stream:
											dump(__A     ,__A		)







							def 							__lowercase      (							self :	Tuple     ,_UpperCAmelCase :	Union[str, Any]     ,_UpperCAmelCase :	Optional[int]		):
									with open(F"""{file_name}"""     ,'w'		) as stream:
											json.dump(__A     ,__A		)







							@staticmethod
							def 							__lowercase      (							_UpperCAmelCase :	Any		):
									with open(__A		) as stream:
											_a					:				Any				=							load(__A     ,Loader=__A		)
									return data







							def __str__(							self :	Tuple		):
									_a					:				Dict				=							'''    '''
									if self._name != "root":
											_a					:				str				=							F"""{t * (self._level-1)}{self._name}:\n"""
									else:
											_a					:				Optional[int]				=							''''''
									_a					:				int				=							self._level
									for i, (k, v) in enumerate(self._pointer.items()		):
											if isinstance(__A     ,__A		):
													r += F"""{t * (self._level)}{v}\n"""
													self._level += 1
											else:
													r += F"""{t * (self._level)}{k}: {v} ({type(__A		).__name__})\n"""
											_a					:				Any				=							level
									return r[:-1]







							@classmethod
							def 							__lowercase      (							cls :	Optional[Any]     ,_UpperCAmelCase :	str     ,**_UpperCAmelCase :	List[str]		):
									_a					:				List[Any]				=							cls.get_config_dict(__A     ,**__A		)
									return cls(__A		)







							@classmethod
							def 							__lowercase      (							cls :	Union[str, Any]     ,_UpperCAmelCase :	str     ,**_UpperCAmelCase :	int		):
									_a					:				List[str]				=							kwargs.pop('cache_dir'     ,__A		)
									_a					:				Dict				=							kwargs.pop('force_download'     ,__A		)
									_a					:				Any				=							kwargs.pop('resume_download'     ,__A		)
									_a					:				Any				=							kwargs.pop('proxies'     ,__A		)
									_a					:				Optional[Any]				=							kwargs.pop('local_files_only'     ,__A		)

									if os.path.isdir(__A		):
											_a					:				Tuple				=							os.path.join(__A     ,__A		)
									elif os.path.isfile(__A		) or is_remote_url(__A		):
											_a					:				Optional[Any]				=							pretrained_model_name_or_path
									else:
											_a					:				Union[str, Any]				=							hf_bucket_url(__A     ,filename=__A     ,use_cdn=__A		)

									try:
											# Load from URL or cache if already cached
											_a					:				Dict				=							cached_path(
											    __A     ,cache_dir=__A     ,force_download=__A     ,proxies=__A     ,resume_download=__A     ,local_files_only=__A     ,)
											# Load config dict
											if resolved_config_file is None:
													raise EnvironmentError

											_a					:				Any				=							Config.load_yaml(__A		)

									except EnvironmentError:
											_a					:				Dict				=							'''Can\'t load config for'''
											raise EnvironmentError(__A		)

									if resolved_config_file == config_file:
											print('loading configuration file from path'		)
									else:
											print('loading configuration file cache'		)

									return Config.load_yaml(__A		), kwargs



def        __lowerCamelCase					(				lowerCAmelCase_  )      ->				List[Any]:
		_a					:				List[str]				=							torch.load('dump.pt'						,      map_location=in_tensor.device  )
		_a					:				int				=							in_tensor.numpy()
		_a					:				Optional[Any]				=							out_tensor.numpy()[0]
		print(na.shape						,      na[0, 0, :5]  )
		print(na.shape						,      na[0, 0, :5]  )
		assert np.allclose(lowerCAmelCase_						,      lowerCAmelCase_						,      rtol=0.01						,      atol=0.1  ), (
		    f"""{sum([1 for x in np.isclose(lowerCAmelCase_						,      lowerCAmelCase_						,      rtol=0.01						,      atol=0.1  ).flatten() if x is False]  )/len(na.flatten()  )*100:.4f} %"""
		    " element-wise mismatch"
		)
		raise Exception('tensors are all good'  )

		# Hugging face functions below



def        __lowerCamelCase					(				lowerCAmelCase_  )      ->				str:
		_a					:				str				=							urlparse(lowerCAmelCase_  )
		return parsed.scheme in ("http", "https")



def        __lowerCamelCase					(				lowerCAmelCase_						,      lowerCAmelCase_						,      lowerCAmelCase_=True  )      ->				str:
		_a					:				Optional[Any]				=							CLOUDFRONT_DISTRIB_PREFIX if use_cdn else S3_BUCKET_PREFIX
		_a					:				str				=							'''/''' not in model_id
		if legacy_format:
				return f"""{endpoint}/{model_id}-{filename}"""
		else:
				return f"""{endpoint}/{model_id}/{filename}"""



def        __lowerCamelCase					(				lowerCAmelCase_						,      lowerCAmelCase_						,      lowerCAmelCase_=None						,      lowerCAmelCase_=0						,      lowerCAmelCase_=None						,      )      ->				str:
		_a					:				Any				=							'''python/{}'''.format(sys.version.split()[0]  )
		if _torch_available:
				ua += "; torch/{}".format(torch.__version__  )
		if isinstance(lowerCAmelCase_						,      lowerCAmelCase_  ):
				ua += "; " + "; ".join('{}/{}'.format(lowerCAmelCase_						,      lowerCAmelCase_  ) for k, v in user_agent.items()  )
		elif isinstance(lowerCAmelCase_						,      lowerCAmelCase_  ):
				ua += "; " + user_agent
		_a					:				Optional[Any]				=							{'''user-agent''': ua}
		if resume_size > 0:
				_a					:				List[str]				=							'''bytes=%d-''' % (resume_size,)
		_a					:				List[str]				=							requests.get(lowerCAmelCase_						,      stream=lowerCAmelCase_						,      proxies=lowerCAmelCase_						,      headers=lowerCAmelCase_  )
		if response.status_code == 416:  # Range not satisfiable
				return
		_a					:				List[Any]				=							response.headers.get('Content-Length'  )
		_a					:				Tuple				=							resume_size + int(lowerCAmelCase_  ) if content_length is not None else None
		_a					:				Any				=							tqdm(
		    unit='B'						,      unit_scale=lowerCAmelCase_						,      total=lowerCAmelCase_						,      initial=lowerCAmelCase_						,      desc='Downloading'						,      )
		for chunk in response.iter_content(chunk_size=1024  ):
				if chunk:  # filter out keep-alive new chunks
						progress.update(len(lowerCAmelCase_  )  )
						temp_file.write(lowerCAmelCase_  )
		progress.close()



def        __lowerCamelCase					(				lowerCAmelCase_						,      lowerCAmelCase_=None						,      lowerCAmelCase_=False						,      lowerCAmelCase_=None						,      lowerCAmelCase_=10						,      lowerCAmelCase_=False						,      lowerCAmelCase_=None						,      lowerCAmelCase_=False						,      )      ->				Optional[Any]:
		if cache_dir is None:
				_a					:				Dict				=							TRANSFORMERS_CACHE
		if isinstance(lowerCAmelCase_						,      lowerCAmelCase_  ):
				_a					:				Optional[Any]				=							str(lowerCAmelCase_  )

		os.makedirs(lowerCAmelCase_						,      exist_ok=lowerCAmelCase_  )

		_a					:				List[str]				=							None
		if not local_files_only:
				try:
						_a					:				int				=							requests.head(lowerCAmelCase_						,      allow_redirects=lowerCAmelCase_						,      proxies=lowerCAmelCase_						,      timeout=lowerCAmelCase_  )
						if response.status_code == 200:
								_a					:				Dict				=							response.headers.get('ETag'  )
				except (EnvironmentError, requests.exceptions.Timeout):
						# etag is already None
						pass

		_a					:				List[Any]				=							url_to_filename(lowerCAmelCase_						,      lowerCAmelCase_  )

		# get cache path to put the file
		_a					:				Dict				=							os.path.join(lowerCAmelCase_						,      lowerCAmelCase_  )

		# etag is None = we don't have a connection, or url doesn't exist, or is otherwise inaccessible.
		# try to get the last downloaded one
		if etag is None:
				if os.path.exists(lowerCAmelCase_  ):
						return cache_path
				else:
						_a					:				Optional[Any]				=							[
						    file
						    for file in fnmatch.filter(os.listdir(lowerCAmelCase_  )						,      filename + '.*'  )
						    if not file.endswith('.json'  ) and not file.endswith('.lock'  )
						]
						if len(lowerCAmelCase_  ) > 0:
								return os.path.join(lowerCAmelCase_						,      matching_files[-1]  )
						else:
								# If files cannot be found and local_files_only=True,
								# the models might've been found if local_files_only=False
								# Notify the user about that
								if local_files_only:
										raise ValueError(
										    'Cannot find the requested files in the cached path and outgoing traffic has been'
										    ' disabled. To enable model look-ups and downloads online, set \'local_files_only\''
										    ' to False.'  )
								return None

				# From now on, etag is not None.
		if os.path.exists(lowerCAmelCase_  ) and not force_download:
				return cache_path

		# Prevent parallel downloads of the same file with a lock.
		_a					:				str				=							cache_path + '''.lock'''
		with FileLock(lowerCAmelCase_  ):
				# If the download just completed while the lock was activated.
				if os.path.exists(lowerCAmelCase_  ) and not force_download:
						# Even if returning early like here, the lock will be released.
						return cache_path

				if resume_download:
						_a					:				int				=							cache_path + '''.incomplete'''

						@contextmanager
						def _resumable_file_manager():
								with open(lowerCAmelCase_						,      'a+b'  ) as f:
										yield f

						_a					:				Any				=							_resumable_file_manager
						if os.path.exists(lowerCAmelCase_  ):
								_a					:				Optional[int]				=							os.stat(lowerCAmelCase_  ).st_size
						else:
								_a					:				Tuple				=							0
				else:
						_a					:				Dict				=							partial(tempfile.NamedTemporaryFile						,      dir=lowerCAmelCase_						,      delete=lowerCAmelCase_  )
						_a					:				Optional[Any]				=							0

				# Download to temporary file, then copy to cache dir once finished.
				# Otherwise you get corrupt cache entries if the download gets interrupted.
				with temp_file_manager() as temp_file:
						print(
						    '%s not found in cache or force_download set to True, downloading to %s'						,      lowerCAmelCase_						,      temp_file.name						,      )

						http_get(
						    lowerCAmelCase_						,      lowerCAmelCase_						,      proxies=lowerCAmelCase_						,      resume_size=lowerCAmelCase_						,      user_agent=lowerCAmelCase_						,      )

				os.replace(temp_file.name						,      lowerCAmelCase_  )

				_a					:				Dict				=							{'''url''': url, '''etag''': etag}
				_a					:				Union[str, Any]				=							cache_path + '''.json'''
				with open(lowerCAmelCase_						,      'w'  ) as meta_file:
						json.dump(lowerCAmelCase_						,      lowerCAmelCase_  )

		return cache_path



def        __lowerCamelCase					(				lowerCAmelCase_						,      lowerCAmelCase_=None  )      ->				int:
		_a					:				Optional[int]				=							url.encode('utf-8'  )
		_a					:				List[str]				=							shaaaa(lowerCAmelCase_  )
		_a					:				Union[str, Any]				=							url_hash.hexdigest()

		if etag:
				_a					:				List[str]				=							etag.encode('utf-8'  )
				_a					:				Optional[Any]				=							shaaaa(lowerCAmelCase_  )
				filename += "." + etag_hash.hexdigest()

		if url.endswith('.h5'  ):
				filename += ".h5"

		return filename



def        __lowerCamelCase					(				lowerCAmelCase_						,      lowerCAmelCase_=None						,      lowerCAmelCase_=False						,      lowerCAmelCase_=None						,      lowerCAmelCase_=False						,      lowerCAmelCase_=None						,      lowerCAmelCase_=False						,      lowerCAmelCase_=False						,      lowerCAmelCase_=False						,      )      ->				Tuple:
		if cache_dir is None:
				_a					:				Union[str, Any]				=							TRANSFORMERS_CACHE
		if isinstance(lowerCAmelCase_						,      lowerCAmelCase_  ):
				_a					:				Any				=							str(lowerCAmelCase_  )
		if isinstance(lowerCAmelCase_						,      lowerCAmelCase_  ):
				_a					:				List[str]				=							str(lowerCAmelCase_  )

		if is_remote_url(lowerCAmelCase_  ):
				# URL, so get it from the cache (downloading if necessary)
				_a					:				Optional[Any]				=							get_from_cache(
				    lowerCAmelCase_						,      cache_dir=lowerCAmelCase_						,      force_download=lowerCAmelCase_						,      proxies=lowerCAmelCase_						,      resume_download=lowerCAmelCase_						,      user_agent=lowerCAmelCase_						,      local_files_only=lowerCAmelCase_						,      )
		elif os.path.exists(lowerCAmelCase_  ):
				# File, and it exists.
				_a					:				str				=							url_or_filename
		elif urlparse(lowerCAmelCase_  ).scheme == "":
				# File, but it doesn't exist.
				raise EnvironmentError('file {} not found'.format(lowerCAmelCase_  )  )
		else:
				# Something unknown
				raise ValueError('unable to parse {} as a URL or as a local path'.format(lowerCAmelCase_  )  )

		if extract_compressed_file:
				if not is_zipfile(lowerCAmelCase_  ) and not tarfile.is_tarfile(lowerCAmelCase_  ):
						return output_path

				# Path where we extract compressed archives
				# We avoid '.' in dir name and add "-extracted" at the end: "./model.zip" => "./model-zip-extracted/"
				_a					:				Optional[Any]				=							os.path.split(lowerCAmelCase_  )
				_a					:				int				=							output_file.replace('.'						,      '-'  ) + '''-extracted'''
				_a					:				int				=							os.path.join(lowerCAmelCase_						,      lowerCAmelCase_  )

				if os.path.isdir(lowerCAmelCase_  ) and os.listdir(lowerCAmelCase_  ) and not force_extract:
						return output_path_extracted

				# Prevent parallel extractions
				_a					:				List[str]				=							output_path + '''.lock'''
				with FileLock(lowerCAmelCase_  ):
						shutil.rmtree(lowerCAmelCase_						,      ignore_errors=lowerCAmelCase_  )
						os.makedirs(lowerCAmelCase_  )
						if is_zipfile(lowerCAmelCase_  ):
								with ZipFile(lowerCAmelCase_						,      'r'  ) as zip_file:
										zip_file.extractall(lowerCAmelCase_  )
										zip_file.close()
						elif tarfile.is_tarfile(lowerCAmelCase_  ):
								_a					:				int				=							tarfile.open(lowerCAmelCase_  )
								tar_file.extractall(lowerCAmelCase_  )
								tar_file.close()
						else:
								raise EnvironmentError('Archive format of {} could not be identified'.format(lowerCAmelCase_  )  )

				return output_path_extracted

		return output_path



def        __lowerCamelCase					(				lowerCAmelCase_						,      lowerCAmelCase_=","  )      ->				Union[str, Any]:
		assert isinstance(lowerCAmelCase_						,      lowerCAmelCase_  )
		if os.path.isfile(lowerCAmelCase_  ):
				with open(lowerCAmelCase_  ) as f:
						_a					:				List[str]				=							eval(f.read()  )
		else:
				_a					:				Optional[Any]				=							requests.get(lowerCAmelCase_  )
				try:
						_a					:				Union[str, Any]				=							requests.json()
				except Exception:
						_a					:				int				=							req.content.decode()
						assert data is not None, "could not connect"
						try:
								_a					:				Optional[Any]				=							eval(lowerCAmelCase_  )
						except Exception:
								_a					:				List[str]				=							data.split('\n'  )
				req.close()
		return data



def        __lowerCamelCase					(				lowerCAmelCase_  )      ->				Tuple:
		_a					:				Union[str, Any]				=							requests.get(lowerCAmelCase_  )
		_a					:				List[Any]				=							np.array(Image.open(BytesIO(response.content  )  )  )
		return img



def        __lowerCamelCase					(				lowerCAmelCase_  )      ->				Union[str, Any]:
		_a					:				Tuple				=							url.split('/'  )[-1]
		if fn not in os.listdir(os.getcwd()  ):
				wget.download(lowerCAmelCase_  )
		with open(lowerCAmelCase_						,      'rb'  ) as stream:
				_a					:				List[Any]				=							pkl.load(lowerCAmelCase_  )
		_a					:				int				=							weights.pop('model'  )
		_a					:				Optional[Any]				=							{}
		for k, v in model.items():
				_a					:				Union[str, Any]				=							torch.from_numpy(lowerCAmelCase_  )
				if "running_var" in k:
						_a					:				List[Any]				=							torch.tensor([0]  )
						_a					:				int				=							k.replace('running_var'						,      'num_batches_tracked'  )
						_a					:				Dict				=							zero
		return new



def        __lowerCamelCase					(				)      ->				List[Any]:
		print(f"""{os.path.abspath(os.path.join(lowerCAmelCase_						,      os.pardir  )  )}/demo.ipynb"""  )



def        __lowerCamelCase					(				lowerCAmelCase_						,      lowerCAmelCase_="RGB"  )      ->				Optional[Any]:
		assert isinstance(lowerCAmelCase_						,      lowerCAmelCase_  )
		if os.path.isfile(lowerCAmelCase_  ):
				_a					:				Dict				=							cva.imread(lowerCAmelCase_  )
		else:
				_a					:				Any				=							get_image_from_url(lowerCAmelCase_  )
				assert img is not None, f"""could not connect to: {im}"""
		_a					:				List[Any]				=							cva.cvtColor(lowerCAmelCase_						,      cva.COLOR_BGR2RGB  )
		if input_format == "RGB":
				_a					:				int				=							img[:, :, ::-1]
		return img



def        __lowerCamelCase					(				lowerCAmelCase_						,      lowerCAmelCase_=1  )      ->				Union[str, Any]:
		return (images[i : i + batch] for i in range(0						,      len(lowerCAmelCase_  )						,      lowerCAmelCase_  ))









'''simple docstring'''

from math import sqrt



def 					__lowerCamelCase					(				lowerCAmelCase_  )      ->				int:
		_a					:				Dict				=							0
		for i in range(1						,      int(sqrt(lowerCAmelCase_  ) + 1  )  ):
				if n % i == 0 and i != sqrt(lowerCAmelCase_  ):
						total += i + n // i
				elif i == sqrt(lowerCAmelCase_  ):
						total += i
		return total - n



def 					__lowerCamelCase					(				lowerCAmelCase_ = 10000  )      ->				int:
		_a					:				Union[str, Any]				=							sum(
		    i
		    for i in range(1						,      lowerCAmelCase_  )
		    if sum_of_divisors(sum_of_divisors(lowerCAmelCase_  )  ) == i and sum_of_divisors(lowerCAmelCase_  ) != i  )
		return total


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




