




def    UpperCAmelCase_				( __UpperCAmelCase		:      int = 50				)   ->					int:
      SCREAMING_SNAKE_CASE_      		=     [1] * (length + 1)

      for row_length in range(length + 1				):
            for tile_length in range(2     ,     5				):
                  for tile_start in range(row_length - tile_length + 1				):
                        ways_number[row_length] += ways_number[
                            row_length - tile_start - tile_length
                        ]

      return ways_number[length]


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





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


lowerCamelCase__					:  List[Any]      							=				generate_large_matrix()
lowerCamelCase__					:  List[Any]      							=				(
    [[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    UpperCAmelCase_				( __UpperCAmelCase		:      list[list[int]]				)   ->					None:
      assert all(row == sorted(__UpperCAmelCase     ,     reverse=__UpperCAmelCase				) for row in grid				)
      assert all(list(__UpperCAmelCase				) == sorted(__UpperCAmelCase     ,     reverse=__UpperCAmelCase				) for col in zip(*__UpperCAmelCase				)				)

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

def    UpperCAmelCase_				( __UpperCAmelCase		:      list[list[int]]				)   ->					int:
      SCREAMING_SNAKE_CASE_      		=     0
      SCREAMING_SNAKE_CASE_      		=     len(grid[0]				)

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

def    UpperCAmelCase_				( __UpperCAmelCase		:      list[list[int]]				)   ->					int:
      return len([number for row in grid for number in row if number < 0]				)

def    UpperCAmelCase_				( __UpperCAmelCase		:      list[list[int]]				)   ->					int:
      SCREAMING_SNAKE_CASE_      		=     0
      for row in grid:
            for i, number in enumerate(__UpperCAmelCase				):
                  if number < 0:
                        total += len(__UpperCAmelCase				) - i
                        break
      return total

def    UpperCAmelCase_				( )   ->					None:
      from timeit import timeit

      print('Running benchmarks'				)
      SCREAMING_SNAKE_CASE_      		=     (
          '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
      ):
            SCREAMING_SNAKE_CASE_      		=     timeit(f"{func}(grid=grid)"     ,     setup=__UpperCAmelCase     ,     number=5_00				)
            print(f"{func}() took {time:0.4f} seconds"				)


if __name__ == "__main__":
   import doctest

   doctest.testmod()
   benchmark()