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()
 
ls = len(S)
res = 0

for i in range(0,ls):
    x = S[ls-i-1]
    a = 0    
    b = 2**(ls-1)
    for j in range(0,i+1):
        if j == i:
            b = b
        
        else:
            b = b//2
        a = a+(10**j)*b
    res  =  res + int(x)*a

print(res)

Solution (Python):
S = input()

cnt = 0
for i in range(1 << (len(S) - 1)):
    t = i
    l = 0
    r = 1
    while t > 0:
        if t % 2 == 1:
            cnt += int(S[l:r])
            l = r
            r += 1
        else:
            r += 1
        t >>= 1
    cnt += int(S[l:])

print(cnt)

Solution (Python):
list_N = list(input())
n = len(list_N) - 1
ans = 0
for i in range(2 ** (n)):
    cnt = 0
    c = []
    for j in range(n):
        if ((i >> j) & 1):
            c.append(int("".join(list_N[cnt:j+1])))
            cnt = j+1
    c.append(int("".join(list_N[cnt:n+1])))
    ans += sum(c)

print(ans)

Solution (Python):
import itertools
s = input()
digits = list(s)
length = len(digits)
operators = list(itertools.product([0, 1], repeat=length - 1))
total = 0
for i in operators:
    t = []
    for j in range(length - 1):
        t.append(digits[j])
        if i[j] == 1:
            t.append('+')
    t.append(digits[-1])
    total += eval(''.join(t))
print(total)

Solution (Python):

"""
Created on Wed Apr 22 23:44:20 2020

@author: Kanaru Sato
"""

def dfs(numstr,count,chara):
    if len(chara) == 1:
        return count+int(numstr+chara)
    else:
        numstr = numstr+chara[0]
        return dfs("",count+int(numstr),chara[1:])+dfs(numstr,count,chara[1:])

s = input()

print(dfs("",0,s))

Solution (Python):
s = input()

keta = []
for i in range(len(s)):
    keta.append(int(s[-(i+1)]))

ans = 0
for j in range(len(s)):
    ans += (10**j)*(keta[0]*(2**(len(s)-j-1))+(sum(keta)-keta[0])*(2**(len(s)-j-2)))
    keta = keta[1:]

print(int(ans))

Solution (Python):
from itertools import product
s = input()
s_last = s[-1]
len_s = len(s)
ttl = 0
for i in product(['', '+'], repeat=len_s- 1):
    ttl += eval(''.join(s[j] + i[j] for j in range(len_s - 1)) + s_last)
print(ttl)

Solution (Python):
s=list(map(int,list(input())))
import itertools
ans=0
for i in itertools.product([0,1], repeat=len(s)-1):
    sums=0
    snum=s[0]
    for ii in range(len(i)):
        if i[ii]==0:
            snum=snum*10+s[ii+1] 

        else:
            sums=sums+snum

            snum=s[ii+1]
    sums=sums+snum


    ans=ans+sums
print(ans)

Solution (Python):
S = input()

plus = [i for i in range(1, len(S))]

import itertools

ans = int(S)
for c in range(1, len(S)):
    for l in itertools.combinations(plus, c):
        l_ = list(l)
        formula = ""
        for i, s in enumerate(S):
            if i in l_:
                formula += "+"
            formula += s
        ans += sum([int(num) for num in formula.split("+")])
print(ans)

Solution (Python):

import math
import heapq
import bisect
import numpy as np
from collections import Counter, deque
import itertools


S = input()
N = len(S)

ans = 0
for i in range(1<<(N-1)):
    func = S[0]
    for j in range(N-1):
        if (i>>j)&1:
            func += '+'
        func += S[j+1]
    ans += eval(func)

print(ans)

Solution (Python):
from collections import deque
S=input()
N=len(S)
cnt=0
for i in range(pow(2,N-1)):
    d=deque()
    flag=[0]*(N-1)
    num = []
    v=[]
    for j in range(N):
        d.append(S[j])
    for j in range(N-1):
        if (i>>j)&1:
            flag[j]=1
    
    for j in range(N):
        s=d.popleft()
        v.append(s)
        if (j<N-1):
            if(flag[j]==1):
                s="".join(v)
                num.append(int(s))
                v=[]
        else:
            s = "".join(v)
            num.append(int(s))
            v = []
    
    cnt=cnt+sum(num)
print(cnt)

Solution (Python):
a,b,k=0,0,1
for d in input():a,b=2*a+b,10*b+int(d)*k;k*=2
print(a+b)

Solution (Python):
S,a,b=input(),0,0
for i in range(len(S)):a,b=2*a+b,10*b+int(S[i])*2**i
print(a+b)

Solution (Python):
S = input()
a, b = 0, int(S[0])
for i in range(1, len(S)):
    d = int(S[i])
    a = 2 * a + b
    b = 10 * b + (2 ** i) * d
print(a + b)

Solution (Python):




def main():
    S = input()
    N = len(S) - 1
    result = 0
    for i in range(2**N):
        f = S[0]
        for j in range(N):
            if i >> j & 1:
                f += "+"
            f += S[j + 1]
        result += eval(f)
    print(result)


if __name__ == "__main__":
    main()

Solution (Python):
s=input()
l_s=len(s)
b='0%db'%(l_s-1)
ans=0
for i in range(2**(l_s-1)):
  t=''
  for j in range(l_s-1):
    t+=s[j]+('+' if format(i,b)[j]=='1' else '')
  t+=s[l_s-1]
  ans+=eval(t)
print(ans)

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

for i in range(2**(n-1)):
  index =format(i,'b').zfill(n-1)
  index = [int(ind) for ind in index]
  
  
  t = s
  for k in range(n-1):
    if index[k]==1:
      t = t[:k+1+sum(index[:k])]+ '+' + s[k+1:]

  ans += eval(t)
print(ans)

Solution (Python):

def dfs(s):
    stack = []
    push, pop = stack.append, stack.pop
    push([s,[]])

    ans = 0

    while stack:
        ss, lst = pop()
        if ss == '':
            ans += sum(lst)
        for i in range(1,len(ss)+1):
            push([ss[i:] , lst + [int(ss[:i])]])
    return ans

s = input()
print(dfs(s))

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):
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):
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):
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):
from collections import defaultdict
import io
import math

data = input()
counter = 0
for o in range(1 << (len(data) - 1)):
    array = data[0]
    for i in range(len(data) - 1):
        if o & 1 << i:
            array += '+'
        array += data[i + 1]
    counter += eval(array)
print(counter)

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

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        S=str(input())

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


resolve()

Solution (Python):
import sys
import fractions

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
bit = len(S)-1
Sum = 0
for b in range(2 ** bit):
    bb = b
    i = 1
    offset = 0
    s = list(S)
    while bb:
        if bb & 1:
            s.insert(i+offset, ',')
            offset += 1
        bb >>= 1
        i += 1
    Sum += sum(map(int, ''.join(s).split(',')))
print(Sum)

Solution (Python):
S=input()
t=len(S)-1
sum = 0
for bit in range(2**t):
    f=S[0]

    for i in range(t):
        if bit &(1<<i):
            f+='+'
        f+=S[i+1]
    
    sum+=eval(f)

print(sum)

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):
S=input()
total=0
for bit in range(1<<len(S)-1):
    evals=S[0]
    for n in range(len(S)-1):
        if bit&(1<<n):
            evals+="+"
        evals+=S[n+1]
    total+=eval(evals)
print(total)

Solution (Python):
def main():
    S = input()

    ans = 0
    for bit in range(1<<(len(S)-1)):
        left = 0
        for i in range(len(S)-1):
            if (bit >> i) & 1:
                ans += int(S[left:i+1])
                left = i + 1
        ans += int(S[left:])
    print(ans)
    
if __name__ == "__main__":
    main()

Solution (Python):
def main():
    S = input()
    strs = str(S)
    width = len(strs)
    num = 0
    
    for i in range(width, 0, -1):
        if width > i + 1:
            num += adding_first(strs, i) * 2 ** (width - i -1)
            strs = strs[1:]
        else:
            num += adding_first(strs, i)
            strs = strs[1:]
    print(num)

def adding_first(x, y):
    addition = 0
    for i in range(1, y + 1):
        a = x[0:int(i)]
        b = x[int(i):y + 1]
        if len(b) != 0:
            addition += int(a) * 2 ** (len(b)-1)
        else:
            addition += int(a)


    return addition

main()

Solution (Python):
import itertools

s = input()

reslist = []

def diverge(current_list, pos):
    if pos == len(s):
        reslist.append(current_list)
        return
    stick_list = current_list.copy()
    current_list.append(int(s[pos]))
    diverge(current_list, pos + 1)
    stick_list[-1] = stick_list[-1]*10 + int(s[pos])
    diverge(stick_list, pos + 1)

diverge([int(s[0])], 1)



sol = 0

for res in reslist:
    sol += sum(res)

print(sol)

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):
s = input()
n = len(s)
ans = 0

for i in range(2**(n-1)):
  f = s[0]
  for j in range(n-1):
    if ((i>>j)&1):
      f += '+'
    f += s[j+1]
  ans += eval(f)

print(ans)

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


for i in range(pow(2, len(S)-1)):
    bit = bin(i)[2:].zfill(len(S)-1)
    ind = 0
    res = 0
    for j in range(len(bit)):
        if bit[j] == "1":
            res += int(S[ind:j+1])
            ind = j+1
    res += int(S[ind:])
    ans += res

print(ans)

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby
    
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

    S = input().rstrip()
    n = len(S)
    res = 0

    for s in range(1<<(n-1)):
        l = 0
        for i in range(n-1):
            if (s>>i) & 1:
                res += int(S[l:i+1])
                l = i+1
        res += int(S[l:])
    print(res)

if __name__ == '__main__':
    main()

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

Solution (Python):
import sys

s = sys.stdin.readline().rstrip()
n = len(s)

def c(n):
    return pow(2, max(0, n - 1))
  
def main():
    res = 0
    for l in range(n):
        for r in range(l, n):
            res += int(s[l:r+1]) * c(l) * c(n - 1 - r)
    print(res)

if __name__ ==  '__main__':
    main()

Solution (Python):
s = input()
n = len(s)-1
ans = 0
for bit in range(1<<n):
    tmp = s
    cnt = 0
    for i in range(n):
        if 1<<i & bit:
            tmp = tmp[:i+1+cnt] + '+' + tmp[i+1+cnt:]
            cnt += 1
    ans += eval(tmp)
print(ans)

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

op_cnt = len(S) - 1
cons = 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] = "+"
    Ans = []
    for k in range(len(S)-1):
        Ans.append(S[k])
        Ans.append(op[k])
    Ans.append(S[-1])
    formula = ''.join(Ans)
    cons += eval(formula)

print(cons)

Solution (Python):
s = input()
l = len(s)
ans = 0
for i in range(2**(l-1)):
    b = str(format(i, '0{}b'.format(l-1)))
    ns = ''
    for j in range(l):
        ns += s[j]
        if j!=l-1:
            if b[j]=='1':
                ns += '+'
    ans += eval(ns)
print(ans)

Solution (Python):
s=input()
n=len(s)
ans=0
for bit in range(2**(n-1)):
  t=0
  t_str=s[0]
  for j in range(n-1):
    if (bit&(1<<j)):
      t+=int(t_str)
      t_str=s[j+1]
    else:
      t_str+=s[j+1]
  t+=int(t_str)
  ans+=t
print(ans)

Solution (Python):










def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:
    return a
  return gcd_(a,a % b) 
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""


def readInts():
  return list(map(int,input().split()))

def main():
  s = input()
  slen = len(s)
  ans = 0
  for i in range(2**(slen-1)):
    nya = [0]
    for j in range(slen-1):
      if i >> j & 1:
        nya.append(j+1)
    nya.append(slen)
    
    
	
	
	
    for j in range(len(nya) - 1):
      ans += int(s[nya[j]:nya[j+1]])
  print(ans)
if __name__ == '__main__':
  main()

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

s=list(s)

keta = len(s)

pluscheck = []

ans = 0

for i in range(1,keta):
    pluscheck.append(i)

for i in range(keta):
    for j in itertools.combinations(pluscheck,i):
        memo = []
        for k in range(keta):
            if k in j:
                ans += int(''.join(map(str,memo)))
                memo = []
                memo.append(s[k])
            else:
                memo.append(s[k])
        ans += int(''.join(map(str,memo)))
print(ans)

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

ksum=0

import itertools
for i in itertools.product([0,1], repeat=len(s)-1):
    isum=0
    nstr=s[0]
    for ii in range(len(s)-1):
        if i[ii]==0:
            nstr=nstr+s[ii+1]
        elif i[ii]==1:
            isum=isum+int(nstr)
            nstr=s[ii+1]
    isum=isum+int(nstr)
    ksum=ksum+isum

print(ksum)

Solution (Python):
S = int(input())
l = len(str(S)) 
li = list(str(S))

S_a = l - 1 

result = S

for i in range(1, 2**S_a):
  L = list(bin(i))
  del L[0:2]
  while len(L) < S_a:
    L.insert(0, "0")

  indexes = [i for i, x in enumerate(L) if x == "1"]

  li2 = li.copy()
  for j in indexes:
    li2[j] += "+"

  result += eval("".join(li2))
  


print(result)

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

s = i_s()

ans = 0
for i in range(1<<(len(s)-1)):
    tmp = s[0]
    for j in range(len(s)-1):
        if i & 1 << j:
            tmp += '+'
        tmp += s[j+1]
    ans += eval(tmp)

print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    S = str(input())
    ls=len(S)


    
    
    n = ls-1
    
    val = 0
    for i in range(2 ** n):
        split=[]
        for j in range(n):  
            if ((i >> j) & 1):  
                split.append(j)
        temp=0
        for k in range(len(split)):
            val+=int(S[temp:split[k]+1])
            temp=split[k]+1
            if k==len(split)-1:
                val+=int(S[split[k]+1:])
    print(val+int(S))


resolve()

Solution (Python):
import itertools

def calc(str, tup):
  l = []
  idx = 0
  for i in tup:
    l.append(int(str[idx:i]))
    idx = i
  l.append(int(str[idx:]))
  return sum(l)

def solve(s):
  l = [i for i in range(1, len(s))]
  ans = 0
  for c in range(len(l)+1):
    for v in itertools.combinations(l,c):
      ans += calc(s, v)
  return ans

if __name__ == "__main__":
  s = input()
  print(solve(s))

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

s = i_s()

ans = 0
for i in range(2**(len(s)-1)):
    tmp = s[0]
    for j in range(len(s)-1):
        if i & (1<<j):
            tmp += "+"
        tmp += s[j+1]
    ans += eval(tmp)

print(ans)

Solution (Python):
s = input()

num_pat = 2 **(len(s) - 1)
ans = 0
for i in range(num_pat):
    subans = 0
    wait = 0
    for j in range(len(s) - 1):
        if ((i >>j) & 1):
            wait += int(s[j])
            subans += wait
            wait = 0
        else:
            wait += int(s[j])
            wait *= 10
    subans += wait
    subans += int(s[-1])
    ans += subans

print(ans)

Solution (Python):
S = input()

sum = 0
for i in range(1 << len(S)-1):
    l = []
    for j in range(len(S)-1):
        if (i >> j) & 1 == 1:
            l.append(S[j])
            l.append("+")
        else:
            l.append(S[j])
    l.append(S[len(S)-1])
    sum += eval(''.join(l))
print(sum)

Solution (Python):
s = input()



t = 0
import itertools
for i in range(0, len(s)):
    for j in list(itertools.combinations([i for i in range(1, len(s))], i)):
        j = list(j)
        j.append(len(s))
        
        t += int(s[:j[0]])
        for k in range(len(j)-1):
            
            t += int(s[j[k]:j[k+1]])
print(t)

Solution (Python):
from itertools import product
S=input()
N=len(S)
fa=0

def asum(X):
    ans=0
    pre=0

    for i in range(len(X)):
        if X[i]==1:
            ans+=int(S[pre:i+1])
            pre=i+1
    else:
        ans+=int(S[pre:])
    return ans

for A in product(range(2),repeat=N-1):
    fa+=asum(A)
print(fa)

Solution (Python):
s = input()
n = len(s)
ans = 0
def bfs(num,i):
    if i == n:
        global ans
        ans += eval(num)
    else:
        bfs(num+'+'+s[i],i+1)
        bfs(num+s[i],i+1)
bfs(s[0],1)
print(ans)

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

Solution (Python):
S = input()

num = 0
for i in range(2**(len(S)-1)):
  plus = list(" " * (len(S)-1))
  indx = bin(i)[2:].zfill(len(S)-1)
  for ind in range(len(indx)):
    if indx[ind] == "1": plus[ind] = "+"
  formula = S[0]
  for j in range(len(S)-1):
    if plus[j] == " ":
      formula += S[j+1]
    else:
      formula += "+" + S[j+1]
  num += eval(formula)
print(num)

Solution (Python):
s=input()
a=int(s)
sum=0
for i in range(2**(len(s)-1)):
  bi=list(map(int,str(format(i,"b").zfill(len(s)-1))))
  
  k=0
  for j in range(len(bi)):
    if bi[j]==1:
      
      sum+=int(s[k:j+1])
      
      
      k=j+1
  
  
  sum+=int(s[k:])
    
print(sum)

Solution (Python):
import queue

n = input()

def all_combination(length):
    q = queue.Queue()
    source = (0, )
    part_list = [source + (length, )]
    q.put(source)
    while not q.empty():
        parent = q.get()
        if parent[-1] < length-1:
            for m in range(parent[-1]+1, length):
                child = parent + (m, )
                part_list.append(child + (length, ))
                q.put(child)
        else:
            pass
            
    return part_list
        
length = len(n)
part_list = all_combination(length)

sum = 0
for t in part_list:
    for i, j in zip(t[:-1], t[1:]):
        sum += int(n[i:j])
        
print(sum)

Solution (Python):
n=input()
m=len(n)-1

ans=0
for i in range(2**m):
    num=format(i,"b").zfill(m)
    N=list(n)
    for j,k in enumerate(num):
        if k=="1":N[j]=N[j]+"+"
    ans +=eval("".join(N))
print(ans)

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

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

S=list(str(input()))
r_sum=0


def dec2bin(target):
	amari=[]
	while(target!=0):
		amari.append(target%2)
		target=target//2
	amari.reverse()
	return amari

    
for i in range(2**(len(S)-1)):
	add_list=dec2bin(i)
	tmp=[0]*(len(S)-1-len(add_list))
	add_list=tmp+add_list
	c=0
	for j in range(len(S)):
		r_sum += int(S[-j-1]) *(10**c)
		c += 1
		if(j<(len(S)-1)):
			if(add_list[-j-1]==1):
				c=0
print(r_sum)

Solution (Python):


in1 = input()
len = len(in1)

in_array = [''] * ((len * 2) - 1)
for idx1 in range(len):
    in_array[idx1 * 2] = in1[idx1]

RC = 0
for idx1 in range(2 ** (len - 1)):
    pos = format(idx1, '0' + str(len - 1) + 'b')
    for idx2 in range(len - 1):
        if pos[idx2] == '1':
            in_array[idx2 * 2 + 1] = '+'
        else:
            in_array[idx2 * 2 + 1] = ''
    RC += eval(''.join(in_array))

print(RC)

Solution (Python):
S=input().rstrip()
N=len(S)
ans=0
for b in range(2**(N-1)):
  a=[]
  p=0
  for i in range(N):
    if b&(1<<i):
      a.append(S[p:i+1])
      p=i+1
  a.append(S[p:])
  ans+=eval("+".join(a))
print(ans)

Solution (Python):
from itertools import combinations

s = list(input())
ans = 0

for i in range(len(s)):
    for j in combinations(range(len(s)-1),i):
        temp = [i for i in s]
        for k in j[::-1]:
            temp.insert(k+1,'+')
        temp = ''.join(temp)
        temp = temp.split('+')
        temp = map(int, temp)
        ans += sum(temp)

print(ans)

Solution (Python):
import copy
a = list(input())
n = len(a)-1
ans = 0
if n == 0:
  print(int(a[0]))
else:
  for i in range(2 ** n):
    l=[]
    l = copy.copy(a)
    dokoka = [0]*(n)
    for j in range(n):
        if ((i >> j)&1):
            dokoka[j] = 1
    x = l.pop(0)
    while True:
      d = dokoka.pop(0)
      if d == 0:
          x += l.pop(0)
      else:
          ans += int(x)
          x = l.pop(0)
      if not dokoka:
          ans += int(x)
          break
  print(ans)

Solution (Python):
S = input()

def f(i, s):
    if i == len(S) - 1:
        return sum(map(int, s.split("+")))
    else:
        return f(i + 1, s + S[i+1]) + f(i + 1, s + "+" + S[i+1])

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

Solution (Python):
c,*s=input();n=len(s);print(sum(eval(c+''.join('+'*(b>>i&1)+s[i]for i in range(n)))for b in range(2**n)))

Solution (Python):
c,*s=input();n=len(s)
print(sum(eval(c+''.join('+'*(b>>i&1)+s[i] for i in range(n))) for b in range(2**n)))

Solution (Python):
c,*s=input();n=len(s)
import itertools as it
print(sum(eval(c+''.join(p[i]+s[i] for i in range(n))) for p in it.product(['','+'],repeat=n)))

Solution (Python):
S = input()

N=len(S)

total=0
for i in range(0, 2**(N-1)):
    answer=S[0]
    for j in range(N-1):
        if (i >> j) & 1:
            answer+='+'+S[j+1]
        else:
            answer+=S[j+1]
    total+=eval(answer)
    
print(total)

Solution (Python):
c,*s=input()
n=len(s)
import itertools as it
a=0
for p in it.product(['','+'],repeat=n):
  t=c
  for i in range(n): t+=p[i]+s[i]
  a+=eval(t)
print(a)

Solution (Python):

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

print(ans)

Solution (Python):
S = list(input())
if len(S) != 1:
    t = 0
    for n in range(2**(len(S) - 1)):
        f = S[0]
        b = bin(n)[2:]
        b = "0"*(len(S) - len(b) - 1) + b
        for a in range(len(b)):
            if b[a] == "1":
                f += "+"
            f += S[a+1]
        t += eval(f)
    print(t)
else:
    print(S[0])

Solution (Python):
import itertools

S = input()
ans = 0
r = len(S) - 1
for t in itertools.product([0, 1], repeat=r):
    lst = [S[0]]
    for i in range(r):
        if t[i]:
            lst.append('+')
        lst.append(S[i + 1])
    ans += eval(''.join(map(str, lst)))
print(ans)

Solution (Python):

import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    
    S = Scanner.string()
    n = len(S) - 1
    ans = 0
    for i in range(1 << n):
        tmp = 0
        x = S[0]
        for j in range(n):
            if (i >> j) & 1:
                tmp += int(x)
                x = S[j + 1]
            else:
                x = x + S[j + 1]
        tmp += int(x)
        ans += tmp
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
from itertools import product, zip_longest
from functools import reduce

s = input()

res = 0
for op in product(('+', ''), repeat=len(s)-1):
    formula = ''.join(reduce(lambda t, u: t+u, zip_longest(s, op, fillvalue='')))
    res += eval(formula)

print(res)

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):
S=list(input())
n=len(S)
ans=0
for i in range(2**(n-1)):
    stack=""
    l=[]
    for j in range(n):
        stack=stack+S[j]
        if ((i >> j) & 1)or j==n-1:
            l.append(int(stack))
            stack=""
    ans+=sum(l)
print(ans)

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

for i in range(2**n):
    stack=""
    l=[]
    for j in range(n):
        stack=stack+S[j]
        if ((i >> j) & 1)or j==n-1:
            l.append(int(stack))
            stack=""
    ans+=sum(l)
    if len(l)==len(S):
        break
print(ans)

Solution (Python):
import copy

s = input()
n = len(s)
li = []
ans = 0

def make_list():
    global li
    if len(li) < n - 1:
        li.append(0)
        make_list()
        li.pop(-1)
        li.append(1)
        make_list()
        li.pop(-1)
    else:
        calc(li)

def calc(li):
    global ans
    tmp = 0
    cnt = 0
    s1 = copy.copy(s)
    for i in range(n-1):
        if li[i] == 0:
            tmp += int(s1[cnt:i+1])
            cnt = i+1
    tmp += int(s1[cnt:])
    ans += tmp

make_list()

print(ans)

Solution (Python):
from collections import *
from heapq import *
from itertools import *
from fractions import gcd
import sys
from decimal import *
import copy
from bisect import *
input=lambda :sys.stdin.readline().rstrip()

S=input()
N=len(S)
lst=[]
for bitlst in [[i>>m&1 for m in range(N-1)] for i in range(2**(N-1))]:
    z=S[0]
    num=0
    for i,b in enumerate(bitlst):
        if b==1:
            num+=int(z)
            z=S[i+1]
        else:
            z+=S[i+1]
    num+=int(z)
    lst.append(num)
print(sum(lst))

Solution (Python):
S=list(input())
n=len(S)
ans=0
for i in range(2**(n-1)):
  A=[0]
  s=format(i,"12b")
  for j in range(1,n):
    if s[-j]=="1":
      A.append(j)
  A.append(n)
  for j in range(len(A)-1):
    a=""
    for k in range(A[j+1]-A[j]):
      a=a+S[A[j]+k]
    ans=ans+int(a)
print(ans)

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

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

Solution (Python):
s = input()
num = 0
for bit in range(2**(len(s)-1)):
    before = 0
    for g in range(len(s)-1):
        if bit >> g & 1:
            num += (int(s[before:g+1]))
            before = g+1
    num += int(s[before:])
print(num)

Solution (Python):
inp = input()
n = len(inp)
s = []
for i in range(n):
  s += inp[i]

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

ans = 0
for i in range(len(com)):
  tmp = ""
  idx = 0
  for j in range(n-1):
    tmp += s[j]
    tmp += com[i][idx]
    idx += 1
  tmp += s[n-1]
  ans += eval(tmp)

print(ans)

Solution (Python):
s=input()
n=len(s)
ans=0
for i in range(2**(n-1)):
  S=format(i,"12b")
  A=[0]
  for j in range(1,n):
    if S[-j]=="1":
      A.append(j)
  A.append(n)
  for j in range(len(A)-1):
    ans=ans+int(s[A[j]:A[j+1]])
print(ans)

Solution (Python):
s=input()
n=len(s)
if n==1:
    print(int(s))
else:
    n-=1
    ans=0
    for i in range(1<<n):
        l=[]
  
        for j in range(n-1,-1,-1):
            if (i>>j)&1:
                l.append(n-1-j)
   
        j=0
        k=0
        while j<len(l):
            num=''
            while k<=l[j]:
                num+=s[k]
                k+=1
    
            ans+=int(num)
            j+=1
        num=''
        while k<n+1:
            num+=s[k]
            k+=1
     
        ans+=int(num)
    print(ans)