// use std::ops::{Index, IndexMut}; // use std::cmp::{Ordering, min, max}; // use std::collections::{BinaryHeap, BTreeMap}; // use std::collections::btree_map::Entry::{Occupied, Vacant}; // use std::clone::Clone; fn getline() -> String{ let mut res = String::new(); std::io::stdin().read_line(&mut res).ok(); res } macro_rules! split { ($x: expr) => { ($x).trim().split(' ').collect() } } macro_rules! parse { ($x: expr) => { ($x).parse().unwrap() } } macro_rules! readl { ($t: ty) => { { let s = getline(); let iv: Vec<_> = split!(s); let mut iter = iv.into_iter(); iter.next().unwrap().parse::<$t>().unwrap() } }; ($( $t: ty),+ ) => { { let s = getline(); let iv: Vec<_> = split!(s); let mut iter = iv.into_iter(); ($(iter.next().unwrap().parse::<$t>().unwrap(),)*) } }; } macro_rules! rvec { ($x: expr) => { ($x).into_iter().map(|x| parse!(x)).collect() } } macro_rules! readlvec { ($t: ty) => { { let s = getline(); let iv: Vec<_> = split!(s); iv.into_iter().map(|x| x.parse().unwrap()).collect::>() } } } macro_rules! debug { ($x: expr) => { println!("{}: {}", stringify!($x), $x) } } fn printvec(v: &Vec) where T: std::fmt::Display { for (i,e) in v.into_iter().enumerate() { if i != 0 { print!(" "); } print!("{}", e); } println!(""); } macro_rules! make_modint { ($MOD: expr, $name: ident) => { struct $name { val: i64, } impl $name { fn new(x: i64) -> $name { let x = x%$MOD; $name{val: if x < 0 { x+$MOD } else { x }} } fn pow(&self, x: i64) -> $name { let mut res = $name::new(1); let mut tmp = x; let mut p = *self; while tmp != 0 { if tmp&1 == 1 { res *= p; } tmp = tmp>>1; p = p*p; } res } fn inv(&self) -> $name { assert!(self.val != 0); let mut a = self.val; let mut b = $MOD; let mut u = 1; let mut v = 0; use std::mem::swap; while b != 0 { let t = a/b; a -= t*b; swap(&mut a, &mut b); u -= t*v; swap(&mut u, &mut v); } $name::new(u) } } impl std::clone::Clone for $name { fn clone(&self) -> $name { $name{ val: self.val } } } impl std::marker::Copy for $name { } impl std::ops::Add for $name { type Output = $name; fn add(self, y: $name) -> $name { let tmp = self.val+y.val; $name{val: if tmp >= $MOD {tmp-$MOD} else {tmp}} } } impl std::ops::Sub for $name { type Output = $name; fn sub(self, other: $name) -> $name{ let tmp = self.val-other.val; $name{val: if tmp < 0 {tmp+$MOD} else {tmp}} } } impl std::ops::Mul for $name { type Output = $name; fn mul(self, y: $name) -> $name { $name{val: (self.val*y.val)%$MOD} } } impl std::ops::Div for $name { type Output = $name; fn div(self, other: $name) -> $name { self*other.inv() } } impl std::fmt::Display for $name { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{}", self.val) } } impl std::ops::AddAssign for $name { fn add_assign(&mut self, other: $name) { *self = *self+other; } } impl std::ops::SubAssign for $name { fn sub_assign(&mut self, other: $name) { *self = *self-other; } } impl std::ops::MulAssign for $name { fn mul_assign(&mut self, other: $name) { *self = *self*other; } } impl std::ops::DivAssign for $name { fn div_assign(&mut self, other: $name) { *self = *self*other.inv(); } } } } make_modint!(1000000007, ModInt); make_modint!(1000000000, ModInt2); macro_rules! solve { ($bv: expr, $ModInt: ident) => {{ let n = $bv.len(); let mut dp = $ModInt::new(0); for i in 0..(n+1)/2 { let num = $bv[i] - '0' as u8; if i == 0 { dp = $ModInt::new(num as i64-1) + dp*$ModInt::new(10); } else { dp = $ModInt::new(num as i64) + dp*$ModInt::new(10); } } let add = $ModInt::new(10).pow((n as i64)/2) + $ModInt::new(10).pow((n as i64-1)/2) - $ModInt::new(2); let mut f = 1; for i in 0..n/2 { let r = (n+1)/2+i; let l = n/2-1-i; if $bv[r] > $bv[l] { f = 1; break; } else if $bv[r] < $bv[l] { f = 0; break; } } dp + add + $ModInt::new(f) }} } fn main() { let s = readl!(String); let bv = s.into_bytes(); let ans1 = solve!(bv, ModInt); let ans2 = solve!(bv, ModInt2); println!("{}", ans2); println!("{}", ans1); }