Problem:
Score : 300 points

Problem Statement

You are given a string S consisting of digits between 1 and 9, inclusive.
You can insert the letter + into some of the positions (possibly none) between two letters in this string.
Here, + must not occur consecutively after insertion.

All strings that can be obtained in this way can be evaluated as formulas.

Evaluate all possible formulas, and print the sum of the results.

Constraints

1 \leq |S| \leq 10

All letters in S are digits between 1 and 9, inclusive.

Input

The input is given from Standard Input in the following format:

S

Output

Print the sum of the evaluated value over all possible formulas.

Sample Input 1

125

Sample Output 1

176

There are 4 formulas that can be obtained: 125, 1+25, 12+5 and 1+2+5. When each formula is evaluated,

125

1+25=26

12+5=17

1+2+5=8

Thus, the sum is 125+26+17+8=176.

Sample Input 2

9999999999

Sample Output 2

12656242944

Solution in Rust (1.15.1) (judge verdict: Accepted)

// This code is generated by [cargo-atcoder](https://github.com/tanakh/cargo-atcoder)
// Original source code:
/*
use proconio::input;
use proconio::marker::Chars;

fn dfs(p: &mut Vec<bool>, n: usize, d: &Vec<u64>) -> u64 {
    if p.len() == n - 1 {
        let mut xs = vec![];
        xs.push(d[0]);
        for (&p_i, &d_i) in p.iter().zip(d.iter().skip(1)) {
            if p_i {
                xs.push(d_i);
            } else {
                let n_x = xs.len();
                let x = xs[n_x - 1];
                xs[n_x - 1] = x * 10 + d_i;
            }
        }
        return xs.iter().sum::<u64>();
    }
    let mut sum = 0;
    let b = vec![false, true];
    for &b_i in b.iter() {
        p.push(b_i);
        sum += dfs(p, n, d);
        p.pop();
    }
    sum
}

fn main() {
    input! {
        s: Chars
    };
    let d = s
        .iter()
        .map(|&c| c.to_digit(10).unwrap() as u64)
        .collect::<Vec<u64>>();
    let n = d.len();
    let ans = dfs(&mut vec![], n, &d);
    println!("{}", ans);
}
*/

fn main() {
    let exe = "/tmp/binD464D085";
    std::io::Write::write_all(&mut std::fs::File::create(exe).unwrap(), &decode(BIN)).unwrap();
    std::fs::set_permissions(exe, std::os::unix::fs::PermissionsExt::from_mode(0o755)).unwrap();
    std::process::exit(std::process::Command::new(exe).status().unwrap().code().unwrap())
}

fn decode(v: &str) -> Vec<u8> {
    let mut ret = vec![];
    let mut buf = 0;
    let mut tbl = vec![64; 256];
    for i in 0..64 { tbl[TBL[i] as usize] = i as u8; }
    for (i, c) in v.bytes().filter_map(|c| { let c = tbl[c as usize]; if c < 64 { Some(c) } else { None } }).enumerate() {
        match i % 4 {
            0 => buf = c << 2,
            1 => { ret.push(buf | c >> 4); buf = c << 4; }
            2 => { ret.push(buf | c >> 2); buf = c << 6; }
            3 => ret.push(buf | c),
            _ => unreachable!(),
        }
    }
    ret
}

const TBL: &'static [u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const BIN: &'static str = "<base64-encoded ELF executable removed>";