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

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

Submission status: Accepted

Solution code:
N, A, B = list(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 = list(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:
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

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

resolve()

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

S_i=[]
for i in range(1,N+1):
    S=[]
    x=str(i)
    y=len(x)
    for j in range(y):
        S.append(int(x[j]))
    if A<=sum(S)<=B:
        S_i.append(i)
        
print(sum(S_i))

Submission status: Accepted

Solution code:
#input
#スペース区切りの整数値の入力
N, A, B = map(int, input().split())
count = 0

def FindSumDigits(x):
    sum = 0
    while x>0:
        sum += x%10
        x = x//10
    return sum

for n in range(1,N+1):
    if A <= FindSumDigits(n) <= B:
        count += n

#Output
print(count)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N, A, B= map(int, input().split())

# 1以上N以下の整数のリスト
target_list = range(1, N+1)
# print(target_list)

# nについて各桁の総和のリストを返す
def sum_each_digit(n):
    return sum(list(map(int,str(n))))

digit_sum_list = list(map(sum_each_digit,target_list))
# print(digit_sum_list)

# A以上B以下はTrue、それ以外はFalse
def A_more_B_less(x, a, b):
    return (a <= x and x <= b) if True else False

bool_list = list(map(lambda x: A_more_B_less(x, A, B), digit_sum_list))
# print(bool_list)

# 総和を求める
combined = [x * y for (x, y) in zip(target_list, bool_list)]
# print(combined)

ans = sum(combined)
print(ans)

Submission status: Accepted

Solution code:
a =list(map(int,input().split()))
x=a[0]
y=a[1]
z=a[2]
t=0
for i in range(1,x+1):
	if i//10000+((i//1000)%10)+((i//100)%10)+((i//10)%10)+(i%10)>=y and i//10000+((i//1000)%10)+((i//100)%10)+((i//10)%10)+(i%10)<=z:
		t=t+i
print(t)

Submission status: Accepted

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

sum_number = []

for i in range(x+1):
  if a <= sum(map(int, str(i))) <= b:
    sum_number += [i]
    
print(sum(sum_number))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def keta(n):
  sum = 0
  while n>0:
    sum += n%10 
    n = n//10 
  return(sum)
def mium():
  N, A, B = map(int, input().split())
  ans = 0
  for i in range (N):
    a = keta(i+1)
    if A <= a and a <= B:
      ans += i+1
  print(ans)
if __name__ == "__main__":
  mium()

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
for i in range(n+1):
  L=map(int,str(i))
  #print(list(L))
  #print(*L)
'''
0
1
2
3
4
5
6
7
8
9
1 0
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
2 0
'''
print(sum(i for i in range(n+1) if a<=sum(map(int,str(i)))<=b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def somesum(n):
    sum = 0
    x = n
    while int(x / 10) > 0:
        sum += x % 10
        x = int(x / 10)
    sum += x % 10
    return sum
    
n,a,b = map(int,input().split())
sum = 0
for val in range(1,n+1):
    if somesum(val) >= a and somesum(val) <= b:
        sum += val
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

    print(res)
    
resolve()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
def findSumOfDigits(num):
    num = int(num)
    sum = 0

    while True:
        sum += num % 10
        num //= 10
        if num <= 0:
            break

    return sum


def main():
    # n = int(input())
    # i = list(map(int,input().split()))
    # j = list(map(int,input().split()))

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

    for i in range(n+1):
        #print(i,end=" =")
        check = int(findSumOfDigits(i))
        #print(check)

        if (check >= a) and (check <= b):
            total += i
            #print(i, check, total, sep=' ')

    print(total)

main()

Submission status: Accepted

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

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

sum = 0
for n in range(N + 1):
    wa = sumOfDigits(n)
    if A <= wa and B >= wa:
        sum += n
print(sum)

Submission status: Accepted

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

sum = 0
for n in range(N + 1):
    wa = 0
    sn = str(n)
    size = len(sn)
    for s in range(size):
        wa += int(sn[s])
    if A <= wa and B >= wa:
        sum += n
print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
SUM1 = 0
for i in range(1, n + 1):
  l = list(str(i))
  if sum([int(m) for m in l]) >= a and sum([int(m) for m in l]) <= b:
    SUM1 += i
print(SUM1)

Submission status: Accepted

Solution code:
# B
# 2020/03/06 14:34-
n, a, b = map(int, input().split())

def SumDegit(x):
    ans = 0
    while x > 0:
        ans += x%10
        x = x//10
    return ans

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

Submission status: Accepted

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

def digitSum(x):
            s=str(x)
            array=list(map(int,s))
            return sum(array)
l=[]
for i in range(n+1):
            if a<=digitSum(i)<=b:
                      l.append(i)
print(sum(l))

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
ans = 0
for x in range(n + 1):
    sum = 0
    temp = x
    for id in range(5):
        sum += temp % 10
        if temp < 10: break
        else: temp //= 10
    if a <= sum <= b: ans += x
print(ans)

Submission status: Accepted

Solution code:
class Somesomes:
  def sum(self, num_list):
    result_dict={}
    for n in num_list:
      add_num = 0
      num_str = list(str(n))
      for l in num_str:
        add_num +=int(l)
      result_dict[n]=add_num
    return result_dict

  def extract_num(self, num_dict, start, end):
    extract_list=[]
    for n in num_dict.keys():
      if start <= num_dict[n] <= end:
        extract_list.append(n)
    return extract_list

  def sum_result(self, result_extract):
    result_sum = 0
    for r in result_extract:
      result_sum +=r
    return result_sum

if __name__ == '__main__' :
  I=list(map(int, input().split()))
  N = I[0]
  A = I[1]
  B = I[2]
  num_list=[]
  for n in range(N):
    num_list.append(n+1)
  somesomes = Somesomes()
  result_dict=somesomes.sum(num_list)
  result_extract = somesomes.extract_num(result_dict, A, B)
  result_sum = somesomes.sum_result(result_extract)
  print(result_sum)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def con(n):
    sum = 0
    while n>0:
        sum +=n%10
        n //=10
    return sum
N,A,B = map(int,input().split())
total=0
for i in range(N+1):
    sum = con(i)
    if A<=sum 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):
    digit_str_list = list(str(i))
    digit_int_list = [int(j) for j in digit_str_list]
    if sum(digit_int_list) >= a and sum(digit_int_list) <= 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):
  digit_sum = 0
  for j in range(len(str(i))):
    digit_sum += int(str(i)[j])
  if (digit_sum >= A) and (digit_sum <= B):
    ans += i
print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC083

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

x = 0

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

print(x)

Submission status: Accepted

Solution code:
s = list(map(int, input().split()))
sum_num = 0
sum_list = []
for r in range(1, s[0] + 1):
    l = []
    for r2 in str(r):
        l.append(int(r2))
    if (s[1] <= sum(l)) and (sum(l) <= s[2]):
        sum_list.append(r)

print(sum(sum_list))

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
## coding: UTF-8
s = input().split()
t = [int(p) for p in s]
#print(t)
N = t[0]
A = t[1]
B = t[2]

def some(k): # 各位の桁の和を算出する
    if(k < 10): # 1の位しかない
        return int(k)
    elif(10 <= k < 100): # 1の位と10の位
        one = k % 10 # 1の位
        ten = (k - one) / 10 # 10の位
        return int(one + ten)
    elif(100 <= k < 1000): # 1の位と10の位と100の位
        one = k % 10 # 1の位
        ten = (k - one) % 100 / 10 # 10の位
        hundred = (k - ten * 10 - one) / 100 # 100の位
        return int(one + ten + hundred)
    elif(k == 10000):
        return 1
    else: # 1の位と10の位と100の位と1000の位
        one = k % 10 # 1の位
        ten = (k - one) % 100 / 10 # 10の位
        hundred = (k - ten * 10 - one) % 1000 / 100 # 100の位
        thousand = (k - hundred * 100 - ten * 10 - one) / 1000 # 1000の位
        return int(one + ten + hundred + thousand)

'''
print(some(92)) # 11
print(some(14)) # 5
print(some(8)) # 8
print(some(893)) # 20
print(some(110)) # 2
print(some(999)) # 27
print(some(1000)) # 1
print(some(1234)) # 10
print(some(2580)) # 15
print(some(9800)) # 17
'''
sum = 0
for i in range(1,N+1):
    if(A <= some(i) and some(i) <= B):
        sum += i

print(sum)

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#083_B
n,a,b=map(int,input().split())
def k_sum(x):
    x=[int(i) for i in list(str(x))]
    return sum(x)
print(sum([i for i in range(1,n+1) if a<=k_sum(i)<=b]))

Submission status: Accepted

Solution code:

def Some_Sums(n , a , b):

    ans = 0

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

    return ans

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
ans = 0
for i in range(n+1):
    if a <= sum(map(int,sorted(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):
    m = 0
    i0 = i
    while i != 0:
        m += int(i % 10)
        i = int(i / 10)
    if a <= m <= b:
        ans += i0
print(ans)

Submission status: Accepted

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

N_str = str(N)
result = 0
for n in range(1, N + 1):
  sum_N = 0
  for s in str(n):
    sum_N += int(s)
  
  if (A <= sum_N and sum_N <= B):
    result += n

print(result)

Submission status: Accepted

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

# 各桁の和を計算する関数
def findSumOfDigits(n):
  sum = 0
  while n > 0:
    q, mod = divmod(n, 10)
    sum += mod
    n = q
  return sum

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())
sum=0

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

    a=i//10000
    x=i-10000*a

    b=x//1000
    x=x-1000*b

    c=x//100
    x=x-100*c

    d=x//10
    e=x-10*d

    s=a+b+c+d+e
    if A<=s<=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):
    cnt = 0
    i = str(i)
    for j in i:
        cnt += int(j)
    if cnt >= A and cnt <= B:
        ans += int(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:
def find_sum_of_digits(n):
    sum_of_digits = 0
    while n>0:
        sum_of_digits = sum_of_digits + n % 10
        n = int(n / 10)
    return sum_of_digits


n, a, b = [int(e) for e in input().split()]
ans = 0
for i in range(n+1):
    sum_of_digits = find_sum_of_digits(i)
    if a <= sum_of_digits and sum_of_digits <= b:
        ans = ans + i
print(ans)

Submission status: Accepted

Solution code:
nab = list(map(int, input().split()))
n = nab[0]
a = nab[1]
b = nab[2]

result_list = []

for i in range(n):
    j = i + 1
    result = sum(list(map(int, str(j))))
    if (result >= a) & (result <= b):
        result_list.append(j)

print(sum(result_list))

Submission status: Accepted

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

count = 0
amount = 0
for i in range(N+1):
    number = str(i)
    for x in number:
        x = int(x)
        amount += x

    if A <= amount <= B:
        number = int(i)
        count += i

    amount = 0

print(count)

Submission status: Accepted

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

nl = [str(i) for i in range(1, n+1)]
r = 0
for ns in nl:
    score = sum(list(map(int, ns)))
    if a <= score <= b:
        r += int(ns)

print(r)

Submission status: Accepted

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

Submission status: Accepted

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


def f(x):
    s = str(x)
    arr = list(map(int, s))
    return sum(arr)


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

Submission status: Accepted

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

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

total = 0
for i in range(l[0]+1):
    
    digit = digitSum(i)
    if l[1] <= digit and digit <= l[2]:
        total += i

print(total)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
def get_sum(a):
    sum = 0
    while(a != 0):
        sum = sum + a%10
        a = a//10
    return sum

res = 0
for i in range(n+1):
    t = get_sum(i)
    if(a <= t and t <= b):
        res = res + i

print(res)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
total = 0
for i in range(1, n+1):
    if a<= sum(map(int, list(str(i)))) <= 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):
    j = i
    d = 0
    while j != 0:
        d += j % 10
        j //= 10
    if a <= d and d <= 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 = sum(list(map(int, list(str(i)))))
    if a <= s and s <= b:
        ans += i
print(ans)

Submission status: Accepted

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

print(t)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, low_A, up_B = map(int, input().split())
ans = 0

for i in range(1, N + 1):
    keta = list(str(i))
    summ = sum([int(i) for i in keta])
    
    if (low_A <= summ and summ <= up_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 = list(str(i))
  counter = 0
  for j in _tmp:
    counter += int(j)
  if a <= counter <= b:
    ans += i
print(ans)

Submission status: Accepted

Solution code:
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

N,A,B=MI()

def calc(n):
    temp=0
    for i in range(5):
        temp+=n%10
        n=n//10
    return temp


ans=0
for i in range(N):
    n=i+1
    temp=calc(n)
    if temp>=A and temp<=B:
        ans+=n
        
print(ans)

Submission status: Accepted

Solution code:
n, a, b = [int(e) for e in input().split()]
ans = 0
for ni in range(1, n + 1):
    if a <= sum([int(c) for c in str(ni)]) <= b:
        ans += ni

print(ans)

Submission status: Accepted

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

ans = 0

for i in range(1, N+1):
    str_num = str(i)
    digit_sum = 0
    for c in str_num:
        n = int(c)
        digit_sum += n
    if digit_sum >= A and digit_sum <= B:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
length,mi,ma = map(int,input().split())
summ = 0
for i in range(1,length + 1):
  s = str(i)
  arr = list(map(int,s))
  su = sum(arr)
  if(su <= ma and su >= mi):
    summ += i
print(summ)

Submission status: Accepted

Solution code:
li = list(map(int, input().split()))
ans = 0
for i in range(li[0]):
  i += 1
  s = sum(list(map(int, str(i))))
  if s >= li[1] and s <= li[2]: 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):
    si=list(str(i))
    res=0
    for j in si:
        res+=int(j)
    if A<=res<=B:
        ans+=i
print(ans)

Submission status: Accepted

Solution code:
def main():
    num = list(map(int, input().split()))
    total_sum = 0
    for i in range(1,num[0]+1):
        current = i
        current_sum=0
        while i >=1:
            current_sum += int( i %10)
            i = i//10
        if ((current_sum >= num[1]) and (current_sum <= num[2])):
            total_sum += current
    print(total_sum)
main()

Submission status: Accepted

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

l =[i for i in range(1,n+1)]

x = 0
for j in range(n):
     y = [int(i) for i in str(l[j])]
     if sum(y) >=a and sum(y) <=b:
         x += l[j]

print(x)

Submission status: Accepted

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

ans = 0
for i in range(1, n+1):
    s = str(i)
    ss = 0
    for k in range(len(s)):
        ss += int(s[k])
    if a<=ss<=b:
        ans += int(s)
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())

sum = 0

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

Submission status: Accepted

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

def calc(x):
    return int(x / 10), x % 10

def func(x, ans):
    a, b = calc(x)
    ans += b
    if a == 0:
        return ans
    return func(a, ans)

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

print(ans)

Submission status: Accepted

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

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

print(tmp)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

def sums(n):
    x=0
    while n>0:
        x+=n%10
        n=n//10
    return x

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

Submission status: Accepted

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

total = 0

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

    p = i // 10000 + (i % 10000) // 1000 + (i % 1000) // 100 + (i % 100) // 10 + (i % 10)

    if a <= p <= b:
        total += i

print(total)

Submission status: Accepted

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

result = 0

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

print(result)

Submission status: Accepted

Solution code:
Nu,A,B = map(int, input().split())
ans = 0
for j in range(0,10):
    for k in range(0,10):
        for l in range(0,10):
            for m in range(0,10):
                if A <= j+k+l+m <= B:
                    num = j*1000 + k*100 + l*10 + m
                    if num <= Nu:
                        ans+=num

if A == 1 and Nu ==10000:
    ans += 10000

print(ans)

Submission status: Accepted

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

for i in range(N+1):
    c = 0
    t = i
    while t > 0:
        c += t % 10
        t //= 10
    if c >= A and c <=B:
        goukei += i
print(goukei)

Submission status: Accepted

Solution code:
# B - Some Sums
n,a,b = [int(i) for i in input().split()]
count_list = []
for j in range(1,n+1):
    num = sum([int(k) for k in str(j)])
    if a<= num <=b:
        count_list.append(j)


        

    
print(sum(count_list))

Submission status: Accepted

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

for i in range (n+1):
  u=i//10000
  v=(i-10000*u)//1000
  x=(i-10000*u-1000*v)//100
  y=(i-10000*u-1000*v-100*x)//10
  z=(i-10000*u-1000*v-100*x-10*y)
  if a<=u+v+x+y+z<=b:
    kei+=i
print(kei)

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
Sum=0
for i in range(1,n+1):
  Sum=0
  x=i
  for j in range(len(str(i))):
    Sum+=x%10
    x//=10
  if a<=Sum<=b:
    ans+=i
print(ans)

Submission status: Accepted

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


def func(x):
    ans = 0
    while x > 0:
        ans += x % 10
        x = x // 10

    return ans


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

print(ans)

Submission status: Accepted

Solution code:
# coding: -utf8
N,A,B = input().split(" ")
N = int(N)
A = int(A)
B = int(B)
NC = [0,0,0,0,0]

answer = 0
for i in range(N+1):
  NC[4] = i // 10000
  NC[3] = (i - NC[4] * 10000)// 1000
  NC[2] = (i - NC[4] * 10000 - NC[3] *1000) // 100
  NC[1] = (i - NC[4] * 10000 - NC[3] *1000 - NC[2] * 100) //10
  NC[0] = i % 10
  sum = 0
  for j in range(5):
    sum = sum + NC[j]
  if(A <= sum and sum <= B):
    answer = answer + i
print(answer)

Submission status: Accepted

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


def main():
    limit, digit_sum_lower, digit_sum_upper = map(int, input().split())
    answer = 0
    for i in range(1, limit + 1):
        if digit_sum_lower <= get_digits_sum(i) <= digit_sum_upper:
            answer += i
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N_,A_,B_=input().split()
N = (int)(N_)
A = (int)(A_)
B = (int)(B_)

sum = 0
for n in range(1,N+1):
    count = 0
    n_ = (str)(n)
    n_num = len(n_)
    for i in range(n_num):
        count = count + (int)(n_[i])
    if A<=count and B>=count:
        sum = sum + n
print(sum)

Submission status: Accepted

Solution code:
def solve():
    n, mi, ma = list(map(int, input().split()))
    ans = 0
    for i in range(1, n+1):
        s = sum(list(map(int, str(i))))
        if mi <= s <= ma:
            ans += i
    return ans

print(solve())

Submission status: Accepted

Solution code:
def solve():
    A = list(map(int, input().split()))

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

print(solve())

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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