




'''simple docstring'''







from __future__ import annotations

from collections import Counter





def 						snake_case__ (lowerCAmelCase_	):
    UpperCamelCase__      =			[True] * n
    UpperCamelCase__      =			False
    UpperCamelCase__      =			False
    UpperCamelCase__      =			True

    for i in range(3					,  int(n**0.5 + 1	)					,  2	):
        UpperCamelCase__      =			i * 2
        while index < n:
            UpperCamelCase__      =			False
            UpperCamelCase__      =			index + i

    UpperCamelCase__      =			[2]

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

    return primes





def 						snake_case__ (lowerCAmelCase_	):
    UpperCamelCase__      =			str(snake_case_	)
    UpperCamelCase__      =			[]
    UpperCamelCase__      =			['''0''', '''1''', '''2''', '''3''', '''4''', '''5''', '''6''', '''7''', '''8''', '''9''']

    for duplicate in Counter(snake_case_	) - Counter(set(snake_case_	)	):
        UpperCamelCase__      =			[int(number_str.replace(snake_case_					,  snake_case_	)	) for digit in digits]
        replacements.append(snake_case_	)

    return replacements





def 						snake_case__ (lowerCAmelCase_ = 8	):
    UpperCamelCase__      =			set()

    # Filter primes with less than 3 replaceable digits
    UpperCamelCase__      =			{
        x for x in set(prime_sieve(1_00_00_00	)	) if len(str(snake_case_	)	) - len(set(str(snake_case_	)	)	) >= 3
    }

    for prime in primes:
        if prime in numbers_checked:
            continue

        UpperCamelCase__      =			digit_replacements(snake_case_	)

        for family in replacements:
            numbers_checked.update(snake_case_	)
            UpperCamelCase__      =			primes.intersection(snake_case_	)

            if len(snake_case_	) != family_length:
                continue

            return min(snake_case_	)

    return -1


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









'''simple docstring'''







import numpy as np  # noqa: E402

from ...configuration_utils import ConfigMixin, register_to_config
from ...schedulers.scheduling_utils import SchedulerMixin


try:
      import librosa  # noqa: E402

      lowercase__     :  Optional[Any]    					=			True
      lowercase__     :  int    					=			''
except Exception as e:
      lowercase__     :  Union[str, Any]    					=			False
      lowercase__     :  List[Any]    					=			(
          F'''Cannot import librosa because {e}. Make sure to correctly install librosa to be able to install it.'''
      )


from PIL import Image  # noqa: E402

class       lowerCamelCase_							(	lowerCAmelCase_					,    lowerCAmelCase_  ):






   '''simple docstring'''

   A :     int				=	"mel_config.json"


   @register_to_config
   def __init__(  self     ,						__UpperCamelCase = 2_56     ,						__UpperCamelCase = 2_56     ,						__UpperCamelCase = 2_20_50     ,						__UpperCamelCase = 20_48     ,						__UpperCamelCase = 5_12     ,						__UpperCamelCase = 80     ,						__UpperCamelCase = 32     ,						):
       UpperCamelCase__      =			hop_length
       UpperCamelCase__      =			sample_rate
       UpperCamelCase__      =			n_fft
       UpperCamelCase__      =			top_db
       UpperCamelCase__      =			n_iter
       self.set_resolution(__UpperCamelCase     ,						__UpperCamelCase )
       UpperCamelCase__      =			None

       if not _librosa_can_be_imported:
           raise ValueError(_import_error )


   def 	_UpperCamelCase       (  self     ,						__UpperCamelCase     ,						__UpperCamelCase ):
       UpperCamelCase__      =			x_res
       UpperCamelCase__      =			y_res
       UpperCamelCase__      =			self.y_res
       UpperCamelCase__      =			self.x_res * self.hop_length - 1


   def 	_UpperCamelCase       (  self     ,						__UpperCamelCase = None     ,						__UpperCamelCase = None ):
       if audio_file is not None:
           UpperCamelCase__    ,  UpperCamelCase__      =			librosa.load(__UpperCamelCase     ,						mono=__UpperCamelCase     ,						sr=self.sr )
       else:
           UpperCamelCase__      =			raw_audio

       # Pad with silence if necessary.
       if len(self.audio ) < self.x_res * self.hop_length:
           UpperCamelCase__      =			np.concatenate([self.audio, np.zeros((self.x_res * self.hop_length - len(self.audio ),) )] )


   def 	_UpperCamelCase       (  self ):
       return len(self.audio ) // self.slice_size


   def 	_UpperCamelCase       (  self     ,						__UpperCamelCase = 0 ):
       return self.audio[self.slice_size * slice : self.slice_size * (slice + 1)]


   def 	_UpperCamelCase       (  self ):
       return self.sr


   def 	_UpperCamelCase       (  self     ,						__UpperCamelCase ):
       UpperCamelCase__      =			librosa.feature.melspectrogram(
           y=self.get_audio_slice(__UpperCamelCase )     ,						sr=self.sr     ,						n_fft=self.n_fft     ,						hop_length=self.hop_length     ,						n_mels=self.n_mels )
       UpperCamelCase__      =			librosa.power_to_db(__UpperCamelCase     ,						ref=np.max     ,						top_db=self.top_db )
       UpperCamelCase__      =			(((log_S + self.top_db) * 2_55 / self.top_db).clip(0     ,						2_55 ) + 0.5).astype(np.uinta )
       UpperCamelCase__      =			Image.fromarray(__UpperCamelCase )
       return image







   def 	_UpperCamelCase       (  self     ,						__UpperCamelCase ):
       UpperCamelCase__      =			np.frombuffer(image.tobytes()     ,						dtype="uint8" ).reshape((image.height, image.width) )
       UpperCamelCase__      =			bytedata.astype("float" ) * self.top_db / 2_55 - self.top_db
       UpperCamelCase__      =			librosa.db_to_power(__UpperCamelCase )
       UpperCamelCase__      =			librosa.feature.inverse.mel_to_audio(
           __UpperCamelCase     ,						sr=self.sr     ,						n_fft=self.n_fft     ,						hop_length=self.hop_length     ,						n_iter=self.n_iter )
       return audio




