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 = 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())
print(sum([i for i in range(1,n+1) if a <= sum(map(int,str(i))) <= b]))

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

Solution (Python):
def sum_of_dig(n):
    s = str(n)
    l = len(s)
    return sum(int(s[i]) for i in range(l))

N, A, B = (int(x) for x in input().split())
ans = 0
for i in range(1, N+1):
    j = sum_of_dig(i)
    if A <= j and j <= B:
        ans += i
else:
    print(ans)

Solution (Python):
N, A, B = map(int, input().split())
ans = 0
for n in range(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())

def degitalsum(i):
  s = str(i)
  array = list(map(int, s))
  return sum(array)

ans = 0

for i in range(1, n + 1):
  if a <= degitalsum(i) <= b:
    ans += i

print(ans)

Solution (Python):
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n+1):
    if a <= sum([int(c) for c 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):
    x = sum(map(int,str(i)))
    if a <= x <= b:
        ans += i
print(ans)

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

def kakuwa(a): 
    k = 0
    for i in range(0,len(str(a))):
        k = k + int(str(a)[i])
    return(k)

for j in range(N+1):
    if kakuwa(j) >= A and kakuwa(j) <= B:
        ans = ans + j

print(ans)

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

for i in range(N + 1):
    r = i
    q = 0
    while r != 0:
        q += r % 10
        r //= 10
    if A <= q <= B:
        ans += i
    else:
        continue

print(ans)

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

result = 0
for i in range(n):
    num = sum(int(j) for j in list(str(i + 1)))
    if a <= num <= b:
        result += (i + 1)

print(result)

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

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

ans = 0

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

print(ans)

Solution (Python):
N,A,B = map(int, input().strip().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())
c = 0
for i in range(1,n+1):
  sum = 0
  for k in str(i):
    sum += int(k)
  if a <= sum and sum <= b:
    c += i
print(c)

Solution (Python):
import copy
N, A, B = list(map(int, input().split()))
total = 0
for i in range(1, N+1):
    tmp_i = copy.deepcopy(i)
    digits_sum = 0
    while tmp_i > 0:
        digits_sum += tmp_i % 10
        tmp_i = tmp_i // 10
    if A <= digits_sum <= B:
        total += i
print(total)

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

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

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

Solution (Python):

stdin = list(map(int, input().split()))
n = stdin[0]
a = stdin[1]
b = stdin[2]

ans = 0
for j in range(n+1):
    wa = 0
    array = list(map(int, str(j)))
    for k in range(len(str(j))):
        
        wa += array[k]
    if wa >= a and wa <= b:
        
        ans += j

print(ans)

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

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

Solution (Python):
ans=0
n,a,b=map(int,input().split())
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())
ans=[0]*37
for i in range(n+1):
    k=sum([int(str(i)[j]) for j in range(len(str(i)))])
    ans[k]+=i
print(sum(ans[a:b+1]))

Solution (Python):
N, A, B =map(int,input().split())
ans = 0
for i in range(N+1):
    keta5 = i//10000
    keta4 = i//1000 - 10*(i//10000)
    keta3 = i//100 - 10*(i//1000)
    keta2 = i//10 - 10*(i//100)
    keta1 = i%10
    if A<=keta1+keta2+keta3+keta4+keta5 <=B:
        ans += i
print(ans)

Solution (Python):
n, a, b = map(int, input().split())
list_ans = []
for i in range(n+1):
	list1 = []
	d = i
	while i >= 1:
		c = i % 10
		i = i//10
		list1.append(c)
	counter = sum(list1)
	if a <= counter <= b:
		list_ans.append(d)
print(sum(list_ans))

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

def wa(n):
    w = 0
    while n != 0:
        w += n % 10
        n = int(n / 10)
    return w

ans = 0
for i in range(1, N+1):
    w = wa(i)
    if A <= w and w <= B:
        
        ans += i

print(ans)

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

res = 0

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

print(res)

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

Solution (Python):

def sumCifre(n):
	sum = 0
	while n > 0:
		sum = sum + n % 10
		n //= 10
	return sum
	
def main():
	linie = input()
	vector = [int(x) for x in linie.split()]	
	n = vector[0]
	a = vector[1]
	b = vector[2]
	sum2 = 0
	for i in range(0, n + 1):
		if sumCifre(i) >= a and sumCifre(i) <= b:
			sum2 += i
	print(sum2)
 
if __name__ == "__main__":
	main()

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

def numSum(num):
  s = str(num)
  strnum = list(map(int, s))
  return sum(strnum)

sm = 0

for i in range(N):
  ns = numSum(Nl[i])
  if ns >= A and ns <= B:
    sm += Nl[i]
    
print(sm)

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

count = 0

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

    ans = str(i)
    s   = sum(map(int, ans))


    if s>=A and s<=B:
        count = count + i

print(count)

Solution (Python):
import sys
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n, a, b = na()
ans = 0
if n == 10**4:
        if a == 1:
                ans += 10**4
for x in range(10):
        for y in range(10):
                for z in range(10):
                        for w in range(10):
                                num = x * 1000 + y * 100 + z * 10 + w
                                s = x + y + z + w
                                if (num <= n) and (a <= s) and (b >= s):
                                        ans += num
print(ans)

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

count = 0
for i in range(n+1):
    sum = 0
    m = str(i)
    for j in range(len(m)):
        sum += int(m[j])
    if a <= sum <= b:
        count += i

print(count)

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

for i in range(1, N+1):
    num = i
    num_sum = 0
    while num > 0:
        num_sum += num % 10
        num = num // 10
    if A <= num_sum and num_sum <= B:
        list.append(i)

print(sum(list))

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

Solution (Python):
N, A, B = map(int, input().split())
def count(X):
    sum = 0
    for n in str(X):
        sum += int(n)
    return sum

print(sum(x for x in range(1, N+1) if A <= count(x) <= B))

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

Solution (Python):



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


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


print(ans)

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

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

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

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

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

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

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

tot = 0

for i in range(N):
    res = 0
    temp = i+1
    while temp >= 10000:
        res += 1
        temp -= 10000
    while temp >= 1000:
        res += 1
        temp -= 1000
    while temp >= 100:
        res += 1
        temp -= 100
    while temp >= 10:
        res += 1
        temp -= 10
    res += temp

    if (A <= res) & (res <= B):
        tot += i+1


print(tot)

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

tot = 0

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

    if (A <= sum) & (sum <= B):
        tot += i+1

print(tot)

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())
z = 0
for i in range(n+1):
    x = map(int,list(str(i)))
    y = sum(x)
    if y >= a and y <= b:
        z += int(i)
print(z)

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

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 = map(int, input().split())

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

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

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

counter = 0
for num in range(1,N+1):
  num = str(num)
  sum = 0
  for j in range(len(num)):
    sum += int(num[j])
  if (sum>=A)&(sum<=B):
    counter += int(num)
print(counter)

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

count = 0

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

Solution (Python):
n,a,b = list(map(int, input().split()))
sum = 0
for i in range(n+1):
  qu = i//10000
  th = (i%10000)//1000
  hu = (i%1000)//100
  te = (i%100)//10
  on = i%10
  m = qu+th+hu+te+on
  if a<=m<=b:
    sum += i
print(sum)

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

total = 0
for i in range(1, n + 1):
  num = i
  sum_i = 0
  while num > 0:
    sum_i += num % 10
    num = int(num/10)
    
  
  if sum_i >= a and sum_i <= b:
    total += i
    
print(total)

Solution (Python):
N,A,B=map(int,input().split())
sum = 0
for N in range(1,N+1):
  a=N%10
  b=(N//10)%10
  c=(N//100)%10
  d=(N//1000)%10
  e=(N//10000)%10
  S=a+b+c+d+e
  
  if A <= S and S <= B:
    sum += (a+b*10+c*100+d*1000+e*10000)
    
print(sum)

Solution (Python):
m,a,b = map(int,input().split())
ans = 0
for  i in range(1,m+1):
    if a <= sum(map(int,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):
    tmp=0
    for j in range(len(str(i))):
        tmp+=int(str(i)[j])
    if a<=tmp<=b:
        ans+=i
print(ans)

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

def keta(m):
    an=0
    while m>0:
        an+=m%10
        m=m//10
    return an

ans=0
for i in range(1,n+1):
    j=keta(i)
    if j<=b and j>=a:
        ans+=i
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline

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

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


if __name__ == "__main__":
    main()

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

res = 0
for x in range(1,N+1):
    x = str(x)
    s = 0
    for y in x:
        s += int(y)
    if s >= A and s <= B:
        res += int(x)
print(res)

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

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

print(ans)

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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

ans = 0
for i in range(n+1):
    su = sum(list(map(int, list(str(i)))))
    
    if (a <= su <= b):
        ans += i
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,str(i)))<=b))

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

for i in range(1, N + 1):
    sum_digit = sum(map(int, list(str(i))))
    
    if (sum_digit >= A) & (sum_digit <= B):
        result_cnt +=  i

print(result_cnt)

Solution (Python):
import sys
stin = sys.stdin.readline
N,A,B=list(map(int,stin().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())
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 num in range(1, n + 1):
    s = str(num)
    sm = 0
    for let in s:
        sm += int(let)
    if a <= sm <= b:
        ans += num

print(ans)

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

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):
rs, mn, mx = map(int, raw_input().split())
rs = [str(r) for r in range(1, rs + 1)]

totals = list()
for r in rs:
    total = sum([int(_r) for _r in r])
    if mn <= total <= mx:
        totals.append(int(r))
print sum(totals)

Solution (Python):
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, A, B = map(int, input().split())
        ans = 0
        for i in range(1, N + 1):
            s = 0
            for n in str(i):
                s += int(n)
            if A <= s <= B:
                ans += i
        print(ans)


if __name__ == '__main__':
    AtCoder().main()

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

def total(x):
    b=0
    while x > 0:
        a=x%10
        b +=a
        x =x//10
    
    return b    
ans=0
for i in range(1,a+1):
  sum=total(i)
  if sum >= b and sum <= c:
    ans +=i
print(ans)

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

def degitsum(x):
	string = str(x)
	array = list(map(int, string))
	return sum(array)

for i in range(N+1):
	if A <= degitsum(i) and degitsum(i) <= B:
		ans.append(i)
	else:
		continue
		
print(sum(ans))

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

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

ok_list = []
for i in range(N):
    N_now = i+1
    sum_tmp = 0
    for j in range(len(str(N_now))):
        sum_tmp += int(str(N_now)[j])
    
    if sum_tmp >= a and sum_tmp <= b:
        ok_list.append(N_now)
print(sum(ok_list))

Solution (Python):
a = input().split()

ans = 0
for i in range(int(a[0])+1):
    i=str(i)
    i.split()
    sum_num=0
    for j in i:
        sum_num+=int(j)
    if sum_num>=int(a[1]) and sum_num<=int(a[2]):
        ans += int(i)

print(ans)

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

ans = 0

for i in range(1,n+1):
    sum = 0
    target = i
    while(target):
        x = target % 10
        sum = sum + x
        target = (target - x) / 10
    if sum >=  a and sum <= b:
        ans = ans + i

print(ans)

Solution (Python):
import sys
from statistics import *
from collections import *
from operator import itemgetter

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n, a, b = na()
ct = 0
for i in range(1, n+1):
    num = str(i)
    s = 0
    for j in range(len(num)):
        s += int(num[j])
    if a <= s <= b:
        ct += i
print(ct)

Solution (Python):
n, a, b = map(int, input().split())
total = 0
def Sum(N):
    sum = 0
    while(N > 0):
        sum += int(N % 10)
        N /= 10
    return sum

for N in range(1,n+1):
    result = Sum(N)
    if result >= a and result <= b:
        total += N

print(total)