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:

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


# show_flg = False
show_flg = True


def main():
    N, A, B = MI()
    ans = 0

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

limit, bottom, top = [int(x) for x  in input().split()]
total = 0
for i in range(1,limit+1):
    sum = check_sum(i)
    if ((sum >= bottom) and (sum <= top)):
        total += i
print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
import sys


def main(argv=sys.argv):

    max_range, min_digit_sum, max_digit_sum = map(int, input().split(' '))

    ok_sum = 0
    for i in range(1, max_range + 1):
        digit_sum = sum(map(int, list(str(i))))
        if min_digit_sum <= digit_sum <= max_digit_sum:
            ok_sum += i

    print(ok_sum)

    return 0


if __name__ == '__main__':
    sys.exit(main())

Submission status: Accepted

Solution code:
# coding: utf-8
import sys


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


if __name__ == '__main__':
  sys.exit(main())

Submission status: Accepted

Solution code:

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

total = 0

for i in range(n):

    sum = 0
    for j in str(i + 1):

        sum += int(j)

    if sum >= a and sum <= b:
        total += (i + 1)


print(total)

Submission status: Accepted

Solution code:
import math

li = list(map(int,input().split()))
a = li[0]
b = li[1]
c = li[2]

list = []

for i in range(a + 1):
  ans = 0
  tmp = i

  while(i >= 1):
    ans += i % 10
    i = math.floor(i / 10)

  if b <= ans <= c:
    list.append(tmp)

data = 0
for e in list:
  data += e

print(data)

Submission status: Accepted

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

for i in range(1, N+1):
  a = 0
  for x in range(len(str(i))):
    a += int(str(i)[x])
  if a >= A and a <= B:
    n.append(i)
print(sum(n))

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 = [int(i) for i in input().split()]

b = []
for i in range(N+1):
    a = [int(j) for j in list(str(i))]
    if A <= sum(a) <=B:
        b.append(i)

print(sum(b))

Submission status: Accepted

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

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

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(int(c) for c in str(i)) <= B))

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, list(str(i)))) <= B) )

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def sm(x):
    a = 0
    a += (x%10)
    a += (x//10)%10
    a += ((x//10)//10)%10
    a += (((x//10)//10)//10)%10
    a += ((((x//10)//10)//10)//10)%10
    return a
 
N, A, B = map(int,input().split())
ans = 0
for i in range(1, N+1):
    if A <= sm(i) <= B:
        ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

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

def main():
    res = 0
    for i in range(1, n+1):
        s = sum([int(d) for d in str(i)])
        if a <= s <= b:
            res += i
    return res
    
if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(List))

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
    sum=0
    p=10000
    l=i
    for k in range(5):
        sum+=int(l/p)
        l%=p
        p/=10
    if sum>=a and sum<=b:
        ans+=i

print(ans)

"""
20 2 5

84

10 1 2

13

100 4 16

4554


"""

Submission status: Accepted

Solution code:
num_list = [int(i) for i in input().split()]

result = 0

for i in range(1, num_list[0] + 1):
    sum = 0
    n = i
    while n > 0:
        sum += n % 10
        n = n // 10
    if sum >= num_list[1] and sum <= num_list[2]:
        result += i

print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
from decimal import Decimal
import copy
N,A,B = (int(x) for x in input().split())
counter = 0

for x in range(1,N + 1):
    S = 0
    power = 0
    new_x = copy.deepcopy(x)
    for i in range(len(str(x))):
        S += x % 10
        x = math.floor(x / 10)
        
        power += 1        
    
    if A <= S and S <= B:

        counter += new_x
    

print(int(counter))

Submission status: Accepted

Solution code:
def sm(x):
    a = 0
    a += (x%10)
    a += (x//10)%10
    a += ((x//10)//10)%10
    a += (((x//10)//10)//10)%10
    a += ((((x//10)//10)//10)//10)%10
    return a

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

Submission status: Accepted

Solution code:
def sm(x):
    xls = list(str(x))
    a = 0
    for i in range(len(xls)):
        a += int(xls[i])
    return a

N, A, B = map(int,input().split())
ans = 0
for i in range(1, N+1):
    if A <= sm(i) <= 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):
    if i <=9:
        if i >= A and i <= B:
            count += i
    elif i <= 99:
        k = str(i)
        m = int(k[0]) + int(k[1])
        if m >= A and m <= B:
            count += i
    elif i <=999:
        k = str(i)
        m = int(k[0]) + int(k[1]) + int(k[2])
        if m >= A and m <= B:
            count += i
    elif i <= 9999:
        k = str(i)
        m = int(k[0]) + int(k[1]) + int(k[2]) + int(k[3])
        if m >= A and m <= B:
            count += i        
    else:
        m = 1
        if m >= A and m <= B:
            count += i
print(count)

Submission status: Accepted

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


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

    # 線形探索（O(n))
    # for n in range(N + 1):
    #     if A <= sum(list(map(int, str(n)))) <= B:
    #         ans += n

    # bit探索(O(log n))
    for i in range(N + 1):
        each_digits_total = 0
        j = i
        while j > 0:
            each_digits_total += j % 10
            j //= 10
        if A <= each_digits_total <= B:
            ans += i
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
n, a, b = map(int, sys.stdin.readline().split())

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

print(sum(l))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def sm(x):
  xls=list(str(x))
  a=0
  for i in range(len(xls)):
    a+=int(xls[i])
  return a
n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
  if a<=sm(i)<=b:
    ans+=i
print(ans)

Submission status: Accepted

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


def sum_digit(num):
    res = 0
    while num > 0:
        res += int(num % 10)
        num = int(num / 10)
    return res


for i in range(1, n + 1):
    tmp = sum_digit(i)
    # print(tmp)
    if tmp >= a and tmp <= b:
        res += i

print(res)

Submission status: Accepted

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

ans = []

def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)


for i in range(1,N+1):
    Number = digitSum(i)
    if A <= Number <= B:
        ans.append(i)

print(sum(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num_list = list(map(int,input().split()))
answer = []
num_answer=0
for i in range(num_list[0]+1):
	k = 0
	for j in range(len(str(i))):
		k+=int(str(i)[j])
	if(k >= num_list[1] and k <= num_list[2]):
		answer.append(i)
#print(answer)
for m in range(len(answer)):
	num_answer+=answer[m]
print(num_answer)

Submission status: Accepted

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

sum_result = 0

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

print(sum_result)

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
point=0
suma=0
for num in range(N+1):
  great_num=num
  S=0
  while(True):
    if num==0:
      break
    else:
      S=S+num%10
      num=num//10
  if A<=S and S <= B:
    suma=suma+great_num
print(suma)

Submission status: Accepted

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

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

mylist = [i for i in range(n+1) if a<=findsum(i) and findsum(i)<=b]
print(sum(mylist))

Submission status: Accepted

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

def func_de(n):
    ans = 0
    while n/10 != 0:
        ans += n % 10
        n //= 10
    return ans

ANS = 0
for i in range(N+1):
    if A <= func_de(i) <= B:
        ANS += i

print(ANS)

Submission status: Accepted

Solution code:
#Some sums
N,A,B = map(int,input().split())
S = 0
for i in range(N+1):
    L = list(str(i))
    S1 = 0
    for j in range(len(L)):
        S1 += int(L[j])
    if A <= S1 <= 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 sum(map(int,str(i))) in range(a,b+1):
		ans+=i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
#-*- coding: utf-8 -*-#
test = input()
a, b, c = map(int, test.split())  # 変数a,b,cにそれぞれN、A、Bをint型にして入力する　
x = []
e = []
for i in range(1,a+1):  # list型の変数xに１からNまでの要素を入れる
    x.append(i)
len_x = len(x)  # リスト型の変数xの要素数を獲得
d = 0  # リストの各行の和を入れるための変数
f = []  # 各行がA以上B以下の要素を入れるための変数
x = map(str, x) # リストxの各要素をstr型に変換
x = list(x)
e_number = 0
for i in range(len_x):
    e = x[i]           # xのi番目の要素を抽出
    e = list(e)  # xのi番目の要素を一文字ずつのstr型としてリスト型の変数に入れる
    e = map(int, e)# xのi番目の要素をint型に変換
    e = list(e)
    e_number = len(e)   # リスト型の変数eの要素数を取得
    d = 0              # 位の合計の判定用の変数
    for g in range(e_number):
        d += e[g-1]  # 位の合計
    if b <= d <= c:  # 位の合計がA以上B以下ならリストfに要素を追加
        f.append(x[i])
answer = 0  # 条件位合う要素の合計を入れる変数
f = map(int, f)
for h in f:
    answer += h  # 要素に合う要素の合計
print(answer)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
total = 0
for i in range(N+1):
	if i < 10:
		n = i
	else:
		li = list(str(i))
		n = 0
		for num in li:
			n += int(num)
	if n >= A and n <=B:
		total += i

print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N,A,B = map(int, input().split())
X = 0
for i in range(1,N+1):
  C = sum(list(map(int,str(i))))
  if A <= C <= B:
    X += i
print(X)

Submission status: Accepted

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

Submission status: Accepted

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

ylist = []
for i in range(1,N+1):
  tot = sum(map(int,list(str(i))))
  if tot >= A and tot <=B:
    ylist.append(i)
print(sum(ylist))

Submission status: Accepted

Solution code:
N, A, B = map(int, input().strip().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:
n,a,b = map(int,input().split())
ans = 0
for i in range(n+1):
  f = sum([int(x) for x in str(i)])
  if (a <= f) & (f <= b):
    ans+=i
print(ans)

Submission status: Accepted

Solution code:
def degitsum(n):
    ans = 0
    while n/10 != 0:
        ans += n%10
        n = int(n/10)
    return ans

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

ans = 0
for i in range(1, n+1):
    if a <= degitsum(i) <= b:
        ans += i
    else:
        continue
        
print(ans)

Submission status: Accepted

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

for j in range(1,int(n)+1): #1<=j<=nを出力
  j = str(j)
  S = 0
  for i in range(len(j)): #整数の各位の和を求める
    S += int(j[i])
  if int(a) <= S <= int(b): #a<=S<=bに収まるかどうかでCに加算するか判別
    C += int(j)
  else:
    C += 0

print(C)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


def solve(N: int, A: int, B: int):
    sum = 0
    for i in range(1, N+1):
        S = str(i)
        wa = 0
        for s in S:
            wa += int(s)
        if wa >= A and wa <= B:
            sum += i
    print(sum)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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:
line = list(map(int,input().split()))
n = line[0]
a = line[1]
b = line[2]

nums = []
for num in range(n+1):
  sowa = 0
  count = len(str(num))
  for i in range(count):
    num = str(num)
    sowa += int(num[i])
  if a <= sowa and sowa <= b:
    nums.append(num)
answer = 0
for j in nums:
  answer += int(j)
print(answer)

Submission status: Accepted

Solution code:
#coding:utf-8

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

total = 0
for i in range(1, n + 1):
  str_i = str(i)
  sum = 0
  for char in str_i:
    sum += int(char)
  if sum >= a and sum <= b:
    total += i
    
print(total)

Submission status: Accepted

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

test = []
for num in range(1, N+1):
    total = 0
    for i in range(len(str(num))):
        total+=int(str(num)[i])
    if A <= total <=B:
        test.append(num)

print(sum(test))

Submission status: Accepted

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

rslt = 0
for i in range(1,n+1):
    s = str(i)
    sum = 0
    for j in s:
        # sum += int(j)
        sum = sum + int(j)
    if sum >= a and sum <= b:
        rslt += i

print(rslt)

Submission status: Accepted

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

def sum_digit(n):
    sum = 0
    while True:
        sum += n%10
        if n//10 > 0:
            n //= 10
        else:
             break
    return sum

for i in range(1,n+1):
    sum = sum_digit(i)
    if a <= sum and sum <= b:
        ans += i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

ans = 0;
for num in range(1, N+1):
    l = []
    q, r = divmod(num, 10)
    l.append(r)
    while q != 0:
        q, r = divmod(q, 10)
        l.append(r)
    if A <= sum(l) and sum(l) <= B:
        # print(num)
        ans += num

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)

# print(digitSum(123))
# => 6
# print(digitSum(35829))
# => 27

for i in l:
    if a <= digitSum(i) <= b:
        ans = ans + i
print(ans)

Submission status: Accepted

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

print(x)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def s(num):
  val=0
  while num>0:
    val+=num%10
    num=num//10
  return val
n,a,b=[int(s) for s in input().split()]
ans=0
for i in range(1,n+1):
  x=s(i)
  if a<=x and x<=b:
    ans+=i
print(ans)

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
num=0
for n in range(0,N+1):
    def degitSum(n):
        s=str(n)
        lists=list(map(int,s))
        return sum(lists)
    if degitSum(n)>A-1 and degitSum(n)<B+1:
        num=num+n
print(num)

Submission status: Accepted

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

def calcSumOfEachDigit(num):
    charts = list(str(num))
    return sum(int(i) for i in charts)

[N_str, A_str, B_str] = input().split()
N = int(N_str)
A = int(A_str)
B = int(B_str)

matches = []
for i in range(1, N+1):
    total = calcSumOfEachDigit(i)
    if total >= A and total <= B:
        matches.append(i)

print(sum(matches))

Submission status: Accepted

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


result_total = 0
for i in range(N):
    result_num = sum([int(s) for s in list(str(i+1))])
    if result_num >= A and result_num <= B:
        result_total += i+1
        
print(result_total)

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n, a, b = map(int, input().split())

lst = []
for i in range(n + 1):
  x = 0
  for j in range(len(str(i))):
    x = x + int(str(i)[j])
  if (x >= a) and (x <= b):
    lst.append(i)
print(sum(lst))

Submission status: Accepted

Solution code:
def sum_digits(digits):
	str_digits = str(digits)
	digit_array = list(map(int, str_digits))
	return sum(digit_array)


n_str, a_str, b_str = input().split(' ')
n = int(n_str)
a = int(a_str)
b = int(b_str)

nums_to_be_summed = []
for x in range(n):
	tmp_sum = sum_digits(x+1)
	if a <= tmp_sum <= b:
		nums_to_be_summed.append(x+1)
print(sum(nums_to_be_summed))

Submission status: Accepted

Solution code:
def digit_sum(n):
    n = str(n)
    S = list(map(int,n))
    return sum(S)

N , A, B = map(int,input().split())
ans = 0
for i in range(1 , N + 1):
    if A <= digit_sum(i) <= 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):
    str_n = str(n)
    sum_digit = 0
    for i in range(len(str_n)):
        int_n = int(str_n[i])
        sum_digit += int_n
    if A <= sum_digit and sum_digit <= B:
        ans += n
        
print(ans)

Submission status: Accepted

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

ans = 0
for n in range(N+1):
    temp = n
    sum = 0
    while (temp>=1):
            sum += temp%10
            temp = int(temp/10)

    if A <= sum <= B:
        ans += n

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(summary)

Submission status: Accepted

Solution code:
dbflag=""

def debug(*args):
	if ""!=dbflag: print(*args)

if ""!=dbflag: _INDATA=open(dbflag)

def readline():
	if ""!=dbflag:return _INDATA.readline()
	else: return input()


result = 0

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



for i5 in range(0,2):
  for i4 in range(0,10):
    for i3 in range(0,10):
      for i2 in range(0,10):
        for i1 in range(0,10):
          s = i5 + i4 + i3 + i2 + i1
          sss = 10000* i5 + 1000 *i4 + 100 * i3 + 10 * i2 + i1
          if sss > N :
            break
            
          if A<= s and s <= B:
            result += sss

print(result)

Submission status: Accepted

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

ans = 0
for n in range(N+1):
    m = n
    sum = 0
    while (n>=1):
            sum += n%10
            n = int(n/10)

    if A <= sum <= B:
        ans += m

print(ans)

Submission status: Accepted

Solution code:
nums = input()
nums = nums.split()
for_num = int(nums[0])
min_num = int(nums[1])
max_num = int(nums[2])

ans_list = []

for i in range(0,for_num+1):
  num = int(i)
  tthou_num = int(num/10000)
  thou_num = int(num/1000) - tthou_num*10
  hun_num = int(num/100) - tthou_num*100 - thou_num*10
  ten_num = int(num/10) -tthou_num*1000 - thou_num*100 - hun_num*10
  one_num = num - tthou_num*10000 - thou_num*1000 - hun_num*100 - ten_num*10
  ans = tthou_num + thou_num + hun_num + ten_num + one_num
  if (ans >= min_num) and (ans <= max_num):
    ans_list.append(num)
print(sum(ans_list))

Submission status: Accepted

Solution code:
n,a,b = map(int, input().split())
t=0
for i in range(1,n+1):
    orign=i
    total = 0
    for ii in range(len(str(i))):
        total += i%10
        i=int(i/10)
    if total>=a and total<=b:
        t+=orign
print(t)

Submission status: Accepted

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

for i in range(1,N+1):
    k = i
    a = 0
    for l in range(len(str(i))):
        a += k%10
        k = int(k/10)
    if a >= A and a <= B:
        s += i

print(s)

Submission status: Accepted

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

if (N < 1 or 10**4 < N):
    sys.exit(100)
elif A > B:
    sys.exit(100)
elif A < 1:
    sys.exit(100)
elif 36 < B:
    sys.exit(100)

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

Submission status: Accepted

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

n = 0
ans = 0
while n < N+1:
	n4 = n // 10**4
	n3 = n // 10**3 - n4 * 10
	n2 = n // 10**2 - n4 * 100 - n3 * 10
	n1 = n // 10 - n4 * 1000 - n3 * 100 - n2 * 10
	n0 = n % 10
	X = n4 + n3 + n2 + n1 + n0
	if X >= A and X <= B:     
		ans += n 
	n += 1

print(ans)

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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

import numpy
import scipy

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

sumsum = 0
for n in range(N):
    s = str(n+1)
    sum = 0
    for a in list(s):
        sum += int(a)
    #print(sum)

    if A<= sum <= B:
        sumsum += n+1
        #print(" {}".format(n+1))
print(sumsum)

Submission status: Accepted

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

ans = 0
for i in range(1,N+1):
    tmp = 0
    for j in str(i):
        tmp += int(j)

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

Submission status: Accepted

Solution code:

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

"""
各桁の和を足し合わせる方法
"""

m = []

for i in range(1,N+1):
    j = str(i)
    l = list(map(int,j))
    total = sum(l)

    if A <= total and total <=B:
        m.append(i)

print(sum(m))

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0

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

print(cnt)

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