<doocs>1277.Count Square Submatrices with All Ones_1.py
def countSquares( matrix: List[List[int]]) -> int:
    m, n = len(matrix), len(matrix[0])
    f = [[0] * n for _ in range(m)]
    ans = 0
    for i, row in enumerate(matrix):
        for j, v in enumerate(row):
            if v == 0:
                continue
            if i == 0 or j == 0:
                f[i][j] = 1
            else:
                f[i][j] = min(f[i - 1][j - 1], f[i - 1][j], f[i][j - 1]) + 1
            ans += f[i][j]
    return ans
def sample_funcname ( var_0 : List [ List [ int ] ] ) -> int :
    var_4 , var_6 = len ( var_0 ) , len ( var_0 [ 0 ] )
    var_9 = [ [ 0 ] * var_6 for var_7 in range ( var_4 ) ]
    var_10 = 0
    for var_12 , var_13 in enumerate ( var_0 ) :
        for var_14 , var_15 in enumerate ( var_13 ) :
            if var_15 == 0 :
                continue
            if var_12 == 0 or var_14 == 0 :
                var_9 [ var_12 ] [ var_14 ] = 1
            else :
                var_9 [ var_12 ] [ var_14 ] = min ( var_9 [ var_12 - 1 ] [ var_14 - 1 ] , var_9 [ var_12 - 1 ] [ var_14 ] , var_9 [ var_12 ] [ var_14 - 1 ] ) + 1
            var_10 += var_9 [ var_12 ] [ var_14 ]
    return var_10
