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):
[n, a, b] = list(map(int, input().split()))
ans = 0
for i in range(1, n + 1):
    p = i
    sum_of_digit = 0
    while p != 0:
        sum_of_digit += p % 10
        p = p // 10
    if sum_of_digit >= a and sum_of_digit <= b:
        ans += i
print(ans)

Solution (Python):
def LI(): return [int(x) for x in input().split(" ")]
def LS(): return [str(x) for x in input().split(" ")]
def ItoS(L): return [str(x) for x in L]
def StoI(L): return [int(c) for c in L]


def solve():
    n, a, b = LI()
    cnt = 0
    for i in range(1, n + 1):
        tmp = i
        i = list(str(i))
        if a <= sum(StoI(i)) <= b:
            cnt += tmp

    print(cnt)


solve()

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

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

print(answer)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,a,b = LI()
    r = 0
    for i in range(1,n+1):
        s = sum([int(_) for _ in str(i)])
        if a <= s <= b:
            r += i

    return r



print(main())

Solution (Python):


num, mini, maxi = map(int, input().rstrip().split())
hani = range(mini,maxi+1)

atari = []

for i in range(1,num+1):
    num_list = list(map(int, str(i)))
    goukei = sum(num_list)
    if goukei in hani:
        atari.append(i)
    

print(sum(atari))

Solution (Python):



import sys

def digit_sum(n):
    s = str(n)
    array = list(map(int, list(s)))
    return sum(array)

n, a, b = sys.stdin.readline().split(" ")
n = int(n)
a = int(a)
b = int(b)
ans = 0
for i in range(1, n + 1):
    if a <= digit_sum(i) <= b:
        ans += i
print(ans)

Solution (Python):
N, A, B = map(int, input().split(' '))
sum_digits = 0
for num in range(1, N + 1):
    sum_digit = 0
    tmp = num
    while True:
        if tmp < 10:
            sum_digit += tmp
            break
        digit = tmp % 10
        tmp //= 10
        sum_digit += digit

    if A <= sum_digit <= B:
        sum_digits += num

print(sum_digits)

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

def can(x):
  global A,B
  sum=0
  while x > 0:
    x, a = divmod(x, 10)
    sum += a
  if A <= sum <= B:
      return True    

res = 0
for i in xrange(1, N+1):
  if can(i):
    res += i

print res

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

total = 0
for i in range(1, n[0]+1):
    sum = 0
    number = str(i)
    for k in range(len(number)):
        sum += int(number[k])
    if n[1] <= sum <= n[2]:
        total += i
print(total)

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

def getTotal(num):
    tmp=0
    for s in str(num):
        tmp+=int(s)
    return tmp

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

print(sum)

Solution (Python):
[n, a, b] = map(int, input().split(" "))
total_sum = 0

for i in range(n):
    num = i + 1
    numbers = []
    while num > 0:
        numbers += [num % 10]
        num = num // 10
    if sum(numbers) >= a and sum(numbers) <= b:
        total_sum += i + 1

print(total_sum)

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

Solution (Python):
def digitSum(num):
    res = 0
    while num > 0:
        res = res + num % 10
        num = int(num / 10)
    return res


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

    ans = 0;
    for i in range(n):
        ds = digitSum(i + 1)
        if ds >= a and ds <= b:
            ans = ans + i + 1

    print (ans)

main()

Solution (Python):
def inputs():
    s = input()
    li = s.split(" ")
    return(int(li[0]), int(li[1]), int(li[2]))

def digitSum(num):
    sum = 0
    while(num > 0):
        sum += (num % 10)
        num //= 10
    return(sum)

def rangeSum(N, A, B):
    allsum = 0
    for i in range(1, N+1):
        tmpsum = digitSum(i)
        if(A <= int(tmpsum) <= B):
            allsum += i
    return(allsum)

def main():
    N, A, B = inputs()
    sum = rangeSum(N, A, B)
    print(sum)

if __name__ == '__main__':
    main()

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

    sumv = 0
    for x in range(a, n+1):
        num = sum([int(i) for i in str(x)])
        if num >= a and num <= b: sumv += x
    print(sumv)


if __name__ == '__main__':
    main()

Solution (Python):

from functools import reduce

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

for i in range(1, n + 1):
    str_num = '0' + str(i)
    num = reduce(lambda a, b:int(a) + int(b), list(str_num))
    if num >= a and num <= b:
        result += i
print(result)

Solution (Python):
import sys
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache, reduce
from operator import xor
from heapq import heappush, heappop
INF = float("inf")
sys.setrecursionlimit(10**7)


dy4, dx4 = [0, -1, 0, 1], [1, 0, -1, 0]


def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def ceil(a, b): return (a + b - 1) // b


def ok(n, A, B):
    ans = 0
    for c in str(n):
        ans += int(c)
    return A <= ans <= B


def main():
    N, A, B = map(int, input().split())
    ans = 0
    for n in range(1, N + 1):
        if ok(n, A, B):
            ans += n
    print(ans)


if __name__ == '__main__':
    main()

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
 else:
  ans+=0
print(ans)

Solution (Python):

n, a, b = map(int, input().split())
ans = 0
for tmp in range(1, n+1):
    c = sum(list(map(int, list(str(tmp)))))
    if c >= a and c <= b:
        ans += tmp
    else:
        pass
else:
    print(ans)

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

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

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

for i in range(N+1):
    t_sum = 0
    for e in str(i):
        t_sum += int(e)
    if A<= t_sum <= B:
        ans += i
        
print(ans)

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

ans=0

for i in range(1,N+1):
        s=str(i)
        num=sum([int(j) for j in s])
        if A<=num and num<=B:
                ans+=i
print(ans)

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

Solution (Python):
n,a,b=map(int,input().split())
def judge(x):
    ans=0
    while x!=0:
        ans+=x%10
        x=x//10
    if ans>=a and ans<=b:
        return True
    else:
        return False
sum=0
for i in range(1,n+1):
    if judge(i):
        sum+=i
print(sum)

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

Solution (Python):
n,a,b = map(int, input().split())
def f(x):
  ret = 0
  while(x > 0):
    ret += x % 10
    x //= 10
  return ret
nums = filter(lambda x: f(x) >= a and f(x) <= b, range(1, n + 1))
print(sum(nums))

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

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

def digit_sum(num):
    num = str(num)
    out = 0
    for i in num:
        out += int(i)
    return out

final = 0
for i in range(1, N+1):
    if A <= digit_sum(i) <= B:
        final += i
print(final)

Solution (Python):


n,a,b=map(int,raw_input().split())
res=0
l=[]
for i in xrange(1,n+1):
 s=str(i)
 sums=0
 for j in xrange(len(s)):
  sums+=int(s[j])
 l.append(sums)
for i in xrange(len(l)):
 if l[i]>=a and l[i]<=b:
  res+=i+1
print res

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

print(ans)

Solution (Python):

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

Solution (Python):

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

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

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

print(res)

Solution (Python):
def getSumDigits(k):
   ret = 0
   while k:
      ret += k%10
      k //= 10
   return ret

N,A,B = map(int, input().split())
ret = 0
for i in range(1,N+1):
   if A <= getSumDigits(i) <= B:
      ret += i

print(ret)

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

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

print(sum(ans))

Solution (Python):
import sys
import math

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

Solution (Python):
N, A, B = map(int,input().split())
sum = 0
for i in range(1,N+1):
    i10000 = i // 10**4
    i1000 = (i - i10000*(10**4)) // 10**3
    i100 = (i - i10000*(10**4) - i1000*(10**3)) // 100
    i10 = (i - i10000*(10**4) - i1000*(10**3)- i100*(10**2)) // 10
    i1 = i - i10000*(10**4) - i1000*(10**3)- i100*(10**2) -i10*10
    if A <= i10000 + i1000 + i100 + i10 + i1 <= B:
        sum = sum + i

print(sum)

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

Solution (Python):
import math
N,A,B = map(int,input().split())
ans = 0
for i in range(1,N+1):
    sum_temp = sum(map(int,list(str(i))))
    if A<=sum_temp<=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)
    t_sum = sum(map(int, list(s)))
    if t_sum >= A and t_sum <= B:
        ans += i
print(ans)

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

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

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

Solution (Python):
import math

l = tuple(map(int, input().split()))

ans = 0

for i in range(1, l[0]+1):
    n = i
    v0 = n % 10
    n /= 10
    v1 = n % 10
    n /= 10
    v2 = n % 10
    n /= 10
    v3 = n % 10
    n /= 10
    v4 = n % 10
    sum = math.floor(v0) + math.floor(v1) \
     + math.floor(v2) + math.floor(v3) + math.floor(v4)
    if(l[1] <= sum and sum <= l[2]):
        ans += i
print(ans)

Solution (Python):
n,a,b = map(int,input().split())
sum = 0
for i in range(n):
	s = i+1
	x = s%10
	y = ((s-x)%100)
	z = ((s-x-y)%1000)
	w = ((s-x-y-z)%10000)
	q = ((s-x-y-z-w)%100000)
	t = x+y//10+z//100+w//1000+q//10000
	if a<=t<=b:
		sum += s
print(sum)

Solution (Python):
n, a, b = map(int, input().split())
cnt = 0
for i in range(1,n+1):
    s = list()
    l = str(i)
    for j in range(len(l)):
        s.append(int(l[j]))
    if a <= sum(s) and sum(s) <= b:
        hoge = map(str, s)
        hoge = ''.join(hoge)
        cnt += int(hoge)

print(cnt)

Solution (Python):
N,A,B=list(map(int, input().split()))
sum=0
count=0
flag=False
for i in range(0,10):
    for j in range(0,10):
        for k in range(0,10):
            for l in range(0,10):
                if count==N+1:
                    break

                count+=1

                if count==1:
                    continue

                if i+j+k+l>=A and i+j+k+l<=B:
                    sum+=i*1000+j*100+k*10+l
    if flag:
        break

if count==10000 and A==1:
    sum+=10000
print(sum)

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

RESULT = 0

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

Solution (Python):
n,a,b = map(int, input().split())
c = 0
for i in range(1,n+1):
  n4 = i//10**4
  n3 = i//10**3 - n4*10
  n2 = i//10**2 - n4*100 - n3*10
  n1 = i//10**1 - n4*1000 - n3*100 -n2*10
  n0 = i - n4*10000 -n3*1000-n2*100-n1*10
  total = n4+n3+n2+n1+n0
  if total>=a and total<=b:
    c+= i
print(c)

Solution (Python):

N, a, b= map(int, input().split())
summation = 0

for i in range(N+1):
    num = i
    total = 0
    while num != 0:
        q, mod = divmod(num, 10)
        total += mod
        num = q
    
    if total >= a and total <= b:
        summation += i
    
print(summation)

Solution (Python):


import sys
from math import *
if __name__ =="__main__":
    str_in = input()
    num = [int(n) for n in str_in.split()]
    N,A,B=num
    SUM=0
    if N<0 or N>(10**4) or A<0 or B<0 or A>36 or B>36 or A>B:
        print("error input!")
    else:
        for i in range(1,(N+1)):
            
            ii0 = int((i / 1) % 10 )
            ii1 = int((i / 10) % 10)
            ii2 = int((i / 100) % 10)
            ii3 = int((i / 1000) % 10)
            ii4 = int((i / 10000) % 10)
            
            SUMi=ii4+ii3+ii2+ii1+ii0
            if(SUMi>=A and SUMi<=B):
                SUM+=i
        print(SUM)

Solution (Python):
a=map(int, raw_input().split())
ans=0
for i in range(a[0]):
    i+=1
    b=list(str(i))
    pre=0
    for j in b:
        pre+=int(j)
    if pre>=a[1] and pre<=a[2]:
        ans+=i
print ans

Solution (Python):
INPUT=input()
IN=INPUT.split(" ")

number=int(IN[0])

A=int(IN[1])
B=int(IN[2])

GOUKEI=0
kazu=0

while kazu<=number:
    X=list(map(int,list(str(kazu))))
    
   
    
    if A<=sum(X)<=B:
        GOUKEI+=kazu
        
    kazu+=1
print(GOUKEI)

Solution (Python):
n, a, b = (int(x) for x in input().split())
c = 0
sum = 0
for i in range(1, n+1):
  c += 1
  if a <= c <= b:
    sum += i
  while i%10 == 9:
    c -= 9
    i //= 10
print(sum)

Solution (Python):
T=0

def wa(a):
    s=0
    A = list(str(a))
    for i in range(len(A)):
        s += int(A[i])
    return s

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

for i in range(1, N+1):
    if(i<10 and A<=i and i<=B):
        T+=i
    elif(i>=10 and A<=wa(i) and wa(i)<=B):
        T+=i

print(T)

Solution (Python):
def f(n):
    N=n
    s=0
    for i in range(5):
        g = n%10
        s+=g
        n = int(n / 10)
        if n < 1:
            break
    if a<=s and s<=b:
        return N
    return 0
n,a,b = map(int, input().split())
l = [i+1 for i in range(n)]
l = list(map(f, l))
print(sum(l))

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

num = map(int, str(n))

nums = []

def digitSum(n):
    s = str(n)
    array = list(map(int, list(s)))
    return sum(array)

for i in range(n+1):
    if a <= digitSum(i) <= b:
        nums.append(i)

print(sum(nums))

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

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

print(sum(ans))

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

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

sum0 = 0
for i in range(N + 1):
    s = 0
    j = i
    while i != 0:
        s += i % 10
        i //= 10
    if A <= s <= B:
        sum0 += j
print(sum0)

Solution (Python):
num, low, hi = list(map(int, input().split()))
within = []
for i in range(1, num+1):
    c = 0
    for n in str(i):
        c = c + int(n)

    if c >= low and c <= hi:
        within.append(int(i))

print(sum(within))

Solution (Python):
num=input().split(' ')
res=0
for i in range(int(num[0])):
    i=i+1
    s=str(i)
    tmp=0
    for w in s:
        tmp+=int(w)
    if tmp>=int(num[1]) and tmp<=int(num[2]):
        res+=i
print(str(res)+'\n')

Solution (Python):
N,A,B=input().split(' ')
N,A,B = [int(N),int(A),int(B)]
SUM = 0

for i in range(N+1):
	I = str(i)
	array = list(map(int, list(I)))
	s = sum(array)
	
	if A <= s and s <= B:
		
		SUM += i
print(SUM)

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

s=0;
for i in range(n+1):
    nl=list(str(i))
    ns=0;
    for j in range(len(nl)):
        ns+=int(nl[j]);
    if (ns>=a and ns<=b):
        s+=i
print(s)

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

sum = 0
for n in range(1, N+1):
  n = '0000' + str(n)
  a, b, c, d, e = int(n[-5]), int(n[-4]), int(n[-3]), int(n[-2]), int(n[-1])
  if A <= a + b + c + d + e <= B:
    sum += int(n)
print(sum)

Solution (Python):
def ketanowa(p):
    ans=0
    p=str(p)
    for i in p:
        ans+=int(i)
    return ans

def main():
    temp=input().split(" ")
    n=int(temp[0])
    a=int(temp[1])
    b=int(temp[2])
    su=0


    for i in range(n+1):
        if  a<=ketanowa(i) and ketanowa(i)<=b:
            su+=i
    print (su)

if __name__ == '__main__':
    main()

Solution (Python):

from functools import reduce
from operator import add


def main(n, min_limit, max_limit):
    result = 0

    for i in range(1, n+1):
        tmp = reduce(add, [int(n) for n in str(i)])
        if min_limit <= tmp <= max_limit:
            result += i

    print(result)


if __name__ == "__main__":
    lst = [int(val) for val in input().split()]
    main(lst[0], lst[1], lst[2])

Solution (Python):

import math

input_line = input().rstrip().split(' ')

total = 0
N = int(input_line[0])
A = int(input_line[1])
B = int(input_line[2])
result = 0
for value in range(1, N + 1):
	tmp_value = value;
	digit_sum = 0;
	while (tmp_value >= 10):
		digit_sum += tmp_value % 10
		tmp_value = math.floor(tmp_value / 10)

	digit_sum += tmp_value % 10
	if (digit_sum >= A and digit_sum <= B):
		result += value

print(result)

Solution (Python):
N,A,B = map(int,input().split())
sumans = 0
for i in range(N+1):
    nn = i
    nnsum = 0
    while nn > 0:
        a = nn%10
        nn = int(nn/10)
        nnsum += a
    if(nnsum <= B and nnsum >= A):
        sumans += i
        
print(sumans)

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

Solution (Python):
n=list(map(int,input().split(" ")))
s=0

for i in range(1,n[0]+1):
    j = str(i)
    j = list(map(int,j))
    
    if (n[1] <= sum(j) <= n[2]):
        s+=i

print(s)

Solution (Python):
N,A,B=map(int,input().split())
ans=0
for i in range(1,N+1):
    digisum=0
    tmpI=i
    while(True):
        digisum+=tmpI%10
        if tmpI<10:
            if(A<=digisum and digisum<=B):
                ans+=i
            break
        tmpI=int(tmpI/10)
print(ans)

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

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

def gen(n):
  if n < 10:
    yield n
  else:
    for m in gen(n/10):
      yield m
    yield n%10

ans = 0
for i in range(0, a[0]+1):
    num = [int(j) for j in gen(i)]
    sumed = sum(num)
    if (a[1] <= sumed) and (sumed <= a[2]):
        ans = ans + i

print(ans)

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

print(ans)

Solution (Python):
def b_SomeSums(N, A, B):
    def sum_digit(N):
        
        ret = 0
        N = str(N)
        for i in range(len(N)):
            ret += int(N[i])
        return ret

    ans = 0
    for i in range(1, N + 1):
        tmp = sum_digit(i)
        if A <= tmp <= B:
            ans += i
    return ans

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

Solution (Python):
n,a,b=[int(x) for x in input().split()]
ans=0
for i in range(n+1):
  j,t=i,0
  while j:
    t+=j%10
    j=j//10
  if a<=t and t<=b:ans+=i
print(ans)

Solution (Python):


N, A, B = list(input().split())
A_ = int(A)
B_ = int(B)
N_ = int(N)
i_ = "0"

lists = []
for i in range(N_+1):
    i_ = str(i)
    sum_ = 0
    for x in i_:
        sum_ += int(x)
    if sum_ >= A_ and sum_ <= B_:
        lists.append(i)


sum_ = 0
for ele in lists:
    sum_ += ele


print(sum_)

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

tally = 0
for i in range(1,n+1):
    s = 0
    for digit in str(i):
        s = s + int(digit)
    if a <= s <= b:
        tally = tally + i

print(tally)

Solution (Python):


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

Solution (Python):

from pprint import pprint as pp

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

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

Solution (Python):


import sys

def sum_digit(number):
    s = 0
    for digit in str(number):
        s += int(digit)
    return s

def main(argv):
    line = sys.stdin.readline()
    while line:
        N, A, B = map(lambda x: int(x), line.rstrip("\n").split(" "))

        s = 0
        for i in xrange(N + 1):
            s_d = sum_digit(i)
            if s_d >= A and s_d <= B:
                s += i
        print s

        line = sys.stdin.readline()

if __name__ == "__main__":
    main(sys.argv)

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

count = 0
for n in xrange(1, N+1):
    s = sum(int(c) for c in str(n))
    if A <= s <= B:
        count += n

print count

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

cnt = 0
for i in range(N + 1):
    if A <= sum([int(l) for l in list(str(i))]) <= B:
        cnt += i
print(cnt)

Solution (Python):
def calc(num):
    ans = 0
    for i in str(num):
        ans += int(i)
    return ans


n, a, b = map(int, raw_input().split(" "))
lis = []
for i in xrange(n):
    tmp = calc(i + 1)
    if a <= tmp  and tmp <= b:
        lis.append(i + 1)

print sum(lis)

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

number_list = list(map(str, range(1, N+1)))

count = 0

for number in number_list:
    sum = 0
    for s in number:
        sum += int(s)
    if sum >= A and sum <= B:
        count += int(number)

print(count)

Solution (Python):



N, A, B = [int(i) for i in input().split()]
cnt = 0
for i in range(1, N + 1):
    chk_val = 0
    n = i
    while n != 0:
        chk_val += n % 10
        n = n // 10
    if (chk_val >= A ) and (chk_val <= B):
        
        cnt += i

print(cnt)

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

Solution (Python):
[N, A, B] = map(int, raw_input().split())

i=1
g_sum = 0
while i<=N:
    sum = 0
    array = list(str(i))

    while len(array) > 0:
        tmp = array.pop(0)

        sum = sum + int(tmp)

    if (A <= sum) and (sum <= B):
        g_sum = g_sum + i
    i=i+1

print g_sum

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

kketa = len(str(n))


lst = []
for i in range(n):
    now = sum([int(x) for x in list(str(i+1))])
    if now>=a and now<=b:
        lst.append(i+1)
print(sum(lst))

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

ans=0
for i in range(1,N+1):
	S=str(i)
	sum_s=0
	for j in range(len(S)):
		sum_s+=int(S[j])
	if sum_s>=A and sum_s<=B:
		ans+=i
print ans

Solution (Python):

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

output = 0
for n in range(1, N + 1):
    s = sum(map(int, list(str(n))))
    if A <= s and s <= B:
        output += n

print(output)

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

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

print(ans)

Solution (Python):
a = [int(x) for x in  input().split()]

cnt = 0

for i in range(1, a[0]+1):
    summ = 0

    for j in list(str(i)):
        summ += int(j)
    if a[1] <= summ <= a[2]:
        cnt += i
print(cnt)

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

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

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

def calc(x):
    count = 0
    while x > 0:
        count += x % 10
        x = x // 10
    return count

cnt = 0
for i in range(1, n+1):
    result = calc(i)
    if a <= result and result <= b:
        cnt += i
print (cnt)

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

count=0
for num in range(1,N+1):
    tmp=num
    
    wa=num%10
    while(num>=10):
        num=int(num/10)
        wa+=num%10
    
    if wa>=A and wa<=B:
        count+=tmp
print(count)

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

Ans = 0

lis = []

for i in range(N + 1):
	X = str(i)
	Y = 0
	for j in range(len(X)):
		Y += int(X[j])
		
	if A <= Y and Y <= B:
		lis.append(int(X))
	
print(sum(lis))

Solution (Python):
N, A, B = input().split(" ")
res = 0
for num in range(0,int(N)+1):
    res_par = 0
    for i in str(num):
        res_par += int(i)
    if res_par >= int(A) and res_par <= int(B):
        res += int(num)
print(res)

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

print(ans)

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

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

main()

Solution (Python):
def main():
    N, A, B = map(int, input().split())
    lc = 0
    for x in range(1, N + 1):
        H = list(str(x))
        c = 0
        for h in H:
            c += int(h)
        if A <= c <= B:
            lc += x
    print(lc)


if __name__ == "__main__":
    main()

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

Solution (Python):
s = input().split(" ")
s = [int(i) for i in s]
N = s[0]
A = s[1]
B = s[2]

cnt = 0
for i in range(N + 1) : 
    l = [int(x) for x in list(str(i))]
    rst = sum(l)
    if (rst >= A) & (rst <= B) : 
        cnt += i
print(cnt)

Solution (Python):
N,A,B=map(int,input().split())
c=0
for i in range(1,N+1):
    n=i
    d=0
    while n != 0:
        d+=n%10
        n//=10
    if d >= A and d <= B:
        c+=i
print(c)

Solution (Python):


N, A, B = raw_input().split()
N = int(N)
A = int(A)
B = int(B)

count = 0
for i in range(1, N+1):
    all = 0
    for j in range(len(str(i))):
        all += int(str(i)[j])
    if all >= A and all <= B:
        count += i

print count

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

ans = 0

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

print(ans)

Solution (Python):


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

counter = 0
for n in range(1,N+1):
    wa = sum([int(x) for x in list(str(n))])
    if (A <= wa <= B):
        counter += n
print(counter)

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

for i in range(n+1):
  s=0
  for j in range(len(str(i))):
    s=s+int(str(i)[j])
  if s>=a and b>=s:
    count=count+i

print(count)

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

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

total = 0
for i in range(a+1):
    p = sum([int(j) for j in str(i)]) 
    if p >= b and p <= c:
        total += i
print(total)

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

ans = 0
for i in range(1,N+1):
    num = 0
    for j in str(i):
        num += int(j)
    if num >= A and num <= B:
        ans += i
print(ans)

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

for i in range(1,N+1):
    num = map(int, str(i))
    if A <= sum(num) <= B:
        a.append(i)

print(sum(a))

Solution (Python):
n, a, b = map(int, raw_input().split())
print sum([_ for _ in xrange(1, n + 1) if a <= sum(map(int, list(str(_)))) <= b])

Solution (Python):
def main():
    """
    1 以上 N 以下の整数のうち、
    10 進法での各桁の和が A 以上 B 以下であるものの総和を求めてください。
    """
    N, A, B = map(int, input().split())

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

    print(ans)

if __name__ == '__main__':
    main()

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