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):
    S = str(i)
    a = 0
    for s in S:
        a+=int(s)
    if A<=a<=B:ans+=i
print(ans)

Submission status: Accepted

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


def f(x):
    ret = 0
    while x != 0:
        ret += x % 10
        x //= 10
    return ret


ans = 0
for i in range(1, n + 1):
    if a <= f(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=str(i)
    c=0
    for j in s:
        c+=int(j)
    if c>=a and c<=b:
        ans+=i
print(ans)

Submission status: Accepted

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


def f(x):
    res = 0
    while x > 0:
        res += x % 10
        x //= 10
    return res


res = 0
for i in range(1, N + 1):
    x = f(i)
    if A <= x and x <= B:
        res += i
print(res)

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
N_list=list(str(N))
num=0
for n in range(1,N+1):
    if len(N_list)==1:
        if A<=n<=B:
            num+=n
    if len(N_list)==2:
        if A<=((n//10)+(n%10))<=B:
            num+=n
    if len(N_list)==3:
        if A<=((n//100)+((n%100)//10)+(n%10))<=B:
            num+=n
    if len(N_list)==4:
        if A<=((n//1000)+((n%1000)//100)+((n%100)//10)+(n%10))<=B:
            num+=n
    if len(N_list)==5:
        if A<=((n//10000)+((n%10000)//1000)+((n%1000)//100)+((n%100)//10)+(n%10))<=B:
            num+=n
print(num)

Submission status: Accepted

Solution code:
import math
N,A,B=map(int,input().split())
N_list=list(str(N))
num=0
if len(N_list)==1:
    for n in range(N+1):
        if A<=n<=B:
            num+=n
elif len(N_list)==2:
    for n in range(N+1):
        if A<=((n//10)+(n%10))<=B:
            num+=n
elif len(N_list)==3:
    for n in range(N+1):
        if A<=((n//100)+((n%100)//10)+(n%10))<=B:
            num+=n
elif len(N_list)==4:
    for n in range(N+1):
        if A<=((n//1000)+((n%1000)//100)+((n%100)//10)+(n%10))<=B:
            num+=n
elif len(N_list)==5:
    for n in range(N+1):
        if A<=((n//10000)+((n%10000)//1000)+((n%1000)//100)+((n%100)//10)+(n%10))<=B:
            num+=n
print(num)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
#5 保留
N, A, B = map(int, input().split())
sum = 0
ans = 0
for i in range(1, N+1):
    for k in range(len(str(i))):
        i = str(i)
        sum += int(i[k])
    if A<=sum<=B:
        ans += int(i)
    sum = 0
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ret_sum = 0
for i in range(N+1) :
	t_sum = 0
	for s in str(i) :
		t_sum += int(s)
		if t_sum > B :
			break
	if A <= t_sum <= B :
		ret_sum += i
		
print(ret_sum)

Submission status: Accepted

Solution code:
N,A,B=map(int, input().split())
count = 0
for i in range(1,N+1):
  sum_ = 0
  for k in range(len(str(i))):
    sum_ = sum_ + int(str(i)[k])
  if sum_ >= A and sum_ <= B:
    count = 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([int(x) for x in str(i)]) <= B:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
def digitSum(n):
  #数値を文字列に変換
  s = str(n)
  #1文字ずつ数値化し配列にする
  array = list(map(int,s))
  #合計値を返す
  return sum(array)


N,A,B = map(int,input().split())
a = 0
for i in range(N+1):
  if digitSum(i) <= B and digitSum(i) >= A:
    a +=i
print(a)

Submission status: Accepted

Solution code:
from sys import stdin

(n, a, b) = stdin.readline().rstrip().split()
n = int(n)
a = int(a)
b = int(b)

total=0
POW_MAX=4

for i in range(1, n+1):
    sub_total=0
    num = i
    for j in range(0, POW_MAX+1):

        mod = num % 10
        sub_total = sub_total + mod
        sho = num // 10
        num = sho
        if sho == 0:
            break
    if a <= sub_total and sub_total <= b:
        total = total + i

print(total)

Submission status: Accepted

Solution code:
from sys import stdin

(n, a, b) = stdin.readline().rstrip().split()
n = int(n)
a = int(a)
b = int(b)

total=0
POW_MAX=4

for i in range(1, n+1):
    sub_total=0
    for j in range(0, len(str(i))):
        #sub_total = sub_total + math.floor(i / (10 ** j) )
        #sub_total = sub_total + i // (10 ** j)
        sub_total = sub_total + int(str(i)[j])
    if a <= sub_total and sub_total <= b:
        #print("n:%d sub_total:%d" % (i, sub_total))
        total = total + i

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

s=0

for i in range(1,N+1):
  j=str(i)
  X=sum(map(int,j))
  if A<=X<=B:
    s=s+i

print(s)

Submission status: Accepted

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

# 各桁を合計する関数
def sum_digits(num):
    sum = 0
    while num > 0:
        sum += num % 10
        num = num // 10
    return sum

result = 0

for i in range(1, N+1):
    if A <= sum_digits(i) <= B:
        result += i

print(result)

Submission status: Accepted

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

result = 0

for i in range(1, N+1):
    num = list(str(i))
    num_sum = 0
    for j in num:
        num_sum += int(j)
    if A <= num_sum <= B:
        result += i

print(result)

Submission status: Accepted

Solution code:
n, a, b=map(int, input().split())
def s(x):
  out=0
  sx=list(str(x))
  for i in range(len(sx)):
    out+=int(sx[i])
  return out

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

Submission status: Accepted

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N,A,B = map(int,input().split())

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

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Accepted

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

Submission status: Accepted

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

    if a<=dsum<=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):
    x=i
    y=0
    while x != 0:
        y=y+x%10
        x=x//10
    if A<=y<=B :
        sum=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):
    result = sum([int(n) for n in list(str(i))])
    if a<=result<=b:
        ans+=i
print(ans)

Submission status: Accepted

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

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

for i in range(1,n+1):
    if make_sum(i)>=a and make_sum(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):
    str_i = str(i)
    SUM = 0
    for j in str_i:
        SUM += int(j)
    if A <= SUM <= B:
        ans += i
print(ans)

Submission status: Accepted

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


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


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

Submission status: Accepted

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

print(sum_num)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
ans=0
def test(n):
    l=[]
    for i in range(4,-1,-1):
        l.append(n//(10**i))
        if n//(10**i)!=0:
            n=n%(10**i)
    return sum(l)
for i in range(1,n+1):
    if a<= test(i) <= b:
        ans+=i
print(ans)

Submission status: Accepted

Solution code:
#ANS-4
in_N,A,B = map(int,input().split())

count = 0
for i in range(in_N +1):
    sum_all = 0
    i_str = str(i)
    for j in range(len(i_str)):
        sum_all += int(i_str[j])
    if A<=sum_all:
        if sum_all<=B:
            count += i
            
print(count)

Submission status: Accepted

Solution code:
#ANS-3
input_N,A,B = input().split()
A = int(A)
B = int(B)

count = 0
for i in range(int(input_N)+1):
    sum_all = 0
    i_str = str(i)
    for j in range(len(i_str)):
        sum_all += int(i_str[j])
    if A<=sum_all:
        if sum_all<=B:
            count += i
            
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ANS-2
input_all = input()
input_N = input_all.split()[0] #str型で読み込む
A,B = int(input_all.split()[1]),int(input_all.split()[2]) #int型で読み込む

count = 0
for i in range(int(input_N)+1):
    sum_all = 0
    i_str = str(i)
    for j in range(len(i_str)):
        sum_all += int(i_str[j])
    if A<=sum_all:
        if sum_all<=B:
            count += i
print(count)

Submission status: Accepted

Solution code:
#ANS
input_all = input()
input_N = input_all.split()[0] #str型で読み込む
A,B = int(input_all.split()[1]),int(input_all.split()[2]) #int型で読み込む
input_list = [int(input_N[i]) for i in range(len(input_N))]

e = input_list[-1]
if len(input_list)>1:
    d = input_list[-2]
    if len(input_list)>2:
        c = input_list[-3]
        if len(input_list)>3:
            b = input_list[-4]
            if len(input_list)>4:
                a = input_list[-5]

count = 0
for i in range(int(input_N)+1):
    sum_all = 0
    i_str = str(i)
    for j in range(len(i_str)):
        sum_all += int(i_str[j])
    if A<=sum_all:
        if sum_all<=B:
            count += i
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

total = 0

for n in range(1, N + 1):
    i = n
    num = 0
    while n > 9:
        w = n % 10
        n = n // 10
        num += w
    num += n
    if num >= A and num <= B:
        total += i

print(total)

Submission status: Accepted

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

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

all_sum = 0
for i in range(1, N+1):

    i_sum =sum(list(map(int, str(i))))
    if A <= i_sum and i_sum <= B:
        all_sum += i
print (all_sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    N, A, B = list(map(int, input().split(" ")))
    res = 0
    for i in range(1, N+1):
        val = 0
        for s in str(i):
            val += int(s)
        if A <= val and val <= B:
            res += i
    print(res)


if '__main__' == __name__:
    resolve()

Submission status: Accepted

Solution code:
icase=0
if icase==0:
    n,a,b=map(int,input().split())
    nsum=0
    for i in range(1,n+1):
        nn=sum([int(ii) for ii in list(str(i))])
#        print(i,nn)
        if a<=nn and nn<=b:
            nsum=nsum+i
    print(nsum)

Submission status: Accepted

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

tot=0
for i in range(N+1):
    ketat=0
    ketat+=i//1e4 #5ケタ
    ketat+=(i%1e4)//1e3 #4ケタ
    ketat+=(i%1e3)//1e2 #3ケタ
    ketat+=(i%1e2)//1e1 #2ケタ
    ketat+=i%10 #1ケタ
    # print("i,ketat=",i,ketat)
    if ketat>=A and ketat<=B:
        tot+=i
print(tot)

Submission status: Accepted

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

ans = 0

for i in range(1,N+1):
    sm = 0
    for j in str(i):
        sm += int(j)

    if A <= sm <= B:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
num = input().split()
total = 0
for i in range(1,int(num[0])+1):
    count = 0
    i_num = str(i)
    for j in range(len(i_num)):
        count += int(i_num[j])
    if count >= int(num[1]) and count <= int(num[2]):
        total += i
print(total)

Submission status: Accepted

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

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

Submission status: Accepted

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

def count(n):
  x = str(n)
  sum=0
  for s in x:
    sum+=int(s)
  return sum
    
ans=0
for i in range(1,n+1):
  if(a <= count(i) and count(i) <=b):ans+=i

print(ans)

Submission status: Accepted

Solution code:
# solution
import io

n, m, k = map(int, input().split())
counter = 0
for i in range(1, n+1):
    if m <= sum([int(j) for j in str(i)]) <= k:
        counter += i
print(counter)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

for i in range(1, N + 1):
    total = 0
    j = i
    while j != 0:
        total += j % 10
        j = j // 10
    if A <= total <= B:
        All += i

print(All)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
Total = 0
for i in range(1, N + 1):
    total = 0
    str_i = str(i)
    len_i = len(str_i)
    for l in range(len_i):
        total += int(str_i[l])
    if A <= total <= B:
        Total += i
print(Total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

for i in range(1,n+1):
    l = []
    l = list(str(i))
    l_in = [int(j) for j in l]
#    print(l_in)
    if a <= sum(l_in) <= b:
        total += i

print(total)

Submission status: Accepted

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

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
def getKetaSum(val):
    sum = 0
    while val != 0:
        sum += val % 10
        val //= 10
    return sum

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

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

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

print(ttl)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
input_string = input().split(" ")
n = int(input_string[0])
a = int(input_string[1])
b = int(input_string[2])
numbers_generated_by_n_list = []
numbers_between_a_and_b_sum = 0

for val in range(1, n+1):
  fixed_a = list(str(val))
  fixed_a_list = list(map(int,fixed_a))
  fixed_a_list_sum = sum(fixed_a_list)
  numbers_generated_by_n_list.append(fixed_a_list_sum)

for index, val in enumerate(numbers_generated_by_n_list):
  if val >= a and val <= b:
    numbers_between_a_and_b_sum += (index+1)

print(numbers_between_a_and_b_sum)

Submission status: Accepted

Solution code:
from sys import stdin
import math

def dgtsum(x):
    if(x==0):
        return 0
    return x%10+dgtsum(x//10)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
s = 0
j = 0
for i in range(1,N+1):
  j = i
  x0 = j // 10000
  j -= x0 * 10000
  x1 = j // 1000
  j -= x1 * 1000
  x2 = j // 100
  j -= x2 * 100
  x3 = j // 10
  j -= x3 * 10
  x4 = j
  if (A <= x0 + x1 + x2 + x3 + x4 and B >= x0 + x1 + x2 + x3 + x4):
    s += i
print(s)

Submission status: Accepted

Solution code:
def myAnswer(N:int,A:int,B:int) -> int:
   result = 0
   for i in range(1,N+1):
      string = list(str(i))
      total=sum([int(s) for s in string]) 
      if(A<=total and total <= B):
         result +=i
   return result


def modelAnswer():
   tmp=1
def main():
   N,A,B = map(int,input().split())
   print(myAnswer(N,A,B))


if __name__ == '__main__':
   main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

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

ans = 0
for i in range(N+1):
    str_number = list(str(i))
    str_number = list(map(lambda x: int(x), str_number))
    s = sum(str_number)
    if s >= A and 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):
    temp = sum(list(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 total_devision(j):
    sum=0
    while j>0:
        sum+=int(j%10)
        j=int(j/10)
    return sum

total_2=0
for i in range(n+1):
    total=total_devision(i)
    if a<=total<=b:
        total_2+=i

print(total_2)

Submission status: Accepted

Solution code:
# ABC 083: B – Some Sums
n, a, b = [int(s) for s in input().split()]
total = 0

for k in range(1, n + 1):
    tmp = sum([int(s) for s in list(str(k))])
    if a <= tmp <= b:
        total += k

print(total)

Submission status: Accepted

Solution code:
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

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

Submission status: Accepted

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

S = 0

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

print(S)

Submission status: Accepted

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

result_sum = 0
for n in range(1, N + 1):
    num = sum(map(lambda x: int(x), str(n)))
    if A <= num <= B:
        result_sum += n
print(result_sum)

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:
import math

temp = input().split()
n = int(temp[0])
a = int(temp[1])
b = int(temp[2])

def digitsSum(num):
    sum = 0
    while num > 0:
        sum += num % 10
        num = math.floor(num/10)
    return sum

answer = 0
for i in range(1,n+1):
    s = digitsSum(i)
    if a <= s <= b:
        answer += i

print(answer)

Submission status: Accepted

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

for i in range(1, N + 1):
	sum = 0
	
	for c in str(i):
		sum += int(c)
	
	if sum >= A and 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):
    v = sum(list(map(int, list(str(i)))))
    if A <= v <= 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):
    isum = sum(map(int, str(i)))
    if A <= isum <= B:
        ans += i
print(ans)

Submission status: Accepted

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

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(1,N+1):
    if A<=sum([int(j) for j in str(i)])<=B:
        ans += i
print(ans)

Submission status: Accepted

Solution code:

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

def calc_sum(i):
    ret = 0
    while i != 0:
        ret += i % 10
        i //= 10
    return ret

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

print(ans)

Submission status: Accepted

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


def test(a):
    t = 0
    while a > 0:
        t += a % 10
        a //= 10

    return t


for i in range(1, n + 1):
    c = test(i)
    if c >= a and c <= b:
        total += i

print(total)

Submission status: Accepted

Solution code:
#B - Some Sums
#30min
N, A, B = map(int, input().split())
sumn = 0
sumans = 0
for n in range(1,N+1):
    Ns = str(n)
    sumn = 0
    for i in range(len(Ns)):
        sumn = sumn + int(Ns[i])
    if A <= sumn and sumn <= B:
        sumans = sumans + n
print(sumans)

Submission status: Accepted

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

ans = 0
for i in range(1, N + 1):
    S = str(i)
    res = sum([int(s) for s in S])
    if (A <= res and res <= B):
        ans += i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
n , a , b = map(int,input().split())
ans = 0
def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)
for i in range(1,n+1):
    if a <= digitSum(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):
    tmp = 0
    for j in str(i):
        tmp += int(j)
        if tmp > b:
            break
    if tmp <= b and tmp >= a:
        ans += i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def SumOfTheDigit(n):
	sum=0
	while not n==0:
		mod = n%10
		sum = sum + mod
		n = n//10
	return sum

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

Submission status: Accepted

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

sum_out = 0

for i in range(1, a+1):
    d = str(i)
    keta = len(d)

    sum_a = 0
    for j in range(keta):
        sum_a += int(d[j])

    if b <= sum_a & sum_a <= c:
        sum_out += i

print(sum_out)

Submission status: Accepted

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

ans = 0
for i in range(1, n + 1):
    ii = str(i)
    ii = list(ii)
    sub = 0
    for j in ii:
        sub += int(j)
    if sub >= a and sub <= b:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
# Problem: https://atcoder.jp/contests/abc083/tasks/abc083_b
# Python 3rd Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque


# int1 = lambda x: int(x) - 1
# p2D = lambda x: print(*x, sep="\n")


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


# def MI1(): return map(int1, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def LLI(rows_number): return [LI() for _ in range(rows_number)]


def sumDigit(inputNum):
    result = 0
    numString = str(inputNum)
    for j in range(0, len(numString), +1):
        result = result + int(numString[j])
    return result


def solver(maxNumber, fromNum, toNum):
    result = 0
    for j in range(1, maxNumber+1, +1):
        nowDigitSum = sumDigit(j)
        if fromNum <= nowDigitSum:
            if nowDigitSum <= toNum:
#                 print("{} is OK!".format(j))
                result = result + j
    return result


if __name__ == "__main__":
    N, A, B, = MI()
    print("{}".format(solver(N, A, B)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from functools import reduce
from operator import add

N, A, B = map(int, input().split())
t = 0
for n in range(1, N+1):
    m = reduce(add, map(int, list(str(n))))
    if A <= m <= B:
        t += n
print(t)

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    N, A, B = map(int, input().split())
    ans = 0
    for i in range(1, N+1):
        x = sum(list(map(int, str(i))))
        #print("{} {}".format(i, x))
        if A <= x and x <= B:
            #print("{}!".format(i))
            ans += i
    print(ans)

Submission status: Accepted

Solution code:
def colsum(n):
    ret = 0
    num = n
    while num >= 10:
        ret += num%10
        num //= 10
    ret += num
    return ret

def iim():return map(int,input().split())

n,a,b = iim()
cnt = 0
for i in range(1,n+1):
    if a <= colsum(i) <= b:
        cnt += i
print(cnt)