AtCoder Beginner Contest 083 - Some Sums

Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).

-----Constraints-----
 - 1 \leq N \leq 10^4
 - 1 \leq A \leq B \leq 36
 - All input values are integers.

-----Input-----
Input is given from Standard Input in the following format:
N A B

-----Output-----
Print the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).

-----Sample Input-----
20 2 5

-----Sample Output-----
84

Among the integers not greater than 20, the ones whose sums of digits are between 2 and 5, are: 2,3,4,5,11,12,13,14 and 20. We should print the sum of these, 84.

Source: atcoder | Difficulty: EASY


Solutions:
(N, A, B) = map(int, input().split())
S = 0
for i in range(N + 1):
	if A <= sum(map(int, str(i))) <= B:
		S += i
print(S)


(n, a, s) = map(int, input().split())
ans = 0
for i in range(1, n + 1):
	if a <= sum(list(map(int, list(str(i))))) <= s:
		ans += i
print(ans)


import sys
input = sys.stdin.readline

def main():
	(n, a, b) = map(int, input().split())
	numbers = []
	tmp = 0
	for i in range(1, n + 1):
		if i >= a and i <= b and (i < 10):
			numbers.append(i)
		else:
			tmp_array = list(map(int, list(str(i))))
			if len(tmp_array) > 1:
				for j in tmp_array:
					tmp += j
				if tmp >= a and tmp <= b:
					numbers.append(i)
				tmp = 0
			else:
				continue
	print(sum(numbers))

def __starting_point():
	main()
__starting_point()


(N, A, B) = map(int, input().split())
ans = 0
for n in range(N + 1):
	if A <= sum(list(map(int, str(n)))) <= B:
		ans += n
print(ans)


(N, a, b) = map(int, input().split())
print(sum([i for i in range(N + 1) if a <= sum(list(map(int, list(str(i))))) <= b]))


(N, A, B) = [int(i) for i in input().split()]
print(sum([int(i) for i in range(1, N + 1) if A <= sum(map(int, list(str(i)))) <= B]))


(N, A, B) = map(int, input().split())
cnt = 0
for i in range(N + 1):
	cnt += i * (A <= sum(map(int, str(i))) <= B)
print(cnt)


import sys
from functools import reduce

def fast_input():
	return sys.stdin.readline()[:-1]

def digit_sum(num: int) -> int:
	str_num = str(num)
	return reduce(lambda acc, n: acc + int(n), list(str_num), 0)

def solve(n: int, a: int, b: int) -> int:
	num_sum = 0
	for num in range(1, n + 1):
		if a <= digit_sum(num) <= b:
			num_sum += num
	return num_sum

def main():
	[n, a, b] = list(map(int, fast_input().split()))
	result = solve(n, a, b)
	print(result)
main()


(n, a, b) = map(int, input().split())
print(sum((i + 1 for i in range(0, n) if a <= sum([int(d) for d in list(str(i + 1))]) <= b)))


(N, A, B) = map(int, input().split())
result = 0
for i in range(1, N + 1):
	num = i // 10 ** 4 + i // 10 ** 3 % 10 + i // 10 ** 2 % 10 + i // 10 % 10 + i % 10
	if A <= num <= B:
		result += i
print(result)


def myfunc(A, B):

	def resfunc(x):
		if A <= sum(map(int, list(str(x)))) <= B:
			return x
		else:
			return 0
	return resfunc
(N, A, B) = map(int, input().split())
print(sum(map(myfunc(A, B), range(1, N + 1))))


(n, a, b) = map(int, input().split())
print(sum([x for x in range(1, n + 1) if a <= sum([int(c) for c in str(x)]) <= b]))


(n, a, b) = map(int, input().split())
sum = 0
sum_n = 0
for num in range(1, n + 1):
	num2 = num
	sum_n = 0
	while num > 0:
		sum_n += num % 10
		num //= 10
	if sum_n >= a and sum_n <= b:
		sum += num2
print(sum)


(N, A, B) = map(int, input().split())
print(sum((x for x in range(1, N + 1) if A <= sum(map(int, str(x))) <= B)))


def calc_sum(num):
	ans = 0
	for i in range(len(str(num))):
		target = num % 10
		num //= 10
		ans += target
	return ans

def main():
	(n, a, b) = map(int, input().split())
	ans = 0
	for i in range(1, n + 1):
		num = calc_sum(i)
		if a <= num <= b:
			ans += i
	print(ans)

def __starting_point():
	main()
__starting_point()


from sys import stdin
(n, a, b) = [int(x) for x in stdin.readline().rstrip().split()]
sum = 0
for x in range(1, n + 1):
	l = x // 10000
	m = x % 10000 // 1000
	n = x % 1000 // 100
	o = x % 100 // 10
	p = x % 10
	if l + m + n + o + p >= a and l + m + n + o + p <= b:
		sum += x
print(sum)


s = list(map(int, input().split()))
oklist = []

def keta(x):
	ketalist = []
	for j in range(len(x)):
		ketalist.append(int(x[j]))
	return sum(ketalist)
for i in range(s[0] + 1):
	check = keta(str(i))
	if s[1] <= check and check <= s[2]:
		oklist.append(i)
sum_ = sum(oklist)
print(sum_)


def mapt(fn, *args):
	return tuple(map(fn, *args))

def Input():
	return mapt(int, input().split(' '))

def main():
	(n, a, b) = Input()
	n += 1
	data = (i for i in range(1, n) if a <= sum(map(int, list(str(i)))) <= b)
	print(sum(data))
main()


(n, a, b) = map(int, input().split())
c = 0
for i in range(n + 1):
	if a <= sum((int(j) for j in str(i))) <= b:
		c += i
print(c)


import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

def I():
	return int(input())

def F():
	return float(input())

def SS():
	return input()

def LI():
	return [int(x) for x in input().split()]

def LI_():
	return [int(x) - 1 for x in input().split()]

def LF():
	return [float(x) for x in input().split()]

def LSS():
	return input().split()

def resolve():
	(N, A, B) = LI()
	ans = 0
	for i in range(1, N + 1):
		if A <= sum([int(i) for i in str(i)]) <= B:
			ans += i
	print(ans)

def __starting_point():
	resolve()
__starting_point()


(N, A, B) = map(int, input().split())
sum1 = 0
for n in range(1, N + 1):
	sum2 = 0
	for s in str(n):
		sum2 += int(s)
	if A <= sum2 <= B:
		sum1 += n
print(sum1)


(N, A, B) = map(int, input().split())
c = 0
for i in range(1, N + 1):
	a = 0
	b = i
	while b > 0:
		a += b % 10
		b = b // 10
	if A <= a <= B:
		c += i
print(c)


(n, a, b) = (int(x) for x in input().split())
c = 0
for i in range(n + 1):
	d = 0
	for j in str(i):
		d += int(j)
	if a <= d <= b:
		c += i
print(c)


(N, a, b) = map(int, input().split())
ans = 0
for i in range(N + 1):
	if a <= sum((int(j) for j in str(i))) <= b:
		ans += i
print(ans)


lst = input().split()
N = int(lst[0])
A = int(lst[1])
B = int(lst[2])

def sum(n):
	result = 0
	s = str(n)
	for i in range(len(s)):
		result += int(s[i])
	return result
count = 0
for i in range(1, N + 1):
	if A <= sum(i) <= B:
		count += i
print(count)


(N, A, B) = map(int, input().split())
SUM = 0
for i in range(1, N + 1):
	n = sum(map(int, list(str(i))))
	if A <= n and n <= B:
		SUM += i
print(SUM)


(n, a, b) = map(int, input().split())
ans = 0
for i in range(1, n + 1):
	x = str(i)
	cnt = 0
	for j in range(len(x)):
		cnt += int(x[j])
	if a <= cnt and cnt <= b:
		ans += i
print(ans)


(n, a, b) = map(int, input().split())
ans = 0
for k in range(1, n + 1):
	if a <= sum(map(int, str(k))) <= b:
		ans += k
print(ans)


(n, a, b) = map(int, input().split())
r = 0
for i in range(n + 1):
	c = 0
	j = i
	for k in range(5):
		c += j % 10
		j = j // 10
	if a <= c and c <= b:
		r += i
print(r)


(N, A, B) = list(map(int, input().split()))
cnt = 0
for n in range(1, N + 1):
	val = n % 10
	tmp = n
	while tmp // 10 > 0:
		tmp = tmp // 10
		val += tmp % 10
	if val >= A and val <= B:
		cnt += n
print(cnt)


(N, A, B) = list(map(int, input().split()))
ans = 0
for x in range(1, N + 1):
	y = sum((int(c) for c in str(x)))
	if A <= y and y <= B:
		ans += x
print(ans)


(n, a, b) = map(int, input().split())
print(sum((i for i in range(n + 1) if a <= sum(map(int, str(i))) <= b)))


(N, A, B) = map(int, input().split())
result = 0

def FindSomeOfDegit(x):
	count = 0
	while x > 0:
		count += x % 10
		x = x // 10
	return count
for i in range(N + 1):
	count = FindSomeOfDegit(i)
	if A <= count <= B:
		result += i
print(result)


(n, a, b) = map(int, input().split())
total = 0
for i in range(1, n + 1):
	x = str(i)
	j = 0
	total2 = 0
	for j in range(len(x)):
		total2 += int(x[j])
	if a <= total2 <= b:
		total += i
print(total)


(N, A, B) = map(int, input().split())
ans = 0
for i in range(1, N + 1):
	x = str(i)
	n = len(x)
	sum = 0
	for j in range(0, n):
		sum = sum + int(x[j])
	if sum >= A and sum <= B:
		ans += i
print(ans)


(N, A, B) = map(int, input().split())
count = 0
for i in range(1, N + 1):
	acc = 0
	for j in range(len(str(i))):
		acc += int(str(i)[j])
	if acc >= A and acc <= B:
		count += i
print(count)


(n, a, b) = map(int, input().split())
ans = 0
for i in range(1, n + 1):
	w = sum(list(map(int, list(str(i)))))
	if a <= w and w <= b:
		ans += i
print(ans)


(n, x, y) = map(int, input().split())
c = 0
for i in range(1, n + 1):
	s = sum(map(int, str(i)))
	if s >= x and s <= y:
		c += i
print(c)


(N, A, B) = map(int, input().split())
sum_1 = 0
for i in range(1, N + 1):
	sum_order = 0
	i_str = str(i)
	n = len(i_str)
	for j in range(0, n):
		sum_order += int(i_str[j])
	if A <= sum_order <= B:
		sum_1 += i
print(sum_1)


def reverse(num):
	sum1 = 0
	while num > 0:
		remainder = num % 10
		sum1 = remainder + sum1
		num = num // 10
	return sum1
(n, a, b) = list(map(int, input().split()))
c = 0
for i in range(1, n + 1):
	if reverse(i) >= a and reverse(i) <= b:
		c += i
print(c)


(n, a, b) = map(int, input().split())
ans = 0
for i in range(n + 1):
	i = str(i)
	c = 0
	for l in i:
		c += int(l)
	if a <= c and c <= b:
		ans += int(i)
print(ans)


(n, a, b) = (int(i) for i in input().split())
ans = 0
for i in range(1, n + 1):
	str_i = str(i)
	sum_i = 0
	for j in str_i:
		sum_i += int(j)
	if a <= sum_i <= b:
		ans += i
print(ans)


(n, a, b) = list(map(int, input().split()))
l = []
ans = 0
for i in range(n):
	l.append(str(i + 1))
for i in l:
	li = list(map(int, i))
	if a <= sum(li) <= b:
		ans += int(i)
print(ans)


(n, a, b) = map(int, input().split())
print(sum([i for i in range(1, n + 1) if a <= eval('+'.join(list(str(i)))) <= b]))


(N, A, B) = map(int, input().split())
ans = 0
for i in range(1, N + 1):
	s = sum(map(int, str(i)))
	if A <= s and s <= B:
		ans += i
print(ans)


(N, A, B) = list(map(int, input().split()))
ans = 0
for i in range(1, N + 1, 1):
	stri = str(i)
	sum = 0
	for j in range(len(str(i))):
		sum += int(stri[j])
	else:
		if sum >= A and sum <= B:
			ans += i
print(ans)


(n, a, b) = list(map(int, input().split()))
ans = 0
for i in range(1, n + 1):
	temp = 0
	c = str(i)
	for j in range(len(c)):
		temp += int(c[j])
	if a <= temp and temp <= b:
		ans += i
print(ans)


(N, A, B) = map(int, input().split())
con = 0
for i in range(1, N + 1):
	a1 = i // 10000
	a2 = (i - a1 * 10000) // 1000
	a3 = (i - a1 * 10000 - a2 * 1000) // 100
	a4 = (i - a1 * 10000 - a2 * 1000 - a3 * 100) // 10
	a5 = i % 10
	if A <= a1 + a2 + a3 + a4 + a5 <= B:
		con += i
print(con)


(N, A, B) = map(int, input().split())
lst = []
for i in range(N + 1):
	if i >= 1 and i < 10:
		if i >= A and i <= B:
			lst.append(i)
	elif i < 100:
		s = i // 10 + i % 10
		if s >= A and s <= B:
			lst.append(i)
	elif i < 1000:
		t = i // 100 + i % 100 // 10 + i % 10
		if t >= A and t <= B:
			lst.append(i)
	elif i < 10000:
		u = i // 1000 + i % 1000 // 100 + i % 100 // 10 + i % 10
		if u >= A and u <= B:
			lst.append(i)
	elif i == 10000:
		lst.append(i)
lst_sum = sum(lst)
print(lst_sum)


def __starting_point():
	(n, a, b) = list(map(int, input().split()))
	ans = 0
	for n in range(n + 1):
		keta = len(str(n))
		wa = 0
		for m in range(keta):
			tmp = str(n)
			wa = wa + int(tmp[-m - 1])
		if a <= wa <= b:
			ans = ans + n
	print(ans)
__starting_point()


(N, A, B) = map(int, input().split())

def caluculate(n):
	sum = 0
	while n > 0:
		sum += n % 10
		n = n // 10
	return sum
ans = 0
for i in range(N + 1):
	if A <= caluculate(i) <= B:
		ans += i
print(ans)


(N, A, B) = map(int, input().split())
x = y = z = a = b = sum = 0
for i in range(1, N + 1):
	x = i % 10
	y = i % 100 // 10
	z = i % 1000 // 100
	a = i % 10000 // 1000
	b = i % 100000 // 10000
	if A <= x + y + z + a + b <= B:
		sum += i
print(sum)


(N, A, B) = list(map(int, input().split()))
s = 0
for i in range(1, N + 1):
	k = 0
	j = i
	while j > 0:
		k += j % 10
		j = j // 10
	if A <= k and k <= B:
		s = s + i
print(s)


(n, a, b) = map(int, input().split())
ans = 0
for i in range(1, n + 1):
	s = str(i)
	sum = 0
	for j in s:
		t = int(j)
		sum += t
	if a <= sum <= b:
		ans += i
print(ans)


(N, A, B) = map(int, input().split())

def calc(N):
	sum = 0
	while N > 0:
		sum += N % 10
		N //= 10
	return sum
sum_num = 0
for i in range(1, N + 1):
	ans = calc(i)
	if A <= ans <= B:
		sum_num += i
print(sum_num)


(n, a, b) = map(int, input().split())
ans = 0
for i in range(1, n + 1):
	l = len(str(i))
	total = 0
	for j in range(1, l + 1):
		total += int(str(i)[-j])
	if a <= total and total <= b:
		ans += i
print(ans)


(N, A, B) = list(map(int, input().split()))
ans = 0
for i in range(1, N + 1):
	M = i // 10000 + i % 10000 // 1000 + i % 1000 // 100 + i % 100 // 10 + i % 10
	if A <= M and M <= B:
		ans += i
print(ans)


(n, a, b) = map(int, input().split())
ans = 0
for i in range(n + 1):
	ans += [0, i][a <= sum([int(j) for j in list(str(i))]) <= b]
print(ans)


(n, a, b) = map(int, input().split())
count = 0
for i in range(1, n + 1):
	num = i
	digit = 0
	while num > 0:
		digit += num % 10
		num = num // 10
	if a <= digit <= b:
		count += i
print(count)


(a, b, c) = map(int, input().split())
y = 0
for x in range(a):
	if b <= sum(list(map(int, list(str(x + 1))))) <= c:
		y += x + 1
print(y)


(n, a, b) = map(int, input().split())
s = 0
for i in range(n + 1):
	if a <= sum(map(int, [_ for _ in str(i)])) <= b:
		s += i
print(s)


(n, lo, hi) = map(int, input().rstrip('\n').split())
print(sum([i if lo <= sum(map(int, str(i))) <= hi else 0 for i in range(n + 1)]))


(N, A, B) = map(int, input().split())
C = 0
for i in range(N + 1):
	T = 0
	for ii in str(i):
		T = T + int(ii)
	if T >= A and B >= T:
		C = C + i
print(C)


(N, A, B) = map(int, input().split())
ls = []
for n in range(1, N + 1):
	sm = sum((int(s) for s in str(n)))
	if A <= sm <= B:
		ls.append(int(n))
print(sum(ls))


(N, A, B) = map(int, input().split())

def aaa(n):
	sum = 0
	while n > 0:
		sum += n % 10
		n = n // 10
	return sum
sum = 0
for i in range(1, N + 1):
	a = aaa(i)
	if A <= a <= B:
		sum += i
print(sum)


(N, A, B) = map(int, input().split())
ans = 0
for i in range(1, N + 1):
	k = list(str(i))
	sum_i = 0
	for j in k:
		sum_i += int(j)
	if A <= sum_i <= B:
		ans += i
print(ans)


(n, a, b) = map(int, input().split())
c = 0
for i in range(1, n + 1):
	s = 0
	d = i
	while d != 0:
		s += d % 10
		d //= 10
	if a <= s <= b:
		c += i
print(c)


(N, A, B) = map(int, input().split())
s = 0
for i in range(1, N + 1):
	j = str(i)
	X = sum(map(int, j))
	if A <= X <= B:
		s = s + i
print(s)


(N, A, B) = map(int, input().split())
ans = []
for i in range(1, N + 1):
	j = i // 10000 + i % 10000 // 1000 + i % 1000 // 100 + i % 100 // 10 + i % 10 // 1
	if A <= j <= B:
		ans.append(i)
print(sum(ans))


(n_num, a_num, b_num) = map(int, input().split())

def digit_sum(num):
	str_num = str(num)
	digit_num = 0
	for s in str_num:
		digit_num += int(s)
	return digit_num
cnt = 0
for n in range(1, n_num + 1):
	if a_num <= digit_sum(n) <= b_num:
		cnt += n
print(cnt)


(N, A, B) = list(map(int, input().split()))
count = 0
ans = []
for i in range(1, N + 1):
	cal = []
	for k in str(i):
		cal.append(int(k))
	if A <= sum(cal) <= B:
		ans.append(i)
print(sum(ans))


(N, A, B) = list(map(int, input().split()))

def ten_sumfunc(n):
	ans = 0
	while n > 0:
		ans += n % 10
		n = n // 10
	return ans
total = 0
for i in range(N + 1):
	sum1 = ten_sumfunc(i)
	if A <= sum1 and sum1 <= B:
		total += i
print(total)


(N, A, B) = map(int, input().split())
cnt = 0
sum = 0
i = 0
for i in range(N + 1):
	j = 0
	tmpsum = 0
	l = list(str(i))
	for j in l:
		tmpsum += int(j)
	if tmpsum >= A and tmpsum <= B:
		sum += i
print(sum)


(n, a, b) = map(int, input().split())
ans = 0
for num in range(n + 1):
	str_num = str(num)
	num_list = list(str_num)
	total = sum([int(i) for i in num_list])
	if total >= a and total <= b:
		ans += num
print(ans)


(n, a, b) = map(int, input().split())
ans = 0
for i in range(1, n + 1):
	t = 0
	v = i
	while v > 0:
		t += v % 10
		v //= 10
	if a <= t <= b:
		ans += i
print(ans)


getints = lambda : map(int, input().split())
(n, a, b) = getints()
ans = 0
for i in range(1, n + 1):
	s = str(i)
	sum = 0
	for c in s:
		sum += int(c)
	if a <= sum <= b:
		ans += i
print(ans)


(n, a, b) = map(int, input().split())
s = 0
for i in range(1, n + 1):
	p = list(str(i))
	c = sum([int(i) for i in p])
	if a <= c <= b:
		s += i
print(s)


(n, a, b) = list(map(int, input().split()))
ans = 0
for i in range(1, n + 1):
	sum = 0
	x = i
	while x > 0:
		sum += x % 10
		x //= 10
	if a <= sum and sum <= b:
		ans += i
print(ans)


(n, a, b) = map(int, input().split())
c = 0
while n:
	c += n * (a <= sum(map(int, str(n))) <= b)
	n -= 1
print(c)


(N, A, B) = map(int, input().split())
ans_list = []
for i in range(0, N + 1):
	temp = list(map(int, str(i)))
	temp = sum(temp)
	if temp >= A and temp <= B:
		ans_list.append(i)
print(sum(ans_list))


(n, a, b) = map(int, input().split())
t = 0
for i in range(1, n + 1):
	s = sum(list(map(int, list(str(i)))))
	if a <= s and s <= b:
		t += i
print(t)


(N, A, B) = list(map(int, input().split()))
ans = 0
for i in range(1, N + 1):
	sum_all = 0
	tmp = i
	while tmp > 9:
		sum_all += tmp % 10
		tmp //= 10
	sum_all += tmp
	if sum_all >= A and sum_all <= B:
		ans += i
print(ans)


(n, a, b) = list(map(int, input().split()))
l = []
c = 0
k = 0
for i in range(n + 1):
	k = i
	c = 0
	while i > 0:
		c += i % 10
		i //= 10
	if a <= c <= b:
		l.append(k)
print(sum(l))


def sum_of_digits(i: int) -> int:
	result = 0
	for _ in range(len(str(i))):
		(i, mod) = divmod(i, 10)
		result += mod
	return result

def answer(n: int, a: int, b: int) -> int:
	some_sums = 0
	for i in range(1, n + 1):
		if a <= sum_of_digits(i) <= b:
			some_sums += i
	return some_sums

def main():
	(n, a, b) = map(int, input().split())
	print(answer(n, a, b))

def __starting_point():
	main()
__starting_point()


(n, a, b) = map(int, input().split())
cnt = 0
for i in range(1, n + 1):
	s = list(str(i))
	k = sum(map(int, s))
	if a <= k <= b:
		cnt += i
print(cnt)


(n, a, b) = list(map(int, input().split()))
ans = 0
for num in range(1, n + 1):
	p = num
	digit_sum = 0
	while p > 0:
		digit_sum += p % 10
		p //= 10
	if a <= digit_sum <= b:
		ans += num
print(ans)


(N, A, B) = map(int, input().split())
g = 0
for i in range(1, N + 1):
	k = sum([int(c) for c in str(i)])
	if A <= k <= B:
		g += i
print(g)


(n, a, b) = map(int, input().split())
cnt = 0
for i in range(1, n + 1):
	x = sum(map(int, str(i)))
	if a <= x <= b:
		cnt += i
print(cnt)


(N, A, B) = list(map(int, input().split()))
total = 0
for i in range(1, N + 1):
	subTotal = sum(list(map(int, str(i))))
	if subTotal >= A and subTotal <= B:
		total += i
print(total)


import sys
sys.setrecursionlimit(10 ** 6)
(n, a, b) = list(map(int, input().split()))
ans = 0
for i in range(1, n + 1):
	tmp = 0
	for j in str(i):
		tmp += int(j)
	if tmp >= a and tmp <= b:
		ans += i
print(ans)


(n, a, b) = list(map(int, input().split()))
s = 0
ans = 0

def findSumOfDigits(num):
	s = 0
	while num > 0:
		s += int(num % 10)
		num = int(num / 10)
	return s
for i in range(n + 1):
	s = findSumOfDigits(i)
	if a <= s <= b:
		ans += i
print(ans)


(n, a, b) = map(int, input().split())
print(sum([x if a <= sum(map(int, list(str(x)))) <= b else 0 for x in range(1, -~n)]))


(n, a, b) = list(map(int, input().split()))

def sum_digit(x):
	s = 0
	while x:
		s += x % 10
		x //= 10
	return s
print(sum([i for i in range(1, n + 1) if a <= sum_digit(i) <= b]))


(n, a, b) = map(int, input().split())
total = 0
for i in range(n + 1):
	j = eval('+'.join(str(i)))
	if a <= int(j) <= b:
		total += int(i)
print(total)


(N, A, B) = list(map(int, input().split()))
ans = 0
for i in range(N + 1):
	i = str(i)
	count = 0
	for j in i:
		count += int(j)
	if A <= count and B >= count:
		ans += int(i)
print(ans)


def findSumOfDigits(n):
	sum = 0
	while n > 0:
		sum += n % 10
		n //= 10
	return int(sum)
(N, a, b) = map(int, input().split())
c = 0
total = 0
for i in range(N + 1):
	c = findSumOfDigits(i)
	if a <= c <= b:
		total += i
print(total)


(n, a, b) = map(int, input().split())

def f(n):
	return a <= sum((int(i) for i in str(n))) <= b
print(sum((i for i in range(1, n + 1) if f(i))))


(N, A, B) = list(map(int, input().split()))
al = []
for i in range(1, N + 1):
	checkno = 0
	for j in range(len(str(i))):
		str_i = str(i)
		checkno += int(str_i[j])
	if A <= checkno and checkno <= B:
		al.append(i)
print(sum(al))


(N, A, B) = list(map(int, input().split()))
ans = []
for i in range(1, N + 1):
	target = 0
	for j in range(len(str(i))):
		target += int(str(i)[j])
	if A <= target <= B:
		ans.append(i)
print(sum(ans))


(N, A, B) = map(int, input().split())
Sum = 0
for i in range(N):
	o = (i + 1) // 10000
	a = (i + 1) % 10000 // 1000
	b = (i + 1) % 1000 // 100
	c = (i + 1) % 100 // 10
	d = (i + 1) % 10
	e = o + a + b + c + d
	if e >= A and e <= B:
		Sum = Sum + (i + 1)
print(Sum)


(N, A, B) = map(int, input().split())
s = 0
for x in range(N):
	if A <= sum(list(map(int, str(x + 1)))) <= B:
		s += x + 1
print(s)


def FindSumOfDigits(n):
	Sum = 0
	while n > 0:
		Sum += n % 10
		n //= 10
	return Sum
(N, A, B) = list(map(int, input().split()))
total = 0
for i in range(N):
	Sum = FindSumOfDigits(i + 1)
	if A <= Sum and Sum <= B:
		total += i + 1
print(total)


(N, A, B) = map(int, input().split())
ans = 0
for i in range(N + 1):
	x = i % 10
	if i >= 10:
		x += (i % 100 - i % 10) / 10
		if i >= 100:
			x += (i % 1000 - i % 100) / 100
			if i >= 1000:
				x += (i % 10000 - i % 1000) / 1000
				if i == 10000:
					x = 1
	if A <= x <= B:
		ans += i
print(ans)


(N, A, B) = map(int, input().split())
answer = 0
for i in range(N + 1):
	numStrList = list(str(i))
	numIntList = [int(s) for s in numStrList]
	if A <= sum(numIntList) <= B:
		answer += i
print(answer)


(N, A, B) = map(int, input().split())
C = 0
D = 0
for i in range(1, N + 1):
	C = 0
	for j in str(i):
		C = C + int(j)
	if A <= C <= B:
		D = D + i
print(D)


def solve(N, A, B):
	nums = []
	for n in range(1, N + 1):
		s = 0
		ns = str(n)
		for j in range(len(ns)):
			s += int(ns[j])
		if A <= s and s <= B:
			nums.append(n)
	print(sum(nums))

def __starting_point():
	(N, A, B) = list(map(int, input().split()))
	solve(N, A, B)
__starting_point()


(n, a, b) = list(map(int, input().split()))
ans = 0
for i in range(1, n + 1):
	mod = 0
	div = i
	while div > 0:
		mod += div % 10
		div //= 10
	if mod >= a and mod <= b:
		ans += i
print(ans)


def sumDigit(x):
	sum_ = 0
	while x > 0:
		sum_ += x % 10
		x //= 10
	return sum_
(N, A, B) = (int(x) for x in input().split())
ss = 0
for i in range(N):
	num = sumDigit(i + 1)
	if num >= A and num <= B:
		ss += i + 1
print(ss)


(a, b, c) = (int(i) for i in input().split())
print(sum([i for i in range(a + 1) if b <= sum([int(ii) for ii in list(str(i))]) <= c]))


(n, a, b) = map(int, input().split())
res = 0
for i in range(1, n + 1):
	tmp = sum([int(elem) for elem in list(str(i))])
	if a <= tmp and tmp <= b:
		res += i
print(res)


(N, A, B) = map(int, input().split())
ct = 0
for i in range(1, N + 1):
	x = sum((int(j) for j in str(i)))
	if A <= x <= B:
		ct += i
print(ct)


(N, A, B) = map(int, input().split())
ans = 0
for i in range(N):
	n = i + 1
	arr = list(map(int, str(n)))
	summ = sum(arr)
	if summ >= A and summ <= B:
		ans += n
print(ans)


x = list(map(int, input().split()))
n = int(x[0])
a = int(x[1])
b = int(x[2])
res = 0
for i in range(n + 1):
	m = sum([int(r) for r in list(str(i))])
	if a <= m <= b:
		res += i
print(res)