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()
n = len(s)

from itertools import product

ans = 0

for i in product([0, 1], repeat=n-1):
    ss = s
    num = 0
    for j in range(n-1):
        if i[j] == 1:
            num += int(ss[n-j-1:])
            ss = ss[:n-j-1]
    num += int(ss)
    ans += num

print(ans)

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    s = input()
    ans = 0
    for i in range(2 ** (len(s) - 1)):
        num = s[0]
        for j in range(len(s) - 1):
            if (i >> j) & 1:
                ans += int(num)
                num = ""
            num += s[j + 1]
        if len(num) != 0:
            ans += int(num)
    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):





import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *


BUFSIZE = 8192

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

def main():
    s=str(input())
    d=[int(x) for x in s[::-1]]
    cnt=[2**(len(s)-1)]
    ans=0
    for i in range(len(d)):
        if i!=0:
            cnt[-1]=cnt[-1]//2
            cnt.append(cnt[-1])
        for j in range(len(cnt)):
            ans+=d[i]*(10**j)*(cnt[j])
    print (ans)
if __name__ == "__main__":
    main()

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()
l = len(s)
ans = 0
for i in range(2 ** (l-1)):
    tmp = ''
    sum = 0
    for j in range(l-1):
        tmp += s[j]
        if i >> j & 1:
            sum += int(tmp)
            tmp = ''
    sum += int(tmp + s[-1])

    ans += sum
print(ans)

Solution (Python):
import copy

s=list(input())
a=[]
for i in range(len(s)):
    a.append(s[i])
    if i !=len(s)-1:
        a.append("")

ans=0

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

print(ans)

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

Solution (Python):
def dfs(i, f):
    if i == n - 1:
        return sum(list(map(int, f.split('+'))))

    return dfs(i + 1, f + a[i + 1]) + dfs(i + 1, f + '+' + a[i + 1])


a = input()
n = len(a)

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

Solution (Python):
s = input()
all_s = []
def ss(index, perm):
    if index == len(s):
        all_s.append(perm)
    else:
        perm1 = [i for i in perm]
        perm1[-1] += s[index]
        ss(index+1, perm1)

        perm2 = [i for i in perm]
        perm2.append(s[index])
        ss(index+1, perm2)

ss(1, [s[0]])
all_sum = 0
for way in all_s:
    tmp = 0
    for n in way:
        tmp += int(n)
    all_sum += tmp
print(all_sum)

Solution (Python):
a = input()

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

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

print(ans)

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 & (1<<j):
      f += '+'
    f += s[j+1]
    
  ans += sum(map(int, f.split('+')))
  
print(ans)

Solution (Python):
from itertools import product

S=input()
N=len(S)
S2=S[0]
for i in range(N-1):
  S2 += '{}'+S[i+1]

ans=0
for p in product(['','+'],repeat=N-1):
  ans += eval(S2.format(*p))
  
print(ans)

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 & (1<<j):
      f += '+'
    f += s[j+1]
    
  ans += sum(map(int, f.split('+')))
  
print(ans)

Solution (Python):
s = input()
L = []
sigma = 0
def sprit_sum(string, sprit, num):
    global sigma
    for i in range(1,len(string)+num-sprit):
        str_front = string[:i]
        str_back = string[i:]
        L.append(int(str_front)) 
        if num < sprit:
            sprit_sum(str_back, sprit, num+1)
        else:
            L.append(int(str_back))
            for x in L:
                sigma += x
            L.pop()
        L.pop()
        
for j in range(len(s)):
    sprit_sum(s, j+1, 1)
sigma += int(s)
print(sigma)

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())


def main():
    s= input()
    n = len(s)
    ans = 0
    for i in range(1<<(n-1)):
        idx = [0]
        for j in range(n-1):
            if (i>>j)&1:
                idx.append(j+1)
        idx.append(n)
        for j in range(1, len(idx)):
            ans += int(s[idx[j-1]:idx[j]])
    print(ans)


if __name__ == '__main__':
    main()

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

print(sum(map(int,ans.split())))

Solution (Python):
S = input()
l = len(S)
ans = 0
for i in range(l):
    for j in range(i+1,l+1):
        temp = int(S[i:j])
        ans += temp * max(1,pow(2,i-1)) * max(1,pow(2,l-j-1))
print(ans)

Solution (Python):
import sys
import math
import copy
import heapq
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
sys.setrecursionlimit(1000000)


input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD

def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD

def fact_and_inv(SIZE):
    inv = [0] * SIZE  
    fac = [0] * SIZE  
    finv = [0] * SIZE  
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv

def renritsu(A, Y):
    
    
    
    A = np.matrix(A)
    Y = np.matrix(Y)
    Y = np.reshape(Y, (-1, 1))
    X = np.linalg.solve(A, Y)

    
    return X.flatten().tolist()[0]

class TwoDimGrid:
    
    def __init__(self, h, w, wall="
        self.h = h
        self.w = w
        self.size = (h+2) * (w+2)
        self.wall = wall
        self.get_grid()
        

    def get_grid(self):
        grid = [self.wall * (self.w + 2)]
        for i in range(self.h):
            grid.append(self.wall + getS() + self.wall)

        grid.append(self.wall * (self.w + 2))
        self.grid = grid
    def init_cost(self):
        self.cost = [INF] * self.size

    def pos(self, x, y):
        
        return y * (self.w + 2) + x
    def getgrid(self, x, y):
        return self.grid[y][x]
    def get(self, x, y):
        return self.cost[self.pos(x, y)]
    def set(self, x, y, v):
        self.cost[self.pos(x, y)] = v
        return
    def show(self):
        for i in range(self.h+2):
            print(self.cost[(self.w + 2) * i:(self.w + 2) * (i+1)])
    def showsome(self, tgt):
        for t in tgt:
            print(t)
        return
    def showsomejoin(self, tgt):
        for t in tgt:
            print("".join(t))
        return

    def search(self):
        grid = self.grid
        move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
        move_eight = [(0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
        
        
        
        
        


def dfs(S):
    ret = int(S)
    for i in range(len(S)-1):
        ls = S[:i+1]
        rs = S[i+1:]
        ret += dfs(rs)
        ret += int(ls) * 2 ** (len(rs) - 1)

    return ret

def solve():
    print(dfs(getS()))
def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    
    solve()

Solution (Python):
from functools import reduce

def original_sum(X, init):
    goukei = 0
    if(len(X) == 0):
        
        
        return sum(init)
    else:
        for i in range(len(X)):
            lstm = init.copy()
            
            num = int(reduce(lambda x, y: x + y, [str(x) for x in X[0:i+1]]))
            
            
            lstm.append(num)
            Y = X[i+1:len(X)].copy()
            
            
            goukei = goukei + original_sum(Y, lstm)
            
                
            

    return goukei


number = list(input())
init = []
print(original_sum(number, init))

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):
s = input()
ans = ''
for i in range(1 << (len(s) - 1)):
    ans += s[0]
    for j in range(len(s) - 1):
      if i >> j & 1:
        ans += ' '
      ans += s[j+1]
    ans += ' '
print(sum(map(int, ans.split())))

Solution (Python):
s = input()

ans = 0

for i in range(1<<(len(s)-1)):
    t = list(s)
    for b in range(len(s)-1):
        if((i>>b)&1):
            t[b] = t[b] + '+'
    ans += eval(''.join(t))
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):
N = str(int(input()))
total = 0
l = len(N)-1
if l == 0:
    print(N)
else:
    for i in range(2**l):
        b = format(i, '0'+str(l)+'b')
        subtotal = 0
        s = N[0]
        for j in range(len(b)):
            if int(b[j]):
                subtotal += int(s)
                s = N[j+1]
            else:
                s += N[j+1]

        subtotal += int(s)
        total += subtotal

    print(total)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
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 LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

s=SI()
ans=0
for b in range(1<<(len(s)-1)):
    f=""
    for i,c in enumerate(s):
        f+=c
        if b>>i&1:f+="+"
    ans+=eval(f)
print(ans)

Solution (Python):
s = input()

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

Solution (Python):
import itertools


def f(A):
    A = A[::-1]
    ret = 0
    for c, a in enumerate(A):
        ret += int(a) * 10 ** int(c)

    return ret


S = input()
ans = f(S)


for n in range(1, len(S)):
    for k in itertools.combinations(range(1, len(S)), r=n):
        st = 0
        q = 0
        for i in k:
            q += f(S[st:i])
            st = i
        q += f(S[st:])
        ans += q

print(ans)

Solution (Python):
import itertools


def f(A):
    A = A[::-1]
    ret = 0
    for c, a in enumerate(A):
        ret += int(a) * 10 ** int(c)

    return ret


S = input()
ans = f(S)


for n in range(1, len(S)):
    for k in itertools.combinations(range(1, len(S)), r=n):
        st = 0
        q = 0
        for i in k:
            q += f(S[st:i])
            st = i
        q += f(S[st:])
        ans += q

print(ans)

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

result = 0


for i in  range(2**(len(s)-1)):
    b = []
    x = 0
    for j in range(len(s)-1):
        if ((i >> j) & 1):
            b.append(s[x:j+1])
            x = j+1
    b.append(s[x:len(s)])
    for k in b:
        result += int(k)
            
print(result)

Solution (Python):
import itertools

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

for lst in itertools.product(range(2),repeat=n):
  x=s[0]
  for i in range(n):
    if lst[i]==0:
      x+=s[i+1]
    else:
      x=int(x)
      ans+=x
      x=s[i+1]
    
  x=int(x)
  ans+=x
      
print(ans)

Solution (Python):
from itertools import product

S=input()
tf_li=list(product([True,False],repeat=len(S)-1))
ans=0
for x in tf_li:
  formula=S[0]
  for i in range(len(S)-1):
    if x[i]==False:
      formula+="+"
    formula+=S[i+1]
  ans+=eval(formula)
print(ans)

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

Solution (Python):
S = input()


r = 0

s = len(S) - 1

for i in range(2 ** s):
    bit = []
    for j in range(s):
        if (i >> j) & 1:
            bit.append(j+1)

    for o in range(len(bit)):
        if o == 0:
            r += int(S[0: bit[o]])
        else:
            r += int(S[bit[o - 1] : bit[o]])
            
    if len(bit) == 0:
        r += int(S)
    else:
        r += int(S[bit[-1] :])
        
print(r)

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):
def rek(erg, rest):
    if not rest:
        return erg
 
    p = []
 
    for i in erg:
        p.append(i+"+"+rest[0])
        p.append(i+rest[0])
 
    return rek(p, rest[1:])
 
 
a = input()
 
erg = 0
comb = rek([a[0]], a[1:])
 
for i in comb:
    erg += eval(i)
 
print(erg)

Solution (Python):
from itertools import product
S = input()
A = ("+", "")
print(sum(eval("".join([s+i for s, i in zip(S, I)]+[S[-1]]))\
         for I in product(A, repeat=len(S)-1)))

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

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

print(ans)

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

N = len(S)-1

def calc(S, bit):
    retval = 0
    l = 0
    for i in range(N):
        if ((bit >> i) & 1):
            retval += int(S[l:i+1])
            l = i+1
    retval += int(S[l:])
    return retval 

ret = 0
for i in range(2 ** N):
    ret += calc(S, i)

print(ret)

Solution (Python):
import itertools

S = input()


def calculate(s):
    arr = list(s)

    totalLength = len(s)

    spliteIndexes = [i for i in range(1,totalLength)]

    result = 0
    for i in range(1, totalLength):
        for item in itertools.combinations(spliteIndexes, i):
            ttr = [0]
            ttr.extend(list(item))
            ttr.append(totalLength)


            for i in range(len(ttr) - 1):
                result += int("".join(arr[ttr[i]:ttr[i+1]]))
    print(result + int(s))


calculate(S)

Solution (Python):
s = input()
l = len(s)
ans = 0
for i in range(l):
  a = max(0,i-1)
  ans += sum([int(s[i:j])*(1<<a)*(1<<max(0,l-j-1)) for j in range(i+1,l+1)])
print(ans)

Solution (Python):
s = input()
l = len(s)
def dfs(n):
  if n == l:
    return [0]
  ret = []
  for i in range(n+1,l+1):
    ret += [int(s[n:i])+j for j in dfs(i)]
  return ret
print(sum(dfs(0)))

Solution (Python):
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

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

Solution (Python):
s = list(input())
digits = len(s)
lists = []
answer = 0

for bit in range(2 ** (digits - 1)):
    formula = s[0]
    for i in range(digits - 1):
        if ((bit >> i) & 1):
            formula += "+"
        formula += s[i + 1]
    lists.append(formula)

for i in range(len(lists)):
    answer += eval(lists[i])
print(answer)

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

Solution (Python):
from scipy.special import comb
import numpy as np
def get_keta_plusnum(n,m):
    if n<=m:
        print("error")
    else:
        hit_num=[0 for i in range(n)]
        for keta in range(1,n-m+1):
            for j in range(n+1-keta):
                if j!=n-keta:
                    hit_num[j]+=10**(keta-1)*comb(n-1-keta,m-1)
                else:
                    hit_num[j]+=10**(keta-1)*comb(n-keta,m)
    return np.array(hit_num,dtype="int64")

s=input()
n=len(s)

hit_num=np.array([0 for i in range(n)])

for m in range(n):
    hit_num+=get_keta_plusnum(n,m)
s=np.array([int(i) for i in s])
print(np.dot(hit_num,s))

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):
import itertools
import bisect
S=input()
T = []
M = int(S)
for i in S:
    T.append(int(i))
    T.append(0)
T.pop()
s = len(S)
for i in range(1,s):
    a = itertools.combinations(list(range(1,2*s-1,2)),i)
    for j in a:
        U = ""
        for k in range(2*s-1):
            if k in j:
                U += "+"
            else:
                U += str(T[k])
        U = U.replace("0","")
        M += eval(U)
print(M)

Solution (Python):
s = str(input())
n = len(s)
k = 0
ls =[]
for i in range(2**(n-1)):
    a = []
    for j in range(n-1):
        if (i >> j)&1:
            a.append(j)
    ls.append(a)
for p in range(len(ls)):
    l = list(s)
    for q in ls[p][::-1]:
        l = l[:q+1] + ["+"] + l[q+1:]
    b = eval("".join(l))
    k += b
print(k)

Solution (Python):
S = list(input())
N = len(S)
for i in range(N):
    S[i] = ord(S[i]) - ord('0')

S.append(0)

ans = 0
for i in range(1<<(N-1)):
    prev = 0
    for k in range(N):
        prev = prev * 10 + S[k]
        if (i & (1<<k)) > 0:
            ans += prev
            prev = 0
    ans += prev
print(ans)

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

from itertools import product

def divid_S(p):
    S_=[]
    p_s=0
    p_e=0

    for p_idx in range(len(p)):
        if p[p_idx] == 1:
            p_e = p_idx+1
            S_.append(S[p_s:p_e])
            p_s = p_idx+1

    S_.append(S[p_e:])
    
    return S_

def get_one_ans(S_):
    ans=0
    for s_ in S_:
        ans+=int(s_)
        
    return ans

ans = 0
for p in product(range(2),repeat=L):
    S_=divid_S(p)
    ans += get_one_ans(S_)
    
print(ans)

Solution (Python):
def f(s):
    if len(s)==1:
        return [s]
    l=[]
    for i in f(s[1:]):
        l.append(s[0]+"+"+i)
        l.append(s[0]+i)
    return l
print(sum(map(eval,f(input()))))

Solution (Python):
import copy
s=input()
def dfs(i,f,last):
    ans=0
    if i==len(s):
        for j in range(len(s)):
            ans+=int(f[j])
        return ans
    else:
        f1=copy.deepcopy(f)
        f2=copy.deepcopy(f)
        f1[last]+=s[i]
        ans+=dfs(i+1,f1,last)
        f2[last+1]+=s[i]
        ans+=dfs(i+1,f2,last+1)
        return ans
f=["0"]*len(s)
f[0]+=s[0]
print(dfs(1,f,0))

Solution (Python):
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

def main():
  s = str(input())
  ans = 0
  for i in range(2**(len(s)-1)):
    bits = Base_10_to_n(i, 2)
    bits = bits.zfill(len(s)-1)
    now = 0
    for j, bit in enumerate(bits):
      if bit == '1':
        ans += int(s[now:j+1])
        now = j + 1
      if j == len(s)-2:
        ans += int(s[now:])
  if ans == 0:
    ans += int(s)
  print(ans)
  
if __name__ == "__main__":
  main()

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

def tolist(sign):
    
    ans = [int(s[0])]
    for i in range(len(sign)):
        if sign[i]: 
            ans.append(int(s[i+1]))
        else:
            prev = ans.pop()
            ans.append(int(str(prev)+s[i+1]))
    return ans

ans = 0
for sign in product([True, False], repeat=len(s)-1):
    ans+=sum(tolist(sign))
print(ans)

Solution (Python):
s = input()
ans = 0
n = len(s)
m = n-1
t= s
for mask in range(0 , (1<<(n))):
	res=0
	cur=0
	for j in range(0 , n):
		if mask&(1<<j):
			res = res+cur
			cur = (ord(t[j])-ord('0'))
		else:
			cur = cur*10+(ord(t[j])-ord('0'))
	
	ans = ans+res+cur
print(ans//2)

Solution (Python):
S = input()

sum = 0

for n in range(1<<(len(S)-1)): 
  i_before = 0
  for i in range(len(S)-1): 
    if n & (1<<i): 
      sum += int(S[i_before:i+1])
      i_before = i+1
  sum += int(S[i_before:]) 

print(sum)

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

from itertools import product

P=product(range(2),repeat=L-1)

ans=0
for p in P:
    s=0
    temp=S[0]
    for i in range(L-1):
        if p[i]==1:
            s+=int(temp)
            temp=S[i+1]
        else:
            temp+=S[i+1]
    s+=int(temp)
    ans+=s
print(ans)

Solution (Python):
S = input()
n = len(S)
ans = 0
for i in range(2**(n-1)):
    B = bin(i)[2:].zfill(n)
    t = 0
    for j in range(n):
        if B[j]=='0':
            t = t*10+int(S[j])
        else:
            ans += t
            t = int(S[j])
    ans += t
print(ans)

Solution (Python):


def main():
    S = input()
    N = len(S) -1
    
    ans = 0
    for i in range(1<<N):
        su = [0, N+1]
        for j in range(N):
            if i & (1<<j) == 0: continue
            su.append(j+1)
            su.sort()
            
        for k in range(len(su)-1):
            ans += int(S[su[k]:su[k+1]])
    
    return ans

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

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

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

Solution (Python):
N = str(input())
length = len(N)

ans = 0
for i in range(2**(length-1)):
  temp = ""
  for j in range(length-1):
    if (i>>j)&1 == 1:
      temp += N[j]+"+"
    else:
      temp += N[j]
  temp += N[-1]
  kotae = eval(temp)
  ans += kotae
print(ans)

Solution (Python):
from itertools import product
S = input().strip()
N = len(S)
cnt = 0
for x in product((0,1),repeat=N-1):
    y = ""
    for i in range(N-1):
        y += S[i]
        if x[i]==1:
            y += "+"
    y += S[N-1]
    cnt += eval(y)
print(cnt)

Solution (Python):
def base10toN(num, base):
    converted_string, modstring = "", ""
    currentnum = num
    if not num:
        return '0'
    while currentnum:
        mod = currentnum % base
        currentnum = currentnum // base
        converted_string = chr(48 + mod + 7*(mod > 10)) + converted_string
    return converted_string
s=input()
n=len(s)
ans=0
for i in range(2**(n-1)):
  t=base10toN(i,2)
  r=[]
  for j in range(n-1-len(t)):
    r.append('0')
  for j in range(len(t)):
    r.append(t[j])
  k=[]
  k.append(s[0])
  for j in range(n-1):
    if r[j]=='0':
      k.append(s[j+1])
    else:
      ans+=int(''.join(k))
      k=[]
      k.append(s[j+1])
  ans+=int(''.join(k))
print(ans)

Solution (Python):
from copy import deepcopy
s = input()
n = len(s)
partitions = []

for i in range(1<<(n-1)):
    p = []
    k = 0
    for j in range(n):
        if i & 2**j:
            
            p.append(int(s[k:j+1]))
            k = j+1
    p.append(int(s[k:n]))
    partitions.append(p)

print (sum([sum(p) for p in partitions]))

Solution (Python):
import copy
s=list(input())
mylist=[""]*(len(s)+(len(s)-1))
for i in range(len(s)):
    mylist[2*i]=s[i]
ans=0
for i in range(2**(len(s)-1)):
    l=copy.deepcopy(mylist)
    for j in range(len(s)-1):
        if (i>>j&1):
            l[2*j+1]="+"
    ans+=eval("".join(l))
print(ans)

Solution (Python):
import copy
s=list(input())
mylist=[""]*(len(s)+(len(s)-1))
for i in range(0,len(s)):
    mylist[2*i]=s[i]
ans=0
for i in range(2**(len(s)-1)):
    l=copy.deepcopy(mylist)
    for j in range(len(s)-1):
        if (i>>j&1):
            l[2*j+1]="+"
    ans+=eval("".join(l))
print(ans)

Solution (Python):
import sys
from functools import lru_cache

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()
    S = list(map(int, S))
    N = len(S)

    ans = 0
    for bit in range(1 << (N - 1)):
        n = 0
        for i, s in enumerate(S):
            n = 10 * n + s
            if bit & (1 << i):
                ans += n
                n = 0
        ans += n

    print(ans)
    return


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from functools import lru_cache

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()
    S = list(map(int, S))
    N = len(S)

    ans = 0
    for bit in range(1 << (N - 1)):
        n = 0
        for i, s in enumerate(S):
            n += s
            if bit & (1 << i):
                ans += n
                n = 0
            else:
                n *= 10
        ans += n // 10

    print(ans)
    return


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from functools import lru_cache

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()
    N = len(S)

    ans = 0
    for bit in range(1 << (N - 1)):
        vec = []
        for i, s in enumerate(S):
            vec.append(s)
            if bit & (1 << i):
                vec.append('+')
        ans += sum(map(int, ''.join(vec).split('+')))

    print(ans)
    return


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from functools import lru_cache

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()
    N = len(S)

    @lru_cache(maxsize=None)
    def rec(i):
        if i == N:
            return 0

        ans = 0
        for j in range(i + 1, N + 1):
            ans += int(S[i:j]) * pow(2, max(N - j - 1, 0)) + rec(j)

        return ans

    print(rec(0))
    return


if __name__ == '__main__':
    main()

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

Solution (Python):
S = input()
n = len(S)-1
ans = 0
for i in range(1 << n):
    p = 0
    for j in range(n):
        if i >> j & 1 == 0:
            continue
        else:
            ans += int(S[p:j+1])
            p = j+1
    ans += int(S[p:])

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[1+j]
  a+=eval(T)

print(a)

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

ans=0
for ib in range(1<<(keta-1)):
    f = s
    cnt = 1
    for i in range(0, keta):
        if (ib >> i & 1):
            
            f = f[0:i+cnt]+"+"+f[i+cnt:]
            cnt += 1
    
    
    cnt = list(map(int, f.split("+")))
    ans += sum(cnt)
print(ans)