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

res = 0

for i in range(1,n+1):
    x5 = i//10000
    x4 = (i-x5*10000)//1000
    x3 = (i-x5*10000-x4*1000)//100
    x2 = (i-x5*10000-x4*1000-x3*100)//10
    x1 = i % 10
    
    xx = x5+x4+x3+x2+x1
    if b >= xx >= a:
        res += i

print(res)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
ans=[0]*37
def ssum(n):
  li=list(str(n))
  ret=0
  for i in li:
    ret+=int(i)
  return(ret)
  
while n!=0:
  ans[ssum(n)]+=n
  n-=1

print(sum(ans[a:b+1]))

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
n = list(map(int, input().split()))
num = 0

for i in range(1, n[0]+1):
  strn = str(i)
  total = 0
  for j in range(len(strn)):
    total += int(strn[j])
    
  if total <= n[2] and total >= n[1]:
    num += i

print(num)

Submission status: Accepted

Solution code:
from math import floor

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

result = 0
for i in range(n+1):
    i_str = str(i)
    sum = 0
    for j in range(i_str.__len__()):
        sum += int(i_str[j])
    
    if sum >= a and sum <= b:
        result += i

print(result)

Submission status: Accepted

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

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

Submission status: Accepted

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

def SumOfDigits(n):
    s = 0
    while n != 0:
        s += n % 10
        n = n // 10
    return(s)


S = 0

for i in range(N+1):
    j = 0
    j = SumOfDigits(i)
    if j >= A and j <= B:
        S += i
    else:
        pass

print(S)

Submission status: Accepted

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

def main():
    n, a, b = map(int, input().split())
    all_sum = 0
    for i in range(1, n+1):
        digit_sum = 0
        for j in list(str(i)):
            digit_sum += int(j)
        if a <= digit_sum and digit_sum <= b:
            all_sum += i
    print(all_sum)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

count = 0

for i in range(1, N + 1):
    sum = findSumOfDigits(i)
    if sum <= b and a <= sum:
        count += i

print(count)

Submission status: Accepted

Solution code:
def sumdidits(x):
  res=0
  while x:
    res+=x%10
    x//=10
  return res

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

Submission status: Accepted

Solution code:
# 各桁の和を求める
def d(n,ans=0):
  if n == 0:
    return ans
  else:
    return d(n//10,ans+n%10)

# 条件を満たすなら桁の和の値を返す
def judge(k,a,b):
  s = d(k)
  if a <= s <= b:
    return k
  else:
    return 0

def solve(n,a,b):
  return sum([judge(i+1,a,b) for i in range(n)])

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

Submission status: Accepted

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

import os
import sys


# ac_py.main
# Date: 2020/06/08
# Filename: main 
# Author: acto_mini

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

    for i in range(1, N+1):
        s = str(i)
        array = list(map(int, s))
        x = sum(array)
        if A <= x and x <= B: ans += i

    print(ans)
    return


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

Submission status: Accepted

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

Submission status: Accepted

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

print(count)

Submission status: Accepted

Solution code:
N,A,B = map(str,input().split())
a = int(A)
b = int(B)
c = int(N) + 1 
all = 0
ans = 0
for count in range(c):
  test = str(count)
  ttt = list(test)
  for mozi in ttt:
    all = all + int(mozi)
  if all >= a and all <= b:
    ans = ans + count
  all = 0

print('{}'.format(ans))

Submission status: Accepted

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

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

print(answer)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

ans = 0
for i in range(N + 1):
    s = list(str(i))

    cnt = 0
    for x in s:
        cnt += int(x)

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

print(ans)

Submission status: Accepted

Solution code:


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


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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

count = 0
for i in range(1, A[0] + 1):
    value_list = [int(i) for i in list(str(i))]
    sum_value = sum(value_list)
    if A[1] <= sum_value <= A[2]:
        count += i
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
box = []
for i in range(1, N+1 ):
    n = len(str(i))
    j = i
    temp = 0
    while n != 0:
        temp += (j % 10)
        j = int(j / 10)
        n -= 1
    if A <= temp <= B:
        box.append(i)
print(sum(box))

Submission status: Accepted

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

Submission status: Accepted

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

def sumketa(x):
  ctr = 0
  y = str(x)
  for j in range(len(y)):
    ctr = ctr + x % 10
    x = x // 10
  return ctr

def sumspe(n,a,b):
  ctr = 0
  for i in range(1,n+1):
    if(a<=sumketa(i)<=b):
      ctr+=i
  return ctr

print(sumspe(n,a,b))

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(n+1):
    numsum = sum([int(x) for x in list(str(i))])
    if b>= numsum >=a:
        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):
    D=0
    for j in str(i):
        D+=int(j)
    if A<=D<=B:
        ans+=i
print(ans)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    a = [int(i) for i in input().split()]
    count = 0
    for i in range(1,a[0]+1):
        s = str(i)
        sumN = 0
        for j in s:
            sumN += int(j)

        if a[1] <= sumN and a[2] >= sumN:
            count+=i
    print(count)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

total = 0
for i in range(N+1):
    # iについて各桁の和を計算
    i_sum = kansu(i)
    if(i_sum >= A and i_sum <= B):
        total += i

print(total)

Submission status: Accepted

Solution code:
def digit_sum(n):
    ans = 0
    while n > 0:
        ans += n % 10
        n //= 10
    return ans
n, a, b = map(int, input().split())
list1 = []
for i in range(n):
    if a <= digit_sum(i+1) <= b:
        list1.append(i + 1)
print(sum(list1))

Submission status: Accepted

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

n_len = len(n)

tmp=ttmp=sum=0

for i in range(1,int(n)+1):
    tmp_len = len(str(i))
    ttmp = 0

    for j in range(tmp_len):
        tmp = str(i)[j]
        ttmp = ttmp + int(tmp)

    if ttmp >= a and ttmp <=b : 
        sum = sum + i

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

sum=0
for i in range(1,n+1):
  dumy=0
  for j in range(5):
    dumy+=i%10**(j+1)//10**j
  if dumy>=a:
    if dumy<=b:
      sum+=i
    
  
print(sum)

Submission status: Accepted

Solution code:
def main():
    target_list = input().split()

    result = 0
    for i in range(1, int(target_list[0])+1):
        sum = 0
        for j in range(len(str(i))):
            sum += int(str(i)[j])
        if int(target_list[1]) <= sum <= int(target_list[2]):
            result += i

    print(result)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

N_sum = 0

for i in range(N+1):
    j = i
    if i >= 10:
        j = 0
        i_list = list(str(i))
        for k in i_list:
            j += int(k)
    if j >= A and j <= B:
        N_sum += i
        
print(N_sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
ct=0
for i in range(1,n+1):
    num=0
    flag=0
    for j in range(len(str(i))):
        num+=int(str(i)[j])
        if num>b:
            flag=1
            break
    if a>num:
        flag=1
    if flag==0:
        ct+=i
print(ct)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np

def main():
    #n = int(input())
    n,a,b = map( int, input().split())
    l = []
    for i in range(1,n+1):
        i_sum = np.sum([int(x) for x in list(str(i))])
        #print(i_sum)
        if a <= i_sum and i_sum <= b:
            #print(i)
            l.append(i)
    print(np.sum(l))

    
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math 

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

result = 0

for i in range(1,n+1):
    tmp = 0
    tmp_i = i
    for j in range(int(math.log10(i))+1):
        tmp = tmp + tmp_i%10
        tmp_i  = tmp_i//10
    if a <= tmp <= b:
        result += i
print(result)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N, A, B = map(int, input().split())

    ans = 0
    for i in range(1, N + 1): #全ての数字に対して桁和を計算する
        digSum = 0
        k = i
        while k > 0:
            digSum += k % 10
            k //= 10

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

    return  0

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):
    num = str(i)
    total = 0
    for n in num:
        total += int(n)
    if total >= A and total <= B:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
def ketawa(i):
  ret = 0
  while(i):
    ret += i % 10
    i //= 10
  return ret

ret = 0
for i in range(1,n+1):
  if a <= ketawa(i) <= b: ret += i
print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N, a, b = map(int,input().split())
    ans = 0
    for i in range(N+1):
        fig = i
        summ = 0
        while fig > 0:
            summ = summ + fig%10
            fig = fig//10
        if a<= summ and summ<= b:
            ans = ans + i
    print(ans)
    return
main()

Submission status: Accepted

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

def fun(x):
  s=list(str(x))
  wa=0
  for p in s:
    wa+=int(p)
  return wa
ans=0
for i in range(1,N+1):
  tmp=fun(i)
  if A<=tmp and tmp<=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):
    num1=str(i)
    num2=0
    for j in range(len(num1)):
        num2+=int(num1[j])
    if num2>=a and num2<=b:
        ans+=i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)



def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1             # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    def check_digit(i, a, b):
        s = str(i)
        digit_sum = 0
        for char in s:
            digit_sum += int(char)
        return a <= digit_sum <= b


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

Submission status: Accepted

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

for i in range(1, n+1):
    temp = list(str(i))
    val = 0
    for j in temp:
        val += int(j)

    if val >= a and val <= b:
        count += i

print(count)

Submission status: Accepted

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

ans = 0

for num in range(N + 1):
    num1 = list(str(num))
    num2 = map(int, num1)
    sums = sum(num2)

    if sums >= A and sums <= B:
        ans += num
    
print(ans)

Submission status: Accepted

Solution code:
N, A ,B = map(int,(input().split()))
ans = 0
for i in range(N):
    sum = 0
    temp = i + 1
    temp_str = str(temp)
    temp_list = list(temp_str)
    
    for j in temp_list:
        sum += int(j)
    
    if sum >= A:
        if sum <= B:
            ans += temp

print(ans)

Submission status: Accepted

Solution code:
n, a, b = (int(i) for i in input().split())
ans = 0
for i in range(1, n+1):
    A = str(i)
    _sum = 0
    for c in A:
        _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(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(N+1):
    s = 0
    strn = str(n)
    for i in strn:
        s += int(i)
    if s >= A and s<= B:
        Sum += n

print("{}".format(Sum))

Submission status: Accepted

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

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

	total = 0
	for i in range(1, n+1):
		sum = findSumOfDigits(i)
		if sum >= a and b >= sum:
			total += i

	print(total)

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):
    s = str(i)
    m = list(map(int,s))
    if a <= sum(m) <= 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)
	a = list(map(int,s))
	if A <= sum(a) <= B:
		ans += i

print(ans)

Submission status: Accepted

Solution code:
import math
l=input().split()
N, A, B=[ int(i) for i in l]
s=0
for i in range(N+1):
   q=i/10
   s2=i% 10
   while q >= 1:
       q=math.floor(q)
       s2 += q% 10
       q/=10
   if s2 >= A and s2 <=B:
       s+=i
       
print(s)

Submission status: Accepted

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

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

print(s)

Submission status: Accepted

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

Submission status: Accepted

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

    for i in range(N+1):
        s=0
        p=str(i)
        for j in range(len(p)):
            s+=int(p[j])
        if s>=A and s<=B:
            k+=i
    print(k)

if __name__ == '__main__':

    ABC_83_B()

Submission status: Accepted

Solution code:
from sys import stdin
from math import log10
def LI(): return list(map(int,stdin.readline().rstrip().split()))

tmp = LI()
n,a,b = [tmp.pop(0) for _ in range(3)]

ans = 0

for i in range(1,n+1):
    tmp = i
    x = 0
    for _ in range(int(log10(i)+1)):
        x+=tmp%10
        tmp = tmp//10
    if a<=x and x<=b:
        ans+=i
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
from math import log10
def LI(): return list(map(int,stdin.readline().rstrip().split()))

tmp = LI()
n,a,b = [tmp.pop(0) for _ in range(3)]

ans = 0

for i in range(1,n+1):
    tmp = i
    x = 0
    for _ in range(int(log10(i)+1)):
        d = tmp%10    
        x+=d
        tmp-=d
        tmp = tmp//10
    if a<=x and x<=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):
    ti = 0
    tmp = i
    while tmp!=0:
        ti += tmp%10
        tmp = tmp//10
    if ti>=a and ti<=b:
        ans+=i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

N, a, b = map(int, input().split())
total = 0
def FindSum(n):
    sum = 0
    while n > 0:
        sum += n % 10
        n = n //10

    return sum

for i in range(1, N + 1): 
    sum = FindSum(i)
    if a <= sum <= b:
        total += i

print(total)

Submission status: Accepted

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

total = 0

for i in range(N):
    n = i + 1
    a = 0
    for m in str(n):
        a += int(m)
    if (A <= a) & (a <= B):
        total += n

print(total)

Submission status: Accepted

Solution code:
def main():
    inp = list(map(int, input().split()))
    n = inp[0]
    a = inp[1]
    b = inp[2]
    n_sum = 0
    res = 0
    for i in range(1, n+1):
        n_list = list(map(int, list(str(i))))
        n_sum = sum(n_list)
        if a <= n_sum and n_sum <= b:
            res += i
    print(res)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

Submission status: Accepted

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

ans = 0

for x in range(1, N + 1):
    SUM = 0
    num = x
    while x > 0:
        SUM += (x % 10)
        x //= 10
    if A <= SUM <= B:
        ans += num
        
print(ans)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
cnt = 0
for i in range(1, n+1):
    s = list(str(i))
    t = 0
    for j in range(len(s)):
        t += int(s[j])
    if a<=t and t<=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):
    s = list(str(i))
    p = 0
    for j in range(len(s)):
        p += int(s[j])
    if (p >= a) and (p <= b):
        ans += i

print(ans)

Submission status: Accepted

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

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# list = list(map(int, input().split()))

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

## Logic

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


print(ans)

Submission status: Accepted

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

while p <= n:
    str_p = str(p)
    for q in str_p:
        r += int(q)
    if r >= a and r <= b:
        ans += p
    p += 1
    r = 0

print(ans)

Submission status: Accepted

Solution code:
N, A, B =map(int, input().split())
R = N // 10000
S = N // 1000
T = N // 100
U = N // 10
V = N % 10
total = 0
for r in range(R +1):
  for s in range(10): 
    for t in range(10):
      for u in range(10):
        for v in range(10):
          if A <= r+s+t+u+v and r+s+t+u+v <= B and 10000*r+1000*s+100*t+10*u+v <=N:
            total = total + 10000*r+1000*s+100*t+10*u+v
print(total)

Submission status: Accepted

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

res =0

for i in range(N+1):
    s = str(i)
    l = len(s)
    sum = 0
    
    for j in range(l):
        sum += int(s[j])
        
    if sum >=A and B>=sum:
        res += i
        
        
print(res)

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
def divi(n):
    n1 = n%10
    n2 = n//10 %10
    n3 = n//100 %10
    n4 = n//1000 %10
    n5 = n//10000 %10
    return n1, n2, n3, n4, n5
ans = 0
for j in range(1,n+1):
    count = 0
    for s in divi(j):
        count += s
    if a<=count<=b:
        ans += j
print(ans)

Submission status: Accepted

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

for i in range(N+1):
    j=i
    n=0
    while True:
        n+=i%10
        if i//10==0:
            break
        else:
            i=i//10
    if A<=n<=B:
        a.append(j)
    else:
        pass
print(sum(a))

Submission status: Accepted

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