Problem:


Score : 200 points

Problem Statement

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

Constraints

1 \leq N \leq 10^4

1 \leq A \leq B \leq 36

All input values are integers.

Input

Input is given from Standard Input in the following format:

N A B

Output

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

Sample Input 1

20 2 5

Sample Output 1

84

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

Sample Input 2

10 1 2

Sample Output 2

13

Sample Input 3

100 4 16

Sample Output 3

4554



Sample input:
20 2 5


Sample output:
84

Submission status: Accepted

Solution code:
from sys import stdin
N, A, B = [int(x) for x in stdin.readline().rstrip().split()]
#N, A, B = map(int, input().split())
n_list = [0]
#digit3_max = min(int(N / 100), 9)
digit_N = len(str(N))

def setDigit(N_max, sum_min, sum_max, digit):
    n_max = int(N_max / (10 ** (digit - 1)))
    for i in range(min(n_max, sum_max, 9) + 1):
        if digit == 1 and i >= sum_min:
            n_list.append(N - N_max + i)
            #print(N_max, i)
        elif digit == 1 and i < sum_min: continue
        else:
            #print(N_max - (i * 10 ** (digit - 1)), max(sum_min - i, 0), sum_max - i, digit - 1)
            setDigit(N_max - (i * 10 ** (digit - 1)), max(sum_min - i, 0), sum_max - i, digit - 1)


setDigit(N, A, B, digit_N)
'''
for digit3 in range(digit3_max + 1):
    tmp1 = N - digit3 * 100
    digit2_max = min(int(tmp1 / 10), 9)
    for digit2 in range(digit2_max + 1):
        tmp2 = tmp1 - digit2 * 10
        digit1_max = min(tmp2, 9)
        for digit1 in range(digit1_max + 1):
            if (digit1 + digit2 + digit3) >= A and (digit1 + digit2 + digit3) <= B:
                n_list.append(digit3 * 100 + digit2 * 10 + digit1)
'''

print(sum(n_list))

Submission status: Accepted

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

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

    print(ans) 

main()

Submission status: Accepted

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

i=0
souwa=0
while i<=N:
  j=i
  sum =0
  while j>0:
    sum=sum+j%10
    j=int(j/10)
  #print(i,sum)
  if sum>=a and sum<=b:
    #print(sum,i)
    souwa=souwa+i
  
  
  i=i+1
print(souwa)

Submission status: Accepted

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

def sumOfDigits(n):
    total = 0
    while n > 0:
        total += n%10
        n //= 10
    return total

answer = 0
for n in range(1, N+1):
    total = sumOfDigits(n)
    if total >= A and total <= B:
        answer += n
print(answer)

Submission status: Accepted

Solution code:
def solve():
    n, a, b = list(map(int, input().split()))
    ok_numbers = []
    for num in range(n + 1):
        total = sum([int(i) for i in str(num)])
        if a <= total <= b:
            ok_numbers.append(num)
    return sum(ok_numbers)


if __name__ == "__main__":
    print(solve())

Submission status: Accepted

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

ans = 0
for i in range(n+1):
    one = i%10
    ten = i//10%10
    hund = i//100%10
    thou = i//1000%10
    man = i//10000%10
    summ = man+thou+hund+ten+one
    if a <= summ <= b:
        ans += i
print(ans)

Submission status: Accepted

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

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

print(total)

Submission status: Accepted

Solution code:
import sys

n, min_, max_ = [int(v) for v in sys.stdin.read().split(" ")]
total = 0
for i in range(1, n+1):
  if min_ <= sum(int(v) for v in str(i)) <= max_ :
    total += i
print(total)

Submission status: Accepted

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

def somesum(x):
    return sum([int(v) for v in str(int(x))])

res = 0
for i in range(n):
    w = somesum(i + 1)
    if a <= w <= b:
        res += (i + 1)

print(res)

Submission status: Accepted

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

ans = 0
for i in range(1,n+1):
    # i = 10
    n1 = i
    n2 = 0
    while n1 != 0:
        n2 += n1%10
        n1 = n1//10
    if a <= n2 <= b:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
def solve():
    n, a, b = read()
    result = think(n, a, b)
    write(result)


def read():
    return read_int(3)


def read_int(n):
    return list(map(int, read_line().split()[:n]))


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n, a, b):
    subsum = 0
    for i in range(1, n + 1):
        if satisfies_condition(i, a, b):
            subsum += i
    return subsum


def satisfies_condition(i, a, b):
    return a <= sum(map(int, list(str(i)))) <= b


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

    for n in range(1, N+1):
        sum = 0
        for digit in str(n):
            sum += int(digit)
        if A <= sum and sum <= B:
            counter += n

    print(counter)


if __name__ == '__main__':
    main()

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
 #ABC83, B - some sums

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

total = 0
for i in range(1, n+1):
    some_sum =  sum([int(s) for s in list(str(i))])
    if a <= some_sum <= b:
        total += i
print(total)

Submission status: Accepted

Solution code:
def find_sum(n):
  ret = 0
  while(n > 0):
    ret += n % 10
    n = int((n - n % 10) / 10)
  return ret

N, A, B = map(int, input().split())
ret = 0
for i in range(N + 1):
  #v = sum(map(int, list(str(i))))
  v = find_sum(i)
  if v >= A and v <= B:
    ret += i
print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, A: int, B: int):
    tot = 0
    for i in range(N+1):
        s = sum([int(c) for c in str(i)])
        if A <= s <= B:
            tot += i
    print(tot)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
sum = 0
 
for n in range(N+1):
  N1 = int(n/10000)
  N2 = int((n-10000*N1)/1000)
  N3 = int((n-10000*N1-1000*N2)/100)
  N4 = int((n-10000*N1-1000*N2-100*N3)/10)
  N5 = n-10000*N1-1000*N2-100*N3-10*N4
  if A <= N1+N2+N3+N4+N5 <= B:
    sum = sum + n
 
 
print(sum)

Submission status: Accepted

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

forsum = []

for num in range(1, n+1):
  d1 = num // 10000
  m1 = num % 10000
  d2 = m1 // 1000
  m2 = num % 1000
  d3 = m2 // 100
  m3 = num % 100
  d4 = m3 // 10
  m4 = num % 10
  d5 = m4 // 1
  total = d1 + d2 + d3 + d4 + d5
  
  if a <= total <= b:
    forsum.append(num)

print(sum(forsum))

Submission status: Accepted

Solution code:
N,A,B = input().split()
n_sum = 0
A_int = int(A)
B_int = int(B)
ans = 0
for n in range(int(N)+1):
    for n_char in str(n):
        n_sum += int(n_char)

    if (A_int <= n_sum) and (B_int >= n_sum):
        ans += n
    n_sum = 0
    
print(ans)

Submission status: Accepted

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

sums = 0

for i in range(n+1):
    if a <= sum([int(x) for x in list(str(i))]) <= b:
        sums += i

print(sums)

Submission status: Accepted

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

for i in range(1,n+1):
    c = 0
    d = i
    while d > 0:
        c += d%10
        d = int(d/10)
    if a <= c and c <= b:
        e += i

print(e)

Submission status: Accepted

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

for n in range(N+1):
  if A <= sum([int(i) for i in str(n)]) <= B:
    s += n
    
print(s)

Submission status: Accepted

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

for n in range(N + 1):
  d_sum = 0
  for d in str(n):
    d_sum += int(d)
  if d_sum >= A and d_sum <= B:
    s += n
    
print(s)

Submission status: Accepted

Solution code:

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

ans = []
for n in range(N+1):
    total = sum([int(n) for n in list(str(n))])
    if A <= total <= B:
        ans.append(n)

print(sum(ans))

Submission status: Accepted

Solution code:




def main():
    N, A, B = [int(x) for x in input().split()]
    a = 0
    for n in range(N+1):
        s = sum(int(x) for x in str(n))
        if A <= s <= B:
          	a += n
    return a
print(main())

Submission status: Accepted

Solution code:
li = []
n,a,b =map(int, input().split())
for i in range(n+1):
    c = list(str(i))
    d = sum([int(c[x]) for x in range(len(c))])

    if a <= d <= b:
        li.append(i)

print(sum(li))

Submission status: Accepted

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

for i in range(N+1):
	array = list(map(int,str(i)))
	if sum(array) >= A and sum(array) <= B:
		N_list.append(i)

print(sum(N_list))

Submission status: Accepted

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


sall = 0

for i in range(1,N+1):
    s =0
    x =i
    while x !=0:
        s =s + x%10
        x =x//10
    if A<=s<=B:
        sall =sall +i
        
print(sall)

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

ans = 0

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

print(ans)

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 = str(i)
	SUM = 0
	for j in range(len(s)):
		SUM += int(s[j])
	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 num in range(1, N+1):
  str_num = str(num)
  sum_char = 0
  for char in str_num:
    sum_char += int(char)
  if sum_char >= A and sum_char <= B:
    ans += int(str_num)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

sum_sum = 0
for i in range(N+1):
    sum = 0
    str_i = str(i)
    for k in range(len(str_i)):
        sum += int(str_i[k])
    if sum >= A and sum <= B:
        sum_sum += i

print(sum_sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

n,a,b = map(int,input().split())
sum_all = 0
for i in range(1,n+1):
    now = i
    keta_sum = 0
    while(1):
        keta_sum += now%10
        now //= 10
        if now == 0:
            break
    if a <= keta_sum and keta_sum <= b:
        sum_all += i
print(sum_all)

Submission status: Accepted

Solution code:
import math

#n = int(input())
#a = int(input())
n,a,b = list(map(int,input().split(" ")))
#ls = list(input().split(" "))
#ls = list(map(int,input().split(" ")))
#a,b = list(input().split())
#string = input()
#ls = [int(input()) for i in range(n)]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def sumall(a):
    n = 0
    while a > 0:
        n += a % 10 
        a = a // 10
    return n
 
 
n, a, b = map(int, input().split())
 
c = [0 for i in range(n)]
for i in range(n):
    c[i] = sumall(i+1)
    
d = 0
for i in range(n):

    if a <= c[i] <= b:
        d += i+1
        
print(d)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

ans = 0
for i in range(N+1):
  if A <= sum_10(i) <= 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):
        if a <= sum([int(c) for c in str(i)]) <= b:
            count += i
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ary = input().split(' ')
n = int(ary[0])
a = int(ary[1])
b = int(ary[2])
ans = 0
for k in range(n+1):
    s = str(k)
    cnt = 0
    for i in range(len(s)):
        cnt += int(s[i])
    if a <= cnt <= b:
        ans += k

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n+1):
    t4 = i %10
    t3 = (i %100 -t4) //10
    t2 = (i %1000 -t4 -t3*10) //100
    t1 = (i %10000 -t4 -t3*10 -t2*100) //1000
    t0 = (i %100000 -t4 -t3*10 -t2*100 -t1*1000) //10000
    c = t0 + t1 + t2 + t3 + t4
    if a <= c <= b: ans += i

print(ans)

Submission status: Accepted

Solution code:
# ABC083-B
def get_wa(N):
    ans = 0
    while N > 0:
        ans += N % 10
        N = N //10
    return ans
N, A, B = map(int, input().split())
ans = 0
for i in range(N+1): 
    tmp = get_wa(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(N):
    a=N//10**4
    b=N//10**3-10*a
    c=N//10**2-100*a-10*b
    d=N//10**1-1000*a-100*b-10*c
    e=N//10**0-10000*a-1000*b-100*c-10*d
    N=N-1
    if A<= a+b+c+d+e <=B:
     ans=ans+N+1


print(ans)

Submission status: Accepted

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

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

for i in range(1, n+1):
  x = find_sum_of_digits(i)
  if x >= a and x <= b:
    count += i
print(count)

Submission status: Accepted

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

for xx in range(1, n+1):
  x = str(xx)
  sum_x = 0
  for i in range(len(x)):
    sum_x += int(x[i])
  if sum_x >= a and sum_x <= b:
    count += xx
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N ,MIN ,MAX =[ int( i ) for i in input().split(" ") ]

answer =0
for n in range(1,N+1):
    con = sum([int(e) for e in list(str(n)) ])
    if con >= MIN and con <= MAX:
        answer += n
print(answer)

Submission status: Accepted

Solution code:
# ABC083B - Some Sums
def main():
    n, a, b = list(map(int, input().rstrip().split()))
    ans = 0
    for i in range(1, n + 1):
        if a <= sum(map(int, list(str(i)))) <= b:
            ans += i
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

for i in range(N+1):
    for j in str(i):
        count += int(j)
    if count >= A and count <= B:
        result += i
    count = 0
    
print(result)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def main():
    N,A,B = map(int,input().split())
    ans = 0
    for i in range(1,N+1):
        to = 0
        tmp = str(i)
        for j in range(len(tmp)):
            to += int(tmp[j])
        if to >= A and to <= B:
            ans += i
            
    print(ans)
            	
if __name__ == "__main__":
	main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

b = [int(e) for e in input().split()]
"""
n=input()
n=int(n)
a=input()
a=int(a)
b=input()
b=int(b)
"""
list = []
for i in range(b[0]+1):
    x=i
    check = 0
    #print(x)
    while(True):
        check=check+x%10
        x=math.floor(x/10)
        #print(x)
        if(x==0):
            break
    if(check>=b[1] and check<=b[2]):
        list.append(i)

print(sum(list))
#print(list)

Submission status: Accepted

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

for i in range(0, N+1, 10):
    for j in range(10):
        temp = str(i + j)
        if (int(temp) > N):
            break

        sum = 0
        for k in range(len(temp)):
            sum += int(temp[k])
        if (B < sum):
            break
        elif (A <= sum) and (sum <= B):
            ans += int(temp)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(0, N+1, 10):
    for j in range(10):
        temp = str(i + j)
        if (int(temp) > N):
            break

        sum = 0
        for k in range(len(temp)):
            sum += int(temp[k])
        if (A <= sum) and (sum <= B):
            ans += int(temp)
        elif (B < sum):
            break

print(ans)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
s=0
for i in range(1,n+1):
    if a<=sum(list(map(int,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(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())

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

print(num)

Submission status: Accepted

Solution code:
N,a,b = map(int,input().split())
R = 0
for i in range(N+1):
    s = i
    r = 0
    while i !=0:
        r+= i%10
        i //=10
    if a <= r <= b:
        R+=s
print(R)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def sum_digit(n):
    L = []
    while n != 0:
        k = n % 10
        L.append(k)
        n = n // 10
    return sum(L)


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

for i in range(N+1):
    X = sum_digit(i)
    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 i in range(1,N + 1):
	num = str(i)
	sum = 0
	for j in num:
		sum += int(j) 		      
	if sum >= A and sum <= B:
		# print(i)          
		ans += i
print(ans)

Submission status: Accepted

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

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

for i in range(N+1):
    if A <= digitSum(i) <= B:
        s += i

print(s)

Submission status: Accepted

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

for i in range(1, n+1):
    s = sum([int(x) for x in str(i)])
    if a <= s & s <= b:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
def sum_all(x):
  a = 0
  while x >= 10:
    a += x%10
    x = x//10
  a += x
  return int(a)
N, A, B = map(int, input().split())
ans_list = []
for i in range(1, N+1):
  if sum_all(i) >= A and sum_all(i) <= B:
    ans_list.append(i)
print(sum(ans_list))

Submission status: Accepted

Solution code:
def sum_all(x):
  return int(x%10 + (x//10)%10 + (x//100)%10 + (x//1000)%10 + x//10000)
N, A, B = map(int, input().split())
ans_list = []
for i in range(1, N+1):
  if sum_all(i) >= A and sum_all(i) <= B:
    ans_list.append(i)
print(sum(ans_list))

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

#各桁の数字合計計算
def add_keta(n):
    ans = 0
    while n > 0 :
        ans += n % 10
        n = n // 10
    return ans


#各桁の数字合計計算
for i in range(1, N+1):
    sum = add_keta(i)
    if A <= sum and sum <= B:
        total += i

print(total)

Submission status: Accepted

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

total = 0

def sumdigits(i):
    i_sum = 0
    while(i > 0):
        i_sum += i % 10
        i = i // 10
        
    return i_sum

for j in range(1,n+1):
    num = sumdigits(j)
    if(num >= a and num <= b):
        total += j
    
print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

data = input().split()
N = int(data[0])
A = int(data[1])
B = int(data[2])

#各桁の和を計算する関数
def digit_total(x):
    total = 0
    while x > 0:
        total += x % 10
        x /= 10
        x = math.floor(x)#小数点以下を切り捨てる
    return(total)

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

Submission status: Accepted

Solution code:
import math
data = input().split()
N = int(data[0])
A = int(data[1])
B = int(data[2])
total = 0
digit_total = 0

for i in range(1,N+1):
    size = int(math.log10(i)+1)
    digit = []
    for j in range(size):
        digit.append(int(str(i)[j-1]))
        digit_total += digit[j]
    if A <= digit_total and digit_total <= B:
        total += i
    digit_total = 0
print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def findSumDigit(num):
    global total
    total = 0
    while num > 0:
        total += num % 10
        num //= 10
    return total

def main():
    n,a,b = map(int, input().split())
    ans = 0
    for i in range(1,n+1):
        tmp = findSumDigit(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())

# まずN <= 10**4だからO(N)で間に合う
ans = 0
for i in range(1, N+1):
    ii = i
    num = 0
    while ii != 0:
        num += ii % 10  # iiの1の位を加算 (ex. ii = 234 -> num = 4)
        ii = ii // 10  # 一桁右にずらす (ex. 234 -> 23)

    if A <= num and num <= B:
        ans += i
print(ans)

Submission status: Accepted

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

# まずN <= 10**4だからO(N)で間に合う
ans = 0
for i in range(1, N+1):
    num = 0
    if i < 10:  # 1桁
        num = i
    elif i < 10**2:
        ii = i
        for j in [10, 1]:
            a = ii // j
            num += a
            ii -= a * j
    elif i < 10**3:
        ii = i
        for j in [10**2, 10, 1]:
            a = ii // j
            num += a
            ii -= a * j
    elif i < 10**4:
        ii = i
        for j in [10**3, 10**2, 10, 1]:
            a = ii // j
            num += a
            ii -= a * j
    else:  # i == 10**4
        ii = i
        for j in [10**4, 10**3, 10**2, 10, 1]:
            a = ii // j
            num += a
            ii -= a * j
    
    if A <= num and num <= B:
        ans += i

print(ans)

Submission status: Accepted

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

sum = 0
S = 0
for i in range(N+1):
    i_str=str(i)
    for k in range(len(i_str)):
        sum += int(i_str[k])
    if(sum >= A and sum <=B):
        S += i
    sum = 0
print(S)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def f(n):
    return sum([int(i) for i in str(n)])


N, A, B = map(int, input().split())
print(sum([i for i in range(1, 1 + N) if A <= f(i) <= B]))

Submission status: Accepted

Solution code:
def f(n):
    return sum([int(i) for i in str(n)])


N, A, B = map(int, input().split())
L = [f(i) for i in range(1, 1 + N)]
print(sum([i + 1 for i, l in enumerate(L) if A <= l <= B]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, A, B = [int(nab) for nab in input().split()]
ans = 0
for n in range(1, N+1):
  NN = [int(nn) for nn in str(n)]
  s_NN = sum(NN)
  if A <= s_NN <= B:
    ans += n
print(ans)

Submission status: Accepted

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

def sum_all_digits(m):
    res = 0
    while m > 0:
        res += m % 10
        m = m // 10
    return res

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

print(ans)

Submission status: Accepted

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

def func(x):
    temp = str(x)
    return sum([int(i) for i in temp])

ans = 0

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

print(ans)