
"""simple docstring"""





from math import pow



def 						_lowerCAmelCase				(				UpperCamelCase_  ,				UpperCamelCase_  ,				UpperCamelCase_  ,				UpperCamelCase_  ,				UpperCamelCase_  ,				):
		if current_sum == needed_sum:
				# If the sum of the powers is equal to needed_sum, then we have a solution.
				solutions_count += 1
				return current_sum, solutions_count

		__SCREAMING_SNAKE_CASE            = int(pow(UpperCamelCase_  ,				UpperCamelCase_				)				)
		if current_sum + i_to_n <= needed_sum:
				# If the sum of the powers is less than needed_sum, then continue adding powers.
				current_sum += i_to_n
				__SCREAMING_SNAKE_CASE       ,__SCREAMING_SNAKE_CASE            = backtrack(
				    UpperCamelCase_  ,				UpperCamelCase_  ,				current_number + 1  ,				UpperCamelCase_  ,				UpperCamelCase_				)
				current_sum -= i_to_n
		if i_to_n < needed_sum:
				# If the power of i is less than needed_sum, then try with the next power.
				__SCREAMING_SNAKE_CASE       ,__SCREAMING_SNAKE_CASE            = backtrack(
				    UpperCamelCase_  ,				UpperCamelCase_  ,				current_number + 1  ,				UpperCamelCase_  ,				UpperCamelCase_				)
		return current_sum, solutions_count



def 						_lowerCAmelCase				(				UpperCamelCase_  ,				UpperCamelCase_				):
		if not (1 <= needed_sum <= 1000 and 2 <= power <= 10):
				raise ValueError(
				    """Invalid input\n"""
				    """needed_sum must be between 1 and 1000, power between 2 and 10."""				)

		return backtrack(UpperCamelCase_  ,				UpperCamelCase_  ,				1  ,				0  ,				0				)[1]  # Return the solutions_count


if __name__ == "__main__":
							import doctest

							doctest.testmod()






"""simple docstring"""





def 						_lowerCAmelCase				(				UpperCamelCase_ = 10**9				):
		__SCREAMING_SNAKE_CASE            = 1
		__SCREAMING_SNAKE_CASE            = 2

		__SCREAMING_SNAKE_CASE            = 0
		__SCREAMING_SNAKE_CASE            = 0
		__SCREAMING_SNAKE_CASE            = 0
		while perimeter <= max_perimeter:
				perimeters_sum += perimeter

				prev_value += 2 * value
				value += prev_value

				__SCREAMING_SNAKE_CASE            = 2 * value + 2 if i % 2 == 0 else 2 * value - 2
				i += 1

		return perimeters_sum


if __name__ == "__main__":
							print(F"""{solution() = }""")




