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: Wrong Answer)

#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#define rep(i,n) for(int i = 0;i<(int)(n);i++);
using namespace std;
using ll = long long;
const ll INF = 100100100100100;
ll keta(ll x) {
	ll sum = 0;
	while (x) {
		x /= 10;
		sum++;
	}
	return sum;
}
int main() {
	ll S;
	cin >> S;
	ll size = 0;
	ll ans = 0;
	ll now = 0;
	size = keta(S);
	vector<ll> num(size);//入力された数字を１つずつ配列に入れる
	for (int i = 0; i < size; i++) {
		num[size - 1 - i] = S % 10;
		S /= 10;
	}
	for (int i = 0; i < (1 << (size-1)); i++) {
		bitset<9> s(i);{//０の時は+は無し１の時は+とする
			for (int j = 0; j < size - 1; i++) {
				now += num[j];
				if (s.test(j)) {//１の場合
					ans += now;
					now = 0;
				}
				else {//0の場合
					now *= 10;
				}
			}
		}
	}
	cout << ans + now << endl;
}