count of numbers between A and B (inclusive) that have sum of digits equal to S Task:
Find the count of numbers between A and B (inclusive) that have sum of digits equal to S.
Also print the smallest such number between A and B (inclusive).

Input:
Single line consisting of A, B, and S.

Output:
Two lines.

In first line, the number of integers between A and B having sum of digits equal to S.

In second line, the smallest such number between A and B.

Constraints:

1 &lt;= A &lt;= B &lt; 10^15

1 &lt;= S &lt;= 135
GolfScript, 35 bytes

~:S;),&gt;{.10base{+}*S=!{;}*}%(\,)]n*


How it works

~         # Interpret the input string.
:S;       # Save the last integer in variable “S” and pop it from the stack.
),        # Increment it by 1 and create the array “[0 ... B]”
&gt;         # Remove the first “A” elements. This leaves the array “[A ... B]”
{         # For each of those integers:
  .10base # Push its digits in base 10.
  {+}*    # Add the digits.
  S=!{;}* # If the sum is not equal to “S”, pop the integer from the stack.
}%        # Collect the results into an array.
(\        # Extract the first and swap it below the array.
,)        # Count the elements of the array of all remaining integers and increment by one. 
n\        # Separate the results by a newline.