


'''simple docstring'''







import gc
import threading
import time

import psutil
import torch







class A__       :






      def __init__( self			:int	)       ->					Tuple:




             '''simple docstring'''
             _a    : int     					=psutil.Process()
             _a    : List[Any]     					=False






      def __UpperCAmelCase       ( self			:Dict	)       ->					List[str]:




             '''simple docstring'''
             _a    : List[Any]     					=-1

             while True:
                    _a    : int     					=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 __UpperCAmelCase       ( self			:List[str]	)       ->					str:




             '''simple docstring'''
             _a    : List[str]     					=True
             _a    : Optional[int]     					=threading.Thread(target=self.peak_monitor	)
             _a    : Dict     					=True
             self.thread.start()






      def __UpperCAmelCase       ( self			:Dict	)       ->					Any:




             '''simple docstring'''
             _a    : Any     					=False
             self.thread.join()
             return self.cpu_memory_peak

A__:    int					    =       PeakCPUMemory()


def 	SCREAMING_SNAKE_CASE_					(  )  ->			Union[str, Any]:
       # Time
       _a    : Any     					={"""time""": time.time()}

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

       # CPU mem
       _a    : Optional[Any]     					=psutil.Process().memory_info().rss
       cpu_peak_tracker.start()

       # GPU mem
       for i in range(torch.cuda.device_count()  ):
              _a    : Union[str, Any]     					=torch.cuda.memory_allocated(_UpperCAmelCase  )
       torch.cuda.reset_peak_memory_stats()

       return measures


def 	SCREAMING_SNAKE_CASE_					(  _UpperCAmelCase	:	List[Any]  )  ->			List[Any]:
       # Time
       _a    : Optional[int]     					={"""time""": time.time() - start_measures["""time"""]}

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

       # CPU mem
       _a    : int     					=(psutil.Process().memory_info().rss - start_measures["""cpu"""]) / 2**20
       _a    : int     					=(cpu_peak_tracker.stop() - start_measures["""cpu"""]) / 2**20

       # GPU mem
       for i in range(torch.cuda.device_count()  ):
              _a    : str     					=(torch.cuda.memory_allocated(_UpperCAmelCase  ) - start_measures[str(_UpperCAmelCase  )]) / 2**20
              _a    : List[Any]     					=(torch.cuda.max_memory_allocated(_UpperCAmelCase  ) - start_measures[str(_UpperCAmelCase  )]) / 2**20

       return measures


def 	SCREAMING_SNAKE_CASE_					(  _UpperCAmelCase	:	int    ,_UpperCAmelCase	:	Tuple  )  ->			str:
       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"  )
              _a    : Union[str, 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'''







from math import isqrt


def 	SCREAMING_SNAKE_CASE_					(  _UpperCAmelCase	:	int  )  ->			bool:
       return all(number % divisor != 0 for divisor in range(2    ,isqrt(_UpperCAmelCase  ) + 1  )  )


def 	SCREAMING_SNAKE_CASE_					(  _UpperCAmelCase	:	int = 10**6  )  ->			int:
       _a    : List[Any]     					=0
       _a    : str     					=1
       _a    : Optional[Any]     					=7
       while prime_candidate < max_prime:
              primes_count += is_prime(_UpperCAmelCase  )

              cube_index += 1
              prime_candidate += 6 * cube_index

       return primes_count


if __name__ == "__main__":
   print(F"{solution() = }")


