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 (Python):
s = input()

import itertools
n = list(itertools.product([0,1], repeat=len(s)-1))

int_list = []
for x in n:
    start = 0
    end = 1
    for y in x:
        if y == 1:
            end+=1
        else:
            int_list.append(int(s[start:end]))
            start=end
            end+=1
    int_list.append(int(s[start:end]))
    
print(sum(int_list))

Solution (Python):
s = input()
length = len(s)
ns = list(map(int,s))
total_sum = 0
for mask in range(2 ** (length-1)):
  sum_ = 0
  num = ns[0]
  for i in range(1, length):
    if (mask & 1) > 0:
      sum_ += num
      num = ns[i]
    else:
      num = (num * 10 + ns[i])
    mask = mask >> 1
  total_sum += sum_ + num
print(total_sum)

Solution (Python):
S = input()
ans = 0
s = ""
for bit in range(2**(len(S)-1)):
    s = "".join(list(map(lambda i,x: x+"+" if ((bit>>i) & 1 and (i<len(S)-1)) else x, range(len(S)), S)))
    ans += eval(s)
print(ans)

Solution (Python):
S = input()
ret = 0
for i in range(2**(len(S)-1)):
    
    s = S
    bin_i = format(i, 'b')
    bin_i =bin_i[::-1]
    
    for j in range(len(bin_i)):
        
        
        
        if bin_i[j] == "1":
            
            
            s = s[:-len(S) + j + 1] + "+" + s[-len(S) + j + 1:]
    
    ret += eval(s)
print(ret)

Solution (Python):
S = input()

if len(S) == 1:
    print(int(S))
    exit()

ans = 0
pluses = [""]*(len(S)-1)
for i in range(2 ** (len(S) - 1)):
    for j in range(len(S)-1):
        if (i >> j) & 1:
            pluses[j] = "+"
        else:
            pluses[j] = ""  
    Ss = ""
    for k, p in zip(S[:-1], pluses):
        Ss += k + p
    Ss += S[-1]
    ans += eval(Ss)
print(ans)

Solution (Python):
S = input()
ret = 0
for i in range(2**(len(S)-1)):
    s = ""
    for j in range(len(S)):
        s += S[j]
        if (i >> j) & 1 and j < len(S)-1:
            s += "+"
    ret += eval(s)
print(ret)

Solution (Python):
s = input()
plus = ''
ans = 0
if len(s) == 1:
    print(s)
else:
    for i in range(2**(len(s)-1)):
        for j in range(len(s)):
            plus += s[j]
            if ((i >> j) & 1):
                ans += int(plus)
                plus = ''
            if j == len(s) - 1 and len(plus) != 0:
                ans += int(plus)
                plus = ''
    print(ans)

Solution (Python):
s = input()
plus = ''
ans = 0
if len(s) == 1:
    print(s)
else:
    for i in range(2**(len(s)-1)):
        for j in range(len(s)):
            plus += s[j]
            if ((i >> j) & 1):
                ans += int(plus)
                plus = ''
            if j == len(s) - 1 and len(plus) != 0:
                ans += int(plus)
                plus = ''
    print(ans)

Solution (Python):
S=list(map(int,list(input())))
def manyformulas(s):
    if len(s)==1:
        return s[0]
    return s[0]*2**(len(s)-2)+manyformulas(s[1:])+manyformulas([s[0]*10+s[1]]+s[2:])
print(manyformulas(S))

Solution (Python):
s = input()
n = len(s)
ans = 0
for i in range(2**(n-1)):
        tmp = s[0]
        for j in range(n-1):
            if (i>>j)&1:
                tmp += '+'+s[j+1]
            else:
                tmp += s[j+1]
        ans += eval(tmp)
print(ans)

Solution (Python):

S = input()

txts = [S[0]]
for i in range(1, len(S)):
    new_txts = []
    for t in txts:
        new_txts.append(t+S[i])
        new_txts.append(t+'+'+S[i])
    txts = new_txts

results = 0
for t in txts:
    numbers = list(map(int, t.split('+')))
    results += sum(numbers)
print(results)

Solution (Python):
def f(S, i):
    if i == len(S)-1:
        return S
    else:
        s = S[:i+1] + '+' + S[i+1:]
        return f(s, i+2) + '+' + f(S, i+1)

if __name__ == '__main__':
    S = input()
    print( eval(f(S, 0)) )

Solution (Python):
num_list = list(input())
ops_cnt = len(num_list)-1

g= 0

for i in range(2 ** ops_cnt):
    f = ""
    op_list = [""] * ops_cnt
    for j in range(ops_cnt):
      if ((i >> j) & 1):
        op_list[ops_cnt -1 - j] = "+"

    for num,op in zip(num_list,op_list + [""]):
      f += num + op
    g += eval(f)

print(g)

Solution (Python):
S = input()

   
ans = 0
for i in range(2 ** (len(S)-1)):
    oparr = []
    for j in range(len(S)-1):
        if (i >> j) & 1:
            oparr.insert(0,"+")
        else:
            oparr.insert(0,"")
    oparr.append("")
    tmp = ""
    for k in range(len(S)):
        tmp += S[k] + oparr[k]
    ans += eval(tmp)

print(ans)

Solution (Python):
S = input()

def d2n(d, n, p):
    x = '' 
    while d > 0:
        x = str(d % n) + x
        d = int(d / n)
    return x.zfill(p)

def compute(b):
    s = S[:]
    ptr = 1
    for i in range(len(S)-1):
        if b[i] == "1":
            s = s[:ptr] + "+" + s[ptr:]
            ptr += 1 
        ptr += 1
    return eval(s)

ans = 0

cnt = 0
while cnt < 2 ** (len(S) - 1):
    b = d2n(cnt, 2, len(S)-1)
    ans += compute(b)
    cnt += 1
print(ans)

Solution (Python):
S = input()

def func(s, split_list):

    l = len(s)
    if l == 0:
        result = 0
        for sl in split_list:
            result += int(sl)
        return result
    
    result = 0
    for i in range(1,l+1):
        result += func(s[i:], split_list[:]+[s[:i]])


    return result
        

result = func(S,[])
print(result)

Solution (Python):
s = input()
cnt = len(s) - 1
bitlist = []
sums = 0
for i  in range(2**cnt):
    op = [True] * cnt 
    for j in range(cnt):
        if ((i >> j) & 1):
            op[cnt - 1 - j] = False
    bitlist.append(op)
ans = []           
for i in range(2**cnt):
    now = 0
    for j in range(cnt):
        if bitlist[i][j]:
            ans.append(int(s[now:(j+1)]))
            now = j + 1
    ans.append(int(s[now:(cnt + 1)]))
    sums += sum(ans)
    ans=[]
print(sums)

Solution (Python):
s = input()
cnt = len(s) - 1
bitlist = []
sums = 0
for i  in range(2**cnt):
    op = [True] * cnt 
    for j in range(cnt):
        if ((i >> j) & 1):
            op[cnt - 1 - j] = False
    bitlist.append(op)
ans = []           
for i in range(2**cnt):
    now = 0
    for j in range(cnt):
        if bitlist[i][j]:
            ans.append(int(s[now:(j+1)]))
            now = j + 1
    ans.append(int(s[now:(cnt + 1)]))
    sums += sum(ans)
    ans=[]
print(sums)

Solution (Python):
from itertools import product
S = input()
ans = 0

for string in product(["","+"],repeat=len(S) - 1):
    string = list(string)
    string.append("")
    sum_ = [a + b for a,b in zip(S,string)]
    ans += eval("".join(sum_))

print(ans)

Solution (Python):


import sys
import itertools as it

sys.setrecursionlimit(2000)


def solve(s, i):
    
    if s == "":
        yield 0
    elif i == len(s):
        yield int(s)
    else:
        for x in solve(s[i:], 1):
            yield x + int(s[:i])
        yield from solve(s, i + 1)


S = input().strip()
res = sum(solve(S, 1))
print(res)

Solution (Python):
n = input()
op_cnt = len(n) - 1
ans = 0
for i in range(2 ** op_cnt):
    op = [""] * op_cnt
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"

    formula = ""
    for p_n, p_o in zip(n, op + [""]):
        formula += (p_n + p_o)
    ans += eval(formula)

print(ans)

Solution (Python):
from itertools import product


def main():
    S = input()

    ans = 0
    for op in product(["", "+"], repeat=len(S) - 1):
        op = list(op)
        op.append("")
        ans += eval(''.join(a + b for a, b in zip(S, op)))

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
from itertools import product
S = input()
ans = 0


for s in product(["", "+"], repeat=len(S) - 1):
  s = list(s)
  s.append("")
  ans += eval("".join(a+b for a,b in zip(S,s)))
 
print(ans)

Solution (Python):
S = input()
ans = 0
if len(S) == 1:
    ans += int(S)
for i in range(2**(len(S)-1)):
    binary =list(bin(i)[2:].zfill(len(S)-1))
    S_divide = []
    index = 0
    for j in range(len(S)-1):
        if binary[j] == "1":
            S_divide.append(S[index:j+1])
            index = j+1
        if j == len(S)-2:
            S_divide.append(S[index:])

    for k in range(len(S_divide)):
        ans += int(S_divide[k])
print(ans)

Solution (Python):
from itertools import product
S = input()
sm = 0

for s in product(["", "+"], repeat=len(S) - 1):
    s = list(s)
    s.append("")
    sm += eval("".join(a+b for a,b in zip(S,s)))
print(sm)

Solution (Python):


import copy

S = list(input())

ans_list = list()

for i in range(2**(len(S)-1)):
    tmp = copy.copy(S)
    for j in range(len(S)-1):
        if((i>>j)&1) == 1:
            tmp.insert(len(S)-j-1,'+')
    ans_list.append(tmp)
    
cnt = 0
for ans in ans_list:
    cnt += sum(map(int,(''.join(ans).split('+'))))
print(cnt)

Solution (Python):
import itertools

S = input()
N = len(S)

ans = 0

fs = []
for op in itertools.product(['','+'], repeat=N-1):
	op = list(op)
	op.append('')
	f = ''.join(a+b for a,b in zip(S,op))
	fs.append(f.split('+'))

for f in fs:
    sum_t = 0
    for t in f:
        sum_t += int(t)
    ans += sum_t

print(ans)

Solution (Python):
S = input()

n = len(S)
s = []
for c in S:
    s.append(c)

operator=[]    
for i in range(2**(n-1)):
    op = ['']*n
    for j in range(n-1):
        if (i>>j) & 1:
            op[n-1-1-j] = '+'

    operator.append(op)

F = []
for op in operator:
    f = "".join(a+b for a, b in zip(s,op))
    F.append(f.split('+'))

res = 0
for elem in F:
    sum_elem=0
    for i in elem:
        sum_elem+=int(i)
    res += sum_elem

print(res)

Solution (Python):
S = input()
N = len(S)
ans = 0
for i in range(1 << (N - 1)):
    tmp = 0
    for j in range(N):
        if i & 1 << j:
            tmp = tmp * 10 + int(S[j])
            ans += tmp
            tmp = 0
        else:
            tmp = tmp * 10 + int(S[j])

    ans += tmp

print(ans)

Solution (Python):
S = input()
n = len(S)
ans = 0
for i in range(2**(n-1)) :
    c = 0
    for j in range(n-1) :
        if (i>>j)&1 :
            ans += int(S[c:j+1])
            c = j + 1
    else :
        ans += int(S[c:])
print(ans)

Solution (Python):
import itertools
S = input()
s = ''
for c in S:
    s += c
    s += '+'
s = s[:-1]

result = eval(s)
memo = [s]
for i in range(len(S)):
    for ss in memo:
        cache = []
        for j in range(1,len(ss)):
            if ss[j] == '+':
                kouho = ss[:j] + ss[j+1:]
                if not kouho in memo:
                    result += eval(kouho)
                    cache.append(kouho)
        memo.extend(cache)

print(result)

Solution (Python):
S = input()
N = len(S)
ans = 0
for i in range(2 ** (N-1)):
    p = 0
    for j in range(N-1):
        if (i >> j) & 1:
            ans += int(S[p:j+1])
            p = j+1
    ans += int(S[p:])
print(ans)

Solution (Python):


S = input()
t = len(S)-1
ans = 0

for i in range(2**t):
    p = bin(i)[2:]
    p = "0"*(t-len(p))+p
    x = ""

    for j, k in enumerate(S):
        x += k
        if j != t and p[j] == "1":
            x += "+"
    
    ans += eval(x)
print(ans)

Solution (Python):
s = input()
space = len(s) - 1
ans = 0

for i in range(2 ** space):
    formula = s[0]
    for j in range(space):
        if (i >> j) & 1:
            formula += "+"
        formula += s[j + 1]
    ans += eval(formula)

print(ans)

Solution (Python):
S = list(map(int, input()))
s = 0
ta = 0
for i in range(2 ** (len(S) - 1)):
    t = 0
    for j in range(len(S) - 1):
        ta = S[j]
        if (i >> j) & 1:
            s += ta + t * 10
            t = 0
        else:
            t = t * 10 + ta
    s += t * 10 + S[len(S) - 1]
print(s)

Solution (Python):
def main():
    s = input()
    ops = [i for i in range(len(s) - 1)]

    powset = []
    for i in range(1 << len(ops)):
        powset.append([ops[j] for j in range(len(ops)) if ((i >> j) & 1) == 1])

    

    expressions = []
    for places in powset:
        f = ''
        for i, char in enumerate(s):
            if i in places:
                f += char + '+'
            else:
                f += char
        expressions.append(f)

    

    total = sum(map(eval, expressions))
    print(total)


main()

Solution (Python):
S = input()
ans = 0
for param in range(2**(len(S)-1)):
    tmp = ""
    for i in range(len(S)):
        tmp += S[i] + ["","+"][((param >> i) & 1) if i != len(S)-1 else 0]
    ans += eval(tmp)
print(ans)

Solution (Python):
from itertools import product

S = input()
ans = 0
for i in product(['+', ''], repeat=len(S)-1):
    ans += eval("".join([S[s] + i[s] for s in range(len(S)-1)] + [S[len(S)-1]]))
print(ans)

Solution (Python):
import itertools as itr
S = input().rstrip()

ans = 0
for param in range(2**(len(S)-1)):
	tmp = ""
	for i in range(len(S)):
		tmp += S[i]+ ["","+"][((param >> i)&1) if i != len(S)-1 else 0]
	ans += eval(tmp)

print(ans)

Solution (Python):
def sumS(s):
  L = []
  if len(s) == 1:
    L.append(s)
  else:
    for formula in sumS(s[1:]):
      L.append(s[0] + "+" + formula)
      L.append(s[0] + formula)
  return L

S = input()
result = 0
for formula in sumS(S):
  result += eval(formula)

print(result)

Solution (Python):
s = input()
n = len(s)
a=[0] 
sum = 0
if n == 1:
    print(s)
else:
    for i in range(2 ** (n-1)): 
        for j in range(n-1):
            if i >> j & 1: a.append(j+1) 
        else:
            a.append(n)
            for k in range(len(a)-1):
                sum += int(s[a[k]:a[k+1]])
            else:
                a = [0]
    else:
        print(sum)

Solution (Python):
import itertools

def calcsum(s, ary):
    converted = ''
    for i, d in enumerate(s):
        converted += d
        if i in ary:
            converted += '+'
    return eval(converted)


def sumup(s):
    count = 0
    for n in range(len(s)):
        for lst_index_pos in itertools.combinations(range(len(s) - 1), n):
            count += calcsum(s, lst_index_pos)

    return count


s = input()
print(sumup(s))

Solution (Python):
S=[int(i) for i in input()]
ans=0
for x in range(1<<len(S)-1):
    a=S[0]
    for n in range(len(S)-1):
        if x>>n & 1:
            ans+=a
            a=0
        a = a * 10 + S[n+1]
    ans += a
print(ans)

Solution (Python):
s=input()
ans=0

if len(s)==1:
  print(s)
  exit()

for i in range(2 ** (len(s)-1)):
  bin_i = bin(i)[2:].rjust(len(s)-1,"0")
  li=[]
  n=s[0]
  for ix,sign in enumerate(bin_i):
    if sign=="0":
      n+=s[ix+1]
    else:
      li.append(int(n))
      n=s[ix+1]
  li.append(int(n))
  ans+=sum(li)

print(ans)

Solution (Python):
s  = str(input())
n = len(s)-1
ans = 0
for i in range(2**n):
  op = ['']*n
  for j in range(n):
    if (i>>j) & 1:
      op[j] = '+'
  
  op = op + ['']
  formula = ''
  for s_, p_ in zip(list(s), op):
      formula += s_ + p_
  ans += eval(formula)
print(ans)

Solution (Python):

S = [int(i) for i in list(input())]

sum = 0
for i in range(2**(len(S)-1)):
  a = S[0]
  for j in range(len(S)-1):
    if (i >> j) & 1:
      sum += a
      a = 0
      
    a = a * 10 + S[j+1]
  sum += a
print(sum)

Solution (Python):
def dfs(i,sep,s,tot):
    n = len(s)
    i += 1

    
    if i == n:
        ans = 0
        if len(sep)>1:
            for j in range(len(sep)-1):
                ans += int(s[sep[j]:sep[j+1]])
        ans += int(s[sep[-1]:])
        return ans

    
    sep.append(i)
    tot += dfs(i,sep,s, 0)

    
    sep.pop()
    tot += dfs(i,sep,s, 0)

    return tot

s = input()
print(dfs(0,[0],s,0))

Solution (Python):
s = input()
len_s = len(s)
ans=0
def dfs(x,len_x,i=0):
        global ans
        if i < len_x:
                dfs(x,len_x,i=i+1)
                x=x[:i+1] + "+" + x[i+1:]
                dfs(x,len_x + 1,i=i+2)
                ans+=sum([int(k) for k in x.split("+")])
dfs(s,len_s-1)
print(ans+int(s))

Solution (Python):
ans=0
def dfs(x,len_x,i=0):
        global ans
        if i < len_x:
                dfs(x,len_x,i=i+1)
        if i < len_x:
                x=x[:i+1] + "+" + x[i+1:]
                dfs(x,len_x + 1,i=i+2)
                ans+=sum([int(k) for k in x.split("+")])
        
s = input()
dfs(s,len(s)-1)
print(ans+int(s))

Solution (Python):
ans=0
def dfs(x,len_x,i=0):
        global ans
        if i < len_x:
                dfs(x,len_x,i=i+1)
        if i < len_x:
                x=x[:i+1] + "+" + x[i+1:]
                dfs(x,len_x + 1,i=i+2)
                ans+=sum([int(k) for k in x.split("+")])
        if i == len_x:
                return sum([int(k) for k in x.split("+")])

        else:
                return 0
s = input()
dfs(s,len(s)-1)
print(ans+int(s))

Solution (Python):



S = input()
sl = list(S)
ans = 0
for i in range(1 << len(S)): 
    string = str(0)
    tmp = 0
    for j in range(len(S)):
        if ((i >> j) & 1) == 1: 
            tmp+=int(string)
            string = "0"
        else:
            string += str(S[j])
    tmp=tmp+int(string)
    ans+=tmp
print(ans)

Solution (Python):
s = list(input())

ans = 0
for i in range(1 << len(s) - 1):
  ans += eval(s[0] + "".join(("+" if i >> j & 1 else "") + x for j, x in enumerate(s[1:])))
print(ans)

Solution (Python):
S = raw_input()
n = 1
for i in range(0, len(S)-1):
	n = n * 2
lstlst = []
for i in range(0, n):
	lst = []
	m = i
	for j in range(0, len(S)-1):
		if m%2 == 1: lst.append(True)
		else: lst.append(False)
		m = m/2
	lstlst.append(lst)
sum = 0
for i in range(0, n):
	tmp = S[0]
	a = 0
	for j in range(0, len(S)-1):
		if lstlst[i][j]:
			a += int(tmp)
			tmp = S[j+1]
		else:
			tmp = tmp + S[j+1]
	sum += a + int(tmp)

print sum

Solution (Python):
S = list(input())
ans = 0

for state in range(1 << len(S)-1):
    ans += eval(S[0] + ''.join(('+' if state >> i & 1 else '') + x for i, x in enumerate(S[1:])))

print(ans)

Solution (Python):
S = [int(x) for x in list(input())]
ans = 0

for i in range(2**(len(S)-1)):
    dig = 0
    for j in range(len(S)-1):
        if int(i/(2**j)) % 2 == 0:
            dig += 1
        else:
            dig = 0
        ans += S[-j-2] * (10**dig)

ans += S[-1]*(2**(len(S)-1))
print(ans)

Solution (Python):
import numpy as np

S = str(input())
N = len(S) - 1

def honyaku(ini,n):
    ans = np.zeros(n)
    for i in range(n-1,-1,-1):
        ans[i] = ini % 2
        ini = ini // 2
    return ans

def sum_list(list_domain,list_S):
    tmp = list_S[0]
    ans = 0
    for i in range(len(list_domain)):
        if list_domain[i] == 0:
            tmp = tmp*10 + list_S[i+1]
        else:
            ans += tmp
            tmp = list_S[i+1]
    return tmp + ans

list_S = np.zeros(N+1)
for i in range(N+1):
    list_S[i] = int(S[i])
ans = 0    
for i in range(2**N):
    list_domain = honyaku(i,N)
    ans += sum_list(list_domain,list_S)
    
print(int(ans))

Solution (Python):
s = input()
ans = 0
memo = []
for i in range(1 << len(s) -1):
    tmp = s[0]
    for j in range(len(s)-1):
        if ((i >> j) & 1):
            tmp+="+"
        tmp += s[j+1]
    if tmp not in memo:
        ans+=eval(tmp)
        memo.append(tmp)
print(ans)

Solution (Python):
S = input()
addition = 0
for i in range(2 ** (len(S)-1)):
    a = ''.join([c + ('+' if j < len(S)-1 and (i & 2 ** j == 2 ** j) else '') for j, c in enumerate(S)])
    for k in a.split('+'):
        addition += int(k)
print(addition)

Solution (Python):
S = input()

ans = 0
memo = []
for i in range(1 << len(S)-1):
  tmp = S[0]
  for j in range(len(S)-1):
    if ((i >> j) & 1) == 1:
      tmp += "+"
    tmp += S[j+1]
  if tmp not in memo:
    ans += eval(tmp)
    memo.append(tmp)
print(ans)

Solution (Python):
import sys






"""Template"""


class IP:
    """
    入力を取得するクラス
    """

    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        
        
        
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def S(self, s, r=0, m=-1):
        """
        ソート関係行います。色々な設定あります。
        :param s: 元となるリスト
        :param r: reversするかどうか 0=False 1=True
        :param m: （2次元配列）何番目のインデックスのソートなのか
        :return: None
        """
        r = bool(r)
        if m == -1:
            s.sort(reverse=r)
        else:
            s.sort(reverse=r, key=lambda x: x[m])

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x // y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)

    def gcd(self, x, y):
        if y == 0:
            return x
        else:
            return self.gcd(y, x % y)


"""ここからメインコード"""


def main():
    
    r, e, p = range, enumerate, print
    ip = IP()
    id = Idea()
    mod = 10 ** 9 + 7

    """この下から書いてね"""
    s = str(ip.I())
    ans = 0
    for i in r(1 << len(s) - 1):
        output = 0
        res = 0
        for j in r(len(s) - 1):
            if (i >> j) & 1:
                output += int(s[res:j + 1])
                res = j + 1
        output += int(s[res:len(s)])
        ans += output
    p(ans)


main()

Solution (Python):


s = list(input())
n = len(s)
can = []

def dfs(i,left,sum):
    if i + 1 == n:
        sum += int("".join(s[left:]))
        can.append(sum)
        return
    dfs(i + 1,left,sum)
    dfs(i + 1,i + 1,sum + int("".join(s[left:i+1])))
    return

dfs(0,0,0)
print(sum(can))

Solution (Python):
S = input()

ans = 0

if len(S) == 1:
    ans = int(S)
else:
    for i in range(2 ** (len(S) - 1)):
        tmp = S[0]
        for j in range(0, len(S) - 1):
            if i >> j & 1 == 0:
                tmp += S[j + 1]
            else:
                ans += int(tmp)
                tmp = S[j + 1]
        ans += int(tmp)

print(ans)

Solution (Python):
S=input()
if len(S)==1:
    print(S)
else:
    bs=[bin(i)[2:].zfill(len(S)-1) for i in range(2**(len(S)-1))]
    operators=[['' if b[i]=='0' else '+' for i in range(len(S)-1)] for b in bs]
    formulas=[''.join([S[j]+operator[j] for j in range(len(S)-1)])+S[-1] for operator in operators]
    print(sum([eval(formula) for formula in formulas]))

Solution (Python):
import itertools

S = input()

total = 0
prev = 0
for p in itertools.product([False, True], repeat=len(S)-1):
    prev = 0
    for i in range(len(p)):
        if p[i]:
            total += int(S[prev:i+1])
            prev = i+1
    total += int(S[prev:])

if total == 0:
    total = int(S)
print(total)

Solution (Python):
s=input()
l=len(s)
ans=0
for i in range(1<<( l-1)):
    res=0
    tmp=int(s[0])
    for j in range(l-1):
        if ((i>>j) & 1) == 1:
            res+=tmp
            tmp=int(s[j+1])
        else:
            tmp=tmp*10+int(s[j+1])
    res+=tmp
    ans+=res
print(ans)

Solution (Python):
S = input()
ans = 0
for i in range(1<<(len(S)-1)):
    li = []
    last = 0
    for j in range(len(S)-1):
        if((i>>j & 1)==1):
            li+=[int(S[last:j+1])]
            last = j+1
    if(last!=len(S)):
        li+=[int(S[last:])]
    ans += sum(li)
print(ans)

Solution (Python):
def DepthFirst_search(S,pre) :
    global out
    
    
    if len(S) == 1 :
        for i in range(len(pre)) :
            if i == len(pre)-1 :
                out += pre[i]*10 + int(S[0]) + pre[i] + int(S[0])
            else :
                out += 2*pre[i]
        return False

    pre.append(int(S[0]))
    if DepthFirst_search(S[1:len(S):],pre) :
        return False
    pre.pop()
    if len(pre) != 0:
        pre.append(pre.pop()*10 + int(S[0]))
        if DepthFirst_search(S[1:len(S):],pre):
            return False

    return False

out = 0
pre = []
S = input()
if len(S) == 1:
    out = int(S[0])
else :
    DepthFirst_search(S,pre)

print(out)

Solution (Python):
S = input()
result = 0

for i in range(1 << (len(S)-1)):
	k = 0
	T = 0
	for j in range(len(S)):
		if ((i >> j) & 1) == 1:
			T += int(S[k:j+1])
			k = j+1
	T += int(S[k:len(S)])
	result += T
print(result)

Solution (Python):
S = list(str(input()))
s = [i for i in range(2*len(S)-1) if i % 2 == 1]
ans = 0
for i in range(1 << len(s)):
    L = [S[(i+1)//2] if i % 2 == 0 else "" for i in range(2*len(S)-1)]
    output = []
    for j in range(len(s)):
        if ((i >> j) & 1) == 1:
            output.append(s[j])
    for i in range(len(L)):
        if i in output:
            L[i] = "+"
    ans += eval("".join(L))
print(ans)

Solution (Python):
s=input()
a = s
isum=0
k=0
for i in range(2**(len(s)-1)):
    for j in range(len(s)-1):
        if ((i>>j) & 1):
            
            a = a[:j+k+1] + "+" + a[j+k+1:]
            k +=1
            
    k=0
    isum += sum(list(map(int, a.split("+"))))
    a=s
print(isum)

Solution (Python):
S = input()

ans = 0

for i in range(2**(len(S)-1)):
    p = [0]
    for j in range(len(S)-1):
        if (i>>j)&1:
            p.append(j+1)
    p.append(len(S))
    
    for l,r in zip(p[:-1],p[1:]):
        ans += int(S[l:r])
print(ans)

Solution (Python):
s = input()
n = 0
ans = 0
for n in range( 1 << len(s) -1):
    p = 0
    for i in range(len(s) - 1):
        if n & (1 << i):
            ans += int(s[p:i + 1])
            p = i + 1
    if p < len(s):
        ans += int(s[p:])
print(ans)

Solution (Python):

s = input() 
S = [_ for _ in s]
N = len(S)-1
ans_lis = []
pra_lis = []
calis = []
for x in range(2**N):
    lis = [''] * (N)
    for y in range(N):
        if((x >> y) & 1):
            lis[N-1-y] = "+"
    pra_lis.append(lis)
for z in pra_lis:
    z.append('')
    for x in range(len(S)):
        calis.append(S[x])
        calis.append(z[x])
 
    calis = []
    ans_lis.append(calis)
ans = 0
for l in ans_lis:
    ans_num = '0'
    for r in l:
        if r == '':
            pass
        elif r == '+':
            ans += int(ans_num)
         
            ans_num = '0'
        else:
            ans_num += r
        
    ans += int(ans_num)
print(ans + int(s))

Solution (Python):
S = input()

N = len(S)-1
sumsum = 0


for i in range(2**N):
    binary = bin(i)
    binary = binary[2:].zfill(N)
    
    tmps = S[0]
    for j in range(N):
        if binary[j] == '0':
            tmps = tmps + S[j+1] 
        else :
            sumsum += int(tmps)
            tmps = S[j+1]

    sumsum += int(tmps)

if N == 0:
    sumsum = int(S)

print(sumsum)

Solution (Python):
from itertools import product
S = input()
s_len = len(S)
output=0
l_plus=[]
for i in range(s_len-1):
    l_plus.append(S[i])
    l_plus.append("")
l_plus.append(S[s_len-1])
for l in product(["", '+'],repeat=s_len-1):
    for i in range(s_len-1):
        l_plus[2*i+1]=l[i]
    output+=eval("".join(l_plus))
print(output)

Solution (Python):

from itertools import product
s = list(input())
n = len(s)
x = []
for i in range(n-1):
    x.append(s[i])
    x.append("")
x.append(s[n-1])

res = 0
for l in product(["","+"],repeat=n-1):
    for i in range(n-1):
        x[2*i+1] = l[i]
    res += eval("".join(x))
print(res)

Solution (Python):
s=str(input())
slist=list(s)

cnt=len(s)-1
ans=0
for i in range(2**cnt):
    ln = [""]*cnt
    tlist=list(slist)
    for j in range(cnt):
        if ((i>>j)&1):
            ln[cnt-j-1]="+"
    for k in range(len(s)-1):
        tlist.insert(k*2+1,ln[k])
    ans+=sum(list(map(int,"".join(tlist).split("+"))))
print(ans)

Solution (Python):
from collections import deque
S=input()
queue=deque()
lst=[]
lst.append([0,0])
for i in range(0,len(S)):
    l=len(lst)
    for _ in range(l):
        x,y=lst.pop(0)
        lst.append([x,y*10+int(S[i])])
        lst.append([x+y*10+int(S[i]),0])
l=len(lst)
for _ in range(l):
    x,y=lst.pop(0)
    lst.append(x+y)
print(int(sum(lst)/2))

Solution (Python):
from collections import deque
S=input()
queue=deque()
lst=[]
lst.append([0,0])
for i in range(0,len(S)):
    l=len(lst)
    for _ in range(l):
        x,y=lst.pop(0)
        lst.append([x,y*10+int(S[i])])
        lst.append([x+y*10+int(S[i]),0])
l=len(lst)
for _ in range(l):
    x,y=lst.pop(0)
    lst.append(x+y)
print(int(sum(lst)/2))

Solution (Python):
s = input()
l = len(s)

total = [0] * (l + 1)
count = [1] * (l + 1)

for i in range(l - 1, -1, -1):
    total[i] = sum(int(s[i:j]) * count[j] + total[j] for j in range(i + 1, l + 1))
    count[i] = sum(count[j] for j in range(i + 1, l + 1))

print(total[0])

Solution (Python):
S = input()
len = len(S)
ans = 0

for i in range(1<<(len-1)):
    temp = [c for c in S]
    plus = 0
    for j in range(len-1):
        if ((i>>j) & 1) == 1:
            temp.insert(j+1+plus, '+')
            plus += 1
    ans += eval("".join(temp))

print(ans)