


from __future__ import annotations

from typing import Any
def     UpperCAmelCase_ (							*__snake_case						)					->      list[list[int]]:







 """simple docstring"""


 if all(_check_not_integer(__snake_case						) for m in matrix_s						):
  for i in matrix_s[1:]:
   _verify_matrix_sizes(matrix_s[0]					,						__snake_case						)
  return [[sum(__snake_case						) for t in zip(*__snake_case						)] for m in zip(*__snake_case						)]
 raise TypeError('''Expected a matrix, got int/list instead'''						)
def     UpperCAmelCase_ (							__snake_case					,						__snake_case						)					->      list[list[int]]:







 """simple docstring"""


 if (
     _check_not_integer(__snake_case						)
     and _check_not_integer(__snake_case						)
     and _verify_matrix_sizes(__snake_case					,						__snake_case						)
 ):
  return [[i - j for i, j in zip(*__snake_case						)] for m in zip(__snake_case					,						__snake_case						)]
 raise TypeError('''Expected a matrix, got int/list instead'''						)
def     UpperCAmelCase_ (							__snake_case					,						__snake_case						)					->      list[list[float]]:







 """simple docstring"""


 return [[x * n for x in row] for row in matrix]
def     UpperCAmelCase_ (							__snake_case					,						__snake_case						)					->      list[list[int]]:







 """simple docstring"""


 if _check_not_integer(__snake_case						) and _check_not_integer(__snake_case						):
  _lowercase				,   _lowercase											=_verify_matrix_sizes(__snake_case					,						__snake_case						)

 if cols[0] != rows[1]:
  _lowercase											=(
      '''Cannot multiply matrix of dimensions '''
      F"({rows[0]},{cols[0]}) and ({rows[1]},{cols[1]})"
  )
  raise ValueError(__snake_case						)
 return [
     [sum(m * n for m, n in zip(__snake_case					,						__snake_case						)						) for j in zip(*__snake_case						)] for i in matrix_a
 ]
def     UpperCAmelCase_ (							__snake_case						)					->      list[list[int]]:







 """simple docstring"""


 _lowercase											=int(__snake_case						)
 return [[int(row == column						) for column in range(__snake_case						)] for row in range(__snake_case						)]
def     UpperCAmelCase_ (							__snake_case					,						__snake_case = True						)					->      list[list[int]] | map[list[int]]:







 """simple docstring"""


 if _check_not_integer(__snake_case						):
  if return_map:
   return map(__snake_case					,						zip(*__snake_case						)						)
  else:
   return list(map(__snake_case					,						zip(*__snake_case						)						)						)
 raise TypeError('''Expected a matrix, got int/list instead'''						)
def     UpperCAmelCase_ (							__snake_case					,						__snake_case					,						__snake_case						)					->      list[list[int]]:







 """simple docstring"""


 _lowercase											=matrix[:row] + matrix[row + 1 :]
 return [row[:column] + row[column + 1 :] for row in minor]
def     UpperCAmelCase_ (							__snake_case						)					->      Any:







 """simple docstring"""


 if len(__snake_case						) == 1:
  return matrix[0][0]

 return sum(
     x * determinant(minor(__snake_case					,						0					,						__snake_case						)						) * (-1) ** i
     for i, x in enumerate(matrix[0]						)						)
def     UpperCAmelCase_ (							__snake_case						)					->      list[list[float]] | None:







 """simple docstring"""


 _lowercase											=determinant(__snake_case						)
 if det == 0:
  return None

 _lowercase											=[
     [determinant(minor(__snake_case					,						__snake_case					,						__snake_case						)						) for j in range(len(__snake_case						)						)]
     for i in range(len(__snake_case						)						)
 ]

 _lowercase											=[
     [x * (-1) ** (row + col) for col, x in enumerate(matrix_minor[row]						)]
     for row in range(len(__snake_case						)						)
 ]
 _lowercase											=list(transpose(__snake_case						)						)
 return scalar_multiply(__snake_case					,						1 / det						)
def     UpperCAmelCase_ (							__snake_case						)					->      bool:







 """simple docstring"""


 return not isinstance(__snake_case					,						__snake_case						) and not isinstance(matrix[0]					,						__snake_case						)
def     UpperCAmelCase_ (							__snake_case						)					->      tuple[int, int]:







 """simple docstring"""


 return len(__snake_case						), len(matrix[0]						)
def     UpperCAmelCase_ (							__snake_case					,						__snake_case						)					->      tuple[tuple[int, int], tuple[int, int]]:







 """simple docstring"""


 _lowercase											=_shape(__snake_case						) + _shape(__snake_case						)
 if shape[0] != shape[3] or shape[1] != shape[2]:
  _lowercase											=(
      '''operands could not be broadcast together with shape '''
      F"({shape[0], shape[1]}), ({shape[2], shape[3]})"
  )
  raise ValueError(__snake_case						)
 return (shape[0], shape[2]), (shape[1], shape[3])
def     UpperCAmelCase_ (							)					->      None:







 """simple docstring"""


 _lowercase											=[[12, 10], [3, 9]]
 _lowercase											=[[3, 4], [7, 4]]
 _lowercase											=[[11, 12, 13, 14], [21, 22, 23, 24], [31, 32, 33, 34], [41, 42, 43, 44]]
 _lowercase											=[[3, 0, 2], [2, 0, -2], [0, 1, 1]]
 print(F"Add Operation, {add(__snake_case					,						__snake_case						) = } \n"						)
 print(
     F"Multiply Operation, {multiply(__snake_case					,						__snake_case						) = } \n"					,						)
 print(F"Identity: {identity(5						)}\n"						)
 print(F"Minor of {matrix_c} = {minor(__snake_case					,						1					,						2						)} \n"						)
 print(F"Determinant of {matrix_b} = {determinant(__snake_case						)} \n"						)
 print(F"Inverse of {matrix_d} = {inverse(__snake_case						)}\n"						)


if __name__ == "__main__":
  import doctest

  doctest.testmod()
  main()





UpperCAmelCase__            =							[
    [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0],
    [0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0],
    [0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0],
]
def     UpperCAmelCase_ (							__snake_case					,						__snake_case					,						__snake_case					,						__snake_case						)					->      bool:







 """simple docstring"""


 return 0 <= row < rows and 0 <= col < cols
def     UpperCAmelCase_ (							__snake_case					,						__snake_case					,						__snake_case					,						__snake_case						)					->      int:







 """simple docstring"""


 _lowercase											=len(__snake_case						)
 _lowercase											=len(mat[0]						)
 if is_safe(__snake_case					,						__snake_case					,						__snake_case					,						__snake_case						) and (row, col) not in seen and mat[row][col] == 1:
  seen.add((row, col)						)
  return (
      1
      + depth_first_search(row + 1					,						__snake_case					,						__snake_case					,						__snake_case						)
      + depth_first_search(row - 1					,						__snake_case					,						__snake_case					,						__snake_case						)
      + depth_first_search(__snake_case					,						col + 1					,						__snake_case					,						__snake_case						)
      + depth_first_search(__snake_case					,						col - 1					,						__snake_case					,						__snake_case						)
  )
 else:
  return 0
def     UpperCAmelCase_ (							__snake_case						)					->      int:







 """simple docstring"""


 _lowercase											=set()

 _lowercase											=0
 for row, line in enumerate(__snake_case						):
  for col, item in enumerate(__snake_case						):
   if item == 1 and (row, col) not in seen:
    # Maximizing the area
    _lowercase											=max(__snake_case					,						depth_first_search(__snake_case					,						__snake_case					,						__snake_case					,						__snake_case						)						)
 return max_area


if __name__ == "__main__":
  import doctest

  print(find_max_area(matrix))  # Output -> 6
  doctest.testmod()

