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):
from sys import stdin
def S(): return stdin.readline().rstrip()

def g(s):
    l = len(s)
    n = 2**l
    sum = 0
    for j in range(n):
        buff = ''
        for i in range(l):
            if j&(1<<i):
                buff += '+'
            else:
                buff += s[i]
        buff = buff.split('+')
        for _ in range(len(buff)):
            tmp = buff.pop()
            if tmp!='':
                sum += int(tmp)
    return sum


s = S()
ans = g(s)
print(ans)

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

  formula = ''
  for j in range(op):
    formula += s[j] + opm[j]
  formula += s[-1]
  ans += eval(formula)

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):
S = input()
n = len(S) - 1
total = 0
for i in range(1 << n):
    t = S[0]
    for j in range(n):
        if (i >> j) & 1:
            t += '+' + S[j + 1]
        else:
            t += S[j + 1]
    total += eval(t)

print(total)

Solution (Python):
import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
import itertools
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

s=input()
n=len(s)
que=deque()
que.append([0,s[0]])
ans=0
while len(que):
    q=que.popleft()

    if q[0]==n-1:
        ans+=sum(list(map(int, q[1].split("+"))))
    else:
        que.append([q[0]+1,q[1]+s[q[0]+1]])
        que.append([q[0]+1,q[1]+"+"+s[q[0]+1]])
print(ans)

Solution (Python):
import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
import itertools
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

s=input()
n=len(s)
que=deque()
que.append([0,s[0]])
ans=0
while len(que):
    q=que.popleft()

    if q[0]==n-1:
        ans+=sum(list(map(int, q[1].split("+"))))
    else:
        que.append([q[0]+1,q[1]+s[q[0]+1]])
        que.append([q[0]+1,q[1]+"+"+s[q[0]+1]])
print(ans)

Solution (Python):
S = input()
L = len(S)-1
a = 0

for i in range(2**L):
  T = S[0]
  for j in range(L):
    T+="+"*(i>>j&1)+S[j+1]
  a+=eval(T)

print(a)

Solution (Python):
S=input()
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):
n = input()
lenn = len(n)
ans = 0
for i in range(2**(lenn-1)):
    now = int(n[0])
    count = 0
    for j in range(lenn-1):
        if (i >> j) & 1 == 1:
            count += now
            now = int(n[j+1])
        elif (i >> j) & 1 == 0:
            now = now*10 + int(n[j+1])
    ans += count + now
print(ans)

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

for x in range(2**(len(S)-1)):
  bin_x = str(format(x,str(len(S)-1)+"b"))[::-1]
  
  l=0
  res=0
  for r,i in enumerate(bin_x):
    if i == "1":
      res+=int("".join(S[l:r+1]))
      l=r+1
  res+=int("".join(S[l:len(S)]))
  ans+=res
print(ans)

Solution (Python):
s=list(input());n=len(s)
def c(i,t):
    if i==n:return eval("".join(t))
    return c(i+1,t+"+"+s[i])+c(i+1, t+s[i])
print(c(1,s[0]))

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
from fractions import gcd
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

from itertools import permutations
from math import factorial, hypot





S = input()

def dfs(i, s):
    global ans
    if i == len(S):
        lista = list(map(int, s.split("+")))
        return sum(lista)
    else:
        return dfs(i + 1, s + S[i]) + dfs(i + 1, s + '+' + S[i])
print(dfs(1, S[0]))

Solution (Python):
S =input()
ans_list = []
if len(S) == 1:
    print(int(S))
else:
    for i in range(2**(len(S)-1)):
        comb = bin(i)[2:].zfill(len(S)-1)
        num_list = []
        num = S[0]
        for i in range(len(comb)):
            if comb[i] == "1":
                num_list.append(int(num))
                num = S[i+1]
            else:
                num += S[i+1]
        num_list.append(int(num))
        ans_list.append(sum(num_list))
    print(sum(ans_list))

Solution (Python):
A=[int(x) for x in input()]
n=len(A)-1
P=[]
for i in range(2**n):
    L=['']*n
    for j in range(n):
        if (i>>j)&1:
            L[j]='+'
    formula=''
    for a,b in zip(A,L+['']):
        formula+=(str(a)+b)
    P.append(eval(formula))
print(sum(P))

Solution (Python):
import itertools

S = int(input())

ans = 0
cnt = 0

for i in itertools.product([0,1], repeat = len(str(S)) - 1):
    A = str(S)
    cnt = 0
    for x, sign in enumerate(i):
        if sign == 0:
            cnt += 1
            if x == len(str(S)) - 2:
                ans += int(A[0:cnt+1])
        else :
            ans += int(A[0:cnt+1])
            cnt = 0
            A = str(S)[x+1:]
            if x == len(str(S)) - 2:
                ans += int(A[-1])

if len(str(S)) == 1:
    print(S)
else:
    print(ans)

Solution (Python):
S=input()
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()
n = len(s)
ans = 0
for i in range(2**(n-1)):
    now = int(s[0])
    cou = 0
    for j in range(n-1):
        if (i >> j) & 1 == 1:
            cou += now
            now = int(s[j+1])
        elif (i >> j) & 1 == 0:
            now = now*10 + int(s[j+1])
    ans += cou + now
print(ans)

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


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


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count





S = S()

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

ans = 0
for b in range(1<<(N-1)):
  rangelist = []
  for i in range(N-1):
    if (b>>i)&1:
      rangelist.append(i+1)
  rangelist.append(N)
  for i in range(len(rangelist)):
    if i == 0:
      ans += int(S[:rangelist[i]])
    else:
      ans += int(S[rangelist[i-1]:rangelist[i]])
print(ans)

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


for i in range(2**(N-1)):
    
    tmp_S = ""
    
    check_j = 0
    for j in range(N-1):
        if i >> j & 1:
            ans += int(S[check_j:j+1])
            check_j = j+1
            tmp_S = S[j+1:]
    if tmp_S:
        ans += int(tmp_S)


ans += int(S)
print(ans)

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

for i in range(1, 2**(N-1)):
    tmp_S = ""
    checked_j = 0
    for j in range(N-1):
        if i >> j & 1:
            ans += int(S[checked_j:j+1])
            checked_j = j+1
            tmp_S = S[j+1:]
    if tmp_S:
        ans += int(tmp_S)

ans += int(S)
print(ans)

Solution (Python):
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(IN())
mod=1000000007



def main():
	
	
	s = input()
	ret=0
	for i in range(len(s)):
		for j in range(i, len(s)):
			
			v = int(s[i:j+1])
			if i >= 1:
				na =2 ** (i-1)
			else:
				na=1
			
			if len(s)-j-1 >= 1:
				nb= 2**(len(s)-j-2)
			else:
				nb=1
			ret += v*na*nb
			
	print(ret)
			
		
		
	
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

Solution (Python):
s = input()
n = len(s)-1
ans = 0
for i in range(2**n):
    tmp = s[0]
    for j in range(n):
        if i>>j&1:
            ans += int(tmp)
            tmp = s[j+1]
        else:
            tmp += s[j+1]
    ans += int(tmp)
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):
s = input()
sl = len(s) - 1
loop = 2 ** sl
total = 0
for i in range(loop):
    x = ''
    for index, num in enumerate(s):
        x += num
        if (i >> index) & 1:
            x += '+'

    total += eval(x)

print(total)

Solution (Python):

from copy import deepcopy
from collections import deque

S = input()

s = deque([])
for i in S:
    s += [i]
    s += [""]
s.pop()

ans = 0
l = len(S)

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

print(ans)

Solution (Python):
import numpy as np
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

s = input()
ans = 0
for i in range(1<<(len(s)-1)):
    tmp = int(s[0])
    for j in range(len(s)-1):
        if i & 1<<j:
            ans += tmp
            tmp = int(s[j+1])
        else:
            tmp = tmp*10 + int(s[j+1])
    ans += tmp
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):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

S = input()

def gen(s):
    l = len(s)

    for i in range(1, l):
        c = int(s[0: i])
        for v in gen(s[i:]):
            yield c + v

    yield int(s)

print(sum(gen(S)))

Solution (Python):
S=input()
N=len(S)
ans=0
for i in range(2**(N-1)):
  F=S[0]
  q="{:0>10b}".format(i)[::-1]
  for j in range(1,N):
    if int(q[j-1])&1:
      F+="+"
    F+=S[j]
  ans+=eval(F)    
print(ans)

Solution (Python):
S=input()
N=len(S)
ans=0
for i in range(2**(N-1)):
  formula=S[0]
  q="{:0>10b}".format(i)[::-1]
  for j in range(1,N):
    if int(q[j-1])&1:
      formula+="+"
    formula+=S[j]
  ans+=eval(formula)    
print(ans)

Solution (Python):
S=input()
N=len(S)
ans=0
for i in range(2**(N-1)):
  formula=S[0]
  q="{:0>10b}".format(i)[::-1]
  
  
  for j in range(1,N):
    if int(q[j-1])&1:
      formula+="+"
      
    formula+=S[j]
    
  ans+=eval(formula)    
print(ans)

Solution (Python):
import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
import itertools as it

def main():
    s = IS()
    n = len(s)

    def calc(bits):
        sumv = 0
        for i in range(len(bits)-1):
            sumv += int(s[bits[i]:bits[i+1]])
        return sumv

    ans = 0
    for bit in range(1<<(n-1)):
        bits = [0]
        for i in range(n-1):
            if bit&(1<<i):
                bits.append(i+1)
        bits += [n]
        ans += calc(bits)
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
num = input()

def enum(num):  
    enumerated = [num]
    for i in range(1, len(num)):
        head = num[:i]
        for tail in enum(num[i:]):
            enumerated.append(head + '+' + tail)
    return enumerated

candidates = enum(num)
ans = sum([eval(eq) for eq in candidates])
print(ans)

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

answer=0
for perm in itertools.product([True,False],repeat=len(S)-1):
  
  eval_str=""
  for i in range(len(S)-1):
    eval_str+=S[i]
    if perm[i]:
      eval_str+="+"
  eval_str+=S[len(S)-1]
  
  
  answer+=eval(eval_str)
  
print(answer)

Solution (Python):
s=input()
sum=0
temps=list(s)
l=len(temps)-1
for i in range(0,2**l):
  temp=s[0]
  for j in range(0,l):
    if (i>>j)&1:
      temp += '+'
    temp += s[j+1]
  sum=sum+eval(temp)
print(sum)

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

Solution (Python):
s = input()
plus_len = len(s) - 1
num_search = 2 ** plus_len
result = 0
for i in range(num_search):
  x = ''
  for index,value in enumerate(s):
    x += value
    if (i >> index) & 1:
      x += '+'
  
  
  
  result += eval(x)
print(result)

Solution (Python):
S = list(input())
N = len(S)
ans = 0
for i in range(N):
    l = []
    c = 0
    now = pow(2,N-1)
    while c < i:
        now //= 2
        l.append(now)
        c += 1
    l.append(now)
    for j in range(len(l)):
        ans += int(S[N-i-1])*pow(10,j)*l[j]
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):
s=input()
n=len(s)-1
ans=0

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

  shiki=''
  for i,j in zip(s,bag+['']):
    shiki+=(i+j)
  
  ans+=eval(shiki)

print(ans)

Solution (Python):
import sys
sys.getrecursionlimit()

def dfs(i,s=''):
  global ans
  if i==len(t)-1:
    s+=t[-1]
    ans+=eval(s)
  else:
    dfs(i+1,s+t[i])
    dfs(i+1,s+t[i]+'+')

ans=0
t=list(input())
dfs(0,s='')
print(ans)

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

Solution (Python):
S = input()

ans = 0
N = len(S)

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

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

ans = 0

for bit in range(1 << l - 1):
    f = s[0]

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

print(ans)

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


def dfs(i, f):
    if i == l - 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)-1

ss = []
for l in s:
    ss.append(l)
    ss.append('')
s_list = ss[:-1]
s_list_tmp = s_list.copy()

d = 0

for i in range(1<<n):
    s_list_tmp = s_list.copy()
    for k in range(n): 
        if i>>k&1:
            
            s_list_tmp[2*k+1] = '_'
    s_str = ''.join(s_list_tmp)
    p_str = s_str.split('_')
    p_list = list(map(int, p_str))
    d += sum(p_list)

print(d)

Solution (Python):
S=list(input())
S=[int(i) for i in S]
n=len(S)
ans=0
if n!=1:
    for k in range(1,n+1):
        for j in range(n-k):
            ans+=S[k-1]*(10**j)*(2**(n-2-j))
        ans+=S[k-1]*(10**(n-k))*(2**(k-1))
    print(int(ans))
else:print(S[0])

Solution (Python):
from itertools import product
s=input()
N=len(s)
res = 0
gen = [0,1]
for ls in product(gen, repeat=N-1):
    tmp = int(s[0])
    tmpsum = 0
    for i in range(1,N):
        if ls[i-1]==0:
            tmp = 10*tmp + int(s[i])
        else:
            tmpsum += tmp
            tmp = int(s[i])
    tmpsum += tmp
    res += tmpsum
print(res)

Solution (Python):
import numpy as np
def g(a,s,n):
    if len(s)<=n:
        return 0
    elif n==0:
        return a+int(s)
    elif n==len(s)-1:
        y=a
        for i in range(len(s)):
            y+=int(s[i:i+1])
        return y
    else:
        y=0
        for i in range(1,len(s)):
            y+=g(a+int(s[:i]),s[i:],n-1)
        return y
def f(s):
    a=0
    for i in range(len(s)):
        b=g(0,s,i)
        a+=b
    return a
def main():
    S=str(input())
    print(f(S))

if __name__=='__main__':
    main()

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

print(ans)

Solution (Python):
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    S_arr = _in[0]  
    
    N = len(S_arr)-1
    cnt = 0
    for bit in range(1<<N):
        
        tmp = []
        pointa = 0
        for i in range(N):
            if bit&(1<<i):
                tmp.append(int(S_arr[pointa:i+1]))
                pointa = i+1
        else:
            tmp.append(int(S_arr[pointa:]))
        cnt += sum(tmp)
    
    print(cnt)

Solution (Python):
import sys
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue


ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)


MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

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

    ret = 0
    for n in range(1 << N):
        fml = ''
        for m in range(len(S)):
            fml += S[m]
            if n >> m & 1:
                 fml += '+'
        ret += eval(fml)
    print(ret)


if __name__ == '__main__':
    main()

Solution (Python):
S = input()

ans = 0
def dfs(i, s=''):
    global ans
    if i == len(S) - 1:
        ans += eval(s+S[-1])
        return
    dfs(i+1, s+S[i])
    dfs(i+1, s+S[i]+'+')
    
dfs(0)
print(ans)

Solution (Python):


import sys












from itertools import product, permutations  









def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())

    def calc_sep_add(s, pattern):
        n = len(s)
        pattern = [True] + pattern + [True]
        ans = 0
        i = 0
        for j in range(1, n+1):
            if pattern[j]:
                ans += int(s[i:j])
                i = j
        return ans
    
    s = input()
    n = len(s)
    ans = 0
    if n == 1:
        print(int(s))
    else:
        for pattern in product([True, False], repeat=n-1):
            
            
            ans += calc_sep_add(s, list(pattern))
        print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
import itertools

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    
    
    
    
    ss=readline().rstrip()
    p=len(ss)-1
    loops=[[0,1] for i in range(p)]
    ans=0
    for one in itertools.product(*loops):
        bef=-1
        for i in range(len(one)):
            if one[i]==1:
                ans+=int(ss[bef+1:i+1])
                bef=i
        ans+=int(ss[bef+1:])
    print(ans)
    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

Solution (Python):
def dfs(string, k):
  ans = 0
  if k == len(s):
    ans += sum(list(map(int, string.split('+'))))
  else:
    ans += dfs(string + s[k], k+1)
    if k != 0 and string[-1] != '+':
      ans += dfs(string + '+', k)
  return ans

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

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

for i in range(2 ** (N - 1)):
    s = S[:]
    for j in range(N):
        if i & 2**j:
            s[j] = s[j] + '+'
    
    ans += eval(''.join(s))
print(ans)

Solution (Python):
S = input()
cand = [0 for _ in range(2 **(len(S) - 1))]
for i in range(2 ** (len(S) - 1)):
    now = 0
    tmp = []
    for k in range(len(S) - 1):
        if i & (1 << k):
            tmp.append(S[now:k + 1])
            now = k + 1
    tmp.append(S[now:])
    for x in tmp:
        if x == '':
            continue
        else:
            cand[i] += int(x)
print(sum(cand))

Solution (Python):
from itertools import product

S=input()
N=len(S)
a=product(["+",""],repeat=N-1)
ans=0

for i,p in enumerate(a):
  bun = S[0]
  for j in range(N-1):
    bun += p[j]+S[j+1]
  nums=bun.split("+")
  tmp=0
  for num in nums:
    tmp+=int(num)
  ans+=tmp
print(ans)

Solution (Python):
from itertools import*
s = list(input())
l = len(s)
p = list(chain.from_iterable(zip(s, " "*l)))[:-1]
S = 0
for i in product([0,1], repeat=~-l):
    q = p[:]
    for k, j in enumerate(i):
        if j:
            q[k*2 + 1] = "+"
    S += eval("".join(q).replace(" ", ""))
print(S)

Solution (Python):
s = input()

n = len(s)-1
s = int(s)
ans = 0

for i in range(1 << n):
    num = s
    c = 1
    for j in range(n):
        if i >> j & 1:
            ans += num % (10**c)
            num //= (10**c)
            c = 1
        else:
            c += 1
    ans += num

print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]



import itertools 

S = sys.stdin.readline().rstrip()
S_int = list(map(int, list(S)))
N = len(S)

if N==1:
    print(S)
    exit()

cnt = 0
for l in list(itertools.product([0, 1], repeat=N-1)):
    tmp = S_int[0]
    for i, kigo in enumerate(l):
        if kigo == 1:
            cnt += tmp
            tmp = S_int[i+1]
        else:
            tmp = tmp * 10 + S_int[i+1]
    cnt += tmp

print(cnt)

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]



import itertools 

S = sys.stdin.readline().rstrip()
S_int = list(map(int, list(S)))
N = len(S)
cnt = 0

if N==1:
    print(S)
    exit()

for l in list(itertools.product([0, 1], repeat=N-1)):
    if l[0] == 0:
        tmp = S_int[0]
    else:
        tmp = 0
        cnt += S_int[0]

    for i, kigo in enumerate(l):
        if kigo == 1:
            cnt += tmp
            tmp = S_int[i+1]
        else:
            tmp = tmp * 10 + S_int[i+1]
    cnt += tmp

print(cnt)

Solution (Python):
s = input()
n = len(s)
sums = 0
for i in range(2 ** (n - 1)):
    plus = []
    for j in range(n - 1):
        if i & (1 << j):
            plus.append(j)
    numbers = []
    prev = -1
    if len(plus) == 0:
        numbers.append(int(s))
    else:
        for p in plus:
            if prev == -1:
                numbers.append(int(s[:p + 1]))
            else:
                numbers.append(int(s[prev + 1: p + 1]))
            prev = p
        numbers.append(int(s[prev+1:]))
    sums += sum(numbers)
print(sums)

Solution (Python):
def main():
    s = input()
    n = len(s)
    ans = 0
    for i in range(n + 1):
        for j in range(i + 1, n + 1):
            x = int(s[i:j])
            p = 2 ** max(0, i - 1)
            q = 2 ** max(0, n - j - 1)
            ans += x * p * q

    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    s = str(input())
    n = len(s)
    ans = 0
    for i in range(n + 1):
        for j in range(i + 1, n + 1):
            x = int(s[i:j])
            p = 2 ** max(0, i - 1)
            q = 2 ** max(0, n - j - 1)
            ans += x * p * q

    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    s = str(input())
    n = len(s)
    ans = 0
    for i in range(n + 1):
        for j in range(i + 1, n + 1):
            x = int(s[i:j])
            p = 2 ** max(0, i - 1)
            q = 2 ** max(0, n - j - 1)
            ans += x * p * q

    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    s = input()
    n = len(s)
    ans = 0
    for i in range(n + 1):
        for j in range(i + 1, n + 1):
            x = int(s[i:j])
            p = 2 ** max(0, i - 1)
            q = 2 ** max(0, n - j - 1)
            ans += x * p * q

    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    s = input()
    n = len(s)
    ans = 0
    for i in range(n + 1):
        for j in range(i + 1, n + 1):
            x = int(s[i:j])
            p = 2 ** max(0, i - 1) * 2 ** max(0, n - j - 1)
            ans += x * p

    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
s = input()
le = len(s)-1
su = 0

for i in range(2**le):
  moji = s[0]
  for j in range(le):
    if (i>>j)&1:
      moji += '+'
    moji += s[j+1]
  su += eval(moji)
  
print(su)

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

for i in range(2**(n-1)):
    s_tmp = s
    nbin = str(bin(i))[2:]
    nbin = nbin.zfill(n-1)
    for j in range(len(nbin)-1, -1, -1):
        if nbin[j] == '1':
            s_tmp = s_tmp[:j+1] + '+' + s_tmp[j+1:]

    ans += eval(s_tmp)
print(ans)

Solution (Python):
def calc(n):
    if n <= 1:
        return 1
    else:
        return 2 ** (n - 1)


def solution(s):
    n = len(s)
    dp = [None for i in range(len(s))]
    cnt = 0
    for i in range(n):
        a = s[:i]
        b = s[i:]
        cnt += calc(len(a)) * int(b)
        cnt2 = 0
        for j in range(len(a)):
            c = a[:j]
            d = a[j:]
            cnt2 += calc(len(c)) * int(d)
            if len(c) == 1:
                cnt2 += int(c)
            elif len(c) > 1:
                cnt2 += dp[len(c)]
        dp[i] = cnt2
        cnt += dp[i]
    return cnt


print(solution(input()))