Function to represent S as the sum of K positive integers less than or equal to N
def solve ( S , K , N ) : NEW_LINE INDENT if ( K > N ) : NEW_LINE INDENT print ( " - 1" ) NEW_LINE return NEW_LINE DEDENT max_sum , min_sum = 0 , 0 NEW_LINE for i in range ( K + 1 ) : NEW_LINE INDENT min_sum += i NEW_LINE max_sum += N - i + 1 NEW_LINE DEDENT DEDENT