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 sys

n = len(s) - 1
if n == 0:
    print(int(s))
    sys.exit()

sums = 0
for i in range(2**n):
    bit = bin(i)[2:]
    if len(bit) <= n:
        bit = '0'*(n-len(bit)) + bit

    if bit.count('1') == 0:
        sums += int(s)
    elif bit.count('1') == 1:
        pos = bit.index('1')
        sums += int(s[:pos+1]) + int(s[pos+1:])
    else:
        num = bit.count('1')
        count = 0
        string = ''
        pos = 0
        for j,k in enumerate(bit):

            if k == '1' and count == 0:
               string += s[:j+1] + '+'
               count += 1
               pos = j
            elif k == '1':
                string += s[pos+1:j+1] + '+'
                pos = j
                count += 1
            if k == '1' and count == num:
                string += s[j + 1:]

        sums += sum([int(x) for x in string.split('+')])

print(sums)

Solution (Python):
s = input()
n = len(s) - 1
cnt = 0
for bit in range(1 << n):
    j = 0
    tmp = s[0]
    for i, v in enumerate(s[1:]):
        if bit & (1 << i):
            cnt += int(tmp)
            tmp = v
        else:
            tmp += v
    cnt += int(tmp)
print(cnt)

Solution (Python):
s = input()
n = len(s) - 1
cnt = 0
for bit in range(1 << n):
    j = 0
    for i, v in enumerate(bin(bit)[2:][::-1]):
        if v == "1":
            cnt += int(s[j:i + 1])
            j = i + 1
    cnt += int(s[j:])
print(cnt)

Solution (Python):
import itertools
s = input()
n = len(s)
ans = 0
for b in itertools.product([0, 1], repeat=n-1):
    array = [s[0]]
    for i, c in enumerate(s[1:]):
        array.append(b[i] * "+")
        array.append(c)
    ans += sum(map(int, "".join(array).split("+")))
print(ans)

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

result=0

for i in range(2**(n-1)):
    
    ll=0
    for j in range(n-1):
        if ((i>>j) & 1):
            
            result+=int(s[ll:j+1])
            ll=j+1
    result+=int(s[ll:])
print(result)

Solution (Python):
s = list(input())
n = len(s)-1
def bfs(i,formula):
  if i == n:
    return sum(list(map(int,formula.split("+"))))
  return bfs(i+1,formula + "+" + s[i+1])+bfs(i+1,formula + s[i+1])
print(bfs(0,s[0]))

Solution (Python):

a = input()


def bubun(inp):
    result = []

    def saiki(bb, index, buf):
        if len(bb) == index:
            if len(bb) == 0:
                result.append(buf)
        else:
            saiki(bb, index + 1, buf)
            buf += int(bb[:index+1])
            bb = bb[index+1:]
            saiki(bb, 0, buf)
    saiki(inp, 0, 0)
    return sum(result)


print(bubun(a))

Solution (Python):
from functools import reduce
from operator import add

S = input()
N = len(S)


def dfs(i, a):
    if i == N:
        return reduce(add, map(int, a.split("+")))

    if i == 0:
        return dfs(i + 1, S[i])

    return dfs(i + 1, a + S[i]) + dfs(i + 1, a + "+" + S[i])


print(dfs(0, ""))

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

for i in range(2**(len(S)-1)):
    op_list = ["+"]*(len(S)-1)

    for j in range(len(S)-1):
        if (i>>j)&1:
            op_list[j]=""

    s = ""

    for k in range(len(S)-1):
        s = s + S[k]+op_list[k]

    s = s + S[len(S)-1]

    sum = sum + eval(s)

print(sum)

Solution (Python):
S = input()
num = len(S) - 1 

all_value = 0
for i in range(2 ** num):
    op = [''] * num
    for j in range(num):
        if((i >> j) & 1):
            op[num - 1 - j] = "+"


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

    all_value += eval(formula)

print(all_value)

Solution (Python):
from itertools import product
s = list(input())
n = len(s)
pattern = []
answer = 0

pattern = list(product(['+', ''], repeat=n-1))

for i in range(2 ** (n-1)):
    formula = s[0]
    for j, k in zip(pattern[i], s[1:]):
        formula += (j + k)
    answer += eval(formula)

print(answer)

Solution (Python):
S = list(input())
N = len(S) -1 
all_formula = []
result = 0


for i in range(2**N):
    temp = S
    for j in range(N):
        all_formula.append(S[j])
        if i & 2**j:
            all_formula.append("+")
    all_formula.append(S[-1])
    all_formula.append("+")

all_formula.pop(-1)
all_formula = ''.join(all_formula)
result = eval(all_formula)

print(result)

Solution (Python):
S = input()
ans=0
for i in range(1<<len(S)-1):
    f =S[0]
    for j in range(len(S)-1):
        if i &(1<<j):
            f +="+"
        f +=S[j+1]
    ans += sum(map(int, f.split("+")))
print(ans)

Solution (Python):
S = [i for i in list(input())]
N = len(S)-1

res = 0
for bit in range(2**N):
    f = []
    for i in range(N):
        f.append(S[i])
        if bit & (2**i): f.append('+')
        else: f.append('')
    f.append(S[-1])
    f = ''.join(f)
    res += eval(f)

print(res)

Solution (Python):
ss = input()
n = len(ss)
result = 0
for i in range(1<<(n-1)):
    f = ss[0]
    for j in range(n-1):
        if (i>>j)&1:
            f += '+'
        f += ss[j+1]
    a = sum(map(int, f.split('+')))
    result += a
print(result)

Solution (Python):
s = input()

ans = 0
for b in range(1<<(len(s)-1)):
    a = s[0]
    for i in range(len(s)-1):
        if b & (1<<i):
            a += "+" + s[i+1]
        else:
            a += s[i+1]
    ans += eval(a)
print(ans)

Solution (Python):
def plus(s):
   s=s.replace("
   if "+" in s:
      numbers=list(map(int,s.split("+")))
      return sum(numbers) 

   else:
      return int(s)

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


S_re=[]
for i in range(len(S)):
   if i!=len(S)-1:
      S_re.append(S[i])
      S_re.append("
   else:
      S_re+=S[i]
T="".join(S_re)


count=0
for i in range(1<<N):
   output=[]
   for j in range(N):
      if((i>>j) & 1)==1:
         output.append(j)

   S_re=[c for c in T]
   for k in output:
      L=2*k+1
      S_re[L]="+"
   mojiretsu="".join(S_re)
   count+=plus(mojiretsu)

print(count)

Solution (Python):
s = input()
nbits = 1 << (len(s) - 1)
ans = 0
for bit in range(nbits):
    tmp = []
    for i in range(len(s) - 1):
        if bit & (1 << i):
            tmp.append(i)

    curr = 0
    for x in tmp:
        ans += int(s[curr : x + 1])
        curr = x + 1
    ans += int(s[curr:])

print(ans)

Solution (Python):
if __name__ == '__main__':

	S = input()

	s_len = len(S) - 1
	sum = 0
	for i in range(2**s_len):
		A = S[0]
		for j in range(s_len):
			if ((i >> j) & 1):
				A += "+" + S[j+1]
			else:
				A += S[j+1]
		sum += eval(A)

	print(sum)

Solution (Python):
S = input()

sum = 0

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

    s = ""

    for j in range(len(S)-1):
        s = s + S[j]+op_list[j]

    s = s + S[len(S)-1]

    sum = sum + eval(s)


print(sum)

Solution (Python):
S = str(input())
t = len(S)-1
a = []
for i in range(2**t):
    tasu = []
    for j in range(t):
        if ( (i >> j) & 1 ):
            tasu.append("+")
        else:
            tasu.append("")
    tasu.append("")
    a.append(tasu)

result = 0
for k in range(2**t):
    p = ""
    for (i,j) in zip(S,a[k]):
        p += i + j
    result += eval(p)
print(result)

Solution (Python):





liststr = list(input())
n = len(liststr)
listnum = []
for i in range(n):
    listnum.append(int(liststr.pop()))



a = [1]
for i in range(1, n):
    tmp = a[-1] * 10 + 2 ** (i-1)
    a.append(tmp)



sum1 = 0
for i in range(n):
    tmp = listnum[i]
    sum1 += int(tmp * a[i] * (2**(n-i-1)))
    
print(sum1)

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



sum = 0

for i in range(2**(len(S)-1)):


    op_list = ["+"]*(len(S)-1)
    for j in range(len(S)-1):
        if (i>>j) & 1:
            op_list[j] = ""
    s = ""
    for k in range(len(S)-1):
        s = s + S[k] + op_list[k]

    s = s + S[len(S)-1]

    sum = sum + eval(s)


print(sum)

Solution (Python):
s = input()
nbits = 2**(len(s)-1)
ans = 0
for bit in range(nbits):
  tmp = []
  for i in range(len(s)-1):
    if bit & (1 << i):
      tmp.append(i)
  curr = 0
  for x in tmp:
    ans += int(s[curr:x+1])
    curr = x + 1
  ans += int(s[curr:])
 
print(ans)

Solution (Python):
s = input()
nbits = 2**(len(s)-1)
ans = 0
for bit in range(nbits):
  tmp = []
  for i in range(len(s)-1):
    if bit & (1 << i):
      tmp.append(i)
  curr = 0
  for x in tmp:
    ans += int(s[curr:x+1])
    curr = x + 1
  ans += int(s[curr:])

print(ans)

Solution (Python):
s = input()
nbits = 2**(len(s)-1)
ans = 0
for bit in range(nbits):
  tmp = []
  for i in range(nbits):
    if bit & (1 << i):
      tmp.append(i)
  curr = 0
  for x in tmp:
    ans += int(s[curr:x+1])
    curr = x + 1
  ans += int(s[curr:])

print(ans)

Solution (Python):
import sys

S = list(input())

sum = 0
for i in range(2**(len(S)-1)):

    op_list = ['+']*(len(S)-1)

    for j in range(len(S)-1):
        if (i>>j) & 1:
            op_list[j] = ''


    s = ""
    for st_index in range(len(op_list)):
        s = s + S[st_index] + op_list[st_index]
    s = s + S[len(S)-1]
    result = eval(s)
    
    sum = sum + result

print(sum)

Solution (Python):
S = input()
s2 = ['+' for i in range(2*len(S)-1)]
for i in range(2*len(S)-1):
    if i%2 == 0:
        s2[i] = S[i//2]
ans = []
for i in range(2**(len(S)-1)):
    s3 = s2.copy()
    for j in range(len(S)-1):
        if (i >> j) & 1 == 1:
            s3[2*j+1] = '+'
        else:
            s3[2*j+1] = ''
    s3 = ''.join(s3)
    ans.append(s3)
suma = 0
for i in ans:
    suma += eval(i)
print(suma)

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

for bit in range(1 << (n - 1)):
    temp = s[0]

    for i in range(n - 1):
        if bit & (1 << i):
            temp += '+'
        temp += s[i + 1]

    ans += sum(map(int, temp.split('+')))

print(ans)

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

Solution (Python):
S = input()

n = len(S) - 1

ans = 0

for i in range(2**n):
    loc = [] 
    for j in range(n):
        if (i>>j) & 1:
            loc.append(j+1)
    
    S2 = S

    for k in reversed(loc):
        S2 = S2[:k] + '+' + S2[k:]
    ans += eval(S2)

print(ans)

Solution (Python):
import sys
import copy
from collections import deque

sys.setrecursionlimit(1000000000)

def dfs(xs,q):
    if len(xs) == 0:
        return sum(int(i) for i in q)

    x = xs.popleft()

    if len(q) == 0:
        q.append(x)
        return dfs(xs,q)


    a1 = copy.copy(xs)
    a2 = copy.copy(xs)

    q1 = copy.copy(q)
    q2 = copy.copy(q)

    q1.append(x)

    y  = q2.pop()
    yx = y + x
    q2.append(yx)

    return dfs(a1,q1) + dfs(a2,q2)


s  = str(input())
xs = deque(list(s))

print(dfs(xs,deque([])))

Solution (Python):
from itertools import combinations
s = list(input())
len_s = len(s)
sum_ = 0

for i in range(len(s)):
    for t in combinations(range(1, len_s), i):
        copy_s = s[:]
        for cnt, idx in enumerate(t):
            copy_s.insert(cnt + idx, '+')
        sum_ += eval("".join(copy_s))

print(sum_)

Solution (Python):
S = input()

n = len(S)-1
ans = 0

for i in range(2**(n)):
    locs = []
    for j in range(n):
        if (i>>j) & 1:
            
            locs.append(j+1)
    S2 = S
    for j in reversed(locs):
        S2 = S2[:j] + "+" + S2[j:]
    ans += eval(S2)
print(ans)

Solution (Python):
s=input()
n=len(s)
sum=0
if n==1:
  sum=int(s)
else:
  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:
        sum+=int(tmp)
        tmp=s[j+1]
    if tmp!='':
      sum+=int(tmp)
print(sum)

Solution (Python):
S = list(map(str,input()))
n = len(S) - 1

def calc(S, i, Tar, ans):
    if i == n:
        return ans + int(Tar)
    return calc(S, i+1, S[i+1], ans + int(Tar)) \
            + calc(S, i+1, Tar + S[i+1], ans)

print(calc(S,0,S[0],0))

Solution (Python):
s = 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[n - 1 - j] = "+"

    fomula = ""
    for value, operator in zip(s, op + [""]):
        fomula += (value + operator)

    ans += eval(fomula)

print(ans)

Solution (Python):
n=list(input())
x=len(n)-1
ans=0

for i in range(2**x):
    v=[0]*x
    for j in range(x):
        if (i>>j)&1==1:
            v[j]='+'

    w=n[0]
    for k in range(x):
        if v[k]=='+':
            w+=('+'+str(n[k+1]))
        else:
            w+=str(n[k+1])

    ans+=eval(w)


print(ans)

Solution (Python):
def dfs(formula, index):
    if index + 1 == max_index:
        return sum(list(map(int, formula.split("+"))))

    return dfs(formula + "+" + S[index + 1], index + 1) + dfs(formula + S[index + 1], index + 1)


S = input()
max_index = len(S)
print(dfs(S[0], 0))

Solution (Python):
def dfs(formula, index):
    if index + 1 == max_index:
        return sum(list(map(int, formula.split("+"))))

    else:
        return dfs(formula + '+' + S[index + 1], index + 1) + dfs(formula + S[index + 1], index + 1)


S = input()
max_index = len(S)

print(dfs(S[0], 0))

Solution (Python):
def dfs(i, formula):
    if i + 1 == num_digits:
        return sum(list(map(int, formula.split("+"))))

    return dfs(i + 1, formula + "+" + s[i + 1]) + dfs(i + 1, formula + s[i + 1])


s = input()
num_digits = len(s)

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

Solution (Python):

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd



def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False



def main():
    S = input()
    N = len(S) - 1

    total = 0
    for i in range(2 ** N):
        splits = []
        
        for j in range(N):
            if ((i >> j) & 1):
                splits.append(j)
        splits.append(len(S))

        for j in range(len(splits)):
            n = splits[j]
            if j == 0:
                total += int(S[:n+1])
                
            else:
                prev = splits[j-1]
                
                total += int(S[prev+1:n+1])

    print(total)


if __name__ == '__main__':
    main()

Solution (Python):
S = input()
N = len(S)

ans = 0
for i in range(1<<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()
n = len(s)


def dfs(i,f):
    if i == n-1:
        return sum(list(map(int,f.split("+"))))
    return dfs(i+1,f+s[i+1]) + dfs(i+1,f+"+"+s[i+1])
    
print(dfs(0,s[0]))

Solution (Python):
import math

N=int(input())

def dig(x,d):
  return int((x%(10**(d+1)))/(10**d))

D=int(math.log10(N))

ans=0

for bits in range(int(2**D)):
  ans+=dig(N,0)
  j=1
  for i in range(1,D+1):
    if (bits>>(i-1))&1:
      j=0
    ans+=int(dig(N,i)*(10**j))
    j+=1
print(int(ans))

Solution (Python):



def solve(*args: str) -> str:
    S, = args
    n_sep = len(S)-1
    b_max = 2**n_sep

    ret = 0
    for b in range(b_max):
        p = 0
        for i in range(n_sep):
            if b >> i & 1:
                ret += int(S[p:i+1])
                p = i+1
        ret += int(S[p:])

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Solution (Python):
S = input()

n = len(S)

ans = 0

for i in range(2**(n-1)):
    tmp = ''
    for j in range(n-1):
        tmp += S[j]
        if i & (1 << j):
            tmp += '+'
    tmp += S[-1]
    ans += eval(tmp)


print(ans)

Solution (Python):
S = list(input())
n = len(S)
a = []

sbox = []


for i in S:
    a.append(int(i))

def dfs(i,box,k):
    if i == n-1:
        box += k
        sbox.append(box)
    else:
        dfs(i+1,box+k,a[i+1])
        dfs(i+1,box,10*k+a[i+1])

dfs(0, 0, a[0])
print(sum(sbox))

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

totals = []

def total(n):
  tmp = int(s[-1 * n:])
  
  for i in range(n-1):
    tmp += int(s[-1 * n:-1 * (i+1)]) * 2**i + totals[i]
    
  totals.append(tmp)


for i in range(size):
  total(i+1)

print(totals[size - 1])

Solution (Python):
S=input()
s=[int(S[i]) for i in range(len(S))]
N=len(s)
B=[]
for i in range(2**(N-1)):
    ans=[[s[0]]]
    for j in range(N-1):
        if ((i>>j)&1):
            ans[-1].append(s[j+1])    
        else:
            ans.append([s[j+1]])
    for k in ans:
        for l, val in enumerate(reversed(k)):
            B.append((10**l)*val)
print(sum(B))

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

for i in range(2**(n-1)):
    nnn = [[s[0]]]
    for j in range(0, n - 1):
        if ((i>>j)&1):
            nnn[-1].append(s[j + 1])
        else:
            nnn.append([s[j + 1]])

    for nn in nnn:
        for i, val in enumerate(reversed(nn)):
            ans += val * 10 ** i

print(ans)

Solution (Python):
def add_or_do_nothing(s, i, pos):
    if i == len(s):
        pre_i = 0
        ans = 0
        for i, pos_i in enumerate(pos, 1):
            if pos_i == '1':
                ans += int(s[pre_i:i])
                pre_i = i

        ans += int(s[pre_i:len(s)])
        return ans

    f_ans = add_or_do_nothing(s, i+1, pos+'0')
    s_ans = add_or_do_nothing(s, i+1, pos+'1')
    return f_ans + s_ans

s = input()

pos = ''
ans = add_or_do_nothing(s, 1, pos)

print(ans)

Solution (Python):
s = input()
n = len(s)
ans = 0
for i in range(2**n):
	l = []
	op = [""]*n
	for j in range(n):
		if ((i >> j) & 1) == 1:
			op[j] = '+'
	res = ""
	for a,b in zip(op+[""],s):
		res += a+b
	ans += eval(res)
print(ans//2)

Solution (Python):
s = input()

n = len(s)

ans = 0
for i in range(2**n):
	l = []
	op = [""]*n
	for j in range(n):
		if i & (1 << j):
			op[j] = '+'
	
	res = ""
	for a,b in zip(op+[""],s):
		res += a+b

	ans += eval(res)

print(ans//2)

Solution (Python):
s = input()

n = len(s)

ans = 0
for i in range(2**n):
	l = []
	for j in range(n):
		if i & (1 << j):
			l.append(j)
	
	string = s
	if len(l) == 0:
		continue
	for k in range(len(l)):
		if l[k] == 0:
			string = '+' + string
		else:
			string = string[:l[k]+k] + '+' + string[l[k]+k:]

	ans += eval(string)

print((ans + int(s))//2)

Solution (Python):
S = input()
n = len(S) - 1
ans = 0
for i in range(2**n):
    bits = [(i>>j)&1 for j in range(n)]
    bits.append("")
    expr = ""
    for s, b in zip(S, bits):
        expr += s
        if b == 1:
            expr += "+"
    ans += sum([int(s) for s in expr.split("+")])
print(ans)

Solution (Python):
S = input()
n = len(S) - 1
ans = 0
for i in range(2**n):
    bits = [(i>>j)&1 for j in range(n)]
    bits.append("")
    expr = ""
    for s, b in zip(S, bits):
        expr += s
        if b == 1:
            expr += "+"
    ans += eval(expr)
print(ans)

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

for i in range(2**(n-1)):
    
    tmp=[]
    for k in range(n-1):
        
        tmp.append(s[k])
        if i>>k & 1:
            
            tmp.append("+")
    tmp.append(s[-1])
    
    ans+=eval("".join(tmp))
print(ans)

Solution (Python):
S = input()
def dfs(i, formula, ans_formula):
    
    if i == len(formula):
        ans_formula.append(formula)
        return formula

    
    dfs(i+2, formula[:i] + '+' + formula[i:], ans_formula)
    
    
    dfs(i+1, formula, ans_formula)

ans_formula = []
dfs(1, S, ans_formula)

ans = 0
for i in range(len(ans_formula)):
    ans += sum(list(map(int, ans_formula[i].split('+'))))

print(ans)

Solution (Python):
INF = float("inf") 

def main():
    s = 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] = "+"
        res = ""
        for a,b in zip(s,op+[""]):
            if len(b) != 0:
                res += a + b
            else:
                res += a
        ans += eval(res)

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
import copy

def main():
    sum=0
    S = list(map(str, input()))
    hoge = tmp = []

    op_cnt = len(S) - 1

    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] = "+"

        S_tmp = copy.deepcopy(S)
        for k in range(len(op)):
            S_tmp.insert(1+k*2,op[k])
        sum+=(eval("".join(S_tmp)))
    print(sum)

main()

Solution (Python):
S = input()

res_list = []

def my_recursion(res):
    if len(res) >= len(S):
        return ''

    my_recursion(res + '0')
    my_recursion(res + '+')
    if len(res) == len(S)-1:
        res_list.append(res)

    return res_list


res_list = my_recursion('')

temp_S_list = []

for item in res_list:
    temp_S = ''
    for i, j in enumerate(item):
        temp_S += S[i]+j
    temp_S += S[-1]
    S_done_eval = eval(temp_S.replace('0', ''))
    temp_S_list.append(S_done_eval)

print(sum(temp_S_list))

Solution (Python):
S = list(input())
A = [i for i in range(len(S)-1)]
ans = 0
for i in range(1 << len(A)):
    tmp = S.copy()
    idx = []
    k = 0
    for j in range(len(A)):
        if ((i >> j) & 1) == 1:
            idx.append(A[j])
    for j in range(len(idx)):
        tmp.insert(idx[j]+1+k, '+')
        k += 1
    
    str = ''.join(tmp)
    n = str.split('+')
    n = [int(i) for i in n]
    ans += sum(n)
print(ans)

Solution (Python):
S = input()
n = len(S)
ans = [0]*(n+1)

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

Solution (Python):
my_list = list(input())
sum = 0
n = len(my_list) - 1
for i in range(2**n):
    tmp = [""]*n
    for j in range(n):
        if 1&(i>>j):
            tmp[n-1-j] = "+"
    formula = ""
    for p,q in zip(tmp+[""],my_list):
        formula += str(q) + p
    sum += eval(formula)

print(sum)

Solution (Python):
S = input()
str_list = list(S)
p = len(S) - 1

ans = 0
for i in range(2 ** p):
    num = str_list[0]
    for j in range(p):
        if (i >> j) & 1:
            ans += int(num)
            num = ''
        num += str_list[j+1]
    ans += int(num)

print(ans)

Solution (Python):
nums = list(input().strip())
N = len(nums)
head = nums.pop(0)
print(sum(eval(head + "".join([('' if (j >> i) % 2 else '+') + str(n) for i, n in enumerate(nums)])) for j in range(2 ** (N - 1))))

Solution (Python):
s = input()
n = len(s) - 1
answers = []
sl = [s[i] for i in range(len(s))]
for i in range(2 ** n):
    tmp = []
    for j in range(n):
        if ((i >> j) & 1):
            tmp.append(j)
    ll = ['*']*len(s)
    for k in tmp:
        ll[k] = '+'
    ans = []
    for k, _ in zip(sl, ll):
        ans.append(k)
        ans.append(_)
    ans = [_ for _ in ans if _ != '*']
    ans = ''.join(ans)
    ans = ans.split('+')
    ans = [int(_) for _ in ans if _ != '+']
    ans = sum(ans)
    answers.append(ans)
print(sum(answers))

Solution (Python):
S = input()


def solve(n,S,idx):
    ans = 0
    if idx >= len(S):
        return eval(n)

    ans += solve(n+"+"+S[idx], S, idx+1)
    ans += solve(n+S[idx], S, idx+1)
    return ans

if len(S) == 1:
    print(S)
else:
    ans = solve(S[0], S, 1)
    print(ans)

Solution (Python):



import pdb
import sys
F = sys.stdin

S = F.readline().rstrip()
N = int(len(S) - 1)
sum = 0
l = [0]


for bit in range(1<<N):
    for i in range(N):
        if bit & (1<<i):
            l.append(i+1)

    l.append(int(N+1))
    l_length = len(l)
    for j in range(l_length):
        if j == 0:
            continue
        ss = S[(l[j-1]):(l[j])]

        sum += int(ss)

    l = [0]


print(sum)

Solution (Python):



import pdb
import sys
F = sys.stdin

S = F.readline().rstrip()
N = int(len(S) - 1)
sum = 0
l = [0]


for bit in range(1<<N):
    for i in range(N):
        if bit & (1<<i):
            l.append(i+1)

    l.append(int(N+1))
    l_length = len(l)
    for j in range(l_length):
        if j == 0:
            continue
        ss = S[(l[j-1]):(l[j])]

        sum += int(ss)

    l = [0]


print(sum)

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

def dfs(pos, pre_pos, val):
    global ans
    if pos == last:
        ans += (val + int(S[pre_pos:]))
    else:
        new_val = val + int(S[pre_pos:pos])
        dfs(pos + 1, pos, new_val)
        dfs(pos + 1, pre_pos, val)

dfs(1, 0, 0)

print(ans)

Solution (Python):
s = input()
print(sum([eval(''.join(sum(zip(s, ['+' if ((bit >> i) & 1) == 1 else '' for i in range(len(s))]), ()))) for bit in range(1 << len(s) - 1)]))

Solution (Python):
S = list(input())
ans = 0
for i in range(1 << len(S) - 1):
    output = S[0]
    for j in range(len(S) - 1):
        if ((i >> j) & 1) == 1:
            output += "+"
        output += S[j + 1]
    ans += eval(output)
print(ans)

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = read().rstrip().decode('utf-8')

def F(S):
    yield int(S)
    for i in range(len(S)-1):
        left = S[:i+1]
        right = S[i+1:]
        x = int(left)
        for y in F(right):
            yield x + y

answer = sum(F(S))
print(answer)

Solution (Python):
S = list(input())
n = len(S)-1
ans=0
for i in range(2**n):
  tmp=S[:]
  for j in range(n):
    if (i>>j) & 1:
      tmp[j]+="+"
  ans+= eval("".join(tmp))
print(ans)

Solution (Python):
import math

S = input()

ans = 0
for i in range(2**(len(S)-1)):
    j = 0
    k = 1
    for c in format(i, '0' + str(len(S)-1) + 'b'):
        if c == '1':
            ans += int(S[j:k])
            j = k
        k += 1
    ans += int(S[j:k])

print(ans)

Solution (Python):
s = input()

ans = 0

n = len(s)-1

for i in range(2 ** n):
    bag = []
    for j in range(n):
        if ((i >> j) & 1):
            bag.append(1)
        else:
            bag.append(0)
    c = 0

    temp = s
    for j in range(0, n):
        c += 1
        if (bag[j]):
            temp = temp[:c] + '+' + temp[c:]
            c += 1

    ans += eval(temp)


print(ans)

Solution (Python):
from itertools import product

S = input()
n = len(S)

ans = 0
for P in product(["+",""],repeat=n-1):
    res = ""
    for s,p in zip(S,P):
        res += s+p
    res += S[-1]
    
    ans += eval(res)
print(ans)

Solution (Python):
S = list(input())
N = len(S)
v = 0

for i in range(2**(N-1)):
    i = str(bin(i))[2:].zfill(N-1)
    op = ["+" if int(i[j]) else "" for j in range(N-1)]
    q = [S[j//2] if j%2==0 else op[(j-1)//2] for j in range(2*N-1)]
    v += eval("".join(q))


print(v)

Solution (Python):


s = list(input())

n = len(s)

def dfs(i,f):
    if i == n -1:
        return sum(list(map(int, f.split("+"))))
    return dfs(i+1,f + s[i+1]) + dfs(i+1,f + "+" + s[i+1])


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

Solution (Python):

S = list(input())
n = len(S) - 1
ans = 0
for i in range(2**n):
    tmp = S[:]
    for j in range(n):
        if (i >> j) & 1 == 1:
            tmp[j] += "+"
    ans += eval("".join(tmp))
print(ans)

Solution (Python):

S = list(input())
ans = 0
n = len(S) - 1
for i in range(2**n):
    tmp = S[:]
    for j in range(n):
        if (i >> j) & 1 == 1:
            tmp[j] += "+"
    ans += eval("".join(tmp))
print(ans)

Solution (Python):

S = str(input())
n = len(S) - 1
ops = []
for i in range(2**n):
    op = [""] * n
    for j in range(n):
        if ((i >> j) & 1) == 1:
            op[n-1-j] = "+"
    ops.append(op[:])
    
ans = 0
for op in ops:
    s = [t for t in S]
    tmp = ""
    for k in range(len(op)):
        tmp += s[k]
        tmp += op[k]
    tmp += s[-1]
    ans += eval(tmp)
print(ans)

Solution (Python):
def main():

    S = input()
    n = len(S)
    memo = dict()
    def recursive(S, i, j):
        if i == j: return 0
        if (i, j) not in memo:
            v = int(S[i:j])
            for k in range(i+1, j):
                v += int(S[i:k])*pow(2, j-k-1) + recursive(S, k, j)
            memo[(i, j)] = v
        return memo[(i, j)]

    return recursive(S, 0, n)

if __name__ == '__main__':
    print(main())

Solution (Python):
def main():

    S = input()
    memo = dict()
    n = len(S)

    def recursive(S, i, j):

        v = 0
        if j < i: return v
        if (i, j) in memo: return memo[(i, j)]
        
        for k in range(i, j+1):
            if j - k < 1:
                v += int(S[i:k+1])
            else:
                v += int(S[i:k+1])*pow(2, j-k-1) + recursive(S, k+1, j)
        memo[(i, j)] = v
        return memo[(i, j)]

    ans = recursive(S, 0, n-1)

    return ans


if __name__ == '__main__':
    print(main())

Solution (Python):
import sys
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline















S = input().rstrip() 
n = len(S)-1 

ops = []
for i in range(2**n): 
	op = [""] * n 
	for j in range(n):
		if((i>>j) & 1) == 1:  
			op[n-1-j] = "+" 
	ops.append(op)











ans = 0
for o in ops:
	s = [s for s in S]
	for k in range(len(o)):
		s.insert(2*k+1, o[k])
	ans += eval(''.join(s)) 

print(ans)

Solution (Python):
S = str(input())
n = len(S)
total,i_sum, reg = 0, 0, 0
for i in range(2**(n-1)):
    reg = int(S[0])
    for j in range(n-1):
        if(i >> j) & 1:
            i_sum += reg

            reg = 0
        reg = reg*10 + int(S[j+1])

    i_sum += reg
    total += i_sum
    i_sum = 0

print(total)

Solution (Python):
S = input()


def solve(current='', index=0):
    if index is len(S) - 1:
        return eval(current + S[index])
    return solve(current + S[index], index + 1) + solve(current + S[index] + '+', index + 1)


def solve2():
    total = 0
    for source in range(1 << (len(S) - 1)):
        
        
        current = ''
        for i, s in enumerate(S):
            current = current + s
            if (source >> i) & 1:
                total += int(current)
                current = ''
        total += int(current)
    return total

print(solve2())

Solution (Python):
S = input()


def solve(current = '', index=0):
    if index is len(S) - 1:
        return eval(current + S[index])
    return solve(current + S[index], index + 1) + solve(current + S[index] + '+', index + 1)


print(solve())