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 C++14 (GCC 5.4.1) (judge verdict: Accepted)

//
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define MOD 1000000007
#define PI 3.14159265
#define EPS 1e-9
#define Pi acos(-1.0)
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;

/*CODE START HERE*/

string s;
ll ans;

void f(int i,string aux, ll total){
    ///cout << "NOW ON " << i << " AUX " << aux << " TOTAL " << total << "\n";
    if(i == (int)s.size()){
        //cout << "SUM " <<  total+(aux.size() > 0 ? stoll(aux) : 0) << "\n";
        ans += total+(aux.size() > 0 ? stoll(aux) : 0);
        return;
    }

    aux.push_back(s[i]);
    f(i+1,aux,total);
    aux.pop_back();
    ll temp = total+(aux.size() > 0 ? stoll(aux) : 0);
    aux.clear();
    aux.push_back(s[i]);
    f(i+1,aux,temp);
}

int main(){
    ios::sync_with_stdio(0);
    cin >> s;
    ans = 0;
    string aux = "";
    aux.push_back(s[0]);
    f(1,aux,0);
    cout << ans << "\n";
    return 0;
}