'''simple docstring'''





import gc
import threading
import time

import psutil
import torch




class 		SCREAMING_SNAKE_CASE     :







				'''simple docstring'''





				def __init__(						self					:						List[Any]					)							->Union[str, Any]:


										'''simple docstring'''




										_UpperCamelCase			:			int   			=						psutil.Process()
										_UpperCamelCase			:			Optional[int]   			=						False





				def  snake_case__				(						self					:						List[str]					)							->int:


										'''simple docstring'''




										_UpperCamelCase			:			Dict   			=						-1

										while True:
																_UpperCamelCase			:			Tuple   			=						max(self.process.memory_info().rss       ,		self.cpu_memory_peak					)

																# can't sleep or will not catch the peak right (this comment is here on purpose)
																if not self.peak_monitoring:
																						break





				def  snake_case__				(						self					:						Union[str, Any]					)							->str:


										'''simple docstring'''




										_UpperCamelCase			:			Tuple   			=						True
										_UpperCamelCase			:			Optional[int]   			=						threading.Thread(target=self.peak_monitor					)
										_UpperCamelCase			:			Tuple   			=						True
										self.thread.start()







				def  snake_case__				(						self					:						Tuple					)							->Dict:


										'''simple docstring'''




										_UpperCamelCase			:			str   			=						False
										self.thread.join()
										return self.cpu_memory_peak





lowerCAmelCase_	:		int			=     PeakCPUMemory()
def 						__A							(     )     ->			Union[str, Any]:




						'''simple docstring'''
						# Time
						_UpperCamelCase			:			str   			=						{"time": time.time()}

						gc.collect()
						torch.cuda.empty_cache()

						# CPU mem
						_UpperCamelCase			:			Dict   			=						psutil.Process().memory_info().rss
						cpu_peak_tracker.start()

						# GPU mem
						for i in range(torch.cuda.device_count()					):
												_UpperCamelCase			:			str   			=						torch.cuda.memory_allocated(UpperCAmelCase					)
						torch.cuda.reset_peak_memory_stats()

						return measures
def 						__A							(     UpperCAmelCase					)     ->			Optional[Any]:




						'''simple docstring'''
						# Time
						_UpperCamelCase			:			int   			=						{"time": time.time() - start_measures["time"]}

						gc.collect()
						torch.cuda.empty_cache()

						# CPU mem
						_UpperCamelCase			:			Optional[Any]   			=						(psutil.Process().memory_info().rss - start_measures["cpu"]) / 2**2_0
						_UpperCamelCase			:			Union[str, Any]   			=						(cpu_peak_tracker.stop() - start_measures["cpu"]) / 2**2_0

						# GPU mem
						for i in range(torch.cuda.device_count()					):
												_UpperCamelCase			:			Union[str, Any]   			=						(torch.cuda.memory_allocated(UpperCAmelCase					) - start_measures[str(UpperCAmelCase					)]) / 2**2_0
												_UpperCamelCase			:			List[str]   			=						(torch.cuda.max_memory_allocated(UpperCAmelCase					) - start_measures[str(UpperCAmelCase					)]) / 2**2_0

						return measures






def 						__A							(     UpperCAmelCase     ,UpperCAmelCase					)     ->			List[str]:




						'''simple docstring'''
						print(f'''{description}:'''					)
						print(f'''- Time: {measures['time']:.2f}s'''					)
						for i in range(torch.cuda.device_count()					):
												print(f'''- GPU {i} allocated: {measures[str(UpperCAmelCase					)]:.2f}MiB'''					)
												_UpperCamelCase			:			List[Any]   			=						measures[f'''{i}-peak''']
												print(f'''- GPU {i} peak: {peak:.2f}MiB'''					)
						print(f'''- CPU RAM allocated: {measures['cpu']:.2f}MiB'''					)
						print(f'''- CPU RAM peak: {measures['cpu-peak']:.2f}MiB'''					)



'''simple docstring'''





import random




class 		SCREAMING_SNAKE_CASE     :







				'''simple docstring'''





				@staticmethod
				def  snake_case__				(						lowercase__					:						str					)							->tuple[list[int], list[int]]:


										'''simple docstring'''




										_UpperCamelCase			:			List[str]   			=						[ord(lowercase__					) for i in text]
										_UpperCamelCase			:			Dict   			=						[]
										_UpperCamelCase			:			Optional[int]   			=						[]
										for i in plain:
																_UpperCamelCase			:			Tuple   			=						random.randint(1       ,		300					)
																_UpperCamelCase			:			Any   			=						(i + k) * k
																cipher.append(lowercase__					)
																key.append(lowercase__					)
										return cipher, key







				@staticmethod
				def  snake_case__				(						lowercase__					:						list[int]       ,		lowercase__					:						list[int]					)							->str:


										'''simple docstring'''




										_UpperCamelCase			:			int   			=						[]
										for i in range(len(lowercase__					)					):
																_UpperCamelCase			:			List[Any]   			=						int((cipher[i] - (key[i]) ** 2) / key[i]					)
																plain.append(chr(lowercase__					)					)
										return "".join(lowercase__					)


if __name__ == "__main__":
			lowerCAmelCase_	,	lowerCAmelCase_	:		Optional[int]			=     Onepad().encrypt("""Hello""")
			print(c, k)
			print(Onepad().decrypt(c, k))


