Function to add k to the specified submatrix ( r1 , c1 ) to ( r2 , c2 )
def update ( D , k , r1 , c1 , r2 , c2 ) : NEW_LINE INDENT for i in range ( r1 , r2 + 1 ) : NEW_LINE INDENT D [ i ] [ c1 ] += k ; NEW_LINE D [ i ] [ c2 + 1 ] -= k ; NEW_LINE DEDENT DEDENT