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)
goukei=0
for i in range(2 **(N-1)):
    T=[]
    T.append(S[0])
    for j in range(N-1):
        if ((i >> j) & 1):
            
            
            T.append("+")
            T.append(S[j+1])
        else:
            T.append(S[j+1])
    
    
    
    tmp=[]
    for m in T:
        if m!="+":
            tmp.append(m)
        else:
            Z=[str(a) for a in tmp]
            Z="".join(Z)
            goukei+=int(Z)
            tmp=[]
    Z=[str(a) for a in tmp]
    Z="".join(Z)
    goukei+=int(Z)
    
print(goukei)

Solution (Python):
from itertools import product

s = str(input())
a = list(product(['+', ''], repeat=len(s)-1))


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

Solution (Python):
import copy
a=list(input())
ano=list(range(1,100,2))
n=len(a)-1
ans=0
for i in range(2**n):
    c=copy.deepcopy(a)
    b=['']*n
    for j in range(n):
        if ((i>>j)&1)==1:
            b[j]='+'
    for k in range(n):
        c.insert(ano[k],b[k])
    ans+=eval(''.join(c))
print(ans)

Solution (Python):


import sys
readline = sys.stdin.readline
read = sys.stdin.read




s = input()

L = len(s)
ans = 0
from itertools import product
for a in product(["+",""],repeat=L-1):
    t = s[0]
    for si,i in zip(s[1:],a):
        t += i + si
        
    
    ans += eval(t)

print(ans)

Solution (Python):
__DEUBG__ = 0
num = input()
pattern = len(num) -1

if pattern == 0:
    print(num)
    exit(0)
total = 0
fmt = '0' + str(pattern) + 'd'
if __DEUBG__:
    print(fmt)
total = 0
for i in range(2**pattern):
    binary = format(int(bin(i)[2:]), fmt)
    if __DEUBG__:
        print('binary', binary)

    equation = ''
    for idx, sign in enumerate(binary):
        equation += num[idx] + ('+' if sign == '1' else '')
        if __DEUBG__:
            print(equation)

    equation += num[-1]
    if __DEUBG__:
        print(equation, eval(equation))
        print()
    total += eval(equation)

print(total)

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):


from itertools import product

S = input()
l = len(S)

res = 0
for a in product(*[[0,1],]*(l-1)):
    c = 0
    st = S[0]
    for i, b in enumerate(a, start=1):
        if b == c:
            st += S[i]
        else:
            res += int(st)
            st = S[i]
        c = b
    res += int(st)

print(res)

Solution (Python):
s0 = input()
def convert(n, m):
  ans = ""
  while n > 0:
    amari = n % m
    ans += str(amari)
    n //= m
  return ans
n = len(s0) - 1
SUM = int(s0)
for i in range(1, 2**n):
  s1 = " ".join(list(s0))
  i = convert(i, 2)
  list_index = []
  for j in range(len(i)):
    list_index.append(i.find("1", j))
  list_index = list(set([x for x in list_index if x != -1]))
  for k in list_index:
    s1 = s1[:2*k+1] + "+" + s1[2*(k+1):]
  s1 = s1.replace(" ", "")
  sum_list = list(map(int, s1.split("+")))
  SUM += sum(sum_list)
print(SUM)

Solution (Python):
from collections import deque

def main():
    N = list(input())
    Nq = deque(N)
    anstmp = []
    ans = 0

    for bit in range(2**(len(N) - 1)):
        for i in range(len(N)):
            anstmp.append(str(Nq.popleft()))
            if ((bit >> i) & 1): 
                anstmp.append("+")
        
        ans += eval("".join(anstmp))

        Nq = deque(N) 
        anstmp = []  

    print(ans)
    
        

if __name__ == "__main__":
    main()

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

Solution (Python):

def dfs(s, seq, res):
  if len(s)==0: return
  for i in range(1, len(s)):
    seq.append(int(s[:i]))
    res[0] += sum(seq) + int(s[i:])
    dfs(s[i:], seq, res)
    seq.pop()
    

S = input()
seq = []
res = [int(S)]
dfs(S, seq, res)
print(res[0])

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

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


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

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

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

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

Solution (Python):
def a(t,i):
    if i == l-1:
        return sum(map(int,t.split("+")))
    return a(t+s[i+1],i+1)+a(t+"+"+s[i+1],i+1)
s = input()
l = len(s)
print(a(s[0],0))

Solution (Python):



import os
import sys
import itertools







def splitter(str):
    for i in range(1, len(str)):
        start = str[0:i]
        end = str[i:]
        yield (start, end)
        for split in splitter(end):
            result = [start]
            result.extend(split)
            yield result


def main():
    S = input()
    A = list(splitter(S))

    ans = int(S)
    for i in range(len(A)):
        for j in range(len(A[i])):
            ans += int(A[i][j])

    print(ans)
    return


if __name__ == '__main__':
    main()

Solution (Python):
from itertools import product
s = input()
op = list(product(["", "+"], repeat=len(s)))
op = [a for a in op if not a[-1] == "+"]
ans = 0
for q in op:
    e = ""
    for w in range(len(q)):
        e += s[w] + q[w]
    ans += eval(e)
print(ans)

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

Solution (Python):
import sys
S=input()
S_seq=[]
for i in S:
    S_seq.append(i)
if(len(S_seq)==1):
    print(int(S))
    sys.exit()
separate=[]
for i in range(len(S_seq)-1):
    a=[]
    if(i==0):
        a.append("*")
        a.append("_")
    else:
        for j in separate:
            a.append(j+"*")
            a.append(j+"_")
    separate=a

separated=[]
for i in separate:
    a=[]
    for j in i:
        a.append(j)
    separated.append(a)

pre_calculated=[]
for i in separated:
    a=[]
    for j in range(len(S_seq)-1):
        a.append(S_seq[j])
        if(i[j]=="*"):
            a.append("+")
        elif(i[j]=="_"):
            continue
    a.append(S_seq[-1])
    pre_calculated.append(a)

sumation=0
for i in pre_calculated:
    number=[]
    for j in range(len(i)):
        new_number=[]
        if(j==len(i)-1):
            for k in number:
                sumation+=k*10
            sumation+=int(i[j])
        elif(i[j]=="+"):
            for k in number:
                sumation+=k
            number=[]
        else:
            for k in number:
                new_number.append(k*10)
            new_number.append(int(i[j]))
        
        number=new_number
print(sumation)

Solution (Python):
s=list(input())
ans=[]
for i in range(1<<(len(s)-1)):
    tmp=0
    num=s[0]
    for j in range(len(s)-1):
        if (i>>j)%2==0:
            num+=s[j+1]
        else:
            tmp+=int(num)
            num=s[j+1]
        
    tmp+=int(num)
    ans.append(tmp)
print(sum(ans))

Solution (Python):
def main():
    S = input()
    ans = 0
    for n in range(2**(len(S)-1)):
        fig = S[0]
        index = 1
        for _ in range(len(S)-1):
            if n % 2:
                fig += "+"+S[index]
            else:
                fig += S[index]
            n >>= 1
            index += 1
        ans += eval(fig)
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):


s = input()

s_list = list(s)
operator_box = list(range(len(s_list) - 1))
operators = dict(zip(operator_box, list(map(lambda x: False, operator_box))))

result = 0


def calc(nums, operators):
    sums = 0
    _index = 0
    for index, operator in operators.items():
        if operator:
            if _index == index:
                chars = [nums[_index]]
            else:
                chars = nums[_index: int(index) + 1]

            _index = int(index) + 1
            number = ''.join(chars)
            sums += int(number)

    chars = nums[_index:]
    sums += int(''.join(chars))
    return sums

length = len(operators)

for i in range(2 ** length):
    _operators = operators
    for j in range(length):
        if ((i >> j) & 1):
            _operators[length - 1 - j] = True
        else: 
            _operators[length - 1 - j] = False

    result += calc(s_list, _operators)

print(result)

Solution (Python):
import sys, re
from math import ceil, floor, sqrt, pi, factorial
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext

def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    s = s_input()

    count = 0
    for bit in list(product([0,1], repeat=len(s)-1)):
        eval_s = s[0]
        for i in range(len(bit)):
            if bit[i] == 1:
                eval_s += '+'
            eval_s += s[i+1]
        count += eval(eval_s)

    print(count)

if __name__ == '__main__':
    main()

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

total = 0

for b in range(2**n):
    nums = []
    index = 0
    
    for i in range(n):
        if ( b & (1 << i) ):
            nums.append(int(s[index:i+1]))
            index = i+1
    nums.append(int(s[index:]))
    total = total + sum(nums)
print(total)

Solution (Python):


import itertools

s = list(input())
n = len(s)
bin = list(itertools.product(['', '+'''], repeat=n - 1))
count = 0
for i in bin:
    t = []
    for j in range(n-1):
        t.append(s[j])
        t.append(i[j])
    t.append(s[-1])
    formula = ''.join(t)
    
    count += eval(formula)
print(count)

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

Solution (Python):
from itertools import product

a=list(input())
sum=0
text=""
for i in product(["","+"],repeat=len(a)-1):
    text=""
    for j in range(len(a)-1):
        text+=a[j]+i[j]
    text+=a[len(a)-1]
    sum+=eval(text)
print(sum)

Solution (Python):
s=input()
m=len(s)
sm=0
for i in range(2**(m-1)):
  a=list(str(bin(i)))[::-1]
  b=list(s)
  for j in range(len(a)-1,-1,-1):
    if a[j]=='1':
      b.insert(-j-1,'+')
  sm+=eval(''.join(b))
print(sm)

Solution (Python):

s = input()
l = len(s)-1
ans = 0
ops = []


for i in range(1 << l):
    op = [''] * l
    for j in range(l):
        if ((i >> j) & 1) == 1:
            op[l-1-j] = '+'
    ops.append(op)

for op in ops:
    num = [digit for digit in s]
    for k in range(len(op)):
        
        num.insert(2*k+1, op[k])
    ans += eval(''.join(num))

print(ans)

Solution (Python):

s = input()
l = len(s)-1
ans = 0
ops = []


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

for o in ops:
    str = [str for str in s]
    for k in range(len(o)):
        str.insert(2*k+1, o[k])
    ans += eval(''.join(str))

print(ans)

Solution (Python):
FS, *S = input()
L = len(S)
ans = 0
for bit in range(1 << L):
    tmp = FS
    f = []
    for i, s in enumerate(S):
        if bit >> i & 1:
            f.append(tmp)
            tmp = s
        else:
            tmp += s
    f.append(tmp)
    ans += sum(map(int, f))
print(ans)

Solution (Python):

S = input()

n = len(S)

sum_formula = 0

for bit in range(2 ** (n-1)):
    nums = []
    
    num = S[0]
    for shift in range(n-1):
        if not ((bit >> shift)&1):
            num = num + S[shift+1]
        else:
            nums.append(int(num))
            num = S[shift+1]
    nums.append(int(num))
    sum_formula += sum(nums)

print(sum_formula)



def calc_all_formula(S, i, lists):
    '''
    listsの要素: ([数字list], temp_str)
    '''
    new_lists = []
    
    new_lists.extend(
        [(lst[0]+[int(lst[1])], S[i+1]) for lst in lists]
    )
    new_lists.extend(
        [(lst[0], lst[1]+S[i+1]) for lst in lists]
    )

    
    if i == len(S)-2:
        new_lists = [
            lst[0]+[int(lst[1])] for lst in new_lists
        ]
        return new_lists
    
    return calc_all_formula(S, i+1, new_lists)

Solution (Python):

s = list(input())
n = len(s)-1
trueans = []
for i in range(2**n):
    bag = []
    for j in range(n):
        bag.append(s[j])
        if (i>>j) & 1:
            bag.append("+")
    bag.append(s[-1])
    bag.append("+")
    kai = ""
    ans = []
    if "+" in bag:
        for j in bag:
            if j != "+":
                kai += j
            else:
                ans.append(int(kai))
                kai = ""
    trueans.append(sum(ans))
print(sum(trueans))

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 = input()
n = len(s)
 
ans = 0
 
for bit in range(2 ** (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 = input()
import itertools
a = itertools.product([0,1],repeat=len(s)-1)

ans = 0
for x in a: 
  txt = s[0]
  for i,kigo in enumerate(x):
    if kigo:
      txt += "+" + s[i+1]
    else:
      txt += s[i+1]
  ans += sum(list(map(int,txt.split('+'))))

print(ans)

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


for b in l:
  ll=[]
  inc=0
  for ii in range(n):
    if b[ii] == "+":
      ll.append(int(s[inc:ii+1]))
      inc=ii+1
  ll.append(int(s[inc:len(s)]))
  
  Sum+=sum(ll)
print(Sum)

Solution (Python):
s = input()

sum = 0
tmp = 2 ** (len(s) -1)

for i in range(tmp):
    format_spec = '0{}b'.format(len(s)-1)
    flag = format(i, format_spec)
    my_sum = 0
    before = 0
    for j in range(len(s) - 1):
        if flag[j] == '1':
            my_sum += int(s[before:j+1])
            before = j+1
    my_sum += int(s[before:])
    sum += my_sum

print(sum)

Solution (Python):
from itertools import permutations, combinations,combinations_with_replacement,product
s = input()
t = product(["+",""],repeat=len(s)-1)
sum=0
for i1 in t:
    calc = ""
    for j,i2 in enumerate(i1):
        calc+=s[j]+i2
    calc += s[-1]
    sum+=eval(calc)

print(sum)

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

Solution (Python):
import math
import sys
from collections import deque
a=input()
ans=0
for i in range(2**(len(a)-1)):
  s=0
  c=int(a[0])
  for j in range(len(a)-1):
    if (i>>j) &1:
      s+=c
      c=int(a[j+1])
    else:
      c=10*c+int(a[j+1])
  ans+=s+c
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 = input()
k = len(s)

















ans = 0

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

print(ans)

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

ans = 0

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

    for i in range(n - 1):
        if bit & (1 << i):
            
            f += "+"
        f += s[i + 1]

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

print(ans)

Solution (Python):
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

s = sinput()
n = len(s) - 1

sum = 0
for i in range(2**n):
    plus = ["" for i in range(n)] + [""]
    for j in range(n):
        if i>>j&1: plus[j] = "+"
    equa = ""
    for k in range(n+1): equa += s[k] + plus[k]
    sum += eval(equa)

print(sum)

Solution (Python):
from sys import stdin
S = stdin.readline().rstrip()
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):


import sys
input = sys.stdin.readline
import itertools
 
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

s = str(input().rstrip())
s = tuple(int(s[i]) for i in range(len(s)))


mylist = [1, 0]
d = []

for i in itertools.product(mylist, repeat = len(s)-1):
    temp = s[0]
    result = 0
    for j, k in zip(s[1:], i):
        if k != 1:
            temp = temp * 10 + j
        else:
            result += temp
            temp = j
    result += temp
    d.append(result)
    
print(sum(d))

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

Solution (Python):
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
s = rs()
n = len(s)
ans = 0
for bit in range(1 << n - 1):
    tmp = 0
    for i in range(n - 1):
        if bit & (1 << i):
            ans += int(s[tmp:i+1])
            tmp = i + 1
    ans += int(s[tmp:n])
print(ans)

Solution (Python):
s = input()
l = list(s)
sum_ = 0
for i in range(1 << len(l) -1):
    ll = []
    for j in range(len(l)):

        ll +=[l[j]]
        if i & (1 << j):
            ll +=['+']

    sum_ += eval(''.join(ll))
print(sum_)

Solution (Python):

















def solve():
    S = input()
    eS = S[0]
    print(dfs(0, S, eS))


def dfs(i, S, eS):
    if i == len(S)-1:
        return eval(eS)
    return dfs(i+1, S, eS+(S[i+1])) + dfs(i+1, S, eS+'+'+(S[i+1]))


if __name__ == '__main__':
    solve()

Solution (Python):
def solve():
    S = input()
    n = len(S) - 1
    ieS = S[0]
    for i in range(n):
        ieS += '*'
        ieS += S[i+1]
    ans = 0
    for i in range(2 ** n):
        eS = ieS
        for j in range(n):
            if (i >> j) & 1:
                eS = eS[:(j+1)*2-1] + '+' + eS[(j+1)*2:]
        ans += eval(eS.replace('*', ''))
    print(ans)





if __name__ == '__main__':
    solve()

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

Solution (Python):
def solve(S):
    N = len(S) - 1
    ret = 0
    used_equation = set()
    for i in range(pow(2, N)):
        tmp_equation = ''
        last_j = -1
        for j in range(N):
            if i >> j & 1:
                tmp_equation = tmp_equation + '+' + S[last_j + 1: j + 1]
                last_j = j
        if last_j < N:
            tmp_equation = tmp_equation + '+' + S[last_j + 1:]
        ret += eval(tmp_equation) if tmp_equation not in used_equation else 0
        used_equation.add(tmp_equation)
    print(ret)

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

Solution (Python):
n = list(input())
ans = 0
for i in range(2**(len(n)-1)):
    plus = [""]*(len(n))
    fomula = ""
    for j in range(len(n)-1):
        if(i>>j & 1):
            plus[j] = "+"
    for i in range(len(n)):
        fomula += n[i] + plus[i]
    ans += eval(fomula)
print(ans)

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

for i in range(2 ** n):
  l = s[0]
  for j in range(n):
    if (i >> j) & 1:
      l += "+"
    l += s[j+1]
  ans += sum(map(int,l.split("+")))
print(ans)

Solution (Python):
from itertools import product
def main():
    s = list(input())
    koho = len(s) - 1
    pat = tuple(product(('+', ''), repeat = koho))
    r = 0
    for pate in pat:
        a = []
        for i, p in enumerate(pate):
            a.append(s[i])
            a.append(p)
        a.append(s[-1])
        r  += eval("".join(a))
    print(r)

if __name__ == '__main__':
    main()

Solution (Python):
s=list(input())
n=len(s)
ans=0
for i in range(2**(n-1)):
    d=0
    s=list(x for x in s if x!="a")
    for j in range(n-1):
        if (i >> j)&1:
            s.insert(-j-1-d,"a")
            d+=1
    z="".join(s)
    y=list(map(int,z.split("a")))
    ans+=sum(y)
print(ans)

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

Solution (Python):
def main():
    s = input()
    f = s[0]
    n = len(s) - 1
    ans = 0
    
    for i in range(2 ** (n)):
        res = [0] * (n)
        for j in range(n):
            if (i >> j) & 1:
                res[j] = 1
                f += '+'
            f += s[j+1]
        ans += sum(map(int, f.split("+")))
        
        
        f = s[0]
    print(ans)

if __name__ == '__main__':
    main()

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

sum = 0
for bit in range(2 ** N):
    E = S[0]
    for i in range(N):
        if (bit & (1 << i)):
            E += ' + '
        E += S[i + 1]
    sum += eval(E)

print(sum)

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

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

    else:
        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):
A = list(map(int, list(input())))
 
ans = 0
from itertools import *
N = len(A)-1
for p in product([0,1],repeat=N):
    now = A[0]
    for i in range(N):
        if p[i] == 0:
            now = now*10+A[i+1]
        else:
            ans += now
            now = A[i+1]
    ans += now
print(ans)

Solution (Python):
S=list(input())
ans=0
for i in range(2**(len(S)-1)):
    kari=[""]*(len(S)-1)
    for j in range(len(S)-1):
        if ((i>>j)&1):
            kari[j]="+"
    hako=[]
    kasu=0
    gomi=0
    for j in range(len(kari)+len(S)):
        if j%2==0:
            hako.append(S[kasu])
            kasu+=1
        else:
            hako.append(kari[gomi])
            gomi+=1
    
    hako="".join(hako)
    
    
    ans+=eval(hako)
print(ans)

Solution (Python):
A = list(map(int, list(input())))

ans = 0
from itertools import *
N = len(A)-1
for p in product([0,1],repeat=N):
    now = A[0]
    for i in range(N):
        if p[i] == 0:
            now = now*10+A[i+1]
        else:
            ans += now
            now = A[i+1]
    ans += now
print(ans)

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

n = len(s) - 1 
plus_list = list(product(["+", ""], repeat=n))

ans = 0

for bit in range(1 << n):
    formula = s[0]
    for j, k in zip(plus_list[bit], s[1:]):
        formula += (j + k)
    ans += eval(formula)

print(ans)

Solution (Python):
S=list(input())
ans=0
for i in range(2**(len(S)-1)):
    kari=[""]*(len(S)-1)
    for j in range(len(S)-1):
        if ((i>>j)&1):
            kari[j]="+"
    hako=[]
    kotae=0
    kasu=0
    gomi=0
    for j in range(len(kari)+len(S)):
        if j%2==0:
            hako.append(S[kasu])
            kasu+=1
        else:
            hako.append(kari[gomi])
            gomi+=1
    
    hako="".join(hako)
    
    
    kotae=eval(hako)
    ans+=kotae
print(ans)

Solution (Python):
S=list(input())
ans=0
for i in range(2**(len(S)-1)):
    kari=[""]*(len(S)-1)
    for j in range(len(S)-1):
        if ((i>>j)&1):
            kari[j]="+"
    hako=[]
    kotae=0
    kasu=0
    gomi=0
    for j in range(len(kari)+len(S)):
        if j%2==0:
            hako.append(S[kasu])
            kasu+=1
        else:
            hako.append(kari[gomi])
            gomi+=1
    
    hako="".join(hako)
    
    
    kotae=eval(hako)
    ans+=kotae
print(ans)

Solution (Python):
S=list(input())
ans=0
for i in range(2**(len(S)-1)):
    kari=[""]*(len(S)-1)
    for j in range(len(S)-1):
        if ((i>>j)&1):
            kari[j]="+"
    hako=[]
    kotae=0
    kasu=0
    gomi=0
    for j in range(len(kari)+len(S)):
        if j%2==0:
            hako.append(S[kasu])
            kasu+=1
        else:
            hako.append(kari[gomi])
            gomi+=1
    
    hako=",".join(hako)
    hako=hako.replace(",","")
    
    kotae=eval(hako)
    ans+=kotae
print(ans)

Solution (Python):
n = input()

if len(n) < 2:
    print(n)
    exit()

kumi = []
iti = 0

for x in range(2 ** (len(n) -1)):
    for m in range(len(n) -1):
        if (x >> m) & 1:
            kumi.append(n[iti:m+1])
            iti = m+1
        if m == len(n) -2:
            kumi.append(n[iti:m+2])
    iti = 0

kumi_int =[int(s) for s in kumi]
print(sum(kumi_int))

Solution (Python):
import copy

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

for i in range(2 ** n):
    x = copy.deepcopy(s)
    y = 1
    for j in range(n):
        if ((i >> j) & 1): 
            x = x[:j+y] + "+" + x[j+y:]
            y += 1
    ans += eval(x)

print(ans)

Solution (Python):
from sys import stdin,setrecursionlimit
setrecursionlimit(10**6)
def S(): return stdin.readline().rstrip()

def f(ls,stock,save):
    if len(ls)<1:
        return int(stock)+save
    else:
        stock += ls.pop(0)
        sum = 0    
        if 0<len(ls):
            buff = ls[:]
            sum += f(buff,'0',save+int(stock))
        buff = ls[:]
        sum += f(buff,stock,save)
        return sum

s = S()
ls = list(s)
ans = f(ls,'0',0)
print(ans)

Solution (Python):
S = input()
ans = 0
for i in range(2**(len(S)-1)):
    moji = S[0]
    tmp = 0
    for j in range(len(S)-1):
        if ((i >>j) & 1):
            moji = moji + '+' + S[j +1]
        else:
            moji = moji + S[j+1]
    tmp = moji.split('+')
    for k in range(len(tmp)):
        ans += int(tmp[k])
print(ans)

Solution (Python):
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

s = ns()
ans = 0
n = len(s)
t = 2**(n-1)
for i in range(t):
    moji = list(s)
    for j in range(n):
        if (i >> j) & 1:
            moji.insert(n-j-1,'+')
    ans += eval(''.join(moji))
print(ans)

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

Solution (Python):
s = input()
n = len(s)
ans = 0
for i in range(2 ** (n-1)):
    tmp = []
    for k in range(n-1):
        tmp.append(s[k])
        if i>>k & 1:
            tmp.append("+")
    tmp.append(s[-1])
    ans += eval("".join(tmp))
print(ans)

Solution (Python):
s = input()
n = len(s) - 1
answers = []
sl = [s[i] for i in range(len(s))]
for i in range(2 ** n):
    tmp = []
    for j in range(n):
        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(_) for _ in ans if _ != '+']
    ans = sum(ans)
    answers.append(ans)
print(sum(answers))

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

ans = 0
bit_n = n-1
for i in range(2**bit_n):
    tmp = 0
    res = int(s)
    mod = 10
    for j in range(bit_n):
        if ((i>>j)&1):
            tmp+=res%mod
            res//=mod
            mod=10
        else:
            mod*=10
    ans+=res
    ans+=tmp
print(ans)

Solution (Python):
s = input()
res_list = []
ls = len(s)
for i in range(2**(ls-1)):
    res = s[0]
    for j in range(ls-1):
        if (i >> j) & 1:
            res += '+'
        res += s[j+1]
    res_list.append(eval(res))
print(sum(res_list))

Solution (Python):
s = input()
n = len(s)
ans = 0
for i in range(2**(n-1)):
    x = []
    for j in range(n):
        x.append(s[j])
        if (i>>j) & 1:
            y = int("".join(x))
            ans += y
            x = []
        else:
            pass
    if x != []:
        y = int("".join(x))
        ans += y
print(ans)

Solution (Python):
S=input()

def f(s):
    sum=0
    if len(s)==1:
        return int(s)
    for i in range(1,len(s)):
        sum+=(2**(len(s)-i-1))*int(s[:i])+f(s[i:])
    return sum+int(s)

print(f(S))