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):
    check = 10000
    keta_wa = 0
    x = i
    while x != 0:
        keta_wa += int(x / check)
        x = x % check
        check /= 10
        #print(keta_wa,check,x)
    
    if a <= keta_wa and keta_wa <= 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):
    L=[int(i) for i in list(str(i))]
    x=sum(L)
    if a<=x<=b:
        ans+=i
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
n , a , b = map(int , input().split())
total = 0
ans = 0
for i in range(1 , 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


def somesum(x):
    total = 0
    while x > 0:
        total += x % 10
        x = x // 10
    return total


for i in range(N + 1):
    total = somesum(i)
    if total >= A and total <= B:
        ans += i

print(ans)

Submission status: Accepted

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

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

    return count

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#定石の商と剰余でやってみた

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    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)

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 = str(i)
  i_len = len(i_str)
  sum = 0
  for j in range(i_len):
    sum += int(i_str[j])
  if sum >= A and sum <= B:
    ans += i
    
print(ans)

Submission status: Accepted

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

# print(n, a, b)

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
def s(x):
    ans=0
    while True:
        ans+=x%10
        x=(x-x%10)/10
        if x==0:
            break
        
    return int(ans)

n,a,b=map(int,input().split())
    
count=0
    
for i in range(n):
    
    c=s(i+1)

    if a<=c<=b:
        count+=i+1
        
print(count)

Submission status: Accepted

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

count=0

for i in range(n):
    k=0 
   
    for j in str(i+1):
        k+=int(j) 
        
    if a<=k<=b:
        count+=i+1
       
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

X = []
for i in range(a, n + 1):
    c = 0
    for j in str(i):
        c = c + int(j)
    
    if a <= c and c <= b:
        X.append(i)

print(sum(X))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from collections import Counter
def resolve():
    N,A,B=pin()
    cnt=0
    for i in range(1,N+1):
        temp=str(i)
        sum=0
        for s in str(i):
            sum+=int(s)
        
        if A<=sum and sum<=B:
            #print(sum)
            cnt+=i
    print(cnt)
#%%submit!
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

s = 0
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
s = input().split()

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

count = 0

for i in range(1,n+1):
    s = list(str(i))
    g = 0
    for stri in s:
        g += int(stri)
    if g >= a and g <= b:
        count += i

print(count)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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:
A,B,C = list(map(int,input().split()))
ans =0
for i in range(1,A+1):
    D = list(str(i))
    D = list(map(int,D))
    D = sum(D)
    if B <= D <= C:
        ans +=i
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

total = 0
for num in range(1, n + 1):
    digit_5 = num // 10000 % 10
    digit_4 = num // 1000 % 10
    digit_3 = num // 100 % 10
    digit_2 = num // 10 % 10
    digit_1 = num % 10
    digits = (digit_5, digit_4, digit_3, digit_2, digit_1)

    if a <= sum(digits) <= b:
        total += num

print(total)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
ans = 0
for i in range(1, N+1):
  n = i
  t = 0
  for j in range(1, 6):
    t += n % 10 
    n = n // 10

  if A <= t <= 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):
  n = i
  t = 0
  while n > 0:
    t += n % 10 
    n = n // 10

  if A <= t <= 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):
    l = list(str(i))
    keta = 0
    for ll in l:
        keta += int(ll)
    if a <= keta and keta <= b:
        ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def cal_digit_sum(x):
    res = 0
    for digit_val in str(x):
        res += int(digit_val)
    return res


def main():
    n, A, B = map(int, input().split())
    res = 0
    for i in range(1, n+1):
        res = res + (i if cal_digit_sum(i) >= A and cal_digit_sum(i) <= B else 0)
    
    print(res)

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):
    tmp = sum([int(x)for x in list(str(i))])
    if tmp >= a and tmp <= b:
        ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
nn, min, max = map(int, input().split())
y = 0
for number in range(nn + 1):
  if min <= sum(int(n) for n in str(number)) <= max:
    y += number
print(y)

Submission status: Accepted

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

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

Submission status: Accepted

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

import fractions
import copy
import bisect
import math
import numpy as np
import itertools
from itertools import combinations_with_replacement
#import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
from operator import itemgetter
from sys import stdin
#input = sys.stdin.readline#こっちの方が入力が早いが使える時に使っていこう
from operator import mul
from functools import reduce
from collections import Counter
#from collections import deque

#input = stdin.readline


j=0
k=0
n=3
r=1
a=[0]
#n=int(input())
#r=int(input())
#print(M)
#A=int(input())
#B=int(input())
#print(N)
"1行1つの整数を入力を取得し、整数と取得する"


#number_list=list(map(int, input().split(" ")))#数字の時
#print(number_list)
"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#メモ
for i in number_list:#こっちの方がrage使うより早いらしい
    print(number_list[i-1])#

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''
x=[]
y=[]
for i in range(N):
    x1, y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
print(x)
print(y)
"複数行に2数値を入力する形式 x座標とy座標を入力するイメージ"
'''

'''
mixlist=[]
for i in range(N):
    a,b=input().split()
    mixlist.append((int(a),b))
print(mixlist)
"複数行にintとstrを複合して入力するやつ，今回はリスト一つで処理している"
'''

'''
#array=[input().split()for i in range(N)]
#print(type(array[0][0]))
#print(array)
"正方行列にstr型の値を入力"
'''

#brray=[list(map(int, input().split(" ")))for i in range(N)]
#print(type(brray[0][0]))
#print(brray)
'''
入力
1 2
4 5
7 8
出力結果
[[1, 2], [4, 5], [7, 8]]
'''
"列数に関して自由度の高いint型の値を入力するタイプの行列"
#以下に別解を記載
#N, M = [int(i) for i in input().split()]
'''
table = [[int(i) for i in input().split()] for m in range(m)]

print(type(N))
print(N)
print(type(M))
print(M)

print(type(table))
print(table)
'''




#s=input()
#a=[int(i) for i in s]
#print(a[0])
#print([a])
#単数値．桁ごとに分割したい．入力と出力は以下の通り
#イメージとして1桁ごとにリストに値を入れているかんじ
#intを取ると文字列分解に使える
'''
入力
1234
出力
1
[[1, 2, 3, 4]]
'''




'''
word_list= input().split(" ")
print(word_list[0])
"連続文字列の入力"
"qw er ty とかの入力に使う"
"入力すると空白で区切ったところでlistの番号が与えられる"
'''



'''
A, B, C=stdin.readline().rstrip().split()#str style 何個でもいけることが多い
print(A)
"リストではなく独立したstr型を入れるなら以下のやり方でOK"
'''


#a= stdin.readline().rstrip()
#print(a.upper())
"aという変数に入っているものを大文字にして出力"


#a,b=map(int, input().split())  #int style 複数数値入力　「A B」みたいなスペース空いた入力のとき

#なんかうまく入力されるけど
#a=[[int(i) for i in 1.strip()]for 1 in sys.stdin]
#a = [[int(c) for c in l.strip()] for l in sys.stdin]]
#print(a)
#複数行の数値を入力して正方行列を作成


##############################################################################################
##############################################################################################
#under this line explains example calculation



'''
コンビネーションの組み合わせの中身を出力する形式
for i in itertools.combinations(brray, 2)
combinationsをpermutationsにすれば順列になる
今回なら(abc133B)
入力
1 2
5 5
-2 8
出力
[[1, 2], [5, 5], [-2, 8]]
もちろん一次元リストでも使えるし
何よりiもリストのように使えるので便利
'''

#nCr combination
'''
def cmb(n,r):
    #When n < r , this function isn't valid
    r= min(n-r,r)
    #print(n,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n-r, -1))
    #flochart mul(n,n-1)=x
    #next     mul(x,n-2)........(n-r+1,n-r)
    #mul read a,b and returns a*b

    under = reduce(mul, range(1, r+1))
    #print(over, under)
    #reduce is applied mul(1,2)=2
    #next   mul(2,3)=6
    #next   mul(6,4)=4.........last(r!,r+1)=r+1!

    return over // under
    #// is integer divide
    #calc example 5C2
    #over=5*4*3
    #under=3*2*1
a = cmb(n, r)
#print(a)
'''

'''
import itertools
from itertools import combinations_with_replacement

combinationについて
以下の違いを意識しよう
combinations() p, r 長さrのタプル列、ソートされた順で重複なし

combinations_with_replacement() p, r 長さrのタプル列、ソートされた順で重複あり


使用例 　　　　　　　　　　　                  出力　　
combinations('ABCD', 2)　　　　　　　　　　　　AB AC AD BC BD CD

combinations_with_replacement('ABCD', 2)　　 AA AB AC AD BB BC BD CC CD DD
'''



'''
#集計
#example
#a=[2,2,2,3,4,3,1,2,1,3,1,2,1,2,2,1,2,1]
#a=Counter(a)
for i in a.most_common(n):print(i)
#most_common()メソッドは、出現回数が多い要素順にCounterオブジェクトを並び替えます。
#引数にint型の数字nを設定した場合は、出現回数が高い上位ｎ個の要素を返します。
#何も設定しなければ、コンテナ型にあるすべての要素を出現回数の順番に並び替えたタプル型オブジェクトを返します。
#out put
#(2, 8)
 #(1, 6)
#(3, 3)
#(4, 1)
'''


#二部探索(binary search)
#A = [1, 2, 3, 3, 3, 4, 4, 6, 6, 6, 6]
#print(A)
#index = bisect.bisect_left(A, 5) # 7 最も左(前)の挿入箇所が返ってきている
#A.insert(index, 5)
#print(index)
#print(A)
'''
bisect.bisect_left(a, x, lo=0, h=len(a))
引数
a: ソート済みリスト
x: 挿入したい値
lo: 探索範囲の下限
hi: 探索範囲の上限
(lo, hiはスライスと同様の指定方法)
bisect_leftはソートされたリストaに対して順序を保ったままxを挿入できる箇所を探索します。leftが示す通り、aにすでにxが存在している場合は、挿入箇所は既存のxよりも左側になります。また、lo, hiを指定することで探索範囲を絞り込むことも可能です。デフォルトはaの全体が探索対象です。
'''

'''
素数の判定
'''


def is_prime(n):
    if n == 1: return False

    for k in range(2, int(np.sqrt(n)) + 1):
        #sqrt(n)+1以上は考えて約数はないので却下
        if n % k == 0:
            return False
            #割り切れたらFalse
    return True


'''
npのmaxとmaximumの違い
xs = np.array([1, -2, 3])
np.max(xs, 0)
この出力は3となります．[1, -2, 3]と0の4つの数字のうち，最も大きい値を出力します．

一方で，[max(1, 0), max(-2, 0), max(3, 0)]を出力したい時があります．
その時は，numpyのmaximum関数を用います．

xs = np.array([1, -2, 3])
np.maximum(xs, 0)  # [1, 0, 3]

'''

def factorial(x, mod=10**9+7):
    # x!
    # 階乗
    # ex) factorial(5) = 120
    tmp = 1
    for i in range(1, x+1):
        tmp = (tmp * i) % mod
    return tmp
    '''
    Basically, when you do a**d % n, you actually have to calculate a**d, which could be quite large.
    But there are ways of computing a**d % n without having to compute a**d itself, and that is what pow does.
    '''


########################################################################
########################################################################
#b2=a[:]  #1次元のときはコピーはこれで良い
#print(b2)

#a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
#b3=copy.deepcopy(a)  #2次元配列はこうコピーする
#print(b3)

def main():

    w=1
    j=0
    k=0
    #n=int(input())
    #r=int(input())
    #dp= [[0]*3 for i in range(5)]#列　行
    #dp用の0の入ったやつ
    #dp= [[0]*(w+1) for i in range(n+1)]#0からwまでのw+1回計算するから
    #print(dp)＃初期条件が入る分計算回数+1列分必要(この場合は判断すべきものの数)
    DP = np.zeros(w+1, dtype=int)#これでも一次元リストが作れる
    exdp=np.zeros((3,4)) # ３×４の２次元配列を生成。2次元ならこう
    #dtypeは指定しないとfloatになる
    #for i in range(n):#ちょっとした入力に便利
    #    a, b = map(int, input().split())
        #dp[i][0] += [a]
        #これだとintとlistをつなぐことになって不適
    #    dp[i] += [a]
    #    dp[i] += [b]
        #これはうまくいく
        #やり方はいろいろあるということ
    #print(dp)

    ans=0
    "1行1つの整数を入力を取得し、整数と取得する"
    N,A,B=map(int, input().split(" "))#数字の時
    for i in range(1,N+1):
        #s=input()
        a=[int(j) for j in str(i)]
        #print(a)#int取るとstrでも行ける
        b=sum(a)
        if b >= A and b <= B:
            ans=ans+i
    print(ans)
        #
    #print(number_list)
    "12 21 332 とか入力する時に使う"
    "1行に複数の整数の入力を取得し、整数として扱う"
    #brray=[list(map(int, input().split(" ")))for i in range(N)
    #print(brray)


    #s=input()
    #a=[int(i) for i in s]#int取るとstrでも行ける
    #print(a)
    '''
    入力
    1234
    出力
    [1, 2, 3, 4]
    '''
    pin_l=["x" for i in range(10)]#内包表記に慣れろ
    #print(pin_l)

    ls = ["a", "b", "c", "d", "e"]


    #print(ls[2:5])
    #スライスでの取得

    #print(ls[:-3])
    #一番左端から右から3番目より左まで取得

    #print(ls[:4:2])
    #スライスで1個飛ばしで取得
    #ないときは左端スタート
    #始点のインデックス番号 : 終点のインデックス番号 : スキップする数+1
    #print(ls[::2])
    '''
    lsというリストの場合に、1つ飛びの値を取得したい場合には
    ls[::2]
    のようにします。こうすると、
    ["a", "c", "d"]と出力される
    '''

if __name__ == "__main__":
    main()

Submission status: Accepted

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

for n in range(1, N+1):
    n = str(n)
    n_list = list(map(int, n))

    if A <= sum(n_list) <= B:
        ans += int(n)

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

counter = 0
for i in range(1, n+1):
    j = list(str(i))
    l = 0
    for k in j:
        l += int(k)
    if a <= l and b >= l:
        counter += i
print(counter)

Submission status: Accepted

Solution code:
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
N, A, B = ri_()
ans = 0
for num in range(1, N + 1):
    sm = 0
    for i in str(num):
        sm += int(i)
    if A <= sm <= B:
        ans += num
print(ans)

Submission status: Accepted

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

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

ans = int(0)

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

Submission status: Accepted

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

def digidsum(x):
  s = str(x)
  array_list = list(map(int,s))
  return sum(array_list)



for i in range(n):

  if digidsum(i+1) >= a and digidsum(i+1) <= b:
    cnt += i+1
    
print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for i in range(1, n+1):
  tmpsum = 0
  for s in str(i):
    tmpsum += int(s)
  if tmpsum >= a and tmpsum <= b:
    ans += i

print(ans)

Submission status: Accepted

Solution code:
import sys
def main():
    input = sys.stdin.readline()
    N, A, B = map(int,input.split())
    #print('N:%d A:%d B: %d' % (N,A,B)) 

    answer = []
    for i in range(N+1):
        s = sum( map(int,list(str(i)) )) # list of int -> sum
        if s >= A and s <= B: answer.append(i)
        #print('i:%d s:%d' % (i,s))
    print(sum(answer))

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N, A, B = map(int,input().split())
    #print('N:%d A:%d B: %d' % (N,A,B)) 

    answer = []
    for i in range(N+1):
        s = sum( map(int,list(str(i)) )) # list of int -> sum
        if s >= A and s <= B: answer.append(i)
        #print('i:%d s:%d' % (i,s))
    print(sum(answer))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
ssum=0
for i in range(1,N+1):
	listi=[0,0,0,0,0]
	temp=i
	for j in range(5):
		listi[j]=temp%10
		temp=(temp-temp%10)/10
	sumi=sum(listi)
	if(sumi>=A and sumi<=B):
		ssum=ssum+i
print(ssum)

Submission status: Accepted

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

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

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

Submission status: Accepted

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


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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

all_num = 0

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

    str_i = str(i)

    total_i = list(map(int, str_i))

    x = sum(total_i)

    if A <= x <= B:
        all_num += i

print(all_num)

Submission status: Accepted

Solution code:
def main():
    N, A, B  = map(int, input().split())
    sum_v = 0
    for i in range(1, N+1):
        v = sum([int(s) for s in str(i)])
        if v >= A and v <= B:
            sum_v += i
    print(sum_v)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
ans = []
for i in range(1, n+1) :
    one = [int(x) for x in list(str(i))]
    ans.append(sum(one))
co = 0
for d, s in enumerate(ans):
    if a <= s <= b :
        co += (d + 1)
print(co)

Submission status: Accepted

Solution code:
def calc_sum(num):
    sum_value = 0
    while True:
        if num != 0:
            sum_value += (num % 10)
            num //= 10
        else:
            return sum_value


N, A, B = [int(n) for n in input().split()]
count = 0
for n in range(1, N+1):
    if A <= calc_sum(n) <= B:
        count += n
print(count)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

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

Submission status: Accepted

Solution code:

import sys
def input(): return sys.stdin.readline().strip()

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

Submission status: Accepted

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

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

print(total)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,a,b=map(int, input().split())
    l=[]
    for i in range(1,n+1):
        cnt=0
        for j in range(len(str(i))):
            cnt+=int(str(i)[j])
        if a<=cnt<=b:
            l.append(i)
    print(sum(l))
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

sub = [k for k in range(1,N+1)]

for j in sub:
    if A <= digitSum(j) <= B:
        lst_1.append(j)
print(sum(lst_1))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

result = 0
for n in range(1,N+1):
    sm = 0
    for i in range(len(str(n))):
        sm += int(str(n)[i])
    if A<=sm<=B:
        result += n

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(N+1):
    tmp = 0
    i_ori = i
    s = str(N)
    for j in range(len(s)):
        tmp += i%10
        i = i//10
    if (tmp <= B and tmp >= A):
        out += i_ori

print(out)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().strip()

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

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

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:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

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

Submission status: Accepted

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

def calculate_digit_sum(n):
    digit_sum = 0
    for digit in str(n):
        digit_sum += int(digit)
    return digit_sum

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

Submission status: Accepted

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

def sumdigit(n):
    sum=0
    t = getdigits(n)
    #print(n, t)
    for n in t:
        sum+=n
    return sum

def getdigits(n):
    if (n==10000):
        return (1,0,0,0,0)
    
    d4 = n // 1000
    n -= d4*1000
    d3 = n // 100
    n -= d3*100
    d2 = n // 10
    n -= d2*10
    return (d4,d3,d2,n)

def main(n,a,b):
    sum=0
    for i in range(1,n+1):
        s = sumdigit(i)
        #print(s)
        if (a<=s and s<= b):
            sum += i
    return sum

if __name__ == '__main__':
    n,a,b = readinput()
    sum = main(n,a,b)
    print(sum)