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):
"""
yieldを使った全探索
"""
import sys
input = sys.stdin.buffer.readline


S = input()[:-1]

def F(S):
    yield int(S)
    for i in range(len(S)-1):
        left = S[:i+1]
        right = S[i+1:]
        x = int(left)
        for y in F(right):
            yield x + y

answer = sum(F(S))
print(answer)

Solution (Python):
if __name__=='__main__':
    s = input()
    locate = len(s)-1

    
    sum_all = 0
    for bit in range(1 << locate):
        binary = str(format(bit, 'b'))
        binary = binary.zfill(len(s)-1)
        head = 0
        for i in range(len(binary)):
            if binary[i] == '1':
                sum_all += int(s[head:i+1])
                head = i+1
        sum_all += int(s[head:])

    print(sum_all)

Solution (Python):







s = str(input())
slen = len(s)

masterlist = []

for i in range (2 ** (slen-1)):
    pluslist = []
    for j in range(slen - 1):
        if i >> j & 1:
            pluslist.append(True)
        else:
            pluslist.append(False)
    masterlist.append(pluslist)

result = 0



for pl in masterlist:
    plus_count = 0
    after_s = s
    for k in range(len(pl)):
        if pl[k] == True:
            after_s = "{0}{1}{2}".format(after_s[:k+plus_count+1],"+",after_s[k+plus_count+1:])
            plus_count += 1
    try:
        list_sum = eval(after_s)
    except NameError:
        list_sum = int(s) 
    result += list_sum

print(result)





"""

def tansaku(number,plus_point,sum_temp):
    
    str_number = str(number)
    if len(str_number) -1 <= plus_point :
        return number + sum_temp
    else:
        next_number = int(str(number)[plus_point+1:])
        a1 = int(tansaku(next_number,0,sum_temp + int(str(number)[:plus_point+1])))
        

        a2 = tansaku(number,plus_point+1,sum_temp)
        


        return a1 + a2
 


if __name__ == "__main__":
    s = int(input())
    print(tansaku(s,0,0))
"""

Solution (Python):
import sys

S = list(map(int, sys.stdin.readline().strip()))
len_S = len(S)
ans = 0
for i in range(2 ** (len_S - 1)):
  sum_ = S[len_S - 1]
  cursor = len_S - 1
  power = 0
  while cursor > 0:
    cursor -= 1 
    if i % 2 == 1:
      power += 1
    else:
      power = 0
    sum_ += S[cursor] * (10 ** power)
    i >>= 1
  ans += sum_
print(ans)

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

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

Solution (Python):





def tansaku(number,plus_point,sum_temp):
    
    str_number = str(number)
    if len(str_number) -1 <= plus_point :
        return number + sum_temp
    else:
        next_number = int(str(number)[plus_point+1:])
        a1 = int(tansaku(next_number,0,sum_temp + int(str(number)[:plus_point+1])))
        

        a2 = tansaku(number,plus_point+1,sum_temp)
        


        return a1 + a2
 


if __name__ == "__main__":
    s = int(input())
    print(tansaku(s,0,0))

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

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



"""解説：実際に+を入れたのを作ってく 文字列作って＋区切り文字にして足してけば良い
幅優先探索？"""

from collections import deque
bcal = []
que = deque()
que.append(S[0])
s = ''.join([S[0],'+'])
que.append(s)
while len(que)>0:
    a = que.popleft()
    pn = a.count('+')
    if len(a)-pn == len(S):
        if a[-1]=='+':
            b = a.strip(a[-1])
            bcal.append(b)
        else:
            bcal.append(a)
    else:
        ai = len(a)-pn
        an1 =''.join([a,S[ai]])
        an2 =''.join([a,S[ai],'+'])
        que.append(an1)
        que.append(an2)
        
ans = 0
bcal= set(bcal)
for item in bcal:
    ee = item.split('+')
    for item2 in ee:
        ans += int(item2)

print(ans)

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

ans = 0
for i in range(2**(n-1)):
    p = []
    trig = 0
    for j in range(n-1):
        if (i >> j) & 1 == 1:
            p.append(int(s[trig:j+1]))
            trig = j+1
    p.append(int(s[trig:]))
    ans += sum(p)

print(ans)

Solution (Python):
S = input()
Sum = 0
for i in range(2**(len(S)-1)):
  binary = str(format(i,'b'))
  binary_zero = binary.zfill(len(S)-1)
  t = 0
  for j in range(len(S)-1):
    if binary_zero[j]=='1':
      Sum += int(S[t:j+1])
      t = j+1
  Sum += int(S[t:])
print(Sum)

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

def dfs(i, sentence):
    
    if i == l - 1:
        return sum(list(map(int, sentence.split("+"))))
    return dfs(i+1, sentence + "+" + s[i+1]) + dfs(i+1, sentence+s[i+1])

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

Solution (Python):
import sys
S = sys.stdin.readline().rstrip()
n = len(S) - 1
ans = 0
for i in range(2 ** n):
    op = [""] * n
    tmp = S[0]
    for j in range(n):
        if (i >> j) & 1:
            tmp += "+"
        tmp += S[j + 1]
    ans += eval(tmp)
print(ans)

Solution (Python):
inf = 10**15
mod = 10**9+7
s = input()
n = len(s)-1
ans = 0
for i in range(2**n):
    acc = int(s[0])
    for j in range(n):
        if ((i >> j) & 1):  
            ans+=acc
            acc=int(s[j+1])
        else:
            acc *= 10
            acc += int(s[j+1])
    ans+=acc
print(ans)

Solution (Python):
S = input()
N = len(S)
plus_flag = [0] * (N - 1)


def calc(flags):
    val = 0
    num_begin_index = 0
    num_end_index = None
    for flag_index in range(len(flags)):
        if flags[flag_index] == 0:
            continue
        num_end_index = flag_index + 1
        val += int(S[num_begin_index:num_end_index])
        num_begin_index = num_end_index
    num_end_index = len(flags) + 1
    val += int(S[num_begin_index:num_end_index])
    return val


def calc_sum(index, flag):
    plus_flag[index] = flag
    if index == len(plus_flag) - 1:
        return calc(plus_flag)
    return calc_sum(index + 1, 0) + calc_sum(index + 1, 1)


if N == 1:
    print(S)
else:
    print(calc_sum(0, 0) + calc_sum(0, 1))

Solution (Python):
s1, *sn = input()
L = len(sn)
SUM = 0
for bits in range(1 << L):
    formula = s1
    for op, s in enumerate(sn):
        if bits >> op & 1:
            formula += '+'
        formula += s
    value = sum(map(int, formula.split('+')))
    
    
    SUM += value
print(SUM)

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

def calc(s):
    if len(s) == 0: return [0]
    if len(s) == 1: return [int(s)]
    tmp = []
    for i in range(len(s)):
        left = s[:i+1]
        right = s[i+1:]
        x = int(left)
        for j in calc(right):
            tmp.append(x + j)
    return tmp

print(sum(calc(s)))

Solution (Python):
import sys
import string
import time


def input():
    return sys.stdin.readline().rstrip()


def I():
    return int(input())


def S():
    return input()


def MI():
    return map(int, input().split())


def MS():
    return map(str, input().split())


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


def LI_():
    return [int(i) - 1 for i in input().split()]


def StoI():
    return [ord(i) - 97 for i in input()]


def ItoS(nn):
    return chr(nn + 97)


N = {False: 'No', True: 'Yes'}
MOD = 10 ** 9 + 7
inf = float('inf')
IINF = 10 ** 10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()

nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


def main():
    s = S()
    ans = 0
    
    for i in range(2 ** (len(s) - 1)):
        idx = 0
        rng = 1
        
        for n in range(len(s) - 1):
            if (1 << n) & i:
                ans += int(s[idx:idx + rng])
                idx += rng
                rng = 1
            else:
                rng += 1
        ans += int(s[idx:idx + rng])
    print(ans)


if __name__ == '__main__':
    main()

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

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

    for i in range(1 << n-1):
        temp = 0
        for j in range(n-1):
            if i & (1 << j):
                ans += int(''.join(s[temp:j+1]))
                temp = j+1
        ans += int(''.join(s[temp:]))
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):


s = input()

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

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

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

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

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

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

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

Ans = 0

for i in range(2**(len(S)-1)):
    W = [""]*(len(S)-1)
    for j in range(len(S)-1):
        
        if ((i >> j) & 1):
            W[j] = "+"
    
    formula = ""
    for k,l in zip(S,W+[""]):
        formula += (k+l)
    Ans += eval(formula)

print(Ans)

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

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

Solution (Python):
S = input()

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

Solution (Python):
S = input()
cnt=0
result = 0
for i in range(2**(len(S)-1)):
  mark_list = S[0]
  for j in range(len(S)-1):
    if (i>>j)&1 == 1:
      mark_list+="+"+S[j+1] 
    else:
      mark_list+=S[j+1]
  result+=eval(mark_list)
print(result)

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

for i in range(1 << (len(S) - 1)):
    num = [S[0]]

    for j in range(len(S) - 1):
        if ((i >> j) & 1):
            num.append(S[j + 1])
        else:
            num[-1] += S[j + 1]
    ans += sum([int(n) for n in num])

print(ans)

Solution (Python):
s = list(str(input()))
ans = 0
if len(s) == 1:
  print(int(s[0]))
else:
  for i in range(2**(len(s)-1)):
    a = 0
    bin_str = format(i, 'b').zfill(len(s)-1)
    for num,j in enumerate(bin_str):
      if j == "1":
        ans += sum([int(k)*10**(num-a-l) for l,k in enumerate(s[a:num+1])]) 
        a = num+1
      if num == len(bin_str)-1:
        ans += sum([int(k)*10**(num-a+1-l) for l,k in enumerate(s[a:num+2])])
  print(ans)

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


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

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

def allbitCalc(N):
    allbit = []
    for i in range(2**N):
        bit = [0] * N
        for j in range(N):
            if (i >> j) & 1:
                bit[j] = 1
        allbit.append(bit)
    return allbit

def split(S,bit):
    n=len(S)
    terms=[]
    cnt=1;s=int(S[n-1])
    for i,b in enumerate(bit):
        if b==0:
            s+=int(S[n-i-2])*10**cnt
            cnt+=1
        else:
            terms.append(s)
            s=0;cnt=0
            s+=int(S[n-i-2])*10**cnt
            cnt+=1

    terms.append(s)
    return(sum(terms))
        
summ=0
allb=allbitCalc(int(len(S))-1)
for ab in allb:
    tmp=split(S,ab)
    summ+=tmp

print(summ)

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 bit in range(1<<(n)):
    f = s[0]
    for i in range(n):
        if (bit >> i) & 1 :
            f += "+"
        f += s[i + 1]
    
    ans += eval(f)

print(ans)

Solution (Python):

S = input()
op_cnt = len(S) - 1
ops = []
for i in range(2 ** op_cnt):
    op = [""] * op_cnt
    for j in range(op_cnt):
        if (i >> j) & 1:
            op[j] = "+"
    ops.append(op)




def eval_fomula(S, op):
    s = list(S)
    count = 1
    for i in range(len(s) - 1):
        s.insert(i+count, op[i])
        count += 1
    fomula = ""
    for k in range(len(s)):
        fomula += s[k]

    return eval(fomula)


total = 0
for i in range(2 ** op_cnt):
    total += eval_fomula(S, ops[i])

print(total)

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 bit in range(2 ** n):
    f = s[0]
    for i in range(n):
        
        mask = 1 << i
        if bit & mask:
            f += "+"
        f += s[i + 1]
        
    ans += eval(f)

print(ans)

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

ans = 0

for bit in range(2 ** n):
    f = s[0]
    for i in range(n):
        if bit & (1 << i):
            f += "+"
        f += s[i + 1]
        
    ans += eval(f)
    
    

print(ans)

Solution (Python):
s = input()

def fun(s):
    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('+')))

    return ans

print(fun(s))

Solution (Python):


import itertools
S = input()
ans = 0
bit_list = list(itertools.product([0,1], repeat=len(S)-1))
for bits in bit_list:
  A =[]
  bits = list(bits)
  bits.append(0)
  for i in range(len(S)):
    A.append(S[i])
    if bits[i] == 1: A.append("+")
  ans += eval("".join(A))
print(ans)

Solution (Python):
import itertools

def solve(S):
    '''
    数字の間に+を入れるパターンと入れないパターンを全てチェックする
    125であれば、 125, 1+25, 12+5, 1+2+5
    +が入る可能性のある場所は右の通り、 1  |ここ!| 2  |ここ!| 5
    よって、組み合わせは 2 ** (文字列数 - 1)
    '''
    
    if len(S) == 1:
        print(int(S))
    else:
        count = 0
        bit_list = list(itertools.product([0, 1], repeat=len(S)-1))
        for pattern in bit_list:
            '''
            ビットの値が1の時に+が入ると考えて、0の時は入らない
            文字列を先頭から調べていき、次の文字との間に+が入る場合、そこまでの文字列をint型に変換して変数「count」に加算する
            +が入る場所の次の文字をstartに記録する
            
            '''
            start = 0
            for end in range(len(pattern)):
                if pattern[end] == 1:
                    count += int(S[start:end+1])
                    start = end + 1
    
            count += int(S[start:])

        print(count)


if __name__ == '__main__':
    S = input()
    solve(S)

Solution (Python):
import itertools

def solve(S):
    '''
    数字の間に+を入れるパターンと入れないパターンを全てチェックする
    125であれば、 125, 1+25, 12+5, 1+2+5
    +が入る可能性のある場所は右の通り、 1  |ここ!| 2  |ここ!| 5
    よって、組み合わせは 2 ** (文字列数 - 1)
    '''
    
    if len(S) == 1:
        print(int(S))
    else:
        count = 0
        bit_list = list(itertools.product([0, 1], repeat=len(S)-1))
        for pattern in bit_list:
            '''
            ビットの値が1の時に+が入ると考えて、0の時は入らない
            文字列を先頭から調べていき、次の文字との間に+が入る場合、そこまでの文字列をint型に変換して変数「count」に加算する
            +が入る場所の次の文字をstartに記録する
            
            '''
            start = 0
            for end in range(len(pattern)):
                if pattern[end] == 1:
                    count += int(S[start:end+1])
                    start = end + 1

                if end == len(pattern) - 1:
                    count += int(S[start:])

        print(count)


if __name__ == '__main__':
    S = input()
    solve(S)

Solution (Python):
s = input()
nbit = len(s) - 1
ans = 0
for bit in range(1 << nbit):
    f = s[0]
    for i in range(nbit):
        if bit & (1 << i):
            f += "+"
        f += s[i+1]

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

print(ans)

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

Solution (Python):
def cal(formula: str) -> int:
    nums = formula.split("+")
    ans = 0
    for n in nums:
        ans += int(n)
    return ans


def dfs(i: int, s: str, formula: str) -> int:
    if (i == len(s) - 1):
        return cal(formula)
    return dfs(i + 1, s, formula + s[i + 1]) + dfs(i + 1, s, formula + "+" + s[i + 1])


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

Solution (Python):
ans=0
def dfs(lim,cnt,p):
    P=p.copy()
    global ans
    if(cnt==lim):
        res=''
        for x,y in zip(S,P):
            res+=x+y
        ans+=eval(res)
        return
    dfs(lim,cnt+1,P)
    P[cnt]='+'
    dfs(lim,cnt+1,P)
    
S=input()
p=['']*(len(S))
dfs(len(S)-1,0,p)
print(ans)

Solution (Python):
s = str(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): 
            num.append(s[j + 1])
        else: 
            num[-1] += s[j + 1]
    ans += sum(list(map(int, (num[i] for i in range(len(num))))))
print(ans)

Solution (Python):
S = input()
if len(S) == 1:
  print(int(S))
  exit()
else:
  def count(n):
    a = 0
    if len(n) == 1:
      return 0
    else:
      for i in range(1, len(n)):
        a += int(n[:i]) * 2 ** (len(n[i:]) - 1) + int(n[i:]) + count(n[i:])
      return a
  print(int(S) + count(S))

Solution (Python):
S = input()
if len(S) == 1:
  print(int(S))
else:
  def count(n):
    a = 0
    if len(n) == 1:
      return 0
    else:
      for i in range(1, len(n)):
        a += int(n[:i]) * 2 ** (len(n) - 1 - i) + int(n[i:]) + count(n[i:])
      return a
  print(int(S) + count(S))

Solution (Python):
   
s=input()

if len(s)==1:
    print(int(s))
else:
    def count(num):
        
        if len(num)==1:
            return 0
        else:
            a=0
            for j in range(1,len(num)):
                a+=int(num[:j])*2**(len(num[j:])-1)+int(num[j:])+count(num[j:])
            return a
    ans=int(s)+count(s)
    print(ans)

Solution (Python):
S = input()
if len(S) == 1:
  print(int(S))
  exit()
else:
  def count(n):
    if len(n) == 1:
      return 0
    else:
      a = 0
      for i in range(1, len(n)):
        a += int(n[:i]) * 2 ** (len(n) - 1 - i) + int(n[i:]) + count(n[i:])
      return a
  ans = int(S) + count(S)
  print(ans)

Solution (Python):
S = input()
if len(S) == 1:
  print(int(S))
  exit()
else:
  def count(n):
    a = 0
    if len(n) == 1:
      return 0
    else:
      for i in range(1, len(n)):
        a += int(n[:i]) * 2 ** (len(n) - 1 - i) + int(n[i:]) + count(n[i:])
      return a
  print(int(S) + count(S))

Solution (Python):
s=input()
n=len(s)
l=[[] for _ in range(2**(n-1))]
for b in range(2**(n-1)):
    x=b
    for i in range(n-1):
        if x%2==1:
            l[b].append(1)
        else:
            l[b].append(0)
        x//=2

indexes=[[] for _ in range(2**(n-1))]
for k in range(2**(n-1)):
    indexes[k]=[i for i, x in enumerate(l[k]) if x == 1]

SUM=0
for j in range(2**(n-1)):
    L=len(indexes[j])
    if L==0:
        SUM+=int(s)
        
    else:
        SUM+=int(s[:indexes[j][0]+1])
        
        SUM+=int(s[indexes[j][L-1]+1:])
        
        if L>1:
            for h in range(L-1):
                SUM+=int(s[indexes[j][h]+1:indexes[j][h+1]+1])
                
print(SUM)

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

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

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

def cal(l):
    c = ''
    for i in range(len(l)):
        if i%2==0:
            c += l[i]
        else:
            if l[i]==1:
                c += '+'
    return eval(c)

ans = 0
for i in range(1<<N):
    cond = [0]*N
    for j in range(N):
        if 1&(i>>j):  
            cond[j] = 1
    tmp = []
    for i in range(N):
        tmp.append(S[i])
        tmp.append(cond[i])
    tmp.append(S[-1])

    ans += cal(tmp)

print(ans)

Solution (Python):
import itertools
s = input()
ans = 0
for plus in itertools.product(['', '+'], repeat=len(s)-1):
    formula = s[0]
    formula += "".join([op+num for op, num in zip(plus, s[1:])])
    ans += eval(formula)
print(ans)

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

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

print(ans)

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

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

print(ans)

Solution (Python):
s = input()
n = len(s)
f = ''
for i in range(2**(n-1)):
  b = format(i, 'b').zfill(n)
  for j in range(n):
    if b[j] == '1':
      f += '+' + s[j]
    else:
      f += s[j]
  f+= '+'
print(eval(f[:len(f)-1]))

Solution (Python):
INF = 10 ** 9
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from  heapq import heappop,heapify,heappush
from bisect import bisect_left

def main():
    s = input()
    l = len(s) - 1
    ans = 0
    for bit in range(1 << l):
        op = []
        for i in range(l):
            if (bit>>i)&1:
                op.append('+')
            else:
                op.append('')
        
        formula = s[0]
        for i in range(l):
            formula += op[i]
            formula += s[i + 1]
        
        ans += eval(formula)
    
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
S = input()

import itertools

equation_str = []

plus_add_position = []

for i in range(len(S)):
    plus_add_position.extend(list(itertools.combinations(range(len(S)-1), i)))

for v in plus_add_position:
    if v==tuple():
        equation_str.append(S)
    else:
        eq = S[0]
        for i in range(len(S)-1):
            if i in v:
                eq += '+' + S[i+1]
            else:
                eq+= S[i+1]
        equation_str.append(eq)

ans = 0
for eq in equation_str:
    term = list(map(int, eq.split('+')))
    ans += sum(term)

print(ans)

Solution (Python):
S = input()

total = 0

for m in range(1 << len(S) - 1):
  acm = ''
  for i, c in enumerate(S):
    acm += c
    if 1 << i & m:
      total += int(acm)
      acm = ''
  if acm:
    total += int(acm)
    
print(total)

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

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

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

if l == 1:
    print(int(S[0]))
    exit()

A = []
for i in range(2**(l-1)):
    B = []
    for j in range(l-1):
        if (i>>j) & 1:
            B.append(1)
        else:
            B.append(0)
    A.append(B)

ans = 0

for i in range(2**(l-1)):
    C = []
    a = S[0]
    for j in range(l-1):
        if j != l-2:
            if A[i][j] == 0:
                a += S[j+1]
            else:
                C.append(a)
                a = S[j+1]
        else:
            if A[i][j] == 0:
                a += S[j+1]
                C.append(a)
            else:
                C.append(a)
                C.append(S[j+1])
    for j in C:
        ans += int(j)

print(ans)

Solution (Python):
def resolve():
    s = input()
    print(
        sum(
            eval(s)
            for s in [
                "".join(
                    s[i] + "+" if i < 9 and 1 << i & b else s[i] for i in range(len(s))
                )
                for b in range(2 ** (len(s) - 1))
            ]
        )
    )


if __name__ == "__main__":
    resolve()

Solution (Python):
def resolve():
    s = input()
    print(
        sum(
            eval(s)
            for s in [
                "".join(
                    s[i] + "+" if i < 9 and 1 << i & b else s[i] for i in range(len(s))
                )
                for b in range(2 ** (len(s) - 1))
            ]
        )
    )


if __name__ == "__main__":
    resolve()

Solution (Python):
   
s=input()

if len(s)==1:
    print(int(s))
else:
    def count(num):
        
        if len(num)==1:
            return 0
        else:
            a=0
            for j in range(1,len(num)):
                a+=int(num[:j])*2**(len(num[j:])-1)+int(num[j:])+count(num[j:])
            return a
    ans=int(s)+count(s)
    print(ans)

Solution (Python):
S = input()
N = len(S)
total = 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]
  total += sum(map(int, f.split('+')))

print(total)

Solution (Python):
n = list(input())
op = len(n) - 1
total = 0
for i in range(2 ** op):
    op_l = [''] * op
    for j in range(op):
        if (i >> j) & 1:
            op_l[j] = '+'
    
    formula = '' 
    for s, k in zip(n, op_l + ['']):
        formula += s + k
    
    total += eval(formula)
print(total)

Solution (Python):

S = input().strip()

ans = 0

for bit in range(2 ** (len(S) - 1)):
    th = [0]
    for i in range(len(S) - 1):
        if bit & (0x01 << i):
            th.append(i + 1)
    th.append(len(S))
    
    ans += sum([int(S[th[i]: th[i + 1]]) for i in range(len(th) - 1)])

print(ans)

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

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

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

def f(a,c,i):
    if i == len(S)-1:
        return(a + int(S[i]) + c)
    else:
        return(f(a+c+int(S[i]),0,i+1)+f(a,10*(c+int(S[i])),i+1))


print(f(0,0,0))

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

if n == 1:
    sumofall = int(s)
else:
    sumofall = 0
    for i in range(1 << (n-1)):
        j_before = 0
        for j in range(1, n):
            if (1 << (j-1)) & i:
                sumofall += int(s[j_before:j])
                j_before = j
        sumofall += int(s[j_before:])

print(sumofall)

Solution (Python):
s = input()

l = []
for i in range(2**(len(s)-1)):
  pat = ''
  for j in range(len(s)-1):
    pat += s[j]
    if i >> j & 1:
      pat += '+'
  l.append(pat+s[-1])
  
ans = 0
for i in range(len(l)):
  ans += eval(l[i])
print(ans)

Solution (Python):
import copy
S = list(input())
s = copy.copy(S)
p = len(S) - 1
ans = 0
for i in range(2**p):
    s = copy.copy(S)
    
    for j in range(p):
        if((i >> j) & 1):
            s.insert(p - j, "+")
            
    tmp = "".join(s)
    ans += eval(tmp)

print(ans)

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

ans = 0

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

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>>j & 1:
            f += '+'
        f += s[j+1]
    ans += eval(f)
print(ans)

Solution (Python):
import copy


def resolve():
	src = input()
	ans = 0
	for i in range(1 << len(src)-1):
		s = copy.copy(src)
		trim_size = 1
		for j in range(len(s)-1):
			if (i >> j) & 1 and len(s):
				ans += int(s[:trim_size])
				s = s[trim_size:]
				trim_size = 1
			else:
				trim_size += 1
		if len(s):
			ans += int(s)
	print(ans)
resolve()

Solution (Python):
s=input()
t=len(s)-1
sl=[s[i] for i in range(len(s))]
answers=[]

for i in range(2**t):
  tmp=[]
  for j in range(t):
    if (i>>j)&1:
      tmp.append(j)
  ll=['*'] * len(s)
  for k in tmp:
    ll[k]="+"
  ans=[]
  
  for k,_ in zip(sl,ll):
    ans.append(k)
    ans.append(_)
  ans=[_ for _ in ans if _ != "*"]
  ans=''.join(ans)
  ans=ans.split('+')
  ans=[int(k) for k in ans if k != '+']
  ans=sum(ans)
  answers.append(ans)
  
print(sum(answers))

Solution (Python):
import sys
import itertools
import copy

sys.setrecursionlimit(10**7)
s=input()
n=len(s)-1
a=[]

def dfs(i,arr,j):
    if i==n:
        res=sum(arr+[int(s[j:])])
    else:
        res=dfs(i+1,arr,j)+dfs(i+1,arr+[int(s[j:i+1])],i+1)
    return res

def solve():
    print(dfs(0,a,0))

solve()

Solution (Python):
n = int(input())

keta = len(str(n))
ans = 0

for i in range(pow(2,keta-1)):
  shiki = str(n)[0]
  temp = [0]*(keta-1)
  for j in range(keta-1):
    if (i>>j)&1 == 1:
      temp[j] = "+"
    else:
      temp[j] = ""
    shiki += temp[j]+str(n)[j+1]
  ans += eval(shiki)







print(ans)

Solution (Python):
n = int(input())

keta = len(str(n))
ans = 0

for i in range(pow(2,keta-1)):
  shiki = str(n)[0]
  temp = [0]*(keta-1)
  for j in range(keta-1):
    if (i>>j)&1 == 1:
      temp[j] = "+"
    else:
      temp[j] = ""
    shiki += temp[j]+str(n)[j+1]
  ans += eval(shiki)
print(ans)

Solution (Python):
n = int(input())

keta = len(str(n))

fugo =[0]*pow(2,keta-1)
for i in range(pow(2,keta-1)):
  temp = [0]*(keta-1)
  for j in range(keta-1):
    if (i>>j)&1 == 1:
      temp[j] = "+"
    else:
      temp[j] = ""
  fugo[i] = temp

ans = 0
for i in range(pow(2,keta-1)):
  shiki = str(n)[0]
  for j in range(keta-1):
    shiki += fugo[i][j]+str(n)[j+1]
  ans += eval(shiki)
print(ans)

Solution (Python):
l = [int(x) for x in list(str(input()))]


def manysum(n):
    if len(n) == 1:
        return n[0]
    a = n[0] * (2 ** (len(n) - 2)) + manysum(n[1:])
    n[1] += 10 * n[0]
    b = manysum(n[1:])

    return a + b

print(manysum(l))

Solution (Python):
S=str(input())
n=len(S)
N=2**(n-1)
L=[]
for i in range(N):
    Bin=bin(i)[2:]
    Bin=(Bin[::-1]+'0'*max(0,(n-1)-len(Bin)))[::-1]
    L.append(Bin)

if n==1:
    ans=int(S)
else:
    ans=0
    for j in L:
        s=S
        f=0
        for k in range(1,n):
            if k!=n-1:
                s=str(s)
                if j[k-1]=='1':
                    ans+=int(s[f:k])
                    f=k
            else:
                if j[k-1]=='1':
                    ans+=int(s[f:k])+int(s[k:])
                else:
                    ans+=int(s[f:])
            

print(ans)

Solution (Python):
s = input()
n = len(s)-1
nums = [s[0]]
box = []
for i in range(2**n):
  for j in range(n):
    if (i>>j)&1:
      nums.append("+")
      nums.append(s[j+1])
    else:
      nums.append(s[j+1])
  num = 0
  now = 0
  for k in nums:
    if k == "+":
      num += now
      now = 0
    else:
      now = 10*now + int(k)
  num += now
  box.append(num)
  nums = [s[0]]
print(sum(box))

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

res = 0

for i in range(2**n):
    f = ""
    for idx, j in enumerate(s):
        if i >> idx & 1:
            f += j + "+"
            continue
        f += j
    res += eval(f)

print(res)