





'''simple docstring'''







import numpy as np





class     _UpperCAmelCase							:
		def __init__(  self,__SCREAMING_SNAKE_CASE=5,__SCREAMING_SNAKE_CASE=5			):



					'''simple docstring'''

					__lowerCAmelCase											=				depth
					__lowerCAmelCase											=				0
					__lowerCAmelCase											=				None
					__lowerCAmelCase											=				None
					__lowerCAmelCase											=				min_leaf_size
					__lowerCAmelCase											=				None
		def   lowerCamelCase__			(  self,__SCREAMING_SNAKE_CASE,__SCREAMING_SNAKE_CASE			):



					'''simple docstring'''

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

					return np.mean((labels - prediction) ** 2			)
		def   lowerCamelCase__			(  self,__SCREAMING_SNAKE_CASE,__SCREAMING_SNAKE_CASE			):



					'''simple docstring'''

					if x.ndim != 1:
								print("""Error: Input data set must be one dimensional"""			)
								return
					if len(__SCREAMING_SNAKE_CASE			) != len(__SCREAMING_SNAKE_CASE			):
								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(__SCREAMING_SNAKE_CASE			) < 2 * self.min_leaf_size:
								__lowerCAmelCase											=				np.mean(__SCREAMING_SNAKE_CASE			)
								return

					if self.depth == 1:
								__lowerCAmelCase											=				np.mean(__SCREAMING_SNAKE_CASE			)
								return

					__lowerCAmelCase											=				0
					__lowerCAmelCase											=				self.mean_squared_error(__SCREAMING_SNAKE_CASE,np.mean(__SCREAMING_SNAKE_CASE			)			) * 2
					for i in range(len(__SCREAMING_SNAKE_CASE			)			):
								if len(x[:i]			) < self.min_leaf_size:
											continue
								elif len(x[i:]			) < self.min_leaf_size:
											continue
								else:
											__lowerCAmelCase											=				self.mean_squared_error(x[:i],np.mean(y[:i]			)			)
											__lowerCAmelCase											=				self.mean_squared_error(x[i:],np.mean(y[i:]			)			)
											__lowerCAmelCase											=				error_left + error_right
											if error < min_error:
														__lowerCAmelCase											=				i
														__lowerCAmelCase											=				error

					if best_split != 0:
								__lowerCAmelCase											=				x[:best_split]
								__lowerCAmelCase											=				y[:best_split]
								__lowerCAmelCase											=				x[best_split:]
								__lowerCAmelCase											=				y[best_split:]

								__lowerCAmelCase											=				x[best_split]
								__lowerCAmelCase											=				DecisionTree(
								    depth=self.depth - 1,min_leaf_size=self.min_leaf_size			)
								__lowerCAmelCase											=				DecisionTree(
								    depth=self.depth - 1,min_leaf_size=self.min_leaf_size			)
								self.left.train(__SCREAMING_SNAKE_CASE,__SCREAMING_SNAKE_CASE			)
								self.right.train(__SCREAMING_SNAKE_CASE,__SCREAMING_SNAKE_CASE			)
					else:
								__lowerCAmelCase											=				np.mean(__SCREAMING_SNAKE_CASE			)

					return







		def   lowerCamelCase__			(  self,__SCREAMING_SNAKE_CASE			):



					'''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(__SCREAMING_SNAKE_CASE			)
								else:
											return self.left.predict(__SCREAMING_SNAKE_CASE			)
					else:
								print("""Error: Decision tree not yet trained"""			)
								return None





class     _UpperCAmelCase							:
		@staticmethod
		def   lowerCamelCase__			(  __SCREAMING_SNAKE_CASE,__SCREAMING_SNAKE_CASE			):



					'''simple docstring'''

					__lowerCAmelCase											=				float(0			)
					for label in labels:
								squared_error_sum += (label - prediction) ** 2

					return float(squared_error_sum / labels.size			)





def    _lowerCAmelCase						(						)					->					Any:
			__lowerCAmelCase											=				np.arange(-1.0					,	1.0					,	0.0_05	)
			__lowerCAmelCase											=				np.sin(lowercase	)

			__lowerCAmelCase											=				DecisionTree(depth=10					,	min_leaf_size=10	)
			tree.train(lowercase					,	lowercase	)

			__lowerCAmelCase											=				(np.random.rand(10	) * 2) - 1
			__lowerCAmelCase											=				np.array([tree.predict(lowercase	) for x in test_cases]	)
			__lowerCAmelCase											=				np.mean((predictions - test_cases) ** 2	)

			print("""Test values: """ + str(lowercase	)	)
			print("""Predictions: """ + str(lowercase	)	)
			print("""Average error: """ + str(lowercase	)	)


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

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








'''simple docstring'''







def    _lowerCAmelCase						(						lowercase	)					->					int:
			__lowerCAmelCase											=				len(lowercase	)
			__lowerCAmelCase											=				[0] * length
			__lowerCAmelCase											=				[[False for i in range(lowercase	)] for j in range(lowercase	)]
			for i, c in enumerate(lowercase	):
						__lowerCAmelCase											=				i
						for j in range(i + 1	):
									if c == string[j] and (i - j < 2 or is_palindromic[j + 1][i - 1]):
												__lowerCAmelCase											=				True
												__lowerCAmelCase											=				min(lowercase					,	0 if j == 0 else (cut[j - 1] + 1)	)
						__lowerCAmelCase											=				mincut
			return cut[length - 1]


if __name__ == "__main__":
	_a					: int      =    input("""Enter the string: """).strip()
	_a					: Dict      =    find_minimum_partitions(s)
	print(f'Minimum number of partitions required for the \'{s}\' is {ans}')

