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

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
all=0
for i in range(n+1):
    l=str(i)
    v=0
    for j in range(len(l)):
        v=v+int(l[j])
    
    if a<=v & v<=b:
        all=all+i

print(all)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
l=[]
for i in range(1,n+1):
    tmp=0
    tmp_l=[]
    for j in range(len(str(i))):#各桁の和を算出
        tmp_l.append(int(str(i)[j]))
        tmp=sum(tmp_l)
    if a<= tmp <=b:
        l.append(i)
        
ans=sum(l)
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([int(i) for i in list(str(i))])
    if A <= j <= B:
        ans += i
        
print(ans)

Submission status: Accepted

Solution code:
import math
 
n, a, b = map(int, input().split())
 
sum_all = 0
for i in range(1, n + 1):
    sum_n = 0
    m = i
    while(m > 0):
        sum_n += math.floor(m % 10)
        m /= 10
    if a <= sum_n <= b:
        sum_all += i
 
print(sum_all)

Submission status: Accepted

Solution code:
import math

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

sum_all = 0
for i in range(1, n + 1):
    sum_n = 0
    m = i
    while(m > 0):
        sum_n += math.floor(m % 10)
        m = int(m / 10)
    if a <= sum_n <= b:
        sum_all += i

print(sum_all)

Submission status: Accepted

Solution code:
import math

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

sum_all = 0
for i in range(1, n + 1):
    sum_n = 0
    m = i
    while(m > 0):
        sum_n += m % 10
        m = int(m / 10)
    if a <= sum_n <= b:
        sum_all += i

print(sum_all)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

sum_all = 0
for i in range(1, n + 1):
    sum_n = 0
    m = i
    while(m > 0):
        sum_n += math.floor(m % 10)
        m /= 10
    if a <= sum_n <= b:
        sum_all += i

print(sum_all)

Submission status: Accepted

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

res = 0
for i in range(1, N+1):
    n = i
    sums = 0
    while i > 0:
      sums += i % 10
      i = int(i / 10)

    if A <= sums and sums <= B:
        res += n

print(res)

Submission status: Accepted

Solution code:
def sum_digit(N):
    res = N%10
    while N//10 > 0:
        N = N//10
        res += N%10
    return res


if __name__ == '__main__':
    N, A, B = map(int, input().split())

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

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
ans = 0
for i in range(0, 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())
total=[]
for i in range(1,N+1):
    ans=i%10+i//10%10+i//100%10+i//1000%10+i//10000%10
    if A<=ans and ans<=B:
        total.append(i)
print(sum(total))

Submission status: Accepted

Solution code:
a = list(map(int,input().split()))
N = a[0]
A = a[1]
B = a[2]
Lis = []
for i in range(1,N+1):
    k = i%10 + i//10%10 + i//10//10%10 + i//10//10//10%10 + i//10//10//10//10%10
    if k <= B and k >= A:
        Lis.append(i)
print(sum(Lis))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B = map(int, input().split())
S = []
for i in range(1,N+1):
  if i < 10 and A <= i <= B:
    S.append(i)
  elif i >= 10:
    a = list(str(i))
    count = 0
    for j in range(len(a)):
      count += int(a[j])
    if A <= count <= B:
      S.append(i)
print(sum(S))

Submission status: Accepted

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

total = 0
for num in range(1, n + 1):
    digits = [int(digit_str) for digit_str in str(num)]
    if a <= sum(digits) <= b:
        total += int(''.join(map(str, digits)))

print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
anssumsum=0
for i in range(n):
    num=i+1
    num10000=num//10000
    num1000=(num - num10000*10000)//1000
    num100=(num- num10000*10000-num1000*1000)//100
    num10=(num- num10000*10000-num1000*1000-num100*100)//10
    num1=num- num10000*10000-num1000*1000-num100*100-num10*10
    anssum=num10000+num1000+num100+num10+num1
    if (anssum>=a)&(anssum<=b):
        anssumsum=anssumsum+num
    #print(num1000,num100,num10,num1)
print(anssumsum)

Submission status: Accepted

Solution code:
def someSums():
	n, a, b = map(int, input().split())
	count = 0
	for i in range(1, n + 1):
		sum = 0
		n = i
		while True:
			sum += n % 10
			if n >= 10:
				n = n // 10
			else:
				break
		if a <= sum and sum <= b:
			count += i
	print(count)

someSums()

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
  for k in range(len(str(i))):
    SUM+=t%10
    t=t//10
  if A<=SUM<=B:
    ans+=i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
var_sum = 0
for x in range(1, n+1):
    value = 0
    for y in str(x):
        value += int(y)
    if(value >= a and value <= b):
        var_sum += x
print(var_sum)

Submission status: Accepted

Solution code:
a = list(map(int,input().split()))
z = 0

for i in range(a[0]+1):
  b = list(str(i))
  c = list(map(int,b))
  d = sum(c)
  if a[1]<=d<=a[2]:
    z+=i
else:
  print(z)

Submission status: Accepted

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

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

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

Submission status: Accepted

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


def keta(n):
    result = 0
    for s in str(n):
        result += int(s)
    return result

ans = 0
for i in range(1, N+1):
    k = keta(i)
    if A <= k <= 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
	n = i
	while n > 0:
		s += n % 10
		n = n // 10
	if a <= s <= b:
		ans += i
print(ans)

Submission status: Accepted

Solution code:
# 各桁の和を計算する関数
def findSumOfDigits(n):
    sum = 0
    while n > 0:
        sum += n % 10
        n = n // 10
    return sum

def main():
    N, a, b = list(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)
    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

S = 0
for n in range(1, N + 1):
    sum = 0
    for r in range(0, 5):
        sum += n // 10**r % 10
    if (A <= sum <= B):
        S += n

print(S)

Submission status: Accepted

Solution code:
N, A, B = [int(i) for i in input().split()]
result = 0
for number in range(1, N + 1):
    sum_num = sum([int(i) for i in str(number)])
    if (sum_num >= A and sum_num <= B):
        result += number
print(result)

Submission status: Accepted

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

def disassemble(i):
    ilist = []
    while i > 0:
        ilist.append(i%10)
        i //= 10
    ilist.reverse()
    i_sum = sum(ilist)
    return(i_sum)

for i in range(1, n+1):
    i_sum = disassemble(i)
    if a <= i_sum <= b:
        i_sum_sum += i

print(i_sum_sum)

Submission status: Accepted

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

amount = 0
for v in range(1, n+1):
    tmp = v
    s = 0
    while True:
        t = int(tmp % 10)
        tmp /= 10
        s += t
        if tmp == 0:
            break

    if a <= s and s <= b:
        amount += v

print(amount)

Submission status: Accepted

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

def calcsum(i):
	sum = 0
	while (i>0):
		sum += i%10
		i -= i%10
		i = i/10
	#print(sum)
	return sum

tmparr = input().split()

n = int(tmparr[0])
a = int(tmparr[1])
b = int(tmparr[2])
sum = 0

#print("n:{}".format(n))
#print("a:{}".format(a))
#print("b:{}".format(b))

for i in range(n+1):
	tmp = calcsum(i)
	if(tmp >= a):
		if(tmp <= b):
			sum += i
print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
row = input().split()
N = int(row[0])
A = int(row[1])
B = int(row[2])
ans = 0
for i in reversed(range(A,N+1)):
    temp = i
    order = []
    for j in reversed(range(0, 5)):
        order.append(int(temp / (10**j)))
        temp = temp - int(temp / (10**j))*10**j
    if A <= sum(order) <= 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):
    t = str(i)
    l = len(t)
    total = 0
    for j in range(l):
        total += int(t[j])
    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):
    s = list(map(int,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(N+1):
    if A <= sum(list(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())
# 求めたい総和
sum = 0
for i in range(N + 1):
    # 各桁の総和
    digitsum = 0
    i_copy = i
    while i > 0:
        digitsum += i % 10
        i = i // 10

    if A <= digitsum <= B:
        sum += i_copy
print("{}".format(sum))

Submission status: Accepted

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

ans=0

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

Submission status: Accepted

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

s = 0
out = 0

for x in range(n+1):
    x_str = str(x)
    array = list(map(int,x_str))
    s = sum(array)

    if a<=s<=b:
        out += x

print(out)

Submission status: Accepted

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

print(result)

Submission status: Accepted

Solution code:

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

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

    i_st = str(i)

    now = 0
    for j in i_st:

        now += int(j)

    if A <= now and now <= B:
        ans += i

print (ans)

Submission status: Accepted

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

nums=[]
for i in range(1,n+1):
    nums.append(i)
#print(nums)

ans=[]

for j in nums:
    n=list(map(int,str(j)))
    #print(n)
    if a<=sum(n)<=b:
        ans.append(j)


print(sum(ans))

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
ans=0
for i in range(1,N+1):
    s=str(i)
    c=0
    for k in s:
        c+=int(k)
    if A<=c and c<=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):
    l = [int(j) for j in list(str(i))]
    if a <= sum(l) <= 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=str(i)
    k=0
    for j in range(len(s)):
        k+=int(s[j])
    if a<=k and k<=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:
length,mi,ma = map(int,input().split())
summ = 0
for i in range(1,length + 1):
  digits = len(str(i))
  digits_summary = 0
  
  for j in range(digits):
    digits_summary += int(str(i)[j])
  
  if mi<=digits_summary and digits_summary<=ma:
    summ += i
  else:
    pass
print(summ)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
ans = 0
i = 1
while i <= n:
    x = 0
    li = list(str(i))
    for p in li:
        x += int(p)
    if a <= x <= b:
        ans += i
        i += 1
    else:
        i += 1
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
import time
import re
import math
import fractions

def main():
    N,A,B=map(int,input().split())
    count=0
    for a in range(1,N+1):
        s=str(a)
        total=0
        for b in s:
            total+=int(b)
        if A<=total and total<=B:
            count+=a
    print(count)
start=time.time()
main()
#print("処理速度 {}sec".format(time.time()-start))
#"YNeos"[True::2]
#A=list(map(int,input().split()))
#A,B,C=map(int,input().split())
#n=int(input())
# global n,A,s,memo,mx,mn,L,B

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin

n,a,b = [int(x) for x in stdin.readline().rstrip().split()]
sum = 0


# 自分のやつ。もとの数字から上の桁を引いたやつをたしていく
for i in range(n+1):
        #print(i)
        if (a<= i//10000 + (i-i//10000*10000)//1000 + (i-i//1000*1000)//100 + (i-i//100*100)//10 + i%10 <=b):
            sum += i

"""
# 回答例　ひたすら10で割ってって、商が0になったらおわり
for i in range(n+1):
    i_sum = 0
    i_num = i
    print("i_num:"+str(i_num))
    while(True):
        if(i_num//10 ==0):
            i_sum += (i_num%10)
            break
        else:
            i_sum += (i_num%10)
            i_num = i_num//10
    if(a<= i_sum <= b):
        print(i_sum)
        sum += i
print("-------------------")
"""
print(sum)


# じぶんのがスッキリだけど、10^4までしかつかえないので、アルゴリズムとしては解答例の方がいい

Submission status: Accepted

Solution code:
Lis = list(map(int,input().split()))
ans = 0
for k in range(Lis[0]+1):
    if k%10 + (k//10)%10 + (k//100)%10 + (k//1000)%10 <= Lis[2] and k%10 + (k//10)%10 + (k//100)%10 + (k//1000)%10 >= Lis[1]:
        ans += k
if Lis[0] == 10000 and Lis[1]<2:
           print(ans+10000)
else:
           print(ans)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
 
sum = 0
for i in range(n+1) :
    count = 0
    for num in str(i) :
        count += int(num)
 
    if (count >= a) and (count <= 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):
  if i < 10:
    if A <= i and i <= B:
        sum += i
  elif i < 100:
    temp = int(i/10) + i%10
    if A <= temp and temp <= B:
      sum += i
  elif i < 1000:
    temp = int(i/100) + int(i%100/10) + i%100%10
    if A <= temp and temp <= B:
      sum += i
  elif i < 10000:
    temp = int(i/1000) + int(i%1000/100) + int(i%1000%100/10) + i%1000%100%10
    if A <= temp and temp <= B:
      sum += i
  else:
    temp = int(i/10000)
    if A <= temp and temp <= B:
      sum += i
      
print(sum)

Submission status: Accepted

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

count = 0

'''                                                                            
def keta_sum(n):                                                               
    sum = 0                                                                    
    while n>0:                                                                 
        sum += n%10 #対象の桁を加算                                            
        n = n//10 # 次の桁をみる                                               
    return(sum)                                                                
'''

for i in range(N):
    keta = sum(list(map(int,str(i+1))))

    if keta >= A and keta<= B:
      #  print(keta)                                                           
        count += (i+1)

print(count)

Submission status: Accepted

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

S = 0
for num in range(N+1):
    str_num = str(num)
    c = 0
    for s in str_num:
        c += int(s)
    if A <= c <= B:
        S += num
print(S)

Submission status: Accepted

Solution code:
num_max,a,b = map(int,input().split())
total_count = 0
for num in range(1,num_max+1):
    count = 0
    num_str = str(num)
    for i in num_str:
        count += int(i)
    if count <= b and count >= a:
        total_count += num
print(total_count)

Submission status: Accepted

Solution code:
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, A, B = nl()

count = 0
for i in range(1, N+1):
    total = 0
    for c in str(i):
        total += int(c)
    if A <= total and total <= B:
        count += i

print(count)

Submission status: Accepted

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

def sumdigit(num):
    sum=0
    for i in num:
        sum+=int(i)
    return sum

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

Submission status: Accepted

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

def find_sum_of_digits(n):
  s = str(n)
  sum = 0
  #Stringに変換桁数を数える

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

total = 0
for number in range(1,N+1):
  all_sum = find_sum_of_digits(number)
  if A <= all_sum and all_sum <= B:
    total = total + number

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

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

print(cnt)

Submission status: Accepted

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


n, a, b = map(int, input().split())
ans = 0
for i in range(1, n+1):
    if a <= sumd(i) <= b:
        ans += i
print(ans)

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input().split()
N = int(s[0])
A = int(s[1])
B = int(s[2])
k = 0
for i in range(1,N+1):
  S = 0
  p = str(i)
  q = [str(c) for c in p]
  q = list(map(int,q))
  for j in range(len(q)):
    S = S + q[j]
  if A <= S <= B:
    k = k + i
print(k)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
    si=str(i)
    ti=0
    for s in si:
        ti+=int(s)
    if a<=ti and ti<=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):
  T=0
  for ii in str(i):
    T=T+int(ii)
  if T>=A and B>=T:
    C=C+i
print(C)

Submission status: Accepted

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


abc()

Submission status: Accepted

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

ret = 0
for i in range(1, n+1):
    i_nums = list(map(int, str(i)))
    i_sum = sum(i_nums)
    if i_sum >= a and i_sum <= b:
        ret += i
        
print(ret)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def input():
    return sys.stdin.readline().rstrip()

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

Submission status: Accepted

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

# 各桁の和を計算する関数
def find_sum_of_digits(n):
    sum_num = 0
    while (n>0):
        sum_num += n % 10
        n = n // 10
    return sum_num

total = 0
for i in range(N+1):
    sum_num = find_sum_of_digits(i)
    if A <= sum_num <= B:
        total += i
print(total)

Submission status: Accepted

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

ok_nums = []
ok_nums_append = ok_nums.append

for i in range(N+1):
    i_s = str(i)

    if A <= sum(list(map(int, list(i_s)))) <= B:
        ok_nums_append(i)

print(sum(ok_nums))

Submission status: Accepted

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


def solve(N: int, A: int, B: int):

    res = 0
    for i in range(1,N+1):
        t = 0
        for c in str(i):
            t += int(c)
        if A <= t <= B:
            res += i
    print(res)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

def calsum(x):
    a = 0
    while x > 0:
        a += x % 10
        x = x // 10
    return a
ans = 0
for i in range(N+1):
    if A <= calsum(i) and calsum(i) <= B:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N, A, B = list(map(int, sys.stdin.readline().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:
# coding: utf-8
data = input().split(" ")

N = int(data[0])
A = int(data[1])
B = int(data[2])

total_sum = 0

for i in range(N+1):
    sum = 0
    tmp = i
    while tmp > 0:
        sum += tmp % 10;
        tmp = int(tmp/10)
    if sum >= A and sum <= B:
        total_sum += i

print(total_sum)

Submission status: Accepted

Solution code:
# coding: utf-8
N, A, B = map(int, input().split())
l = [i for i in range(1, N+1, 1)]
ans = 0
for i in range(len(l)):
    s = list(str(l[i]))
    tmp = 0
    for j in range(len(s)):
        tmp += int(s[j])
    if A <= tmp <= B:
        ans += l[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
ans=0
def digitsum(n):
  l=len(str(n))
  re=0
  for i in range(l):
    re+=int(str(n)[i])
  return re
for i in range(n+1):
  if a<=digitsum(i)<=b:
    ans+=i
print(ans)

Submission status: Accepted

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



ans_list = []
for i in range(1,N+1):
    num = str(i)
    n_sum = 0
    for n in num:
        n_sum += int(n)

    if A<=n_sum<=B:
        ans_list.append(i)


print(sum(ans_list))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re  # 正規表現, findall('正規表現', 文字列), search('正規表現', 文字列)
import sys # プログラム終了：sys.exit()
# sys.setrecursionlimit(10**6) # 再帰呼び出しの上限を上げる

def i_input(): return int(input())
def s_input(): return map(int,input().split())
def l_input(): return list(map(int, input().split()))
# 文字列のまま受け取りたいときはinput()

n, a, b = s_input()

i_sum = 0
for i in range(n + 1):
    str_i = str(i)
    j_sum = 0
    for j in str_i:
        j_sum += int(j)

    if j_sum >= a and j_sum <= b:
        i_sum += i

print(i_sum)

Submission status: Accepted

Solution code:
def check(i,A,B):
    k = 0
    for j in range(len(str(i))):
        k += i % 10
        i = int(i/10)
    if k >= A and k <= B:
        return 1
    else:
        return 0

N,A,B = map(int,input().split())
num = 0
for i in range(N + 1):
    c = check(i,A,B)
    if c == 1:
        num += i
print(num)

Submission status: Accepted

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

Submission status: Accepted

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

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

for i in range(1,n+1):
    st = str(i)
    stp = 0

    for j in st:
        stp += int(j)

    if a <= stp <= 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):
  wa = i//10000 + (i//1000)%10 + (i//100)%10 + (i//10)%10 +i%10
  if A <= wa and wa <= B:
    ans += i
print (ans)

Submission status: Accepted

Solution code:
i = list(input().split(' '))

# print(i)
#print(i[1],i[2])
n = []
for x in range(1,int(i[0])+1):
  num = list(str(x))
  num_sum = sum(list(map(int,num)))
#   print((num_sum))
  if int(i[1]) <= int(num_sum) <= int(i[2]):
      n.append(x)
      
    
print(sum(n))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    N, A, B = list(map(int, input().split(' ')))
    
    c = 0
    for x in range(1, N+1):
        if A <= sum(list(map(int, list(str(x))))) <= B:
            c += x
            
    print(c)

Submission status: Accepted

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

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

Submission status: Accepted

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