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()



interval = len(s) - 1
ans = 0
for i in range(2**interval):
    f = list(s)
    for j in range(interval):
        if (i & (1<<j)):
            f[j] = f[j] + '+'
    f = "".join(f)
    
    if '+' in f:
        
        ans = ans + sum(list(map(int,f.split('+'))))
    else:
        ans = ans + int(f)
print(ans)

Solution (Python):
n = [int(x) for x in input()]
op_cnt = len(n) - 1  
out=0
for i in range(2 ** op_cnt):
    op = ["+"] * op_cnt  
    box=""
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "" 
        box=""  
    for a,b in zip(n,op+[""]):
        box+=(str(a)+b)
    box=box.split('+')
    ou=0
    for k in box:
        out+=int(k)
print(out)

Solution (Python):
n = input()

sumP = 0

for i in range(2 ** (len(n)- 1)):   
    plus=[]                         
    for j in range(len(n) - 1):     
        if i >> j & 1 :             
            plus.append(j)          

    middle_index = 0

    for pos in plus:
        sumP += int(n[middle_index:pos + 1])       
        middle_index = pos + 1
    sumP += int(n[middle_index:])                  

print(sumP)

Solution (Python):
s = input()
n = len (s)
def self(i,w):
    if i == n-1:
        return sum(list(map(int, w.split('+'))))
    return self(i+1,w+s[i+1])+self(i+1,w+'+'+s[i+1])

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

Solution (Python):
def main():
    S = input()
    s = set()
    for i in range(2**len(S)):
        tmp = S[0]
        for j in range(1,len(S)):
            if (i >> j) & 1:
                tmp += '+' + S[j]
            else:
                tmp += S[j]
        s.add(tmp)
    ans = 0
    for a in s:
        ans += eval(a)
    print(ans)



if __name__ == "__main__":
    main()

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

for i in range(2**n):
    num = s[0]
    for j in range(n):
        if (i >> j) & 1:
            num += "+"
        num += s[j + 1]
    ans += sum(map(int, num.split("+")))
print(ans)

Solution (Python):
s=input()

n=len(s)
ans=int(s)
for bit in range(1<<(n-1)):
    if bit==0 : continue
    now=[] 
    for i in range(n):
        if bit>>i &1 :
            now.append(i)

    for i in range(len(now)-1):
        ans+=int(s[now[i]+1:now[i+1]+1])
    ans+=int(s[:now[0]+1])
    ans+=int(s[now[-1]+1:])

print(ans)

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

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

print(a)

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

def value(m):
    num = s[0]
    ans = 0
    for i in range(1, n):
        t = (m>>(i-1)) & 1
        if t ==1:
            ans += int(num)
            num = s[i]
        else:
            num = num + s[i]
    ans += int(num)
    return ans

count = 0
for i in range(2**(n-1)):
    count +=value(i)

print(count)

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

for i in range(2 ** (n - 1)):
    k = 0
    num_list = []
    for j in range(n):
        if (i >> j) & 1:
            num = s[k : j + 1]

            k = j + 1
            num_list.append(int(num))

    num = s[k : n +1]
    num_list.append(int(num))
    ans += sum(num_list)
print(ans)

Solution (Python):
from itertools import product
S = input()
n = len(S)
bit = list(product([0, 1], repeat = n - 1))
ans = 0
for state in bit:
    s = S[0]
    for i in range(len(state)):
        if state[i] == 1:
            s += '+' + S[i + 1]
        else:
            s += S[i + 1]
    ans_list = list(map(int,s.split('+')))
    for a in ans_list:
        ans += a
print(ans)

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

ans = 0
p = 1
c = pow(2, n - 1)

for i in range(n):
    for j in range(i, n):
        if j == i:
            ans += p * c * int(S[-j - 1])
            c //= 2
        else:
            ans += p * c * int(S[-j - 1])
    p *= 10

print(ans)

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

from itertools import product
LS = list(product([0,1], repeat=N-1))
out = 0
for L in LS:
    T = S[0]
    for i in range(N-1):
        if L[i]==1:
            T += "+"+S[i+1]
        else:
            T += S[i+1]
    A = list(map(int,T.split("+")))
    out += sum(A)
print(out)

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

def calc(T):
    N = len(T)
    t = 0
    ans = 0
    tmp = 0
    while T[t]!="=":
        if T[t]=="+":
            ans += tmp
            tmp = 0
            t+=1
            continue
        else:
            tmp = 10*tmp+int(T[t])
            t+=1
    ans += tmp
    return ans

from itertools import product
LS = list(product([0,1], repeat=N-1))
out = 0
for L in LS:
    T = S[0]
    for i in range(N-1):
        if L[i]==1:
            T += "+"+S[i+1]
        else:
            T += S[i+1]
    T += "="
    out += calc(T)
print(out)

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


ans = 0

for i in range(2 ** (n-1)):
    s_temp = s.copy()
    numbers = [s_temp.pop(0)]
    for j in range(n-1):
        if (i >> j) & 1:
            numbers.append(s_temp.pop(0))
        else:
            numbers[len(numbers)-1] = numbers[len(numbers)-1] + s_temp.pop(0)

    numbers = list(map(int, numbers))

    ans += sum(numbers)

print(ans)

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

ans = 0

for bit in range(1 << (n - 1)):
    partial_sum = S[0]
    for i in range(n-1):
        if bit & (1 << i):
            partial_sum += "+"
        partial_sum += S[i+1]
    ans += sum(map(int, partial_sum.split("+")))

print(ans)

Solution (Python):
S=input()
def dfs(s,i):
  if i==len(S)-1:
    return sum(map(int,s.split("+")))
  return dfs(f"{s}{S[i+1]}",i+1)+dfs(f"{s}+{S[i+1]}",i+1)
print(dfs(S[0],0))

Solution (Python):
S=input()
def dfs(s,i):
  if i==len(S)-1:
    return sum(map(int,s.split("+")))
  return dfs(f"{s}{S[i+1]}",i+1)+dfs(f"{s}+{S[i+1]}",i+1)
print(dfs(S[0],0))

Solution (Python):
S=input()
def dfs(s,i):
  if i==len(S)-1:
    return sum(map(int,s.split("+")))
  return dfs(s+S[i+1],i+1)+dfs(f"{s}+{S[i+1]}",i+1)
print(dfs(S[0],0))

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

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

Solution (Python):
nums = input()

op_cnt = len(nums) -1

sum = 0

for i in range(2 ** op_cnt):
    op = [""] * op_cnt
    for j in range(op_cnt):
        if(i >> j & 1):
            op[j] = "+"
    

    formula = ""

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

    sum += eval(formula)

print(sum)

Solution (Python):
S = input()
size = len(S)
patterns = []
ans = 0

def flagfun(flag):
    if len(flag) == size:
        patterns.append(flag+"1")
        return
    
    flagfun(flag+'0')
    flagfun(flag+'1')

flagfun('')

for pattern in patterns:
    lastKey = 0
    for k, v in enumerate(pattern):
        if v == "1":
            if len(S[lastKey:k]) != 0:
                ans += int(S[lastKey:k])
                lastKey = k

print(int(ans/2))

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

ans = 0
for i in range(2 ** (N - 1)):
    nums = []
    num = ''
    for j in range(N):
        num += S[j]
        if (i >> j) & 1:
            nums.append(int(num))
            num = ''
    else:
        nums.append(int(num))
    ans += sum(nums)

print(ans)

Solution (Python):
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])
 
 
s = input()
n = len(s)
 
print(dfs(0, s[0]))

Solution (Python):
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])


s = input()
n = len(s)

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

Solution (Python):
import sys
S = list(input())
T = [int(a) for a in S]
N = len(T)

if N == 1:
  print(T[0])
  sys.exit()
  
ans = 0
for i in range(2 ** (N-1)):
  i_ = i
  j = 1
  tmp = T[0]
  while j < N:
    
    if i_ % 2 == 0:
      tmp *= 10
      tmp += T[j]
    if i_ % 2 == 1:
      ans += tmp
      tmp = T[j]
    i_ = i_ >> 1
    j += 1
  ans += tmp
  
    
print(ans)

Solution (Python):
S = input()
def dfs(s, i):
  if i == len(S) - 1:
    return sum(map(int, s.split("+")))
  return dfs(s + S[i + 1], i + 1) + dfs(f"{s} + {S[i + 1]}", i + 1)
print(dfs(S[0], 0))

Solution (Python):
s = input().strip()

cnt = [1]
for i in range(20):
    cnt.append(sum(cnt))
ans = 0
for i in range(len(s)):
    for f in range(i + 1, len(s) + 1):
        num = int(s[i:f])
        ans += num * cnt[i] * cnt[len(s) - f]
print(ans)

Solution (Python):
S = input()
N = len(S)-1
res = 0

for i in range(2 ** N):
  pw = 0
  for j in range(N):
    if ((i >> j) & 1):
      res += int(S[pw:j+1])
      pw = j+1
  res += int(S[pw:])
  
print(res)

Solution (Python):
S = list(input())
def dfs(s, i):
  if i == len(S) - 1:
    return sum(map(int, s.split("+")))
  return dfs(s + S[i + 1], i + 1) + dfs(s + "+" + S[i + 1], i + 1)

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

Solution (Python):



S = input().strip()
result = 0
num = list()
for i in range(len(S)):
    num.append(int(S[i]))

for b in range(2**(len(S)-1)):
    b_str = format(b, 'b').zfill(len(S)-1)
    sum = 0
    for i in range(len(num) - 1):
        if b_str[i] == '0':
            result += sum * 10 + num[i]
            sum = 0
        else:
            sum = sum * 10 + num[i]
    result += sum * 10 + num[-1]

print(result)

Solution (Python):
s = input()

res = 0
for i in range(2**(len(s)-1)):
    pos = 0
    for j in range(len(s)-1):
        if (i >> j) & 1:
            res += int(s[pos:j+1])
            pos = j + 1
    res += int(s[pos:])

print(res)

Solution (Python):
s = list(input())
n = len(s) - 1 
p = 0
for i in range(2**n):
    m = int(s[0])
    x = i
    for j in range(n):
        if x % 2 != 0:
            p += m
            m = int(s[j+1])
        else:
            m = m * 10 + int(s[j+1])
        x = x // 2
    p += m
print(p)

Solution (Python):
S = list(input())
def dfs(t, i):
  if i == len(S) - 1:
    return sum(map(int, t.split("+")))
  return dfs(t + S[i + 1], i + 1) + dfs(t + "+" + S[i + 1], i + 1)
print(dfs(S[0], 0))

Solution (Python):
S = input()
blank_cnt = len(S) - 1
ans = 0
for i in range(2 ** blank_cnt):
  formula = S[0]
  for j in range(blank_cnt):
    if (i >> j) & 1:
      formula += "+" + S[j + 1]
    else:
      formula += S[j + 1]
  ans += sum(list(map(int, formula.split("+"))))
print(ans)

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

print(a)

Solution (Python):
n=input()
s=len(n)
ans=0
def f(i,cur=""):
    global ans
    
    if(i==s):
        ans+=eval(cur)
        return
    f(i+1,cur+n[i])
    if(i!=s-1):f(i+1,cur+n[i]+'+')
f(0)
print(ans)

Solution (Python):
S=input()
ans=0
for i in range(2**(len(S)-1)):
    a=bin(i)
    b=a[2:]
    while len(b)<len(S)-1:
        b="0"+b
    k=0
    temp=0
    for j in range(len(b)):
        if b[j]==str(1):
            temp+=int(S[k:j+1])
            k=j+1
    if S[k:len(S)]!="":    
        temp+=int(S[k:len(S)])
    ans+=temp
print(ans)

Solution (Python):
def solve(S):
    n = len(S) - 1
    result = 0
    for i in range(2**n):
        sum_i = 0
        now = 0
        for j in range(n+1):
            now = now * 10 + int(S[j])
            if j < n:
                if ((i >> j) & 1):
                    sum_i += now
                    now = 0
            else:
                sum_i += now
        result += sum_i
    return result
S = input()
print(solve(S))

Solution (Python):
S = list(input())
l = len(S)-1
su = 0
for i in range(2**l):
    q = S[0]
    for j in range(l):
        if (i>>j) & 1:
            q += '+' + S[j+1]
        else:q += S[j+1]
    su += eval(q)
print(su)

Solution (Python):
S = input()

N = len(S)

ans = 0
for i in range(2**(N-1)):
    tmp = S[0]
    for j in range(len(S)-1):
        flag = (i >> j) & 1

        if flag:
            tmp += "+" + S[j+1]
        else:
            tmp += S[j+1]

    num = list(map(int, tmp.split("+")))
    ans += sum(num)

print(ans)

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

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

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

Solution (Python):






s=input()
n=len(s)
l=n-1
lst_1=[]
for i in range(1<<l):
    lst=[]
    for j in range(l):
        if ((i>>j)&1):
            lst.append("+")
        else:lst.append("_")
    lst_1.append(lst)

ans=0
for i in range(1<<l):
    temp=s[0]
    for j in range(l):

        if lst_1[i][j]=="+":
            temp+="+"
        temp += s[j+1]
    ans+=sum(map(int,temp.split("+")))
print(ans)

Solution (Python):
import copy
a = list(input())
N=len(a)
bit_list =[]
for i in range(2**(N-1)):
  b = format(i,"09b")
  b = b[::-1]
  bit_list.append(b)
count = 0
for i in range(2**(N-1)):
  a_list = []
  a_list=copy.copy(a)
  num = 0
  num_li =[a[0]]
  for k,j in enumerate(bit_list[i]):
    if j == '1':
      a_list.insert(k+1+num,"+")
      num+=1
  for j,i in enumerate(a_list):
    if j>0:
      num_li[0] +=i
  count+= eval(num_li[0])
print(count)

Solution (Python):
s = list(input())
n = len(s)-1
ans = 0
l = []
for i in range(2**n):
    ss = s.copy()
    for j in range(n):
        bit = (i >> j) & 1
        if bit == 1:
            ss.insert(n - j, '+')

    ans += eval(''.join(ss))      

 
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):
def RecSum(S, i):
    if i > len(S) - 1:
        return eval(''.join(S))
    SS = S.copy()
    SS.insert(i, "+")
    return RecSum(S, i+1) + RecSum(SS, i+2)


S = list(input())
print(RecSum(S, 1))

Solution (Python):
data = input()
length = len(data)

between = length - 1
num = 0
for i in range(2**between):
    list_data = list(data)
    for j in range(between):
        if ((i >> j) & 1):
            list_data[between - j] = '+'+list_data[between - j]
    hoge = ''.join(list_data).split('+')
    for k in hoge:
        num += int(k)

print(num)

Solution (Python):
s=input()
ans=0
for i in range(2**(len(s)-1)):
  i=bin(i)[2:].zfill(len(s)-1)
  a=s[0]
  for j in range(len(s)-1):
    if i[j]=='1':
      a+='+'
    a+=s[j+1]
  ans+=eval(a)
print(ans)

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

for i in range(2**num):
    tmp=['-']*num 
    for j in range(num):
        if ((i >> j) &1):
            tmp[num-1-j] ='+'
    x.append(tmp)
        


ans =0

for i in range(len(x)):
    now =S[0]
    for j in range(len(x[i])):
        if x[i][j] == '-':
            now += S[j+1:j+2]
        else:
            now = now + x[i][j] + S[j+1:j+2] 
    
    ans += eval(now)

print(ans)

Solution (Python):

import itertools

def part_sum(S, clist):
    start = 0
    sum = 0
    for c in clist:
        sum += int(S[start:c])
        start = c
    sum += int(S[start:])
    return sum

def main():
    s = input()
    
    length = len(s)
    numlist = list(range(1, length))
    ans = 0
    for i in range(length):
        combi = list(itertools.combinations((numlist), i))
        for clist in combi:
            clist = list(clist)
            ans += part_sum(s, clist)
    print(ans)
    
    
    
    
                
            
        
    
if __name__ == '__main__':
    main()

Solution (Python):




S = list(input())
ans = 0

for i in range(2**(len(S)-1)):
    p = list(bin(i))
    flag = ['0' for _ in range(len(S) - len(p) + 1)] + p[2:]
    l = 0
    for j in range(len(S)-1):
        if (i >> j) & 1:
            ans += int("".join(S[l:j+1]))
            l = j+1
    ans += int("".join(S[l:]))

print(ans)

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

for i in range(2**(len(S)-1)):
    tmp = S
    p = list(bin(i))
    flag = ['0' for _ in range(len(S) - len(p) + 1)] + p[2:]
    nums = []
    l = 0
    for j in range(len(S)-1):
        if flag[j] == '1':
            nums.append("".join(tmp[l:j+1]))
            l = j+1
    nums.append("".join(tmp[l:]))
    for n in nums:
        ans += int(n)

print(ans)

Solution (Python):
import sys






def calc(express,i):
    if i == len(nums):
        return sum(list(map(int,express.split("+"))))
    return calc(express + nums[i],i+1) + calc(express + "+"+ nums[i] ,i+1) 

nums = list(input())
print(calc(nums[0],1))

Solution (Python):
import itertools
s = input()
ans=0
for i in list(itertools.product([0,1], repeat=len(s)-1)):
  b = 0
  a = s[0]
  for j in range(len(s)-1):
    if i[j] == 0:
      a+=s[j+1]
    else:
      b+=int(a)
      a=s[j+1]
  b+=int(a)
  ans+=b
print(ans)

Solution (Python):
def gen(s):
    yield int(s)
    for i in range(len(s)-1):
        l = s[:i+1]
        r = s[i+1:]
        x = int(l)
        for y in gen(r):
            yield x + y
s = input()
print(sum(gen(s)))

Solution (Python):
s = input()
ans = 0
l = len(s)
for i in range(2**(l-1)):
  nums = [s]
  idx = 0
  
  for j in range(l-1):
    if i>>j&1:
      a = s[idx:j+1]
      b = s[j+1:]
      
      
      idx = j+1
      nums[-1] = a
      if b != '':
        nums.append(b)
  ans += sum(list(map(int, nums)))
  
  
print(ans)

Solution (Python):
s = input()
n = len(s) - 1
ans = 0
for i in range(1 << n):
    tmp_l = []
    sep = 0
    for j in range(n):
        if (i >> j) & 1:
            tmp_l.append(int(s[sep:j + 1]))
            sep = j + 1
    tmp_l.append(int(s[sep:]))
    ans += sum(tmp_l)
print(ans)

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

ans = 0
for i in range(1<<(n-1)):
    form = ""
    for j in range(n-1):
        form += s[j]
        if i & 1<<j:
            form += "+"
    form += s[-1]
    ans += eval(form)

print(ans)

Solution (Python):
s = str(input())
n = len(s)
m = [0 for _ in range(n)]
for i in range(n):
  m[i] = int(s[i])
a = 0
for i in range(2**(n-1)):
  ai = 0
  tmp = 0
  for j in range(n-1):
    if ((i>>j)&1) == 1:
      ai += tmp*10+m[j]
      tmp = 0
    else:
      tmp = tmp*10+m[j]
  tmp = tmp*10 + m[n-1]
  ai += tmp
  a += ai
print(a)

Solution (Python):
import sys
import numpy as np
import math
import collections
import copy
from collections import deque 
from functools import reduce
from itertools import product


S = input()
total = 0
for p in (product((0, 1), repeat=len(S)-1)):
    ns = S[0]
    for i, pp in enumerate(p, 1):
        if pp == 0:
            ns += S[i]
        else:
            total += int(ns)
            ns = S[i]
    total += int(ns)
print(total)

Solution (Python):
def main():
    S = input()
    ans = 0
    for i in range(1 << (n := len(S) - 1)):
        T = ''
        for j in range(n):
            if i >> j & 1:
                T += S[j] + '+'
            else:
                T += S[j]
        T += S[n]
        ans += eval(T)
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):


S = input()
n = len(S)
ans = 0

for i in range(1 << n - 1):
    
    x = S[0]
    for j in range(n - 1):
        if i & 1 << j:
            
            x += '+'
        x += S[j + 1]
    ans += sum(map(int, x.split('+')))
print(ans)

Solution (Python):
import itertools
S = list(input())
ans = []
a = S[0]
pl = ["+",""]

for i in itertools.product(pl, repeat=len(S)-1):
    for j in range(len(S)-1):
        a += i[j]+S[j+1]
    ans.append(eval(a))
    a = S[0]

print(sum(ans))

Solution (Python):
s = input()
n = len(s)
ans = 0
for i in range(2**(n-1)):
  x = s[0]
  for j in range(n-1):
    if i & (1<<j):
      x += '+'
    x += s[j+1]
  ans += sum(map(int, x.split('+')))
print(ans)

Solution (Python):
S = input()
N = len(S)
Sum = 0
for i in range(2**(N-1)):
    exp = []
    for j in range(N):
        exp.append(S[j])
        if ((i >> j) & 1):
            exp.append('+')
    
    a = ''
    for j in range(len(exp)):
        if exp[j] == '+':
            Sum += int(a)
            a = ''
        else:
            a += exp[j]
        if j == (len(exp)-1):
            Sum += int(a)
    
print(Sum)

Solution (Python):
import sys
input = sys.stdin.readline


def RecSum(S, i):
    if i > len(S) - 1:
        return eval(''.join(S))
    SS = S.copy()
    SS.insert(i, "+")
    return RecSum(S, i+1) + RecSum(SS, i+2)


S = list(input().rstrip('\n'))
print(RecSum(S, 1))

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

Solution (Python):
S = input()

res = [[S[0]]]

for c in S[1:]:
    buf = []
    for dp in res[-1]:
        buf.append(dp+c)
        buf.append(dp+'+'+c)
    res.append(buf)
sum_num = 0

for string in res[-1]:
    sum_num += sum(map(int, string.split('+')))
print(sum_num)

Solution (Python):
s = input()
n = len(s)
ans = 0
for i in range(2**(n-1)):
  x = s[0]
  for j in range(n-1):
    if i & 1<<j:
      x += '+'
    x += s[j+1]
  ans += sum(map(int, x.split('+')))
print(ans)

Solution (Python):
S = input()
n = len(S)
ans = 0
for bit in range(2**(n-1)):
  x = S[0]
  for i in range(n-1):
    if bit & (1<<i):
      x += '+'
    x += S[i+1]
  ans += sum(map(int, x.split('+')))
print(ans)

Solution (Python):
import itertools
S = input()

ans = 0
for v in itertools.product([1,0], repeat=len(S)-1):
    idx = 0
    sum = 0
    for i in range(1,len(S)):
        if v[i-1] == 1:
            sum += int(S[idx:i])
            idx = i
    ans += int(S[idx:])
    ans += sum
print(ans)

Solution (Python):
import itertools
import copy
S = input()

ans = 0
for v in itertools.product([1,0], repeat=len(S)-1):
    S_copy = copy.deepcopy(S)
    idx = 0
    sum = 0
    for i in range(1,len(S)):
        if v[i-1] == 1:
            sum += int(S[idx:i])
            idx = i
    ans += int(S[idx:])
    ans += sum
print(ans)

Solution (Python):



    
def a(t,i):
    if i == len(s)-1:
        return sum(map(int,t.split('+')))
    return a(t+s[i+1],i+1) + a(t+'+'+s[i+1],i+1) 
s = input()
print(a(s[0],0))

Solution (Python):








import sys
S = sys.stdin.readline().rstrip()
N = len(S)
def solve(i,c,s):
    
    if i == N:
        return [s+c]
    ret = []
    ret.extend(solve(i+1,0,s+c*10+int(S[i])))
    ret.extend(solve(i+1,c*10+int(S[i]),s))
    return ret

print(sum(solve(0,0,0))//2)

Solution (Python):
S = input()
answer = 0
for bit in range(2 ** (len(S) - 1)):
    f = S[0]
    for i in range(len(S) - 1):
        if bit & (1 << i):
            f += '+'
        f += S[i + 1]
    answer += sum(map(int, f.split('+')))
print(answer)

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

Solution (Python):
from itertools import product

S=input()
ans=0
for i in list(product([False,True],repeat=len(S)-1)):
  b=0
  a=S[0]
  for j in range(len(S)-1):
    if i[j]==False:
      a+=S[j+1]
    else:
      b+=int(a)
      a=S[j+1]
  b+=int(a)
  ans+=b
print(ans)

Solution (Python):
import itertools
s = input()
ans=0
for i in list(itertools.product([0,1], repeat=len(s)-1)):
  b = 0
  a = s[0]
  for j in range(len(s)-1):
    if i[j] == 0:
      a+=s[j+1]
    else:
      b+=int(a)
      a=s[j+1]
  b+=int(a)
  ans+=b
print(ans)

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

for bit in range(1<<(n-1)):
    f=s[0]
    
    for i in range(n-1):
        
        if bit & 1<<i:
            f+="+"
        
        f+=s[i+1]
    
    ans+=sum(map(int,f.split("+")))

print(ans)

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

Solution (Python):
def separate_and_calc(S,plus_list):
    if plus_list == []:
        return array_to_num(S)
    
    result = 0
    for i in range(len(plus_list)):
        if i == len(plus_list)-1:
            result += array_to_num(S[plus_list[i]:])
        if i == 0:
            result += array_to_num(S[0:plus_list[i]])
            continue
        result += array_to_num(S[plus_list[i-1]:plus_list[i]])

    return result

def array_to_num(S):
    result = 0
    for i in range(len(S)):
        result += int(S[len(S) -1 - i]) * (10**(i))
    return result

S = input()
N = len(S)
result = 0
for bit in range(2**N):
    plus_list = []
    if bit & 1 or bit & (1<<N):
        continue

    for i in range(N):
        if (bit & (1<<i)):
            plus_list.append(i)
    
    result += separate_and_calc(S,plus_list)
    
    
print(result)

Solution (Python):
S = input()
n=len(S) - 1 
shiki = ""
output = 0
for i in range(2**n):
  result = list()
  shiki = S[0]
  for j in range(n):
    if ((i>>j)&1):
      shiki = shiki + '+' + S[j+1]
    else:
      shiki = shiki + S[j+1]
  result = list(map(int,shiki.split('+')))
  for k in range(len(result)):
    output += result[k]
print(output)

Solution (Python):
def abc061_c():
    s = str(input())

    l = []
    def saiki(i,moji):
        if i == len(s)-1:
            
            l.append(sum(list(map(int,moji.split("+")))))
            return

        
        saiki(i+1,moji+"+"+s[i+1])
        
        saiki(i+1,moji+s[i+1])

    saiki(0,s[0])

    print(sum(l))


abc061_c()

Solution (Python):
import copy

s = list(input())
n = len(s) - 1

ans = 0
for bit in range(1 << n):

    

    p = []
    for i in range(n):
        if bit & (1 << i):
            p.append(i)
    

    m = 1
    s_ = copy.copy(s)
    for idx in p:
        s_[idx+m:idx+m] = '+'
        m += 1
    

    ss = ''.join(s_)
    
    ans += sum([int(n) for n in ss.split('+')])

print(ans)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

S = list(input())
leng = len(S)
ans = 0
for i in range(1<<(leng-1)):
    lis = [S[0]]
    for j in range(leng-1):
        if (i>>j)&1:
            ans += int(''.join(lis))
            lis = []
        lis.append(S[j+1])
    else:
        if lis:
            ans += int(''.join(lis))
print(ans)

Solution (Python):
s = input()

n = 2 ** (len(s) - 1)
result = 0

for i in range(n):
  bin_n = bin(i)[2:]
  bin_n = '0' * ((len(s) - 1) - len(bin_n)) + bin_n
  current_address = 0
  for j in range(len(bin_n)):
    if bin_n[j] == '1':
      result += int(s[current_address:j+1])
      current_address = j+1

  result += int(s[current_address:])

print(result)

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

for bit in range(0, 1<<n):
    st=s
    for i in range(n+1):
        if (bit>>i)%2==0:
            continue
        st=st[:n-i]+'+'+st[n-i:]

    ans+=sum(list(map(int,st.split('+'))))
print(ans)

Solution (Python):
S=list(input())
s=0
op_count=len(S)-1
for i in range(2**op_count) :
    op=[""]*op_count
    for j in range(op_count) :
        if (i>>j) & 1 :
            op[j]="+"
    
    formula=""
    for p,q in zip(S,op+["+"]) :
        formula+=(p+q)
    formula+="0"
    s+=eval(formula)
print(s)

Solution (Python):
s = input()
len_s = len(s)
def calc_one_sum(n):
    r = len_s
    l = len_s - 1
    i = 0
    one_sum = 0
    while l > 0:
        if n & 1<<i != 0:
            one_sum += int(s[l:r])
            r = l
            l -= 1
        else:
            l -= 1
        i += 1
    one_sum += int(s[l:r])
    return one_sum
ans = 0
for i in range(2**(len_s - 1)):
    ans += calc_one_sum(i)
print(ans)

Solution (Python):
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


s = S()
n = len(s)
ans = 0
for i in range(2 ** (n - 1)):
    res = '' + s[0]
    for j in range(n - 1):
        if i >> j & 1:
            res += '+'
        res += s[j + 1]
    res = list(map(int, res.split('+')))
    ans += sum(res)
print(ans)

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

s = 0
for i in range(1 << (N - 1)):
    bs = format(i, f'0{N - 1}b')[::-1]
    t = S[0]
    for j in range(N - 1):
        if bs[j] == '1':
            s += int(t)
            t = S[j + 1]
        else:
            t += S[j + 1]
    s += int(t)
print(s)

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

Solution (Python):
def a(t,i):
    if i == n-1:
        return sum(map(int,t.split("+")))
    return a(t+s[i+1],i+1)+ a(t+"+"+s[i+1],i+1)

s = input()
n = len(s)
i=0
print(a(s[0],0))

Solution (Python):
s=list(input())
n=len(s)
ans=0
for i in range(2**(n-1)):
    a=list(bin(i)[2:])
    a=['0']*(n-1-len(a))+a
    j=0
    num=s[0]
    while j<n-1:
        if a[j]!='0':
            ans += int(num)
            num=''
        j+=1
        num+=s[j]
    ans+=int(num)
print(ans)

Solution (Python):
def sum(list, index):
    if (len(list) > 1):
        d = len(list[:-1]) - 1
        return (sum(list[:-1], 0) + list[-1] * 10**index * 2**d ) + (sum(list[:-1], index + 1 ) + list[-1] * 10**index * 2**d)
    else:
        return (list[-1] * 10**index)

def resolve():
    s = list(map(int,input()))
    print(sum(s,0))


if __name__ == "__main__":
    resolve()

Solution (Python):

S = input()

buf = [[0]]
for i in range(1, len(S)):
    buf2 = [b + [i] for b in buf] + buf
    buf = buf2
buf = [b + [len(S)] for b in buf]

ans = 0
for b in buf:
    for i in range(len(b) - 1):
        right, left = b[i], b[i+1]
        ans += int(S[right: left])
print(ans)

Solution (Python):
S=input()
N=len(S)
goukei=0
for i in range(2 **(N-1)):
    T=[]
    T.append(S[0])
    for j in range(N-1):
        if ((i >> j) & 1):
            
            
            T.append("+")
            T.append(S[j+1])
        else:
            T.append(S[j+1])
    
    
    
    tmp=[]
    for m in T:
        if m!="+":
            tmp.append(m)
        else:
            Z=[str(a) for a in tmp]
            Z="".join(Z)
            goukei+=int(Z)
            tmp=[]
    Z=[str(a) for a in tmp]
    Z="".join(Z)
    goukei+=int(Z)
    
print(goukei)