


def 		_A		(		)					-> list[list[int]]:


     """simple docstring"""


     return [list(range(10_00 - i					,  -10_00 - i					,  -1 ) ) for i in range(10_00 )]


__snake_case   							=						generate_large_matrix()
__snake_case   							=						(
    [[4, 3, 2, -1], [3, 2, 1, -1], [1, 1, -1, -2], [-1, -1, -2, -3]],
    [[3, 2], [1, 0]],
    [[7, 7, 6]],
    [[7, 7, 6], [-1, -2, -3]],
    grid,
)






def 		_A		(		_lowercase )					-> None:


     """simple docstring"""


     assert all(row == sorted(_lowercase					,  reverse=_lowercase ) for row in grid )
     assert all(list(_lowercase ) == sorted(_lowercase					,  reverse=_lowercase ) for col in zip(*_lowercase ) )






def 		_A		(		_lowercase )					-> int:


     """simple docstring"""


     __UpperCamelCase =			0
     __UpperCamelCase =			len(_lowercase ) - 1

     # Edge cases such as no values or all numbers are negative.
     if not array or array[0] < 0:
          return 0

     while right + 1 > left:
          __UpperCamelCase =			(left + right) // 2
          __UpperCamelCase =			array[mid]

          # Num must be negative and the index must be greater than or equal to 0.
          if num < 0 and array[mid - 1] >= 0:
               return mid

          if num >= 0:
               __UpperCamelCase =			mid + 1
          else:
               __UpperCamelCase =			mid - 1
    # No negative numbers so return the last index of the array + 1 which is the length.
     return len(_lowercase )






def 		_A		(		_lowercase )					-> int:


     """simple docstring"""


     __UpperCamelCase =			0
     __UpperCamelCase =			len(grid[0] )

     for i in range(len(_lowercase ) ):
          __UpperCamelCase =			find_negative_index(grid[i][:bound] )
          total += bound
     return (len(_lowercase ) * len(grid[0] )) - total






def 		_A		(		_lowercase )					-> int:


     """simple docstring"""


     return len([number for row in grid for number in row if number < 0] )






def 		_A		(		_lowercase )					-> int:


     """simple docstring"""


     __UpperCamelCase =			0
     for row in grid:
          for i, number in enumerate(_lowercase ):
               if number < 0:
                    total += len(_lowercase ) - i
                    break
     return total






def 		_A		(		)					-> None:


     """simple docstring"""


     from timeit import timeit

     print('Running benchmarks' )
     __UpperCamelCase =			(
         'from __main__ import count_negatives_binary_search, '
         'count_negatives_brute_force, count_negatives_brute_force_with_break, grid'
     )
     for func in (
         "count_negatives_binary_search",  # took 0.7727 seconds
         "count_negatives_brute_force_with_break",  # took 4.6505 seconds
         "count_negatives_brute_force",  # took 12.8160 seconds
     ):
          __UpperCamelCase =			timeit(f'''{func}(grid=grid)'''					,  setup=_lowercase					,  number=5_00 )
          print(f'''{func}() took {time:0.4f} seconds''' )


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    benchmark()






def 		_A		(		_lowercase					,  _lowercase )					-> int:


     """simple docstring"""


     return (pointa[0] - pointa[0]) ** 2 + (pointa[1] - pointa[1]) ** 2






def 		_A		(		_lowercase					,  _lowercase=0 )					-> Dict:


     """simple docstring"""


     return sorted(_lowercase					,  key=lambda _lowercase : x[column] )






def 		_A		(		_lowercase					,  _lowercase					,  _lowercase=float('inf' ) )					-> List[Any]:


     """simple docstring"""


     for i in range(points_counts - 1 ):
          for j in range(i + 1					,  _lowercase ):
               __UpperCamelCase =			euclidean_distance_sqr(points[i]					,  points[j] )
               if current_dis < min_dis:
                    __UpperCamelCase =			current_dis
     return min_dis






def 		_A		(		_lowercase					,  _lowercase					,  _lowercase=float('inf' ) )					-> Tuple:


     """simple docstring"""


     for i in range(min(6					,  points_counts - 1 )					,  _lowercase ):
          for j in range(max(0					,  i - 6 )					,  _lowercase ):
               __UpperCamelCase =			euclidean_distance_sqr(points[i]					,  points[j] )
               if current_dis < min_dis:
                    __UpperCamelCase =			current_dis
     return min_dis






def 		_A		(		_lowercase					,  _lowercase					,  _lowercase )					-> Optional[Any]:


     """simple docstring"""


     if points_counts <= 3:
          return dis_between_closest_pair(_lowercase					,  _lowercase )

     # recursion
     __UpperCamelCase =			points_counts // 2
     __UpperCamelCase =			closest_pair_of_points_sqr(
         _lowercase					,  points_sorted_on_y[:mid]					,  _lowercase )
     __UpperCamelCase =			closest_pair_of_points_sqr(
         _lowercase					,  points_sorted_on_y[mid:]					,  points_counts - mid )
     __UpperCamelCase =			min(_lowercase					,  _lowercase )
     __UpperCamelCase =			[]
     for point in points_sorted_on_x:
          if abs(point[0] - points_sorted_on_x[mid][0] ) < closest_pair_dis:
               cross_strip.append(_lowercase )

     __UpperCamelCase =			dis_between_closest_in_strip(
         _lowercase					,  len(_lowercase )					,  _lowercase )
     return min(_lowercase					,  _lowercase )






def 		_A		(		_lowercase					,  _lowercase )					-> Optional[int]:


     """simple docstring"""


     __UpperCamelCase =			column_based_sort(_lowercase					,  column=0 )
     __UpperCamelCase =			column_based_sort(_lowercase					,  column=1 )
     return (
         closest_pair_of_points_sqr(
             _lowercase					,  _lowercase					,  _lowercase )
     ) ** 0.5


if __name__ == "__main__":
    __snake_case   							=						[(2, 3), (1_2, 3_0), (4_0, 5_0), (5, 1), (1_2, 1_0), (3, 4)]
    print('''Distance:''', closest_pair_of_points(points, len(points)))


