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

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

const (
	initialBufSize = 10000
	maxBufSize     = 100000000
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	return sc
}()

// Input string
func scanString() (s string) {
	sc.Scan()
	return sc.Text()
}

func main() {
	input := scanString()

	remSumArray := make([]int, 2019)
	remSumArray[0] = 1
	var num int
	digit := 1

	for i := len(input) - 1; i >= 0; i-- {
		num += int(input[i]-48) * digit
		digit *= 10
		digit %= 2019
		//fmt.Println(num, "\t", num%2019)
		remSumArray[num%2019]++
	}

	//fmt.Println(remSumArray)
	var result int
	for _, num := range remSumArray {
		result += num * (num - 1) / 2
	}

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

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

const (
	initialBufSize = 10000
	maxBufSize     = 100000000
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	return sc
}()

// var sc = bufio.NewScanner(os.Stdin)
// var buff []byte
//
// func init() {
// 	sc.Split(bufio.ScanWords)
// 	sc.Buffer(buff, 100000000)
// 	log.SetFlags(log.Lshortfile)
// }

func main() {
	input := nextString()
	remSumArray := make([]int, 2019)
	remSumArray[0] = 1
	var num int
	digit := 1
	for i := len(input) - 1; i >= 0; i-- {
		num += int(input[i]-48) * digit
		digit *= 10
		digit %= 2019
		remSumArray[num%2019]++
	}
	var result int
	for _, num := range remSumArray {
		result += num * (num - 1) / 2
	}
	fmt.Println(result)
}

func nextString() (s string) {
	sc.Scan()
	return sc.Text()
}

func nextFloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

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

func nextInts(n int) (r []int) {
	r = make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
)

// const (
// 	initialBufSize = 10000
// 	maxBufSize     = 100000000
// )
//
// var sc *bufio.Scanner = func() *bufio.Scanner {
// 	sc := bufio.NewScanner(os.Stdin)
// 	buf := make([]byte, initialBufSize)
// 	sc.Buffer(buf, maxBufSize)
// 	return sc
// }()

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func init() {
	sc.Buffer(buff, 100000000)
	log.SetFlags(log.Lshortfile)
}

func main() {
	input := nextString()
	remSumArray := make([]int, 2019)
	remSumArray[0] = 1
	var num int
	digit := 1
	for i := len(input) - 1; i >= 0; i-- {
		num += int(input[i]-48) * digit
		digit *= 10
		digit %= 2019
		remSumArray[num%2019]++
	}
	var result int
	for _, num := range remSumArray {
		result += num * (num - 1) / 2
	}
	fmt.Println(result)
}

func nextString() (s string) {
	sc.Scan()
	return sc.Text()
}
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func Reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func dfs(s string) int {
	ans := 0
	sl := len(s)

	mod := 2019
	s = Reverse(s)

	sum := 0
	cnt := make([]int, sl)

	cnt[0] = 0
	x := 1

	for i := 0; i < sl; i++ {
		cnt[sum]++
		a, _ := strconv.Atoi(string(s[i]))
		sum += (a * x)
		sum = sum % mod
		ans += cnt[sum]
		x = x * 10 % mod
	}
	return ans
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(nil, 1000000000000000)

	ss := nextString()

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

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func Reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func dfs(s string) int {
	ans := 0
	sl := len(s)

	mod := 2019
	s = Reverse(s)

	sum := 0
	cnt := make([]int, sl+1)
	hist := make(map[int]bool)

	cnt[0] = 0
	hist[0] = true

	for i := 1; i <= sl; i++ {
		a, _ := strconv.Atoi(string(s[i-1]))
		sum += (a * int(math.Pow10(i-1))) % mod
		cnt[i] = sum % mod
		if hist[cnt[i]] {
			ans++
		}
		hist[cnt[i]] = true
	}
	return ans
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(nil, 100000000)

	ss := nextString()

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

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func dfs(s string) int {
	ans := 0
	for i := 0; i < len(s); i++ {
		for j := i + 3; j <= len(s); j++ {
			// fmt.Println(s[i:j])
			num, _ := strconv.Atoi(s[i:j])
			if num%2019 == 0 {
				ans++
			}
		}
	}
	return ans
}

func main() {
	sc.Split(bufio.ScanWords)
	ss := nextString()

	fmt.Println(dfs(ss))
}
//  [ruby]
g=[a=0]*M=2019
gets.bytes{g[a%M]+=1;a+=_1%48*$.=$.*202%M}
p g.sum{_1*~-_1/2}
//  [ruby]
g=[a=0]*M=2019;g[0]=t=1;gets.chop.reverse.bytes{g[a=(a+_1%48*t=t*10%M)%M]+=1};p g.sum{_1*~-_1/2}
//  [ruby]
g=[x=a=-1]*M=2019
t = 1
gets.bytes do
  x-=g[a%M]+=1
  t = t*202%M
  a+=_1%48*t
end
p~x
//  [ruby]
S = gets.chomp

ans = 0
c = 0
mods = [0] * 2019
mods[0] = 1
S.chars.reverse.each_with_index do |s,i|
    c = (c + s.to_i * (10**i)) % 2019
    ans += mods[c]
    mods[c] += 1
end

p ans
//  [ruby]
S = gets.chomp

ans = 0
(0..S.size-4).each do |i|
    (i+1..S.size-1).each do |j|
        ans += 1 if S[i..j].to_i % 2019 == 0
    end
end

p ans
//  [ruby]
s = gets.to_i
s_length = s.to_s.length 

ans = 0

temp = 0
for i in 0..s_length-4 do
	for j in 4..s_length-i do
		temp = s.to_s.slice(i,j)
		if temp.to_i % 2019 == 0 then
			ans += 1
		end		
	end
end

puts ans
//  [rust]
use std::io::stdin;
// use std::collections::HashMap;

fn main() {
    let mut s: String = String::new();
    stdin().read_line(&mut s).ok();
    let s: Vec<char> = s.trim().chars().collect();

    let mut counts: Vec<usize> = vec![0; 2019];
    counts[0] += 1;

    // s $B$rA`:n$7$F$$$-!"(Bmod 2019 $B$r(B count $B$H$7$FJ]B8$7$F$$$/(B
    let mut base = 1;
    let mut temp_mod = 0;
    for &s_i in s.iter().rev() {
        temp_mod = (temp_mod + (s_i as usize - 48) * base) % 2019;
        base = (base * 10) % 2019;
        if s_i != '0' {
            counts[temp_mod] += 1;
        }
    }

    let mut res = 0;
    for counts_i in counts {
        if counts_i > 1 {
            res += counts_i * (counts_i - 1) / 2;
        }
    }
    println!("{}", res);
}


// fn main() {
//     let mut s: String = String::new();
//     stdin().read_line(&mut s).ok();
//     let s: Vec<char> = s.trim().chars().collect();
// 
//     // $B8e$m$+$iAv::$7$F$$$/(B
//     // $B3FCmL\?t$K$D$$$F!">jM>$r=P$7$F!"0l$D:8$N>jM>$rB-$7$F(B... $B$r7+$jJV$7$F$$$/(B
// 
//     let mut res = 0;
//     let mut dp_dict: HashMap<usize, usize> = HashMap::new();
//     for i_upper in 0..s.len() {
//         let mut temp_mod = 0;
//         let mut temp_dp_dict: HashMap<usize, usize> = HashMap::new();
//         for i_lower in i_upper..s.len() {
//             // println!("{}, {}", s[i_lower], s[i_lower] as usize);
//             temp_mod = (temp_mod * 10 + (s[i_lower] as usize - 48)) % 2019;
// 
//             // temp_mod = (temp_mod + (s[i_upper] as usize) * base);
// 
//             // let temp_str: String = s[i_upper..i_lower + 1].iter().collect();
//             // // println!("{}, {}", temp_str, temp_str.parse::<usize>().unwrap() % 2019);
//             // // temp_mod = (temp_mod + temp_str.parse::<usize>().unwrap() % 2019) % 2019;
//             // temp_mod = temp_str.parse::<usize>().unwrap() % 2019;
//             // // println!(" === {} === ", temp_mod);
// 
//             if temp_mod == 0 {
//                 if dp_dict.contains_key(&i_lower) {
//                     res += dp_dict.get(&i_lower).unwrap();
//                     for (k, v) in temp_dp_dict.iter_mut() {
//                         *v += 1;
//                     }
//                     break;
//                 }
//                 res += 1;
//                 temp_dp_dict.insert(i_lower, 0);
//                 for (k, v) in temp_dp_dict.iter_mut() {
//                     *v += 1;
//                 }
//             }
//         }
//         for (k, v) in temp_dp_dict.iter() {
//             dp_dict.insert(*k, *v);
//         }
//     }
// 
//     println!("{}", res);
// }
//  [rust]
use std::io::stdin;fn main(){let mut st = String::new();stdin().read_line(&mut st).unwrap();let s:Vec<char>=st.trim().chars().collect();let mut t=1;let mut c:usize=0;let mut r:[usize;2020]=[0;2020];let m=2019 as usize;for i in (0..s.len()).rev(){let x=(s[i] as usize)-48;c=(c+x*t)%m;r[c]+=1;t=(t*10)%m;};c=0;for i in 0..m{if &1<&r[i] {c+=(r[i]-1)*r[i]/2;}};c+=r[0];println!("{}",c)}
//  [rust]
use std::io::stdin;
fn main() {
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let s:Vec<char> = st.trim().chars().collect();
    let mut ten = 1;
    let mut c:usize = 0;
    let mut r:[i64;2020] = [0;2020];
    let m = s.len() as usize;
    for i in 1..m+1 {
        let x = (s[m-i] as usize)-48;
        c = (c+x*ten)%2019;
        r[c] += 1;
        ten = (ten*10)%2019;
    };
    let mut result:i64 = 0;
    for i in 0..2019 {
        if &1 < &r[i] {
            result += (r[i]-1)*r[i]/2
        };
    };
    result += r[0];
    println!("{}", result);
}
//  [rust]
// -*- coding:utf-8-unix -*-

#[macro_use]
extern crate lazy_static;
extern crate num_bigint;
// 0.2.2
extern crate num_traits;

// 0.2.8
use num_bigint::BigInt;
use num_bigint::ToBigInt;
use num_traits::{Pow, ToPrimitive};
use num_traits::{One, Zero};

// use proconio::derive_readable;
use itertools::*;
use itertools_num::*;
use proconio::fastout;
use proconio::input;
// use std::convert::TryInto;
// use ascii::Chars;
// use libm::*;
use proconio::marker::{Bytes, Chars};
use std::cmp::*;
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::*;
use std::ops::Range;
use std::str::FromStr;
use superslice::*;

use lazy_static::lazy_static;
use std::sync::Mutex;

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")
}

lazy_static! {
    // static ref PARENTS: Mutex<Vec<usize>> = Mutex::default();
    // static ref CHILDS: Mutex<Vec<Vec<usize>>> = Mutex::default();
    static ref ADJ: Mutex<Vec<Vec<usize>>> = Mutex::default();
}

// const MOD: usize = 9997063;
// const MOD: usize = 100_000_000_ + 7;

//abc164-D
// #[fastout]
fn main() {
    input![s: Chars];

    let mut is_2019 = vec![Vec::new(); 2019];
    for i in 0..s.len() {
        let s: String = s.iter().as_slice()[i..].iter().collect();
        let s = BigInt::from_str(&s).unwrap();
        // eprintln!("{}, {}", s, s % 2019);
        let modulo = (s % 2019.to_bigint().unwrap()).to_usize().unwrap();
        let last_e = *is_2019[modulo].last().unwrap_or(&0);
        is_2019[modulo].push(1 + last_e);
    }

    let last_e = *is_2019[0].last().unwrap_or(&0);
    is_2019[0].push(1 + last_e);


    // let mut is_2019_comsum = is_2019.iter().fold(
    //     vec![], |mut mid, a| {
    //         mid.push(
    //             mid.last().unwrap_or(&0) + if *a { 1 } else { 0 }
    //         );
    //         mid
    //     },
    // );
    let is_2019: Vec<_> = is_2019.iter().map(|mod_count| *mod_count.last().unwrap_or(&0)).collect();
    // eprintln!("{:?}", is_2019.iter().filter_map(|a| if *a > 0 {Some(*a)} else{None}).collect::<Vec<_>>());

    let mut ans = 0;
    for c in is_2019.iter(){
        ans += if *c <= 1 {0}else{
            c * (c - 1) / 2
        }
    }


    // eprintln!("{:?}", is_2019);

    // let num2019 = is_2019_comsum.last().unwrap();
    // let mut ans = 0;
    // for i in 0..is_2019_comsum.len(){
    //     ans +=  num2019 - is_2019_comsum[i]
    // };

    // eprintln!("{:?}", adj);
    println!("{}", ans);
}

// let mut values = VALUES.lock().unwrap();
// values.extend_from_slice(&[1, 2, 3, 4]);
// assert_eq!(&*values, &[1, 2, 3, 4]);

// -100000000

//  1000000000
//  [rust]
// -*- coding:utf-8-unix -*-

#[macro_use]
extern crate lazy_static;
extern crate num_bigint;
// 0.2.2
extern crate num_traits;

// 0.2.8
use num_bigint::BigInt;
use num_bigint::ToBigInt;
use num_traits::Pow;
use num_traits::{One, Zero};

// use proconio::derive_readable;
use itertools::*;
use itertools_num::*;
use proconio::fastout;
use proconio::input;
// use std::convert::TryInto;
// use ascii::Chars;
// use libm::*;
use proconio::marker::{Bytes, Chars};
use std::cmp::*;
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::*;
use std::ops::Range;
use std::str::FromStr;
use superslice::*;

use lazy_static::lazy_static;
use std::sync::Mutex;

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")
}

lazy_static! {
    // static ref PARENTS: Mutex<Vec<usize>> = Mutex::default();
    // static ref CHILDS: Mutex<Vec<Vec<usize>>> = Mutex::default();
    static ref ADJ: Mutex<Vec<Vec<usize>>> = Mutex::default();
}

// const MOD: usize = 9997063;
// const MOD: usize = 100_000_000_ + 7;

//abc164-D
// #[fastout]
fn main() {
    input![s: Chars];

    let mut is_2019 = vec![Vec::new(); 2019];
    for i in 0..s.len() {
        let s: String = s.iter().as_slice()[i..].iter().collect();
        let s = usize::from_str(&s).unwrap();
        // eprintln!("{}, {}", s, s % 2019);
        let last_e = *is_2019[s % 2019].last().unwrap_or(&0);
        is_2019[s % 2019].push(1 + last_e);
    }

    let last_e = *is_2019[0].last().unwrap_or(&0);
    is_2019[0].push(1 + last_e);


    // let mut is_2019_comsum = is_2019.iter().fold(
    //     vec![], |mut mid, a| {
    //         mid.push(
    //             mid.last().unwrap_or(&0) + if *a { 1 } else { 0 }
    //         );
    //         mid
    //     },
    // );
    let is_2019: Vec<_> = is_2019.iter().map(|mod_count| *mod_count.last().unwrap_or(&0)).collect();
    // eprintln!("{:?}", is_2019.iter().filter_map(|a| if *a > 0 {Some(*a)} else{None}).collect::<Vec<_>>());

    let mut ans = 0;
    for c in is_2019.iter(){
        ans += if *c <= 1 {0}else{
            c * (c - 1) / 2
        }
    }


    // eprintln!("{:?}", is_2019);

    // let num2019 = is_2019_comsum.last().unwrap();
    // let mut ans = 0;
    // for i in 0..is_2019_comsum.len(){
    //     ans +=  num2019 - is_2019_comsum[i]
    // };

    // eprintln!("{:?}", adj);
    println!("{}", ans);
}

// let mut values = VALUES.lock().unwrap();
// values.extend_from_slice(&[1, 2, 3, 4]);
// assert_eq!(&*values, &[1, 2, 3, 4]);

// -100000000

//  1000000000
//  [rust]
// 答えを見た
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

fn main() {
    input! {
        S: String,
    }

    // 2019 = 3 * 673
    // まずはNaive解を書いてみる
    // O(N^2) なので4*10^10 アウト
    // let mut ans = 0;
    // for i in 0..S.len() {
    //     for j in i + 1..S.len() {
    //         let s: &str = &S[i..j + 1];

    //         let num: i64 = s.parse().unwrap();
    //         if num % 2019 == 0 {
    //             ans += 1;
    //         }
    //     }
    // }

    // println!("{}", ans);

    // (i, j)が2019で割れるとはどういうことか
    // (i, N-1) % 2019 == (j+1, N-1) % 2019
    // ここで、「割り切れる」ではなくて「余りが同じ」という関係に持ち込んでいるのがポイント
    // 「割り切れる」だと当てはまるものが少ない。問題を分割したいのにサイズが小さくなっていない感じ

    let N = S.len();
    let mut Tmod2019s: Vec<i64> = Vec::with_capacity(N + 1);
    Tmod2019s.resize(N + 1, 0);

    let mut Rs: Vec<i64> = Vec::with_capacity(2019);
    Rs.resize(2019, 0);

    // 最初、「DPで~」ということが分かっていなかった。
    // |S|<=200000なので、Sは20万桁の数になりうる。
    // よって、Sそのものをparse()するとあふれてエラーになる。
    // そこで、剰余の性質を使って求めていく

    for i in (0..N).rev() {
        // これは収まらない
        // let s: &str = &S[i..N];
        // let num: i64 = s.parse().unwrap();

        // これもあふれる
        // Tmod2019s[i] = S[i..i+1] * 10^(N-i-1) + Tmod2019s[i+1];

        let mut num: i64 = (&S[i..i + 1]).parse().unwrap();
        for _ in 0..(N - i - 1) {
            num = (num * 10) % 2019;
        }

        num = (num + Tmod2019s[i + 1]) % 2019;
        Tmod2019s[i] = num;

        Rs[Tmod2019s[i] as usize] += 1;
    }

    // 2019の倍数であるような部分文字列は、引かなくてもそれ単体で2019の倍数
    // これを見逃していて、数時間困っていた。
    let mut ans = Rs[0];

    // ペアにして引いて2019の倍数を作る
    for i in 0..2019 {
        ans += Rs[i] * (Rs[i] - 1) / 2;
    }

    println!("{}", ans);
}
//  [swift]
import Foundation

func readInt() -> [Int] {
    return readLine()!.split(separator: " ").map { c in Int(c)! }
}

func main() {
    let S = readLine()!

    var x = 0
    var pow10 = 1
    var counts = Array(repeating: 0, count:2019)
    counts[0] = 1
    for c in S.reversed() {
        x += Int(String(c))! * pow10
        pow10 *= 10
        x %= 2019
        pow10 %= 2019
        counts[x] += 1
    }
    let ans = counts.reduce(0) {$0 + $1 * ($1 - 1) / 2}

    print(ans)
}


main()
//  [swift]
let mod = 2019

let S = readLine()!
var place = 1
var remainder = 0
var count = Array(repeating: 0, count: mod)
count[0] = 1
for char in S.reversed() {
    remainder += place * Int(String(char))!
    remainder %= mod
    count[remainder] += 1
    place = place * 10 % mod
}

var ans = 0
count.forEach({m in ans += m * (m - 1) / 2})
print(ans)
//  [swift]
extension Int {
    func pow(_ x: Int) -> Int {
        if x < 1 { fatalError() }
        var base = 1
        for _ in 1...x {
            base *= self
        }
        return base
    }
}

extension Collection where Element == Int {
    func createN() -> Int {
        self.reversed()
            .enumerated()
            .reduce(0) { $0 + $1.element.pow($1.offset) }
    }
}

let S = readLine()!.map { $0.wholeNumberValue! }

var r = 0
for i in S.indices {
    var s = S[i...]
    
    while let j = s.index(i, offsetBy: 5, limitedBy: s.endIndex) {
        let a = s.createN()
        let b = a % 2019
        if b == 0 { r += 1 }
        s.replaceSubrange(i..<j, with: String(b).map { $0.wholeNumberValue! })
    }
    
    if s != [0] && s.createN().isMultiple(of: 2019) {
        r += 1
    }
}

print(r)
//  [swift]
let S = readLine()!

var r = 0
for i in S.indices {
    var s = S[i...]
    
    while let j = s.index(i, offsetBy: 5, limitedBy: s.endIndex) {
        let a = Int(s[i..<j])!
        let b = a % 2019
        if b == 0 { r += 1 }
        s.replaceSubrange(i..<j, with: String(b))
    }
    
    if s != "0" && Int(s)!.isMultiple(of: 2019) {
        r += 1
    }
}

print(r)
//  [swift]
let S = readLine()!

var r = 0
for i in S.indices {
    var s = S[i...]
    
    let sum = s.reduce(0) { $0 + $1.wholeNumberValue! }
    if !sum.isMultiple(of: 3) {
        continue
    }
    
    while let j = s.index(i, offsetBy: 5, limitedBy: s.endIndex) {
        let a = Int(s[i..<j])!
        let b = a % 2019
        if b == 0 { r += 1 }
        s.replaceSubrange(i..<j, with: String(b))
    }
    
    if s != "0" && Int(s)!.isMultiple(of: 2019) {
        r += 1
    }
}

print(r)
//  [typescript]
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var s = next(1);
  var map = xArray(0,2020);
  var x = 0, ans = 0, k = 1;
  map[0] = 1;
  for(var i = s.length; i--;){
    x += +s[i] * k;
    x %= 2019;
    k = k*10%2019;
    ans += map[x]++;
  }
  return ans;
}
//  [typescript]
import { count } from 'console';

process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
let gInput = '';
process.stdin.on('data', (chunk) => (gInput += chunk));
process.stdin.on('end', () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {
  const s = inputs[0];
  const noList = new Set();
  const yesList = new Set();
  let count = 0;
  let left = 0;
  let right = 4;
  let num = Number(s.substring(0, 4));

  while (String(num).length >= 4) {
    if (num % 2019 == 0) {
      count++;
      left = right - 1;
      right += 4;
      num = Number(s.substring(left, right));
      continue;
    }
    right++;
    if (right > s.length) {
      left++;
      right = left + 4;
    }
    num = Number(s.substring(left, right));
  }

  console.log(count);
}
//  [typescript]
import { count } from 'console';

process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
let gInput = '';
process.stdin.on('data', (chunk) => (gInput += chunk));
process.stdin.on('end', () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {
  const s = inputs[0];
  const noList = new Set();
  const yesList = new Set();
  let count = 0;
  let left = 0;
  let right = 4;
  let num = Number(s.substring(0, 4));

  while (String(num).length >= 4) {
    if (num % 2019 == 0) {
      count++;
    }
    right++;
    if (right > s.length) {
      left++;
      right = left + 4;
    }
    num = Number(s.substring(left, right));
  }

  console.log(count);
}
//  [python]
A,B = map(int,input().split())
ans = 0
while 1:
    C = int(ans*0.08)
    D = int(ans*0.1)
    if C == A and D == B:
        print(ans)
        break
    if C > A or D > B:
        print(-1)
        break
    ans += 1
//  [python]
a, b = map(int, input().split())
for i in range(10, 1001):
    if int(i * 0.08) == a and int(i * 0.1) == b:
        print(i)
        exit()
print(-1)
//  [python]
import math
A, B = map(int, input().split())
max_price = math.ceil((A+0.99999)/0.08)
min_price = math.floor((B/0.1))
found = 0
for price in range(min_price, max_price+1):
  if math.floor(price*0.08) == A and math.floor(price*0.1) == B:
    print(price)
    found = 1
    break
if found == 0:
  print(-1)
//  [python]
a,b=map(int,input().split())

ans=-1
n = int(max(12.5*a,10*b))

if int(n*1.1)-b == int(n*1.08)-a:
    ans=n
    
print(ans)
//  [python]
a,b=map(int,input().split())
x1=a*100//8
x2=b*10
if x1//10==b:
    print(x1)
else:
    print(-1)
//  [python]
a,b=map(int,input().split())
x1=a*100//8
x2=b*10
 if x1//10==b:
    print(x1)
else:
    print(-1)
//  [java]
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		int a = ni(), b = ni();
		for(int i = 1; i <= 10000; i++) {
			if(i * 8 / 100 == a && i * 10 / 100 == b) {
				out.println(i);
				return;
			}
		}
		out.println(-1);
	}

	void run() throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if (!INPUT.isEmpty())
			tr(System.currentTimeMillis() - s + "ms");
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}
//  [java]
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		for (int ans = Math.min(a * 7, b * 9); ans < Math.max(a * 13, b * 11); ans++) {
			if ((int)(ans * 0.08) == a && (int)(ans * 0.1) == b) {
				System.out.println(ans);
				return;
			}
		}
		System.out.println(-1);

	}

}
//  [java]
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double tax_8 = sc.nextDouble();
		double tax_10 = sc.nextDouble();
		boolean lowTax8 = false;
		if(tax_8 * 2 < tax_10) {
			System.out.println("-1");
			System.exit(0);
		}
		if(tax_8 * 12.5 < tax_10 * 10)
		lowTax8 = true;
        if(lowTax8 && tax_8 * 12.5 / 10 <= (int)tax_10) {
			System.out.println((int)(tax_8 * 12.5));
		}else if(lowTax8){
			System.out.println((int)(tax_10 * 10));
		}
		if(!lowTax8 && tax_10 * 10 / 8 <= (int)tax_8) {
			System.out.println((int)(tax_10 * 10));
		}else if(!lowTax8){
			System.out.println((int)(tax_8 * 12.5));
		}
	}
}
//  [java]
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int A = scan.nextInt();
		int B = scan.nextInt();
		int f = 0;

		for (int price = B*10; price < (B+1)*10; price++) {
			if ((int)((double)price*0.08 + 0.05) == A) {
				System.out.println(price);
				f++;
				break;
			}
		}

		if (f == 0) {
			System.out.println(-1);
		}

	}

}
//  [cpp]
//
//  main.cpp
//  At
//
//  Created by 熊本和正 on 2020/03/07.
//  Copyright © 2020 kumamotone. All rights reserved.
//

#define ALL(obj) (obj).begin(), (obj).end()
 
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
 
using namespace std;
typedef long long ll;
const ll INF = 1e18;
 
ll A, B;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> A >> B;

    ll a = ceil(A * 12.5);
    ll adash = ceil((A+1)*12.5);
    ll b = B * 10;
    ll bdash = (B+1) * 10;

    if (a==b) {
        cout << b << endl;
    } else if(a>b) {
        if (bdash > a) {
            cout << a << endl;
        } else {
            cout << "-1" << endl;
        }
    } else if(a<b) {
        if (b < adash) {
            cout << b << endl;
        } else {
            cout << "-1" << endl;
        }
    }
    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(v1, v2)     cout << v1 << " " << v2 << endl
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << endl
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << endl

//----------------------------------------------------------------

int main(void) {
  int a, b;
  cin >> a >> b;

  double a_min, a_max, b_min, b_max;
  a_min = a/0.08;
  a_max = (a+1)/0.08;
  b_min = b/0.1;
  b_max = (b+1)/0.1;

  rep(i,1300){
    if(i>=a_min && i<a_max && i>=b_min && i<b_max){
      prt(i); return 0;
    }
  }

  prt(-1);
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

#define rep2(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) rep2(i,0,n)
#define all(a) a.begin(),a.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    
    int a, b;
    cin >> a >> b;
    rep(i, 100001) {
        if(i * 8 / 100 == a && i / 10 == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    

    return 0;
}
//  [cpp]
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;

int main(){
	int a, b;
	int ans=-1;
	cin >> a >> b;
	for (int i = 0; i < 10000000; i++) {
		if (i * 0.08 == a && i * 0.1 == b) {
			ans = i; break;
		}
	}
	cout << ans << endl;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 100000007;
using Graph = vector<vector<int>>;

int main(){
    int A,B;
    cin >> A >> B;
    A*=25;
    A/=2;
    if(A/10==B) cout << A << endl;
    else cout << -1 << endl;
}
//  [cpp]
// C - Tax increase
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(int)(n); i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main(){
    int a, b;
    cin >> a >> b;
    int num1 = a/0.08, num2 = b/0.1;
    int maxnum = max(num1, num2);
    int ans = maxnum; 
    bool ok = false;
    if(abs(num1-num2) < 10){
        for(int i=1; i<=maxnum; i++){
            int ad = i*0.08, bd=i*0.1;
            if(ad==bd && ad>0 && bd>0){
                ans = i;
                ok = true;
            }
        }
    }
    if(num1 == num2){
        ok = true;
        ans = num1;
    }
    if(ok) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}
//  [c]
#include<stdio.h>
int main(void)
{
  int a,b;
  scanf("%d %d",&a,&b);
  for(int i=a;i<=1010;i++){
    if((i*8)/100==a&&(i*10)/100==b){
      printf("%d\n",i);
      return 0;
    }
  }

  puts("-1");
  return 0;
}
//  [c]
#include <stdio.h>

int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=1;i<10000;i++){
		if(i*8/100==a&&i*10/100==b){
			printf("%d",i);
			return 0;
		}
	}
	puts("-1");
}
//  [c]
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main(void){
    int a,b,i,ans;
    scanf("%d %d",&a,&b);
    for(i=1; i<11000; i++){
        if(i*2/25==a && i/10==b){
            printf("%d",i);
            return 0;
        }
    }
    printf("-1");
    return 0;
}
//  [c]
#include <stdio.h>

int main(void){
  int a,b,i;
  scanf("%d %d",&a,&b);
  for(i=1;i<=2000;i++){
    if((0.08*i==a)&&(0.1*i==b)) break;
    if(i==2000) i=-1;
  }
  printf("%d\n",i);





  return 0;
}
//  [c]
#include <stdio.h>

int main(void){

    int a, b, i, a1, a2;
    
    scanf("%d%d",&a,&b);

    for(i=1;i<=1000;i++){

        a1 = i * 8 / 100;
        a2 = i * 10 / 100;

        if(a1 == a && a2 == b){
            printf("%d",i);
            return 0;
        }
    }

    printf("-1");
    return -1;
}
//  [javascript]
'use strict'

function main(inp) {
  inp = inp.trim().split(' ')
  const A = Number(inp[0])
  const B = Number(inp[1])

  const t8 = Math.ceil(A / 0.08)
  const t10 = Math.ceil(B / 0.1)

  for (let i = Math.min(t8, t10); i <= Math.max(t8, t10); i++) {
    if (Math.floor(i * 0.08) === A && Math.floor(i * 0.1) === B) {
      return console.log(i)
    }
  }
  console.log(-1)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function Main(input){
	var A = parseInt(input.trim().split(" ")[0],10);
  	var B = parseInt(input.trim().split(" ")[1],10);
  	var min = 0;
 	var MAX = 1000;
  	var res = [];
  	for(var i = 1;i<=MAX;i++){
      	var x1 = Math.floor(i*0.08);
      	var x2 = Math.floor(i*0.1);
    	if(x1 == A && x2 == B)res.push(i);
    }
  	if(res.length == 0){
    	console.log(-1);
    }else{
    	console.log(Math.min(...res));
    }
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));
//  [javascript]
function Main(input) {
  "use strict"
  const temp = input.split("\n")[0].split(" ");

  const a = parseInt(temp.shift());
  const b = parseInt(temp.shift());

  const a_min = Math.ceil(a * 12.5)
  const a_max = Math.ceil(a * 12.5 + 11.5)
  const b_min = Math.ceil(b * 10)
  const b_max = Math.ceil(b * 10 + 9)
  
  if(a_max < b_min || b_max < a_min) console.log(-1)
  else console.log(Math.max(a_min, b_min))
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
const input = require("fs").readFileSync("/dev/stdin", "utf8")
const lines = input.split('\n')
const [A, B] = lines[0].split(' ').map(Number)

const a = A / 0.08
const b = B / 0.1

let ans = null
if (a < b && Math.floor(b * 0.08) === A) {
    ans = b
} else if (a > b && Math.floor(a * 0.1) === B) {
    ans = a
} else if (a === b) {
    ans = a
} else {
    ans = -1
}
console.log(ans)
//  [javascript]
function *main() {
  
  const [A, B] = (yield).split(" ").map(s => +s);
  
  // floor(X/25) = A/2 => A*25/2 <= X <= A*25/2+24
  // floor(X/10) = A => A*10 <= X <= A*10+9
  const l1 = (A%2) ? Math.floor(A/2)*25+13 : Math.floor(A/2)*25, r1 = l1+24;
  const l2 = 10*B, r2 = l2+9;
  
  if (r1 < l2 || r2 < l1) {
    console.log(-1);
  } else {
    console.log(Math.max(l1, l2));
  }
  
}

const iter = main();
iter.next();
require("readline").createInterface({input: process.stdin}).on("line", s => iter.next(s));
//  [javascript]
function *main() {
  
  const [A, B] = (yield).split(" ").map(s => +s);
  
  // floor(X/25) = A/2 => A*25/2 <= X <= A*25/2+24
  // floor(X/10) = A => A*10 <= X <= A*10+9
  const l1 = Math.ceil(12.5*A), r1 = l1+24;
  const l2 = Math.ceil(10*B), r2 = l2+9;
  
  if (r1 < l2 || r2 < l1) {
    console.log(-1);
  } else {
    console.log(Math.max(l1, l2));
  }
  
}

const iter = main();
iter.next();
require("readline").createInterface({input: process.stdin}).on("line", s => iter.next(s));
//  [go]
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	result := -1
	for i:=1; i<=1009; i++{
		if int(float64(i) * 0.08) == a && int(float64(i) * 0.1) == b{
			result = i
			break
		}
	}

	fmt.Println(result)
}
//  [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 main() {
	a, b := nextInt(), nextInt()

	for x := 1; x < 1500; x++ {
		if int(float64(x)*0.08) == a && int(float64(x)*0.1) == b {
			fmt.Println(x)
			return
		}
	}
	fmt.Println(-1)
}
//  [go]
package main

import (
	"fmt"
)

// go run ./main.go < in

type NibunData struct {
	target int
	left   int
	mid    int
	right  int
}

var nubunData NibunData

var a, b int

func main() {
	fmt.Scan(&a, &b)

	num8 := 0
	var stack []int
	for i := 0; i < 1265; i++ {
		num8 = about8(i)
		if num8 != 0 {
			stack = append(stack, num8)
		}
	}

	num10 := 0
	for _, v := range stack {
		num10 = about10(v)
		if num10 != 0 {
			break
		}
	}

	if num10 == 0 {
		fmt.Println("-1")
	} else {
		fmt.Println(num10)
	}
}

func about8(price int) int {
	if price*8 >= a*100 && price*8 < (a+1)*100 {
		return price
	}
	return 0
}

func about10(price int) int {
	if price*10 >= b*100 && price*10 < (b+1)*100 {
		return price
	}
	return 0
}
//  [go]
package main

import (
	"fmt"
	"math"
)

func main() {
	// Code for C - Tax Increase
	var A, B float64
	fmt.Scanf("%f %f", &A, &B)

	var flag int
	for i := 0; i < 1000; i++ {
		if math.Floor(float64(i)*0.08) == A && math.Floor(float64(i)*0.1) == B {
			fmt.Println(i)
			flag = 1
			break
		}
	}

	if flag == 0 {
		fmt.Println("-1")
	}
}
//  [go]
package main

import "fmt"

func main() {
	var A, B int
	fmt.Scan(&A, &B)
	min := Max((100*A+7)/8, (100*B+9)/10)
	max := Min((100*A+100)/8, (100*B+100)/10)
	if min <= max {
		fmt.Println(min)
	} else {
		fmt.Println(-1)
	}
}

func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func Max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
//  [go]
package main

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

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	a, b := io.NextInt(), io.NextInt()
	max := 100
	lb := sort.Search(max+1, func(i int) bool { return i*8/100 >= a })
	ub := sort.Search(max+1, func(i int) bool { return i*8/100 > a })
	for i := lb; i < ub; i++ {
		if i*10/100 == b {
			io.Println(i)
			return
		}
	}
	io.Println(-1)
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}
//  [ruby]
a,b = gets.split(' ').map(&:to_i)
ans = -1
(0..1009).each do |i|
    if (i*0.08).floor == a && (i*0.1).floor == b
        ans = i 
        puts ans 
        exit
    end
end
puts ans
//  [ruby]
# n = gets.split.map(&:to_i)
# array = readlines.map(&:chomp!).map { |e| e.split.map(&:to_i) }
#
#

a,b = gets.split.map(&:to_i)

res = -1
1000.times do |i|
  if (0.08*(i+1)).floor == a && (0.1*(i+1)).floor == b
    res = i+1
    break;
  end
end

puts res
//  [ruby]
a, b = gets.split.map(&:to_i)
a1 = (a * 12.5).ceil.to_i
a2 = ((a + 1) * 12.5).to_i
b1 = b * 10
b2 = (b + 1) * 10
r = -1
(a1...a2).each do |i|
  if (b1...b2).include?(i)
    r = i
    break
  end
end
puts r
//  [ruby]
eval"p (1..1e5).find{_1*2/25==%d&&_2/10==%d}||-1"%gets.split
//  [ruby]
a,b = gets.chomp.split(' ').map(&:to_i)
a_l = (a / 0.08).to_r
a_r = ((a + 1) / 0.08).to_r
b_l = (b / 0.1).to_r
b_r = ((b + 1) / 0.1).to_r
if a_r.round - a_r == 0
  a_r -= 0.1
end
if b_r.round - b_r == 0
  b_r -= (1/10).to_r
end
ans = ((a_l.ceil..a_r.round).to_a & (b_l.ceil..b_r.round).to_a).min
if ans
  puts ans
else
  puts -1
end
//  [ruby]
a,b = gets.chomp.split(' ').map(&:to_i)
a_l = a / 0.08
a_r = (a + 1) / 0.08
b_l = b / 0.1
b_r = (b + 1) / 0.1
if a_r.round - a_r == 0
  a_r -= 0.1
end
if b_r.round - b_r == 0
  b_r -= 0.1
end
ans = ((a_l.ceil..a_r.round).to_a & (b_l.ceil..b_r.round).to_a).min
if ans
  puts ans
else
  puts -1
end
//  [rust]
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        a: u32,
        b: u32
    }
    for x in 1..1001 {
        if x *  8 / 100 == a &&
           x * 10 / 100 == b {
            println!("{}", x);
            return;
        }
    }
    println!("-1");
}
/* vim:set foldmethod=marker: */
//  [rust]
#![allow(unused_imports)]

use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::ops::*;
use std::process::exit;
use std::str::FromStr;

fn main() {
    let (a, b): (f64, f64) = input_two();
    for i in 1..10005 {
        if (i as f64 * 0.08).floor() == a && (i as f64 * 0.10).floor() == b {
            println!("{}", i);
            break;
        }
        if i == 10004 {
            println!("-1");
        }
    }

}



pub fn input<T: FromStr>() -> T {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

pub fn input_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>()
}

pub fn input_lines<T: FromStr>(l: usize) -> Vec<T> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input());
    }
    res
}

pub fn input_lines_two<T: FromStr, U: FromStr>(l: usize) -> Vec<(T, U)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_two());
    }
    res
}

pub fn input_lines_three<T: FromStr, U: FromStr, V: FromStr>(l: usize) -> Vec<(T, U, V)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_three());
    }
    res
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}
//  [rust]
use std::process::exit;

fn main() {
  let input: Vec<u32> = read_vec();
  for i in 1..101 {
    if i*8/100 == input[0] && i*10/100  == input[1] {
      println!("{}", i);
      exit(0);
    }
  }
  println!("-1");
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}
//  [rust]
use whiteread::parse_line;

fn main() {
    let (a, b): (f64, f64) = parse_line().unwrap();
    let p1 = a / 0.08;
    let p2 = b / 0.1;

    let mut p = p1.min(p2).floor();
    while (p * 0.08).floor() == a || (p * 0.1).floor() == b {
        if (p * 0.08).floor() == a && (p * 0.1).floor() == b {
            println!("{}", p.round() as u32);
            return;
        }
        p += 1.0;
    }
    println!("-1");
}
//  [rust]
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        a: i32, b: i32,
    }

    let min = (b as f64 / 0.10).floor() as i32;
    let max = (a as f64 / 0.08).ceil() as i32;

    if min > max {
        println!("-1");
    } else {
        for i in min..=max {
            if (i as f64 * 0.08) as i32 == a && (i as f64 * 0.10) as i32 == b {
                println!("{}", i);
                return;
            }
        }
        println!("-1");
    }
}
//  [swift]
let l = readLine()!.split(separator:" ").map{Int($0)!}
var ans:Int?
for x in 10*l[1]..<10*(l[1]+1) {
  if x*2/25 == l[0] {
    ans = x
    break
  }
}
print(ans ?? -1)
//  [swift]
import Foundation

func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let ab = readInts()
    let (a,b) = (ab[0],ab[1])
    var cost = a * 10
    
    for _ in cost...10000 {
        if cost * 8 / 100 == a && cost * 10 / 100 == b {
            print(cost)
            return
        }
        cost += 1
    }
    print(-1)
}
main()
//  [swift]
import Foundation

func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let ab = [68, 85]//readInts()
    let (a,b) = (ab[0],ab[1])
    var cost = a * 10
    
    for _ in cost...10000 {
        if cost * 8 / 100 == a && cost * 10 / 100 == b {
            print(cost)
            return
        }
        cost += 1
    }
    print(-1)
}
main()