


import math
from itertools import permutations






def 	a__ (							A__							):







			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(A__							) + 1							),			6							):
						if number % i == 0 or number % (i + 2) == 0:
									return False
			return True






def 	a__ (							A__,			A__							):
			SCREAMING_SNAKE_CASE_		,			SCREAMING_SNAKE_CASE_		:    str 		=				0, len(A__							) - 1
			while left <= right:
						SCREAMING_SNAKE_CASE_		:    Union[str, Any] 		=				(left + right) // 2
						if prime_list[middle] == target:
									return True
						elif prime_list[middle] < target:
									SCREAMING_SNAKE_CASE_		:    Optional[Any] 		=				middle + 1
						else:
									SCREAMING_SNAKE_CASE_		:    Dict 		=				middle - 1

			return False






def 	a__ (							):
			SCREAMING_SNAKE_CASE_		:    List[Any] 		=				[n for n in range(1_0_0_1,			1_0_0_0_0,			2							) if is_prime(A__							)]
			SCREAMING_SNAKE_CASE_		:    Union[str, Any] 		=				[]

			for number in prime_list:
						SCREAMING_SNAKE_CASE_		:    Any 		=				[]

						for prime_member in permutations(list(str(A__							)							)							):
									SCREAMING_SNAKE_CASE_		:    Tuple 		=				int(''.join(A__							)							)

									if prime % 2 == 0:
												continue

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

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

			SCREAMING_SNAKE_CASE_		:    Optional[int] 		=				[]
			for candidate in candidates:
						SCREAMING_SNAKE_CASE_		:    List[str] 		=				len(A__							)
						SCREAMING_SNAKE_CASE_		:    Dict 		=				False

						for i in range(A__							):
									for j in range(i + 1,			A__							):
												for k in range(j + 1,			A__							):
															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]]							)							)
																		SCREAMING_SNAKE_CASE_		:    Dict 		=				True

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

			SCREAMING_SNAKE_CASE_		:    Tuple 		=				set()
			for seq in passed:
						answer.add(''.join([str(A__							) for i in seq]							)							)

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


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




import numpy as np







class   __lowercase						:





							"""simple docstring"""







							def __init__(			self ,	lowerCAmelCase__=5 ,	lowerCAmelCase__=5					):





										"""simple docstring"""




										SCREAMING_SNAKE_CASE_		:    List[str] 		=				depth
										SCREAMING_SNAKE_CASE_		:    Union[str, Any] 		=				0
										SCREAMING_SNAKE_CASE_		:    int 		=				None
										SCREAMING_SNAKE_CASE_		:    List[Any] 		=				None
										SCREAMING_SNAKE_CASE_		:    Optional[int] 		=				min_leaf_size
										SCREAMING_SNAKE_CASE_		:    Optional[Any] 		=				None






							def 				UpperCamelCase__    (			self ,	lowerCAmelCase__ ,	lowerCAmelCase__					):





										"""simple docstring"""




										if labels.ndim != 1:
													print('Error: Input labels must be one dimensional'					)

										return np.mean((labels - prediction) ** 2					)






							def 				UpperCamelCase__    (			self ,	lowerCAmelCase__ ,	lowerCAmelCase__					):





										"""simple docstring"""




										if x.ndim != 1:
													print('Error: Input data set must be one dimensional'					)
													return
										if len(lowerCAmelCase__					) != len(lowerCAmelCase__					):
													print('Error: X and y have different lengths'					)
													return
										if y.ndim != 1:
													print('Error: Data set labels must be one dimensional'					)
													return

										if len(lowerCAmelCase__					) < 2 * self.min_leaf_size:
													SCREAMING_SNAKE_CASE_		:    Optional[int] 		=				np.mean(lowerCAmelCase__					)
													return

										if self.depth == 1:
													SCREAMING_SNAKE_CASE_		:    Tuple 		=				np.mean(lowerCAmelCase__					)
													return

										SCREAMING_SNAKE_CASE_		:    int 		=				0
										SCREAMING_SNAKE_CASE_		:    List[str] 		=				self.mean_squared_error(lowerCAmelCase__ ,	np.mean(lowerCAmelCase__					)					) * 2
										for i in range(len(lowerCAmelCase__					)					):
													if len(x[:i]					) < self.min_leaf_size:
																continue
													elif len(x[i:]					) < self.min_leaf_size:
																continue
													else:
																SCREAMING_SNAKE_CASE_		:    Dict 		=				self.mean_squared_error(x[:i] ,	np.mean(y[:i]					)					)
																SCREAMING_SNAKE_CASE_		:    int 		=				self.mean_squared_error(x[i:] ,	np.mean(y[i:]					)					)
																SCREAMING_SNAKE_CASE_		:    Any 		=				error_left + error_right
																if error < min_error:
																			SCREAMING_SNAKE_CASE_		:    Union[str, Any] 		=				i
																			SCREAMING_SNAKE_CASE_		:    int 		=				error

										if best_split != 0:
													SCREAMING_SNAKE_CASE_		:    int 		=				x[:best_split]
													SCREAMING_SNAKE_CASE_		:    Optional[Any] 		=				y[:best_split]
													SCREAMING_SNAKE_CASE_		:    Union[str, Any] 		=				x[best_split:]
													SCREAMING_SNAKE_CASE_		:    str 		=				y[best_split:]

													SCREAMING_SNAKE_CASE_		:    str 		=				x[best_split]
													SCREAMING_SNAKE_CASE_		:    Optional[Any] 		=				DecisionTree(
													    depth=self.depth - 1 ,	min_leaf_size=self.min_leaf_size					)
													SCREAMING_SNAKE_CASE_		:    int 		=				DecisionTree(
													    depth=self.depth - 1 ,	min_leaf_size=self.min_leaf_size					)
													self.left.train(lowerCAmelCase__ ,	lowerCAmelCase__					)
													self.right.train(lowerCAmelCase__ ,	lowerCAmelCase__					)
										else:
													SCREAMING_SNAKE_CASE_		:    List[Any] 		=				np.mean(lowerCAmelCase__					)

										return






							def 				UpperCamelCase__    (			self ,	lowerCAmelCase__					):





										"""simple docstring"""




										if self.prediction is not None:
													return self.prediction
										elif self.left or self.right is not None:
													if x >= self.decision_boundary:
																return self.right.predict(lowerCAmelCase__					)
													else:
																return self.left.predict(lowerCAmelCase__					)
										else:
													print('Error: Decision tree not yet trained'					)
													return None







class   __lowercase						:





							"""simple docstring"""







							@staticmethod
							def 				UpperCamelCase__    (			lowerCAmelCase__ ,	lowerCAmelCase__					):





										"""simple docstring"""




										SCREAMING_SNAKE_CASE_		:    Optional[Any] 		=				float(0					)
										for label in labels:
													squared_error_sum += (label - prediction) ** 2

										return float(squared_error_sum / labels.size					)







def 	a__ (							):
			SCREAMING_SNAKE_CASE_		:    List[str] 		=				np.arange(-1.0,			1.0,			0.0_05							)
			SCREAMING_SNAKE_CASE_		:    Dict 		=				np.sin(A__							)

			SCREAMING_SNAKE_CASE_		:    str 		=				DecisionTree(depth=1_0,			min_leaf_size=1_0							)
			tree.train(A__,			A__							)

			SCREAMING_SNAKE_CASE_		:    Dict 		=				(np.random.rand(1_0							) * 2) - 1
			SCREAMING_SNAKE_CASE_		:    Any 		=				np.array([tree.predict(A__							) for x in test_cases]							)
			SCREAMING_SNAKE_CASE_		:    Optional[int] 		=				np.mean((predictions - test_cases) ** 2							)

			print('Test values: ' + str(A__							)							)
			print('Predictions: ' + str(A__							)							)
			print('Average error: ' + str(A__							)							)


if __name__ == "__main__":
				main()
				import doctest

				doctest.testmod(name='mean_squarred_error', verbose=True)





