Loop to iterate over every possible cell of the matrix
for i in range ( n ) : NEW_LINE INDENT for j in range ( m ) : NEW_LINE INDENT val = v [ i ] [ j ] - x * ( i + j ) NEW_LINE for ii in range ( 151 ) : NEW_LINE INDENT for jj in range ( 151 ) : NEW_LINE INDENT dp [ ii ] [ jj ] = - 1 NEW_LINE DEDENT DEDENT val = min_operation ( 0 , 0 , val , x ) NEW_LINE ans = min ( ans , val ) NEW_LINE DEDENT DEDENT return ans NEW_LINE