



"""simple docstring"""
from __future__ import annotations

from math import ceil, floor, sqrt


def 			_SCREAMING_SNAKE_CASE						(__lowerCAmelCase = 2_00_00_00							) ->						int:







  '''simple docstring'''


  lowercase_								= [0]
  lowercase_								= 42

  for idx in range(1 ,  ceil(sqrt(target * 2							) * 1.1							)							):
    triangle_numbers.append(triangle_numbers[-1] + idx							)

  # we want this to be as close as possible to target
  lowercase_								= 0
  # the area corresponding to the grid that gives the product closest to target
  lowercase_								= 0
  # an estimate of b, using the quadratic formula
  lowercase_								= 42
  # the largest integer less than b_estimate
  lowercase_								= 42
  # the largest integer less than b_estimate
  lowercase_								= 42
  # the triangle number corresponding to b_floor
  lowercase_								= 42
  # the triangle number corresponding to b_ceil
  lowercase_								= 42

  for idx_a, triangle_a in enumerate(triangle_numbers[1:] ,  1							):
    lowercase_								= (-1 + sqrt(1 + 8 * target / triangle_a							)) / 2
    lowercase_								= floor(__lowerCAmelCase							)
    lowercase_								= ceil(__lowerCAmelCase							)
    lowercase_								= triangle_numbers[b_floor]
    lowercase_								= triangle_numbers[b_ceil]

    if abs(target - triangle_b_first_guess * triangle_a							) < abs(
        target - best_product							):
      lowercase_								= triangle_b_first_guess * triangle_a
      lowercase_								= idx_a * b_floor

    if abs(target - triangle_b_second_guess * triangle_a							) < abs(
        target - best_product							):
      lowercase_								= triangle_b_second_guess * triangle_a
      lowercase_								= idx_a * b_ceil

  return area


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






"""simple docstring"""
def 			_SCREAMING_SNAKE_CASE						(__lowerCAmelCase ,  __lowerCAmelCase							) ->						int:







  '''simple docstring'''


  while a != 0:
    lowercase_					,    lowercase_								= b % a, a
  return b


def 			_SCREAMING_SNAKE_CASE						(__lowerCAmelCase ,  __lowerCAmelCase							) ->						int:







  '''simple docstring'''


  if gcd(__lowerCAmelCase ,  __lowerCAmelCase							) != 1:
    lowercase_								= F'''mod inverse of {a!r} and {m!r} does not exist'''
    raise ValueError(__lowerCAmelCase							)
  lowercase_					,    lowercase_					,    lowercase_								= 1, 0, a
  lowercase_					,    lowercase_					,    lowercase_								= 0, 1, m
  while va != 0:
    lowercase_								= ua // va
    lowercase_					,    lowercase_					,    lowercase_					,    lowercase_					,    lowercase_					,    lowercase_								= (ua - q * va), (ua - q * va), (ua - q * va), va, va, va
  return ua % m

