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

number = []

def SUM(s):
  b = map(int, str(s))
  return sum(b)
  
for x in range(1, N+1):
      if A <= SUM(x) <= B:
          number.append(int(x))
     
print(sum(number))

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

ans = 0

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

Submission status: Accepted

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

def digit_sum(s):
    s = str(s)
    return sum([int(s[i]) for i in range(len(s))])
  
cnt=0
for i in range(1,n+1):
    if a<=digit_sum(i)<=b: cnt+=i
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
N,a,b=map(int,input().split())
ans=0
for i in range(1,N+1):
    s=sum([int(j) for j in str(i)])
    if a<=s<=b:
        ans+=i

print(ans)

Submission status: Accepted

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

for i in range(n+1):
    s = list(str(i))
    for j in s:
        total += int(j)
    if a<=total  and b>=total:
        ans += i
    total = 0
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

s = 0
for i in range(1, N+1):
    if(lambda x,a,b: x>=a and x<=b)(sum([int(d) for d in str(i)]), A, B):
        s = s + i

print(s)

Submission status: Accepted

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

Submission status: Accepted

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

def tasu(i):
  k=0
  s=0
  while 10**k<i:
    k+=1
  for a in range(k+1)[::-1]:
    s+=i//(10**a)
    i-=10**a*(i//(10**a))
  return(s)
    

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

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:

def sum_digit(num):
    sums = 0
    while num != 0:
        sums += num % 10
        num //= 10
    return sums

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

Submission status: Accepted

Solution code:
import math

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

total = 0
ans = []

# 文字列に変換
def findSumdigit(n):
    s = str(n)
    # 1文字ずつ数値化して配列に入れる
    array = list(map(int,s))
    return sum(array)

for i in range(A,N+1):
    total = findSumdigit(i)
    if total>= A and total <= B :
        ans.append(i)

print(sum(ans))

Submission status: Accepted

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

lisN=list(range(1,N+1))
lisW=[0]*N

for i in lisN:
	dignum=numpy.array(list(str(i)),dtype=int)
	lisW[i-1]=sum(dignum)

arN=numpy.array(lisN)
arW=numpy.array(lisW)
ans=sum(arN[(A<=arW)&(arW<=B)])
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:
input = input().split()
N = int(input[0])
A = int(input[1])
B = int(input[2])

ans = 0

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

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

print(ans)

Submission status: Accepted

Solution code:
def FindSumOfDigits(n):
    Sum=0
    len_n=len(str(n))
    for i in range(len_n):
        Sum+=int(n%10)
        n=n/10
    return Sum

N,A,B=map(int,input().split())
ans=0
#ans_list=[]
#sumlist=[]
for i in range(1,N+1):
    #sumlist.append(FindSumOfDigits(i))
    if A<=FindSumOfDigits(i)<=B:
        ans+=i
        #ans_list.append(i)
print(ans)
#print(ans_list)
#print(sum_list)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def FindSumOfDigits(n):
    Sum=0
    while(n>0):
        Sum+=(int(n%10))
        n=n/10
    return Sum

N,A,B=map(int,input().split())
ans=0
#ans_list=[]
#sumlist=[]
for i in range(1,N+1):
    #sumlist.append(FindSumOfDigits(i))
    if A<=FindSumOfDigits(i)<=B:
        ans+=i
        #ans_list.append(i)
print(ans)
#print(ans_list)
#print(sum_list)

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
Z=[]
for n in range(1,N+1):
    ns=str(n)
    len_ns=len(ns)
    total=0
    for x in range(len_ns):
        total=total+int(ns[x])
    if A<=total<=B:
        Z.append(n)
print(sum(Z))

Submission status: Accepted

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

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 = [int(n) for n in input().split(" ")]

cnt = 0

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

print(cnt)

Submission status: Accepted

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

cnt = 0

for n in range(1,N+1):
  temp = 0
  temp += n%10
  temp += int(n/10)%10
  temp += int(n/10/10)%10
  temp += int(n/10/10/10)%10
  temp += int(n/10/10/10/10)%10
  if temp >= A and temp <= B:
    cnt += n

print(cnt)

Submission status: Accepted

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


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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 入力 : 数字3つ
N, A, B = map(int, input().split())

# 1 以上 N 以下の整数のうち、10 進法での各桁の和が A 以上 B 以下
# であるものの総和を出力せよ。

def keta_wa(n) :
    sum = 0
    while n :
        sum += n%10
        n = int(n/10)
    return sum

ans = 0

for i in range(1,N+1) :
    if A <= keta_wa(i) <= 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):
    cnt += i * (A <= sum(map(int, str(i))) <= B)
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def digitsum(n):#nは正の整数、各位の和、許容は１０＾１０００
    if n<10:
        return n
    else:
        m=n//10
        return n%10+digitsum(m)

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

s=0

for i in range(0,N+1):
    if B>=digitsum(i)>=A:
        s=s+i

print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b = map(int, input().split())
# print(n,a,b)
# kakuketa no wa = x, a <= x <= b
def wa(x):
	res = [0,0,0,0,0]
	q = x // 10**4
	if q!=0:
		x = x - 10**4 *q
		res[0]=q
	q = x // 10**3
	if q!=0:
		x = x - 10**3 *q
		res[1]=q
	q = x // 10 **2
	if q!=0:
		x = x - 10**2 *q
		res[2]=q
	q = x // 10 
	if q!=0:
		x=x - 10*q
		res[3]=q
	res[4]=x
	return sum(res)
ans=0
for nn in range(1,n+1):
	wa1 =wa(nn)
	if wa1 >= a:
		if wa1 <= b:
			ans += nn
print(ans)

Submission status: Accepted

Solution code:
def main(n,a,b):
    res = 0
    for i in range(1, n+1):
        val = sub(i)
        if a <= val and val <= b:
            res += i
    return res

def sub(val):
    res = 0
    x = val
    while x > 0:
        x, j = divmod(x,10)
        res += j
    return res

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

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

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

total = 0
for i in range(1, N+1):
  SUM = numOfSumDigit(i)

  if A <= SUM and SUM <= B:
    total += i
    
print(total)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(str(ans))

Submission status: Accepted

Solution code:
"""
1以上N以下の整数の内、各桁の和がA以上B以下であるものの全ての総和は？

20 以下の整数のうち、各桁の和が 2 以上 5 以下なのは、
2, 3, 4, 5, 11, 12, 13, 14, 20 です。これらの合計である 84 を出力します。
"""

def summaker(n):
  sum1 = 0
  while n > 0:
    
    sum1 += n % 10
    n = n // 10
  return sum1

N, A, B = map(int, input().strip().split(' '))
total = 0
for i in range(1, N + 1):
  sum1 = summaker(i)
  if A <= sum1 <= 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):
    str_i = str(i)
    sum = 0
    for j in range(len(str_i)):
        sum += int(str_i[j])
    if a <= sum <= b:
        ans +=i

print(ans)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split(" "))
def check(x):
    sum=0
    while x>0: 
        sum = sum + x % 10 
        x=int(x/10); 
    return sum
 
total=0
for i in range(n+1): #1-10 1,2,10
    sum=check(i)
    if sum<=b and sum>=a:
        #print(i)
        total=total+i

print(total)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split(" "))
def check(x):
    sum=0
    while x>0: 
        sum = sum + x % 10 
        x=int(x/10); 
    return sum

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

print(ans)

Submission status: Accepted

Solution code:
# 関数を使った場合
N, A, B = map(int, input().split())
ans = 0

def FindSumOfDigits(x):
    count = 0
    while x>0:
        count += x%10
        x = x//10
    
    return count
    

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

print(ans)

Submission status: Accepted

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

for n in range(1, N+1):
    count = 0
    n_list = n
    while True:
        count += n%10
        n = n//10
        if n==0:
            break

    if A<= count <=B:
        l.append(n_list)

for i in l:
    ans += i

print(ans)

Submission status: Accepted

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

ans = 0
for i in range(1, n + 1):
    tmp = i
    tmp2 = list(str(tmp))
    sum = 0
    for j in range(len(tmp2)):
        sum += int(tmp2[j])
    if a <= sum <= 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):
    s = 0
    for j in range(len(str(i))):
        s += int(str(i)[j])
    if s >=a and b >= s:
        sum += i

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
"""
1以上N以下の整数の内、各桁の輪がA以上B以下であるものの全ての総和は？

20 以下の整数のうち、各桁の和が 2 以上 5 以下なのは、
2, 3, 4, 5, 11, 12, 13, 14, 20 です。これらの合計である 84 を出力します。
"""

N, A, B = map(int, input().strip().split(' '))
sum_list = []
for i in range(1, N + 1):
  # １以上N以下の整数を1つずつ
  if len(str(i)) == 1:
    if A <= i <= B:
      sum_list.append(i)
  elif len(str(i)) == 2:
    if A <= int(str(i)[0]) + int(str(i)[1]) <= B:
      sum_list.append(i)
  elif len(str(i)) == 3:
    if A <= int(str(i)[0]) + int(str(i)[1]) + int(str(i)[2]) <= B:
      sum_list.append(i)
  elif len(str(i)) == 4:
    if A <= int(str(i)[0]) + int(str(i)[1]) + int(str(i)[2]) + int(str(i)[3]) <= B:
      sum_list.append(i)
  else:
    if A <= int(str(i)[0]) + int(str(i)[1]) + int(str(i)[2]) + int(str(i)[3]) + int(str(i)[4]) <= B:
      sum_list.append(i)
print(sum(sum_list))

Submission status: Accepted

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

Submission status: Accepted

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

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

for i in range(n+1):
    add = 0
    add = SumOfDigits(i)
    if a <= add and add <= b:
        sum += i

print(sum)

Submission status: Accepted

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

for i in range(N+1):
  output=0
  c=i
  for p in range(4,-1,-1):
    order=int(c/10**p)
    c=c-order*10**p
    output+=order
  if output>=A and output<=B:
    #print(i)
    SUM+=i
    
print(SUM)

Submission status: Accepted

Solution code:
def sumEach(n):
    n = str(n)
    return sum(map(int, n))

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

for i in range(1, n+1):
    if sumEach(i) >= a and sumEach(i) <= 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):
  c = 0
  d = i
  while i != 0:
    c += i%10  
    i //=10
  if a <= c <= b:
    count += d
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

ans = []
for n in range(1, n_num+1):
  n_str = list(str(n))
  total = sum(list(map(int, n_str)))
  if total >= a and total <= b:
    ans.append(n)

print(sum(ans))

Submission status: Accepted

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

for i in range(1, n+1):
    s = str(i)
    sum = 0
    for j in range(len(s)):
        sum += int(s[j])
    if sum >= a and sum <= 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):
  d = i
  s = 0
  while d:
    s +=  d % 10
    d = int(d/10)
  if a<=s<=b:
    ans += i
print(ans)

Submission status: Accepted

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

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

print(sum(arr))

Submission status: Accepted

Solution code:
N,A,B=[int(str1) for str1 in input().split()]
#print(N,A,B)
sums=0

def digits_sum(digits,len):
    sum=0
    for i in range(len):
        sum+=int(digits[i])
    return sum


for i in range(N+1):
    digits=str(i)
    sum=digits_sum(digits,len(digits))
    if sum>=A and sum<=B:
        sums+=i
    else:
        pass

print(sums)

Submission status: Accepted

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,a,b=INTM()
    ans=0
    for i in range(1,n+1):
        ct=0
        si=str(i)
        for j in si:
            ct+=int(j)
        if a<=ct and ct<=b:
            ans+=i
            #print(i)
    print(ans)
if __name__ == '__main__':
    do()

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1, n+1):
  q = i // 10000
  qi = i % 10000
  w = qi // 1000
  wi = qi % 1000
  e = wi // 100
  ei = wi % 100
  r = ei // 10
  ri = ei % 10
  t = ri
  sum = q + w + e + r + t
  if sum >= a and sum <= b:
    x += i
    
print(x)

Submission status: Accepted

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

Submission status: Accepted

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

def digitsum(j):
    s = str(j)
    array = list(map(int, s))
    return sum(array)

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

Submission status: Accepted

Solution code:
from functools import reduce 
from operator import add
n, a, b = map(int, input().split())

n_cond = 0

for i in range(1, n+1):
  i_str = str(i)

  if len(i_str) == 1:
    order_sum = i
    
  else:
    temp = list(map(int, i_str))
    order_sum = reduce(add, temp)
    
  if order_sum >= a and order_sum <= b:
    n_cond += i
print(n_cond)

Submission status: Accepted

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

total = 0

def sum_digits(n):
  return sum(map(int, str(n)))

for n in range(1, N + 1):
  if A <= sum_digits(n) <= B:
    total += n
    
print(total)

Submission status: Accepted

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

ans = 0
for num in range(1, n+1):
    str_num = str(num)

    sum = 0
    for s in str_num:
        sum += int(s)

    if a <= sum <= b:
        ans += num

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n, a, b = map(str, input().split())
h = 0
ans = []

for i in range(1,int(n)+1):
	for j in str(i):
		h += int(j)
	if h >= int(a) and h <= int(b):
		ans.append(int(i))

	h = 0

print(sum(ans))

Submission status: Accepted

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

Submission status: Accepted

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

sum = 0

for i in range(N):
    sum_t = 0
    j = i + 1
    n = j
    while n != 0:
        sum_t += n % 10
        n //= 10
    if sum_t >= A and sum_t <= B:
        sum += j

print(sum)

Submission status: Accepted

Solution code:
# スペース区切りの整数の入力
N, A, B = map(int, input().split())

totalSum = 0
tmpNum = 0

for n in range(N + 1):
    digit = 0
    digitSum = 0
    tmpNum = n
    while True:
        digit = tmpNum % 10
        digitSum = digitSum + digit
        if tmpNum >= 10:
            tmpNum = tmpNum / 10
            tmpNum = int(tmpNum)
        else:
            if A <= digitSum <= B:
                totalSum = totalSum + n
            break

print(totalSum)

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
count = 0
for i in range (1,N+1):
	if i == 10000:
		e = 1
		if e>=A and e<=B:
			count += i
	else:
		a=i//1000
		b=(i%1000)//100
		c=(i-a*1000-b*100)//10
		d=i%10
		#print(a,b,c,d)
		e = a+b+c+d
		if e>=A and e<=B:
			count += i
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(N+1):
    T = (i//10000) + ((i//1000)%10) + ((i//100)%10) + ((i//10)%10) + (i%10)
    if (A<=T) and (T<=B):
        L += i

print(L)

Submission status: Accepted

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

def findSum(n):
    sum_total = 0
    while n > 0:
        sum_total += int(n % 10)
        n = int(n /10)
    return int(sum_total)

total = 0
for i in range(1, N + 1):
    sum_total = findSum(i)
    if sum_total >= A and sum_total <= B:
        total += i

print(total)

Submission status: Accepted

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

ans = 0
for n in range(1, N+1):
    ns = list(str(n))
    if A <= sum(map(int, ns)) <= 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):
  tmp = 0
  for j in str(i):
    tmp += int(j)
  if A <= tmp <= B:
    ans += i
      
print(ans)

Submission status: Accepted

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


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

s = []
for n in range(N + 1):
    if A <= some_sum(n) and some_sum(n) <= B:
        s.append(n)

print(sum(s))

Submission status: Accepted

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

print(answer)

Submission status: Accepted

Solution code:
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, A, B = map(int, readline().split())
ans = 0
for i in range(N + 1):
    s = 0
    t = i
    while t:
        s += t % 10
        t = t // 10

    if A <= s <= B:
        ans += i
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
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())
Num=0
Num_sum=0

for number in range(1,N+1):
    for num in str(number):
        num=int(num)
        Num+=num

    if Num>=a and Num<=b:
        Num_sum+=number
    Num=0
print(Num_sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(n, a, b):
    f = lambda x: sum(int(s) for s in str(x))
    return sum(i for i in range(1, n + 1) if a <= f(i) <= b)

_n, _a, _b = map(int, input().split())
print(solve(_n, _a, _b))

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

y = []
for i in range(1, N + 1):
    if A <= sum(map(int, str(i))) <= B:
        y.append(i)

print(sum(y))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n,a,b = map(int,input().split())
ans = 0
for i in range(1,n+1):
    if a <= sum([int(str(i)[j]) for j in range(len(str(i)))]) <= b:
        ans += i
print(ans)

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:
def sum_digits(n):
  sum_ = 0
  while(n > 0):
    sum_ += (n % 10)
    n = (n // 10)
  return sum_
   
 
  
def main():
  n, a, b = map(int, input().strip().split())
  total = 0
  for i in range(1, n+1):
    tmp = sum_digits(i)
    
    if (tmp >= a) & (tmp <= b):
      total += i
  print(total)
 
    
if __name__=="__main__":
  main()

Submission status: Accepted

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

#整数値入力 1文字の入力
def input_one_number():
    return int(input())

#整数値龍力　複数の入力
def input_multiple_number():
    return map(int, input().split())

#整数値龍力　複数の入力(配列)
def input_multiple_number_as_list():
    return list(map(int, input().split()))

#2次元配列入力
def input_map():
    return [list(map(int,list(input()))) for i in range(h)]

#リスト出力
def print_list(list):
    print(*list)
    return

#2次元配列出力
def print_map(maplist):
    for i in maplist:print(*i, sep='')
    return

#素数生成
def generate_primenums():
    n = 100
    primes = set(range(2, n+1))
    for i in range(2, int(n**0.5+1)):
        primes.difference_update(range(i*2, n+1, i))
    primes=list(primes)
    return primes

def memo():
    a=[0]*5
    b=a  #良くない配列のコピー
    b2=a[:]  #1次元のときはコピーはこれで良い
    a[1]=3
    print('b:{}, b2:{}'.format(b,b2))  #b:[0, 3, 0, 0, 0], b2:[0, 0, 0, 0, 0]
    
    import copy
    a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
    b=copy.deepcopy(a)  #2次元配列はこうコピーする
    
    #内包表記奇数のみ
    odd=[i for i in range(100) if i%2==1] #[1, 3, 5, 7, 9, 11, 13, 15, 17, 19]

    #二部探索
    import bisect
    a = [1, 2, 3, 5, 6, 7, 8, 9]
    b=bisect.bisect_left(a, 8)

    #combinations、組み合わせ、順列
    from itertools import permutations, combinations,combinations_with_replacement,product
    a=['a','b','C']
    print(list(permutations(a)))
    print(list(combinations(a,2)))
    print(list(combinations_with_replacement(a,3)))


#階乗
def kaijo(n):
    import math
    return math.factorial(n)

#選び方（コンビネーション nCr）
def num_combination(n,r):
    import math
    return math.factorial(n) // math.factorial(n - r)


#最大公約数、最小公倍数
def calc_gcd(a,b):
    import fractions
    GCD=fractions.gcd(a,b)
    lcm=a*b//gcd
    return gcd,lcm

#複数の最大公約数
def calc_gcd_list(l):
    gcd = l[0]
    for i in range(1, N):
        gcd = fractions.gcd(gcd, l[i])
    return gcd

#各桁の和
def sum_digit(n):
    sum = 0
    while n > 0:
        sum += n%10
        n //= 10
    return sum

N,A,B = input_multiple_number()

ans=[]

for i in range(N+1):
    a = sum_digit(i)
    if A <= a and a <= B:
        ans.append(i)

sumans = 0
for j in ans:
    sumans += j

print(sumans)

Submission status: Accepted

Solution code:
lst = list(map(int, input().split()))
ans = 0
tot = 0
cnt = 0
 
for i in range(1,lst[0]+1):
    flg = True
    val = i
    while flg:
        cnt += 1
        tot = tot + val%10
        val = val//10
 
        if val==0:
            if ( lst[1] <= tot and
                 tot <= lst[2] ):
                ans = ans + i
 
            tot = 0
            flg = False
 

print(ans)

Submission status: Accepted

Solution code:
def getInput():
    return [int(i) for i in input().rstrip().split(' ')]


def sumNum(num, sums):
    if num == 0:
        return sums
    sums += num % 10
    num = num // 10
    return sumNum(num, sums)

N, A, B = getInput()

ret = []
for i in range(1, N + 1):
    sums = sumNum(i, 0)    

    if sums < A or sums > B:
        continue
    else:
        ret.append(i)

print(sum(ret))

Submission status: Accepted

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