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())
 
ans = 0
for i in range(n+1):
    if a <= i//10000 + i//1000%10 + i//100%10 + i//10%10 + i%10 <= 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
    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())

ans = 0

for n in range(1, N+1):
    mn = str(n)
    lst_n = list(mn)
    sum = 0
    for i in range(len(lst_n)):
        sum += int(lst_n[i])
    if (sum >= A) and (sum <= B):
        ans += n

print(ans)

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

Submission status: Accepted

Solution code:
import math

def main():
    n, a, b = map(int, input().split())
    ans = 0
    for i in range(1, n + 1):
        data = list(map(int, list(str(i))))
        if a <= sum(data) <= 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):
    I = str(i)
    sum_i = 0
    for j in range(len(I)):
        sum_i += int(I[j])

    if A <= sum_i <= B:
        ans += i

print(ans)

Submission status: Accepted

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

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

def solve(N: int, A: int, B: int):
    ret = 0
    for i in range(1, N + 1):
        if A <= sum_dig(i) <= B:
            ret += i
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [input() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,A,B = MI()
    ans = 0
    def digit_sum(n):
        l = list(str(n))
        s=0
        for i in l:
            a = int(i)
            s+=a
        return s

        
    for i in range(1, N + 1):
        if A <= digit_sum(i) <= 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):
  sum = 0
  for s in str(i):
    sum += int(s)
  if A <= sum and sum <= 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):
  isum = 0
  m = i
  while m != 0:
    isum += m%10
    m = m//10
  if a <= isum <= b:
    num += i
print(num)

Submission status: Accepted

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

def add(n,a,b):
    ls = list(str(n))
    pl = sum([int(i) for i in ls])
    if a<= pl and pl<= b:
        return n
    else:
        return 0

flg = 0
for i in range(n+1):
    flg += add(i,a,b)

print(flg)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
input_nums = input().split()
n = int(input_nums[0])
a = int(input_nums[1])
b = int(input_nums[2])

total = 0

for num in range(1, n+1):
    num_list = list(str(num))
    num_list_int = [int(i) for i in num_list]
    num_list_sum = sum(num_list_int)
    if num_list_sum >= a:
        if num_list_sum <= b:
            total += num
            
print(total)

Submission status: Accepted

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

l = []
for num in range(1, n+1):
  total = 0
  for c in str(num):
    total = total + int(c)
  if total >= a and total <= b:
    l.append(num)

print(sum(l))

Submission status: Accepted

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


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

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

    print(answer)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
 k=i//10000+i//1000%10+i//100%10+i//10%10+i%10
 if a<=k<=b:
  ans+=i
print(ans)

Submission status: Accepted

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

memo = [0]*37

def S(n):
  if n<10:
    return n
  return n%10+S(n//10)

for n in range(1,N+1):
  memo[S(n)] += n

answer = sum(memo[A:B+1])
print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B = list(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 = list(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 = list(map(int,input().split(" ")))
 
def check(n,c):
    c+=n%10
    return (c if n/10==0 else check(int(n/10),c))
 
print(sum([i for i in range(1,N+1) if A<=check(i,0)<=B]))

Submission status: Accepted

Solution code:
def some_sums(n):
  answer = 0
  a = n // 10
  if a > 0:
    answer = some_sums(a)
  b = n % 10
  answer = answer + b
  return answer

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

some_sums_list = [some_sums(i+1) for i in range(N)]
answer_list = [i+1 for i in range(N) if some_sums_list[i]>=A and some_sums_list[i]<=B]
answer = sum(answer_list)
print(answer)

Submission status: Accepted

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

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

    ans = 0
    for i in range(1, N+1):
        keta_sum = 0
        num = i
        while True:
            if num == 0:
                break
            keta_sum += num%10
            num = num//10

        if keta_sum >= A and keta_sum <= B:
            ans += i
    
    print(ans)

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

ans = 0
for i in range(1, N+1):
    d1 = i % 10
    d1 += (i % 100) // 10
    d1 += (i % 1000) // 100
    d1 += (i % 10000) // 1000
    d1 += (i % 100000) // 10000
    if A <= d1 <= B:
        ans += i

print(ans)

Submission status: Accepted

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

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

total = 0

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

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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


num = 0
for i in range(1, N + 1):
    s = 0
    tmp = i
    while True:
        if i == 0:
            break
        s += i % 10
        i = int(i / 10)
    if A <= s and s <= B:
        num += tmp

print(num)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
ans = 0
for c in range(10):
    for i in range(10):
        for j in range(10):
            for k in range(10):
                for l in range(10):
                    if c*10000 + i*1000 + j*100 + k*10 + l <= n and c + i + j + k + l >= a and c + i + j + k + l <= b:
                        ans = ans + c*10000 + i*1000 + j*100 + k*10 + l
print(ans)

Submission status: Accepted

Solution code:
d=list(map(int,input().split()))
n,a,b=d[0],d[1],d[2]
alist=[]
for x in range(1,n+1):
    if x==10000:
        if 1>=a and 1<=b:
            alist.append(x)
    else:
        f=x%1000
        e=int((x-f)/1000)
        h=f%100
        g=int((f-h)/100)
        j=h%10
        i=int((h-j)/10)
        wa=e+g+i+j
        if wa>=a and wa<=b:
            alist.append(x)

print(sum(alist))

Submission status: Accepted

Solution code:
from sys import stdin
N,A,B=[int(x) for x in stdin.readline().rstrip().split()]
ans=0
for i in range(1,N+1):
    digit = list(map(int,str(i)))
    if A <= sum(digit) and sum(digit) <= B:
        ans+=i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
# import statistics
import bisect
import copy
import fractions
import math
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
def unite(x, y):
    # それぞれのノードの根を求める
    x = root(x)
    y = root(y)
    if x == y:
        return
    # node[x]の根をyに変更する
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  # xが根の場合
        return x
    else:
        node[x] = root(node[x])  # 経路圧縮
        return node[x]
def dfs(v):
    # ノードに訪れた
    visited[v] = True
    for v2 in range(n):
        if graph[v][v2] == False:  # そもそもvとv2が辺でつながっていない
            continue
        if visited[v2] == True:  # もう見た
            continue
        dfs(v2)


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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1,N+1):
        digits_sum = 0
        for j in str(i):
            digits_sum += int(j)
        if A <= digits_sum <= B:
            number.append(i)
for k in range(len(number)):
    sum += number[k]

print(sum)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding:utf-8

L = list(map(int,input().split()))
l =[]
cnt = 0

for i in range(int(L[0]+1)):
      l = [int(x) for x in list(str(i))]
      S = sum(l)
      if L[1] <= S <= L[2]:
              cnt += i

print(cnt)

Submission status: Accepted

Solution code:
n, a, b = list(map(int, input().split()))
result = 0
for i in range(1, n+1):
  total = 0
  t = i
  for j in range(5):
    total += t%10
    t = t // 10
  if a <= total <= b:
    result += i
print(result)

Submission status: Accepted

Solution code:
num1, num2, num3 = [int(i) for i in input().split()]
sum1 = 0

for index1 in range(num1+1):
    d1 = int(index1/ 10000)
    d2 = int(int(index1%10000)/1000)
    d3 = int(int(int(index1%10000)%1000)/100)
    d4 = int( int(int(int(index1%10000)%1000)%100)/10)
    d5 = index1%10

    if (d1+d2+d3+d4+d5) >= num2 and (d1+d2+d3+d4+d5) <= num3:
        sum1 += index1

print(sum1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
ans = 0
for i in range(N+1):
	sum = i % 10 + (i % 100)//10 + (i % 1000)//100 + (i % 10000)//1000 + i//10000
	if A <= sum <= B:
		ans += i
print(ans)

Submission status: Accepted

Solution code:
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N,A,B = (int(_) for _ in input().split())
    ans = 0
    for i in range(N+1):
        digit_sum = sum((int(_) for _ in list(str(i))))
        if digit_sum >=A and digit_sum<=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(n + 1):
    if a <= sum(list(map(int, list(str(i))))) <= b:
        ans += i

print(ans)

Submission status: Accepted

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

sum = 0
for i in range(n+1):
  d_sum = 0
  for d in str(i):
    d_sum += int(d)
  if a <= d_sum <= b:
    sum += i

print(sum)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

def digit_sum(num):
    sum = 0
    i = 1
    while num > 0:
        mod = num % (10**i)
        num = int(num / (10**i))
        sum += mod
    return sum

sum = 0
for i in range(n):
    t = digit_sum(i+1)
    if (t >= a) and (t <= b):
        sum += i+1
print(sum)

Submission status: Accepted

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

for num in range(1, n + 1):
  sum_num = 0
  for c_num in str(num):
    sum_num += int(c_num)
  if sum_num >= a and sum_num <= b:
    sum += num
    
print(sum)

Submission status: Accepted

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

c=0
for x in range(1,N+1):
  y=list(str(x))

  # 各桁の和を求める
  z=sum([int(a) for a in y])

  # 各桁の和がA以上B以下なら加算
  if A<=z and z<=B:
    c+=x

# 出力
print(c)

Submission status: Accepted

Solution code:


def kakuketawa(num: int):
    return sum(list(map(int, list(str(num)))))


if __name__ == '__main__':
    N, A, B = map(int, input().split())
    # N, A, B = 100, 4, 16
    s = 0
    for i in range(N):
        if A <= kakuketawa(i + 1) <= B:
            s += i + 1
    print(s)

Submission status: Accepted

Solution code:
#Some Sums
x = input()
x = x.split(" ")
sum = 0
plo = [int(s) for s in x]
for i in range(1,plo[0] + 1):
    cnt = 0
    num = list(str(i))
    inte = [int(s) for s in num]
    for j in range(len(inte)):
        cnt += inte[j]
    if(cnt >=plo[1] and cnt <= plo[2]):
        sum += i
print(sum)

Submission status: Accepted

Solution code:
def sum(n):
    num = 0
    while True:
        num += int(n%10)
        n = int(n/10)
        if n == 0:
            break
    return num

def main():
    N,A,B = [int(_) for _ in input().split(" ")]
    sum_num = 0

    for n in range(1, N+1):
        num = sum(n)

        if num >= A and num <= B:
            sum_num += n

    print(sum_num)

main()

Submission status: Accepted

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

total = 0
for i in range(N + 1):
    if A <= sum([int(s) for s in str(i)]) <= B:
        total += i

print(total)

Submission status: Accepted

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

c = 0
for _n in range(n+1):
  s = 0
  temp_n = _n
  for i in reversed(list(range(0,5))):
    m = _n // (10**i)
    s = s + m
    _n = _n - m * (10**i)
  if (s >= a and s <= b):
    c = c + temp_n
    
print("{}".format(c))

Submission status: Accepted

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


def f(x):
	return [int(i) for i in str(x)]

for i in range(n+1):
	s+= i if a<=sum(f(i))<=b else 0

print( s)

Submission status: Accepted

Solution code:

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


ans = 0
for i in range(1,n+1):

    si = str(i)
    total = 0
    for se in si:

        total += int(se)

    ans += i if a<=total and total <= b else 0
    #    print(ans)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(answer)

Submission status: Accepted

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



Sum = 0

for i in range(1, N + 1):
	Y = i
	Judge = 0

	while Y >= 1:
		Judge += Y % 10	#10で割った余り、512の場合は2、2の場合は2
		Y = int(Y // 10)	#10で割った商、512の場合は51、2の場合は0
		

	if A <= Judge and Judge <= B:
		Sum += i


print(Sum)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1, n+1):
  tmp = map(int, list(str(i)))
  v = sum(tmp)
  if v >= a and v <= b:
    res += i

print(res)

Submission status: Accepted

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

array = []
for i in range(n+1):
    wa = 0
    for s in str(i):
        wa += int(s)
    if a<=wa and b>=wa: array.append(i)
print(sum(array))

Submission status: Accepted

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

array = []
for i in range(n+1):
    wa = 0
    for s in str(i):
#        if int(s)>b: break
        wa += int(s)
    if a<=wa and b>=wa: array.append(i)
print(sum(array))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
[n,a,b] = [int(i) for i in input().split()]
cnt = 0
for i in range(1,n+1):
  t = i
  s = 0
  while t != 0:
    s += t % 10
    t //= 10
  if s >= a and s <= b:
    cnt += i
print(cnt)

Submission status: Accepted

Solution code:
N,A,B=[int(i) for i in input().split()]
i,n=1,0
while i<=N:
  x=i%10+i//10%10+i//100%10+i//1000%10+i//10000
  if (x>=A) and (x<=B):n+=i
  i+=1
print(n)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c, d = LI()
    a += b
    c += d
    ans = ["Left", "Right"]
    if a == c:
        print("Balanced")
        return
    print(ans[a < c])
    return

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

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    B()

Submission status: Accepted

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

num = [i for i in range(1,N+1)]
li = [sum(list(map(int, str(i)))) for i in range(1,N+1)]

result = 0
for i, j in zip(num, li):
    result += i if (j>=A and j <= B) else 0
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 入力割り当て
N, A, B = map(int, input().split())

# 変数割り当て
n = 0
sum = 0

# nをNまでインクリメントし繰り返し処理
for n in range(N+1):
	# 各桁の和
	m = n//10000 + n%10000//1000 + n%1000//100 + n%100//10 + n%10
	if A <= m:
		if m <= B:
			# nの各桁がA以上B以下ならsumに加算
			sum += n
# nをインクリメント
n +=1

# 結果の表示
print(sum)

Submission status: Accepted

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

ans = 0
for i in range(1, n+1):
    d_sum = sum([int(tar) for tar in str(i)])
    if a <= d_sum <= 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):
  c = 0
  for j in str(i):
    c += int(j)
  # print(c)
  if A <= c and c <= 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_sum = sum([int(tar) for tar in str(i)])
    if d_sum >= a and d_sum <= b:
        ans += i

print(ans)

Submission status: Accepted

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

choku = []
lst=[]
for i in range(n):
    l= [int(x) for x in list(str(n))]
    x = sum(l)
    if x >= a and x <= b:
        choku.append(n)
    n -= 1
print(sum(choku))

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(n+1):
    t = sum(list(map(int, str(i))))
    if t >= a and t <= 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):
    nn = list(str(i))
    count = 0
    for j in nn:
        count += int(j)
    if a <= count <= b:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
c=[]
for i in range(N+1):
    s=list(str(i))
    a=0
    for k in s:
        a+=int(k)
    if A<=a<=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):
  wa = sum(map(int,tuple(str(i))))
  if wa >= a and wa <= 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):
    x=sum(list(map(int,[n_ for n_ in str(i)])))
    if x>=a and x<=b:
        cnt += i
print(cnt)

Submission status: Accepted

Solution code:
n,a,b = map(lambda x:int(x),input().strip().split())
res = []

for i in range(1,n+1):
    tmp = sum(list(map(lambda x:int(x),list(str(i)))))
    if tmp>=a and tmp<=b:
        res.append(i)
print(sum(res))

Submission status: Accepted

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


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

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

Submission status: Accepted

Solution code:
def ipt(N=0,switch=0):
    if N == 0:
        return list(map(int,input().split()))
    else:
        if switch==0:
            return [list(map(int,input().split())) for _ in range(N)]
        else:
            return [int(input()) for _ in range(N)]

n,a,b=ipt()

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

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    N, A, B = [int(x) for x in stdin.readline().rstrip().split()]
    total = 0
    for i in range(1, N + 1):
        sum_ = sum([int(x) for x in str(i)])
        if A <= sum_ <= B:
            total += i
    print(total)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

def sumofDigits(num):
    sumDigits = 0
    for j in range(len(num)):
        sumDigits += int(num[j])
    return sumDigits

total_sumDigits = 0

for i in range(1,N+1):
    if A <= sumofDigits(str(i)) <= B:
        total_sumDigits += i

print(total_sumDigits)

Submission status: Accepted

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

def sum(k):
  s = 0
  for j in range(len(k)):
    s+=int(k[j])
  return s

for i in range(1,n+1):
  if a<=sum(str(i))<=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):
    if a<=sum(map(int,str(i)))<=b:
        cnt+=i
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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