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


A__           =							generate_large_matrix()
A__           =							(
    [[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  _lowerCamelCase					(   a_				: list[list[int]]):
			assert all(row == sorted(a_						,			reverse=a_) for row in grid)
			assert all(list(a_) == sorted(a_						,			reverse=a_) for col in zip(*a_))





def  _lowerCamelCase					(   a_				: list[int]):
			lowerCamelCase						:Optional[Any]						  =     0
			lowerCamelCase						:Dict						  =     len(a_) - 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:
						lowerCamelCase						:str						  =     (left + right) // 2
						lowerCamelCase						:Optional[Any]						  =     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:
									lowerCamelCase						:Any						  =     mid + 1
						else:
									lowerCamelCase						:int						  =     mid - 1
    # No negative numbers so return the last index of the array + 1 which is the length.
			return len(a_)





def  _lowerCamelCase					(   a_				: list[list[int]]):
			lowerCamelCase						:Dict						  =     0
			lowerCamelCase						:Optional[Any]						  =     len(grid[0])

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





def  _lowerCamelCase					(   a_				: list[list[int]]):
			return len([number for row in grid for number in row if number < 0])





def  _lowerCamelCase					(   a_				: list[list[int]]):
			lowerCamelCase						:Tuple						  =     0
			for row in grid:
						for i, number in enumerate(a_):
									if number < 0:
												total += len(a_) - i
												break
			return total





def  _lowerCamelCase					(   ):
			from timeit import timeit

			print('''Running benchmarks''')
			lowerCamelCase						:List[Any]						  =     (
			    '''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
			):
						lowerCamelCase						:Optional[int]						  =     timeit(F"{func}(grid=grid)"						,			setup=a_						,			number=5_00)
						print(F"{func}() took {time:0.4f} seconds")


if __name__ == "__main__":
			import doctest

			doctest.testmod()
			benchmark()




import math





def  _lowerCamelCase					(   a_				: int):

			if 1 < number < 4:
						# 2 and 3 are primes
						return True
			elif number < 2 or number % 2 == 0 or number % 3 == 0:
						# Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
						return False

			# All primes number are in format of 6k +/- 1
			for i in range(5						,			int(math.sqrt(a_) + 1)						,			6):
						if number % i == 0 or number % (i + 2) == 0:
									return False
			return True





def  _lowerCamelCase					(   a_				: float = 0.1):
			lowerCamelCase						:Dict						  =     3
			lowerCamelCase						:List[Any]						  =     3

			while primes / (2 * j - 1) >= ratio:
						for i in range(j * j + j + 1						,			(j + 2) * (j + 2)						,			j + 1):
									primes += is_prime(a_)
						j += 2
			return j


if __name__ == "__main__":
			import doctest

			doctest.testmod()



