Loop to iterate over the elements of the matrix
for i in range ( N ) : NEW_LINE INDENT for j in range ( M ) : NEW_LINE INDENT if mat [ i ] [ j ] > k : NEW_LINE INDENT m = mat [ i ] [ j ] - k NEW_LINE if m in s : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT m = k - mat [ i ] [ j ] NEW_LINE if m in s : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT s . add ( mat [ i ] [ j ] ) NEW_LINE DEDENT DEDENT return False NEW_LINE