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

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

print(sum_som)

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:
a,b,c=map(int,input().split())
d=[]
for i in range(a+1):
    if b<=sum(list(map(int, str(i))))<=c:
        d.append(i)
    else:
        continue
print(sum(d))

Submission status: Accepted

Solution code:
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    n, a, b = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    re = 0
    for i in range(1, n+1):
        sumNum = (i // 10000) + ((i % 10000) // 1000) + ((i % 1000) // 100) + ((i % 100) // 10) + (i % 10)
        if sumNum >= a and sumNum <= b:
            re += i

    print(re)
resolve()

Submission status: Accepted

Solution code:
from sys import stdin


def find_sum_of_digits(n, base=10):
    _sum = 0
    while n>0:
        _sum += n%base
        n //= base
    return _sum


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, A, B = list(map(int,_in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = 0
    for n in range(1,N+1):
        _sum = find_sum_of_digits(n)
        if A <= _sum <= B:
            cnt += n
    ## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)

Submission status: Accepted

Solution code:
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, A, B = list(map(int,_in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = 0
    for n in range(N+1):
        _sum = sum(list(map(int,list(str(n)))))
        if A <= _sum <= B:
            cnt += n
    ## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)

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 str(i):
        tmp += int(j)
    if a<=tmp<=b:
        ans += i
print(ans)

Submission status: Accepted

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

for i in range(1,N+1):
  moji = str(i)    #文字列
  leng = len(moji) #文字長
  
  S = 0
  for j in range(leng):
    S += int(moji[j])
  
  if S >= A and S <= B:
    OutPut += i
    
print(OutPut)

Submission status: Accepted

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

for i in range(N + 1):
    actual = sum(map(int, str(i)))
    if actual >= A and actual <= B:
        sum_number += i

print(sum_number)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for i in range(N+1):
    stri = str(i)
    sumi = 0
    for j in range(len(stri)):
        sumi += int(stri[j])
    if A <= sumi <= 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
    num = i
    while num > 0:
        s = s + num % 10
        num = num // 10
    if a <= s <= b:
        ans = ans + i
print(ans)

Submission status: Accepted

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

ans = 0


def keta_sum(num):
	sum = 0
	while num:
		sum += num % 10
		num = num // 10
    
	return sum

for i in range(N):
	num = i + 1
	sum = keta_sum(num)
	if (sum >= A) and (sum <= B):
		ans += num

print(ans)

Submission status: Accepted

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

total = 0
sum = 0
for i in range(1, l[0] + 1):
  sum = 0
  n = i
  while i > 0:
    sum += i % 10
    i //= 10
  if sum >= l[1] and sum <= l[2]:
    total += n

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
"""this is python work script"""

def sum_digits(i):
    """return sum input digits"""
    str_i = str(i)
    list_i = list(map(int, str_i))
    sum_list = sum(list_i)

    return sum_list

def solve(N, num_min, num_max):
    """solve problem"""
    result = 0
    for i in range(1, N+1):
        sum_d = sum_digits(i)
        if num_min <= sum_d <= num_max:
            result += i
    return result

def main():
    """main method"""
    N, A, B = list(map(int, input().split(' ')))
    answer = solve(N, A, B)
    print(answer)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
"""this is python work script"""

def sum_digits(i):
    """return sum input digits"""
    sum_tmp = 0
    quotient = i

    for _ in range(5):
        quotient, mod = divmod(quotient, 10)
        sum_tmp += mod
        if quotient == 0:
            break
    return sum_tmp

def solve(N, num_min, num_max):
    """solve problem"""
    result = 0
    for i in range(1, N+1):
        sum_d = sum_digits(i)
        if num_min <= sum_d <= num_max:
            result += i
    return result

def main():
    """main method"""
    N, A, B = list(map(int, input().split(' ')))
    answer = solve(N, A, B)
    print(answer)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
"""this is python work script"""
def sum_num(i):
    sum_tmp = 0
    p = i
    for _ in range(5):
        p, mod = divmod(p, 10)
        sum_tmp += mod
        if p == 0:
           break
    return sum_tmp

def solve(N, num_min, num_max):
    """solve problem"""
    result = 0
    for i in range(1, N+1):
        sum_tmp = sum_num(i)
        if num_min <= sum_tmp and sum_tmp <= num_max:
            result += i
    return result

def main():
    N, A, B = list(map(int, input().rstrip().split(' ')))
    answer = solve(N, A, B)
    print(answer)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

def fun(x):
  y = 0
  while(x > 0):
    y = y + (x%10)
    x = x//10
  return y

for i in range(n):
  sum = fun(i+1)
  if a <= sum <= b:
    count = count + (i+1)

print(count)

Submission status: Accepted

Solution code:
N, sita, ue = map(int,input().split())
wa = 0
for i in range(N+1):
    # 数値を文字列に変換
    n = str(i)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, n))
    # 合計値を返す
    kei = sum(array)
    if kei <=ue and kei>= sita:
        wa += i
print(wa)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
"""this is python work script"""
def solve(N, A, B):
    LIST_RESULT = []
    for i in range(1, N + 1):
        str_i = str(i)
        l = len(str_i)

        sum_tmp = 0
        for x in range(l):
            sum_tmp += int(str_i[x])
        if A <= sum_tmp and sum_tmp <= B:
            LIST_RESULT.append(i)
    sum_result = sum(LIST_RESULT)
    return sum_result

def main():
    N, A, B = list(map(int, input().rstrip().split(' ')))
    answer = solve(N, A, B)
    print(answer)

if __name__ == '__main__':
    main()

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:
num_list = [int(e) for e in input().split()]

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

SUM = 0

for j in range(num_list[0]):
    value = digitSum(j+1)
    if num_list[1] <= value <= num_list[2]:
        SUM += j+1


print(SUM)

Submission status: Accepted

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

for x in range(a+1):
    keta = 0
    x_str = str(x)
    
    for y in range(len(x_str)):
        keta += int(x_str[y:y+1])
    
    if keta >= b and keta <= c:
        sum += x

print(sum)

Submission status: Accepted

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

for i in range(1,N+1):
    
    m = 0
    tmp = i
    for t in range(1, len(str(i))+1):
        #print(tmp)
        
        m += tmp%10
        tmp /= 10
        tmp = int(tmp)
    
    if( A <=m and m <= B):
        count += i

print(count)

Submission status: Accepted

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

for num in range(1, N+1):
    sum = 0
    num_copy = num
    while True:
        if num_copy==0:
            break
        sum += num_copy % 10
        num_copy = (num_copy - num_copy % 10) // 10
    
    if sum >= A and sum <= B:
        grand_sum += num

print(grand_sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

N, A, B = list(map(int, input().rstrip().split(' ')))
LIST_RESULT = []

for i in range(1, N+1):
    str_i = str(i)
    l = len(str_i)

    sum_tmp = 0
    for x in range(l):
        sum_tmp += int(str_i[x])
    if A <= sum_tmp and sum_tmp <= B:
        LIST_RESULT.append(i)

sum_result = sum(LIST_RESULT)
print(sum_result)

Submission status: Accepted

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

def sumCount(n):
    total = 0
    while n > 0:
        total += n % 10
        n //= 10
    return total

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

print(ans)

Submission status: Accepted

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

for i in range(N):
    s=str(i+1)
    for j in range(len(s)):
        Sum+=int(s[j])
    if A<=Sum and Sum<=B:
        ans+=int(s)
    else:
        pass
    Sum=0

print(ans)

Submission status: Accepted

Solution code:
n,a,b = input().split()
N = int(n)
A = int(a)
B = int(b)

lst = list(range(1,N+1))
l_str = [str(i).zfill(5) for i in lst]
l_int = []

for j in l_str:
  array = list(map(int,j))
  l_sum = sum(array)
  #print(l_sum)
  if A<=l_sum and l_sum<=B:
    k = int(j)
    l_int.append(k)
print(sum(l_int))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(Ssum)

Submission status: Accepted

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

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


print(ALlsum)

Submission status: Accepted

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

ans = 0

for i in range(int(N)+1):
    sum = 0
    for j in range(len(str(i))):
        num = str(i)
        sum += int((num[j]))
    if int(A) <= sum and sum <= int(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):
    isum = 0
    m = i
    while m != 0:
        isum += m%10
        m = m // 10
    if isum >= A and isum <=B:
        sum += i
print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
#N,A,B = 20,2,5

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

if __name__ == '__main__':
	ans = 0
	for n in range(1,N+1):
		sum = sum_digit(n)
		if sum >= A and sum <= B:
			ans = ans + n

	print(ans)

Submission status: Accepted

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

    for i in range(1, N+1):
        n = 0
        for j in str(i):
            n += int(j)
            if n > B:
                break
        if n >= A and n <= B:
            answer += i

    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from functools import reduce
from operator import add

inputs = input().split()

num = int(inputs[0])
begin = int(inputs[1])
end = int(inputs[2])
result = list()

for i in range(1, num + 1):
    l = [int(x) for x in list(str(i))]
    if begin <= reduce(lambda x, y: x + y, l) <= end:
        result.append(i)

print(sum(result))

Submission status: Accepted

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


tmp = []

for num in range(1,N+1):
    i = 0
    for n in list(str(num)):
        i += int(n)

    if A <= i <= B:
        tmp.append(num)

ans = 0

for t in tmp:
    ans += t

print(ans)

Submission status: Accepted

Solution code:
import numpy as np
import sys

input = sys.stdin.readline

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

res = 0
for x in range(1,N+1):

    _sum = 0
    for i in range(len(str(x))):
        _sum += int(str(x)[i])
    
    if _sum >= A and _sum <= B:
        res+=x

print(res)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B = MAP()
ans = 0
for i in range(1, N+1):
	a = [0]*5
	a[0] = i%10
	j = i//10
	a[1] = j%10
	j //= 10
	a[2] = j%10
	j //= 10
	a[3] = j%10
	j //= 10
	a[4] = j
	if A <= sum(a) <= B:
		ans += i

print(ans)

Submission status: Accepted

Solution code:
import sys
import os
import math
import string
import collections

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def f(N):
    return sum(map(int, str(N)))


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

    N, A, B = il()
    ret = 0
    for n in range(N + 1):
        q = f(n)
        if A <= q <= B: ret += n
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

count = 0

for i in range(N+1):
    t = i
    tmp = 0
    while t > 0:
        s = t % 10
        tmp += s
        t = t // 10
    
    if A <= tmp <= B:
        count += i

print(count)

Submission status: Accepted

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

count = 0

for i in range(N+1):
    i10000 = i // 10000
    i1000 = (i-i10000*10000) // 1000
    i100 = (i-i10000*10000-i1000*1000) // 100
    i10 = (i-i10000*10000-i1000*1000-i100*100) // 10
    i1 = (i-i10000*10000-i1000*1000-i100*100-i10*10) // 1

    isum = i10000 + i1000 + i100 + i10 + i1

    if A <= isum <= B:
        count += i

print(count)

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
number = 0
pic = []
for i in range(a[0] + 1):
    str_number = str(number)
    p =  list(str_number)
    now_line = list(map(int, p))
    sum_a = sum(now_line)
    
    # print(now_line)
    # print(sum_a)
    
    if a[1] <= sum_a <= a[2]:
        pic.append(number)
        # print(number)
        
    number += 1 
    
    
print(sum(pic))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
INIT_VAL = 0
def DD2(d1,d2): return [[INIT_VAL]*d2 for _ in range(d1)]
def DD3(d1,d2,d3): return [DD2(d2,d3) for _ in range(d1)]
## math ##
MOD=10**9+7
def divc(x,y): return -(-x//y)
def divf(x,y): return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers"""
    is_prime = [True] * MAX_NUM
    is_prime[0] = False
    is_prime[1] = False
    primes = []
    for i in range(MAX_NUM):
        if is_prime[i]:
            primes.append(i)
            for j in range(2*i, MAX_NUM, i):
                is_prime[j] = False
    return primes
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left

#======================================================#

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc083/tasks/abc083_b

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

def check(num):
    s = str(num)
    t = 0
    for i in s:
        t += int(i)
    if a <= t <= b:
        return True
    return False

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

Submission status: Accepted

Solution code:
# ABC083B

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

Submission status: Accepted

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

def main():
    # 整数の入力
    n, a, b = map(int, input().split())

    # 雑な探索
    sum = 0
    for i in range(1, n+1):
        # 桁数
        keta = len(str(i))
        num = i
        sum_all_keta = 0
        for j in range(keta):
            sum_all_keta += num % 10
            num = num // 10

        # print(sum_all_keta)
        if a <= sum_all_keta <= b:
            sum += i

    print(sum)


main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
data = input().split(' ')
n = int(data[0])
a = int(data[1])
b = int(data[2])
cnt = 0
for i in range(1, n + 1):
    num_1 = i % 10 // 1
    num_2 = i % 100 // 10
    num_3 = i % 1000 // 100
    num_4 = i % 10000 // 1000
    num_5 = i % 100000 // 10000
    s = sum([num_1, num_2, num_3, num_4, num_5])
    if a <= s <= b:
        cnt += i
print(cnt)

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 str(i)]
    if a <= sum(l) <= b:
       ans += i
print(ans)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
sum1 = 0
ans = 0
for i in range(1,n+1):
  sum1 =0
  for j in range(len(str(i))):
    sum1 +=int(str(i)[j])
  if a<= sum1 <=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):
    i = str(i)
    c = 0
    for j in range(len(i)):
        c += int(i[j])
    if (a<=c and c<=b):
        count += int(i)
print(count)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
my_list = [20] * 20
anslist = []
ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N, A, B = map(int, input().split())
# 文字列の入力
#s = input()
#print(s[0:K-1]+s[K-1].lower()+s[K:N])
i=1
ans=0
while(i<=N):
    s=str(i)
    array=list(map(int,s))
    #print(sum(array))
    SUM=sum(array)
    if A<=SUM and SUM<=B:
        #print(i)
        ans=ans+i
    i=i+1

print(ans)

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
sum_li = []
for i in range(N+1):
    s = str(i)
    array = list(map(int, s))
    temp = sum(array)
    if (temp>=A)&(temp<=B):
        sum_li.append(i)
ans = sum(sum_li)
print(ans)

Submission status: Accepted

Solution code:
n,a,b = input().strip().split()
n,a,b = [int(n),int(a),int(b)]
sum = 0

for i in range(1,n+1):
    if a<=(i//10000 + i//1000%10 + i//100%10 + i//10%10 + i%10)<=b:
        sum += i
print(sum)

Submission status: Accepted

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

l=[]
for i in range(1,N+1):
    x=0
    for j in range(len(str(i))):
        x+=int(str(i)[j])
    if x>=A and x<=B:
        l.append(i)
#print(l)
print(sum(l))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
def place_of_1(num):
    return num%10

def place_of_10(num):
    return (num%100 - num%10)/10

def place_of_100(num):
    return (num%1000 - num%100)/100

def place_of_1000(num):
    return (num%10000 - num%1000)/1000

def place_of_10000(num):
    return (num%100000 - num%10000)/10000

ans = 0
Sum = 0 
for i in range(n+1):
    Sum = place_of_1(i)+place_of_10(i)+place_of_100(i)+place_of_1000(i)+place_of_10000(i)
    if a <= Sum <= b:
        ans += i
    Sum = 0

print(ans)

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))
    num = 0
    for j in range(len(l)):
        num += int(l[j])
    if a <= num <= b:
        ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(res)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1, N + 1):
    # 各桁の和を出す処理
    w = sum(list(map(int, str(i))))
    if A <= w & w <= B:
        sub += i

print(sub)

Submission status: Accepted

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

def digit_sum(n):
  ret=0
  while(n>0):
    ret+=n%10
    n//=10
    
  return ret

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

nCnt = 0
nTtl = 0

while nCnt < n:
  nCnt = nCnt + 1
  sn = str(nCnt)
  sList = list(map(int,sn))
  if a <= sum(sList) <= b:
      nTtl = nTtl + nCnt

print(nTtl)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b = map(int, input().split())
total = 0
for i in range(1,n+1):
  array = list(map(int,str(i)))
  if a<=sum(array) and sum(array)<=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):
  array = list(map(int,str(i)))
  if a<= sum(array) and sum(array)<=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):
    num_sum = sum(map(int,list(str(i))))
    if A<=num_sum and num_sum<=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):
  li = [int(k) for k in list(str(i))]
  if sum(li)>=a and sum(li)<=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(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
i=1
while i<=N:
    X=i//1e4+i//1e3%10+i//100%10+i//10%10+i%10
    ans+=i*(A<=X<=B)
    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):
    if A <= sum([int(s) for s in str(i)]) <= B:
        ans += i
print(ans)

Submission status: Accepted

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


def digit_sum(q):
    if q <= 9:
        return q
    return digit_sum(q // 10) + int(q % 10)


result = 0
for q in range(N + 1):
    if A <= digit_sum(q) <= B:
        result += q
print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b=map(int, input().split()) 
total = 0
for i in range(1,n+1):
  m = i
  wa = 0
  while True:
    wa += m % 10
    m = m // 10
    if (m == 0):
      break
  if (wa >= a)and(wa <= 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):
    c = 0
    t = i
    for j in range(5):
        c += t % 10
        t //= 10
    if a <= c and c <= b:
        ans += i
print(ans)