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(' '))
answer = 0
for i in range(N):
  n = sum(int(j) for j in str(i+1))
  if n >= A and n <= B:
    answer += i+1
print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
MM = input().split()
N = int(MM[0])
A = int(MM[1])
B = int(MM[2])
total = 0
for i in range(N+1):
  x = list(str(i))
  total1 = 0
  for j in x:
    
    total1 += int(j)
  
  if A<= total1 <= 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):
    s = str(i)
    sum = 0
    for ss in s:
        sum += int(ss)
    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):
    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())


X = [0]*10100
for i in range(len(X)):
  S = str(i)
  a = 0
  for c in S:
    a += int(c)

  X[i] = a

# print( X )

ans = 0
for i,x in enumerate(X[:N+1]):
  if A<=x and x<=B:
    ans += i
    # print(i, ans)

print(ans)

Submission status: Accepted

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

num_lists = list(range(1, n+1, 1))
sum_lists = []
for i in num_lists:
  count = 0
  j = i
  while j >0:
    ans = j%10
    count += ans
    j = j//10
  if a <= count and count <= b:
    sum_lists.append(i)

answer = 0
for i in sum_lists:
  answer += i

print(answer)

Submission status: Accepted

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

Submission status: Accepted

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


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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

def sum_of_digits(n):
   result   = 0
   quotient = n
   while quotient:
       result   +=  quotient % 10
       quotient //= 10
   return result

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

print(ans, flush=True)

Submission status: Accepted

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


#print(length_N)

count = 0
for i in range(1,N+1):
  total = 0
  string_N = list(str(i))
  length_N = len(str(i))
  
  for j in range(length_N):
    total += int(string_N[j])
  if total >= A and total <= B:
    count += i

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input().split()
n = int(s[0])
a = int(s[1])
b = int(s[2])

sums = []

for i in range(1, n + 1):
    x = i
    check = 0
    while (x > 0):
        y = x % 10
        x = int(x / 10)
        check += y
    if a <= check <= b:
        sums.append(i)

answer = 0
for i in range(len(sums)):
    answer += sums[i]

print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, a, b = map(int, input().split())
    r = 0
    for i1 in range(1, n + 1):
        i1sum = 0
        i1org = i1
        while i1:
            i1sum += i1 % 10
            i1 = i1 // 10
        if a <= i1sum <= b:
            r += i1org
    print(r)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, a, b = map(int, input().split())
    r = 0
    for i1 in range(1, n + 1):
        i1sum = sum(tuple(map(int, str(i1))))
        if a <= i1sum <= b:
            r += i1
    print(r)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

while count <= n:

    c_check = 0
    count_temp = count
    while 1:
        c_check += count_temp % 10
        count_temp = int(count_temp/10)
        if count_temp<1:
            break

    if a <= c_check and b >= c_check:
        sum += count

    count += 1


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

n, a, b = map(int, open(0).read().split())

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

Submission status: Accepted

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

ans_list = []
for i in range(N + 1):
    n = i
    local_sum = 0
    for j in reversed(range(len(str(i)))):
        local_sum += n // (10 ** j)
        n -= n // (10 ** j) * (10 ** j)
    if A <= local_sum and local_sum <= B:
        ans_list.append(i)
print(sum(ans_list))

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
cnt = 0
for i in range(1,N+1):
  if i<10:
    if A <= i <= B:
      cnt += i
  elif 10 <= i < 100:
    if A <= int(str(i)[0])+int(str(i)[1]) <= B:
      cnt += i
  elif 100 <= i < 1000:
    if A <= int(str(i)[0])+int(str(i)[1])+int(str(i)[2]) <= B:
      cnt += i
  elif 1000 <= i < 10000:
    if A <= int(str(i)[0])+int(str(i)[1])+int(str(i)[2])+int(str(i)[3]) <= B:
      cnt += i
  else:
    if A <= 1 <= B:
      cnt += i
print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
import sys
sys.setrecursionlimit(10 ** 5)
input = sys.stdin.readline
mod = 1000000007
inf = float("INF")
def I(): return int(input().rstrip())
def IR(n): return [I() for _ in range(n)]
def LI(): return list(map(int, input().rstrip().split()))
def LIR(n): return [LI() for _ in range(n)]
def LI_(): return list(map(lambda x: int(x) - 1, input().rstrip().split()))
def LIR_(n): return [LI_() for _ in range(n)]
def F(): return float(input().rstrip())
def FR(n): return [F() for _ in range(n)]
def LF(): return list(map(float, input().rstrip().split()))
def LFR(n): return [LI() for _ in range(n)]
def S(): return input().rstrip()
def SR(n): return [S() for _ in range(n)]
def LS(): return list(sys.stdin.readline().rstrip().split())
def LSR(n): return [LS() for _ in range(n)]
# ↑template↑
# ↓solution↑
n, a, b = LI()
def digitSum(i):
    s = str(i)
    ary = list(map(int, s))
    return sum(ary)
res = 0
for n in range(n+1):
    if a <= digitSum(n) <= b:
        res += n
print(res)

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:
INPUT = list(map(int, input().split()))

N = INPUT[0]
A = INPUT[1]
B = INPUT[2]

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

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split(" "))
sum = 0
for e in range(a, n + 1):
    c = 0
    ee = e
    while True:
        c += e % 10
        e = e // 10
        if e == 0:
            break
    if a <= c <= b:
        sum += ee
print(sum)

Submission status: Accepted

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


def read():
    N, A, B = map(int, input().strip().split())
    return N, A, B


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


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#n=int(input())
n,a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

def sum_of_digit(n):
    res=0
    while n>0:
        res+=n%10
        n=n//10
    return res
count=0
for i in range(1,n+1):
    if a<= sum_of_digit(i) and sum_of_digit(i) <=b :
        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):
    a = i
    tot = 0
    while a > 0:
        tot += a%10
        a //= 10
    if A <= tot <= B:
        ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0

while current <= n:
    
    number = str(current)
    length = len(number)
    
    allsum = 0
    
    for i in range(length):
        allsum += int(number[i])
        
    if a <= allsum and allsum <= b:
        cnt += current
    
    current += 1

print(cnt)

Submission status: Accepted

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

result = 0

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

for i in range(n):
    x = check(i+1)
    if a <= x and x <= b:
        result += i+1

print(result)

Submission status: Accepted

Solution code:
n,a,b = map(int, open(0).read().split())

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

Submission status: Accepted

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


n, a, b = map(int, input().split())
ans = 0
for i in range(1, n + 1):
    if a <= s(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):
    add = sum(list(map(int, str(i))))
    if A <= add and add <= B:
        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):
    sum_digits = sum([int(c) for c in str(i)])
    if a <= sum_digits <= b:
        ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
	sum_ = 0
	m = i

	while True:
		sum_ += m % 10
		m //= 10
		if not m:
			break
	if a <= sum_ <= 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):
    c=0
    d=i
    while d>0:
        c+=d%10
        d//=10
    if a<=c<=b:
        sum+=i
    
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for i in range(1,N + 1):
  a = i
  digit_sum = 0
  while a > 0:
    digit_sum += a%10
    a //= 10
  if A <= digit_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):
    i = str(i)
    val = 0
    for j in range(len(i)): val += int(i[j])
    if A <= val <= B: ans += int(i)
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):
    tmp_l = list(str(i))
    tmp_sum = 0
    for j in tmp_l:
        tmp_sum = tmp_sum + int(j)
    if A <= tmp_sum <= B:
        ans = ans + i

print(ans)

Submission status: Accepted

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

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:
n, a, b = map(int, input().split())
ans = []
for i in range(1, n+1):
  if a <= sum(map(int, list(str(i)))) <= b:
    ans.append(i)
print(sum(ans))

Submission status: Accepted

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

ans = 0
for i in range(1,N+1):
    a = 0
    j = i
    while i != 0:
        a += i % 10
        i //= 10
    if A <= a <= B:
        ans += j

print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

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

s_list=[]
for i in range(1,n+1):
    s=0
    x=i
    while True:
        if x//10!=0:
            s+=x%10
            x//=10
        else:
            s+=x%10
            break
    if a<=s<=b:
        s_list.append(i)

print(sum(s_list))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, a, b = map(int, input().split())
c = 0
for i in range(1, n + 1):
    if a <= sum(int(i) for i in str(i)) <= b:
        c += i
print(c)

Submission status: Accepted

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

# check
res = sum([n for n in range(1, N + 1) if A <= sum(list(map(int, str(n)))) <= B])
print(res)

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(map(int, str(i))) <= b)
print(ans)

Submission status: Accepted

Solution code:
int_list = list(map(int,input().split()))
tes = list(map(int,str(int_list[0])))
res = 0
for i  in range(1,int_list[0] + 1):
    tes = list(map(int,str(i)))
    
    if (sum(tes) >= int_list[1])&(sum(tes) <= int_list[2]):
        res += i
        
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
N,a,b = (int(x) for x in input().split())
z = 0
for I in range (N):
    o = 0
    i = I+1
    while True:
        o += i%10
        i = math.floor(i/10) 
        if i == 0:
            if a <= o <= b:
                z += I+1
            break
print (z)

Submission status: Accepted

Solution code:
# B Some Sums

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

ans = 0
for ni in range(1, n+1):
  sum = 0
  for nij in str(ni):
    sum += int(nij)
  if sum >= a and sum <= b:
    ans += ni
    
print(ans)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
total = 0
for i in range(1, n + 1):
    num = 0
    str_i = str(i)
    list_i = list(str_i)
    for j in range(len(list_i)):
        num += int(list_i[j])
    if a <= num and num <= 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):
  s=str(i)
  x=0
  for j in s:
    x+=int(j)
    
  if A<=x<=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):
    s = str(i)
    if A <= sum(int(t) for t in s) <= B:
        res += i
print(res)

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(map(int, str(i))) <= b)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
 
Alltotal=0
for i in range(1,N+1):
  partTotal=0
  temp=i
  while temp!=0:
    partTotal+=temp%10
    temp=temp//10
    
  if A<=partTotal and partTotal<=B:
    Alltotal+=i
    #print(i)
print(Alltotal)

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:
def main():
    N, A, B = (int(x) for x in input().split(" "))
    total = 0
    for n in range(1, N+1):
        sum_digit = sum([int(x) for x in str(n)])
        if A <= sum_digit & sum_digit <= B:
            total += n
    print(total)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, a, b = map(int, input().split())
ans = 0

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

print(ans)

Submission status: Accepted

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

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, str(i)))
    if A <= s <= B:
        ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy


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

    num = 0
    for i in range(n+1):
        for j in range(len(str(i))):
            m = str(i)[j]
            num += int(m)

        if a <= num <= b:
            ans += i
        num = 0

    print(ans)

if __name__ == '__main__':
	main()

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 0
for i in range(1, n + 1):
  t = 0
  k = i
  while(True):
    t += k % 10
    k = int(k / 10)
    if k == 0:
      break
  if a <= t <= b:
    ans += i

print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

N,A,B=map(int,input().split())
ans=0
for i in range(1,N+1):
    if A<=f(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):
    t = i
    tmp = 0
    while i > 0:
        ten = i % 10
        tmp += ten
        i //= 10
    
    if a <= tmp <= b:
        ans += t

print(ans)

Submission status: Accepted

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

for i in range(1,n + 1):
    length = len(str(i)) # iの桁数
    ele = []
    # 各桁の和
    l = str(i)
    array = list(map(int, l))
    s = sum(array)
    if a <= s and s <= b:
        total += i
print(total)

Submission status: Accepted

Solution code:
def count(n):
    sum = 0
    l = [int(x) for x in list(str(n))]
    for i in l:
      sum += i 
    return sum 
  
N,A,B = map(int,input().split())
i = 1
counter = 0
while i <= N:
  if A <= count(i) <= B:
    counter += i
  i += 1
print(counter)

Submission status: Accepted

Solution code:

def actual(N, A, B):
    satisfied_nums = []

    for i in range(1, N + 1):
        sum_of_digits = 0
        num = i
        for _ in range(5):
            sum_of_digits += num % 10
            num //= 10

        if A <= sum_of_digits <= B:
            satisfied_nums.append(i)

    return sum(satisfied_nums)

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

Submission status: Accepted

Solution code:
def actual(N, A, B):
    satisfied_nums = []

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

        if A <= sum_of_digits <= B:
            satisfied_nums.append(i)

    return sum(satisfied_nums)

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

Submission status: Accepted

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

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

find_list=[]    
for x in range(1,N+1):
    if A<=findsum0fdigit(x)<=B:
        find_list.append(x)
        
print(sum(find_list))

Submission status: Accepted

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

sum_list=[]
for x in range(1,N+1):
    #万の位
    a=x//10000
    #千の位
    b=(x%10000)//1000
    #百の位
    c=((x%10000)%1000)//100
    #10の位
    d=(((x%10000)%1000)%100)//10
    #1の位
    e=(((x%10000)%1000)%100)%10
    
    
    if A<=(a+b+c+d+e)<=B:
        sum_list.append(x)
        
print(sum(sum_list))

Submission status: Accepted

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

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

Submission status: Accepted

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

ans_list = []
for i in range(1, n+1):
  if i <= 9:
    if a <= i <= b:
      ans_list.append(i)
  elif 10 <= i <= 99:
    i10 = i // 10
    i1 = i % 10
    if a <= i10+i1 <= b:
      ans_list.append(i)
  elif 100 <= i <= 999:
    i100 = i // 100
    i10 = (i % 100) // 10
    i1 = (i % 100) % 10
    if a <= i100+i10+i1 <= b:
      ans_list.append(i)
  elif 1000 <= i <= 9999:
    i1000 = i // 1000
    i100 = (i % 1000) // 100
    i10 = ((i % 1000) % 100) // 10
    i1 = ((i % 1000) % 100) % 10
    if a <= i1000 +i100 +i10 +i1 <= b:
      ans_list.append(i)
  else:
    if a <= 1 <= b:
      ans_list.append(i) 

print(sum(ans_list))

Submission status: Accepted

Solution code:
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline().rstrip()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

N, A, B = iInM()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 入力をN,A,Bに代入
N,A,B = map(int,input().split())

# 結果変数を0で初期化
result=0

# 1からNまでを一つずつ加算しながらiに代入
for i in range(1,N+1):
    
    # iを文字型化
    i=str(i)
   
    # 各桁を数値化し、リストの要素として追加(内包表記)
    somesums_list=[int(j) for j in i]    #iと言う数字が何桁かは分からないが、それの角桁の数字を１つずつ数値化し、リストに追加した
    # リストの要素を全て合計
    sumlist=sum(somesums_list)
    # リストの合計値がA以上B以下か判定
    if sumlist <= B and  A <= sumlist:  
        # 結果変数にiを加算
        result=result+int(i)#iが文字列になっていたので、足し算するために数値化する
# 結果変数をプリント
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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