jiahuimbzuai/CoQuIR huggingface dataset:
//  [go]
package main

import(
  "fmt"
)

func main(){
  var S,T,R,Q string
  
  fmt.Scan(&S)
  fmt.Scan(&T)

  i := 0
  R=S
  
  for i<len(S){
    
    Q=R[len(R)-1:]
    R=R[:len(R)-1]
    R=Q+R
    
    fmt.Println(R)
    
    if R==T{
      fmt.Println("Yes")
      break
    }else{
      if i==len(S)-1{
        fmt.Println("No")
        break
      }
    }
    i++
  }
}
//  [ruby]
s,t = 2.times.map{gets.chomp.chars}

if s == t
  puts 'Yes'
  exit
end

if s.any?{s.rotate! == t}
  puts 'Yes'
else
  puts 'No'
end
//  [ruby]
s,t = 2.times.map{gets.chomp}

if s == t
  puts 'Yes'
  exit
end

s.size.times do |i|
  last = s.size-2
  s = s[-1] + s[0..last]
  if s == t
    puts 'Yes'
    exit
  end
end

puts 'No'
//  [ruby]
s = gets.chomp
t = gets.chomp

n = s.size

n.times do
  s = s[-1] + s[0..n-2]
  if s == t
    puts 'Yes'
    exit
  end
end
puts 'No'
//  [ruby]
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を文字の配列で返却する
def gets_nsp_list()
  gets.chomp.split("")
end

s = gets_nsp_list.sort
t = gets_nsp_list.sort

0.upto(s.size-1) do |i|
  if s[i] != t[i]
    puts "No"
    exit
  end
end

puts "Yes"
//  [ruby]
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を文字の配列で返却する
def gets_nsp_list()
  gets.chomp.split("")
end

s = gets_nsp_list.sort
t = gets_nsp_list.sort

if s == t
  puts "Yes"
else
  puts "No"
end
//  [ruby]
s = gets.chomp.split('')
t = gets.chomp.split('')
check = 0
n = s.size
if s.join('') != t.join('')
  n.times do
    tmp = s.pop
    s.unshift(tmp)
    check += 1 if s.join('') == t.join('')
  end
end
if check > 0
  puts :Yes
else
  puts:No
end
//  [rust]
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: String = read();
    let c: String = read();
    let mut sv: Vec<char> = s.chars().collect();
    let cv: Vec<char> = c.chars().collect();

    for _ in 0..s.len() {
        let a = sv.remove(0);
        sv.push(a);


        if sv == cv {
            println!("Yes");
            return;
        }

    }
    println!("No");
}
//  [rust]
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s:Vec<char> = buf.trim().chars().collect();
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let t:Vec<char> = buf.trim().chars().collect();
	let mut flag = false;
	
	for i in 0..s.len() {
		let s1 = &s[(s.len() - i - 1)..s.len()];
		let s2 = &s[0..(s.len() - i -1)];
		let t1 = &t[0..(i + 1)];
		let t2 = &t[(i + 1)..t.len()];
		if s1 == t1 && s2 == t2 {
			flag = true;
			break;
		}
	}
	if flag {
		println!("Yes");
	}else{
		println!("No");
	}
}
//  [rust]
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s = buf.trim().to_string();
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let t = buf.trim().to_string();
	let mut flag = false;
	let mut rots = String::new();
	rots = s;
	for i in 0..rots.len() {
		let s1 = &rots[0..(rots.len() - 1)];
		let s2 = &rots[(rots.len()-1)..rots.len()];
		s = format!("{}{}", s2, s1);
		
		if s == t {
			flag = true;
			break;
		}
		rots = s;
	}
	if flag {
		println!("Yes");
	}else{
		println!("No");
	}
}
//  [rust]
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s = buf.trim().to_string();
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let t = buf.trim().to_string();
	let mut flag = false;
	let mut rots = String::new();
	rots = s;
	for i in 0..rots.len() {
		let s1 = &rots[0..(rots.len() - 1)];
		let s2 = &rots[(rots.len()-1)..rots.len()];
		rots = format!("{}{}", s2, s1);
		
		if rots == t {
			flag = true;
			break;
		}
	}
	if flag {
		println!("Yes");
	}else{
		println!("No");
	}
}
//  [rust]
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s = buf.trim();
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let t = buf.trim();
	let mut flag = false;
	for i in 1..(t.len() + 1) {
		let s1 = &s[(s.len() - i)..s.len()];
		let t1 = &t[0..i];
		if s1 == t1 {
			flag = true;
			break;
		}
	}
	if flag {
		println!("Yes");
	}else{
		println!("No");
	}
}
//  [swift]
import Foundation
var s = readLine()!
let t = readLine()!
for _ in 0..<t.count {
  if s == t {
    print("Yes")
    exit(0)
  }
  let c = s[s.index(s.endIndex, offsetBy: -1)]
  s = "\(c)\(String(s.dropLast()))"
}
print("No")
//  [swift]
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

var S = readLine()!.toArray() + [""]              // 100 + 1 -> 101
let T = readLine()!
var ans = "No"
for _ in 0..<S.count {
    for i in ((0..<S.count).map{$0}).reversed() { // (0..<101).reversed() -> (100...0)
        if i > 0 {
            S[i] = S[i-1]                         // S[100] = S[99]
        } else {
            S[i] = S[S.count-1]                   // S[0] = S[100]
            S[S.count-1] = ""
        }
    }
    if S.joinWithSeparator("") == T {
        ans = "Yes"
        break
    }
}
print(ans)
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};
const main=()=>{
  let s=ts().split('')
  let t=ts()
  for(let i=0;i<s.length;i++){
    if(s.join('')===t){
      to('Yes')
      return
    }
    s.unshift(s[s.length-1])
    s.pop()
  }
  to('No')
}
main()
//  [typescript]
declare var require: (x: string) => any;

function Main(input: string[]) {
  const [s, t] = input;
  console.log((s+s).indexOf(t) >= 0 ? 'Yes' : 'No');
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8').split('\n'));
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [s, t] = stdin.trim().split('\n')

const ans = _ => {
  let sArr = s.split('')
  for (let i = 0; i < sArr.length; i++) {
    const last = sArr[sArr.length - 1]
    sArr = [last, ...sArr]
    sArr.pop()

    const str = sArr.join('')

    if (str === t) return 'Yes'
  }
  return 'No'
}

console.log(ans())
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};
const main=()=>{
  let s=ts().split('')
  let t=ts()
  for(let i=1;i<s.length;i++){
    s.unshift(s[s.length-1])
    s.pop()
    if(s.join('')===t){
      to('Yes')
      return
    }
  }
  to('No')
}
main()
//  [python]
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)
//  [python]
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))
//  [python]
N, A, B = map(int, input().split())
n_list = [0]
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)
        elif digit == 1 and i < sum_min: continue
        else:
            setDigit(N_max - (i * 10 ** (digit - 1)), max(sum_min - i, 0), sum_max - i, digit - 1)


setDigit(N, A, B, digit_N)

print(sum(n_list))
//  [python]
N,A,B = map(int,input().split())
ans_list = []

for i in range(0,N+1):
    if i < 10:
        if i >= A and i <=B:
            ans_list.append(i)
    else:
        temp = list(map(int,str(i)))
        temp = temp[0]+temp[1]
        if temp >=A and temp<=B:
            ans_list.append(i)
            
print(sum(ans_list))
//  [python]
N = int(input())
A = int(input())
B = int(input())
ans_list = []

for i in range(0,N+1):
    if i < 10:
        if i >= A and i <=B:
            ans_list.append(i)
    else:
        temp = list(map(int,str(i)))
        temp = temp[0]+temp[1]
        if temp >=A and temp<=B:
            ans_list.append(i)
            
print(sum(ans_list))
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader buff = null;
		buff = new BufferedReader(new InputStreamReader(System.in));

		String[] box = buff.readLine().split(" ");
		int N = Integer.parseInt(box[0]);
		int A = Integer.parseInt(box[1]);
		int B = Integer.parseInt(box[2]);

		int count = 0;
		while(N > 0){
			int total = 0;
			int pre = N;
			while(pre > 0){
				total += pre % 10;
				pre = pre / 10;
				//System.out.println(" / " + pre + " " + total);
			}
			if(total >= A && total <= B){
				//System.out.println(" * " + total + " " + N);
				count += N;
			}
			N--;
		}

		System.out.println(count);
	}

	static long f() {
		long ans = 0;


		return ans;
	}
}
//  [java]
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int ans = 0;
		for (int i = 1; i <= N; i++) {
			if (i / 10 == 0) {
				if (A <= i && i <= B)
					ans += i;
			} else if (i / 100 == 0) {
				if (A <= i % 10 + i / 10 && i % 10 + i / 10 <= B)
					ans += i;
			} else if (i / 1000 == 0) {
				if (A <= i % 10 + i % 100 / 10 + i / 100 && i % 10 + i % 100 / 10 + i / 100 <= B)
					ans += i;
			} else if (i / 10000 == 0) {
				if (A <= i % 10 + i % 100 / 10 + i % 1000 / 100 + i / 1000
						&& i % 10 + i % 100 / 10 + i % 1000 / 100 + i / 1000 <= B)
					ans += i;
			} else if (i == 10000) {
				if (A <= 1 && 1 <= B)
					ans += i;
			}
		}
		System.out.println(ans);

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}
//  [java]
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
      	int b = sc.nextInt();
		int sho = 0;
      	int amrs = 0;
	    int ans = 0;
      
      for(int i = 1 ; i < n+1 ; i++){
        sho = i;
        amrS= 0;
      	while(sho != 0){
          amrS += sho%10;
          sho /= 10;
        }  
        if(amrS >= a && amrS <= b){
        	ans += i; 
        }  
      }
                  System.out.println(ans);
    }
}
//  [java]
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
      	int b = sc.nextInt();
		int sho, amrS;
	    int ans = 0;
      for(int i = 1 ; i < n+1 ; i++){
        sho = i;
        amrS= 0;
      	while(sho != 0){
          sho /= 10;
          amrS += sho%10;
        }  
        if(amrS >= a && amrS <= b){
        	ans += i; 
        }  
      }
                  System.out.println(ans);
    }
}
//  [java]
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
      	int b = sc.nextInt();
		int sho, amrs;
	    int ans = 0;
      for(int i = 1 ; i < n+1 ; i++){
        sho = i;
        amrS= 0;
      	while(sho != 0){
          sho /= 10;
          amrS += sho%10;
        }  
        if(amrS >= a && amrS <= b){
        	ans += i; 
        }  
      }
                  System.out.println(ans);
    }
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000000
#define maxn 110
#define inf 0x7fffffff
/*------------------------------------------------------------*/
int n,m;
int a,b;
bool check(int x){
	int ans=0;
	while(x){
		ans+=x%10;
		x/=10;
	}
	return ans>=a&&ans<=b;
}
int main(){
	in(n);
	in2(a,b);
	int ans=0;
	FOR(i,1,n){
		if(check(i))ans+=i;
	}
	out(ans);
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int fn(int i){
	if(i<=9) return i;
	else return i%10+fn(i/10);
}
 
int main(void){
	int N,A,B;
	ll result=0;
	cin>>N>>A>>B;
	FOR(i,1,N+1){
		int tmp=fn(i);
		if(A<=tmp&&tmp<=B) result+=i;
	}
	print(result);
	return 0;
}
//  [cpp]
#include <bits/stdc++.h>

using namespace std;

bool check(int i, int a, int b)
{
    int res = 0;
    while(i) {
        res += i % 10;
        i /= 10;
    }

    return a <= res && res <= b;
}

int main()
{
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);

    int ans = 0;
    for(int i = 1; i <= n; i++)
        if(check(i, a, b))
            ans += i;
    printf("%d\n", ans);

    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  int res = 0;
  for(int i = 1; i <= n; ++i){
    if(check(i,a,b)){
      res += i;
    }
  }
  cout << res;
}

bool check(int p,int x,int y){
  int c = 0;
  while(p > 0){
    c += p % 10;
    p /= 10;
  }
  if(x <= c && c <= y){
    return true;
  }
  return false;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
int main(){long long n,a,b,sum1=0,sum2=0,sum3=0;
cin>>n>>a>>b;
sum1=((b-a+1)*(b+a))/2 ;
for(int i=11;i<=sum1;i++){
    sum2+=i;
}
long long ans =sum1 + sum2 + n;
cout << ans << endl;
return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
int main(){int n,a,b,sum1=0,sum2=0,sum3=0;
cin>>n>>a>>b;
sum1=((b-a+1)*(b+a))/2 ;
 int arr1[n];
for(int i=11;i<=sum1;i++){
    sum2+=i;
}
int ans =sum1 + sum2 + n;
cout << ans << endl;
return 0;
}
//  [c]
#include <stdio.h>
int main(){
    int n,a,b,r=0,i,j;
    scanf("%d%d%d",&n,&a,&b);
    for(i=1;i<=n;i++){
        int s=0;
        j=i;
        for(;j;j/=10)s+=j%10;
        if(a<=s&&s<=b)r+=i;
    }
    printf("%d\n",r);
    return 0;
}
//  [c]
#include <stdio.h>

int bun_kai(int x, int k){
    if(k == 4){
        return x / 10000;
    }else if(k == 3){
        return (x % 10000) / 1000;
    }else if(k == 2){
        return (x % 1000) / 100;
    }else if(k == 1){
        return (x % 100) / 10;
    }else {
        return x % 10;
    }
}
int main(void){
    int N, A, B = 0;
    scanf("%ld %ld %ld", &N, &A, &B);
    int sum = 0;
    for(int n = 1; n <= N; n++){
        int degit[5] = {0};
        int subsum = 0;
        for(int i = 4; i >= 0; i--){
            degit[i] = bun_kai(n, i);
            subsum += degit[i];
        }

        if(subsum >= A && subsum <= B){
            sum += n;
        }
    }
    printf("%d\n", sum);
    return 0;
}
//  [c]
#include<stdio.h>
int sum(int);
int main(){
  int n,a,b,i,ans=0;
  scanf("%d%d%d",&n,&a,&b);
  for(i=1;i<=n;i++){
    if(a<=sum(i)&&sum(i)<=b){
      ans+=i;
    }
  }
  printf("%d",ans);
}
int sum(int n){
  int s;
  s=n/10000+(n%10000)/1000+(n%1000)/100+(n%100)/10+n%10;
  return s;
}
//  [c]
#include<stdio.h>

int main(){
	long long int a,b,c,d;
	long long int N,A,B;
	long long int total=0;
	
	scanf("%lld %lld %lld", &N, &A, &B);
	
	for(int i=1; i<=N; i++){
	
		a=i/1000; 
		b=(i/100)%10;
		c=(i/10)%10;
		d=i%10;
		
		
		long long int hasil=a+b+c+d;
		
		if(hasil >=A && hasil <=B){
			total+=i;
		
		}
	}
	printf("%lld", total);
}
//  [c]
#include<stdio.h>

int main(){
	long long int a,b,c,d;
	long long int N,A,B;
	long long int total=0;
	
	scanf("%d %d %d", &N, &A, &B);
	
	for(int i=1; i<=N; i++){
	
		a=i/1000; 
		b=(i/100)%10;
		c=(i/10)%10;
		d=i%10;
		
		
		long long int hasil=a+b+c+d;
		
		if(hasil >=A && hasil <=B){
			total+=i;
		
		}
	}
	printf("%lld", total);
}
//  [c]
#include<stdio.h>

int main(){
	int a,b,c,d;
	int N,A,B;
	long long int total=0;
	
	scanf("%d %d %d", &N, &A, &B);
	
	for(int i=1; i<=N; i++){
	
		a=i/1000; 
		b=(i/100)%10;
		c=(i/10)%10;
		d=i%10;
		
		int hasil=a+b+c+d;
		
		if(hasil >=A && hasil <=B){
			total+=i;
		
		}
	}
	printf("%lld", total);
}
//  [javascript]
'use strict'

function Main(input) {
  const inputList = input.split(' ');
  const n = Number(inputList[0])
  const a = Number(inputList[1])
  const b = Number(inputList[2])
  let sum = 0

  for (let i=1; i<=n; i++) {
    let digitTotal = 0
    let tmpN = i
    while (tmpN>0) {
      digitTotal = digitTotal + (tmpN % 10)
      tmpN = Math.floor(tmpN/10)
    }

    if (digitTotal >= a && digitTotal <= b) {
      sum += i
    }
  }

  console.log(sum)
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
'use strict'
function Main(input) {
  input = input.split(" ");
  const N = parseInt(input[0], 10);
  const A = parseInt(input[1], 10);
  const B = parseInt(input[2], 10);
  const div10 = (a) => Math.floor(a / 10);
  let count = 0;
  
  function sum(n){
    let result = 0;
    while(n > 0){
      result += (n % 10);
      n = div10(n);
    }
    return result;
  }
  
  for (let i=1; i<=N; i++){
    const temp = sum(i);
    if (temp >= A && temp <= B){
      count += i;
    }
  }
 
  console.log('%d',count);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split(" ");
    var n = parseInt(input[0], 10);
	//文字列から10進数に変換するときはparseIntを使います
    var a = parseInt(input[1], 10);
    var b = parseInt(input[2], 10);
    var sum = 0;
    for(var checkVal = 0; checkVal <= n; checkVal++) {
        var tmpSum = 0;
        var tmpValForSum = checkVal;
        do {
            tmpSum += tmpValForSum % 10;
            tmpValForSum = Math.floor(tmpValForSum / 10);
        } while (tmpValForSum > 0);
        if(tmpSum >= a && tmpSum <= b) {
            sum+= checkVal;
        }
    }
	//出力
	console.log('%d',sum);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function main(input) {
	const args = input.split(' ').map((n) => parseInt(n, 10));
  	const N = args[0],
          A = args[1],
          B = args[2]

    let total = 0;
  	
  	for (let i = 1; i <= N; i++) {
    	sum = findSumOfDigits(i);
      	if (A <= sum && sum <= B) {
        	total += i
        }
    }
  
  	console.log(total);
}

function findSumOfDigits(n) {
  	let sum = 0;
	while(n > 0) {
      sum += n % 10;
      n = n / 10;
    }
  	return sum;
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function main(input){
  //初期条件（入力値を取り出し、N,A,Bを数値化した）
  var val = input;
  val = val.split(' ');
  var nod = val[0].length
  var con = [];
  for(var i=0;i<val.length;i++){
    con.push(Number.parseInt(val[i]));
  }
  //今回求める総和の初期条件を設定
  var totalSum = 0;
  for(var j=1;j<=con[0];j++){
    var sum = 0;
    for(let k=0;k<nod;k++){
      var sum = (j%10)+sum;
      int = Math.floor(int/10);
    }
    if(sum >= con[1] && sum <= con[2]){
      totalSum += j;
    }
  }
  console.log(totalSum);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
const input = require("fs").readFileSync("/dev/stdin", "utf8").split(/\s/);

var ret = 0;
for (var i = 1; i <= input[0] - 0; i++) {
  var s = i.split("");
  var sum = s.map(Number).reduce(function (a, b) {
    return a + b;
  });

  if (input[1] <= sum && sum <= input[2]) ret += i;
}

console.log(ret);
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func digitSum(x int) int {
	s := 0
	for x > 0 {
		s += x % 10
		x /= 10
	}

	return s
}

func main() {
	n, a, b := nextInt(), nextInt(), nextInt()

	s := 0
	for i := 1; i <= n; i++ {
		d := digitSum(i)
		if a <= d && d <= b {
			s += i
		}
	}

	fmt.Println(s)
}
//  [go]
package main

import (
        "fmt"
)

func solution(n, a, b int) int {
        out := 0
        for i := 1; i <= n; i++ {
                t := sumDigit(i)
                if t >= a && t <= b {
                        out += i
                }
        }
        return out
}

func sumDigit(n int) int {
        out := 0
        for n > 0 {
                out += n % 10
                n /= 10
        }
        return out
}

func main() {
        var n, a, b int
        fmt.Scan(&n, &a, &b)
        fmt.Println(solution(n, a, b))
}
//  [go]
package main

import (
	"fmt"
)

func sums(n int) int {
	var sum int
	for n > 0 {
		sum += n%10
		n/=10
	}
	return sum
}

func main() {
	var (
		n, a, b, sum int
	)
	fmt.Scan(&n, &a, &b)
	for i := 1; i<n+1; i++{
		if v := sums(i); a<=v && v<=b {
			sum += i
		} 
	}
	
	fmt.Println(sum)
}
//  [go]
package main
 
import (
	"fmt"
	"os"
	"bufio"
	"strconv"
	"strings"
)

func sum(i int) int {
    str := strconv.Itoa(i)
    if len(str) == 1 {
        in, _ := strconv.Atoi(string(str[0]))
        return in
    } else {
        //len==2
        in, _ := strconv.Atoi(string(str[0]))
        in2, _ := strconv.Atoi(string(str[0]))
        result := in + in2
        return result
    }
}
 
func main(){
  sc := bufio.NewScanner(os.Stdin)
  sc.Scan()
  numsList := strings.Split(sc.Text(), " ")
  max, _ := strconv.Atoi(numsList[0])
  lower, _ := strconv.Atoi(numsList[1])
  upper, _ := strconv.Atoi(numsList[2])
  
  nums := make([]int, 0)
  for i:=1; i<=max; i++ {
    
    if sum(i)>=lower && upper>=sum(i) {
      nums = append(nums, i)
    }
  }

  sum := 0
  for _, n := range nums {
      sum+=n
  }
    
  fmt.Println(sum)
}
//  [go]
package main

import (
	"fmt"
	"os"
	"bufio"
	"strconv"
	"strings"
)

func main(){
  sc := bufio.NewScanner(os.Stdin)
  sc.Scan()
  numsList := strings.Split(sc.Text(), " ")
  max, _ := strconv.Atoi(numsList[0])
  lower, _ := strconv.Atoi(numsList[1])
  upper, _ := strconv.Atoi(numsList[2])
  
  nums := make([]int, 0)
  for i:=1; i<=max; i++ {
    if i>=lower && upper>=i {
      nums = append(nums, i)
    }
  }
  
  fmt.Println(nums)
}
//  [go]
package main

import (
	"fmt"
)

func sums(n int) int {
	var sum int
	for n > 0 {
		sum += n%10
		n/=10
	}
	return sum
}

func main() {
	var (
		n, a, b, sum int
	)
	fmt.Scan(&n, &a, &b)
	for i:=1;i<n+1; i++{
		if v := sums(i); a<=v && v<=b {
			sum += i
		} 
	}
	
	fmt.Println(sum)
}
//  [ruby]
N, A, B = gets.chomp.split(' ').map(&:to_i)

total = 0

if A == 1 && B == 1 && N == 10000
  total = N
end

(1..N).each do |n|
  nn = n
  a = n / 1000
  n = n - a * 1000

  b = n / 100
  n = n - b * 100

  c = n / 10
  d = n - c * 10

  sum = a + b + c + d
  if A <= sum && sum <= B 
    total += nn 
  end
end

print total
//  [ruby]
n,a,b=gets.split.map &:to_i
y=0
(n+1).times do|i|
  x=i/10000+i%10000/1000+i%1000/100+i%100/10+i%10
  if x>=a&&x<=b then y+=i end
end
p y
//  [ruby]
n,a,b = gets.split.map &:to_i
y = 0
(n+1).times do |i|
	x = i/10000+i%10000/1000+i%1000/100+i%100/10+i%10
	y += i if a<=x && x<=b
end

puts y
//  [ruby]
def digit_sum(n)
    sum = 0
    while n > 0 do
        sum += n % 10
        n /= 10
    end
    sum
end

ans = (1..n)
        .map { |i| [i, digit_sum(i)] }
        .select { |d| a <= d[1] && d[1] <= b }
        .inject(0) { |sum, d| sum + d[0] }

puts ans
//  [ruby]
n,a,b=gets.strip.split.map(&:to_i)

def calc_digit_sum n
    sum=0
    while n>0 do
    a=n%10
    sum+=a
    n/=10
    end
    sum
end

ans=(10..n).map{|i| [i,calc_digit_sum(i)]}.select{|i| a<=i[1]&&i[1]<=b}.inject(0){|sum,num| sum+=num[0]}


puts ans
//  [rust]
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        n: usize,
        a: usize,
        b: usize
    };
    let range = a..=b;
    println!(
        "{}",
        (1..=n)
            .filter(|&i| {
                let mut sum = 0;
                let mut j = i;
                while j > 0 {
                    sum += j % 10;
                    j /= 10;
                }
                range.contains(&sum)
            })
            .sum::<usize>()
    );
}
//  [rust]
use std::io::*;

fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let nums: Vec<&str> = buf.trim_right().split(" ").collect();

    let n: i32 = nums[0].parse().unwrap();
    let a: i32 = nums[1].parse().unwrap();
    let b: i32 = nums[2].parse().unwrap();

    let mut total = 0;

    for i in 1..n+1 {
        let sum: i32 = i.to_string().chars().map(|c| c as i32 - 48).sum();
        if sum >= a && sum <= b {
            total += i;
        }
    }

    let out = stdout();
    let mut out = out.lock();
    writeln!(out, "{}\n", total).unwrap();

}
//  [rust]
use std::io::stdin;

fn calc_ten_digit_num_sum(mut num: i32) -> i32 {
    let mut res = 0;
    while num > 0 {
        res += num % 10;
        num /= 10;
    }
    res
}

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();

    let nums: Vec<i32> = s
        .trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect();

    let n = nums[0];
    let a = nums[1];
    let b = nums[2];

    let mut total_sum = 0;

    // logic
    for i in 1..n+1 {
        let temp_sum = calc_ten_digit_num_sum(i);
        if a <= temp_sum && temp_sum <= b {
            total_sum += i;
            // total_sum += temp_sum;
        }
    }

    println!("{}", total_sum);
}
//  [rust]
fn solve(n: u16, a: u16, b: u16) -> u16 {
    let mut result = 0;

    for x in 1..=n {
        let v: Vec<u16> = x.to_string().chars().map(|c| c as u16 - 48).collect();
        let sum = v.iter().sum::<u16>();

        if a <= sum && sum <= b {
            result += x;
        }
    }
    result
}

fn main() {
    let (n, a, b) = read_tup3();

    println!("{}", solve(n, a, b));
}

fn read_tup3<T: std::str::FromStr + Copy>() -> (T, T, T) {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let v = s.trim().split_whitespace()
        .map(|c| c.parse().ok().unwrap())
        .collect::<Vec<T>>();
    (v[0], v[1], v[2])
}
//  [rust]
use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).expect("panic read line");
    let splitted_input: Vec<i32> = input.split_whitespace()
                        .map(|s| s.parse().expect("panic parse"))
                        .collect();

    let n = splitted_input[0];
    let a = splitted_input[1];
    let b = splitted_input[2];

    let mut some_sum = 0;
    for i in 1..n {
        let i: String = i.to_string();
        let mut sum: i32 = 0;
        for s in i.chars() {
            let digit: i32 = s as i32 - 48;
            sum += digit;
        }

        if sum >= a && sum <= b {
            some_sum += sum;
        }
    }

    println!("{}", some_sum);
}
//  [swift]
//usr/bin/env swift $0 $@;exit
let arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}
let n=arr[0]
let a=arr[1]
let b=arr[2]
var r=0
for i in 1...n {
	var j=i
	var s=0
	while j>0 {
		s+=j%10
		j/=10
	}
	if a<=s&&s<=b {r+=i}
}
print(r)
//  [swift]
func readInts() -> [Int] { readLine()!.split(separator: " ").map { Int($0)! } }

extension Int {
    var digits: [Int] {
        String(describing: self).compactMap { Int(String($0))! }
    }
}

func main() {
  let numbers: [Int] = readInts()
  var sum = 0
  for i in 1...numbers.first! {
    let sumOfDigits = i.digits.reduce(0) { $0 + $1 }
    if sumOfDigits >= numbers[1] && sumOfDigits <= numbers[2] {
      sum += i
    }
  }
  print(sum)
}

main()
//  [swift]
func sumDigits(_ num: Int) -> Int {
    var num = num
    var sum = 0
    while num > 0 {
        sum += num%10
        num /= 10
    }
    return sum
}


let rd = readLine()!.split(separator: " ").map({Int($0)!})
let N = rd[0]
var sum = 0

for i in 1 ... N {
    if rd[1] <= sumDigits(i) && sumDigits(i) <= rd[2] {
        sum += i
    }
}
print(sum)
//  [swift]
func sumDigits(_ num: Int) -> Int {
    var num = num
    var sum = 0
    while num > 0 {
        sum += num%10
        num /= 10
    }
    return sum
}

let rd = readLine()!.split(separator: " ").map({Int($0)!})
let N = rd[0]
var sum = 0

for i in 1 ... N {
    if rd[1] <= sumDigits(i) && sumDigits(i) <= rd[2] {
        sum += sumDigits(i)
    }
}
print(sum)
//  [swift]
import Foundation
func indexSum(_ num: Int) -> Int {
    var sum = 0
    var arr = Array(String(num))
    for i in 0 ..< arr.count {
        var k = Int(String(arr[i]))
        sum += k ?? 0
    }
    return sum
}
let rd = readLine()!.split(separator: " ").map({Int($0)!})
let N = rd[0]
var sum = 0

for i in 1 ... N {
    if rd[1] <= indexSum(i) && indexSum(i) <= rd[2] {
        sum += indexSum(i)
    }
}
print(sum)
//  [swift]
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/

//var min, min2, count: Int!
//for i in 1...10 {
//    let x = Int(readLine()!)!
//    if i == 1 {
//        min = x
//        count = 1
//    } else if x < min {
//        min2 = min
//        min = x
//        count = 1
//    } else if x == min && count == 1 {
//        min2 = x
//        count = 2
//    }
//}
//print(min2)

/*************** メインプログラム ***************/

let input = readIntSplit(by: " ")
let (N, A, B) = (input[0], input[1], input[2])
var ans = 0
for i in 1...N {
    if A...B ~= String(i).toArray().reduce(0){$0+Int($1)!} {
        ans += i
    }
}
print(ans)
//  [typescript]
function Main(input) {
  const args = input.split(" ").map((x) => parseInt(x, 10));
  const n = args[0];
  const a = args[1];
  const b = args[2];

  let ans = 0;
  for (let i = 1; i <= n; i++) {
    let digit_sum = 0;
    let t = i;
    while (t != 0) {
      digit_sum += t % 10;
      t = parseInt(t / 10, 10);
    }
    if (a <= digit_sum && digit_sum <= b) {
      ans += i;
    }
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1];}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const objvs =(a)=>{const b=[];for(const v in a){b.push(a[v])}return b};
const main=()=>{
  let [n,a,b]=tnn(3),ans=0
  for(let i=1;i<=n;i++){
    let s=('00000'+i).slice(-5)
    let l=Number(s[0])+Number(s[1])+Number(s[2])+Number(s[3])+Number(s[4])
    if(l>=a&&l<=b)ans+=i
  }
  to(ans)
}
main()
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const [n, a, b] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

const ans = () => {
  let total = 0

  for (let i = 1; i <= n; i++) {
    const digits = String(i)
      .split('')
      .map(Number)

    const sum = digits.reduce((p, c) => p + c)

    if (sum >= a && sum <= b) total += i
  }

  console.log(total)
}

ans()
//  [typescript]
const lines = [];
const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});
reader.on("line", function (line) {
  lines.push(line);
});

reader.on("close", function () {
  const input = (lines[0] as string).split(" ");
  const maximum = input[0];
  const min = Number(input[1]);
  const max = Number(input[2]);

  console.log(sum(maximum, min, max));
});

function sum(maximum: string, min: number, max: number): number {
  let sum = 0;

  for (let i = 1; i <= Number(maximum); i++) {
    const iSum = digitSum(i);
    console.log(iSum);
    if (iSum >= min && iSum <= max) {
      sum = sum + i;
    }
  }

  return sum;
}

function digitSum(number): number {
  const numberArray: number[] = [];
  for (let i = 0; i < String(number).length; i++) {
    numberArray.push(+String(number).charAt(i));
  }
  return numberArray.reduce((accumulator, element) => {
    return accumulator + Number(element);
  });
}
//  [typescript]

const main = input => {
  'use strict';
  let args = String(input).split(' ');
  let N = Number(args[0]) + 1;
  let A = args[1];
  let B = args[2];
  let n1 = num => A <= num;
  let n2 = num => B >= num;
  let ans = [...Array(N)]
    .map((val, index) => {
      let num = String(index).split('');
      let n = num.reduce((pre, cu) => pre + Number(cu), 0);
      return n1(n) && n2(n) ? index : 0;
    })
    .reduce((pre, cu) => pre + cu, 0);
  console.log(ans);
};

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [python]
from heapq import heappop, heappush
from operator import itemgetter


def branchAndBound(N: int, M: int, V: list, W: list, R: list) -> int:
    def upperbound(w, v, i):
        rest = M - w
        _v = v
        for j in range(i + 1, N):
            if W[j] >= rest:
                rest -= W[j]
                v += V[j]
                _v = v
            else:
                _v += R[j] * rest
                break
        return v, _v

    prov, tmp = upperbound(0, 0, -1)
    h = [(tmp, W[0], V[0] * (W[0] >= M), 0), (upperbound(0, 0, 0)[1], 0, 0, 0)]
    while h:
        _v, w, v, cur = heappop(h)
        if _v > prov or cur == N - 1:
            continue
        nxtw, nxtv = w + W[cur + 1], v + V[cur + 1]
        if nxtw >= M:
            heappush(h, (_v, nxtw, nxtv, cur + 1))
        _prov, ub = upperbound(w, v, cur)
        if _prov < prov:
            prov = _prov
        if ub < prov:
            heappush(h, (ub, w, v, cur + 1))
    return -prov


def main():
    N, M, *L = map(int, open(0).read().split())
    t = [(v, w, v / w) for w, v in zip(*[iter(L)] * 2)]
    t.sort(key=itemgetter(2), reverse=True)
    V, W, R = [], [], []
    for v, w, r in t:
        V += [-v]
        W += [-w]
        R += [r]
    ans = branchAndBound(N, -M, V, W, R)
    print(ans)
    
if __name__=="__main__":main()
//  [python]
N, W = map(int,input().split())
dp = [0]*-~W
for _ in [None]*N:
  w, v = map(int,input().split())
  for j in range(W, w-1, -1):
    dp[j] = max(dp[j], dp[j - w] + v)
print(max(dp))
//  [python]
N,W=list(map(int,input().split()))
item_list=[]
dp=[[0]*(W+1) for i in range(N+1)]

for i in range(1,N+1):
  w,v=list(map(int,input().split()))
  for j in range(1,W+1):
    if j - w >=0:
      dp[i][j]=max(dp[i-1][j],v+dp[i-1][j-w])
    else:
      dp[i][j]=dp[i-1][j]
  


  
  
print(dp[N][W])
//  [python]
n, w = map(int, input().split())
wv = [list(map(int, input().split())) for i in range(n)]

dp = [[0] * (w + 1) for i in range(n + 1)]

for i in range(n):
    for sum_w in range(w + 1):
        if sum_w - wv[i][0] >= 0:
            dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w - wv[i][0]] + wv[i][1])
        dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w])
print(dp[n][w])
//  [python]
n, w = map(int, input().split())
wv = [list(map(int, input().split())) for i in range(n)]

dp = [[0] * (w + 1) for i in range(n + 1)]

for i in range(n):
    for sum_w in range(w + 1):
        if sum_w - wv[i][0] >= 0:
            dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w - wv[i][0]] + wv[i][1])
        dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w])
print(max(dp[n]))
//  [java]
import java.util.*;
import java.io.*;

//atcoder need change class name to Main
//D - Knapsack 1
//stand dp <= Weight
//loop from right to left

//https://atcoder.jp/contests/dp/tasks/dp_c

public class Main {
    static StringTokenizer st;
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

 
    public static void main(String[] args) throws IOException {
  
        int N = nextInt(); 
        int W = nextInt(); 
        long[] dp = new long[W+1];
        dp[0] = 0;

        for (int i=1; i<=N;  i++) {
            int w = nextInt();
            int v = nextInt();
            
            for (int j=W; j>=w; j--) {
                dp[j] = Math.max(dp[j], dp[j-w] + v); 
            }
        }
 
        System.out.println(dp[W]);
    }
    

    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}