

'''simple docstring'''
import itertools
import random
import unittest

import numpy as np

from transformers import EncodecFeatureExtractor
from transformers.testing_utils import require_torch
from transformers.utils.import_utils import is_torch_available

from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin


if is_torch_available():
					import torch


_lowerCamelCase	 =			random.Random()


def       a__    (  _SCREAMING_SNAKE_CASE					:    str     ,							_SCREAMING_SNAKE_CASE					:    List[str]=1.0     ,							_SCREAMING_SNAKE_CASE					:    Tuple=None     ,							_SCREAMING_SNAKE_CASE					:    Optional[Any]=None							)			-> Any:


	"""simple docstring"""





	if rng is None:
		UpperCAmelCase_			:	Optional[Any]      =   global_rng

	UpperCAmelCase_			:	Any      =   []
	for batch_idx in range(shape[0]							):
		values.append([]							)
		for _ in range(shape[1]							):
			values[-1].append(rng.random() * scale							)

	return values
@require_torch
class  _snake_case						(unittest.TestCase):






			def __init__(   self       ,_snake_case       ,_snake_case=7       ,_snake_case=4_00       ,_snake_case=20_00       ,_snake_case=1       ,_snake_case=0.0       ,_snake_case=2_40_00       ,_snake_case=True       ,):
				UpperCAmelCase_			:	List[Any]      =   parent
				UpperCAmelCase_			:	Optional[Any]      =   batch_size
				UpperCAmelCase_			:	Optional[int]      =   min_seq_length
				UpperCAmelCase_			:	List[Any]      =   max_seq_length
				UpperCAmelCase_			:	str      =   (self.max_seq_length - self.min_seq_length) // (self.batch_size - 1)
				UpperCAmelCase_			:	Optional[Any]      =   feature_size
				UpperCAmelCase_			:	Union[str, Any]      =   padding_value
				UpperCAmelCase_			:	int      =   sampling_rate
				UpperCAmelCase_			:	Any      =   return_attention_mask






			def 						UpperCamelCase__				(   self			):
				return {
				    "feature_size": self.feature_size,
				    "padding_value": self.padding_value,
				    "sampling_rate": self.sampling_rate,
				    "return_attention_mask": self.return_attention_mask,
				}






			def 						UpperCamelCase__				(   self       ,_snake_case=False       ,_snake_case=False			):
				def _flatten(_snake_case			):
					return list(itertools.chain(*_snake_case			)			)

				if equal_length:
					UpperCAmelCase_			:	Any      =   floats_list((self.batch_size, self.max_seq_length)			)
				else:
					# make sure that inputs increase in size
					UpperCAmelCase_			:	Tuple      =   [
					    _flatten(floats_list((x, self.feature_size)			)			)
					    for x in range(self.min_seq_length       ,self.max_seq_length       ,self.seq_length_diff			)
					]

				if numpify:
					UpperCAmelCase_			:	Any      =   [np.asarray(_snake_case			) for x in audio_inputs]

				return audio_inputs




@require_torch
class  _snake_case						(__SCREAMING_SNAKE_CASE       ,       unittest.TestCase):
			__A   :     Any          =EncodecFeatureExtractor






			def 						UpperCamelCase__				(   self			):
				UpperCAmelCase_			:	Optional[int]      =   EnCodecFeatureExtractionTester(self			)






			def 						UpperCamelCase__				(   self			):
				# Tests that all call wrap to encode_plus and batch_encode_plus
				UpperCAmelCase_			:	Union[str, Any]      =   self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()			)
				# create three inputs of length 800, 1000, and 1200
				UpperCAmelCase_			:	int      =   [floats_list((1, x)			)[0] for x in range(8_00       ,14_00       ,2_00			)]
				UpperCAmelCase_			:	Union[str, Any]      =   [np.asarray(_snake_case			) for audio_input in audio_inputs]

				# Test not batched input
				UpperCAmelCase_			:	int      =   feat_extract(audio_inputs[0]       ,return_tensors="np"			).input_values
				UpperCAmelCase_			:	Optional[int]      =   feat_extract(np_audio_inputs[0]       ,return_tensors="np"			).input_values
				self.assertTrue(np.allclose(_snake_case       ,_snake_case       ,atol=1E-3			)			)

				# Test batched
				UpperCAmelCase_			:	str      =   feat_extract(_snake_case       ,padding=_snake_case       ,return_tensors="np"			).input_values
				UpperCAmelCase_			:	Union[str, Any]      =   feat_extract(_snake_case       ,padding=_snake_case       ,return_tensors="np"			).input_values
				for enc_seq_a, enc_seq_a in zip(_snake_case       ,_snake_case			):
					self.assertTrue(np.allclose(_snake_case       ,_snake_case       ,atol=1E-3			)			)






			def 						UpperCamelCase__				(   self			):
				UpperCAmelCase_			:	Union[str, Any]      =   self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict()			)
				UpperCAmelCase_			:	Union[str, Any]      =   np.random.rand(1_00			).astype(np.floataa			)
				UpperCAmelCase_			:	Tuple      =   np_audio_inputs.tolist()

				for inputs in [py_audio_inputs, np_audio_inputs]:
					UpperCAmelCase_			:	int      =   feature_extractor.pad([{"input_values": inputs}]       ,return_tensors="np"			)
					self.assertTrue(np_processed.input_values.dtype == np.floataa			)
					UpperCAmelCase_			:	List[Any]      =   feature_extractor.pad([{"input_values": inputs}]       ,return_tensors="pt"			)
					self.assertTrue(pt_processed.input_values.dtype == torch.floataa			)






			def 						UpperCamelCase__				(   self       ,_snake_case			):
				from datasets import load_dataset

				UpperCAmelCase_			:	Optional[Any]      =   load_dataset("hf-internal-testing/librispeech_asr_dummy"       ,"clean"       ,split="validation"			)
				# automatic decoding with librispeech
				UpperCAmelCase_			:	List[Any]      =   ds.sort("id"			).select(range(_snake_case			)			)[:num_samples]["audio"]

				return [x["array"] for x in audio_samples]






			def 						UpperCamelCase__				(   self			):
				# fmt: off
				UpperCAmelCase_			:	int      =   torch.tensor(
				    [2.38_04E-03, 2.07_52E-03, 1.98_36E-03, 2.10_57E-03, 1.61_74E-03,
				     3.05_18E-04, 9.15_53E-05, 3.35_69E-04, 9.76_56E-04, 1.83_11E-03,
				     2.01_42E-03, 2.10_57E-03, 1.73_95E-03, 4.57_76E-04, -3.96_73E-04,
				     4.57_76E-04, 1.00_71E-03, 9.15_53E-05, 4.88_28E-04, 1.15_97E-03,
				     7.32_42E-04, 9.46_04E-04, 1.80_05E-03, 1.83_11E-03, 8.85_01E-04,
				     4.27_25E-04, 4.88_28E-04, 7.32_42E-04, 1.09_86E-03, 2.10_57E-03]			)
				# fmt: on
				UpperCAmelCase_			:	Dict      =   self._load_datasamples(1			)
				UpperCAmelCase_			:	Optional[int]      =   EncodecFeatureExtractor()
				UpperCAmelCase_			:	Dict      =   feature_extractor(_snake_case       ,return_tensors="pt"			).input_values
				self.assertEquals(input_values.shape       ,(1, 1, 9_36_80)			)
				self.assertTrue(torch.allclose(input_values[0, 0, :30]       ,_snake_case       ,atol=1E-6			)			)






			def 						UpperCamelCase__				(   self			):
				# fmt: off
				UpperCAmelCase_			:	List[Any]      =   torch.tensor(
				    [2.38_04E-03, 2.07_52E-03, 1.98_36E-03, 2.10_57E-03, 1.61_74E-03,
				     3.05_18E-04, 9.15_53E-05, 3.35_69E-04, 9.76_56E-04, 1.83_11E-03,
				     2.01_42E-03, 2.10_57E-03, 1.73_95E-03, 4.57_76E-04, -3.96_73E-04,
				     4.57_76E-04, 1.00_71E-03, 9.15_53E-05, 4.88_28E-04, 1.15_97E-03,
				     7.32_42E-04, 9.46_04E-04, 1.80_05E-03, 1.83_11E-03, 8.85_01E-04,
				     4.27_25E-04, 4.88_28E-04, 7.32_42E-04, 1.09_86E-03, 2.10_57E-03]			)
				# fmt: on
				UpperCAmelCase_			:	int      =   self._load_datasamples(1			)
				UpperCAmelCase_			:	str      =   [np.tile(input_audio[0][None]       ,reps=(2, 1)			)]
				input_audio[0][1] *= 0.5
				UpperCAmelCase_			:	List[Any]      =   EncodecFeatureExtractor(feature_size=2			)
				UpperCAmelCase_			:	List[str]      =   feature_extractor(_snake_case       ,return_tensors="pt"			).input_values
				self.assertEquals(input_values.shape       ,(1, 2, 9_36_80)			)
				self.assertTrue(torch.allclose(input_values[0, 0, :30]       ,_snake_case       ,atol=1E-6			)			)
				self.assertTrue(torch.allclose(input_values[0, 1, :30]       ,EXPECTED_INPUT_VALUES * 0.5       ,atol=1E-6			)			)






			def 						UpperCamelCase__				(   self			):
				UpperCAmelCase_			:	Union[str, Any]      =   self._load_datasamples(2			)
				# would be easier if the stride was like
				UpperCAmelCase_			:	Optional[Any]      =   EncodecFeatureExtractor(feature_size=1       ,chunk_length_s=1       ,overlap=0.01			)

				# pad and trunc raise an error ?
				with self.assertRaisesRegex(
				    _snake_case       ,"^Both padding and truncation were set. Make sure you only set one.$"       ,):
					UpperCAmelCase_			:	str      =   feature_extractor(
					    _snake_case       ,padding="max_length"       ,truncation=_snake_case       ,return_tensors="pt"			).input_values

				# truncate to chunk
				UpperCAmelCase_			:	List[Any]      =   feature_extractor(_snake_case       ,truncation=_snake_case       ,return_tensors="pt"			).input_values
				self.assertEquals(truncated_outputs.shape       ,(2, 1, 7_15_20)			)  # 2 chunks

				# force truncate to max_length
				UpperCAmelCase_			:	str      =   feature_extractor(
				    _snake_case       ,truncation=_snake_case       ,max_length=4_80_00       ,return_tensors="pt"			).input_values
				self.assertEquals(truncated_outputs.shape       ,(2, 1, 4_80_00)			)

				# pad to chunk
				UpperCAmelCase_			:	Optional[Any]      =   feature_extractor(_snake_case       ,padding=_snake_case       ,return_tensors="pt"			).input_values
				self.assertEquals(padded_outputs.shape       ,(2, 1, 9_52_80)			)

				# pad to chunk
				UpperCAmelCase_			:	str      =   feature_extractor(_snake_case       ,return_tensors="pt"			).input_values
				self.assertEquals(truncated_outputs.shape       ,(2, 1, 9_52_80)			)

				# force pad to max length
				UpperCAmelCase_			:	Tuple      =   feature_extractor(
				    _snake_case       ,padding="max_length"       ,max_length=10_00_00       ,return_tensors="pt"			).input_values
				self.assertEquals(truncated_outputs.shape       ,(2, 1, 10_00_00)			)

				# force no pad
				with self.assertRaisesRegex(
				    _snake_case       ,"^Unable to create tensor, you should probably activate padding with 'padding=True' to have batched tensors with the same length.$"       ,):
					UpperCAmelCase_			:	Tuple      =   feature_extractor(_snake_case       ,padding=_snake_case       ,return_tensors="pt"			).input_values

				UpperCAmelCase_			:	str      =   feature_extractor(input_audio[0]       ,padding=_snake_case       ,return_tensors="pt"			).input_values
				self.assertEquals(truncated_outputs.shape       ,(1, 1, 9_36_80)			)

				# no pad if no chunk_length_s
				UpperCAmelCase_			:	int      =   None
				with self.assertRaisesRegex(
				    _snake_case       ,"^Unable to create tensor, you should probably activate padding with 'padding=True' to have batched tensors with the same length.$"       ,):
					UpperCAmelCase_			:	Optional[Any]      =   feature_extractor(_snake_case       ,padding=_snake_case       ,return_tensors="pt"			).input_values

				UpperCAmelCase_			:	Dict      =   feature_extractor(input_audio[0]       ,padding=_snake_case       ,return_tensors="pt"			).input_values
				self.assertEquals(truncated_outputs.shape       ,(1, 1, 9_36_80)			)

				# no pad if no overlap
				UpperCAmelCase_			:	Optional[Any]      =   2
				UpperCAmelCase_			:	Dict      =   None
				with self.assertRaisesRegex(
				    _snake_case       ,"^Unable to create tensor, you should probably activate padding with 'padding=True' to have batched tensors with the same length.$"       ,):
					UpperCAmelCase_			:	Any      =   feature_extractor(_snake_case       ,padding=_snake_case       ,return_tensors="pt"			).input_values

				UpperCAmelCase_			:	Dict      =   feature_extractor(input_audio[0]       ,padding=_snake_case       ,return_tensors="pt"			).input_values
				self.assertEquals(truncated_outputs.shape       ,(1, 1, 9_36_80)			)







'''simple docstring'''
import math
from itertools import permutations


def       a__    (  _SCREAMING_SNAKE_CASE					:    int							)			-> bool:


	"""simple docstring"""





	if 1 < number < 4:
		# 2 and 3 are primes
		return True
	elif number < 2 or number % 2 == 0 or number % 3 == 0:
		# Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
		return False

	# All primes number are in format of 6k +/- 1
	for i in range(5     ,							int(math.sqrt(_SCREAMING_SNAKE_CASE							) + 1							)     ,							6							):
		if number % i == 0 or number % (i + 2) == 0:
			return False
	return True


def       a__    (  _SCREAMING_SNAKE_CASE					:    int     ,							_SCREAMING_SNAKE_CASE					:    list							)			-> bool:


	"""simple docstring"""





	UpperCAmelCase_ , UpperCAmelCase_			:	Any      =   0, len(_SCREAMING_SNAKE_CASE							) - 1
	while left <= right:
		UpperCAmelCase_			:	List[str]      =   (left + right) // 2
		if prime_list[middle] == target:
			return True
		elif prime_list[middle] < target:
			UpperCAmelCase_			:	Dict      =   middle + 1
		else:
			UpperCAmelCase_			:	int      =   middle - 1

	return False


def       a__    (  )			-> Tuple:


	"""simple docstring"""





	UpperCAmelCase_			:	Dict      =   [n for n in range(10_01     ,							1_00_00     ,							2							) if is_prime(_SCREAMING_SNAKE_CASE							)]
	UpperCAmelCase_			:	Optional[int]      =   []

	for number in prime_list:
		UpperCAmelCase_			:	Optional[Any]      =   []

		for prime_member in permutations(list(str(_SCREAMING_SNAKE_CASE							)							)							):
			UpperCAmelCase_			:	List[Any]      =   int("".join(_SCREAMING_SNAKE_CASE							)							)

			if prime % 2 == 0:
				continue

			if search(_SCREAMING_SNAKE_CASE     ,							_SCREAMING_SNAKE_CASE							):
				tmp_numbers.append(_SCREAMING_SNAKE_CASE							)

		tmp_numbers.sort()
		if len(_SCREAMING_SNAKE_CASE							) >= 3:
			candidates.append(_SCREAMING_SNAKE_CASE							)

	UpperCAmelCase_			:	Tuple      =   []
	for candidate in candidates:
		UpperCAmelCase_			:	Union[str, Any]      =   len(_SCREAMING_SNAKE_CASE							)
		UpperCAmelCase_			:	Any      =   False

		for i in range(_SCREAMING_SNAKE_CASE							):
			for j in range(i + 1     ,							_SCREAMING_SNAKE_CASE							):
				for k in range(j + 1     ,							_SCREAMING_SNAKE_CASE							):
					if (
					    abs(candidate[i] - candidate[j]							)
					    == abs(candidate[j] - candidate[k]							)
					    and len({candidate[i], candidate[j], candidate[k]}							) == 3
					):
						passed.append(
						    sorted([candidate[i], candidate[j], candidate[k]]							)							)
						UpperCAmelCase_			:	Optional[Any]      =   True

					if found:
						break
				if found:
					break
			if found:
				break

	UpperCAmelCase_			:	Any      =   set()
	for seq in passed:
		answer.add("".join([str(_SCREAMING_SNAKE_CASE							) for i in seq]							)							)

	return max(int(_SCREAMING_SNAKE_CASE							) for x in answer							)


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




