



'''simple docstring'''




import fcntl
import os
import socket

import torch
import torch.distributed as dist



def      a      (			*lowerCamelCase__   ):
			'''simple docstring'''





			with open(lowerCamelCase__						,				"""r"""   ) as fh:
						fcntl.flock(lowerCamelCase__						,				fcntl.LOCK_EX   )
						try:
									print(*lowerCamelCase__   )
						finally:
									fcntl.flock(lowerCamelCase__						,				fcntl.LOCK_UN   )


lowerCamelCase							:Tuple       = int(os.environ['''LOCAL_RANK'''])
torch.cuda.set_device(local_rank)
lowerCamelCase							:int       = torch.device('''cuda''', local_rank)
lowerCamelCase							:Dict       = socket.gethostname()

lowerCamelCase							:Any       = F"[{hostname}-{local_rank}]"

try:
			# test distributed
			dist.init_process_group('''nccl''')
			dist.all_reduce(torch.ones(1).to(device), op=dist.ReduceOp.SUM)
			dist.barrier()

			# test cuda is available and can allocate memory
			torch.cuda.is_available()
			torch.ones(1).cuda(local_rank)

			# global rank
			lowerCamelCase							:Optional[Any]       = dist.get_rank()
			lowerCamelCase							:Optional[Any]       = dist.get_world_size()

			printflock(F"{gpu} is OK (global rank: {rank}/{world_size})")

			dist.barrier()
			if rank == 0:
						printflock(F"pt={torch.__version__}, cuda={torch.version.cuda}, nccl={torch.cuda.nccl.version()}")

except Exception:
			printflock(F"{gpu} is broken")
			raise




'''simple docstring'''




from __future__ import annotations

from functools import lru_cache
from math import ceil

lowerCamelCase							:List[str]       = 1_0_0

lowerCamelCase							:Dict       = set(range(3, NUM_PRIMES, 2))
primes.add(2)
lowerCamelCase							:int

for prime in range(3, ceil(NUM_PRIMES**0.5), 2):
						if prime not in primes:
												continue
						primes.difference_update(set(range(prime * prime, NUM_PRIMES, prime)))



@lru_cache(maxsize=1_00   )
def      a      (			lowerCamelCase__   ):
			'''simple docstring'''





			if number_to_partition < 0:
						return set()
			elif number_to_partition == 0:
						return {1}

			A_     :						set[int]     =					set()
			A_     :						int
			A_     :						int

			for prime in primes:
						if prime > number_to_partition:
									continue
						for sub in partition(number_to_partition - prime   ):
									ret.add(sub * prime   )

			return ret



def      a      (			lowerCamelCase__ = 50_00   ):
			'''simple docstring'''





			for number_to_partition in range(1						,				lowerCamelCase__   ):
						if len(partition(lowerCamelCase__   )   ) > number_unique_partitions:
									return number_to_partition
			return None


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