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:
# B - Some Sums
# coding: utf-8

N, A, B = map(int, raw_input().split())
result = 0

for num in range(1, N+1):
  wa = num/10000 + (num%10000)/1000 + (num%1000)/100 +(num%100)/10 +(num%10)
  if wa >= A and wa <= B : result += num

print result

Submission status: Accepted

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

for i in range(A, N+1):
    i_str = str(i)
    i_list = list(map(int, list(i_str)))
    s = sum(i_list)
    if s >= A and s <= B:
        n += i
print(n)

Submission status: Accepted

Solution code:
# coding: utf-8

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

# main
total = 0
for i in range(n + 1):
    str_i = str(i)
    temp = sum(map(int, str_i))
    if a <= temp <= b:
        total += i

print(total)

Submission status: Accepted

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

ans = 0
for x in range(1,n+1):
    acc = 0
    for d in str(x):
        acc += int(d)
    if a <= acc and acc <= b : ans += x

print(ans)

Submission status: Accepted

Solution code:
import math

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

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

ans = 0
for i in range(1, N+1):
    S = wa(i)
    if A <= S & S <= B:
       ans += i

print(ans)

Submission status: Accepted

Solution code:

def sum_dig(num):
    sum = 0
    while(num):
        dig = num % 10
        sum = sum + dig
        num = num // 10
#        print (dig,sum,num)
    return sum


lim, min, max = map(int, input().split(" "))
chk_sum = 0
for i in range(1,lim+1) :
    chk = sum_dig(i)
#    print(chk,type(chk))
    if (chk >= min and chk <= max) :
        chk_sum += i

print (chk_sum)

Submission status: Accepted

Solution code:

def sum_dig(num):
    nsum = 0
    while(num):
        dig = num % 10
        nsum = nsum + dig
        num = num // 10
#        print (dig,sum,num)
    return nsum


lim, nmin, nmax = map(int, input().split(" "))
chk_sum = 0
for i in range(1,lim+1) :
    chk = sum_dig(i)
#    print(chk,type(chk))
    if (chk >= nmin and chk <= nmax) :
        chk_sum += i

print (chk_sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque


# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_I(): return map(int, stdin)
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))

##### main #####



def main():
	n,a,b = LI()
	ans = 0
	for i in range(1,n+1):
		s = sum([int(k) for k in str(i)])
		if a<=s<=b:
			ans += i
	print(ans)

	
if __name__ == '__main__':
	main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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

s = 0

for x in range(1,N+1):
    a = int(x%10)
    b = int((x%100)/10)
    c = int((x%1000)/100)
    d = int((x%10000)/1000)
    e = int((x%100000)/10000)
    t = a+b+c+d+e
    if t<=B and t>=A:
        s = s + x
print(s)

Submission status: Accepted

Solution code:
l = map(int,raw_input().split())
new = []
for i in range(l[0]+1):
    temp = map(int, str(i))
    total = sum(temp)
    if (l[1] <= total <= l[2]):
        new.append(i)
print sum(new)

Submission status: Accepted

Solution code:
[n, a, b] = list(map(int, input().split()))
ans = 0
for i in range(1, n + 1):
    p = i
    sum_of_digit = 0
    while p != 0:
        sum_of_digit += p % 10
        p = p // 10
    if sum_of_digit >= a and sum_of_digit <= b:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
def LI(): return [int(x) for x in input().split(" ")]
def LS(): return [str(x) for x in input().split(" ")]
def ItoS(L): return [str(x) for x in L]
def StoI(L): return [int(c) for c in L]


def solve():
    n, a, b = LI()
    cnt = 0
    for i in range(1, n + 1):
        tmp = i
        i = list(str(i))
        if a <= sum(StoI(i)) <= b:
            cnt += tmp

    print(cnt)


solve()

Submission status: Accepted

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

answer = 0
for i in range(1, n + 1):
    sum = 0
    temp = i
    while temp > 0:
        sum += (temp % 10)
        temp //= 10
    if a <= sum <= b:
        answer += i

print(answer)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,a,b = LI()
    r = 0
    for i in range(1,n+1):
        s = sum([int(_) for _ in str(i)])
        if a <= s <= b:
            r += i

    return r



print(main())

Submission status: Accepted

Solution code:
# coding: utf-8

num, mini, maxi = map(int, input().rstrip().split())
hani = range(mini,maxi+1)

atari = []

for i in range(1,num+1):
    num_list = list(map(int, str(i)))
    goukei = sum(num_list)
    if goukei in hani:
        atari.append(i)
    #print(atari)

print(sum(atari))

Submission status: Accepted

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

import sys

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

n, a, b = sys.stdin.readline().split(" ")
n = int(n)
a = int(a)
b = int(b)
ans = 0
for i in range(1, n + 1):
    if a <= digit_sum(i) <= b:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split(' '))
sum_digits = 0
for num in range(1, N + 1):
    sum_digit = 0
    tmp = num
    while True:
        if tmp < 10:
            sum_digit += tmp
            break
        digit = tmp % 10
        tmp //= 10
        sum_digit += digit

    if A <= sum_digit <= B:
        sum_digits += num

print(sum_digits)

Submission status: Accepted

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

def can(x):
  global A,B
  sum=0
  while x > 0:
    x, a = divmod(x, 10)
    sum += a
  if A <= sum <= B:
      return True    

res = 0
for i in xrange(1, N+1):
  if can(i):
    res += i

print res

Submission status: Accepted

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

total = 0
for i in range(1, n[0]+1):
    sum = 0
    number = str(i)
    for k in range(len(number)):
        sum += int(number[k])
    if n[1] <= sum <= n[2]:
        total += i
print(total)

Submission status: Accepted

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

def getTotal(num):
    tmp=0
    for s in str(num):
        tmp+=int(s)
    return tmp

for i in range(1, N+1):
    total=getTotal(i)
    if(A<=total and total<=B):
        sum+=i

print(sum)

Submission status: Accepted

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

for i in range(n):
    num = i + 1
    numbers = []
    while num > 0:
        numbers += [num % 10]
        num = num // 10
    if sum(numbers) >= a and sum(numbers) <= b:
        total_sum += i + 1

print(total_sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def digitSum(num):
    res = 0
    while num > 0:
        res = res + num % 10
        num = int(num / 10)
    return res


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

    ans = 0;
    for i in range(n):
        ds = digitSum(i + 1)
        if ds >= a and ds <= b:
            ans = ans + i + 1

    print (ans)

main()

Submission status: Accepted

Solution code:
def inputs():
    s = input()
    li = s.split(" ")
    return(int(li[0]), int(li[1]), int(li[2]))

def digitSum(num):
    sum = 0
    while(num > 0):
        sum += (num % 10)
        num //= 10
    return(sum)

def rangeSum(N, A, B):
    allsum = 0
    for i in range(1, N+1):
        tmpsum = digitSum(i)
        if(A <= int(tmpsum) <= B):
            allsum += i
    return(allsum)

def main():
    N, A, B = inputs()
    sum = rangeSum(N, A, B)
    print(sum)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

    sumv = 0
    for x in range(a, n+1):
        num = sum([int(i) for i in str(x)])
        if num >= a and num <= b: sumv += x
    print(sumv)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from functools import reduce

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

for i in range(1, n + 1):
    str_num = '0' + str(i)
    num = reduce(lambda a, b:int(a) + int(b), list(str_num))
    if num >= a and num <= b:
        result += i
print(result)

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache, reduce
from operator import xor
from heapq import heappush, heappop
INF = float("inf")
sys.setrecursionlimit(10**7)

# 4近傍（右, 下, 左, 上）
dy4, dx4 = [0, -1, 0, 1], [1, 0, -1, 0]


def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def ceil(a, b): return (a + b - 1) // b


def ok(n, A, B):
    ans = 0
    for c in str(n):
        ans += int(c)
    return A <= ans <= B


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
n, a, b = map(int, input().split())
ans = 0
for tmp in range(1, n+1):
    c = sum(list(map(int, list(str(tmp)))))
    if c >= a and c <= b:
        ans += tmp
    else:
        pass
else:
    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,list(str(i))))<=b))

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(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(N+1):
    t_sum = 0
    for e in str(i):
        t_sum += int(e)
    if A<= t_sum <= B:
        ans += i
        
print(ans)

Submission status: Accepted

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

ans=0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
def judge(x):
    ans=0
    while x!=0:
        ans+=x%10
        x=x//10
    if ans>=a and ans<=b:
        return True
    else:
        return False
sum=0
for i in range(1,n+1):
    if judge(i):
        sum+=i
print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b = map(int, input().split())
def f(x):
  ret = 0
  while(x > 0):
    ret += x % 10
    x //= 10
  return ret
nums = filter(lambda x: f(x) >= a and f(x) <= b, range(1, n + 1))
print(sum(nums))

Submission status: Accepted

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

Submission status: Accepted

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

def digit_sum(num):
    num = str(num)
    out = 0
    for i in num:
        out += int(i)
    return out

final = 0
for i in range(1, N+1):
    if A <= digit_sum(i) <= B:
        final += i
print(final)

Submission status: Accepted

Solution code:
#abc083b

n,a,b=map(int,raw_input().split())
res=0
l=[]
for i in xrange(1,n+1):
 s=str(i)
 sums=0
 for j in xrange(len(s)):
  sums+=int(s[j])
 l.append(sums)
for i in xrange(len(l)):
 if l[i]>=a and l[i]<=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):
    x=list(map(int,list(str(i))))
    if sum(x)>=a and sum(x)<=b:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
N, A, B = list(map(int, input().split()))
print(sum([(i if (A <= sum(list(map(int, str(i)))) <= B) else 0) for i in range(1, N + 1)]))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
N, A, B = list(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 = map(int,input().split())

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

print(res)

Submission status: Accepted

Solution code:
def getSumDigits(k):
   ret = 0
   while k:
      ret += k%10
      k //= 10
   return ret

N,A,B = map(int, input().split())
ret = 0
for i in range(1,N+1):
   if A <= getSumDigits(i) <= B:
      ret += i

print(ret)

Submission status: Accepted

Solution code:
def ss(n):
   r = 0
   while n:
       r, n = r + n % 10, n // 10
   return r
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n + 1):
  sr = ss(i)
  if sr <= b and sr >=a: 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 sum(list(map(int, str(i)))) >= a and sum(list(map(int, str(i)))) <= b:
    ans.append(i)

print(sum(ans))

Submission status: Accepted

Solution code:
import sys
import math

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

Submission status: Accepted

Solution code:
N, A, B = map(int,input().split())
sum = 0
for i in range(1,N+1):
    i10000 = i // 10**4
    i1000 = (i - i10000*(10**4)) // 10**3
    i100 = (i - i10000*(10**4) - i1000*(10**3)) // 100
    i10 = (i - i10000*(10**4) - i1000*(10**3)- i100*(10**2)) // 10
    i1 = i - i10000*(10**4) - i1000*(10**3)- i100*(10**2) -i10*10
    if A <= i10000 + i1000 + i100 + i10 + i1 <= B:
        sum = sum + i

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math

l = tuple(map(int, input().split()))

ans = 0

for i in range(1, l[0]+1):
    n = i
    v0 = n % 10
    n /= 10
    v1 = n % 10
    n /= 10
    v2 = n % 10
    n /= 10
    v3 = n % 10
    n /= 10
    v4 = n % 10
    sum = math.floor(v0) + math.floor(v1) \
     + math.floor(v2) + math.floor(v3) + math.floor(v4)
    if(l[1] <= sum and sum <= l[2]):
        ans += i
print(ans)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
sum = 0
for i in range(n):
	s = i+1
	x = s%10
	y = ((s-x)%100)
	z = ((s-x-y)%1000)
	w = ((s-x-y-z)%10000)
	q = ((s-x-y-z-w)%100000)
	t = x+y//10+z//100+w//1000+q//10000
	if a<=t<=b:
		sum += s
print(sum)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
cnt = 0
for i in range(1,n+1):
    s = list()
    l = str(i)
    for j in range(len(l)):
        s.append(int(l[j]))
    if a <= sum(s) and sum(s) <= b:
        hoge = map(str, s)
        hoge = ''.join(hoge)
        cnt += int(hoge)

print(cnt)

Submission status: Accepted

Solution code:
N,A,B=list(map(int, input().split()))
sum=0
count=0
flag=False
for i in range(0,10):
    for j in range(0,10):
        for k in range(0,10):
            for l in range(0,10):
                if count==N+1:
                    break

                count+=1

                if count==1:
                    continue

                if i+j+k+l>=A and i+j+k+l<=B:
                    sum+=i*1000+j*100+k*10+l
    if flag:
        break

if count==10000 and A==1:
    sum+=10000
print(sum)

Submission status: Accepted

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

RESULT = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# スペース区切りの整数の入力
N, a, b= map(int, input().split())
summation = 0

for i in range(N+1):
    num = i
    total = 0
    while num != 0:
        q, mod = divmod(num, 10)
        total += mod
        num = q
    
    if total >= a and total <= b:
        summation += i
    
print(summation)

Submission status: Accepted

Solution code:
#2
# -*- coding: utf-8 -*-
import sys
from math import *
if __name__ =="__main__":
    str_in = input()
    num = [int(n) for n in str_in.split()]
    N,A,B=num
    SUM=0
    if N<0 or N>(10**4) or A<0 or B<0 or A>36 or B>36 or A>B:
        print("error input!")
    else:
        for i in range(1,(N+1)):
            #print(i)
            ii0 = int((i / 1) % 10 )
            ii1 = int((i / 10) % 10)
            ii2 = int((i / 100) % 10)
            ii3 = int((i / 1000) % 10)
            ii4 = int((i / 10000) % 10)
            #print(ii4,ii3,ii2,ii1,ii0)
            SUMi=ii4+ii3+ii2+ii1+ii0
            if(SUMi>=A and SUMi<=B):
                SUM+=i
        print(SUM)

Submission status: Accepted

Solution code:
a=map(int, raw_input().split())
ans=0
for i in range(a[0]):
    i+=1
    b=list(str(i))
    pre=0
    for j in b:
        pre+=int(j)
    if pre>=a[1] and pre<=a[2]:
        ans+=i
print ans

Submission status: Accepted

Solution code:
INPUT=input()
IN=INPUT.split(" ")
#N=int(IN[0])
number=int(IN[0])
#N
A=int(IN[1])
B=int(IN[2])

GOUKEI=0
kazu=0

while kazu<=number:
    X=list(map(int,list(str(kazu))))
    #X = list(map(int, n))
   
    #print(X)
    if A<=sum(X)<=B:
        GOUKEI+=kazu
        #print("add",kazu)
    kazu+=1
print(GOUKEI)

Submission status: Accepted

Solution code:
n, a, b = (int(x) for x in input().split())
c = 0
sum = 0
for i in range(1, n+1):
  c += 1
  if a <= c <= b:
    sum += i
  while i%10 == 9:
    c -= 9
    i //= 10
print(sum)

Submission status: Accepted

Solution code:
T=0

def wa(a):
    s=0
    A = list(str(a))
    for i in range(len(A)):
        s += int(A[i])
    return s

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

for i in range(1, N+1):
    if(i<10 and A<=i and i<=B):
        T+=i
    elif(i>=10 and A<=wa(i) and wa(i)<=B):
        T+=i

print(T)

Submission status: Accepted

Solution code:
def f(n):
    N=n
    s=0
    for i in range(5):
        g = n%10
        s+=g
        n = int(n / 10)
        if n < 1:
            break
    if a<=s and s<=b:
        return N
    return 0
n,a,b = map(int, input().split())
l = [i+1 for i in range(n)]
l = list(map(f, l))
print(sum(l))

Submission status: Accepted

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

num = map(int, str(n))

nums = []

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

for i in range(n+1):
    if a <= digitSum(i) <= b:
        nums.append(i)

print(sum(nums))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
num, low, hi = list(map(int, input().split()))
within = []
for i in range(1, num+1):
    c = 0
    for n in str(i):
        c = c + int(n)

    if c >= low and c <= hi:
        within.append(int(i))

print(sum(within))

Submission status: Accepted

Solution code:
num=input().split(' ')
res=0
for i in range(int(num[0])):
    i=i+1
    s=str(i)
    tmp=0
    for w in s:
        tmp+=int(w)
    if tmp>=int(num[1]) and tmp<=int(num[2]):
        res+=i
print(str(res)+'\n')

Submission status: Accepted

Solution code:
N,A,B=input().split(' ')
N,A,B = [int(N),int(A),int(B)]
SUM = 0

for i in range(N+1):
	I = str(i)
	array = list(map(int, list(I)))
	s = sum(array)
	#print(s)
	if A <= s and s <= B:
		#print(i)
		SUM += i
print(SUM)

Submission status: Accepted

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

s=0;
for i in range(n+1):
    nl=list(str(i))
    ns=0;
    for j in range(len(nl)):
        ns+=int(nl[j]);
    if (ns>=a and ns<=b):
        s+=i
print(s)

Submission status: Accepted

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

sum = 0
for n in range(1, N+1):
  n = '0000' + str(n)
  a, b, c, d, e = int(n[-5]), int(n[-4]), int(n[-3]), int(n[-2]), int(n[-1])
  if A <= a + b + c + d + e <= B:
    sum += int(n)
print(sum)

Submission status: Accepted

Solution code:
def ketanowa(p):
    ans=0
    p=str(p)
    for i in p:
        ans+=int(i)
    return ans

def main():
    temp=input().split(" ")
    n=int(temp[0])
    a=int(temp[1])
    b=int(temp[2])
    su=0


    for i in range(n+1):
        if  a<=ketanowa(i) and ketanowa(i)<=b:
            su+=i
    print (su)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
from functools import reduce
from operator import add


def main(n, min_limit, max_limit):
    result = 0

    for i in range(1, n+1):
        tmp = reduce(add, [int(n) for n in str(i)])
        if min_limit <= tmp <= max_limit:
            result += i

    print(result)


if __name__ == "__main__":
    lst = [int(val) for val in input().split()]
    main(lst[0], lst[1], lst[2])

Submission status: Accepted

Solution code:

import math

input_line = input().rstrip().split(' ')

total = 0
N = int(input_line[0])
A = int(input_line[1])
B = int(input_line[2])
result = 0
for value in range(1, N + 1):
	tmp_value = value;
	digit_sum = 0;
	while (tmp_value >= 10):
		digit_sum += tmp_value % 10
		tmp_value = math.floor(tmp_value / 10)

	digit_sum += tmp_value % 10
	if (digit_sum >= A and digit_sum <= B):
		result += value

print(result)

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
sumans = 0
for i in range(N+1):
    nn = i
    nnsum = 0
    while nn > 0:
        a = nn%10
        nn = int(nn/10)
        nnsum += a
    if(nnsum <= B and nnsum >= A):
        sumans += i
        
print(sumans)

Submission status: Accepted

Solution code:
n=list(map(int,input().split(" ")))
s=0

for i in range(1,n[0]+1):
    j = str(i)
    j = list(map(int,j))
    
    if (n[1] <= sum(j) <= n[2]):
        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):
    digisum=0
    tmpI=i
    while(True):
        digisum+=tmpI%10
        if tmpI<10:
            if(A<=digisum and digisum<=B):
                ans+=i
            break
        tmpI=int(tmpI/10)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

def gen(n):
  if n < 10:
    yield n
  else:
    for m in gen(n/10):
      yield m
    yield n%10

ans = 0
for i in range(0, a[0]+1):
    num = [int(j) for j in gen(i)]
    sumed = sum(num)
    if (a[1] <= sumed) and (sumed <= a[2]):
        ans = ans + i

print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
def b_SomeSums(N, A, B):
    def sum_digit(N):
        # Nの各桁の和を計算
        ret = 0
        N = str(N)
        for i in range(len(N)):
            ret += int(N[i])
        return ret

    ans = 0
    for i in range(1, N + 1):
        tmp = sum_digit(i)
        if A <= tmp <= B:
            ans += i
    return ans

N,A,B = [int(i) for i in input().split()]
print(b_SomeSums(N, A, B))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding:utf-8

N, A, B = list(input().split())
A_ = int(A)
B_ = int(B)
N_ = int(N)
i_ = "0"

lists = []
for i in range(N_+1):
    i_ = str(i)
    sum_ = 0
    for x in i_:
        sum_ += int(x)
    if sum_ >= A_ and sum_ <= B_:
        lists.append(i)

#print("list = ", lists)
sum_ = 0
for ele in lists:
    sum_ += ele

#print("sum = ",sum_)
print(sum_)

Submission status: Accepted

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

tally = 0
for i in range(1,n+1):
    s = 0
    for digit in str(i):
        s = s + int(digit)
    if a <= s <= b:
        tally = tally + i

print(tally)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from pprint import pprint as pp

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/python

import sys

def sum_digit(number):
    s = 0
    for digit in str(number):
        s += int(digit)
    return s

def main(argv):
    line = sys.stdin.readline()
    while line:
        N, A, B = map(lambda x: int(x), line.rstrip("\n").split(" "))

        s = 0
        for i in xrange(N + 1):
            s_d = sum_digit(i)
            if s_d >= A and s_d <= B:
                s += i
        print s

        line = sys.stdin.readline()

if __name__ == "__main__":
    main(sys.argv)

Submission status: Accepted

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

count = 0
for n in xrange(1, N+1):
    s = sum(int(c) for c in str(n))
    if A <= s <= B:
        count += n

print count

Submission status: Accepted

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

cnt = 0
for i in range(N + 1):
    if A <= sum([int(l) for l in list(str(i))]) <= B:
        cnt += i
print(cnt)

Submission status: Accepted

Solution code:
def calc(num):
    ans = 0
    for i in str(num):
        ans += int(i)
    return ans


n, a, b = map(int, raw_input().split(" "))
lis = []
for i in xrange(n):
    tmp = calc(i + 1)
    if a <= tmp  and tmp <= b:
        lis.append(i + 1)

print sum(lis)

Submission status: Accepted

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

number_list = list(map(str, range(1, N+1)))

count = 0

for number in number_list:
    sum = 0
    for s in number:
        sum += int(s)
    if sum >= A and sum <= B:
        count += int(number)

print(count)

Submission status: Accepted

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

N, A, B = [int(i) for i in input().split()]
cnt = 0
for i in range(1, N + 1):
    chk_val = 0
    n = i
    while n != 0:
        chk_val += n % 10
        n = n // 10
    if (chk_val >= A ) and (chk_val <= B):
        #print(i, chk_val)
        cnt += i

print(cnt)