


from __future__ import annotations

from collections import Counter







def   A   (		A__ ):
     UpperCAmelCase						:				Tuple		  =			[True] * n
     UpperCAmelCase						:				Union[str, Any]		  =			False
     UpperCAmelCase						:				Optional[int]		  =			False
     UpperCAmelCase						:				Optional[int]		  =			True

     for i in range(3		,		int(n**0.5 + 1 )		,		2 ):
          UpperCAmelCase						:				List[str]		  =			i * 2
          while index < n:
               UpperCAmelCase						:				List[str]		  =			False
               UpperCAmelCase						:				List[str]		  =			index + i

     UpperCAmelCase						:				Dict		  =			[2]

     for i in range(3		,		A__		,		2 ):
          if is_prime[i]:
               primes.append(A__ )

     return primes







def   A   (		A__ ):
     UpperCAmelCase						:				Optional[Any]		  =			str(A__ )
     UpperCAmelCase						:				Tuple		  =			[]
     UpperCAmelCase						:				Optional[Any]		  =			["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]

     for duplicate in Counter(A__ ) - Counter(set(A__ ) ):
          UpperCAmelCase						:				Union[str, Any]		  =			[int(number_str.replace(A__		,		A__ ) ) for digit in digits]
          replacements.append(A__ )

     return replacements







def   A   (		A__ = 8 ):
     UpperCAmelCase						:				Dict		  =			set()

     # Filter primes with less than 3 replaceable digits
     UpperCAmelCase						:				Optional[Any]		  =			{
         x for x in set(prime_sieve(1_0_0_0_0_0_0 ) ) if len(str(A__ ) ) - len(set(str(A__ ) ) ) >= 3
     }

     for prime in primes:
          if prime in numbers_checked:
               continue

          UpperCAmelCase						:				Optional[Any]		  =			digit_replacements(A__ )

          for family in replacements:
               numbers_checked.update(A__ )
               UpperCAmelCase						:				Optional[Any]		  =			primes.intersection(A__ )

               if len(A__ ) != family_length:
                    continue

               return min(A__ )

     return -1


if __name__ == "__main__":
      print(solution())







import torch

from diffusers import EulerAncestralDiscreteScheduler
from diffusers.utils import torch_device

from .test_schedulers import SchedulerCommonTest




class    A_   ( a_     ):







 """simple docstring"""





 _UpperCamelCase				: Any      =					(EulerAncestralDiscreteScheduler,)
 _UpperCamelCase				: Union[str, Any]      =					10
 def   _UpperCamelCase    (			self					: int       ,    **_a					: str				)    ->			Dict:
      UpperCAmelCase						:				List[Any]		  =			{
          "num_train_timesteps": 1_1_0_0,
          "beta_start": 0.0_0_0_1,
          "beta_end": 0.0_2,
          "beta_schedule": "linear",
      }

      config.update(**_a				)
      return config
 def   _UpperCamelCase    (			self					: str				)    ->			Union[str, Any]:
      for timesteps in [1_0, 5_0, 1_0_0, 1_0_0_0]:
           self.check_over_configs(num_train_timesteps=_a				)
 def   _UpperCamelCase    (			self					: Tuple				)    ->			int:
      for beta_start, beta_end in zip([0.0_0_0_0_1, 0.0_0_0_1, 0.0_0_1]       ,    [0.0_0_0_2, 0.0_0_2, 0.0_2]				):
           self.check_over_configs(beta_start=_a       ,    beta_end=_a				)
 def   _UpperCamelCase    (			self					: Optional[Any]				)    ->			List[str]:
      for schedule in ["linear", "scaled_linear"]:
           self.check_over_configs(beta_schedule=_a				)
 def   _UpperCamelCase    (			self					: Dict				)    ->			str:
      for prediction_type in ["epsilon", "v_prediction"]:
           self.check_over_configs(prediction_type=_a				)
 def   _UpperCamelCase    (			self					: Any				)    ->			Optional[Any]:
      UpperCAmelCase						:				int		  =			self.scheduler_classes[0]
      UpperCAmelCase						:				Optional[int]		  =			self.get_scheduler_config()
      UpperCAmelCase						:				List[Any]		  =			scheduler_class(**_a				)

      scheduler.set_timesteps(self.num_inference_steps				)

      UpperCAmelCase						:				Dict		  =			torch.manual_seed(0				)

      UpperCAmelCase						:				Union[str, Any]		  =			self.dummy_model()
      UpperCAmelCase						:				Dict		  =			self.dummy_sample_deter * scheduler.init_noise_sigma.cpu()
      UpperCAmelCase						:				Optional[Any]		  =			sample.to(_a				)

      for i, t in enumerate(scheduler.timesteps				):
           UpperCAmelCase						:				List[Any]		  =			scheduler.scale_model_input(_a       ,    _a				)

           UpperCAmelCase						:				str		  =			model(_a       ,    _a				)

           UpperCAmelCase						:				int		  =			scheduler.step(_a       ,    _a       ,    _a       ,    generator=_a				)
           UpperCAmelCase						:				Optional[int]		  =			output.prev_sample

      UpperCAmelCase						:				Tuple		  =			torch.sum(torch.abs(_a				)				)
      UpperCAmelCase						:				str		  =			torch.mean(torch.abs(_a				)				)

      assert abs(result_sum.item() - 1_5_2.3_1_9_2				) < 1E-2
      assert abs(result_mean.item() - 0.1_9_8_3				) < 1E-3
 def   _UpperCamelCase    (			self					: Optional[int]				)    ->			Tuple:
      UpperCAmelCase						:				Optional[int]		  =			self.scheduler_classes[0]
      UpperCAmelCase						:				Tuple		  =			self.get_scheduler_config(prediction_type="v_prediction"				)
      UpperCAmelCase						:				str		  =			scheduler_class(**_a				)

      scheduler.set_timesteps(self.num_inference_steps				)

      UpperCAmelCase						:				Dict		  =			torch.manual_seed(0				)

      UpperCAmelCase						:				List[Any]		  =			self.dummy_model()
      UpperCAmelCase						:				Optional[int]		  =			self.dummy_sample_deter * scheduler.init_noise_sigma
      UpperCAmelCase						:				Any		  =			sample.to(_a				)

      for i, t in enumerate(scheduler.timesteps				):
           UpperCAmelCase						:				Union[str, Any]		  =			scheduler.scale_model_input(_a       ,    _a				)

           UpperCAmelCase						:				Union[str, Any]		  =			model(_a       ,    _a				)

           UpperCAmelCase						:				Union[str, Any]		  =			scheduler.step(_a       ,    _a       ,    _a       ,    generator=_a				)
           UpperCAmelCase						:				Optional[int]		  =			output.prev_sample

      UpperCAmelCase						:				Dict		  =			torch.sum(torch.abs(_a				)				)
      UpperCAmelCase						:				Any		  =			torch.mean(torch.abs(_a				)				)

      assert abs(result_sum.item() - 1_0_8.4_4_3_9				) < 1E-2
      assert abs(result_mean.item() - 0.1_4_1_2				) < 1E-3

 def   _UpperCamelCase    (			self					: List[str]				)    ->			Optional[Any]:
      UpperCAmelCase						:				str		  =			self.scheduler_classes[0]
      UpperCAmelCase						:				str		  =			self.get_scheduler_config()
      UpperCAmelCase						:				Union[str, Any]		  =			scheduler_class(**_a				)

      scheduler.set_timesteps(self.num_inference_steps       ,    device=_a				)
      UpperCAmelCase						:				str		  =			torch.manual_seed(0				)

      UpperCAmelCase						:				Optional[int]		  =			self.dummy_model()
      UpperCAmelCase						:				Any		  =			self.dummy_sample_deter * scheduler.init_noise_sigma.cpu()
      UpperCAmelCase						:				Optional[Any]		  =			sample.to(_a				)

      for t in scheduler.timesteps:
           UpperCAmelCase						:				Tuple		  =			scheduler.scale_model_input(_a       ,    _a				)

           UpperCAmelCase						:				int		  =			model(_a       ,    _a				)

           UpperCAmelCase						:				Tuple		  =			scheduler.step(_a       ,    _a       ,    _a       ,    generator=_a				)
           UpperCAmelCase						:				str		  =			output.prev_sample

      UpperCAmelCase						:				Tuple		  =			torch.sum(torch.abs(_a				)				)
      UpperCAmelCase						:				Optional[Any]		  =			torch.mean(torch.abs(_a				)				)

      assert abs(result_sum.item() - 1_5_2.3_1_9_2				) < 1E-2
      assert abs(result_mean.item() - 0.1_9_8_3				) < 1E-3



