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:
#!/user/bin/env pypy3
import sys
from functools import reduce


def fast_input():
    return sys.stdin.readline()[:-1]


def digit_sum(num: int) -> int:
    str_num = str(num)
    return reduce(
        lambda acc, n: acc + int(n),
        list(str_num),
        0
    )


def solve(n: int, a: int, b: int) -> int:
    num_sum = 0
    for num in range(1, n + 1):
        if a <= digit_sum(num) <= b:
            num_sum += num
    return num_sum


def main():
    [n, a, b] = list(map(int, fast_input().split()))
    result = solve(n, a, b)
    print(result)


main()

Submission status: Accepted

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

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

for i in range(N+1):
    count = FindSomeOfDegit(i)
    if A <= count <= B:
        result += i

print(result)

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, a, b = rm()
ans = 0
for i in range(1, n+1):
    s = sum(map(int, str(i)))
    if a <= s <= 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):
    i = str(i)
    keta = 0
    for j in i:
        keta += int(j)
    if a <= keta <= b:
        res += int(i)

print(res)

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
e = 0
for i in range(a):
  d = i + 1
  f = d
  L = []
  for j in range(len(str(d))):
    q, mod = divmod(f, 10)
    f = q
    L.append(mod)
  if b <= sum(L) and sum(L) <= c:
    e = e + d
print(e)

Submission status: Accepted

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

print(s)

Submission status: Accepted

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

def calc_digit_sum(num):
    sums = 0
    while num > 0:
        sums += num % 10
        num //= 10
    return sums

answer = 0
for num in range(1, n+1):
    sums = calc_digit_sum(num)
    if a <= sums <= b:
        answer += num

print(answer)

Submission status: Accepted

Solution code:
num_list = input().split(' ')
N = int(num_list[0])
A = int(num_list[1])
B = int(num_list[2])
total = 0
for n in range(N+1):
  calc_num = 0
  for s in str(n):
    calc_num += int(s)
  if A <= calc_num <= B:
    total += n
print(total)

Submission status: Accepted

Solution code:
[a,b,c] = [int(i) for i in input().split(" ")]
goukei = 0
for i in range(1,a+1):
  kurainowa = 0
  kisuu = [int(k) for k in list(str(i))]
  
  for j in range(0,len(kisuu)-1+1):
    kurainowa = kurainowa + kisuu[j]
  if kurainowa < c+1 and b-1 <kurainowa :
    goukei = goukei + i
print(goukei)

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, A, B = map(int, readline().split())
    ans = 0
    for i in range(1, N + 1):
        ns = str(i)
        s = 0
        for c in ns:
            s += int(c)
        if A <= s <= B:
            ans += i

    print(ans)


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 = str(i)
    T_sum = 0
    for t in T:
        T_sum += int(t)
    if A <= T_sum <= B:
        ans += i
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(sum(l))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b=map(int, input().split())
su=0
for i in range(n+1):
  keta=sum(list(map(int, str(i))))
  if a<=keta<=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):
  d_num = i
  s_sum = 0
  while d_num > 0:
    s_sum += (d_num % 10)
    d_num //= 10
  
  if A <= s_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):
  count=0
  for j in str(i):
    count+=int(j)
  if a<=count<=b:
    ans+=i
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 0
cnt = 0
for i in range(a, n+1):
    res = 0
    num = i
    while num > 0:
        res += num % 10
        num //= 10

    if res >= a and res <= 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):
  m=len(str(i))
  res=0
  for j in range(m):
    res+=int(str(i)[j])
  if a<=res<=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):
  ans=0
  i=str(i)
  for j in range(len(i)):
    x=int(i[j])
    ans+=x
  if a<=ans<=b:
    i=int(i)
    cnt+=i
    

print(cnt)

Submission status: Accepted

Solution code:
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
d=0
for i in range(1,a+1):
  if b<=(i//10000+(i//1000-(i//10000)*10))+(i//100-(i//1000)*10)+(i//10-(i//100)*10)+(i//1-(i//10)*10)<=c:
    d=d+i
print(d)

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
for i in range(1, n+1):
    s = str(i)
    tot = 0
    for c in s:
        tot += ord(c) - ord('0')
    if tot >= a and tot <= b:
        ans += i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# vim: fileencoding=utf-8


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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# 2020-08-30, Sun

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

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

print(ans)

Submission status: Accepted

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

result = 0

for x in range(1, n+1):
  if a <= sum(map(int, str(x))) <= b:
    result += x

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

sum = 0
for i in range(1, N+1):
    num = i
    val = 0
    while True:
        val += num % 10
        if num // 10 > 0:
            num = num // 10
        else:
            break
    if A <= val <= B:
        sum += i
print(sum)

Submission status: Accepted

Solution code:
def SumReturn(num):
    total=0
    while num!=0:
        total += num%10
        num //= 10
        
    return total

if __name__ == '__main__':
    
    n, a, b = map(int, input().split())
    
    sum = 0
    
    for i in range(1, n+1):
        
        if SumReturn(i)>=a and SumReturn(i)<=b:
            sum += i
            
    print(sum)

Submission status: Accepted

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

result = 0
for i in range(1, n + 1):
    number = i
    sum_of_digits = 0
    while number > 0:
        sum_of_digits += (number % 10)
        number //= 10
    if a <= sum_of_digits <= b:
        result += i

print(result)

Submission status: Accepted

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


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

N, A, B = map(int, input().split())
result = 0
for n in range(1, N+1):
    if A <= calc_sum_digits(n) <= B:
        result += n
print(result)

Submission status: Accepted

Solution code:
def calc_sum_digits(n):
    return sum(int(x) for x in str(n))

N, A, B = map(int, input().split())
print(sum(n if A <= calc_sum_digits(n) <= B else 0 for n in range(1, N+1)))

Submission status: Accepted

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

N, A, B = map(int, input().split())
result = 0
for n in range(1, N+1):
    sumdigit = calc_sum_digits(n)
    if sumdigit >= A and sumdigit <= B:
        result += n
print(result)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# 別解：10で割った余りを足していく
ans = 0
for n in range(1, N+1):
  s = 0
  m = n
  while m > 0:
    s += m % 10
    m = m // 10
  if A <= s and s <= B: ans += n
    
print(ans)

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 and s <= B: ans += n
    
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
nab = [int(s) for s in input().split()]

N = nab[0]
A = nab[1]
B = nab[2]

count = 0
for i in range(N):
  target = str(i+1)
  total = 0
  for j in range(len(target)):
    total = total + int(target[j])

  if total >= A and total <= B:
    count = count + int(target)

print(count)

Submission status: Accepted

Solution code:
input_line = input()
x, y, z = map(str, input_line.split())

resultNum = 0

for i in range(int(x)+1):
  loopCnt = len(str(i))
  addNum = 0
  for j in range(loopCnt):
    addNum += int(str(i)[j])
  if int(y) <= addNum <= int(z):
    resultNum += i

print(resultNum)

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,str(i)))<=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 = str(i)
    sum = 0
    for c in s:
        sum += int(c)
    if sum >= A and sum <= B:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
ans=0
for i in range(1,N+1):
    if A<=sum(map(int,str(i)))<=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):
  d5, mod = divmod(n,10**4)
  d4, mod = divmod(mod,10**3)
  d3, mod = divmod(mod,10**2)
  d2, mod = divmod(mod,10)
  d1 = mod
  s = d1 + d2 + d3 + d4 + d5
  if A <= s <= B:
    sum += n

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(result)

Submission status: Accepted

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

N, A, B = map(int, input().split())
result = 0
for n in range(1, N+1):
    sum = calc_sum_digits(n)
    if sum >= A and sum <= B:
        result += n
print(result)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
c = 0
for i in range(1,n+1):
    if i < 10:
        x = str(i)
        xsum = int(x[0])
        if xsum >= a and xsum <= b:
            c += i
    elif i < 100:
        x = str(i)
        xsum = int(x[0]) + int(x[1])
        if xsum >= a and xsum <= b:
            c += i
    elif i < 1000:
        x = str(i)
        xsum = int(x[0]) + int(x[1]) + int(x[2])
        if xsum >= a and xsum <= b:
            c += i
    elif i < 10000:
        x = str(i)
        xsum = int(x[0]) + int(x[1]) + int(x[2]) + int(x[3])
        if xsum >= a and xsum <= b:
            c += i
    else:
        x = str(i)
        xsum = int(x[0]) + int(x[1]) + int(x[2]) + int(x[3]) + int(x[4])
        if xsum >= a and xsum <= b:
            c += i
print(c)

Submission status: Accepted

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

Submission status: Accepted

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

sum_numbers = 0

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

Submission status: Accepted

Solution code:
# coding= utf-8
abN=input("")
nab=abN.split(" ")
rn=int(nab[0])
ra=int(nab[1])
rb=int(nab[2])
p=[int(s+1) for s in range(rn)]
def counting(s):
    if s<10:
        if ra<=s<=rb:
            return s
    if 10<=s<100:
        s=str(s)
        w10=int(s[0:1])
        w1=int(s[1:2])
        s=int(s)
        ww=w10+w1
        if ra<=ww<=rb:
            return s
    if 100<=s<1000:
        s=str(s)
        w100=int(s[0:1])
        w10=int(s[1:2])
        w1=int(s[2:3])
        s=int(s)
        ww=w100+w10+w1
        if ra<=ww<=rb:
            return s
    if 1000<=s<10000:
        s=str(s)
        w1000=int(s[0:1])
        w100=int(s[1:2])
        w10=int(s[2:3])
        w1=int(s[3:4])
        s=int(s)
        ww=w1000+w100+w10+w1
        if ra<=ww<=rb:
            return s
    if 10000==s:
        if ra<=1<=rb:
            return s
    else:
        return 0
r=map(counting,p)
g=list(r)
print(sum(g))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import numpy as np
                                                               
def ketawa(x):
    return sum(list(map(int, str(x))))
                                                               
N, A, B = map(int, input().split())
new_func = np.frompyfunc(ketawa, 1, 1)
arr = np.arange(1, N + 1)
result = new_func(arr)
print(np.sum(np.where((A <= result) & (result <= B), arr, 0)))

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1,n+1):
    m = str(i)
    x = len(m)
    cnt = 0
    for j in range(x):
        cnt = cnt + int(m[j])
    if a <= cnt <= b:
        ans = ans + i
    else:
        continue
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

ans = 0
for i in range(1,N+1):
    a = int(i/10000)%10
    b = int(i/1000)%10
    c = int(i/100)%10
    d = int(i/10)%10
    e = i%10
    
    if A<=a+b+c+d+e and a+b+c+d+e<=B:
        ans += i
        
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

res = 0
for n in range(1,N+1):
    tmp = sum([int(x) for x in str(n)])
    if tmp>=A and tmp<=B:
         res += n
print(res)

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
Z=0
for i in range(1,N+1):
  X=0
  Y=i
  for j in range(5):
    X+=Y%10
    Y//=10
  if A<=X and X<=B:
    Z+=i
print(Z)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1,n+1):
    num=i
    re=0
    while num>0:
        re+=num%10
        num//=10
    if a<=re<=b:
        ans_list.append(i)

print(sum(ans_list))

Submission status: Accepted

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

Submission status: Accepted

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

r_sum = 0
for i in range(1, N+1):
  sum_digit = 0
  n_str = str(i)
  for j in range(len(n_str)):
    sum_digit += int(n_str[j])
  if A <= sum_digit and sum_digit <= B:
    r_sum += i
print(str(r_sum))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, A, B= list(map(int, input().split()))
ans = 0
digsum = 0
for i in range(1,N+1):
  if i<10:
    digsum = i
  elif i <100:
    dig1 = i%10
    dig2 = ((i%100)-dig1)/10
    digsum = dig1 + dig2
  elif i < 1000:
    dig1 = (i%10)
    dig2 = ((i%100)-dig1)/10
    dig3 = i//100
    digsum = dig1 + dig2 + dig3
  elif i < 10000:
    dig1 = (i%10)
    dig2 = ((i%100)-dig1)/10
    dig3 = ((i%1000) - dig2*10 - dig1)/100
    dig4 = i//1000
    digsum = dig1 + dig2 + dig3 + dig4
  else:
    digsum = 1
  if (digsum>=A) and (digsum<=B):
    ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 1 以上 N 以下の整数のうち、10 進法での各桁の和が A 以上 B 以下であるものの総和を求めてください。
n, a, b = [int(x) for x in input().split()]
total = 0

def digit_sum(num,digitotal = 0):
      while(num > 0):
            digitotal += num%10
            num //= 10
      return digitotal
      
for i in range(1,n+1):
      x = digit_sum(i)
      if x >= a and x <= b:
            #print(i,end=", ")
            total += i

print(total)

Submission status: Accepted

Solution code:
def digitsum(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):
  if a<=digitsum(i) and b>=digitsum(i):
    ans+=i
print(ans)

Submission status: Accepted

Solution code:
def digit_sum(x): 
    y = str(x) 
    y_len = len(y) 
    ans = 0
    for j in range(y_len):
        ans += int(y[j]) 

    return ans

answer=0
n,a,b = map(int,input().split()) 
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(int, input().split())
ans = 0
lis = []

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

total=0
for n in range(1,N+1):
    if A<=sum_keta(n)<=B:
        total+=n
    else:
        continue

print(total)

Submission status: Accepted

Solution code:
from functools import reduce

n,a,b = map(lambda x:int(x),input().split(" "))

ans = 0
for ni in range(a,n+1):
    add_each_dig = int(reduce(lambda x, y: int(x) + int(y), str(ni) ))
    if a <= add_each_dig and add_each_dig <= b:
        ans += ni

print(ans)

Submission status: Accepted

Solution code:
from functools import reduce

n,a,b = map(lambda x:int(x),input().split(" "))

ans = 0
for ni in range(a,n+1):
    if ni <= 9 :
        if a <= ni and ni <= b:
            ans += ni
    else:
        add_each_dig = reduce(lambda x, y: int(x) + int(y), str(ni) )
        if a <= add_each_dig and add_each_dig <= b:
            ans += ni

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
ans = 0
def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)
for i in range(1, n+1):
    if a <= digitSum(i) <= b:
        ans += i
print(ans)

Submission status: Accepted

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

def find_of_digits(num):
    sum = 0
    while num>0:
        sum += num % 10
        num //= 10

    return sum

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

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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

Submission status: Accepted

Solution code:
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    n, a, b = [int(x) for x in input().rstrip().split(" ")]
    ans = 0
    for i in range(1, n+1):
        x = sum([int(c) for c in str(i)])
        if x >= a and x <= b:
            ans += i

    print(ans)


if __name__ == "__main__":
    resolve()

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(len(str(i))):
        s += int(str(i)[j])
    if A <= s <= B:
        ans += i
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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


def main():
    args = input().split()
    N = int(args[0])
    A = int(args[1])
    B = int(args[2])

    counter = 0
    for i in range(1, N + 1):
        sumValue = sum(list(map(lambda x: int(x), list(str(i)))))
        if sumValue >= A and sumValue <= B:
            counter += i

    print(counter)


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):
    if a <= sum(list(map(int, str(i)))) <= b:
        ans += i
print(ans)