Problem:
 Score : 200 points    Problem Statement 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 1 20 2 5      Sample Output 1 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 .       Sample Input 2 10 1 2      Sample Output 2 13       Sample Input 3 100 4 16      Sample Output 3 4554

Solution (Python):
a = list(map(int,input().split()))
z = 0

for i in range(a[0]+1):
  b = list(str(i))
  c = list(map(int,b))
  d = sum(c)
  if a[1]<=d<=a[2]:
    z+=i
else:
  print(z)

Solution (Python):



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

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

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


def keta(n):
    result = 0
    for s in str(n):
        result += int(s)
    return result

ans = 0
for i in range(1, N+1):
    k = keta(i)
    if A <= k <= B:
        ans += i
print(ans)

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

Solution (Python):

def findSumOfDigits(n):
    sum = 0
    while n > 0:
        sum += n % 10
        n = n // 10
    return sum

def main():
    N, a, b = list(map(int, input().split()))
    total = 0
    for i in range(1,N+1):
        sum = findSumOfDigits(i)
        if ((sum >= a)and(sum <= b)):
            total += i
            
    print(total)
    
if __name__ == "__main__":
    main()

Solution (Python):
N, A, B = map(int, input().split(' '))

S = 0
for n in range(1, N + 1):
    sum = 0
    for r in range(0, 5):
        sum += n // 10**r % 10
    if (A <= sum <= B):
        S += n

print(S)

Solution (Python):
N, A, B = [int(i) for i in input().split()]
result = 0
for number in range(1, N + 1):
    sum_num = sum([int(i) for i in str(number)])
    if (sum_num >= A and sum_num <= B):
        result += number
print(result)

Solution (Python):
n, a, b = map(int, input().split())
i_sum_sum = 0

def disassemble(i):
    ilist = []
    while i > 0:
        ilist.append(i%10)
        i //= 10
    ilist.reverse()
    i_sum = sum(ilist)
    return(i_sum)

for i in range(1, n+1):
    i_sum = disassemble(i)
    if a <= i_sum <= b:
        i_sum_sum += i

print(i_sum_sum)

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

amount = 0
for v in range(1, n+1):
    tmp = v
    s = 0
    while True:
        t = int(tmp % 10)
        tmp /= 10
        s += t
        if tmp == 0:
            break

    if a <= s and s <= b:
        amount += v

print(amount)

Solution (Python):


def calcsum(i):
	sum = 0
	while (i>0):
		sum += i%10
		i -= i%10
		i = i/10
	
	return sum

tmparr = input().split()

n = int(tmparr[0])
a = int(tmparr[1])
b = int(tmparr[2])
sum = 0





for i in range(n+1):
	tmp = calcsum(i)
	if(tmp >= a):
		if(tmp <= b):
			sum += i
print(sum)

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

y = 0
for i in range(n+1):
    x = 0
    j = i
    while j > 0:
        x += j % 10
        j //= 10
    if x >= a and x <= b:
        y += i
print(y)

Solution (Python):
row = input().split()
N = int(row[0])
A = int(row[1])
B = int(row[2])
ans = 0
for i in reversed(range(A,N+1)):
    temp = i
    order = []
    for j in reversed(range(0, 5)):
        order.append(int(temp / (10**j)))
        temp = temp - int(temp / (10**j))*10**j
    if A <= sum(order) <= B:
        ans += i
print(ans)

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

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

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

Solution (Python):
N, A, B = (int(i) for i in input().split())

sum = 0
for i in range(N + 1):
    
    digitsum = 0
    i_copy = i
    while i > 0:
        digitsum += i % 10
        i = i // 10

    if A <= digitsum <= B:
        sum += i_copy
print("{}".format(sum))

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

ans=0

for i in range(n+1):
    str_n=str(i)
    sum_n=0
    
    for j in range(len(str_n)):
        sum_n += int(str_n[j])
    if sum_n>=a and sum_n<=b:
        ans+=i
            
print(ans)

Solution (Python):
n,a,b=(int(x) for x in input().split())

s = 0
out = 0

for x in range(n+1):
    x_str = str(x)
    array = list(map(int,x_str))
    s = sum(array)

    if a<=s<=b:
        out += x

print(out)

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

print(result)

Solution (Python):

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

for i in range(N):
    i += 1

    i_st = str(i)

    now = 0
    for j in i_st:

        now += int(j)

    if A <= now and now <= B:
        ans += i

print (ans)

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

nums=[]
for i in range(1,n+1):
    nums.append(i)


ans=[]

for j in nums:
    n=list(map(int,str(j)))
    
    if a<=sum(n)<=b:
        ans.append(j)


print(sum(ans))

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

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

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

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

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

Solution (Python):
length,mi,ma = map(int,input().split())
summ = 0
for i in range(1,length + 1):
  digits = len(str(i))
  digits_summary = 0
  
  for j in range(digits):
    digits_summary += int(str(i)[j])
  
  if mi<=digits_summary and digits_summary<=ma:
    summ += i
  else:
    pass
print(summ)

Solution (Python):
n,a,b = map(int,input().split())
ans = 0
i = 1
for i in range(1,n+1):
    x = 0
    num = str(i)
    for p in num:
        x += int(p)
    if a <= x <= b:
        ans += i
        i += 1
print(ans)

Solution (Python):
n,a,b = map(int,input().split())
ans = 0
i = 1
while i <= n:
    x = 0
    li = list(str(i))
    for p in li:
        x += int(p)
    if a <= x <= b:
        ans += i
        i += 1
    else:
        i += 1
print(ans)

Solution (Python):

import time
import re
import math
import fractions

def main():
    N,A,B=map(int,input().split())
    count=0
    for a in range(1,N+1):
        s=str(a)
        total=0
        for b in s:
            total+=int(b)
        if A<=total and total<=B:
            count+=a
    print(count)
start=time.time()
main()

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

Solution (Python):
from sys import stdin

n,a,b = [int(x) for x in stdin.readline().rstrip().split()]
sum = 0



for i in range(n+1):
        
        if (a<= i//10000 + (i-i//10000*10000)//1000 + (i-i//1000*1000)//100 + (i-i//100*100)//10 + i%10 <=b):
            sum += i

"""

for i in range(n+1):
    i_sum = 0
    i_num = i
    print("i_num:"+str(i_num))
    while(True):
        if(i_num//10 ==0):
            i_sum += (i_num%10)
            break
        else:
            i_sum += (i_num%10)
            i_num = i_num//10
    if(a<= i_sum <= b):
        print(i_sum)
        sum += i
print("-------------------")
"""
print(sum)

Solution (Python):
Lis = list(map(int,input().split()))
ans = 0
for k in range(Lis[0]+1):
    if k%10 + (k//10)%10 + (k//100)%10 + (k//1000)%10 <= Lis[2] and k%10 + (k//10)%10 + (k//100)%10 + (k//1000)%10 >= Lis[1]:
        ans += k
if Lis[0] == 10000 and Lis[1]<2:
           print(ans+10000)
else:
           print(ans)

Solution (Python):
n, a, b = map(int, input().split())
 
sum = 0
for i in range(n+1) :
    count = 0
    for num in str(i) :
        count += int(num)
 
    if (count >= a) and (count <= b) :
        sum += i
            
print(sum)

Solution (Python):
N, A, B = map(int, input().split())
 
sum = 0
for i in range(1, N+1):
  if i < 10:
    if A <= i and i <= B:
        sum += i
  elif i < 100:
    temp = int(i/10) + i%10
    if A <= temp and temp <= B:
      sum += i
  elif i < 1000:
    temp = int(i/100) + int(i%100/10) + i%100%10
    if A <= temp and temp <= B:
      sum += i
  elif i < 10000:
    temp = int(i/1000) + int(i%1000/100) + int(i%1000%100/10) + i%1000%100%10
    if A <= temp and temp <= B:
      sum += i
  else:
    temp = int(i/10000)
    if A <= temp and temp <= B:
      sum += i
      
print(sum)

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

count = 0

'''                                                                            
def keta_sum(n):                                                               
    sum = 0                                                                    
    while n>0:                                                                 
        sum += n%10 
        n = n//10 
    return(sum)                                                                
'''

for i in range(N):
    keta = sum(list(map(int,str(i+1))))

    if keta >= A and keta<= B:
      
        count += (i+1)

print(count)

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

S = 0
for num in range(N+1):
    str_num = str(num)
    c = 0
    for s in str_num:
        c += int(s)
    if A <= c <= B:
        S += num
print(S)

Solution (Python):
num_max,a,b = map(int,input().split())
total_count = 0
for num in range(1,num_max+1):
    count = 0
    num_str = str(num)
    for i in num_str:
        count += int(i)
    if count <= b and count >= a:
        total_count += num
print(total_count)

Solution (Python):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, A, B = nl()

count = 0
for i in range(1, N+1):
    total = 0
    for c in str(i):
        total += int(c)
    if A <= total and total <= B:
        count += i

print(count)

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

def sumdigit(num):
    sum=0
    for i in num:
        sum+=int(i)
    return sum

ans=0
for i in range(1,n+1):
    sum=sumdigit(str(i))
    if a<=sum<=b:
        ans+=i
print(ans)

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

def find_sum_of_digits(n):
  s = str(n)
  sum = 0
  

  for i in range(0,len(str(n))):
    sum = sum + int(s[i])
  return sum

total = 0
for number in range(1,N+1):
  all_sum = find_sum_of_digits(number)
  if A <= all_sum and all_sum <= B:
    total = total + number

print(total)

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

Solution (Python):
n, a, b = map(int,input().split())
count = 0
for i in range(n+1):
    nums = list(map(int,list(str(i))))
    numSum = sum(nums)
    if a<=numSum<=b:
        count += i
print(count)

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

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

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

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

Solution (Python):
n, a, b = map(int, input().split())
 
sum = 0
for i in range(n+1) :
    count = 0
    for num in str(i) :
        count += int(num)
 
    if (count >= a) and (count <= b) :
        sum += i
            
print(sum)

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

cnt = 0

for i in range(1,n+1):
    num = list(map(int,list(str(i))))
    if (a<=sum(num)) and (sum(num) <= b):
        cnt += i

print(cnt)

Solution (Python):
def sumd(x):
    s = str(x)
    ret = 0
    for i in range(len(s)):
        ret += int(s[i])
    return ret


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

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

res = 0
for i in range(1, N+1):
    tmp = sum(list(map(int, list(str(i)))))
    if A <= tmp and tmp <= B:
        res = res + i

print(res)

Solution (Python):
s = input().split()
N = int(s[0])
A = int(s[1])
B = int(s[2])
k = 0
for i in range(1,N+1):
  S = 0
  l = i
  while l >= 1:
    p = l%10
    l = l//10
    S = S + p
  if A <= S <= B:
    k = k + i
print(k)

Solution (Python):
s = input().split()
N = int(s[0])
A = int(s[1])
B = int(s[2])
k = 0
for i in range(1,N+1):
  S = 0
  p = str(i)
  q = [str(c) for c in p]
  q = list(map(int,q))
  for j in range(len(q)):
    S = S + q[j]
  if A <= S <= B:
    k = k + i
print(k)

Solution (Python):
N,A,B = (int(x) for x in input().split())
ans = 0
for n in range(1,N+1):
  temp = [int(x) for x in str(n)]
  if A <= sum(temp) <= B:
    ans+= n
print(ans)

Solution (Python):
n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
    si=str(i)
    ti=0
    for s in si:
        ti+=int(s)
    if a<=ti and ti<=b:
        ans+=i
print(ans)

Solution (Python):
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)

Solution (Python):
def abc():
    n, a, b = map(int, input().split())
    total = 0
    for i in range(1, n+1):
        if a <= sum(map(int, str(i))) <= b:
            total += i
    print(total)


abc()

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

ret = 0
for i in range(1, n+1):
    i_nums = list(map(int, str(i)))
    i_sum = sum(i_nums)
    if i_sum >= a and i_sum <= b:
        ret += i
        
print(ret)

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

Solution (Python):
import sys

def input():
    return sys.stdin.readline().rstrip()

if __name__ == "__main__":
    n, a, b = map(int, input().split())
    
    res = 0
    for i in range(1, n+1):
        if a <= sum(list(map(int, list(str(i))))) <= b:
            res += i
    
    print(res)

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

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


def find_sum_of_digits(n):
    sum_num = 0
    while (n>0):
        sum_num += n % 10
        n = n // 10
    return sum_num

total = 0
for i in range(N+1):
    sum_num = find_sum_of_digits(i)
    if A <= sum_num <= B:
        total += i
print(total)

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

ok_nums = []
ok_nums_append = ok_nums.append

for i in range(N+1):
    i_s = str(i)

    if A <= sum(list(map(int, list(i_s)))) <= B:
        ok_nums_append(i)

print(sum(ok_nums))

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

Solution (Python):

import sys


def solve(N: int, A: int, B: int):

    res = 0
    for i in range(1,N+1):
        t = 0
        for c in str(i):
            t += int(c)
        if A <= t <= B:
            res += i
    print(res)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = int(next(tokens))  
    B = int(next(tokens))  
    solve(N, A, B)

if __name__ == '__main__':
    main()

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

result = 0
for i in range(1,n+1):
    temp = i
    res = 0
    while temp > 0:
        res += temp % 10
        temp = temp // 10
    if a <= res <= b:
        result += i

print(result)

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

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

def calsum(x):
    a = 0
    while x > 0:
        a += x % 10
        x = x // 10
    return a
ans = 0
for i in range(N+1):
    if A <= calsum(i) and calsum(i) <= B:
        ans += i
print(ans)

Solution (Python):
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N, A, B = list(map(int, sys.stdin.readline().split()))

ans = 0
for i in range(1, N + 1):
    if A <= sum(map(int, list(str(i)))) <= B:
        ans += i

print(ans)

Solution (Python):

data = input().split(" ")

N = int(data[0])
A = int(data[1])
B = int(data[2])

total_sum = 0

for i in range(N+1):
    sum = 0
    tmp = i
    while tmp > 0:
        sum += tmp % 10;
        tmp = int(tmp/10)
    if sum >= A and sum <= B:
        total_sum += i

print(total_sum)

Solution (Python):

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

Solution (Python):
n,a,b = map(int,input().split())
count = 0
aaa = [str(i) for i in range(1,n+1)]
for j in aaa:
    m = 0
    for k in j:
        m += int(k)
    if a <= m <= b:
        count += int(j)
        
print(count)

Solution (Python):
n, a, b = [int(x) for x in input().split()]
count = 0
for i in range(a, n+1):
    if a <= sum([int(x) for x in list(str(i))]) <= b:
        count += i
print(count)

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

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

Solution (Python):
n,a,b=map(int,input().split())
ans=0
def digitsum(n):
  l=len(str(n))
  re=0
  for i in range(l):
    re+=int(str(n)[i])
  return re
for i in range(n+1):
  if a<=digitsum(i)<=b:
    ans+=i
print(ans)

Solution (Python):
N,A,B = list(map(int, input().split(" ")))



ans_list = []
for i in range(1,N+1):
    num = str(i)
    n_sum = 0
    for n in num:
        n_sum += int(n)

    if A<=n_sum<=B:
        ans_list.append(i)


print(sum(ans_list))

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

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

Solution (Python):
import re  
import sys 


def i_input(): return int(input())
def s_input(): return map(int,input().split())
def l_input(): return list(map(int, input().split()))


n, a, b = s_input()

i_sum = 0
for i in range(n + 1):
    str_i = str(i)
    j_sum = 0
    for j in str_i:
        j_sum += int(j)

    if j_sum >= a and j_sum <= b:
        i_sum += i

print(i_sum)

Solution (Python):
def check(i,A,B):
    k = 0
    for j in range(len(str(i))):
        k += i % 10
        i = int(i/10)
    if k >= A and k <= B:
        return 1
    else:
        return 0

N,A,B = map(int,input().split())
num = 0
for i in range(N + 1):
    c = check(i,A,B)
    if c == 1:
        num += i
print(num)

Solution (Python):
N, A, B = map(int, input().split())
ans = 0
for i in range(N+1):
    lis = [int(i) for i in str(i)]
    if A <= sum(lis) <= B:
        num = ""
        for j in lis:
            num += str(j)
        ans += int(num)
print(ans)

Solution (Python):


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

for i in range(1,n+1):
    st = str(i)
    stp = 0

    for j in st:
        stp += int(j)

    if a <= stp <= b:
        ans += i

print(ans)

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

ans = 0
for i in range(1, N+1):
  wa = i//10000 + (i//1000)%10 + (i//100)%10 + (i//10)%10 +i%10
  if A <= wa and wa <= B:
    ans += i
print (ans)

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

ans = 0
for i in range(1, N+1):
  wa = i//10000 + (i//1000)%10 + (i//100)%10 + (i//10)%10 +i%10
  if A <= wa and wa <= B:
    ans += i
print (ans)

Solution (Python):
i = list(input().split(' '))



n = []
for x in range(1,int(i[0])+1):
  num = list(str(x))
  num_sum = sum(list(map(int,num)))

  if int(i[1]) <= int(num_sum) <= int(i[2]):
      n.append(x)
      
    
print(sum(n))

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

Solution (Python):
if __name__ == '__main__':
    N, A, B = list(map(int, input().split(' ')))
    
    c = 0
    for x in range(1, N+1):
        if A <= sum(list(map(int, list(str(x))))) <= B:
            c += x
            
    print(c)

Solution (Python):
def sumofdegit(x):
  sum = 0
  while x > 0:
    sum += x % 10
    x //= 10
  return sum

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

Solution (Python):
N, A, B = map(int, input().split())
ans = 0
def sumsum(x):
    k = 0
    while(x != 0):
        t, x = x%10, x//10
        k += t
    return k
for i in range(1,N+1):
    if A <= sumsum(i) <= B:
        ans += i
print(ans)

Solution (Python):
n, a, b = map(int, input().split())
 
ans = 0
for i in range(n+1):
    if a <= i//10000 + i//1000%10 + i//100%10 + i//10%10 + i%10 <= b:
        ans += i
print(ans)

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

Solution (Python):

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

ans = 0

for n in range(1, N+1):
    mn = str(n)
    lst_n = list(mn)
    sum = 0
    for i in range(len(lst_n)):
        sum += int(lst_n[i])
    if (sum >= A) and (sum <= B):
        ans += n

print(ans)

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

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

Solution (Python):
import math

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

if __name__ == '__main__':
    main()

Solution (Python):
N, A, B = map(int, input().split())
ans = 0

for i in range(1, N + 1):
    I = str(i)
    sum_i = 0
    for j in range(len(I)):
        sum_i += int(I[j])

    if A <= sum_i <= B:
        ans += i

print(ans)

Solution (Python):

import sys

def sum_dig(n):
    ret = 0
    while n > 0:
        ret += n % 10
        n //= 10
    return ret

def solve(N: int, A: int, B: int):
    ret = 0
    for i in range(1, N + 1):
        if A <= sum_dig(i) <= B:
            ret += i
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = int(next(tokens))  
    B = int(next(tokens))  
    solve(N, A, B)

if __name__ == '__main__':
    main()

Solution (Python):
N,A,B=map(int,input().split())
k=0
C=[]
for i in range(1,N+1):
    i=str(i)
    C=[int(a) for a in i]
    z=sum(C)
    if A<=z and z<=B:
        k+=int(i)
print(k)

Solution (Python):











import sys
input=sys.stdin.readline
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [input() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,A,B = MI()
    ans = 0
    def digit_sum(n):
        l = list(str(n))
        s=0
        for i in l:
            a = int(i)
            s+=a
        return s

        
    for i in range(1, N + 1):
        if A <= digit_sum(i) <= B:
            ans += i
    print(ans)
if __name__ == '__main__':
    main()

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

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

print(ans)

Solution (Python):
n, a, b = map(int,input().split())
num = 0
for i in range(1, n+1):
  isum = 0
  m = i
  while m != 0:
    isum += m%10
    m = m//10
  if a <= isum <= b:
    num += i
print(num)

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

def add(n,a,b):
    ls = list(str(n))
    pl = sum([int(i) for i in ls])
    if a<= pl and pl<= b:
        return n
    else:
        return 0

flg = 0
for i in range(n+1):
    flg += add(i,a,b)

print(flg)

Solution (Python):
n, a, b = list(map(int, input().split()))
ans = 0

for i in range(1, n+1):
    sumNum = sum(list(map(int, list(str(i)))))
    if sumNum < a:
        continue
    if sumNum > b:
        continue
    ans += i
print(ans)

Solution (Python):
n,a,b=map(int,input().split())
l1=[]
for i in range(1,n+1):
  l=map(int,list(str(i)))
  s=sum(l)
  if s>=a and s<=b:
    l1.append(i)
print(sum(l1))

Solution (Python):
input_nums = input().split()
n = int(input_nums[0])
a = int(input_nums[1])
b = int(input_nums[2])

total = 0

for num in range(1, n+1):
    num_list = list(str(num))
    num_list_int = [int(i) for i in num_list]
    num_list_sum = sum(num_list_int)
    if num_list_sum >= a:
        if num_list_sum <= b:
            total += num
            
print(total)

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

l = []
for num in range(1, n+1):
  total = 0
  for c in str(num):
    total = total + int(c)
  if total >= a and total <= b:
    l.append(num)

print(sum(l))

Solution (Python):
def calc_sum_digit(N):
    sum_digit = 0
    while N > 0:
        sum_digit += N%10
        N = N//10
    return sum_digit


if __name__ == '__main__':
    N, A, B = map(int, input().split())

    answer = 0
    for i in range(1, N+1):
        sum_digit = calc_sum_digit(i)
        if A <= sum_digit <= B:
            answer += i

    print(answer)

Solution (Python):
N, A, B = [int(i) for i in input().split()]

ans = 0
for i in range(1, N + 1):
    if A <= sum(int(s) for s in str(i)) <= B:
        ans += i

print(ans)

Solution (Python):
n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
 k=i//10000+i//1000%10+i//100%10+i//10%10+i%10
 if a<=k<=b:
  ans+=i
print(ans)

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

memo = [0]*37

def S(n):
  if n<10:
    return n
  return n%10+S(n//10)

for n in range(1,N+1):
  memo[S(n)] += n

answer = sum(memo[A:B+1])
print(answer)

Solution (Python):
n, a, b = [int(i)  for i in input().split()]
s = 0

for i in range(n+1):
    if a <= sum(list(map(int, str(i)))) <= b :
        s += i

print(s)

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

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

Solution (Python):
N,A,B = list(map(int,input().split(" ")))

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

Solution (Python):
N,A,B = list(map(int,input().split(" ")))
 
def check(n,c):
    c+=n%10
    return (c if n/10==0 else check(int(n/10),c))
 
print(sum([i for i in range(1,N+1) if A<=check(i,0)<=B]))

Solution (Python):
def some_sums(n):
  answer = 0
  a = n // 10
  if a > 0:
    answer = some_sums(a)
  b = n % 10
  answer = answer + b
  return answer

N,A,B = [int(i) for i in input().split()]

some_sums_list = [some_sums(i+1) for i in range(N)]
answer_list = [i+1 for i in range(N) if some_sums_list[i]>=A and some_sums_list[i]<=B]
answer = sum(answer_list)
print(answer)

Solution (Python):


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

    ans = 0
    for i in range(1, N+1):
        keta_sum = 0
        num = i
        while True:
            if num == 0:
                break
            keta_sum += num%10
            num = num//10

        if keta_sum >= A and keta_sum <= B:
            ans += i
    
    print(ans)

if __name__ == "__main__":
    solve()

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

ans = 0
for i in range(1, N+1):
    d1 = i % 10
    d1 += (i % 100) // 10
    d1 += (i % 1000) // 100
    d1 += (i % 10000) // 1000
    d1 += (i % 100000) // 10000
    if A <= d1 <= B:
        ans += i

print(ans)

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

def findSumOfDigits(n):
    sum = 0
    while n > 0:
        sum += n % 10
        n = n // 10
    return sum

total = 0

for i in range(N+1):
    sum = findSumOfDigits(i)
    if (A <= sum <= B):
        total += i

print(total)

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

Solution (Python):
str = input().split()
N = int(str[0])
A = int(str[1])
B = int(str[2])

SUM = 0
for i in range(N+1):
    a = i % 10
    b = int(i / 10) % 10
    c = int(i/100) % 10
    d = int(i/1000) %10
    e = int(i/10000) % 10
    if a+b+c+d+e >= A and a+b+c+d+e <= B:
        SUM = SUM + i
        
print(SUM)

Solution (Python):

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


num = 0
for i in range(1, N + 1):
    s = 0
    tmp = i
    while True:
        if i == 0:
            break
        s += i % 10
        i = int(i / 10)
    if A <= s and s <= B:
        num += tmp

print(num)

Solution (Python):
n,a,b = map(int,input().split())
ans = 0
for c in range(10):
    for i in range(10):
        for j in range(10):
            for k in range(10):
                for l in range(10):
                    if c*10000 + i*1000 + j*100 + k*10 + l <= n and c + i + j + k + l >= a and c + i + j + k + l <= b:
                        ans = ans + c*10000 + i*1000 + j*100 + k*10 + l
print(ans)