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())
#print(a,b,c)
ans=0
for i in range(1,n+1):
  j = str(i)
  l=[int(k) for k in j]   
  gokei=sum(l)
  if a<=gokei<=b:
    ans+=i
    
print(ans)

Submission status: Accepted

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

#Nの範囲内の数値をリストに格納
N_list = list(range(1, N+1))

#条件に合うNの値を格納するリストを作成
N_match = []


#以下の処理をNの範囲で繰り返す
for n in N_list:
    
    #最後の処理（※）のためにnを別の値に代入しておく
    i = n

    #各桁の数値を求める
    #余りを格納するリストを作成
    R_list = []

    while True:
    
        #1の位の数値を算出しリストに順に格納
        R = n%10   
        R_list.append(R)    
    
        #10で割ることで、1の位を削る
        n = int(n/10)
    
        #1の位を削った時、N==0となった場合処理終了
        if n==0:
            break
    
    
    #あるnにおける各桁の和を算出
    R_sum = sum(R_list)
    
    #（※）条件に合致した時、その時のnをリストに格納
    if A<=R_sum<=B:
        N_match.append(i)
               
print(sum(N_match))

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split(" "))
list = []
for i in range(1,N+1):
    i = str(i)
    if len(str(i)) == 1:
        d = int(i)
    elif len(str(i)) == 2:
        d = int(i[0]) + int(i[1])
    elif len(str(i)) == 3:
        d = int(i[0]) + int(i[1]) + int(i[2])
    elif len(str(i)) == 4:
        d = int(i[0]) + int(i[1]) + int(i[2]) + int(i[3])
    elif len(str(i)) == 5:
        d = int(i[0]) + int(i[1]) + int(i[2]) + int(i[3]) +int(i[4])
    list.append(d)
ans = 0
for j in range(len(list)):
    if list[j] >= A and list[j] <= B:
        ans += j+1
print(ans)

Submission status: Accepted

Solution code:
a = list(int(i) for i in input().split()) 
ct = 0
for i in range (0,a[0]):
 c = int(0)
 d = int(i+1)
 for j in range(0,5):
  c += d%10
  d  = d//10
 if a[1]<=c and c <=a[2]:
  ct += i+1
print(ct)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def sum_digits(num):
    total = 0
    while num != 0:
        total += num % 10
        num //= 10
    return total

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

ans = 0

for i in range(1, n + 1):
    num = i
    total = sum_digits(num)

    if a <= total <= 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 = i
    total = 0
    while num != 0:
        total += num % 10
        num //= 10

    if a <= total <= 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 = i
    total = 0
    while True:
        total += num % 10
        num //= 10
        if num == 0:
            break
    if a <= total <= b:
        ans += i

print(ans)

Submission status: Accepted

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

def find(x):
        rtn=0
        while x>0:
                rtn+=int(x%10)
                x/=10
        return rtn

for i in range(n+1):
        sum=int(find(i))
        if sum>=a and sum<=b:
                ans+=int(i)

print(ans)

Submission status: Accepted

Solution code:
n = list(map(int,input().split()))
ans = 0
count = 0
for i in range(n[0]+1):
    j = i
    ans = 0
    while(i is not 0):
        ans = ans + i%10
        i = int(i/10)
    if ans >= n[1] and ans <= n[2]:
        count = count +j
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
N, A, B = map(int, input().split())
ans = 0
for x in range(1, N+1):
    sum_x = sum(map(int, str(x)))
    if A <= sum_x <= B:
        ans += x
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
N, A, B = map(int, input().split())
ans = 0
for x in range(1, N+1):
    z = str(x)
    sum_x = sum(int(y) for y in z)
    if A <= sum_x <= B:
        ans += x
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

def main():
    sa = input().split(' ')
    n = int(sa[0])
    a = int(sa[1])
    b = int(sa[2])

    c = 0
    for i in range(n + 1):
        k = i % 10 + int(i / 10) % 10 + int(i / 100) % 10 + int(i / 1000) % 10 + int(i / 10000) % 10
        if a <= k and k <= b:
            c += i

    print(c)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def abc083_b():
    n, a, b = map(int, input().split())
    ans = 0
    for i in range(1, n + 1):
        tmp = 0
        for digit in str(i):
            tmp += int(digit)
        if a <= tmp <= b:
            ans += i
    print(ans)


abc083_b()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
def _sum(n):
    ans = 0
    while n>0:
        ans += n%10
        n /= 10
        n = int(n)
    return ans
total = 0
for i in range(N+1):
    judge = _sum(i)
    if A <= judge <= B:
        total += i
print(total)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest083-B
#  https://atcoder.jp/contests/abc083/tasks/abc083_b

def sumKeta(number):
	number2Str = str(number)
	numberLength=len(number2Str)
	thisNumberSum = 0
	ketaRange = range(0,numberLength,1)
	for i in ketaRange:
		thisNumberKeta = int(number2Str[i])
		thisNumberSum = thisNumberKeta + thisNumberSum

	return thisNumberSum


def  sumRangeCalcRange(limitNumber,fromNumber,toNumber):
	sumValue = 0
	valueRange = range(0,limitNumber+1,1)
	for nowNumber in valueRange:
		thisSum = sumKeta(nowNumber)
		if (fromNumber <= thisSum and thisSum <= toNumber):
			sumValue = sumValue + nowNumber
	answer = sumValue
	return answer


if __name__ == '__main__':
	n,a,b = map(int,input().strip().split(' '))
	solution=sumRangeCalcRange(n,a,b)
	print(solution)

Submission status: Accepted

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

##nの各桁の和を求める

def digitSum(s):
    x1 = s//10**4
    x2 = (s-x1*10**4)//10**3
    x3 = (s-x2*10**3-x1*10**4)//10**2
    x4 = (s-x3*10**2-x2*10**3-x1*10**4)//10
    x5 = (s-x4*10-x3*10**2-x2*10**3-x1*10**4)
    # print(x1,x2,x3,x4,x5)
    return x1+x2+x3+x4+x5
    

count = 0
for i in range(1,n+1):
    u = digitSum(i)
    if ((u >= a) and (u<= b)):
        # print(u)
        count += i


print(count)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
ans = 0
for i in range(N+1):
    sum = i%10 + i//10%10 + i//100%10 + i//1000%10 + i//10000
    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(map(int, list(str(i)))) <= B:
        ans += i
print(ans)

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,a,b = list(map(int,input().split()))
Sum_0 = 0

for i in range(1,N+1):
    Sum_1 = 0
    t = i
    while t != 0:
        Sum_1+=t%10
        t = t//10
        
    if a <= Sum_1 <= b:
        Sum_0+=i
print(Sum_0)

Submission status: Accepted

Solution code:
N,a,b = list(map(int,input().split()))
Sum_0 = 0

for i in range(N+1):
    i = str(i)
    Sum_1 = 0
    for t in i:
        Sum_1 += int(t)
    if a <= Sum_1 <=b:
        Sum_0+=int(i)
print (Sum_0)

Submission status: Accepted

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

def digitsum(num):
    s = str(num)
    r = 0
    for c in s:
        r += int(c)
    return r

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

Submission status: Accepted

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

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(map(int, list(str(x)))) <= b]))

Submission status: Accepted

Solution code:
N,A,B = [int(i) for i in input().split()]
all_sum = 0
for i in range(1,N+1) :
    degit_sum = sum([int(i) for i in list(str(i))])
    if (A <= degit_sum and degit_sum <= B ) :
        all_sum += i

print(all_sum)

Submission status: Accepted

Solution code:
def calculate_sum_of_digits(n):
    result = 0
    while n != 0:
        result += n % 10

        n //= 10

    return result


n, a, b = map(int, input().split())
result = 0
for i in range(1, n + 1):
    sum_of_digits = calculate_sum_of_digits(i)
    if a <= sum_of_digits <= b:
        result += i

print(result)

Submission status: Accepted

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

total = 0
for i in range(1, N+1):
  _i = i
  k=0
  for _ in range(len(str(i))):
    k += _i % 10
    _i //= 10
  if A <= k <= 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):
    strli = list(str(i))
    l_n_str = [int(n) for n in strli]
    sumstr = sum(l_n_str)
    if a <= sumstr <= 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 i in range(1,n+1):
	dat = str(i)
	w_sum = 0
	for d in dat:
		w_sum = w_sum + int(d)
	if (w_sum>=a and w_sum<=b):
		sum = sum + i
	
print(sum)

Submission status: Accepted

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

for i in range(N+1):
    n=0
    for t in str(i):
        n += int(t)
    if A <= n <= B:
        X_list.append(i)
    
print(sum(X_list))

Submission status: Accepted

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

Sum=0


for i in range(N+1):
    keta=0
    l = [int(x) for x in list(str(i))]
    for j in range(len(l)):
        keta+=l[j]

    if(keta>=A and keta<=B):
        Sum+=i
    
print(Sum)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split(" "))
cnt = 0
all_ans = []
for i in range(1, N+1):
  ans = sum([int(i) for i in list(str(i))])
  if A <= ans and ans <= B:
    all_ans.append(i)
print(sum(all_ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,a,b = map(int,input().split(" "))
total= 0
ans = 0
for i in range(1,N+1):
    st_i = str(i)
    for j in range(4):
        try:
            total += int(st_i[j])
        except:
            pass


    if a <= total <= b:
        ans += i
    total = 0

print(ans)

Submission status: Accepted

Solution code:
# Some Sums
n, a, b = map(int, input().split())
n = int(n)
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())
A=[]
for i in range(1,n+1):
  m=0
  for j in range(len(str(i))):
    m+=int(str(i)[j])
  else:
    if a<=m<=b:
      A.append(i)
print(sum(A))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
(lambda NAB: print(sum([int(i) for i in range(1, NAB[0] + 1) if NAB[1] <= sum(map(int, list(str(i)))) <= NAB[2]])))([int(i) for i in input().split()])

Submission status: Accepted

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

Submission status: Accepted

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

some_sum = 0
for num in range(n+1):
	tmp_num = num
	
	sum_num = 0
	while tmp_num > 0:
		sum_num += tmp_num % 10
		tmp_num //= 10
	
	if a <= sum_num and sum_num <= b:
		some_sum += num
		#print(num)

print(some_sum)

Submission status: Accepted

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

def charSum(s):
    r = 0
    for c in s:
        r += int(c)
    return r

ans = sum(list(filter(lambda x: a <= charSum(str(x)) <= b, range(1, n+1))))
print(ans)

Submission status: Accepted

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


def calculate_summary_of_digits(n):
    result = 0
    while n != 0:
        result += (n % 10)
        n //= 10

    return result


result = 0
for i in range(1, n + 1):
    sum_of_digits = calculate_summary_of_digits(i)
    if a <= sum_of_digits <= b:
        result += i

print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def sum(i):
	S = 0
	while i >= 1:
		S +=  i % 10
		i = i // 10
	return S

counter = 0

N, A, B = (int(i) for i in input().split()) #任意個の整数値の入力、今の場合３個



for i in range(1, N + 1):	#rangeの範囲に注意
	if sum(i) >= A and sum(i) <= B:
		counter += i

print(counter)

Submission status: Accepted

Solution code:
def getNum(x):
    sum = 0
    for i in range(len(str(x))):
        sum += int(str(x)[i])
    return sum

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

Submission status: Accepted

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

sum1 = 0

for n in range(N+1):
    if A <= sum([int(s) for s in str(n)]) <= B:
        sum1 += n

print(sum1)

Submission status: Accepted

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


def sum_digit(n):
    result = 0
    while True:
        result += (n % 10)
        n //= 10
        if n == 0:
            break

    return result


summary = 0
for i in range(1, n + 1):
    sum_of_digits = sum_digit(i)
    if a <= sum_of_digits <= b:
        summary += i

print(summary)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
total = 0
for i in range(1, N + 1):
    sum_digits = 0
    j = i
    while j > 0:
        sum_digits += j % 10
        j //= 10
    if A <= sum_digits <= 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_sum = 0
    for j in str(i):
        digit_sum += int(j)
    if a <= digit_sum & digit_sum <= b:
        ans += i
print(ans)

Submission status: Accepted

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

if __name__ == "__main__":
    n, a, b = map(int, input().split())

    val = 0
    for i in range(1, n+1):
        dum = 0
        for j in str(i):
            dum += int(j)

        if a <= dum <= b:
            val += i

    print(val)

Submission status: Accepted

Solution code:
a,b,c = map(int,input().split(" "))
count = 0
sr = []
for i in range(1,a+1):
    ar = list(str(i))
    for r in ar:
        count += int(r)
    if count >= b and count <= c:
        sr.append(i)
    count = 0
print(sum(sr))

Submission status: Accepted

Solution code:
def sumorder(k, a, b):
  arr = list(str(k))
  s = sum(list(map(int,arr)))
  #print(arr, s)
  if a<=s and s<=b:
    return True
  else:
    return False
  
n, a, b = list(map(int, input().split()))
ans = 0
for i in range(1, n+1):
  if sumorder(i, a, b):
    ans += i
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
plus = 0

for i in range(0,n_a_b[0]+1,1):
    num = i

    for j in range(5):
        plus = plus + num % 10
        num = int(num /10) 

    if  n_a_b[1] <= plus and plus <= n_a_b[2]:
        ans = ans + i

    plus = 0

print(ans)

Submission status: Accepted

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

ans = 0
plus = 0

for i in range(0,n_a_b[0]+1,1):
    num = i
    for j in range(5):
        plus = plus + num % 10
        num = int(num /10) 
        if i < 0:
            break

    if  n_a_b[1] <= plus and plus <= n_a_b[2]:
        ans = ans + i

    plus = 0

print(ans)

Submission status: Accepted

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

ans = 0

for i in range(0,n_a_b[0]+1,1):
    plus = i - (int(i/10) * 9 + int(i/100) * 9 + int(i/1000) * 9+ int(i/10000) * 9)

    if  n_a_b[1] <= plus and plus <= n_a_b[2]:
        ans = ans + i

print(ans)

Submission status: Accepted

Solution code:
N, A, B = map(int, raw_input().split())
res = 0
for i in range(1, N + 1):
	num = sum([int(n) for n in list(unicode(i))])
	if A <= num and num <= B:
		res += i
print res

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

Solution code:
n, a, b = [int(i) for i in input().split()]
sum = 0
for i in range(1, n + 1):
    digitSum = 0
    target = i
    while target > 0:
        digitSum += target % 10
        target = int(target / 10)
    if a <= digitSum <= 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):
    i_sum = sum(list(map(int, str(i))))
    if i_sum >= A and i_sum <= B:
        ans += i
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

ok_list = []

for i in range(1, N+1):
    str_i = str(i)
    i_sum = sum(map(int, list(str(i))))
    if A <= i_sum and i_sum <= B:
        ok_list.append(int(i))
print(sum(ok_list))

Submission status: Accepted

Solution code:
n,a,b=map(int, input().split())
 
def dsum(n):
  res = 0
  while n>0:
    res += n%10
    n //= 10
  return res
 
cnt = 0
for i in range(1,n+1):
  if a<=dsum(i)<=b:
    cnt += i
print(cnt)

Submission status: Accepted

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

s = 0


def dsum(n):
	res = 0
	while n!= 0:
		res += n%10
		n = n//10

	return res


for i in range(1,n+1):
	if (dsum(i)>=a and dsum(i)<=b):
		s +=i

print(s)

Submission status: Accepted

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

for i in range(n+1):
    sum = 0
    n_list = list(str(i))
    for j in range(len(n_list)):
        sum += int(n_list[j])
    
    if (sum >= a) and (sum <= b):
        all_sum += i
    else:
        pass

print(all_sum)

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):
  if a <= sum(list(map(int, list(str(i))))) <= b:
    ans += i
  
print(ans)

Submission status: Accepted

Solution code:
def sum(i):
	sum = 0

	while i  >= 1 :
		# 余りを足す i.e 1の位を足す eg. 153は+3
		sum += i % 10
		# 一の位を消す eg. 153 -> 15   3 -> 0
		i = i //10
	return sum	


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

counter = 0

for i in range(1 , N + 1 ):
	
	j = sum(i)
	
	if j >= A and j <= B :
		counter += i
		


print(counter)

Submission status: Accepted

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

sum_lst = []

for i in range(1, n+1):
    i_lst = list(str(i))
    sums = 0
    for j in i_lst:
        sums += int(j)
    if a <= sums <= b:
        sum_lst.append(int(i))

print(sum(sum_lst))

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
List=[]
Correct=[]
Counter=0
n=1
M=0
while n<=N:
    M=n
    while Counter<=5:
      List.append(M%10)
      M=int(M/10)
      Counter+=1
    if A<=sum(List)<=B:
      Correct.append(n)
    List.clear()
    n+=1
    Counter=0
print(sum(Correct))

Submission status: Accepted

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


def division(x):
    tmp = 0
    while x > 0:
        shou,amari = divmod(x,10)
        tmp += amari
        x = shou
    return tmp


    
for i in range(n+1):
    z = division(i)
    if a <= z <= b:
        iamsum += i
print(iamsum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def sum_digits(x):
        rt = ''
        for char in str(x):
            rt += char
            rt += '+'

        return eval(rt[0:-1])


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

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

    return ans

  
if __name__ == '__main__':
  print(some_sums())

Submission status: Accepted

Solution code:
n, low, high = map(int, input().split())
ans = 0
save = 0

def keisan(j):
    goukei = 0
    while j > 0:
        goukei += int(j % 10)
        j = int(j / 10)
    return goukei
            
for i in range(n + 1):
    save = keisan(i)
    if low <= save <= high:
            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):
    s_sum = 0
    j = i
    while True:
        if j >= 10:
            s_sum += j % 10
            j = j // 10
        else:
            s_sum += j
            break
    if A <= s_sum and s_sum <= 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):
    x = (sum(list(map(int, list(str(i))))))
    if A <= x <= 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 = sum(list(map(int, list(str(i)))))
    if a <= x <= b:
        ans += i
print(ans)

Submission status: Accepted

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

Answers = []
for i in range(1,N+1):
    Nums = str(i)
    Sum = 0
    for num in Nums:
        Sum += int(num)
    if A <= Sum <= B:
        Answers.append(i)
print(sum(Answers))

Submission status: Accepted

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

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

print(r)

Submission status: Accepted

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

Submission status: Accepted

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

def sum_digit(x):
    y = sum(int(digit) for digit in str(x))
    return y

result = []
for i in range(n+1):   
    z = sum_digit(i)
    if(int(z)<=b and int(z)>=a):
        result.append(i)
        
print(sum(result))

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
i=1
count=0
while i<=N:
    s=str(i)
    c=0
    for ss in s:
        c+=int(ss)
    if c>=A and c<=B:
        count+=i
    i+=1
print(count)

Submission status: Accepted

Solution code:
import sys

num = raw_input().strip().split()
ans = 0

for i in range(1, int(num[0])+1):
    cnt = 0
    a = i
    while a !=0:
        cnt += a%10
        a = a/10
    if cnt >= int(num[1]) and cnt <= int(num[2]):
        ans += i
print(str(ans))

Submission status: Accepted

Solution code:
import sys

def sum_keta(num):
    tmp = num
    res = 0
    while tmp != 0:
        res += (tmp % 10)
        tmp = int(tmp/10)
    return res

n, a, b = list(map(int, sys.stdin.readline().strip().split(" ")))

r = 0
for i in range(1, n+1):
    s = sum_keta(i)
    if a <=  s and b >= s:
        r += i

print(r)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def func(x):
    if x == 0: return 0
    return func(x // 10) + (x % 10)


if __name__ == '__main__':
    n, a, b = map(int, input().split())

    i = 1
    ans = 0
    while i <= n:
        if a <= func(i) <= b:
            ans += i
        i += 1

    print(ans)

Submission status: Accepted

Solution code:
from sys import stdin


def main() -> None:
    n, a, b = [int(next_str()) for _ in range(3)]
    ans = 0

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

    print(ans)


def sum_of_digits(a: int) -> int:
    result = 0
    while a != 0:
        result += a % 10
        a //= 10
    return result


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def digits_sum(n):
    s = 0
    while True:
        n, t = divmod(n, 10)
        s = s + t
        if n == 0:
            break
    return s


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

xs = {i: digits_sum(i) for i in range(1, N+1)}
ys = [i for i, y in xs.items() if A <= y and y <= B]
print(sum(ys))

Submission status: Accepted

Solution code:
def digits_sum(n):
    s = 0
    while True:
        n, t = divmod(n, 10)
        s = s + t
        if n == 0:
            break
    return s


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

answer = 0
for i in range(1, N+1):
    s = digits_sum(i)
    if A <= s and s <= B:
        answer = answer + i
print(answer)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n,a,b = map(int, input().split())

res=0

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

Submission status: Accepted

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

for x in range(1,N + 1):
    sx = str(x)
    total = 0
    for i in range(len(sx)):
        total += int(sx[i])

    if A <= total and total <= B:
        ans += x

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def SumDegit(N):
    s = str(N)
    Sum = 0
    for i in range(len(s)):
        Sum = Sum + int(s[i])
    return Sum

N = input().split()
N = [int(n) for n in N]

count = 0
for i in range(N[0]):
    if((SumDegit(i+1)>=N[1])and(SumDegit(i+1)<=N[2])):
        count = count + (i+1)
print(count)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from functools import reduce
n,a,b = map(int, input().split(' '));
re = 0;

for x in range(1, n+1):
    digits = list(str(x));
    sum_x  = reduce( lambda a,b: int(a)+int(b), digits, 0)
    if ( a <= sum_x and sum_x <= b ):
        re += x;

print(re);

Submission status: Accepted

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

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

print(total)

Submission status: Accepted

Solution code:
def sum_(a):
    ans=0
    while a!=0:
        ans+=a%10
        a//=10
    return ans

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

arr=[0 for i in range(37)]
for i in range(1,N+1):
    arr[sum_(i)]+=i

print(sum(arr[A:B+1]))

Submission status: Accepted

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


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

a = list(map(int, input().split()))
N = a[0]
A = a[1]
B = a[2]

total = 0
for i in range(N):
    sumOfDigits = calcSumOfDigits(i+1)
    # print("sumOfDigits: ", sumOfDigits)
    if sumOfDigits >= A and sumOfDigits <= B:
        # print("N: ", i+1)
        total += i+1
# print("total: ", total)
print(total)

Submission status: Accepted

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

print(sum(ans_list))

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
    j=i%10+(i//10)%10+(i//100)%10+(i//1000)%10+(i//10000)%10+(i/100000)%10
    if a<=j<=b+1:
        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):
    _num = 0
    digits = list(str(n))
    for _n in list(str(n)):
        _num += int(_n)

    if _num >= A and _num <= B:
        sum += n

print(sum)

Submission status: Accepted

Solution code:
## ABC 083
## B - Some Sums
n,a,b = (int(_) for _ in input().split())

ans = 0
for i in range(1,n+1):
    nl = list(str(i))
    s = 0
    for j in nl:
        s += int(j)
    if(a <= s <= b):
        ans += i
    
print(ans)