



"""simple docstring"""
def 					lowerCamelCase_		(UpperCamelCase__						:						list[list[int]]	,			UpperCamelCase__						:						int	,			UpperCamelCase__						:						int	,			UpperCamelCase__						:						set				):
    _UpperCAmelCase				,							_UpperCAmelCase				:    str											=       len(_UpperCamelCase				), len(grid[0]				)
    if (
        min(_UpperCamelCase	,			_UpperCamelCase				) < 0
        or row == row_length
        or col == col_length
        or (row, col) in visit
        or grid[row][col] == 1
    ):
        return 0
    if row == row_length - 1 and col == col_length - 1:
        return 1

    visit.add((row, col)				)

    _UpperCAmelCase				:    Optional[Any]											=       0
    count += depth_first_search(_UpperCamelCase	,			row + 1	,			_UpperCamelCase	,			_UpperCamelCase				)
    count += depth_first_search(_UpperCamelCase	,			row - 1	,			_UpperCamelCase	,			_UpperCamelCase				)
    count += depth_first_search(_UpperCamelCase	,			_UpperCamelCase	,			col + 1	,			_UpperCamelCase				)
    count += depth_first_search(_UpperCamelCase	,			_UpperCamelCase	,			col - 1	,			_UpperCamelCase				)

    visit.remove((row, col)				)
    return count


if __name__ == "__main__":
  import doctest

  doctest.testmod()







from __future__ import annotations

from math import ceil, floor, sqrt





def 		a__      (		_UpperCamelCase      :			int = 2_00_00_00				):
   __lowerCamelCase    				=     [0]
   __lowerCamelCase    				=     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
   __lowerCamelCase    				=     0
   # the area corresponding to the grid that gives the product closest to target
   __lowerCamelCase    				=     0
   # an estimate of b, using the quadratic formula
   __lowerCamelCase    				=     42
   # the largest integer less than b_estimate
   __lowerCamelCase    				=     42
   # the largest integer less than b_estimate
   __lowerCamelCase    				=     42
   # the triangle number corresponding to b_floor
   __lowerCamelCase    				=     42
   # the triangle number corresponding to b_ceil
   __lowerCamelCase    				=     42

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

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

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

   return area


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






