


"""simple docstring"""


import pickle

import numpy as np
from matplotlib import pyplot as plt



class 			lowerCamelCase__						:







						def __init__(							self   :    int			,			_lowercase   :    Dict			,			_lowercase   :    int			,			_lowercase   :    List[Any]			,			_lowercase   :    str			,			_lowercase   :    Optional[Any]			,			_lowercase   :    Tuple=0.2			,			_lowercase   :    List[Any]=0.2		):
								A					       = bp_numa
								A					       = bp_numa
								A					       = bp_numa
								A					       = conva_get[:2]
								A					       = conva_get[2]
								A					       = size_pa
								A					       = rate_w
								A					       = rate_t
								A					       = [
								    np.mat(-1 * np.random.rand(self.conva[0]			,			self.conva[0]		) + 0.5		)
								    for i in range(self.conva[1]		)
								]
								A					       = np.mat(-1 * np.random.rand(self.num_bpa			,			self.num_bpa		) + 0.5		)
								A					       = np.mat(-1 * np.random.rand(self.num_bpa			,			self.num_bpa		) + 0.5		)
								A					       = -2 * np.random.rand(self.conva[1]		) + 1
								A					       = -2 * np.random.rand(self.num_bpa		) + 1
								A					       = -2 * np.random.rand(self.num_bpa		) + 1







						def __a						(							self   :    Optional[int]			,			_lowercase   :    Any		):
								# save model dict with pickle
								A					       = {
								    'num_bp1': self.num_bpa,
								    'num_bp2': self.num_bpa,
								    'num_bp3': self.num_bpa,
								    'conv1': self.conva,
								    'step_conv1': self.step_conva,
								    'size_pooling1': self.size_poolinga,
								    'rate_weight': self.rate_weight,
								    'rate_thre': self.rate_thre,
								    'w_conv1': self.w_conva,
								    'wkj': self.wkj,
								    'vji': self.vji,
								    'thre_conv1': self.thre_conva,
								    'thre_bp2': self.thre_bpa,
								    'thre_bp3': self.thre_bpa,
								}
								with open(_lowercase			,			'wb'		) as f:
										pickle.dump(_lowercase			,			_lowercase		)

								print(f'Model saved： {save_path}'		)







						@classmethod
						def __a						(							cls   :    Union[str, Any]			,			_lowercase   :    Any		):
								# read saved model
								with open(_lowercase			,			'rb'		) as f:
										A					       = pickle.load(_lowercase		)  # noqa: S301

								A					       = model_dic.get('conv1'		)
								conv_get.append(model_dic.get('step_conv1'		)		)
								A					       = model_dic.get('size_pooling1'		)
								A					       = model_dic.get('num_bp1'		)
								A					       = model_dic.get('num_bp2'		)
								A					       = model_dic.get('num_bp3'		)
								A					       = model_dic.get('rate_weight'		)
								A					       = model_dic.get('rate_thre'		)
								# create model instance
								A					       = CNN(_lowercase			,			_lowercase			,			_lowercase			,			_lowercase			,			_lowercase			,			_lowercase			,			_lowercase		)
								# modify model parameter
								A					       = model_dic.get('w_conv1'		)
								A					       = model_dic.get('wkj'		)
								A					       = model_dic.get('vji'		)
								A					       = model_dic.get('thre_conv1'		)
								A					       = model_dic.get('thre_bp2'		)
								A					       = model_dic.get('thre_bp3'		)
								return conv_ins







						def __a						(							self   :    Tuple			,			_lowercase   :    Optional[int]		):
								return 1 / (1 + np.exp(-1 * x		))







						def __a						(							self   :    List[Any]			,			_lowercase   :    Dict		):
								return round(_lowercase			,			3		)







						def __a						(							self   :    List[str]			,			_lowercase   :    Any			,			_lowercase   :    int			,			_lowercase   :    Optional[Any]			,			_lowercase   :    Optional[int]			,			_lowercase   :    List[str]		):
								# convolution process
								A					       = convs[0]
								A					       = convs[1]
								A					       = np.shape(_lowercase		)[0]
								# get the data slice of original image data, data_focus
								A					       = []
								for i_focus in range(0			,			size_data - size_conv + 1			,			_lowercase		):
										for j_focus in range(0			,			size_data - size_conv + 1			,			_lowercase		):
												A					       = data[
												    i_focus : i_focus + size_conv, j_focus : j_focus + size_conv
												]
												data_focus.append(_lowercase		)
        # calculate the feature map of every single kernel, and saved as list of matrix
								A					       = []
								A					       = int((size_data - size_conv) / conv_step + 1		)
								for i_map in range(_lowercase		):
										A					       = []
										for i_focus in range(len(_lowercase		)		):
												A					       = (
												    np.sum(np.multiply(data_focus[i_focus]			,			w_convs[i_map]		)		)
												    - thre_convs[i_map]
												)
												featuremap.append(self.sig(_lowercase		)		)
										A					       = np.asmatrix(_lowercase		).reshape(
										    _lowercase			,			_lowercase		)
										data_featuremap.append(_lowercase		)

								# expanding the data slice to One dimenssion
								A					       = []
								for each_focus in data_focus:
										focusa_list.extend(self.Expand_Mat(_lowercase		)		)
								A					       = np.asarray(_lowercase		)
								return focus_list, data_featuremap







						def __a						(							self   :    List[str]			,			_lowercase   :    str			,			_lowercase   :    int			,			_lowercase   :    Optional[Any]="average_pool"		):
								# pooling process
								A					       = len(featuremaps[0]		)
								A					       = int(size_map / size_pooling		)
								A					       = []
								for i_map in range(len(_lowercase		)		):
										A					       = featuremaps[i_map]
										A					       = []
										for i_focus in range(0			,			_lowercase			,			_lowercase		):
												for j_focus in range(0			,			_lowercase			,			_lowercase		):
														A					       = feature_map[
														    i_focus : i_focus + size_pooling,
														    j_focus : j_focus + size_pooling,
														]
														if pooling_type == "average_pool":
																# average pooling
																map_pooled.append(np.average(_lowercase		)		)
														elif pooling_type == "max_pooling":
																# max pooling
																map_pooled.append(np.max(_lowercase		)		)
										A					       = np.asmatrix(_lowercase		).reshape(_lowercase			,			_lowercase		)
										featuremap_pooled.append(_lowercase		)
								return featuremap_pooled







						def __a						(							self   :    Any			,			_lowercase   :    Tuple		):
								# expanding three dimension data to one dimension list
								A					       = []
								for i in range(len(_lowercase		)		):
										A					       = np.shape(data[i]		)
										A					       = data[i].reshape(1			,			shapes[0] * shapes[1]		)
										A					       = data_listed.getA().tolist()[0]
										data_expanded.extend(_lowercase		)
								A					       = np.asarray(_lowercase		)
								return data_expanded







						def __a						(							self   :    Tuple			,			_lowercase   :    str		):
								# expanding matrix to one dimension list
								A					       = np.asarray(_lowercase		)
								A					       = np.shape(_lowercase		)
								A					       = data_mat.reshape(1			,			shapes[0] * shapes[1]		)
								return data_expanded







						def __a						(							self   :    Optional[int]			,			_lowercase   :    Optional[int]			,			_lowercase   :    Dict			,			_lowercase   :    Dict			,			_lowercase   :    str			,			_lowercase   :    List[Any]		):
								A					       = []
								A					       = 0
								for i_map in range(_lowercase		):
										A					       = np.ones((size_map, size_map)		)
										for i in range(0			,			_lowercase			,			_lowercase		):
												for j in range(0			,			_lowercase			,			_lowercase		):
														A					       = pd_pool[
														    i_pool
														]
														A					       = i_pool + 1
										A					       = np.multiply(
										    _lowercase			,			np.multiply(out_map[i_map]			,			(1 - out_map[i_map])		)		)
										pd_all.append(_lowercase		)
								return pd_all







						def __a						(							self   :    Dict			,			_lowercase   :    Union[str, Any]			,			_lowercase   :    Optional[int]			,			_lowercase   :    int			,			_lowercase   :    str			,			_lowercase   :    Optional[int]			,			_lowercase   :    Tuple=bool		):
								# model traning
								print('----------------------Start Training-------------------------'		)
								print((' - - Shape: Train_Data  ', np.shape(_lowercase		))		)
								print((' - - Shape: Teach_Data  ', np.shape(_lowercase		))		)
								A					       = 0
								A					       = []
								A					       = 10_000
								while rp < n_repeat and mse >= error_accuracy:
										A					       = 0
										print(f'-------------Learning Time {rp}--------------'		)
										for p in range(len(_lowercase		)		):
												# print('------------Learning Image: %d--------------'%p)
												A					       = np.asmatrix(datas_train[p]		)
												A					       = np.asarray(datas_teach[p]		)
												A       , A					       = self.convolute(
												    _lowercase			,			self.conva			,			self.w_conva			,			self.thre_conva			,			conv_step=self.step_conva			,			)
												A					       = self.pooling(_lowercase			,			self.size_poolinga		)
												A					       = np.shape(_lowercase		)
												A					       = self._expand(_lowercase		)
												A					       = data_bp_input

												A					       = np.dot(_lowercase			,			self.vji.T		) - self.thre_bpa
												A					       = self.sig(_lowercase		)
												A					       = np.dot(_lowercase			,			self.wkj.T		) - self.thre_bpa
												A					       = self.sig(_lowercase		)

												# --------------Model Leaning ------------------------
												# calculate error and gradient---------------
												A					       = np.multiply(
												    (data_teach - bp_outa)			,			np.multiply(_lowercase			,			(1 - bp_outa)		)		)
												A					       = np.multiply(
												    np.dot(_lowercase			,			self.wkj		)			,			np.multiply(_lowercase			,			(1 - bp_outa)		)		)
												A					       = np.dot(_lowercase			,			self.vji		)

												A					       = pd_i_all / (self.size_poolinga * self.size_poolinga)
												A					       = pd_conva_pooled.T.getA().tolist()
												A					       = self._calculate_gradient_from_pool(
												    _lowercase			,			_lowercase			,			shape_featuremapa[0]			,			shape_featuremapa[1]			,			self.size_poolinga			,			)
												# weight and threshold learning process---------
												# convolution layer
												for k_conv in range(self.conva[1]		):
														A					       = self._expand_mat(pd_conva_all[k_conv]		)
														A					       = self.rate_weight * np.dot(_lowercase			,			_lowercase		)

														A					       = self.w_conva[k_conv] + delta_w.reshape(
														    (self.conva[0], self.conva[0])		)

														A					       = (
														    self.thre_conva[k_conv]
														    - np.sum(pd_conva_all[k_conv]		) * self.rate_thre
														)
												# all connected layer
												A					       = self.wkj + pd_k_all.T * bp_outa * self.rate_weight
												A					       = self.vji + pd_j_all.T * bp_outa * self.rate_weight
												A					       = self.thre_bpa - pd_k_all * self.rate_thre
												A					       = self.thre_bpa - pd_j_all * self.rate_thre
												# calculate the sum error of all single image
												A					       = np.sum(abs(data_teach - bp_outa		)		)
												error_count += errors
												# print('   ----Teach      ',data_teach)
												# print('   ----BP_output  ',bp_out3)
										A					       = rp + 1
										A					       = error_count / patterns
										all_mse.append(_lowercase		)

								def draw_error():
										A					       = [error_accuracy for i in range(int(n_repeat * 1.2		)		)]
										plt.plot(_lowercase			,			'+-'		)
										plt.plot(_lowercase			,			'r--'		)
										plt.xlabel('Learning Times'		)
										plt.ylabel('All_mse'		)
										plt.grid(_lowercase			,			alpha=0.5		)
										plt.show()

								print('------------------Training Complished---------------------'		)
								print((' - - Training epoch: ', rp, f'     - - Mse: {mse:.6f}')		)
								if draw_e:
										draw_error()
								return mse







						def __a						(							self   :    str			,			_lowercase   :    Optional[int]		):
								# model predict
								A					       = []
								print('-------------------Start Testing-------------------------'		)
								print((' - - Shape: Test_Data  ', np.shape(_lowercase		))		)
								for p in range(len(_lowercase		)		):
										A					       = np.asmatrix(datas_test[p]		)
										A       , A					       = self.convolute(
										    _lowercase			,			self.conva			,			self.w_conva			,			self.thre_conva			,			conv_step=self.step_conva			,			)
										A					       = self.pooling(_lowercase			,			self.size_poolinga		)
										A					       = self._expand(_lowercase		)

										A					       = data_bp_input
										A					       = bp_outa * self.vji.T - self.thre_bpa
										A					       = self.sig(_lowercase		)
										A					       = bp_outa * self.wkj.T - self.thre_bpa
										A					       = self.sig(_lowercase		)
										produce_out.extend(bp_outa.getA().tolist()		)
								A					       = [list(map(self.do_round			,			_lowercase		)		) for each in produce_out]
								return np.asarray(_lowercase		)







						def __a						(							self   :    Optional[Any]			,			_lowercase   :    int		):
								# return the data of image after convoluting process so we can check it out
								A					       = np.asmatrix(_lowercase		)
								A       , A					       = self.convolute(
								    _lowercase			,			self.conva			,			self.w_conva			,			self.thre_conva			,			conv_step=self.step_conva			,			)
								A					       = self.pooling(_lowercase			,			self.size_poolinga		)

								return data_conveda, data_pooleda


if __name__ == "__main__":
	pass






"""simple docstring"""


def  __snake_case       (   )      ->		int:







		"""simple docstring"""





		return 1







def  __snake_case       (   UpperCamelCase__	)      ->		int:







		"""simple docstring"""





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







def  __snake_case       (   UpperCamelCase__	)      ->		int:







		"""simple docstring"""





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







def  __snake_case       (   UpperCamelCase__	)      ->		int:







		"""simple docstring"""





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







def  __snake_case       (   UpperCamelCase__	)      ->		int:







		"""simple docstring"""





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







def  __snake_case       (   UpperCamelCase__	)      ->		int:







		"""simple docstring"""





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







def  __snake_case       (   UpperCamelCase__	)      ->		int:







		"""simple docstring"""





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







def  __snake_case       (   UpperCamelCase__	)      ->		int:







		"""simple docstring"""





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







def  __snake_case       (   UpperCamelCase__ = 200	)      ->		int:







		"""simple docstring"""





		return two_pound(UpperCamelCase__	)


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





