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


def sum_digit(n):
    t = 0
    while n > 0:
        t += n % 10
        n //= 10
    return t


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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#
# Author: Tetsuya Ishikawa <tiskw111@gmail.com>
# Date  : June 30, 2020
##################################################### SOURCE START #####################################################

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

s  = 0

for n in range(1, N + 1):
    n1 = n % 10
    n2 = (n // 10) % 10
    n3 = (n // 100) % 10
    n4 = (n // 1000) % 10
    n5 = (n // 10000) % 10
    p = n1 + n2 + n3 + n4 + n5
    if A <= p <= B:
        s += n

print(s)

##################################################### SOURCE FINISH ####################################################
# vim: expandtab tabstop=4 shiftwidth=4 fdm=marker

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

if not (1 <= N <= 10000 and 1 <= A <= 36 and 1 <= B <= 36):
    sys.exit()

sum = 0
for I in range(1,N+1):
    tmp = list(str(I))
    check = 0
    for J in range(len(tmp)):
        check += int(tmp[J])
    if A <= check <= B:
        sum += I
print(sum)

Submission status: Accepted

Solution code:
def f(N):
    if N<=9:
        return N
    else:
        return f(N//10)+(N%10)

N,A,B=map(int,input().split())
K=0
for i in range(1,N+1):
    K+=(A<=f(i)<=B)*i
print(K)

Submission status: Accepted

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

def Sum(n):
    s = str(n)
    t = list(map(int,s))
    return sum(t)

total = 0

for i in range(N + 1):
    if A <= Sum(i) and Sum(i) <= B:
        total += i
        
print(total)

Submission status: Accepted

Solution code:
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n, a, b = i2()
test = 0
memo = []
for i in range(1,n+1):
	c = str(i)
	for j in range(len(c)):
		test += int(c[j])
	if a <= test and test <= b:
		memo.append(i)
	test = 0
# print(memo)
print( sum(memo) )

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
less = []
for i in range(a, n+1):
    num = 0
    digit = len(str(i))
    if digit > 1:
        string = str(i)
        for j in range(digit):
            num += int(string[j])
    else:
        num = i

    if a <= num <= b:
        less.append(i)

print(sum(less))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def sum_of_digits(n):
  s = 0
  while n > 0:
    s += n % 10
    n = int(n / 10)
  return s

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

for i in range(1, n + 1):
  if a <= sum_of_digits(i) <= b:
    res += i
    
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

N, A, B = map(int, input().split())
ans = 0
for nn in range(1, N + 1):
    ns = list(str(nn))
    ns = list(map(int, ns))
    # print(ns)
    if A <= sum(ns) and sum(ns) <= B:
        ans += nn
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
i,A,B = map(int,input().split())
X=0
import math

for n in range(i+1):
    N = n%10 + math.floor((n/10)%10) + math.floor((n/100)%10) + math.floor((n/1000)%10) + math.floor((n/10000)%10)
    if A <= N <= B:
        X = X+n
        
print(X)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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


list_1 = [i for i in range(1,N+1)]

list_2 = []

for _ in list_1:
  if A<=check_num(_)<=B:
    list_2.append(_)
  else:
    pass
  
print(sum(list_2))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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


def sum_of_digits(n):
    res = 0
    while n > 0:
        res += n % 10
        n = math.floor(n / 10)
    return res


total = 0
for i in range(1, N+1):
    s = sum_of_digits(i)
    if s >= A and s <= B:
        total += i
print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1,N+1):
    if i < 10:
        if A<=i<=B:
            ans += i
    elif i < 100:
        a = i // 10
        b = i - a*10
        s = a+b
        if A<=s<=B:
            ans+=i
    elif i < 1000:
        a = i // 100
        b = (i-a*100)//10
        c = i-a*100-b*10
        s = a+b+c
        if A<=s<=B:
            ans+=i
    elif i < 10000:
        a = i // 1000
        b = (i-a*1000)//100
        c = (i-a*1000-b*100)//10
        d = i-a*1000-b*100-c*10
        s = a+b+c+d
        if A<=s<=B:
            ans+=i
    else:
        s = 1
        if A<=s<=B:
            ans+=i

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
data = stdin.read().splitlines()

n = int(list(data[0].split())[0])
a = int(list(data[0].split())[1])
b = int(list(data[0].split())[2])

i = 0
count = 0
while i <= n:
    s = sum(list(map(int, str(i))))
    if a <= s and s <= b:
        count = count + i
    i += 1
print(count)

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

Submission status: Accepted

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

res = 0

for i in range(1, n+1):
  tot = i%10 + i//10%10 + i//100%10 + i//1000%10 + i//10000
  if tot >= a and tot <= b:
    res += i

print(res)

Submission status: Accepted

Solution code:
def resolve():
    N, A, B = [int(i) for i in input().split()]
    sumA = 0
    for i in range(1, N + 1):
        tmp = eval("+".join(list(str(i))))
        if tmp < A or B < tmp:
            continue
        else:
            sumA += i
    print(sumA)


resolve()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
#nは10000以下
#1以上N以下の整数のうち、10進法での各桁の和がA以上B以下であるものの総和

elemtotal = []
elem = 0
for elem in range(1, n+1):
    n10000 = elem // 10000
    n1000 = (elem - 10000 * n10000) // 1000
    n100 = (elem - 10000 * n10000 - 1000 * n1000) // 100
    n10 = (elem - 10000 * n10000 - 1000 * n1000 - 100 * n100) // 10
    n1 = elem - 10000 * n10000 - 1000 * n1000 - 100 * n100 - 10 * n10
    ketatotal = n10000 + n1000 + n100 + n10 + n1
    if ketatotal >= a and ketatotal <= b:
        elemtotal.append(elem)

ans= sum(elemtotal)
print(ans)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
ans = 0
for i in range(int(n) + 1):
  ins = []
  sums = 0
  ins.append(i // 10000)
  ins.append((i % 10000) // 1000)
  ins.append((i % 1000) // 100)
  ins.append((i % 100) // 10)
  ins.append(i % 10)
  if sum(ins) >= a and sum(ins) <= 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 < 10):
        if(a <= i <= b):
            count += i
    else:
        s = str(i)
        ary = list(map(int,s))
        if(a <= sum(ary) <= b):
            count += i

print(count)

Submission status: Accepted

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

goodNumberSum = 0
goodNumbers = []

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

    # 各桁の和を求める
    digitSum = 0    # 各桁の和
    initDigits = n  # まだ足されていない残りの桁
    while initDigits > 0:
        lastDigit = initDigits % 10                  # 末尾の桁
        initDigits = int((initDigits - lastDigit) / 10)   # 末尾の桁を取り除く
        digitSum += lastDigit # 末尾の桁を足す

    # 条件を満たせば足す
    if A <= digitSum <= B:
        goodNumberSum += n

print(goodNumberSum)

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def dgsm(n):
    x=0
    while n>0:
        x+=n%10
        n//=10
    return(x)
ans=0
n,a,b=map(int, input().split())
for i in range(1,n+1):
    if a<=dgsm(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):
    lst=list(str(i))
    lst_int=[int(n) for n in lst]
    if a<=sum(lst_int)<=b:
        ans+=i

print(ans)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
cnt=0
for i in range(1,n+1):
    List=list(str(i))
    List=[int(j) for j in List]
    if a<=sum(List)<=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):
  d = i
  c = 0
  while d >0:
    c += (d%10)
    d = d // 10
#  print(i,c)
  if a <= c <= b:
    ans += i
print(ans)

Submission status: Accepted

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

def f(x):
    sum = 0
    while x > 0:
        sum += x % 10
        x //= 10
    return sum

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

print(count)

Submission status: Accepted

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

for i in range(N+1):
    S = list(str(i))
    S = list(map(int, S))
    total = sum(S)
    if A <= total <= B:
        lis.append(i)

print(sum(lis))

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n+1):
    s = 0
    i_ = i
    while i_ > 0:
        s += i_%10
        i_ //= 10
    if a <= s <= 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):
    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):
  h=list(str(i))
  tmp=0
  for j in h:
    tmp+=int(j)
  if a<=tmp<=b:
    ans+=i
print(ans)

Submission status: Accepted

Solution code:
n,a,b = map(str,input().split())
# al = list(map(int,input().split()))
a = int(a)
b = int(b)

lst = []
for x in range(1,int(n)+1):
    total = 0
    for i in str(x):
        total += int(i)
    if a <= total <= b:
        lst.append(x)

print(sum(lst))

Submission status: Accepted

Solution code:
def sumd(x):
  s=0
  while x>0:
    t=str(x)
    s+=int(t[-1])
    x//=10
  return s

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

Submission status: Accepted

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

Submission status: Accepted

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

for n in range(1,N+1):
  d = str(n)
  x = list(map(int, d))
  y = sum(x)
  
  if A <= y <= B:
    count += n

print(count)

Submission status: Accepted

Solution code:
# 10で割っていくやつ
[N, A, B] = list(map(int, input().split()))
sum = 0
a = 0
for i in range(1, N+1):
  n = i
  while n > 0:
    a += n % 10
    n //= 10
  if A <= a <= B:
    sum += i
    a = 0
  else:
    a = 0
    continue
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

#結果格納用
result = 0

#分解 &リスト化
for i in range(N+1):
    list_N = list(int(n) for n in str(i))
    #条件判定
    if (A <= sum(list_N)) and (B >= sum(list_N)):
        result += i
print(result)

Submission status: Accepted

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

for i in range(N + 1):
  sum = 0

  q = i // 10000
  sum += q
  x = i - 10000 * q

  q = x // 1000
  sum += q
  x = x - 1000 * q

  q = x // 100
  sum += q
  x = x - 100 * q

  q = x // 10
  sum += q
  x = x - 10 * q

  q = x // 1
  sum += q

  if A <= sum and sum <= B:
    ans += i

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))
#map(int,list(str(i)))もmap(int,str(i))も変わらない？前者は１つ前の提出。

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
SUM = 0
for i in range(1, N+1):
    j = i
    s = 0
    while True:
        if j == 0:
            break
        s += j%10
        j = j//10
    if A <= s <= B:
        SUM += i
print(SUM)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
"""
B - Some Sums
"""
ans = 0
#入力される数n, a, b
N, a, b = map(int, input().split())

def digitSum(n):
    d = str(n)   #iの数値を文字列に変換 d ←　下記eにおいてitrrableなものが求められるため文字列に変換する
    #print(d)
    e = list(map(int, d))   #1文字ずつ数値化し配列にする
    #print(e)
    f = sum(e)
    return f

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin

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


def sum_each(N):
    N_10000 = N // 10000
    N_1000 = N % 10000 // 1000
    N_100 = N % 1000 // 100
    N_10 = N % 100 // 10
    N_1 = N % 10
    return N_10000 + N_1000 + N_100 + N_10 + N_1


ans = 0
for a in range(N + 1):
    this = sum_each(a)
    if A <= this <= B:
        ans += a

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n, a, b = [int(x) for x in input().split()]

sum = 0
for k in range(n+1):
    orik = k
    ksum = 0
    while k > 0:
        last = k % 10
        k = int(k/10)
        ksum += last
    if a <= ksum <= b:
        sum += orik
print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

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

count = 0
for n in range(N+1):
  d1 = n//10**4
  d2 = (n-d1*10**4)//10**3
  d3 = (n-d1*10**4-d2*10**3)//10**2
  d4 = (n-d1*10**4-d2*10**3-d3*10**2)//10
  d5 = n%10

  if (A <= d1 + d2 + d3 + d4 + d5) and (B >= d1 + d2 + d3 + d4 + d5):
    count += d1*10**4 + d2*10**3 + d3*10**2 + d4*10 + d5
print(count)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
n,a,b = map(int,input().split())
res = 0
for i in range(n + 1):
    if a <= sum(list(map(int,list(str(i))))) <= b:
        res += i
print(res)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[5]:


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


# In[6]:


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


# In[ ]:

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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


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

Submission status: Accepted

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

for i in range(n+1)[1:]:
    l = i
    while l > 0:
        j = j + l % 10
        l = l // 10
    if a <= j and j <= b:
        k += i
    j = 0

print(k)

Submission status: Accepted

Solution code:
# coding-utf8 #

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

sum = 0
result = 0

for i in range(n):
  str_n = str(i + 1)
  for char in str_n:
    sum += int(char)
  if a <= sum <= b:
    result += (i + 1)
  sum = 0

print(result)

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
ans=0
for i in range(1,N+1):
    if i<=9:
        if A<=i<=B:
            ans+=i
    elif 10<=i<=99:
        I=str(i)
        a=int(I[0])
        b=int(I[1])
        if A<=a+b<=B:
            ans+=i
    elif 100<=i<=999:
        K=str(i)
        c=int(K[0])
        d=int(K[1])
        e=int(K[2])
        if A<=c+d+e<=B:
            ans+=i
    elif 1000<=i<=9999:
        K=str(i)
        c=int(K[0])
        d=int(K[1])
        e=int(K[2])
        f=int(K[3])
        if A<=c+d+e+f<=B:
            ans+=i
    elif i==10000:
        if A<=1<=b:
            ans+=10000
            
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
## coding: UTF-8
N, A, B = map(int,input().split())

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

Submission status: Accepted

Solution code:
def keisan(x):
  ret_val=0
  while x>0:
    ret_val+=x%10
    x//=10
  return ret_val

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N, A, B = map(int, input().split())
    ans = []
    for i in range(1, N+1):
        tmp = list(str(i))
        tmplist = [int(x) for x in tmp]
        s = sum(tmplist)
        if A <= s <= B:
            ans.append(i)
    print(sum(ans))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import numpy as np
# 複数個格納
# A,B = map(int, input().split())
#A = int(input())
# 行列化
# A = np.array(A)
# A=A.reshape(1,-1)
# A=A.T
#行列の比較
#C=((A%2 == vector0).all())
#行列の作成
#A=(np.arange(0,2000,500)).reshape(1,-1)

N,A,B = map(int, input().split())
count=0
for i in range(1, N+1):
    i1=i%10
    i2=((i-i1)%100)/10
    i3=((i-i1-i2*10)%1000)/100
    i4=((i-i1-i2*10-i3*100)%10000)/1000
    i5=(i-i1-i2*10-i3*100-i4*1000)/10000

    
    if  A<= i1+i2+i3+i4+i5 <=B:
        count=count+i

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 20200612_yorukatsu_a.py
N, A, B = map(int,input().split())
ans = 0
for i in range(N+1):
    tmp = str(i)
    _sum = 0
    for j in tmp:
        c=int(j)
        _sum+=c
    if _sum >=A and _sum <=B:
        ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

total = 0
for i in range(1, n+1):
    s = str(i)
    tmp = 0
    for j in s:
        tmp += int(j)
    if a <= tmp <= b:
        total += i
print(total)

Submission status: Accepted

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

Submission status: Accepted

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

resolve()

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
lis = []
for i in range(n):
    lis.append(i+1)

ans = []
for i in range(n):
    tmp = sum([int(x) for x in list(str(lis[i]))])
    if tmp >= a and tmp <= b:
        ans.append(lis[i])

print(sum(ans))

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

Submission status: Accepted

Solution code:
import math
from collections import deque
from collections import defaultdict

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

n,a,b = readInts()

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

Solution code:
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


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


def LS(): return list(sys.stdin.readline().rstrip().split())


N, A, B = LI()
ans = 0
for i in range(1, int(N)+1):
    si = str(i)
    sum = 0
    for sii in si:
        sum += int(sii)
    if A <= sum <= B:
        ans += i
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(list(map(int,str(i))))<=B]))