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:
#B - Some Sums
N,A,B = map(int,input().split())

def some_sum(n):
    n = str(n)
    n = list(n)
    n = [int(j) for j in n]
    return sum(n)
    
count = 0
for k in range(A,N+1):
    if A <= some_sum(k) <= B:
        count += k
print(count)

Submission status: Accepted

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

while n <= N:
    result_n = sum(list(map(int, str(n))))
    if A <= result_n <= B:
        cnt = cnt+n
    n += 1

print(cnt)

Submission status: Accepted

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

count = 0

for i in range(1, n + 1):
    x = sum(list(map(int, str(i))))
    if a <= x <= b:
        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 = 0
    for j in range(5):
        m = 10**j
        s += (i // m) % 10
    if a <= s <= b:
        ans += i
print(ans)

Submission status: Accepted

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

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

ans1 = 0
for i in range(N+1):
    if A <= sum(i) <= B:
        ans1 += i
    else:
        continue
print(ans1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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))):
    cnt+=int(str(i)[j])
  if a<=cnt<=b:
    ans+=i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans =0

while N > 0:
    n = N
    t = 0

    while n > 0:
        t += n % 10
        n //= 10

    if A <= t <= B:
        ans += N

    N -= 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

sum = 0

for n in range(1, N+1):
    nsum = 0
    m = n
    while m != 0:
        nsum += m % 10
        m = m//10
    if nsum >= A and nsum <= B:
        sum += n
print(sum)

Submission status: Accepted

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

ans = 0
for i in range(N+1):
    moji = str(i)
    n = 0
    for j in range(len(moji)):
      n += int(moji[j])

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

print(ans)

Submission status: Accepted

Solution code:
# AtCoder Beginners Selection  Some Sums 解けなかった
N,A,B = map(int,input().split())
ans = 0
for i in range(1,N+1):
    moji = str(str(i).zfill(4))
    sumsomes = int(moji[0])+int(moji[1])+int(moji[2])+int(moji[3])
    if (sumsomes >= A) and (sumsomes <= B):
        ans += i
print(ans)

Submission status: Accepted

Solution code:
def calc(num, A, B) -> bool:
	ans = 0

	while True:
		if num // 10 == 0:
			ans += num
			break
		ans += num % 10
		num //= 10

	if A <= ans and ans <= B:
		return True
	else:
		return False



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

	for num in range(1, N + 1):
		result = calc(num, A, B)
		if result:
			ans += num

	print(ans)

  
if __name__ == "__main__":
  	main()

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(map(int, str(i))) <= B))

Submission status: Accepted

Solution code:
N, A, B = map(int,input().split())
ans = 0
sum = 0
for i in range(N+1):
    for j in str(i):
        sum += int(j)
    if sum >= A and sum <= B:
        ans += i
    sum = 0 
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)
    List = []
    for j in range(len(i)):
        List.append(i[j])
    List = list(map(int,List))
    
    if sum(List) >= a and sum(List) <= b:
        count += int(i)

print(str(count))

Submission status: Accepted

Solution code:

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

ans = 0

# 0からnまで回す
for i in range(n + 1):
    
    # print("i : {0}".format(i))

    _sum = 0

    # 要素を1桁ずつ足していく
    for j in range(len(str(i))):

        # print("iの{0}桁目 : {1}".format(j + 1, int(str(i)[j])))

        _sum = _sum + int(str(i)[j])

        if b < _sum :
            break

    # print("sum : {0}".format(_sum))

    if a <= _sum and _sum <= b :
        ans = ans + i
        # print('追加!')

print(ans)

Submission status: Accepted

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

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

for i in range(1,n+1):
  if degitSum(i) >= a and degitSum(i) <= b:
    array2.append(i)
    
print(sum(array2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
upNum, firstNum, lastNum = map(int, input().split())
total = 0
digitNumSum = 0
for i in range(1, upNum + 1):
  digitNumSum = 0
  digitNumList = list(str(i))
  for j in range(len(digitNumList)):
    digitNumSum += int(digitNumList[j])
  if firstNum <= digitNumSum <= lastNum:
    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 and a<=B:
    ans+=i
print(ans)

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

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

def func(s):
    rtn = 0
    for i in s:
        rtn += int(i)
    return rtn

ans = [0]
for i in range(1,n+1):
    temp = func(str(i))
    if (temp >= a and temp <= b):
        ans.append(i)

print(sum(ans))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

import math

x=1234

def divmod2(x,y):
    a=math.floor(x/y)
    b=x%y
    return x,y

def ksouwa(x):
    x=int(x)
    sen=math.floor(x/1000)
    hyaku=math.floor((x%1000)/100)
    juu=math.floor((x%100)/10)
    iti=math.floor(x%10)
    return sen+hyaku+juu+iti

def ksouwa2(x):
    int1=0
    x=str(x)
    len(x)
    for i in list(x):
        #print(i)
        int1=int(int1)+int(i)
    return int1

X,A,B=open(0).read().split()

X=int(X)

A=int(A)

B=int(B)

int1=0
int2=0

for i in range(X+1):
    if (ksouwa2(i)>=A) and (ksouwa2(i)<=B):
        int1=int1+1
        int2=int2+i

#print(int1)
print(int2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
a=0
b=0
c=0
d=0
e=0
y=0
for i in range(1,N+1,1):
  n = str(i)
 
  if int(n)==10000:
    e=n[0]
    d=n[1]
    c=n[2]
    b=n[3]
    a=n[4]
  if 1000<=int(n)<10000:
    d=n[0]
    c=n[1]
    b=n[2]
    a=n[3]
  if 100<=int(n)<1000:
    c=n[0]
    b=n[1]
    a=n[2]
  if 10<=int(n)<100:
    b=n[0]
    a=n[1]
  if int(n)<10:
    a=n[0]
  x = int(d) + int(c) + int(b) + int(a) + int(e)
  if A <= x <= B:
    y = y + int(n)
print(y)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def int_sum(x):
    y=str(x)
    num=0
    for i in range(len(y)):
        num += x%10
        x = x//10
    return num

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

Submission status: Accepted

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

def int_to_sum(i):
    i_str = str(i)
    result = 0
    for i_s in i_str:
        result += int(i_s)
    return result

result = 0

for i in range(1,N+1):
    int_sum = int_to_sum(i)
    if int_sum <= B and int_sum >= A:
        result += i

print(result)

Submission status: Accepted

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

N, A, B = list(map(lambda x: int(x), input().split(" ")))

print(sum([j for j in range(N + 1) if A <= digitsum(j) <= B]))

Submission status: Accepted

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

for i in range(n+1):
    s_sum = 0
    c = i
    while c>0:
        s_sum += c%10
        c = c//10
    if a <= s_sum <= b:
        sum += i
print(sum)

Submission status: Accepted

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, a, b =  inintm()

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

def sum_of_num(num):
    list_a = []
    sums = 0
    while num > 0:
        list_a.append(num % 10)
        num = num // 10
    for i in range(len(list_a)):
        sums = sums + list_a[i]
    return sums

list_b = []
for i in range(1,N+1):
    if A <= sum_of_num(i) <=B:
        list_b.append(i)

sums = 0
for i in range(len(list_b)):
    sums = sums + list_b[i]

print(str(sums))

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
start_number = 0
sum_number = 0
for d in range(0, a+1, 1):
    for e in str(d):
        sum_number += int(e)
    if b <= sum_number <= c:
        start_number += d
        sum_number = 0
    else:
        sum_number = 0
print(start_number)

Submission status: Accepted

Solution code:
def kakuinowa(x):
    y=0
    for i in range(5):
        y+=(x%(10**(i+1)))//(10**i)
    return(y)
n,a,b = list(map(int, input().strip().split()))
ans=0
for i in range(n+1):
    if a<=kakuinowa(i) and kakuinowa(i)<=b:
        ans+=i
print(ans)

Submission status: Accepted

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

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

ans = 0

for n in range(1, N+1):
    if A <= sum(n) <= B:
        ans += n

print(ans)

Submission status: Accepted

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

def digisum(m):
  if m<10:
    return m
  else:
    return digisum(m//10)+m%10

print(sum(x for x in range(1,n+1) if a<=digisum(x)<=b))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def f(x):
    return (sum(list(map(int, list(str(x))))))

ans = 0
n , a, b = map(int, input().split())
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):
    total = 0
    buf = i
    for j in range(4, -1, -1):
        division, buf = divmod(buf, 10**j)
        total += division
    if total >= A:
        if total <= B:
            ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b=(int(x) for x in input().split())
c=0
d=[]
def sual(N,A,B):
  l=list('{}'.format(N))
  for y in range(len(l)):
      d.append(int(l[y]))
  e=sum(d)
  d.clear()
  if A<=e<=B:
    return True
  else:
    return False

for x in range(n):
  if sual(x+1,a,b):
    c=c+x+1
print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

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

    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

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

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

Submission status: Accepted

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

Submission status: Accepted

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

r = [0] * 40

for i in range(1, N + 1):
    si = str(i)
    t = 0
    for j in range(len(si)):
        t += int(si[j])

    r[t] += i

res = 0

for i in range(A, B + 1):
    res += r[i]

print(res)

Submission status: Accepted

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

ans=0
for i in range(1,N+1):
  S=digitSum(i)
  if A<=S<=B:
    ans+=i
print(ans)

Submission status: Accepted

Solution code:

n, a, b = map(int , raw_input().split())
def dfs(u, q, n, a, b):
	c = 0
	if u > n:return 0

	if a <= q <= b: 
		c += u

	for d in range(0 if u else 1,10): 
		c += dfs(u * 10 + d,q + d, n, a, b)
	return c


print dfs(0, 0,n, a, b )

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

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(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
tmp = 0
frag10000 = 0
frag1000 = 0
frag100 = 0
frag10 = 0
frag1 = 0
for i in range(n + 1):
    tmp = i
    frag10000 = int(tmp / 10000)
    tmp %= 10000
    frag1000 = int(tmp / 1000)
    tmp %= 1000
    frag100 = int(tmp / 100)
    tmp %= 100
    frag10 = int(tmp / 10)
    tmp %= 10
    frag1 = int(tmp)
    tmp = frag10000 + frag1000 + frag100 + frag10 + frag1
    if a <= tmp <= b:
        ans += i
print(ans)

Submission status: Accepted

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

def findSumOfDigits(N):
	sum = 0
	while N > 0:
		sum += N % 10
		N = N//10
	return(sum)
	
total = 0
for i in range(1, N+1):
	sum = findSumOfDigits(i)
	if (A <= sum and sum <= 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):
    s = str(i)
    sums = 0
    for x in s:
        sums += int(x)
    if a <= sums and sums <= 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):
  isum=0
  ii=i
  while ii>0:
    isum+=ii%10
    ii//=10
  if a<=isum<=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):
  stri=str(i)
  cnt=0
  for j in range(len(stri)):
    cnt+=int(stri[j])
  if cnt>=a and cnt<=b:
    ans+=i
print(ans)

Submission status: Accepted

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

def s(sum,a,b):
    t = 0
    if sum >= a and sum <= b:
        t = 1
    return t

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

num = 0
for i in range(1,n+1):
    sum = S(i)
    if s(sum,a,b) == 1:
        num += i
print(num)

Submission status: Accepted

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

Submission status: Accepted

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

print(tt)

Submission status: Accepted

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

ans = 0

for n in range(1, N+1, 1):
    l = [i for i in str(n)]
    n_sum = sum(map(int, l))
    if n_sum >= A and n_sum <= B:
        ans += n

print(ans)

Submission status: Accepted

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

ans = 0
for i in range(1,N+1):
    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())
res = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

x = 0
ans = 0
for i in range(N + 1):
    i = str(i)
    l = len(i)
    for j in range(l):
        x += int(i[j])
    if A <= x <= B:
        ans += int(i)
    x = 0
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def wa(n):
    return sum(list(map(int,list(str(n)))))

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

ans = 0
for i in range(1,N+1,1):
    tmp = wa(i)
    if A<=tmp and tmp<=B:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
list=[]
for i in range(0,n+1):
    s1=int(i%10)
    s2=int((i-s1)%100/10)
    s3=int((i-s1-10*s2)%1000/100)
    s4=int((i-s1-10*s2-100*s3)%10000/1000)
    s5=int((i-s1-10*s2-100*s3-1000*s4)%100000/10000)
    if s1+s2+s3+s4+s5>=a and s1+s2+s3+s4+s5<=b:
        list.append(i)
print(sum(list))

Submission status: Accepted

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

def digitSum(n):
    total = 0
    for digit in str(n):
        total += int(digit)
    return total


for i in range(1,N+1):
    if A <= digitSum(i) <= B:
        p+=i
        
print(p)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


def dsum(n):
    wa = 0
    while n > 0:
        wa += n % 10
        n //= 10
    return wa


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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

N,A,B = MI()

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 = map(int,input().split())

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

print(ans)

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

Solution code:
n_a_b = input().split(' ')

n = int(n_a_b[0])
sum([int(i) for i in list(n_a_b[0])])
a = int(n_a_b[1])
b = int(n_a_b[2])

result = 0
for i in range(1, n+1):
    total = sum([int(s) for s in list(str(i))])
    if total >= a and total <= b:
        result += i

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

sum=0
for i in range(int(N)+1):
    nums = list(str(i))
    tmp = 0
    for j in nums:
        tmp = tmp + int(j)
    if int(A)<=tmp:
        if tmp<=int(B):
            sum = sum + i
print(sum)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

ans = 0
for num in range(n):
  num += 1
  num_0 = num
  place_of_10000 = num//10000
  num -= 10000*place_of_10000
  place_of_1000 = num//1000
  num -= 1000*place_of_1000
  place_of_100 = num//100
  num -= 100*place_of_100
  place_of_10 = num//10
  num -= 10*place_of_10
  
  tmp = place_of_10000 + place_of_1000 + place_of_100 + place_of_10 + num
  if a<=tmp and tmp<=b:
    ans += num_0
    
print(ans)

Submission status: Accepted

Solution code:
def resolve():
    n, a, b = map(int, input().split())
    
    ans = 0
    for i in range(n, 0, -1):
        snum = str(i)
        total = 0
        for c in snum:
            total += int(c)
        if a <= total and total <= b:
            ans += i
    print(ans)
resolve()

Submission status: Accepted

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

count = 0
for i in range(N+1):
    if i == 10000:
        i_4 = 1
        res_i = 0
    else:
        i_4 = 0
        res_i = i

    i_3 = int(res_i/1000)
    if i_3 != 0:
        res_i = res_i - i_3*1000
    
    i_2 = int(res_i/100)
    if i_2 != 0:
        res_i = res_i - i_2*100
    
    i_1 = int(res_i/10)
    if i_1 != 0:
        res_i = res_i - i_1*10
    
    i_0 = res_i
    i_sum = i_4 + i_3 + i_2 + i_1 + i_0
    # print('i_sum：', i_sum)
    # print(i_4, i_3, i_2, i_1, i_0)

    if i_sum >= A and i_sum <= B:
        count += i
        # print('clear i_sum：', i_sum)
        # print('clear', i_4, i_3, i_2, i_1, i_0)

print(count)

Submission status: Accepted

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

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

print(sum(ans_list))

Submission status: Accepted

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

def check(a):
  sumsum = 0
  while a > 0:
    sumsum += a % 10
    a = a // 10
  return sumsum

for i in range(N+1):
  if A<=check(i)<=B:
    res += i
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

m = 0

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

    n = 0
    
    for j in range(len(str(i))):

        n += int(str(i)[j])

    if A <= n <= B:
        m += i

print(m)

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

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

sum_list = []
for i in range(1, n+1):
    tmp = sum(list(map(int, str(i))))
    if A <= tmp and tmp <= B:
        sum_list.append(i)
print(sum(sum_list))

Submission status: Accepted

Solution code:
from sys import stdin

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

s = 0
for i in range(n+1):
    pp = 0
    m = i
    for j in range(5):
        p = m % 10
        pp = pp + p
        m = m//10
    if pp >= a and pp <= b: s = s + i

print (s)

Submission status: Accepted

Solution code:
#

import sys
input=sys.stdin.readline

def main():
    N,A,B=map(int,input().split())
    cnt=0
    for i in range(1,N+1):
        ds=0
        for j in range(5):
            ds+=(int(i//(10**j)))%(10)
        if A<=ds<=B:
            cnt+=i
    print(cnt)
    
if __name__=="__main__":
    main()

Submission status: Accepted

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

def su(n):
  n = str(n)
  aa = 0
  for i in range(len(n)):
    aa += int(n[i])
  return aa
  

ans = 0
for i in range(1, N + 1):
  now = su(i)
  if A <= now <= B:
    ans += i
print(ans)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

ans = 0

for i in range( 1 , int(a)+1 ):
    
    o = str(i)
    
    count = 0
    
    for k in range( 0 , len(o)) :
        
        count += int(o[k])
    
    if count >= int(b) and count <= int(c):
        
        ans += i
        
print(ans)

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
ans=0
for x in range(1,N+1):
  temp=0
  for y in str(x):
    temp+=int(y)
  else:
    if temp>=A and temp<=B:
      ans+=x
print(ans)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
ans = 0
for i in range(1, N+1):
    j = i
    cnt = 0
    while j != 0:
        cnt += j % 10
        j //= 10
    if A <= cnt <= B: ans += i
print(ans)

Submission status: Accepted

Solution code:
N, A, B = input().split(' ')
N = int(N)
A = int(A)
B = int(B)
Num = []
Num = list(range(1, N+1))
checkbox = [0]
all = []
for i in range(N):
  cn = str(Num[i])
  for j in range(len(cn)):
    cnk = int(cn[j])
    checkbox.append(cnk)
  check = sum(checkbox)
  if A<= check <= B:
    all.append(Num[i])
  checkbox = [0]
print(sum(all))

Submission status: Accepted

Solution code:
import math


def main(n, a, b):
    def validator(x, a, b):
        total = sum([(x // (10 ** digit)) %
                     10 for digit in range(int(math.log10(n)) + 1)])
        return total >= a and total <= b
    print(sum([x for x in range(1, n + 1) if validator(x, a, b)]))


if __name__ == "__main__":
    n, a, b = [int(x) for x in input().split()]
    main(n, a, b)