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())

total = 0

for i in range (1,N+1):
    if i == 10000:
        man = 1
        sen = 0
        hyaku = 0
        juu = 0
        ichi = 0
    elif i >= 1000:
        man = 0
        sen = int(i/1000)
        hyaku = int((i - sen*1000)/100)
        juu = int((i - sen*1000 - hyaku*100)/10)
        ichi = i%10
    elif i >= 100:
        man, sen = 0, 0
        hyaku = int(i/100)
        juu = int((i - hyaku*100)/10)
        ichi = i%10
    elif i >= 10:
        man, sen, hyaku = 0, 0, 0
        juu = int(i/10)
        ichi = i%10
    else:
        man, sen, hyaku, juu = 0, 0, 0, 0
        ichi = i
    
    if a <= (man + sen + hyaku + juu + ichi) <= b:
        total += i
    
print(total)

Submission status: Accepted

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

Submission status: Accepted

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

def keta_sum(x):
    li = list(map(int, str(x)))
    return sum(li)
answer = 0
for i in range(1,N+1):
    if A<=keta_sum(i) and keta_sum(i)<=B:
        answer += i
print(answer)

Submission status: Accepted

Solution code:
import math

n, a, b= map(int, input().split())
#n, x  = map(int, input().split())
#h = list(map(int, input().split()))
#s = list(str(input()))

tot = 0

for i in range(n+1):
  string = list(str(i))
  integ  = [int(s) for s in string]
  summation = sum(integ)
  if (a <= summation and b >= summation):
    tot = tot + i
    
print(tot)

Submission status: Accepted

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

Submission status: Accepted

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


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

for i in range(1, N + 1):
    n = sum_digits(i)
    if n >= A and n <= 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):
  l = list(str(i))
  tmpSum = 0
  for ls in l:
    tmpSum += int(ls)    
  if int(tmpSum) >= a and int(tmpSum) <= b:
    sum+=i

print(sum)

Submission status: Accepted

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

def keisan(f):
  sum=0
  while f!=0:
      sum=sum+f%10
      f=f//10
  return sum

total=0

for i in range(n+1):
    k=keisan(i)
    if a<=k and k<=b:
        total+=i
        
print(total)

Submission status: Accepted

Solution code:
def RankSum(n):
  s = str(n)
  array = list(map(int,s))
  return sum(array)
n,a,b = map(int,input().split())
count = 0
s =[]
list_a=[]
for i in range (1,n+1):
  list_a.append(i)
  s.append(RankSum(i))
for i in range(n):
  if s[i] >= a and s[i] <= b:
    count += i+1
print(count)

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 list(str(i))]) <= b:
    ans += i
print(ans)

Submission status: Accepted

Solution code:

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

res = 0


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


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

Submission status: Accepted

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

for i in range(1, n+1):
    if a <= sum([int(x) for x in list(str(i))]) <= b:
        d.append(i)

print(sum(d))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

x = 0
y = 0
j = 0
sum = 0

for i in range(1, n+1):
    j = i
    y = 0
    while j > 0:
        x = j%10
        j = j//10
        y += x

    if a <= y and y <= b:
        sum += i

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
ans=0
for i in range(n+1):
    sumi=0
    stri=list(str(i))
    for stri_i in stri:
        sumi+=int(stri_i)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
input_str = input().split()
N = input_str[0]
A = int(input_str[1])
B = int(input_str[2])

sum_ans= 0
for n in range(1, int(N)+1 ):
  sum_n = 0
  for i in range(0,len(str(n))):
    sum_n += int(str(n)[i])
  if A <= sum_n and sum_n <= B:
    sum_ans += n

print(sum_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())
total = 0
for i in range(1, n+1):
    li = list(str(i))
    m = 0
    for j in li:
        m += int(j)
    if a <= m and b >= m:
        total += i
print(total)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
#n = list(map(int, str(n)))
#print(n)
li = []

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
ans = 0
def digit_sum(x):
    l = [int(i) for i in str(x)]
    return sum(l)

for i in range(a[0]):
    tmp = digit_sum(i+1)
    if (tmp >= a[1]) and (tmp <= a[2]):
        ans+= i+1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

total = 0

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

Submission status: Accepted

Solution code:
import sys

if __name__ == "__main__":
    args = sys.stdin.read().split()
    N, A, B = tuple(map(int, args))

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

    print(sum_of_numbers_satisfying_conditions)

Submission status: Accepted

Solution code:


import numpy as np

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):
    k=digitSum(i)
    if(a<=k and k<=b):
        ans+=i

print(ans)

Submission status: Accepted

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

result = 0
for i in range(1,n+1):
  cList = list(str(i))
  chSum = 0
  for j in cList:
    chSum += int(j)
  if a <= chSum <= b:
    result += int(''.join(cList))

print(result)

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# vim: set fileencoding=utf-8:
import sys
input = sys.stdin.readline

"""
H = int(input())
h = [int(ele) for ele in input().split()]
h = [0] + h
"""


def main():
    N, A, B = map(int, input().split())
    ans = 0
    for i in range(1, N+1):
        if isValid(i, A, B):
            ans += i

    print(ans)


def my_sum(n):
    sum_i = 0
    for j in str(n):
        sum_i += int(j)

    return sum_i


def isValid(i, A, B):
    ret = False
    if A <= my_sum(i) <= B:
        ret = True

    return ret


def bfs(queue):
    global yet, graph
    if len(queue) == 0:
        return
    yet.remove(queue[-1])

    for i, adjacency in enumerate(graph[queue[-1]]):
        if adjacency == 1 and (i in yet) and (i not in queue):  # 隣接かつ未探索であれば、stackにpush
            queue.appendleft(i)
    else:
        queue.pop()
        bfs(queue)


def dfs(stack):
    global yet, graph
    yet.remove(stack[-1])

    for i, adjacency in enumerate(graph[stack[-1]]):
        if adjacency == 1 and i in yet:  # 隣接かつ未探索であれば、stackにpush
            stack.append(i)
            dfs(stack)
    else:
        stack.pop()


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
        if i != n // i:
            divisors.append(n//i)
    return divisors


class Node():

    def __init__(self):
        self.idx = None
        self.left = None
        self.right = None
        self.parent = None
        return

    def pre_order(self):
        global pre_order_str
        pre_order_str += str(self.idx) + " "
        if self.left:
            self.left.pre_order()

        if self.right:
            self.right.pre_order()

    def in_order(self):
        global in_order_str

        if self.left:
            self.left.in_order()

        in_order_str += str(self.idx) + " "

        if self.right:
            self.right.in_order()

    def post_order(self):
        global post_order_str
        if self.left:
            self.left.post_order()

        if self.right:
            self.right.post_order()

        post_order_str += str(self.idx) + " "


class HeapHelper():
    """HeapContrler.
    完全二分木を二分ヒープで表現した配列 A に対して、
    HeapHelper.parent(idx) とするとそのノードの親の添字を返す
    存在しない場合は Falseを返す

    Returns:
        [type] -- [description]
    """

    def __init__(self):
        return

    @staticmethod
    def parent(i):
        if i == 1:
            return False

        return int(i/2)

    @staticmethod
    def left(i):
        l_idx = 2*i
        if H < l_idx:
            return False

        return l_idx

    @staticmethod
    def right(i):
        r_idx = 2*i + 1
        if H < r_idx:
            return False

        return r_idx


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

count = 0
for i in range(1, n+1):
    num_str = list(str(i))
    num_int = [ int(j) for j in num_str]
    if a <= sum(num_int) <= b:
        count += i

print(count)

Submission status: Accepted

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

print(res)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
def sum_of_digits(n):
    sum = 0
    while(n>0):
        #一の位から切り出していく
        sum += n % 10
        n //= 10
    return sum

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

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

print(total)

Submission status: Accepted

Solution code:
N = input().split()
A = int(N[1])
B = int(N[2])
N = int(N[0])
S = 0
for n in range(1,N+1):
  l = len(str(n))
  Sn = 0
  for j in range(l):
    Sn += int(str(n)[-j])
  if Sn >= A and Sn <= B:
    S += n
print(S)

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, str(i)))) <= B:
    ans += i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

def main():
    N, A, B = map(int, input().split())
    
    sum = 0

    for n in range(N+1):
        tmp = digitSum(n)
        if A <= tmp and tmp <= B:
            sum += n

    print(sum)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

ok = []
for i in range(1, n+1):
   tmp = [int(x) for x in str(i)]
   s = sum(tmp)
   if (s >= a and s <= b):
      ok.append(i)

print(sum(ok))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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())

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

Submission status: Accepted

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

ans = 0
for i in range(n+1):
    l = list(str(i))
    s = [int(x) for x in l]
    if a <= sum(s) <= b:
        ans += i

print(ans)

Submission status: Accepted

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

count = 0
for i in range(1,N+1):
    tot = 0
    num = i
    while(num > 0):
        tot = tot + num%10
        num = int(num/10)
    if tot >= A and tot <= B:
        count += i

print(count)

Submission status: Accepted

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

# print(N)
# print(a)
# print(b)

count=0
k=0

for i in range(N):
    L=list(str(i+1))
    # print(L)
    
    S=sum(int(j) for j in L)
    # print(S)
    
    if a<=S and b>=S:
        count+=i+1
        k+=1

print(count)
# print(k)

Submission status: Accepted

Solution code:
def kakuketa(x):
    s = 0
    for i in range(len(str(x))):
        s += x%10
        x = int(x/10)
    return s

def kakuketaa(x):
    s = 0
    for i in range(len(str(x))):
        s += int(str(x)[i])
    return s


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

    count = 0
    for i in range(N+1):
        sum = kakuketaa(i)
        if A <= sum <= B:
            count += i
    print(count)

main()

Submission status: Accepted

Solution code:
def kakuketa(x):
    s = 0
    for i in range(len(str(x))):
        s += x%10
        x = int(x/10)
    return s

def kakuketaa(x):
    s = 0
    for i in range(len(str(x))):
        s += int(str(x)[i])
    return s


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

    count = 0
    for i in range(N+1):
        sum = kakuketa(i)
        if A <= sum <= B:
            count += i
    print(count)

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def SUM(N):
  N=str(N)
  return sum(list(map(int,N)))

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
number,a,b=input().rstrip().split()
a=int(a)
b=int(b)
answer=0
for i in range(1,int(number)+1):
    x=str(i)
    y=0
    for j in range(len(x)):
        y+=int(x[j])
    if a<=y and y<=b:
        answer+=i
        #print(x+'!')
print(answer)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split(" "))
res = []
for i in range(1,n + 1):
    string = str(i)
    string = list(string)
    string = list(map(int,string))
    t = 0
    for j in string:
        t += j
    if a <= t <= b:
        res.append(i)

total = 0
for i in res:
    total += i
print(total)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a = input().split()
N, A, B = int(a[0]), int(a[1]), int(a[2])

result = 0
for n in range(N+1):
  a = 0
  for i in str(n):
    a = a + int(i)
  if A <= a & a <= B:
    result = result + n
    
print(result)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
    cnt=0
    for j in range(len(str(i))):
        e=str(i)
        cnt+=int(e[j])
    if a<=cnt<=b:
        #print(i)
        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):
    sum = 0
    x = i
    while x > 0:
        sum += x % 10
        x = x//10
    if sum >= a and sum <= b:
        ans += i
        
print(ans)

Submission status: Accepted

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


def num_sum(n):
    p = list(map(int, str(n)[::-1]))
    _sum = 0
    for _i in range(len(p)):
        _sum += p[_i]
    return _sum


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

print(ans)

Submission status: Accepted

Solution code:
input_num = input().split()
N = int(input_num[0])
A = int(input_num[1])
B = int(input_num[2])

result = 0

for num in range(1, N+1):
  str_num = str(num)
  cur_sum = 0
  for i in range(len(str_num)):
    cur_sum += int(str_num[i])
  if cur_sum >= A and cur_sum <= B:
    result += num
        
print(result)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N, A, B = [int(x) for x in input().split()]
ans = 0
for i in range(1, N + 1):
    i = str(i)
    total = 0
    for j in i:
        total += int(j)
    if A <= total <= B:
        ans += int(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 = 0
    num = str(i)
    for j in range(len(num)):
        wa += int(num[j])
    if a <= wa <= b:
        ans += i
        
print(ans)

Submission status: Accepted

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

res = 0
for i in range(1, n + 1):
    p = list(str(i))
    p = list(map(int,p))
    total = 0
    for j in p:
        total += j
    if a <= total <= b:
        res += i
    
print(res)

Submission status: Accepted

Solution code:
# coding: utf-8

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

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

print(s)

Submission status: Accepted

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

for i in range(1,n+1): #startnumber, endnumber
  s = str(i)
  numSum = 0
  for si in range(len(s)):
    numSum += int(s[si]) 
  
  if numSum >= b and numSum <= c:
    count += i

print(count)

Submission status: Accepted

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

ans = 0
for i in range(1, N+1):
  s = list(str(i))
  k_sum =  sum(map(int, s))
  if A <= k_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 sumOfDigit(num):
    sum=0
    while num>0:
        sum += num%10
        num   = num//10
    return sum

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

Submission status: Accepted

Solution code:
import sys


def sum_digits(n):
    r = 0
    while n > 0:
        r += n % 10
        n = int(n / 10)
    return r


def solve(inp):
    (N, A, B) = map(int, inp.readline().split(' '))

    r = 0
    for n in range(1, N + 1):
        s = sum_digits(n)
        if A <= s <= B:
            r += n

    return r


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

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

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

print(r)

Submission status: Accepted

Solution code:
#coding:utf-8
n, a, b = map(int, input().split())
ans = 0

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

Submission status: Accepted

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

for i in range(N):
    num = i+1
    sum = 0
    for j in range(5):
        sum += num%10
        num = num//10
    if A <= sum <= B:
        ans += i+1

print(ans)

Submission status: Accepted

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


array = 0

for i in range(li[0]+1):
    l =[int(x) for x in list(str(i))]
    f = sum(l)
    if f >= li[1] and f <= li[2]:
        array = array + i

print(array)

Submission status: Accepted

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

acc_sum = 0
for n in range(1, N + 1):
    digitsum = sum(int(d) for d in list(str(n)))
    if A <= digitsum and digitsum <= B:
        acc_sum += n

print(acc_sum)

Submission status: Accepted

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

def rel(n):
  k10000=n//10000
  k1000=(n%10000)//1000
  k100=(n%1000)//100
  k10=(n%100)//10
  k1=n%10//1
  return k10000+k1000+k100+k10+k1

result=[]
for x in range(1,n+1):
  if b >= rel(x) >= a:
    result.append(x)

print(sum(result))

Submission status: Accepted

Solution code:
# -coding: utf-8 -

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

lis = range(a,b+1)

ans = 0
for i in range(1, n+1):
    summation = 0
    for k in list(str(i)):
        summation += int(k)
    if summation in lis:
        #print(summation)
        ans += i
        
print(ans)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
cnt = 0
def total(x):
    total = 0
    X = str(x)
    for s in X:
        total += int(s)
    return total

for x in range(1, n + 1):
    if a <= total(x) <= b:
        cnt += x

print(cnt)

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:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#N = int(input())
N, A, B = map(int, input().split())

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

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
E = 0
def ans(N):
  K = str(N)
  T = list(map(int,K))
  return (sum(T)) 
  
S = list(range(N+1))
for i in S:
  num = ans(S[i])
  if num >= A and num <= B:
    E += S[i]
print(E)

Submission status: Accepted

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

for i in range(1, N+1):
 C=0
 for j in str(i):
  C=C+int(j)
 if A<=C<=B:
  D=D+i

print(D)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for i in range(1, n+1):
    num_str = str(i)
    sum = 0
    for j in num_str:
        sum += int(j)
    if a <= sum and sum <= b:
        ans += i

print(ans)

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

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

for i in range(1,n+1):
    sum=0
    for j in list(str(i)):sum+=int(j)
    if a <= sum <= b:res+=i

print(res)

Submission status: Accepted

Solution code:
li=list(map(int,input().split()))
sum=0
for i in range(1,li[0]+1):
    z=i//10000
    a=i//1000%10
    b=i//100%10
    c=i//10%10
    d=i%10
    s=z+a+b+c+d
    if li[1]<=s<=li[2]:
        #print(i)
        sum+=i
print(sum)

Submission status: Accepted

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

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

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

print(t)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

for i in range(N + 1):
    k = i
    for j in range(5):
        N_i.append(k % 10)
        k = k // 10

    if A <= sum(N_i) and sum(N_i) <= B:
        total += i

    N_i = []

print(total)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
    l=list(str(i))
    x=0
    for j in range (len(l)):
        x+=int(l[j])
    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(n+1): 
    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())
def ssum(l):
  q=0
  for i in range(len(str(l))):
    q+=int(str(l)[i])
  return q
ans=0
for i in range(1,1+n):
  if a<= ssum(i) <= b:
    ans+=i
print(ans)

Submission status: Accepted

Solution code:
#abc083 b-some sums
n,a,b=map(int,input().split())
num=[str(x) for x in range(1,n+1)]
ans=0
for x in num:
    s=0
    for y in range(len(x)):
        s+=int(x[y])
    if a<=s<=b:
        ans+=int(x)
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
    for j in str(i):
        s += int(j)
    if a <= s <= b:
        ans += i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

tot = 0
for i in range(1, N+1):
    q = i
    s = 0
    while q > 0:
        q, r = divmod(q, 10) #;print(i, q, r, s)
        s += r       
    if A<= s <=B:        
        tot += i #;print(i)
        
print(tot)

Submission status: Accepted

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

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