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



Sample input:
20 2 5


Sample output:
84

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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]))

Submission status: Accepted

Solution code:
#1以上N以下の整数のうち、10進法で各桁の和がA以上B以下であるものについて総和
  
n,a,b=map(int,input().split())
def s(x):
        return x//10000 + x%10000//1000 + x%1000//100 + x%100//10 + x%10

sum=0

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

print(sum)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
total = 0
for num in range(1,n+1):
    array = list(map(int,str(num)))
    if a<=sum(array)<=b:
        total += num
print(total)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
total = 0


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


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

print(total)

Submission status: Accepted

Solution code:
def main():
    n, a, b = map(int, input().split())
    
    sum = 0
    for i in range(1, n+1):
        digit_sum = 0
        num = i
        while(num > 0):
            if num >= 1 and num <= 9:
                digit_sum += num
                num //= 10
            else:
                digit_sum += num % 10
                num //= 10

        if (digit_sum >= a) and (digit_sum <= b):
            sum += i

    print(sum)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,A,B = map(int, input().split())
total = 0
for i in range(N + 1):
    count = 0
    n = str(i)
    length = len(n)
    
    for j in range(length):
        count += int(n[j])

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

print(total)

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
S = 0
for i in range(N + 1):
    if i < 10:
        W = i
    elif i < 100:
        W = int(str(i)[0]) + int(str(i)[1])
    elif i < 1000:
        W = int(str(i)[0]) + int(str(i)[1]) + int(str(i)[2])
    elif W < 10000:
        W = int(str(i)[0]) + int(str(i)[1]) + int(str(i)[2]) + int(str(i)[3])
    else:
        W = 1
    
    if A <= W <= B:
        S += i

print(S)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
sum = 0

for i in range(1, N+1):
    j = i
    sum_digit = 0
    while j:
        sum_digit += j % 10
        j //= 10
    if A <= sum_digit <=B:
        sum += i
        
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

total = 0

for n in range(1,N+1):
    sum = 0
    q = n
    while q != 0:
        sum += (q%10)
        q = q//10
    if (A<=sum) and (sum<=B):
        total += n

print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, A, B = [int(s) for s in input().split()]
r = 0;
def sumdig(n):
    r = 0;
    d = n % 10;
    r += d;
    n = (n - d) / 10;
    d = n % 10;
    r += d;
    n = (n - d) / 10;
    d = n % 10;
    r += d;
    n = (n - d) / 10;
    d = n % 10;
    r += d;
    n = (n - d) / 10;
    d = n % 10;
    r += d;
    n = (n - d) / 10;
    return r;
for n in range(1, N + 1):
    s = sumdig(n)
    if (s >= A and s <= B):
        r += n;
print(r)

Submission status: Accepted

Solution code:
def num_sum(L):
  ret = 0
  for l in L:
    ret += int(l)
  return ret

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

Submission status: Accepted

Solution code:
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]))

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split(' '))
total = 0
for number in range(1, N + 1):
  total_number = 0
  for number_str in str(number):
    total_number += int(number_str)
  if total_number >= A and total_number <= B:
    total += number
print(total)

Submission status: Accepted

Solution code:
def main():
    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)


main()

Submission status: Accepted

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


main()

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split(' '))
total = 0
for number in range(1, N + 1):
  total_number = 0
  for number_str in str(number):
    total_number += int(number_str)
  if total_number >= A and total_number <= B:
    total += number
print(total)

Submission status: Accepted

Solution code:
def sums(n):
    return(sum(list(map(int,[str(n)[i] for i in range(len(str(n)))]))))


n,a,b=map(int,input().split())
ans=0
for j in range(n+1):
    if sums(j)>=a and sums(j)<=b:
        ans+=j

print(ans)

Submission status: Accepted

Solution code:
def findSumOfDigit(n):
    
    sum_digit = 0

    while n > 0:  

        sum_digit += n % 10 
        n = int(n / 10)
        
    return sum_digit

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

ans = 0

for i in range(N+1):
    
    sum_digit = findSumOfDigit(i)
    if A <= sum_digit and sum_digit <= B:
        ans += i
        
print(ans)

Submission status: Accepted

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

def sum_each_digit(n):
    ans = 0
    div = 10000
    while div > 0:
        t = n // div
        ans += t
        n -= div * t
        div //= 10
    return ans

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

print(ans)

Submission status: Accepted

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def digsum(n):
    return n if  n//10 == 0 else n%10 + digsum(n//10)

def solve():
    n, a, b = f()

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

solve()

Submission status: Accepted

Solution code:
#data = [input() for x in range(0, 1, 1)]

ws = input()

N = int(ws.split(" ")[0])
A = int(ws.split(" ")[1])
B = int(ws.split(" ")[2])

sums = 0

for i in range(0, N + 1, 1):
  
  num = 0
  
  
  for v in list(str(i)):
    num += int(v)
    
  if num >= A and num <= B:
    sums += i
  else:
    pass
  
print(sums)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
sum = 0
for n in range(1, N+1):
    nn = n
    ans = 0
    while nn != 0:
        ans += nn % 10
        nn = nn // 10
    if A <= ans <= B:
        sum += n
print(sum)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
res = 0
 
for i in range(1,n+1):
  sum = 0
  j=0
  while True:
    num = i//(10**j)
    if num != 0:
      num = num % 10 
      sum += num
      j+=1
    else:
      break
  if a<=sum and sum<=b:
    res += i;
 
print(res)

Submission status: Accepted

Solution code:
def main():
    N, A, B = [int(_) for _ in input().split()]

    ans = 0

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

    print(ans)

main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
ant=0
for i in range(1,N+1):
  sum=0
  j = i
  while j != 0:
    hoge = j % 10
    sum = sum + hoge
    j = j // 10
  if A <= sum <= B:
    ant = ant + i
print(ant)

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
ans = 0
for i in range(1,N+1):
  sum = 0
  j = i
  while j !=0:
    sum += j % 10
    j = j//10
  if A <= sum <= B:
    ans += i
print(ans)

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
total = 0

for x in range(a+1):
  z = x
  d = 0
  while z != 0:
    d += z % 10
    z = z // 10
  if b <= d <= c:total += x
print(total)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:

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

# スペース区切りの整数の入力
n, a, b = map(int, input().split())

ans = 0

for i in range(1,n+1):
    #print(i)
    test = findSumOfDigits(i)
    if a <= test <= b:
        ans = ans + i

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, a, b = list(map(int, input().split()))
c = list(range(1,n + 1, 1))
d = 0

def souwa(x):
    answer = 0
    for i in range(len(str(x))):
        b = str(x)
        a = str(b[i])
        answer += int(a)
    return answer

for i in range(len(c)):
    if souwa(c[i]) >= a:
        if souwa(c[i]) <= b:
            d += c[i]
            
print(d)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

def check_a_b(n, a, b):
    sum = 0
    while n > 0:
        if sum + n%10 <= b:
            sum += n%10
            n //= 10
        else:
            return False
    if sum >= a:
        return True
    else:
        return False

ans = 0
for i in range(n+1):
    if check_a_b(i, a, b):
        ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-

n, a, b = map(int, input().split())
count = 0
for i in range(n+1):
        sum = 0
        x = str(i)
        for j in range(0,4):
                try:
                        sum += int(x[j])
                except IndexError:
                        pass
        if a <= sum and sum <= b:
                count += i
print(count)

Submission status: Accepted

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

n,a,b = 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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
n,a,b = map(int, input().split())
lst = []

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
ans = 0
for i in range(1, a+1):
    N = [int(x) for x in str(i)]
    sum_N = sum(N)
    if (b <= sum_N and sum_N <= c):
        ans += i

print(ans)

Submission status: Accepted

Solution code:
def main():
    N, A, B = map(int, input().split())
    ans = 0
    for n in range(1, N+1):
        temp = n
        sum = 0
        while n > 0:
            sum += n % 10
            n = int(n / 10)
        if sum >= A and B >= sum:
            ans += temp
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
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]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
l = []

for i in range(1, n+1):
    num = 0
    for j in str(i):
        num += int(j)
    if a <= num <= b:
        l.append(i)

print(sum(l))

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
count = 0

for i in range(1, N+1):
    sum = 0
    ans = i
    for j in range(len(str(i))):
        sum += i % 10
        i //= 10

    if A <= sum <= B:
        count += ans

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def digit_sum(x):
    res = 0
    while x != 0:
        res += x%10
        x //= 10
    return res
    
[N,A,B] = list(map(int,input().split()))
ans = 0
for i in range(1,N+1):
    if A <= digit_sum(i) <= B:
        ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

sum = 0
for n_i in range(1, n + 1):
	n_orders_sum = 0
	for n_order_i in str(n_i):
		n_orders_sum += int(n_order_i)
	if a <= n_orders_sum <= b:
		sum += n_i
print(sum)

Submission status: Accepted

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

sum = 0
for n_i in range(1, n + 1):
	n_orders_sum = 0
	for n_order_i in str(n_i):
		n_orders_sum += int(n_order_i)
	if a <= n_orders_sum and n_orders_sum <= b:
		sum += n_i
print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 0
for i in range(N + 1):
    sho = i
    total = 0
    while(sho > 0):
        yo = sho % 10
        sho = sho // 10
        total += yo
    if total >= A and total <= B:
        ans += i
        
print(ans)

Submission status: Accepted

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

for i in range(n):
    isum = sum(list(map(int, str(i+1))))
    if isum >= a and b >= isum:
        ans += i + 1

print(ans)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B = [int(x) for x in input().split()]
ans = 0
for i in range(1,N+1):
    sums = 0
    for j in str(i):
        sums += int(j)
    if(A<=sums and sums<=B):
        ans += i
print(ans)

Submission status: Accepted

Solution code:
def calc_digit_sum(num):
    result = 0
    while num > 0:
        result += num % 10
        num //= 10
    return result

n, a, b = map(int, input().split())
result = 0
for i in range(1, n+1):
    digit_sum = calc_digit_sum(i)
    if digit_sum >= a and digit_sum <= b:
        result += i

print(result)

Submission status: Accepted

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

t=0
z=0
x=0

for z in range(N):
    x=x+1
    if x>=10000:
        a=x//10000
        b=(x-a*10000)//1000
        c=(x-a*10000-b*1000)//100
        d=(x-a*10000-b*1000-c*100)//10
        e=x-a*10000-b*1000-c*100-d*10
        y=a+b+c+d+e
        if A<=y<=B:
            t=t+x
    elif 1000<=x<10000:
        f=x//1000
        g=(x-f*1000)//100
        h=(x-f*1000-g*100)//10
        i=x-f*1000-g*100-h*10
        y=f+g+h+i
        if A<=y<=B:
            t=t+x
    elif 100<=x<1000:
        j=x//100
        k=(x-j*100)//10
        l=x-j*100-k*10
        y=j+k+l
        if A<=y<=B:
            t=t+x
    elif 10<=x<100:
        m=x//10
        n=x-m*10
        y=m+n
        if A<=y<=B:
            t=t+x 
    else:
        o=x
        y=o
        if A<=y<=B:
            t=t+x

    
print(t)

Submission status: Accepted

Solution code:
import sys

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

def counter(N, A, B):
    total = 0
    for n in range(1, N+1):
        sum = 0
        nn = n
        while n!=0:
            sum += n % 10
            n = n // 10
        if A <= sum <= B: total += nn
    return total

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

ans = 0

for i in range(1, n+1):
    temp = list(str(i))
    temp = [int(x) for x in temp]
    temp = sum(temp)

    if a<=temp and temp <= b:
        ans +=i
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
ans=0
for i in range(n+1):
    nn=str("{0:05d}".format(i))
    temp=int(nn[0]) + int(nn[1]) + int(nn[2]) + int(nn[3]) + int(nn[4])
    
    if temp>b or temp<a:
        continue
    else:
        ans+=i
print(ans)

Submission status: Accepted

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

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

sum = 0
for i in range(1, N+1):
  tmp = digsum(i)
  if tmp >= A and tmp <= B:
    sum += i
print(sum)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
ans=0
for i in range(1,N+1):
        tmp=0
        p=i
        while p!=0:
            tmp+=p%10
            p//=10
        if A <= tmp <= B:
            ans+=i
            
    
print(ans)

Submission status: Accepted

Solution code:
n,a,b=(int(x) for x in input().split())
t=0
c=1
while c<=n:
    d=str(c)
    e=list(d)
    f=0
    for x in e:
        f=f+int(x)
    if f>=a:
        if f<=b:
            t=t+c
    c=c+1
print(t)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
b = []
d = 0
    
for i in range(a[0] + 1):
    c = 0
    e = i
    sum = []
    while e != 0:
        sum.append(e % 10)
        e //= 10
    for j in sum:
            c += j
    if a[1] <= c <= a[2]:
            b.append(i)

for i in b:
    d += i
       
print(d)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC083B - Some Sums
n, a, b = list(map(int, input().rstrip().split()))
total = 0
for i in range(1, n + 1):
    if a <= sum(list(map(int, list(str(i))))) <= b:
        total += i
print(total)

Submission status: Accepted

Solution code:
def FindSumOfDigit(n):
    sum = 0
    while n > 0:
        n, rest = divmod(n, 10)
        sum += rest
    return sum


def main():
    N, A, B = map(int, input().split(' '))
    total = 0
    for i in range(1, N+1):
        sum = FindSumOfDigit(i)
        if A <= sum <= B:
            total += i
    print(total)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
N, A, B = list(map(int, input().split()))
answer = 0

for i in range(1, N+1):
    l = [int(x) for x in list(str(i))]
    if A <= sum(l) <= B: answer += i

print(answer)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, A, B = map(int,input().split())
list = [0] * 5
ans_list = []

for i in range(N):
    i += 1
    i = str(i)
    for j in range(len(i)):
        list[j] = (int(i[j]))
    result = sum(list)
    if result >= A and result <= B:
        ans_list.append(int(i))
     
print(sum(ans_list))

Submission status: Accepted

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

print(sum(numbers))

Submission status: Accepted

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

ret = 0

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

print(ret)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
ans = 0
for i in range(N+1):
    tmp = sum([int(j) for j in str(i)])#str[]からj番目の文字を足していく
    if(A <= tmp <= B):
        ans += i
print(ans)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
n, a, b = map(int, 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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
S=0
for i in range(1,N+1):
  s=0
  C=str(i)  #N文字化
  c=list(C)
  
  w=[int(i) for i in c]
  s=sum(w)
  if s>=A and s<=B:
    S +=i
print(S)

Submission status: Accepted

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

S=0
for i in range(1,N+1):
  s=0
  C=str(i)  #N文字化
  c=list(C)
  
  w=[int(i) for i in c]
  s=sum(w)
  if s>=A and s<=B:
    S +=i
print(S)

Submission status: Accepted

Solution code:
# ABC083B - Some Sums

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l = list(map(int,input().split()))

count = 0
for i in range(l[0]):
  s = sum(list(map(int, list(str(i+1)))))
  if s >= l[1] and s <= l[2]:
    count += i+1
print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

cnt = 0
for i in range(1, n + 1):
    str_i = str(i)
    sum_i = sum(map(int, str_i))
    cnt += (a <= sum_i <= b) * i

print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

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

vsum = 0
for n in range(1, N + 1):
	tsum = sum(map(int, [s for s in list(str(n))]))
	#print(tsum)
	if A <= tsum <= B:
		vsum += n
print(vsum)

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
sum=0
for i in range(1,N+1):
    key=0
    x=i
    while x!=0:
        key+=x%10
        x//=10
    if A<=key and key<=B:
        sum+=i
        
print(sum)

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
def digit_sum(n):
    sum = 0
    while (n>0):
        sum += n%10
        n = int(n/10)
    return(sum)

ans = 0
for i in range(N+1):
    a = digit_sum(i)
    if A <= a <= B:
        ans += i
#        print(i)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def sumdigit(m):
    s=str(m)
    array=list(map(int,s))
    return sum(array)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
ctr=0
for i in range(n+1):
    tl1=list(str(i))
    tl2=[int(tl1[j]) for j in range(len(tl1))]
    if a<=sum(tl2)<=b:
        ctr+=i

print(ctr)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

def sum(a):
    b = 0
    while a != 0:
        b = b + a % 10
        a = a // 10
        
    return b
    
a = 1
c = 0

while a <= N:
    if A <= sum(a) <= B:
        c = c + a
        
    else:
        pass
    
    a += 1
    
print(c)