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 i in range(n + 1):
    X = list(str(i))
    y = sum(map(int, X))
    if a <= y <= b:
        ans += i
        
print(ans)

Submission status: Accepted

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

s=0
for i in range(n+1):
    x = i
    m = 0
    while x:
        m += x % 10
        x //= 10
    if a <= m <= 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):
  s = str(i)
  if A <= sum(list(map(int, list(s)))) <= B:
    ans += i
    
print(ans)

Submission status: Accepted

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

sum1 = 0

for i in range(1,n+1):
  sum = 0
  N = list(str(i))
  for j in N:
    sum += int(j)
  
  if a<=sum <= b:
    sum1 += i
    
print(sum1)

Submission status: Accepted

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

ans = 0
for i in range(1, N + 1):
    j = i
    l = []
    while i > 0:
        l.append(i % 10)
        i //= 10

    c = sum(l)
    if c >= A and c <= B:
        ans += j

print(ans)

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

for i in range(N+1):
    d1 = int(i%10)
    d2 = int(i//10%10)
    d3 = int(i//100%10)
    d4 = int(i//1000%10)
    d5 = int(i//10000%10)
    d = d1+d2+d3+d4+d5
    if d >= a and d <= 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 A<=sum(map(int,str(i)))<=B:
        count+=i
print(count)

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
total_num = 0
cnt = 0
for i in range(1,N+1):
    num = i
    for j in range(5): # N <= 10**4より
        total_num +=  num % 10
        num = num // 10
    if A <= total_num <= B:
        cnt += i
    total_num = 0
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(map(int, list(str(i)))) <= B:
    ans += i
 
print(ans)

Submission status: Accepted

Solution code:
n,a,b = input().split()
s = []
c = 0
arr = []
ans = []

for i in range(1,int(n)+1):
  arr.append(str(i))
#print(arr[18][1])

for i in range(0,len(arr)):
  tmp = 0
  for j in range(0,len(arr[i])):
    tmp += int(arr[i][j])
    #print(arr[i][j])
  s.append(tmp)

for i in range(0,len(s)):
  if(s[i] >=int(a) and s[i] <= int(b)):
    ans.append(i+1)
    
print(sum(ans))

Submission status: Accepted

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

for i in range(1, n + 1):
    tmp = i
    x = 0
    for j in range(5)[::-1]:
        x += tmp // (10**j)
        tmp = tmp - (tmp // (10**j))*(10**j)
        
    if a <= x <= 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):
    __s = 0
    s = str(i)
    for _s in s:
        __s += int(_s)
    if  __s >= a and __s <= b:
        ans += i
print (ans)

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
sum = 0
array = []
for i in range(1,N+1):
    array.append(list(str(i)))

for i in range(N):
    value = 0
    for j in range(len(array[i])):
        value += int(array[i][j])
    if A <= value <= B:
        sum += int(''.join(array[i]))
print(sum)

Submission status: Accepted

Solution code:
# B - Some Sums
N,A,B= map(int,input().split())
cnt = 0
for n in range(1,N+1):
    tmp = sum([int(i) for i in str(n)])
    if A<=tmp and tmp <= B:
        cnt+=n
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

count = 0

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)

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

ans = 0

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

for i in range(1, n+1):
    sum = 0
    num = i
    while num > 0:
        sum += num%10 # 10で割ったあまりを取得することで最下位桁を取る
        num = num//10 # 10で割った商を取得することで一桁ずらす
    if a <= sum <=b:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)

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

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1, N+1):
    sums = i//10000 + (i%10000)//1000 + (i%1000)//100 + (i%100)//10 + i%10
    if sums >= A and sums<= B:
        score += i

print(score)

Submission status: Accepted

Solution code:

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

count = 0

for i in range(n):

    s = str(i + 1)
    array = list(map(int, s))
    total = sum(array)

    if a <= total <= b:
        count += (i + 1)

print(count)

Submission status: Accepted

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

count = 0
sum1 = 0

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

Submission status: Accepted

Solution code:
def num_list(n):
    le = len(str(n))
    m = []
    for j in range(le):
        if j == le-1:
            m.append(n % 10)
        elif 0 < j < le-1:
            x = (n % (10 ** (le - j))) // (10 ** (le - j - 1))
            m.append(x)
        elif j == 0:
            m.append(n // (10 ** (le - 1)))
    return m


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

total = 0
for i in range(1, N+1):
    y0 = num_list(i)
    y = sum(num_list(i))
    if A <= y <= B:
        total += i
print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


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


N, A, B = invr()

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

n_list = list(range(0,n + 1))

result_sum = 0
for i in n_list :
    i_str = list(str(i))
    #print(i_str)
    i_sum = 0
    for t in i_str :
        i_sum = i_sum + int(t)
    #print(i_sum)
    if i_sum >= a and i_sum <= b :
        result_sum = result_sum + i
print(result_sum)

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:
vals=input().split(' ')
N=int(vals[0])
A=int(vals[1])
B=int(vals[2])

total=0

number=1
while number<=N:
  subtotal=0
  for n in str(number):
    subtotal+=int(n)
  if A<= subtotal & subtotal <= B:
    total+=number
  number+=1

print(total)

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
N, A, B = map(int, input().split())
s = 0
for i in range(1, N+1):
    n = i
    m = 0
    while n > 9:
        m += n % 10
        n = n // 10
    m += n
    if A <= m <= B:
        s += i
print(s)

Submission status: Accepted

Solution code:
def ds(n):
    s = str(n)
    array = list(map(int, s))
    return sum(array)

n,a,b = map(int,input().split())
y=[]
for i in range(n+1):
    x = ds(i)
    if x >= a:
        if x <= b:
            y.append(i)
print(sum(y))

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, a, b = list(map(int, readline().split()))
ans = 0
for i in range(n+1):
    y = list(str(i))
    y = [int(z) for z in y]
    if a <= sum(y) <= 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):
    digit = i
    digit_sum = 0
    while digit > 0:
        digit_sum += digit % 10
        digit = digit // 10

    if digit_sum >= a and 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_l = list(str(i))
    i_sum = sum(list(map(int, i_l)))
    if a <= i_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):
    ns = str(i)
    t = 0
    for j in ns:
        t+= int(j)
    if t >= a and t <= b:
        ans+=i
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, A, B = map(int, read().split())
count = 0

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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


answer=0
for n in range(N+1):
    sum=0
    for i in str(n):
        sum+=int(i)
    if A<=sum and sum<=B:
        answer+=n
print(answer)

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if X//n:
    return Base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def Base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def split_sum(n):
    return sum(map(int, str(n)))


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

Submission status: Accepted

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

Submission status: Accepted

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

res = 0
for i in range(1, N + 1):
    cnt = 0
    tmp = i
    while tmp > 0:
        cnt += tmp % 10
        tmp //= 10
    if A <= cnt <= B:
        res += i
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

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

wholeSum = 0

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

for pivot in range(n+1):
  target = digitSum(pivot)
  if target <= b\
  and a <= target:
    wholeSum += pivot

print(wholeSum)

Submission status: Accepted

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

wholeSum = 0

def digitSum(n):
  basis = 10
  transDigit = list()
  while n > 0:
    transDigit.append(n % basis)
    n = int(n / basis)
  result = sum(transDigit)
  return result

for pivot in range(n+1):
  target = digitSum(pivot)
  if target <= b\
  and a <= target:
    wholeSum += pivot

print(wholeSum)

Submission status: Accepted

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

res = 0

for i in range(1, n+1):
  sum = 0
  P = str(i)
  for j in P:
    sum += int(j)
  if a<=sum<=b:
    res += i

print(res)

Submission status: Accepted

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

sum = 0

for i in range(1,N+1):
  p = 0
  for k in str(i):
    p += int(k)
    if p > B:
      break
  if A <= p and p <= B:
    sum += i
print(sum)

Submission status: Accepted

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

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

print(result)

Submission status: Accepted

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

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

print(result)

Submission status: Accepted

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


def solve(N: int, A: int, B: int):
    total = 0
    for i in range(1, N + 1):
        keta4, mod = divmod(i, 10000)
        keta3, mod = divmod(mod, 1000)
        keta2, mod = divmod(mod, 100)
        keta1, mod = divmod(mod, 10)
        ketasum = keta4 + keta3 + keta2 + keta1 + mod
        if ketasum >= A and ketasum <= B:
            total = total + i
    return total


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    print(solve(N, A, B))

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):
    l = list(str(i))
    total = sum([int(i) for i in l])
    if a <= total <= b:
        tmp = int("".join(l))
        ans += tmp
print(ans)

Submission status: Accepted

Solution code:
in_all = list(map(int, input().split()))
 
total = 0
for n in range(1, in_all[0]+1):
    tmp = str(n)
    all = 0
    for t in tmp:
        all += int(t)
    if all>=in_all[1] and all<=in_all[2]:
        total += n
 
print(total)

Submission status: Accepted

Solution code:
in_all = list(map(int, input().split()))

total = 0
for n in range(1, in_all[0]+1):
    all = 0
    tmp = n
    while tmp!=0:
        all += tmp%10
        tmp = tmp//10
    if all>=in_all[1] and all<=in_all[2]:
        total += n

print(total)

Submission status: Accepted

Solution code:
in_all = list(map(int, input().split()))

total = 0
for n in range(1, in_all[0]+1):
    tmp = str(n)
    all = 0
    for t in tmp:
        all += int(t)
    if all>=in_all[1] and all<=in_all[2]:
        total += int(tmp)

print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num, lower, upper = map(int, input().split())

result = 0
for tmp in range(num + 1):
    sumOfNum = sum(map(int, list(str(tmp))))
    if lower <= sumOfNum and sumOfNum <= upper: result += tmp

print(result)

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
sumall=0
for i in range(1,n+1):
    n1=int(i/10**4)
    n2=int((i-n1*10**4)/10**3)
    n3=int((i-n1*10**4-n2*10**3)/10**2)
    n4=int((i-n1*10**4-n2*10**3-n3*10**2)/10)
    n5=int(i-n1*10**4-n2*10**3-n3*10**2-n4*10)
    if (n1+n2+n3+n4+n5)>=a and (n1+n2+n3+n4+n5)<=b:
        sumall=sumall+i
print(sumall)

Submission status: Accepted

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

def total (x:int):
    total = 0
    while True:
        if x == 0:
            return total
        else:
            total += x%10
            x = x//10

ans = 0
for i in range(0,n+1):
    t = total(i)
    if a <= t and t <= b:
        ans += i

print (ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
listint=[i for i in range(1,n+1)]
liststr=[str(listint[i]) for i in range(n)]
anssum=[[] for i in range(n)]
def calculate_sum(listint,liststr,k):
  sumnumber=liststr[k-1]
  sumlist=list(sumnumber)
  sumlistint=[int(sumlist[i]) for i in range(len(sumlist))]
  sum=0
  for i in range(len(sumlistint)):
    sum=sum+sumlistint[i]
  return(sum)
for k in range(0,n):
  anssum[k]=[listint[k],calculate_sum(listint,liststr,k+1)]
answer=0
for i in range(0,n):
  if a<=anssum[i][1]<=b:
    answer=answer+anssum[i][0]
print(answer)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

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

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

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

c = 0
for s in range(1, n+1):
    sum = 0
    r = s
    for t in range(1, len(str(s))+1):
        sum += r%10
        r = r//10
    if(a <= sum <= b):
        c += s
print(c)

Submission status: Accepted

Solution code:
import math
import copy

neko = 0

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

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

Submission status: Accepted

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

for i in range(N+1):
    i = str(i)
    listi = list(i)
    listi = [int(s) for s in listi]
    sumi = sum(listi)
    
    if sumi <= b and sumi >= a:
        c = c + int(i)

print(c)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range (n+1):
    i_10000 = i//10000
    i_1000 = i%10000//1000
    i_100 = i%1000//100
    i_10 = i%100//10
    i_1 = i%10
    i_sum = i_10000 + i_1000 + i_100 + i_10 + i_1
    if a<=i_sum<=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):
    val = sum(list(map(int, list(str(i)))))
    if a <= val <= b:
        ans += i

print(ans)

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())
total_sum = 0
for i in range(n+1):
  s = str(i)
  digit_sum = 0
  for j in range(len(s)):
    digit_sum += int(s[j])
  if a <= digit_sum <= b:

    total_sum += i

print(total_sum)

Submission status: Accepted

Solution code:
import numpy as np
n, a, b = map(int, input().split()) 
numbers = np.arange(1, n+1)
collect = []
for i in numbers:
    if i < 10:
        if (i >= a) and (i <= b):
            collect.append(i)
    else:
        divide_number_str = list(str(i))
        divide_number = list(map(int, divide_number_str))
        sum_num = sum(divide_number)
        if (sum_num >= a) and (sum_num <= b):
            collect.append(i)
        
print(sum(collect))

Submission status: Accepted

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

def judge_sum(s, A, B):
    s = str(s)
    ans = 0
    for i in range(len(s)):
        ans += int(s[i])
    return A <= ans <= B

li = [i for i in range(1, N+1) if judge_sum(i, A, B)]

print(sum(li))

Submission status: Accepted

Solution code:
def func(x, y, total):
    if y == 0:
        return total
    else:
        total += x // y
        new_x = x % y
        new_y = y // 10
        return func(new_x,new_y,total) 

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

ans = sum([
	i for i in range(1, n+1)
	if a <= func(i, 10**4, 0) <= b])
print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


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


def keta(x):
    res = 0
    for s in str(x):
        res += int(s)
    return res


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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

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

total = 0
for i in range(1, N+1):
  a = i
  lis =[]
  while i >0:
    lis.append(i%10)
    i //=10
  lis.reverse()
  lis = np.array(lis)
  SUM = np.sum(lis)

  if SUM >=A and SUM <=B:
    total += a
    
print(total)

Submission status: Accepted

Solution code:
Number_list=list(map(int,input().split()))
taget_number=[]
for i in range(1,Number_list[0]+1):
    sum_digit=0
    for s in str(i):
        sum_digit+=int(s)
    if sum_digit>=Number_list[1] and sum_digit<=Number_list[2]:
        taget_number.append(i)
print(sum(taget_number))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#http://delta114514.hatenablog.jp/entry/2018/03/15/014555
n, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
    if a <= sum(list(map(int, list(str(i))))) <= b:
        ans += i
print(ans)

Submission status: Accepted

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

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

print(ans)