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):
def main():
    S = list(map(int,input()))
    n = len(S)

    ans = 0
    for i in range(2**(n-1)):
        b = 0
        t = 0
        for j in range(n):
            if (j < (n-1) and i >> j &1) or j == n-1:
                for k,s in enumerate(S[b:j+1]):
                    t += s * 10**(j-b-k)

                b = j+1
        ans += t

    print(ans)
    
main()

Solution (Python):
S=input()
l=len(S)
ans=int(S[-1])*2**(l-1)
for i in range(1,l):
    a=int(S[-i-1])
    for j in range(i+1):
        ans+=a*10**j*2**(l-min(j,i-1)-2)
print(ans)

Solution (Python):
s = input()
s_len = len(s)
ans = 0
for i in range(1<<s_len-1):
    dum = s[0]
    for j in range(1,s_len):
        if (i >> (j-1))%2 == 1:
            dum += "+"
        dum += s[j]
    ans += sum(map(int,dum.split("+")))
print(ans)

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

print(ans)

Solution (Python):
S = input()

num = len(S)

ans = 0

for bit in range(2**(num-1)):
  f = S[0]
  for i in range(num-1):
    if (bit >> i) & 1:
      f += '+'
    f += S[i+1]
  ans += sum(map(int,f.split('+')))

print(ans)

Solution (Python):
s = input()
s = s[::-1]
ans = 0

for mask in range(1 << (len(s) - 1)):
    rate = 1
    for i in range(len(s)):
        ans += int(s[i]) * rate
        if mask >> i & 1 == 1:
            rate = 1
        else:
            rate *= 10

print(ans)

Solution (Python):
S=input()
Len=len(S)-1
ans=0
for i in range(1<<Len):
  Tmp=S[0]
  cnt=0
  for j in range(Len):
    if 1&(i>>j):
      Tmp+='+'
      Tmp+=S[j+1]
    else:
      Tmp+=S[j+1]
  cnt=eval(str(Tmp))
  ans+=cnt
print(ans)

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

Solution (Python):
def h(A,B):
    T=""
    for i in range(len(B)):
        T+=A[i]+B[i]
    return T+A[-1]

from itertools import product
S=input()

P=product(["","+"],repeat=len(S)-1)

K=0
for p in P:
    K+=eval(h(S,p))
print(K)

Solution (Python):
def bfs(s: str, n: int, i: int, j: int, k: int):
    return k+int(s[j:]) if i==n-1 else bfs(s,n,i+1,i+1,k+int(s[j:i+1]))+bfs(s,n,i+1,j,k)

s=input()
n=len(s)
print(bfs(s,n,0,0,0))

Solution (Python):
def dfs(s: str, n: int, i: int, x: str):
    return sum(list(map(int,x.split('+')))) if i==n-1 else dfs(s,n,i+1,x+s[i+1])+dfs(s,n,i+1,f'{x}+{s[i+1]}')

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

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

Solution (Python):
import sys
import itertools

import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines



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

ans = 0
for i in range(1 << N):
    exp = ""
    for j in range(len(S)):
        exp += S[j]
        if i & 1 << j > 0:
            exp += "+"
    ans += sum(map(int, exp.split("+")))
print(ans)

Solution (Python):
from itertools import product

S = input()
ans = 0
for i in product([0,1],repeat=len(S)-1):
    check = S[0]
    for s,flag in zip(S[1:],i):
        if flag:
            check += '+' + s
        else:
            check += s
    ans += eval(check)
print(ans)

Solution (Python):
import sys

def main(s):
    intl=[int(w) for w in s]
    intl.reverse()
    ps=0
    for i in range(2**(len(s)-1)):
        l=[x for x in intl]
        j=i
        e=0
        for k in range(1,len(s)):
            e=(e+1)*(j&1)
            l[k]=l[k]*(10**e)
            j>>=1
        ps=ps+sum(l)
    return ps

s=sys.stdin.readline().strip()

print(main(s))

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):
import sys
import itertools

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    S = in_s()
    N = len(S)

    comb = itertools.product([0, 1], repeat=N - 1)
    ans = 0

    for com in comb:
        now = S[0]
        ts = 0
        for i, f in enumerate(com):
            i = i + 1
            if f == 0:
                now += S[i]
            else:
                ts += int(now)
                now = S[i]
        else:
            ts += int(now)

        
        ans += ts

    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
S = input()

res = 0
for bit in range(1<<len(S)-1):
  last = 0  
  for i in range(len(S)-1):
    if bit & (1<<i):
      res += int(S[last:i+1])
      
      last = i + 1
  res += int(S[last:])
  
  
print(res)

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

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

for i in range(1<<len(S)-1):
    func = S[0]
    a = 0
    for j in range(len(S)-1):
        if (i>>j)&1 == 1:
            func += "+"
        func += S[j+1]
    a = eval(func)
    ans += a
    
print(ans)

Solution (Python):
from itertools import product

s = input()

ans = 0
for l in product([0, 1], repeat=len(s) - 1):
    num = s[0]
    for i, bit in enumerate(l):
        if bit == 0:
            num = ''.join([num, s[i + 1]])
        elif bit == 1:
            ans += int(num)
            num = s[i + 1]
    ans += int(num)
print(ans)

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

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

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

Solution (Python):
from itertools import product

s = input()
n = len(s)
ans = 0
for pluses in product((True, False), repeat=n - 1):
    current_continuous_num = s[0]
    current_sum = 0
    for idx, is_plus in enumerate(pluses):
        if is_plus:
            current_sum += int(current_continuous_num)
            current_continuous_num = s[idx + 1]
        else:
            current_continuous_num += s[idx + 1]
    ans += current_sum + int(current_continuous_num)
print(ans)

Solution (Python):
from itertools import product

s = input()

ans = 0

for i in product(["","+"], repeat=len(s)-1):
    str = ""
    for j in range(len(s)-1):
        str += s[j]
        str += i[j]
    str += s[-1]

    ans += eval(str)

print(ans)

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):
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
sum = 0;

for i in range(2**N):
    
    
    """
    例えば、3は011であり、この下から2ビット目は、0
    3を2ビット右シフトすると 0|11 となり0、1とのORをとりfalse
    """
    operator = [''] * N
    for n in range(N):
        if ((i>>n) & 1):
            operator[N-1-n] = '+'

    
    

    operator.append('')
    formula = ""

    for s, o  in zip(S, operator):
        formula += s + o
    
    sum += eval(formula)
print(sum)

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

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

Solution (Python):


import math

import itertools
from collections import deque
from collections import Counter




s=input()
n=len(s)
ans=0
ans+=int(s)
if n==1:
  print(ans)
  exit()
for i in s:
    ans+=int(i)
l=[i for i in range(n-1)]
for i in range(1,n-1):
    c=itertools.combinations(l,i)
    for p in c:
        pulus=set(list(p))
        z=0
        for j in range(n):
            ans+=int(s[n-1-j])*10**z
            if j != n-1 and n-2-j not in pulus:
                z+=1
            else:
                z=0
print(ans)

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

print(ans)

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

from itertools import product
bits=list(product([0,1], repeat=l-1))

ans=0
for bit in bits:
    tmp_s=s
    cnt=0
    for i in range(l-1):
        if bit[i]==1:
            tmp_s=tmp_s[:i+1+cnt]+'+'+tmp_s[i+1+cnt:]
            cnt+=1
    ans+=eval(tmp_s)

print(ans)

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

def dfs(i,f):
    if i==l-1:
        return eval(f)
    else:
        return dfs(i+1, f+s[i+1]) + dfs(i+1,f+'+'+s[i+1])

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

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

def dfs(i,f):
    if i==l-1:
        return eval(f)
    else:
        return dfs(i+1, f+s[i+1]) + dfs(i+1,f+'+'+s[i+1])

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

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

from itertools import product
bits=list(product([0,1], repeat=l-1))

ans=0
for bit in bits:
    tmp_s=s
    cnt=0
    for i in range(l-1):
        if bit[i]==1:
            tmp_s=tmp_s[:i+1+cnt]+'+'+tmp_s[i+1+cnt:]
            cnt+=1
    ans+=eval(tmp_s)

print(ans)

Solution (Python):
s = input()

from itertools import combinations
from collections import Counter

def split(s, pivot):
    split_ary = []
    st = 0
    for p in pivot:
        split_ary.append(s[st:p])
        st = p
    split_ary.append(s[st:])
    return split_ary

sub_ary = []
N = len(s)
for i in range(N):
    for sep_idx in combinations(range(1,N), i):
        sub_ary.extend(split(s, sep_idx))

c = Counter(sub_ary)
ans = 0
for k,cnt in c.items():
    ans += int(k) * cnt

print(ans)

Solution (Python):
import itertools
S = list(input())
set01 = list(itertools.product('01', repeat=(len(S)-1)))
S_01 = ['','+']
counter = 0
for i in range(len(set01)):
    SS = ""
    for j in range(len(S)-1):
        SS += S[j   ] + S_01[int(set01[i][j])]
    SS += S[-1]
    SS = "".join(SS)
    counter += eval(SS)
print(counter)

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 >>i) & 1:
           
            f += "+"
        f += s[i + 1]

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

print(ans)

Solution (Python):


s = input()

length = len(s)
if length == 1:
    print(s)
else:
    ans = 0
    for i in range(2 << length - 2):
        temp = []
        for j in range(length):
            t = (i >> j) & 1
            temp.append(s[j])
            if t:
                temp.append('+')
        ans += eval(''.join(temp))
    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])

def main():
    ans = dfs(0,S[0])
    print(ans)


if __name__ == '__main__':
    S = input()
    n = len(S)
    main()

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

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from itertools import product

    s = input()
    l = len(s) - 1
    ans = 0

    for bit in product(range(2), repeat=l):
        score = 0
        cur = ""
        for i, b in enumerate(bit):
            cur += s[i]
            if b:
                score += int(cur)
                cur = ""
        cur += s[-1]
        score += int(cur)
        ans += score

    print(ans)


if __name__ == '__main__':
    main()

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

ans = 0
for i in range(2 ** (l -1)):
    ans_sub = 0
    subst = s[0]
    for j in range(l-1):
        if(i>>j)&1:
            ans_sub += int(subst)
            subst = s[j+1]
        else:
            subst += s[j+1]
        if j ==l-2:
            ans_sub += int(subst)
    ans += ans_sub
if l == 1:
    print(int(s))
else:
    print(ans)

Solution (Python):
S = list(input())
s = []
q = 0
ans = 0
for i in S:
    s.append(int(i))
for i in range(2 ** len(s)):
    for i2 in range(len(s)):
        if i >> i2 & 1:
            ans += q
            q = s[i2]
        else:
            q *= 10
    ans += q
    q = 0
print(ans)

Solution (Python):
def calc(s):
    n = len(s)
    ans = 0
    for bit in range(1 << (n - 1)):
        ss = s[0]
        for i in range(n - 1):
            if bit & (1 << i):
                ss += '+'
            ss += s[i + 1]
        ans += eval(ss)
    return ans

s = str(input())
print(calc(s))

Solution (Python):
S=input()
if len(S)==1:
  print(S)
else:
  def bfs(i,j,k):
    if i==len(S)-1:
      return k+int(S[j:])
    return bfs(i+1,i+1,k+int(S[j:i+1]))+bfs(i+1,j,k)
  bns=bfs(0,0,0)
  print(bns)

Solution (Python):
import sys
from itertools import product

input = sys.stdin.readline
P = 10 ** 9 + 7


def main():
    S = input().rstrip()

    N = len(S)
    ans = 0
    for comb in product(["+", ""], repeat=N - 1):
        eq = S[0]
        for s, c in zip(S[1:], comb):
            eq = "".join([eq, c])
            eq = "".join([eq, s])
        ans += eval(eq)

    print(ans)


if __name__ == "__main__":
    main()

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


class Solver:
    def __init__(self):
        self.ans = 0

    def calc(self, cur: int, rest: str, pos: int):
        if not rest or len(rest) == pos:
            self.ans += cur + int(rest)
            return

        self.calc(cur + int(rest[:pos]), rest[pos:], 1)
        self.calc(cur, rest, pos + 1)


def main():
    S = input().strip()
    solve = Solver()
    solve.calc(0, S, 1)
    print(solve.ans)


if __name__ == "__main__":
    main()

Solution (Python):
from itertools import product

S = input()
N = len(S)
ans = 0
for opes in product(("", "+"), repeat=N - 1):
    eqn = "".join(s + o for s, o in zip(S[:-1], opes)) + S[-1]
    ans += sum(map(int, eqn.split("+")))
print(ans)

Solution (Python):
from itertools import product

S = input()
N = len(S)
ans = 0
for opes in product(("", "+"), repeat=N - 1):
    eqn = []
    for s, o in zip(S[:-1], opes):
        eqn += s + o
    eqn = "".join(eqn) + S[-1]
    ans += sum(map(int, eqn.split("+")))
print(ans)

Solution (Python):
from itertools import product

S = input()
N = len(S)
ans = 0
for opes in product(("", "+"), repeat=N - 1):
    eqn = []
    for s, o in zip(S[:-1], opes):
        eqn += s + o
    ans += eval("".join(eqn) + S[-1])
print(ans)

Solution (Python):
from copy import deepcopy
S = input()
n = len(S) - 1
C = 0
for bit in range(2 ** n):
    T = list(S)
    U = []
    for i in range(n + 1):
        U.append(T[i])
        if (bit & (1 << i)):
            U.append('+')
    V = ''
    for u in U:
        V += u
    C += eval(V)
print(C)

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

s = input()
n = len(s)

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

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)

S = s()
N = len(S)-1
ans = 0
for bit in range(1<<N):
    B = [(bit>>i)&1 for i in range(N)]
    start = 0
    for i in range(N):
        if B[i] == 1:
            ans += int(S[start:i+1])
            start = i+1
    ans += int(S[start:N+1])
print(ans)

Solution (Python):


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def debug(predicate, value):
    if predicate:
        print(value)
    return value


def solve():
    """
    OPT[i][j] : (count, all sum between i and j)
    OPT[i][j] = OPT[i][k]+S[k+1:j+1]
    """
    S = input().strip()
    N = len(S)
    OPT = [
        [0 for _ in range(N)] for _ in range(N)
    ]
    for length in range(N+1):
        for i in range(N-length):
            j = i+length
            OPT[i][j] = [1, int(S[i:j+1])]
            for l in range(i, j):
                OPT[i][j][0] += OPT[i][l][0]
                OPT[i][j][1] += OPT[i][l][1]+OPT[i][l][0]*int(S[l+1:j+1])
    return OPT[0][N-1][1]


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

Solution (Python):
S = input()
a=[""]*(len(S))
ans = 0
for n in range(len(S)):
  a[n] = S[n]
for n in range(2**(len(S)-1)):
  b=[""]*(len(S))
  c=""
  for m in range(len(S)-1):
    if n>>m & 1:
      b[m] = "+" 
  for p in range(len(S)):
    c += a[p]+b[p]
  ans += eval(c)
print(ans)

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

for i in range(2**(n-1)):
  op = []
  tmp = ""
  for j in range(n-1):
    if (i >> j) & 1:
      op.append("+")
    else:
      op.append("")
  op.append("")
  
  for num, sbl in zip(s, op):
    tmp += num + sbl
  a += eval(tmp)

print(a)

Solution (Python):
from collections import deque

s = input()

if len(s) == 1:
  print(s)
  exit()

lst = deque([[" "], ["+"]])
rlt = 0

while lst:
  sm = lst.pop()
  if len(sm) == len(s) - 1:
    now = int(s[0])
    for i in range(len(s) - 1):
      if sm[i] == '+':
        rlt += now
        now = int(s[i+1])
      else:
        now = now*10 + int(s[i+1])
    rlt += now
  else:
    als = sm+[" "]
    lst.append(als)
    als = sm+["+"]
    lst.append(als)
    
print(rlt)

Solution (Python):
def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    S = input()
    K = len(S)-1
    s = 0
    for pattern in range(2**K):
        tmp = S[0]
        for i in range(K):
            if (pattern>>i)&1:
                tmp += ' '
            tmp += S[i+1]
        s += sum(map(int, tmp.split()))
    print(s)
if __name__ == '__main__':
    main()

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
readline = sys.stdin.readline

S = readline().rstrip()

K = len(S) - 1
ans = 0
for i in range(2 ** K):
  f = S[0]
  for j in range(K):
    if (i >> j) & 1:
      f += "+"
    f += S[j + 1]
  ans += eval(f)
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):
import itertools


def m():
    S = input()
    ans = 0
    for i in range(len(S)):
        for item in itertools.combinations(range(len(S) - 1), i):
            if len(item) == 0:
                ans += int(S)
                continue
            ind = 0
            for j in item:
                ans += int(S[ind:j+1])
                ind = j+1
            ans += int(S[ind:])
    return ans


print(m())

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)):
  i=list(bin(i))[::-1]
  t=list(s)
  for j in range(len(i)-1,-1,-1):
    if i[j]=='1':
      t.insert(j+1,'+')
  t=''.join(t)
  ans+=eval(t)
print(ans)

Solution (Python):
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	s = S()
	total = int(s)
	s_list = [s[:i+1] + '+' + s[i+1:] for i in range(len(s)-1)]
	while s_list:
		new_s_list = []
		for s_tmp in s_list:
			total += eval(s_tmp)
			plus = s_tmp.rfind('+')
			if plus < len(s_tmp)-2:
				new_s_list += [s_tmp[:plus+i+2] + '+' + s_tmp[plus+i+2:] for i in range(len(s_tmp)-plus-2)]
		s_list = new_s_list.copy()
	print(total)


if __name__ == '__main__':
    main()

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

ans = 0
for bit in range(1<<(N-1)):
    formula = ""
    for i in range(N-1):
        if (bit >> i) & 1:
            k = "+"
        else:
            k = ""
        formula += S[i] + k
    formula += S[N-1]
    ans += eval(formula)
print(ans)

Solution (Python):
def rec(i, x):
    if i >= length:
        return sum(list(map(int, x.split("+"))))
    return rec(i + 1, x + s[i + 1]) + rec(i + 1, x + "+" + s[i + 1])


s = input()
length = len(s) - 1
print(rec(0, s[0]))

Solution (Python):
def solve(bit):
    nums = []
    i, j = 1, 0
    num = s[0]
    while i < len(s):
        if bit[j] == 1:
            nums.append(int(num))
            num = s[i]
        else:
            num += s[i]
        i += 1
        j += 1
    else:
        nums.append(int(num))
    return sum(nums)

s = str(input())
l = len(s)
ans = 0
for i in range(2**(l-1)):
    bit = [0] * (l - 1)
    for j in range(l-1):
        if ((i >> j) & 1):
            bit[j] = 1
    ans += solve(bit)
print(ans)

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


patterns = product([True, False], repeat=len(S)-1)

ans = 0
for ptn in patterns:
  ptn_idxs = [i for i, bl in enumerate(ptn) if bl]
  ptn_s = ''
  for i in range(len(S) - 1):
    ptn_s += S[i]
    if i in ptn_idxs:
      ptn_s += '+'
  ans += eval(ptn_s + S[-1])

print(ans)

Solution (Python):
s = input()
l = len(s)
res = 0
for pat in range(2 ** (l-1)):
    
    shiki = s[0]
    for i in range(l-1):
        if (pat >> i & 1) == 1:
            shiki += "+" + s[i+1]
        else:
            shiki +=  s[i+1]
    res += eval(shiki)
    
print(res)

Solution (Python):

s = input()
slen = len(s) - 1
sum = 0
for i in range(2 ** (slen)):
    oplist = [""]*(len(s)-1)
    for j in range(slen):  
        if ((i >> j) & 1):  
            oplist[len(s) - 2 - j] = "+"

    siki = ""
    for i in range(len(oplist)):
        siki += s[i] + oplist[i]
    siki += s[-1]
    sum += eval(siki)

print(sum)

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

ans = 0
N = len(S)

for i in range(2**(N-1)):
  pattern = bin(i)[2:].zfill((N-1))
  formula = ''
  for j in range(N):
    mark = ''
    if j < N-1:
      if pattern[j] == '1':
        mark = '+'
    formula += S[j]+mark
  ans += eval(formula)

print(ans)

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

ans = 0
N = len(S)
for i in range(2**N):
  pattern = bin(i)[2:].zfill(N)
  formula = ''
  for j in range(N):
    mark = ''
    if pattern[j] == '1' and j < N-1:
      mark = '+'
    formula += S[j]+mark
  ans += eval(formula)

print(ans//2)

Solution (Python):
import sys
import itertools

s=input()

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


S=0

for i in itertools.product([0,1],repeat=len(s)-1):
    sm=0
    st=0
    for j in range(len(i)):
        if i[j]==1:
            sm+=int(s[st:j+1])
            st=j+1
            if j==len(s)-2:
                sm+=int(s[j+1:len(s)])
        elif j==len(s)-2:
            sm+=int(s[st:len(s)])
    S+=sm

print(S)

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

s = 0
for i in range(2**n):
    A = ['+' if (i>>j) & 1 else '' for j in range(n)]
    T = S[0]
    for j in range(n):
        T += A[j]
        T += S[j+1]
    T = ''.join(T)
    s += eval(T)
print(s)

Solution (Python):
def resolve():
    s = input()
    ans = 0
    for i in range(2**(len(s)-1)):
        test = []
        cal = ""
        for j in range(len(s)-1):
            test.append((i>>j) & 1)
        for j in range(len(test)):
            if test[j] == 0:
                cal = cal + s[j]
            else:
                cal += s[j] + "+"
        cal += s[-1]
        ans += eval(cal)
    print(ans)
resolve()

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

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

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

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

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    S = SI()
    l = len(S)
    ans = 0
    for case in range(2**(l-1)):
        j = 0
        N = int(S)
        ans += N % 10
        for i in range(l-1):
            if (case >> i) & 1:
                j = 0
            else:
                j += 1
            ans += int(S[-(i+2)]) * 10**j

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
n = input()

N = len(n)-1

i = 0
ans = 0
for i in range(2**N):
    
    n2 = n
    for j in range(N):
        if(i>>j)&1:
            n2= n2[:(N-j)] + " " + n2[N-j:]
            
    
    n3 = n2.split()
    for k in range(len(n3)):
        ans += int(n3[k])
    
print(ans)

Solution (Python):
import sys


import math
import collections

import bisect
import itertools
import fractions

import copy
import heapq
import decimal

import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))





def main():
    s = list(input())

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

        tmp_ans = 0
        for ti in tmp:
            tmp_ans += int(ti)
        ans.append(tmp_ans)

    print(sum(ans))


if __name__ == '__main__':
    main()

Solution (Python):
S = input()

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

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

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

ans = 0
for p in pattern:
    sum = s[0]
    for i in range(n - 1):
        if p[i]:
            sum += '+'
        sum += s[i + 1]
    ans += eval(sum)

print(ans)

Solution (Python):
S = list(input())
l = len(S)
sub = []
for i in range(2 ** (l-1)):
    chk = []
    for j in range(l):
        chk.append(S[j])
        if i >> j & 1:
            chk.append('+')
    sub.append(''.join(chk))
ans = [eval(a) for a in sub]
print(sum(ans))

Solution (Python):
import itertools
n=list(str(input()))
ans=0
lst=list(itertools.product(["", "+"], repeat=(len(n)-1)))
for i in range(len(lst)):
  just=""
  for k in range(len(n)-1):        
    just+=n[k]+str(lst[i][k])
  just+=n[len(n)-1]
  ans+=eval(just)
print(ans)

Solution (Python):
s = input()
pat = [bin(i)[2:].zfill(len(s)-1) for i in range(2**(len(s)-1))]
ans = 0
if len(s) == 1:
    print(int(s))
    exit()
for cond in pat:
    cnt = 0
    now = int(s[0])
    for i in range(len(cond)):
        if cond[i] == "0":
            now *= 10
            now += int(s[i+1])
        else:
            cnt += now
            now = int(s[i+1])
    cnt += now
    ans += cnt
print(ans)

Solution (Python):
import copy
S = input()
EX = ' '.join(list(S))
EX = list(EX)
sum = 0
for i in range(2 ** (len(S)-1)):
    P = copy.deepcopy(EX)
    for j in range((len(S)-1)):
        if ((i >> j) & 1):
            P[j*2+1] = '+'
    sum += eval(''.join(P).replace(' ',''))
print(sum)

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

sumAns = 0
for bit in itertools.product([0, 1], repeat=len(S) - 1):
    ans = 0
    start = 0
    for fin in range(len(bit)):
        if bit[fin] == 1:
            ans += int(S[start: (fin + 1)])
            start = fin + 1
    ans += int(S[start:])

    sumAns += ans

print(sumAns)