Problem:


Score : 200 points

Problem Statement

Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).

Constraints

1 \leq N \leq 10^4

1 \leq A \leq B \leq 36

All input values are integers.

Input

Input is given from Standard Input in the following format:

N A B

Output

Print the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).

Sample Input 1

20 2 5

Sample Output 1

84

Among the integers not greater than 20, the ones whose sums of digits are between 2 and 5, are: 2,3,4,5,11,12,13,14 and 20. We should print the sum of these, 84.

Sample Input 2

10 1 2

Sample Output 2

13

Sample Input 3

100 4 16

Sample Output 3

4554



Sample input:
20 2 5


Sample output:
84

Submission status: Accepted

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

ans = 0
for val_int in range(1,N+1):
  num = 0
  val_str = str(val_int)
  for j in val_str:
    num += int(j)
  if A <= num and num <= B:
    ans += val_int

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = list(map(int,input().split()))
sum = 0
for i in range(1,x[0]+1):
    if i == 10000:
        b=1
    else:
        a3 = int(i/1000)
        a2 = int((i-1000*a3)/100)
        a1 = int((i-1000*a3-100*a2)/10)
        a0 = i-1000*a3-100*a2-10*a1
        b = a0+a1+a2+a3
    if b>=x[1] and b<=x[2]:
        sum += i
print(sum)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

def sumdigits(i):
  return i%10 + i//10%10 + i//100%10 + i//1000%10 + i//10000%10

print(sum([i if A<=sumdigits(i)<=B else 0 for i in range(1, N+1)]))

Submission status: Accepted

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

result = 0

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

print(result)

Submission status: Accepted

Solution code:
N,A,B=[int(i) for i in input().split(" ")]
sum = 0
for n in range(N+1):
    t,v = n,0
    for i in reversed(range(5)):
        v+=int(t/pow(10,i))
        t-=int(t/pow(10,i)) * pow(10,i)
    if A <= v <= B:
        sum+=n
print (sum)

Submission status: Accepted

Solution code:
# coding: utf-8
nab =input().split()
n = nab[0]
a = int(nab[1])
b = int(nab[2])
x = 0
for i in range(1,int(n)+1):
  temp = 0
  for j in range(len(str(i))):
    temp += int(str(i)[j:j+1])
  if temp>=a and temp<=b:
    x +=i

print(x)

Submission status: Accepted

Solution code:
A = list(map(int,input().split() ) )
total = 0

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

for i in range(1,int(A[0]+1)):
  temp = findSumofDigits(i)
  if (A[1] <= temp) and (temp <= A[2]):
    total += i
print(int(total))

Submission status: Accepted

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

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 and s <= b:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
#4569=n
t = 0
for i in range(1, n+1):
    ans = 0
    s = i
    while s!=0:
        amari = s%10
        s = int(s/10)
        ans += amari
    if a <= ans <= b:
        t += i
print(t)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

c = 0
s = 0
ans = 0
k = 0

for i in range(1,n+1):
    s = 0
    k += 1
    while i != 0:
        s += i % 10
        i = i // 10
    if a <= s <= b:
        ans += k
        
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

counter = [0 for _ in range(N+1)]
ans = 0

for i in range(1,N+1):
    for j in str(i):
        counter[i] += int(j)
    if A<= counter[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):
    num_sum = 0
    for j in str(i):
        num_sum += int(j)
    if A<= num_sum <= B:
        ans += i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def in_range(x: int, lower: int, upper: int) -> bool:
    return lower <= x and x <= upper


def digit_sum(n: int) -> int:
    s = 0
    while n > 0:
        s += n % 10
        n //= 10
    return s


def some_sums(N: int, A: int, B: int) -> int:
    return sum(n+1 for n in range(N) if in_range(digit_sum(n+1), A, B))


if __name__ == "__main__":
    N, A, B = map(int, input().split())
    ans = some_sums(N, A, B)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc083/tasks/abc083_b
import itertools
import collections
import bisect
import sys
input = sys.stdin.readline

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
count = 0
for i in range(1, N+1):
    sum = 0
    cur = i
    for j in range(0, 5):
        q, cur = divmod(cur, 10**(4-j))
        sum = sum+q
    if A<=sum<=B:
        count = count+i
print("{}".format(count))

Submission status: Accepted

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

Submission status: Accepted

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

def sumQ5(num):
    ret = 0
    for s in str(num):
        ret += int(s)
    return ret
ret = 0
for i in range(N+1):
    total = sumQ5(i)
    if A<=total and total<=B:
        ret += i
print(ret)

Submission status: Accepted

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

count = 0

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

    if A <= n and n <= B:
        count += i
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(cnt)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
answer = 0
m = 0
for i in range(n+1) :
  if i < 10 ** 1 :
    if a <= i and b >= i :
      answer = answer + i
  elif i < 10 ** 2 :
    m = int(str(i)[0]) + int(str(i)[1])
    if a <= m and b >= m :
      answer = answer + i
  elif i < 10 ** 3 :
    m = int(str(i)[0]) + int(str(i)[1]) + int(str(i)[2])
    if a <= m and b >= m :
      answer = answer + i
  elif i < 10 ** 4 :
    m = int(str(i)[0]) + int(str(i)[1]) + int(str(i)[2]) + int(str(i)[3])
    if a <= m and b >= m :
      answer = answer + i
  elif i < 10 ** 5 :
    m = int(str(i)[0]) + int(str(i)[1]) + int(str(i)[2]) + int(str(i)[3]) + int(str(i)[4])
    if a <= m and b >= m :
      answer = answer + i

print(answer)

Submission status: Accepted

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

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

Submission status: Accepted

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

count = 0

for i in range(1, n + 1):
    count_rem = 0
    j = i
    while j > 0:
        rem = j % 10
        count_rem += rem
        j = j // 10
    if a <= count_rem <= b:
        count += i

print(count)

Submission status: Accepted

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

for i in range(1, N+1):
    Nsum = 0
    temp = i
    while (temp > 0):
        Nsum += int(temp % 10)
        temp /= 10
    if Nsum >= A and Nsum <= B:
        ResSum += i

print(ResSum)

Submission status: Accepted

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

l = []
for i in range(n+1):
    s = str(i)
    sum_ = 0
    for x in s:
        sum_ += int(x)
    
    if a <= sum_ and sum_ <= b:
        l.append(i)

print(sum(l))

Submission status: Accepted

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

    total_sum = 0
    for n in range(1,N+1):
        n_each_sum = sum(map(int, list(str(n))))

        if n_each_sum >= A and n_each_sum <= B:
            total_sum += n

    print(total_sum)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def sum_of_digits(n):
    answer = 0
    while True:
        if n == 0:
            break
        else:
            answer += n%10
            n = n // 10
    return answer
    
answer = 0
N, A, B = map(int, (input().split()))

for i in range(N+1):
    count = sum_of_digits(i)
    if(A<=count & count <= B):
        answer += i
        
    
print(answer)

Submission status: Accepted

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

N, A, B = map(int, input().split())
count = 0
for i in range(N):
  sum = sumcal(i + 1)
  if sum >= A and sum <= B:
    count += i + 1
print(count)

Submission status: Accepted

Solution code:
import sys

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

    ans = 0
    for i in range(N+1):
        a = [0] * 5
        a[0] = i // 10**4
        a[1] = (i % 10**4) // 10**3
        a[2] = (i % 10**3) // 10**2
        a[3] = (i % 10**2) // 10
        a[4] = i % 10

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
a2 = 0

while a > 0:
    a1 = a
    l = []
    while a1 >= 1:
        l.append(int(a1 % 10))
        a1 = a1 / 10
    if sum(l) >= b and sum(l) <= c:
        a2 = a2 + a

    a = a - 1
print(a2)

Submission status: Accepted

Solution code:
def digsum(n):
  tmp = 0
  for i in str(n):
    tmp += int(i)
  return tmp

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

ans = 0
for i in range(N+1):
  if A <= digsum(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):
  hoge=1+i
  huga=0
  for j in range(5):
    huga+=hoge%10
    hoge=int(hoge/10)
  
  if(a<=huga and huga<=b):
    ans+=1+i

print(ans)

Submission status: Accepted

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

numbers = list(range(1, N + 1))
digit_sums = [0] * N

for i in range(N):
    j = i + 1
    while j != 0:
        digit_sums[i] += j % 10
        j = int(j / 10)

digit_sums = [0 if (i < A or i > B) else 1 for i in digit_sums]
ans = [i * j for (i, j) in zip(numbers, digit_sums)]
print(sum(ans))

Submission status: Accepted

Solution code:
import numpy as np
import sys

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

total = 0

for i in range(N):
    N_quotient_1 = 0
    N_quotient_2 = 0
    N_quotient_3 = 0
    N_quotient_4 = 0
    N_quotient_5 = 0

    sum = 0

    j = i + 1
    if j == 10000:
        N_quotient_1 = int(j / 10000)
        if A == 1:
            total += 10000
            print(total)
            sys.exit()
    if j >= 1000:
        N_quotient_2 = int(j / 1000)
    if j >= 100:
        N_quotient_3 = int((j - N_quotient_2 * 1000) / 100)
    if j >= 10:
        N_quotient_4 = int((j - N_quotient_2 * 1000 - N_quotient_3 * 100) / 10)
    if j >= 1:
        N_quotient_5 = int((j - N_quotient_2 * 1000 - N_quotient_3 * 100 - N_quotient_4 * 10) / 1)

    sum = N_quotient_1 + N_quotient_2 + N_quotient_3 + N_quotient_4 + N_quotient_5

    if A <= sum <= B:
        total += j

print(total)

Submission status: Accepted

Solution code:
n, a, b = list(map(int, input().split(' ')))
ss = 0
for i in range(1, n + 1):
    x = i
    s = 0
    br = False
    while x > 0:
        s += x % 10
        x = int(x / 10)
        if s > b:
            br = True
            break
    if not br and s >= a:
        ss += i
print(ss)

Submission status: Accepted

Solution code:
N, A, B = map(int,input().split())
sum_element = []
for i in range(N+1):
    ketawa = 0
    i_temp = i
    for j in range(5):
        k = 4-j
        syou = i_temp//(10**k)
        ketawa += syou
        i_temp = i_temp - syou*(10**k)
    if A<=ketawa<=B:
        sum_element.append(i)
print(sum(sum_element))

Submission status: Accepted

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

lres = []
for n in range(N + 1):
    s = 0
    for _n in str(n):
        s += int(_n)
    if A <= s and s <= B:
        lres.append(n)
print(sum(lres))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
###ABC083B - Some Sums
n, a, b = map(int, input().split())
sums = 0

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

Submission status: Accepted

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

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

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:
N, A, B = map(int,input().split())

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

Submission status: Accepted

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


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

for i in range(n+1):
    if a <= calc(i) & calc(i) <= b:
        total += i

print(total)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
answer = 0
for i in range(N + 1):
    t = 0
    k = i # int型の場合はコピーされる
    while i > 0:
        t += i % 10
        i = i //10
    if A<= t <= B:
        answer += k
print(answer)

Submission status: Accepted

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


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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

print(num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
i = 0
total = 0
arr = [num for num in range(1,N+1)]
while len(arr) > i:
	if A <= arr[i] and arr[i] <= B and arr[i] < 10:
		total += arr[i]
	if arr[i] >= 10:
		u10 = list(str(arr[i]))
		splt = sum([int(num)  for num in u10])
		if A <= splt and splt <= B:
			total += arr[i]
	i += 1
print(total)

Submission status: Accepted

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

def digits_sum(n):
  n = str(n)
  n = list(n)
  for i in range(len(n)):
    n[i] = int(n[i])
  return sum(n)

for i in range(1,N+1):
  if(A<=digits_sum(i)<=B):
   sum_all += i

print(sum_all)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
ans = 0
for n in range(1, N+1):
  tmp = n
  i = 4
  s = 0
  while i > -1:
    keta = tmp // (10 ** i)
    tmp -=  keta * (10 ** i)
    s += keta
    i -= 1
  if s >= A and s <= B:
    ans += n
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import exit
N,A,B = [int(n) for n in input().split()]
ans=0
for i in range(1,N+1):
    s = list(str(i))
    sums = sum([int(n) for n in s])
    if A <=sums and sums<=B:
        ans+=i
print(ans)

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin

n, a, b = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0

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

print(ans)

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 = sum(list(map(int, list(str(i)))))
    if s >= A and 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):
    judge=0
    for j in str(i):
        judge+=int(j)
    if judge>=a and judge<=b:ans+=i
print(ans)

Submission status: Accepted

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

def sumofdigit(x):
  ans = 0
  while(x>0):
    ans+=x%10
    x=int(x/10)
  return ans

sum = 0
for i in range(1,N+1):
  tmp = sumofdigit(i)
  if tmp >= A and tmp <= 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(list(map(int, list(str(i))))) <= 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):
    l=list(map(int,str(i)))
    """"""
    #なぜできない？
    lengh=len(l)
    #print(l,lengh)
    s=0
    for j in range(lengh):
        s=+l[j]
        #print("s=",s)
    """"""
    s=sum(l)
    if a<=s and s<=b:
        #print("i=",i)
        ans+=i
print(ans)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
cnt=0
for i in range(n+1):
    s=str(i)
    su=0
    for j in range(len(s)):
        su+=int(s[j])
    if su>=a and su<=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):
    tot = sum(list(map(int,str(i))))
    if A<=tot<=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):
    tot = sum(list(map(int,list(str(i)))))
    if A<=tot<=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):
    digit=0
    tmp = i
    while(i!=0):
     digit+=i%10
     i = int(i/10)
    if(digit>=A and digit<=B):
         ans+=tmp
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):
    s=sum([int(j) for j in str(i)])
    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):
    q=sum([int(j) for j in str(i)])
    if a<=q and q<=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):
    judge = i%10 + (i%100 - i%10)//10 + (i%1000 - i%100)//100 + (i%10000 - i%1000)//1000 + (i%100000 - i%10000)//10000
    if judge >= a and judge <= b:
        count += i
print(count)

Submission status: Accepted

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

answer = 0

def sum_deci(n):
    out_sum_deci = 0
    
    while(n > 0):
        out_sum_deci = n % 10 + out_sum_deci
        n = int(n / 10)
        
    return out_sum_deci

'''
print(sum_deci(N))
'''

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

print(answer)

Submission status: Accepted

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

for i in range(1, n+1):
    sum_i = i%10 + (i//10)%10 +(i//100)%10 + (i//1000)%10 + (i//10000)%10
    if a <= sum_i <= b:
        sum += i

print(sum)

Submission status: Accepted

Solution code:
def digisum(N):
    if N == 10000:
        return 1
    elif N < 10:
        return N
    elif N < 100:
        return (N//10) + (N%10)
    elif N < 1000:
        return (N//100) + ((N%100)//10) +(N%10)
    else:
        return (N//1000) + ((N//100)%10) + ((N%100)//10) +(N%10)

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

for i in range(n+1):
    test = digisum(i)
    if test >= a and test <= 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):
  m = i
  wa = 0
  while True:
    wa += m % 10
    m = m // 10
    if (m == 0):
      break
  if (wa >= a)and(wa <= b):
    total += i
print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
u=0
for i in range(N):
    s=i+1
    t=0
    while s>0:
        t+=s%10
        s=(s-s%10)//10
    if A<=t and t<=B:
        u+=i+1
print(u)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 27 17:56:34 2019

@author: yuta
"""

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

def main(n,a,b):
    somesum = 0
    for i in range(1,(n+1)):
        x = [0]*5
        for j in range(1,5):
            x[j] = int(i/(10**j)) % 10
            x[0] = i % 10
            s = sum(x)
        if a <= s <= b:
            somesum += i
    print(somesum)
main(n[0],n[1],n[2])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

cursum = 0

for x in range(1, n+1):
    y = sum(map(int, str(x)))
    if a <= y and y <= b:
        cursum += x

print(cursum)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
number = range(A, N+1)
number_str = list(map(str, number))
arc = []
for item in number_str:
    num = list(map(int, item))
    s = sum(num)
    if A <= s and s <= B:
        arc.append(int(item))
print(sum(arc))

Submission status: Accepted

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

ans = 0
for i in range(1,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() )

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

print( ans )

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
ans = 0
for i in range(a[0]+1):
    num = [int(c) for c in str(i)]
    if (sum(num) >= a[1]) & (a[2] >= sum(num)) :
        ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split());c=0
while n:c+=n*(a<=sum(map(int,str(n)))<=b);n-=1
print(c)

Submission status: Accepted

Solution code:
def sum(i):
  t=0
  while True:
    if i==0:
      return t
    else:
      t +=i%10
      i //=10
      
N,A,B = [int(i) for i in input().split()]
s = 0

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

Submission status: Accepted

Solution code:
def sum(i):
  t=0
  while True:
    if i==0:
      return t
    else:
      t+=i%10
      i//=10

N,A,B=[int(i) for i in input().split()]
s=0
for i in range(1,N+1):
  if sum(i)<=B and sum(i)>=A:
    s+=i
print(s)

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
ans=0
for i in range(N+1):
    #numlst=list(str(i))
    #sumofdigit=sum(map(int,numlst))
    #if A<=sumofdigit<=B:
    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())
count=0
for i in range(1,n+1):
    k=list(str(i))
    k=list(map(int,k))
    
    if sum(k)<=b and sum(k)>=a:
        count+=i

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

def digit_sum(num):
    nstr = str(num)
    cdigs = list(nstr)
    idigs = [int(x) for x in cdigs]
    
    return sum(idigs)

nums = range(1, N + 1) 

focus = [
    x for x in nums 
    if digit_sum(x) in range(A, B + 1)
    ]

s = sum(focus)

print(s)

Submission status: Accepted

Solution code:
n, a, b = [int(x) for x in input().split()]
sum_nums = 0
for i in range(1,n+1):
    sum_digits = 0
    j = int(i)
    while j > 0:
        sum_digits += j%10
        j //= 10
    if a <= sum_digits <= b:
        sum_nums += i
print(sum_nums)

Submission status: Accepted

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

Submission status: Accepted

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

l=[]

	
for i in range(1,n+1):
	#print(i)
	d=i
	count=0
	while(i!=0):
		count+=i%10
		#print(count)
		i=int(i/10)	
	if(a<=count and count<=b):
		l.append(d)

#print(l)
#print(count)
print(sum(l))