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:
def sumDigit(str_digit):
    a = [int(n) for n in list(str(str_digit))]
    return sum(a)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def findSumOfDigits(n):
    ret = 0
    while n>0:
        ret += n % 10
        n //= 10
    return ret
 
if __name__ == '__main__':
    n, a, b = map(int, input().split())
    ttl = 0
    for i in range(1, n+1):
        sod = findSumOfDigits(i) ##各桁の和
        if (a <= sod) and (sod <= b):
            ttl += i
    print(ttl)

Submission status: Accepted

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

res = 0
for n in range(1, N+1):
    s = str(n)
    temp = 0
    for i in range(len(s)):
        temp += int(s[i])
    if temp <= B and temp >= A:
        res += n
    
print(res)

Submission status: Accepted

Solution code:
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

n = int(arr_data[0][0])
a = int(arr_data[0][1])
b = int(arr_data[0][2])

#print(n,a,b)
mysum=0
i=1
while i<=n:
    
#    print(i)
    strtemp=str(i)
    
    sum_temp =0
    for v in strtemp:
        
        sum_temp+=int(v)
    else:

        if sum_temp>=a and sum_temp<=b:
#            
#            print(i)
#            
            mysum+=i
    
    
    i+=1
    
    
print(mysum)

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(n+1):
    sd = sum_digits(i)
    if a <= sd and sd <= b:
        ans += i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x, min, max = input().rstrip().split()
ans = 0
for i in range(int(x) + 1):
    if int(min) <= sum(map(int, str(i))) <=int(max):
        ans += i
print(ans)

Submission status: Accepted

Solution code:
x, min, max = input().rstrip().split()
ans = 0
i = int(x)
while i > 0:
    num = sum(map(int, str(i)))
    if int(min) <= num <=int(max):
        ans += i
    i = i - 1
print(ans)

Submission status: Accepted

Solution code:
x, min, max = input().rstrip().split()
ans = 0
i = int(x)
while i > 0:
    num = sum(list(map(int, str(i))))
    if int(min) <= num <=int(max):
        ans += i
    i = i - 1

print(ans)

Submission status: Accepted

Solution code:
x, min, max = input().rstrip().split()
digit = len(x)

ans = 0
i = int(x)
while i > 0:
    num = sum(list(map(int, str(i))))
    if int(min) <= num <=int(max):
        ans += i
    i = i - 1

print(ans)

Submission status: Accepted

Solution code:
x, min, max = input().rstrip().split()
digit = len(x)

ans = 0
for i in range(int(x)+1):
    num = sum(list(map(int, str(i))))
    if num>=int(min) and num<=int(max):
        ans += i

print(ans)

Submission status: Accepted

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

result = 0
for n in range(1, N + 1):
   sum_n = 0
   for i in str(n):
       sum_n += int(i)
   if a <= sum_n <= b:
       result += n
print(result)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

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

res = 0
for i in range(1, n + 1):
    si = "%05d" % i
    su = 0
    for c in si:
        su += int(c)
    if a <= su <= b:
        res += i

print(res)

Submission status: Accepted

Solution code:
n,a,b=map(int, input().split())
ret = 0
for i in range(1, n+1):
    c = eval('+'.join(str(i)))
    if a<=c and c <=b:
        ret += i
print(ret)

Submission status: Accepted

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

for i in range(1, n + 1):
    # 割とスッキリ書けた
    digit_sum = sum(map(int, list(str(i))))

    if a <= digit_sum and digit_sum <= b:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
n, a, b = [int(i) for i in input().split()]
ans = 0
for i in range(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())
res = 0
for i in range(1, N+1):
    Sum = 0
    tmp = i
    while tmp != 0:
        Sum += tmp%10
        tmp = tmp//10
    if Sum >= A and Sum <= B:
        res += i
print(res)

Submission status: Accepted

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

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

    for num in range(1, n + 1):
        chars = list(str(num))
        tmp = 0
        for char in chars:
            tmp += int(char)
        if a <= tmp and tmp <= b:
            total += num

    print(total)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

print(x)

Submission status: Accepted

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

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

    if wa >= A and wa <= B:
        cnt += i

print(cnt)

Submission status: Accepted

Solution code:
n,a,b = (int(i) for  i in input().split())
answer = 0
for j in range(1,n+1):
	num = 0
	for j2 in str(j):
		num += int(j2)
	if a<=num and num<=b:
		answer += j
print(answer)

Submission status: Accepted

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

def f(num):
    s = str(num)
    return sum(list(map(int, list(s))))

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ret)

Submission status: Accepted

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

def x(a):
    A = 0
    num = []
    while a != 0:
        num.append(a % 10)
        a //= 10
    num.reverse()
    for i in num:
        A += i
    return A

c = 0

for j in range(n+1):
    if (x(j)>=a)and(x(j)<=b):
        c += j

print(c)

Submission status: Accepted

Solution code:
line = list(map(int, input().split(" ")))
ans = 0
digitsum = 0
for i in range(1, line[0]+1):
    digitsum = i % 10 + (i // 10) % 10 + (i // 100) % 10 + (i // 1000) % 10 + (i // 10000)
    ans += i if line[1] <= digitsum <= line[2] else 0
print(ans)

Submission status: Accepted

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

    ans = 0

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n,a,b = na()
tot = 0
ans = 0
for i in range(1,n+1):
    for j in list(str(i)):
        tot += int(j)
    if a <= tot <= b:
        ans += i
    tot = 0
print(ans)

Submission status: Accepted

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

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

print(ret)

Submission status: Accepted

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

ret = 0
d = [0, 0, 0, 0, 0]
for i in range(1, n+1):
 div = i
 for k in range(5):
  div, d[k] = divmod(div, 10)
 if sum(d)>=a and sum(d)<=b:
  ret += i

print(ret)

Submission status: Accepted

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

ret = 0
for i in range(1, n+1):
 d1 = i%10
 d2 = (i%10**2)//10
 d3 = (i%10**3)//10**2
 d4 = (i%10**4)//10**3
 d5 = i//10**4
 sum = d1+d2+d3+d4+d5
 if sum>=a and sum<=b:
  ret += i

print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

# AtCoder Beginner Contest
# Problem B


def sum_digit(number):
    string = str(number)
    array = list(map(int, list(string)))
    return sum(array)


if __name__ == '__main__':
    N, A, B = list(map(int, input().split()))

    total = 0

    for number in range(1, N + 1):
        if A <= sum_digit(number) <= B:
            total += number

    print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
score = 0
for i in range(N+1):
    i_1 = i % 10
    i_10 = i % 100 // 10
    i_100 = i % 1000 // 100
    i_1000 = i % 10000 // 1000
    i_10000 = i // 10000
    sum_i = i_1 + i_10 + i_100 + i_1000 + i_10000
    if A <= sum_i <= B:
        score += i
print(score)

Submission status: Accepted

Solution code:
N_A_B = map(str,input().split(" "))
list_NAB = list(map(int,N_A_B))
N = list_NAB[0]
A = list_NAB[1]
B = list_NAB[2]


box = []
for i in range(N+1):
	l = [int(j) for j in list(str(i))]
	m = sum(l)

	if A <= m <= B:
		box.append(i)
		sum__ = sum(box)
print(sum__)

Submission status: Accepted

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

ans = 0

for i in range(N + 1):
    num = i
    sum = 0
    while num > 0:
        sum += num % 10
        num = num // 10
    if a <= sum <= b:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
def sumDig(n) :
    s = 0
    for c in str(n) :
        s += (ord(c) - ord('0'))
    return s
N, A, B = list(map(int, input().split()))
ans = 0
for i in range(1, N+1) :
    if A <= sumDig(i) <= B :
        ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
from collections import Counter
import collections
round = lambda x:(x*2+1)//2
a = list(map(float,input().split()))
a = np.array(a)
N = a[0]
A = a[1]
B = a[2]
b = np.array([])
for i in range(int(N+1)):
  l = [int(x) for x in list(str(i))]
  l = sum(l)
  if l >= A and l <= B:
    b = np.append(b,i)
print(int(sum(b)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N, A, B = map(int, input().rstrip().split())
sum_of_integers = 0
for i in range(1, N + 1):
    sum_of_each_digit = sum(list(map(int, (str(i))))) #各桁の和を求める
    if A <= sum_of_each_digit and sum_of_each_digit <= B:
        sum_of_integers += i
print(sum_of_integers)

Submission status: Accepted

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

Submission status: Accepted

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

tot = 0
for i in xrange(1,n+1):
  sn = '%05d' % (i)
  sntot = sum([int(s) for s in sn])
  if(a<=sntot<=b):
    tot += i
print tot

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
ans=0
for i in range(1,N+1):
    tmp=0
    n=i
    for _ in range(5):
        tmp+=n%10
        n//=10
    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):
	number = str(i)
	if A <= sum([int(d) for d in number]) <= B:
		S += i
print(S)

Submission status: Accepted

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

import sys

def main():
    n, a, b = map(int, sys.stdin.readline().split())

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

    print(s)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
g = list(map(int,input().split()))
counter = 0
for i in range(g[0]+1):
    N_ = sum(map(int, list(str(i))))
    if  (N_ >=g[1]) & (N_ <=g[2]):
        counter+=i
    else:
        pass
      
print(counter)

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

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
count=0
for i in range(1,a+1):
  x=i//10000+(i%10000)//1000+(i%1000)//100+(i%100)//10+i%10
  if(x<=c and x>=b):
    count+=i
print(count)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def calc_sum_of_digit(k):
    _sum = 0

    for i in k:
        _sum += int(i)

    return _sum

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

    result = 0
    for i in range(1, N+1):
        sum_of_digit = calc_sum_of_digit(str(i))

        if A <= sum_of_digit <= B:
            result += i

    print(result)


main()

Submission status: Accepted

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

for i in range(1,n+1):
    si = str(i)
    if len(si) == 1:
        s = int(si[0])
    elif len(si) == 2:
        s = int(si[0])+int(si[1])
    elif len(si) == 3:
        s = int(si[0])+int(si[1])+int(si[2])
    else:
        s = int(si[0])+int(si[1])+int(si[2])+int(si[3])

    if a <= s and s <= 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):
    a = i
    sum = 0
    while(a > 0):
        sum += a % 10
        a //= 10
    if(A <= sum and sum <= B):
        ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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:
def sum_ketagoto(n):
    nsum = 0
    while n != 0:
        nsum += n % 10
        n //= 10
    return nsum


def main():
    n, a, b = map(int, input().split())
    nsum = 0
    for j, k in zip(map(lambda i: sum_ketagoto(i), range(1, n + 1)), range(1, n + 1)):
        if a <= j and j <= b:
            nsum += k
    print(nsum)


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):
    t = i
    sum = 0
    while(t > 0):
        sum += t % 10
        t = int(t / 10)
    
    if(a <= sum <= b):
        ans += i
    
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc083/tasks/abc083_b

"""
import sys
from sys import stdin
input = stdin.readline


def digits_sum(N):
    ans = 0
    while N:
        ans += (N % 10)
        N //= 10
    return ans


def solve(N, A, B):
    ans = []
    for i in range(1, N+1):
        d_sum = digits_sum(i)
        if A <= d_sum <= B:
            ans.append(i)
    return sum(ans)


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


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
cnt = 0
def is_cond(n):
	s = 0
	while n > 0:
		s += n % 10
		n //= 10
	return A <= s <= B
print(sum(filter(is_cond, range(1, N + 1))))

Submission status: Accepted

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

total = 0

for n in range(1, N + 1):
    s = sum([int(x) for x in list(str(n))])
    if A <= s <= B:
        total += n

print(total)

Submission status: Accepted

Solution code:
import math
n, a, b = map(int,input().split())
ans = []

for v in range(1,n+1):
    size = int (math.log10(v) + 1)
    if size==1 and a<=v and v<=b:
        ans.append(v)
    else:
        s=0
        strNum=str(v)
        for p in range(len(strNum)):
            s+=int(strNum[p])
        if a<=s and s<=b:
            ans.append(v)

print(sum(ans))

Submission status: Accepted

Solution code:
def digit_sum(x):
  string_x = str(x)
  total = 0
  for char in string_x:
    total += int(char)
  return total
a, b, c = map(int, input().split())

sum=0
for i in range(1,a+1):
    if(digit_sum(i)>=b and digit_sum(i)<=c):
        sum=sum+i

print(sum)

Submission status: Accepted

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

n_sum = 0

for i in range(n):
  order = [int(j) for j in list(str(i+1))]
  if a <= sum(order) <= b:
    n_sum += i + 1
    
print(n_sum)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

sums = 0
for i in range(1, N+1):
    temp_sum = 0
    for j in str(i):
        temp_sum += int(j)
    if A <= temp_sum and temp_sum <= B:
        sums += i
print(sums)

Submission status: Accepted

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



def digits(n):
    while n > 0:
        yield n % 10
        n //= 10

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

    ans = sum(i for i in range(1,N+1) if A <= sum(digits(i)) <= B)
    print(ans)

if __name__ == "__main__": main()

Submission status: Accepted

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

solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def digit_sum(n):
    sum = 0
    for c in str(n):
        sum += int(c)
    return sum

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

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

print(res)

Submission status: Accepted

Solution code:
N, A,B = map(int,input().split(' '))
def conv(x):
    s = str(x)
    i=0
    c0=0
    while i < len(s):
        p = int(s[i])
        c0 += p
        i += 1
    return c0

L = []
for r in range(1,N+1):
    L.append([r,conv(r)])

L2 = [x for x in L if A<=x[1]<=B]
ans=0
for i in range(0,len(L2)):
    ans += L2[i][0]
print(ans)

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
# a, b, c = 20, 2, 5
my_sum = 0
for x in range(1, a + 1):
    # print(x)
    sum1 = 0
    y = x
    while y >= 1:
        sum1 = sum1 + y % 10
        y = y // 10
    # print(x, sum1)
    if c >= sum1 >= b:
        my_sum = my_sum + x
        # print("my sum {}".format(my_sum))
print(my_sum)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
c=[]
for i in range(N+1):
    
    b=0
    a=i
    while (a!=0):
        b+=a%10
        a=int(a/10)
    if A<=b and b<=B:
        c.append(i)
print(sum(c))

Submission status: Accepted

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

ans = 0
for i in range(1,n+1):
    s = 0
    t = i
    while t>0:
        s += t%10
        t = t//10

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

Submission status: Accepted

Solution code:


def someSum(i):
    return sum([ord(c) - 48 for c in "%d"%i])

def foo(n, a, b):
    r = 0
    for i in range(n+1):
        s = someSum(i)
        if a <= s <= b:
            r += i
    return r

if __name__ == "__main__":
    n, a, b = map(int, input().split())
    print(foo(n, a, b))

Submission status: Accepted

Solution code:
# n,a,b = map(int,input().split())
# ans = 0;
# for i in range(1,n+1):
#     sum = 0;
#     x = i;
#     while x:
#         sum += int(x%10);
#         x/=10;
#     if a <= sum <= b:
#         ans+=i;
# print("%d" % (ans) );

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

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
ans = 0;
for i in range(1,n+1):
    sum = 0;
    x = i;
    while x:
        sum += int(x%10);
        x/=10;
    if a <= sum <= b:
        ans+=i;
print("%d" % (ans) );

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
sum = 0
for i in range(1, n + 1):
    c = int(i / 10000)
    d = int(i / 1000) % 10
    e = int(i / 100) % 10
    f = int(i / 10) % 10
    g = i % 10
    if c + d + e + f + g >= a and c + d + e + f + g <= b:
        sum += i
print(sum)

Submission status: Accepted

Solution code:
import numpy as np
import pdb
import copy

def main():
    [N, A, B] = map(int, raw_input().split(' '))
    print mysum(N, A, B)

def mysum(N, A, B):
    sumval = 0
    for k in range(N + 1 ):
        checkval = np.sum(np.array(list(str(k))).astype(int))
        if checkval <= B and checkval >= A:
            sumval += k
    return sumval


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':

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

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

    print(ans)

Submission status: Accepted

Solution code:
N, A, B = map(int, raw_input().split())
def f(x):
    res = 0
    while x > 0:
        res += x % 10
        x /= 10
    return res
ans = 0
for num in range(1, N+1):
    if A <= f(num) <= B:
        ans += num
print ans

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1, N+1):
    str_num = str(i)
    if i < 10:
        if i >= A and i <= B:
            count += i
    elif i < 100:
        sum_num = int(str_num[0]) + int(str_num[1])
        if sum_num >= A and sum_num <= B:
            count += i
    elif i < 1000:
        sum_num = int(str_num[0]) + int(str_num[1]) + int(str_num[2])
        if sum_num >= A and sum_num <= B:
            count += i
    elif i < 10000:
        sum_num = int(str_num[0]) + int(str_num[1]) + int(str_num[2]) + int(str_num[3])
        if sum_num >= A and sum_num <= B:
            count += i
    else:
        if 1 >= A and 1 <= B:
            count += i

print(count)

Submission status: Accepted

Solution code:
N,A,B = input().split()
S = 0
def dsum(n):
    s = str(n)
    array = list(map(int,list(s)))
    return sum(array)

for i in range(1,int(N)+1):
    s = dsum(i)
    if int(A) <= s and s <= int(B):
        S += i
    else:
        continue
print(S)

Submission status: Accepted

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

ans=0

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

print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N, A, B = list(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())

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

res = 0
for d in range(1, N + 1):
    if A <= sum_digits(d) <= B:
        res += d

print(res)

Submission status: Accepted

Solution code:
s = input()
l = s.split()   #スペースで区切る 

N = int(l[0])
A = int(l[1])
B = int(l[2])

def sum(p):
    n4 = p // 10000
    n3 = ( p - n4 * 10000 ) // 1000
    n2 = ( p - ( p // 1000 ) * 1000) // 100
    n1 = ( p - ( p // 100 ) * 100)// 10 
    n0 = p - ( p // 10 ) * 10
    s = n4 + n3 + n2 + n1 + n0
    return s
#print( n4, n3, n2, n1, n0 ) 


S = 0

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

print(S)

Submission status: Accepted

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

limit, lower, upper = map(int, input().split(' '))

sums = 0
for n in range(1, limit + 1):
    order = sum(map(int, list(str(n))))
    if lower <= order <= upper:
        sums += n

print(sums)

Submission status: Accepted

Solution code:
import math

def sumEachDigit(num):
    list = []
    for i in range(1,6):
        list.append(num % 10)
        num = math.floor(num / 10)

    return sum(list)


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

ret = 0
for i in range(1,N+1):
    sumOfEach = sumEachDigit(i)

    if A <= sumOfEach <= B:
        ret += i

print(ret)

Submission status: Accepted

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

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

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

print(ans)