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)
import copy

ans = [0]

def rec(index,tmp,tmp_list):
    
    if index > n-1:

        tmp_list.append(tmp)
        
        
        ans[0] += sum(tmp_list)
        return

    tmp_list1 = copy.deepcopy(tmp_list)
    tmp_list2 = copy.deepcopy(tmp_list)
    
    
    tmp_list1.append(tmp)
    rec(index+1,int(S[index]),tmp_list1)

    rec(index+1,10*tmp + int(S[index]),tmp_list2)
    return

rec(1,int(S[0]),[])
print(ans[0])

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

print(ans)

Solution (Python):
st_N=input()
N=int(st_N)


output=0
for i in range(1<<(len(st_N)-1)):
    f=st_N[0]
    for j in range(len(st_N)-1):

        if((i>>j) & 1)==1:
            f=f+'+'
        f=f+st_N[j+1]
    
    output=output+sum(map(int,f.split('+')))

print(output)

Solution (Python):
s = input()
n = len(s)
p = []
for i in range(2 ** (n-1)):
    tmp = [' '] * (n-1)
    for j in range(n-1):
        if i >> j & 1:
            tmp[j] = "+"
    p.append(tmp)
ans = []
s = list(s)
s_ = []
for i in range(n):
  if(i == n-1):
    s_.append(s[i])
    break
  s_.append(s[i])
  s_.append(" ")

s__ = []
for i in range(len(p)):
  tmp = s_
  tmp[1::2] = p[i]
  
  tmp = [a for a in tmp if a != ' ']
  temp = ''.join(tmp)
  
  if("+" in temp):
    ans.append(eval(temp))
  else:
    ans.append(int(temp))
print(sum(ans))

Solution (Python):
S = list(input())
s = len(S)-1
from itertools import product
a = list(product(["+",""],repeat=s))
ans = 0
for i in a:
    b = ""
    for j in range(len(S)):
        if j<=s-1:
            b += S[j]
            b += i[j]
        else:
            b += S[j]
    ans += eval(b)
print(ans)

Solution (Python):
from itertools import product

S = input()

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

ans = 0

for pattern in patterns:
    cnt = 0
    num = ""
    for i in range(len(pattern)+1):
        if i == 0:
            num = num + S[i]
        else:
            if pattern[i-1] == "+":
                cnt += int(num)
                num = S[i]
            else:
                num = num + S[i]
    cnt += int(num)
    ans += cnt


print(ans)

Solution (Python):
s = list(input())
n = (len(s)-1)
sum = 0
pt = []
for i in range(2 ** n):
  tmp = [""] * n
  for j in range(n):
    if (i >> j) &1 :
      tmp[j] = "+"
  pt.append(tmp)
  
for p in pt:
  fr = ""
  for j in range(n):
    
    fr += s[j] + p[j]
  sum += eval(fr+s[n])
    
print(sum)

Solution (Python):
s = input()
res_list = []
for i in range(2**(len(s)-1)):
    res = s[0]
    for j in range(len(s)-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)):
    c = 10
    tmp = int(s)
    res = 0
    for j in range(n-1):
        if ((i>>j)&1):
            res+=tmp%c
            tmp=tmp//c
            c=10
        else:
            c*=10
    ans+=res+tmp
print(ans)

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

Solution (Python):
ss = input()
ans = []

def bfs(exp, x):
    
    if x == len(ss):
        return exp
    nxt = None
    
    if exp[-1] == '+':
        nxt = ss[x]
        ret = bfs(exp+nxt, x+1)
        if ret:
            s_ = sum([int(i) for i in ret.split("+")])
            ans.append(s_)
    else:
        nxt = ss[x]
        ret = bfs(exp+nxt, x+1)
        if ret:
            s_ = sum([int(i) for i in ret.split("+")])
            ans.append(s_)
        ret = bfs(exp+'+', x)
        if ret:
            s_ = sum([int(i) for i in ret.split("+")])
            ans.append(s_)
if len(ss) == 1:
    print(int(ss))
else:
    bfs(ss[0],1)
    print(sum(ans))

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

for n in range(1 << N-1):
    s = S
    cnt = 0
    for i in range(N-1):
        if (n >> i) & 1 == 1:
            s = s[:i+cnt+1] + "+" + s[i+cnt+1:]
            cnt += 1
    ans += eval(s)

print(ans)

Solution (Python):
import itertools
S=input()
lis = list(itertools.product([0,1], repeat=len(S)-1))
ans=0
for li in lis:
    st=0
    x=0
    for i in range(len(S)-1):
        if li[i]==1:
            x += int(S[st:i+1])
            st = i+1
            
    x += int(S[st:])
    
    ans += x         
print(ans)

Solution (Python):
def resolve():
    S = input()
    sumA = 0
    for i in range(2**(len(S) - 1)):
        Stmp = list(S)
        for j in range(len(S) - 2, -1, -1):
            if (i >> j) & 1:
                Stmp.insert(j + 1, "+")
        sumA += eval("".join(Stmp))
    print(sumA)


resolve()

Solution (Python):
s = input()
res_list = []

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

print(sum(res_list))

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

ans = 0

for bit in range(2 ** (l-1)):
    f = s[0]
    for i in range(l-1):
        if ((bit >> i) & 1):
            f += '+'
        f += s[i+1]

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

Solution (Python):

from itertools import product
S = input()
n = len(S)-1
total =0
for i in list(product(["","+"],repeat=n)):
    bag=""
    for ind,val in enumerate(S):
        if ind ==0:
            bag+=val
        else:
            bag+=i[ind-1]+val
    total +=eval(bag)        
print(total)

Solution (Python):

S =(input())
n = len(S)-1
total = 0
for i in range(2**n):
    bag = ""
    for ind,val in enumerate(S):
        bag+=val
        if ((i>>ind)&1):
            bag+="+"
    total+=eval(bag)
print(total)

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

Solution (Python):
S = input()

def saiki(n, s=S[0]):
    _sum = 0
    
    if n==len(S)-1:

        return eval(s)
    
    _sum += saiki(n+1, s + "+" + S[n+1])
    _sum += saiki(n+1, s + S[n+1])
    
    return _sum
    
print(saiki(0))

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

wa = 0
for i in range(2**n):
    lst = [""]*n
    for j in range(n):
        if i&(1<<j):
            lst[j] = "+"
    lst_s = [0]*(len(s) + n)
    lst_s[::2] = s
    lst_s[1::2] = lst
    
    wa += eval("".join(lst_s))
print(wa)

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

wa = 0
for i in range(2**n):
    lst = [""]*n
    for j in range(n):
        if i&(1<<j):
            lst[j] = "+"
    lst_s = [0]*(len(s) + n)
    lst_s[::2] = s
    lst_s[1::2] = lst
    
    wa += eval("".join(lst_s))
print(wa)

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 = str(input())
N = 2 ** (len(S)-1)
l = [] 
for i in range(N):
  m = [S] 
  cnt = 0
  for j in range(len(S)-1):
    if (i >> j) & 1:
      m.append(m[-1][:cnt+1])
      m.append(m[-2][cnt+1:])
      del m[-3]
      cnt = 0
    else:
      cnt += 1
  m = [int(s) for s in m]
  l.append(sum(m))
print(sum(l))

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

cnt = 0

for i in range(2**lng):
    A = format(i, '09b')
    A = A[-lng:]
    
    slc = 0
    for j in range(lng):
        
        
        if int(A[j]):
            
            cnt += int(S[slc:j+1])
            
            slc = j +1
    
    cnt += int(S[slc:])
print(cnt)

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

ans = 0

for bit in range(1 << (l-1)):
    
    f = S[0]
    for i in range(l-1):
        if bit & (1 << i):
            f += "+"
        f += S[i+1]

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

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

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


def dfs(i, f):
    if i == n-1:
        return eval(f)

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


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

Solution (Python):
s = str(input())
l = len(s)
ans = 0
x = 2**(l-1)
dg = [[] for i in range(x)]
for i in range(x):
    b = 0
    d = 0
    tmp = 0 

    for j in range(l):
        b = int(s[j])
        d = d*10 +b
        if i>>j&1 :
            tmp += d
            dg[i].append(d)
            d = 0
    tmp += d
    ans += tmp
    dg[i].append(d)


print(ans)

Solution (Python):



import sys


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


def resolve():
    s = input().rstrip()

    ans = 0
    int_list = []
    for bit in range(1<<len(s)-1):

        plus_list = []
        for i in range(len(s)-1):
            
            if bit & (1<<i):
                plus_list.append(i)

        

        if len(plus_list) == 0:
            int_list.append(s)
        else:
            pre = 0
            temp_list = []
            for i, plus in enumerate(plus_list):
                if i == 0:
                    temp_list.append(s[:plus+1])
                    temp_list.append(s[plus+1:])
                    pre = plus+1
                else:
                    temp_s = temp_list.pop(i)
                    temp_list.append(temp_s[:plus+1-pre])
                    temp_list.append(temp_s[plus+1-pre:])
                    pre = plus+1

            for s2 in temp_list:
                int_list.append(s2)


        


    for num in int_list:
        ans += int(num)




    print(ans)


if __name__ == "__main__":
    resolve()

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

def saiki(i,s = S[0]):
    _sum = 0
    if i == len(S) - 1:
        ans = eval(s)
        return ans
    a = saiki(i + 1, s + "+" + S[i+1])
    b = saiki(i + 1, s + S[i+1])
    
    return a + b
    
print(saiki(0))

Solution (Python):
S = input()

def saiki(i,s = S[0]):
    _sum = 0
    if i == len(S) - 1:
        ans = eval(s)
        return ans
    _sum += saiki(i + 1, s + "+" + S[i+1])
    _sum += saiki(i + 1, s + S[i+1])
    
    return _sum
        
print(saiki(0))

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

Solution (Python):



def main():
    S = input()
    l = len(S)-1
    ret = 0
    for i in range(2**l):
        fs = S[0]
        for j in range(l):
            if (i>>j & 1) == 1:
                fs += '+'
            fs += S[j+1]
        ret += eval(fs)
    print(ret)

if __name__ == '__main__':
    main()

Solution (Python):
S=list(map(int,input()))
s=len(S)
if s==1:
    print(S[0])
else:

    s=s-1
    t=pow(2,s)
    l=len(list(format(t-1,'b')))
    x=0
    for i in range(t):
        k=list(format(i,'b'))
        L=[0]*l
        x+=S[-1]
        v=1
        for i in range(l):
            if i+1<=len(k):
                L[l-i-1]=k[-1-i]
            if int(L[l-i-1])==0:
                v=v*10
                x+=v*S[len(S)-2-i]
            else:
                v=1
                x+=S[len(S)-2-i]
    print(x)

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

Solution (Python):
s = input()
n = len(s)-1
if n == 0:
    print(s)
    exit()

ans = 0
for i in range(2**n):
    data = []
    for j in range(n):
        if((i >> j) & 1):
            data.append(1)
        else:
            data.append(0)
    
    num = s[0]
    x = []
    for i in range(n-1):
        if data[i] == 1:
            x.append(int(num))
            num = s[i+1]
        else:
            num += s[i+1]
    if data[-1] == 0:
        num += s[-1]
        x.append(int(num))
    else:
        x.append(int(num))
        x.append(int(s[-1]))
    ans += sum(x)
    
print(ans)

Solution (Python):


def susiki(n, s, dest):
    if n == len(s):
        tmp = 0
        pre = 0
        for d in dest:
            tmp += int(s[pre:d])
            pre = d
        tmp += int(s[pre:])
        return tmp
    return susiki(n+1, s, dest+[n]) + susiki(n+1, s, dest)

s = input()
l = len(s)

print(susiki(1, s, []))

Solution (Python):
S = input()
S_damy = S
sum_S = 0
plus = 2**(len(S)-1)
for i in range(plus):
    for j in range(len(S)-1):
        if i >> j & 0b1:
            sum_S += int(S_damy[len(S)-1-j:])
            if S_damy:
                S_damy = S_damy[:len(S)-1-j]

        if j == len(S)-2 and S_damy:
            sum_S += int(S_damy)
    S_damy = S
if len(S) == 1:
    print(S)
else:
    print(sum_S)

Solution (Python):
s=input()

l=len(s)

count=0
for i in range(2**(l-1)):
    memory=0
    for j in range(l-1):
        if ((i>>j)&1):
            
            count+=int(s[memory:j+1])
            memory=j+1
    
    count+=int(s[memory:])

print(count)

Solution (Python):
N=input()

num=list(N)
sum=0;
for i in range(1 << len(num)-1):
    l=[]
    for j in range(len(num)):
        l+=num[j]
        if (j != len(num)-1):
            if (i & (1<<j)):
                l+=['+']
        
    sum+=eval("".join(l))
print(sum)

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

        li += l[j]
        if j != len(s)-1:
            if i & 1 <<j:
                li += ['+']

        
    r += eval(''.join(li))
print(r)

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

def add(n, s):
    if n == 0:
        tmp = 0
        for i in s.split('+'):
            tmp += int(i)
        return tmp
    else:
        st = s[:n] + '+' + s[n:]
        return add(n-1, st) + add(n-1, s)

print(add(N, S))

Solution (Python):
s = input()
sa = [i for i in s]
r = 0
for i in range(2**(len(s)-1)):  
    si = sa[0]
    for j in range(len(s) - 1):
        t = 2 ** j  
        if i & t:  
            si += '+'  
        si += sa[j+1]
    r += eval(si)  

print(r)

Solution (Python):
from itertools import product

S = input()

s = 0
for bits in product((False, True), repeat=len(S) - 1):
    buf = S
    for i in range(len(bits)):
        if bits[i]:
            sep = len(S) - (i + 1)
            buf = buf[:sep] + ' ' + buf[sep:]
    s += sum(map(int, buf.split()))

print(s)

Solution (Python):
from itertools import chain, combinations


def powerset(iterable):
    s = list(iterable)
    return chain.from_iterable(combinations(s, r) for r in range(len(s) + 1))


def s_to_num(s):
    numlst = list(map(int, s))
    res = 0
    for i in numlst:
        res *= 10
        res += i
    return res


s = input()
length = len(s)
res = 0
for i in powerset(range(1, length)):
    if not i:
        res += int(s)
    else:
        jlst = [0] + list(i) + [length]
        for j in range(len(jlst) - 1):
            res += s_to_num(s[jlst[j]:jlst[j + 1]])
print(res)

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

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

for i in range(2**(n-1)):
    tmp = 0
    for j in range(n-1):
        if i & (1 <<(n-2 -j)):
            ans += 10*tmp + int(S_str[j])
            tmp = 0
        else:
            tmp = 10*tmp + int(S_str[j]) 
    ans += 10*tmp + int(S_str[-1])
print(ans)

Solution (Python):
s = input()
res = int(s)
length = len(s)
for i in range(1, 2**(length-1)):
    res_i = 0
    b = bin(i)[2:].zfill(length-1)
    s_ = s[0]
    idx = 0
    while idx < length - 1:
        for bi in b:
            if int(bi):
                res_i += int(s_)
                idx += 1
                s_ = s[idx]
            else:
                idx += 1
                s_ += s[idx]
    res_i += int(s_)
    res += res_i
print(res)

Solution (Python):
S = list(input())
num_cnt = len(S) - 1
total = 0

for i in range(2 ** num_cnt):
    temp_sum = S[0]
    for j in range(num_cnt):
        if ((i >> j) & 1):
            temp_sum = temp_sum + '+' + str(S[j+1])
        else:
            temp_sum = temp_sum  + S[j+1]
    total += eval(temp_sum)

print(total)

Solution (Python):
from sys import stdin


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

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

Solution (Python):



import sys


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


def all_search(s, i, i_sum: int, temp):
    n = int(s[i])

    if i == len(s)-1:
        
        i_sum += temp + n
        return i_sum
    else:
        ret = all_search(s, i+1, i_sum, (temp+n)*10) + all_search(s, i+1, i_sum+temp+n, 0)
        return ret




def resolve():
    s = input().rstrip()

    print(all_search(s, 0, 0, 0))



if __name__ == "__main__":
    resolve()

Solution (Python):
N = str(input())
t = len(N)
bi_li =[]
li_formula = []
total = 0

for i in range(2**(t-1)):
    temp =[0 for _ in range(t-1)]
    for p in range(t-1):
        if ((i >> p) & 1):
            temp[p] =1
    bi_li.append(temp)

for k in bi_li:
    formula =""
    for j in range(t+len(k)):
        if j%2==0:
            formula+=N[int(j/2)]
        else:
            if k[j//2] == 1:
                formula+="+"
    li_formula.append(formula)

for l in li_formula:
    total += eval(l)
print(total)

Solution (Python):
s = input()

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

    for p_n, p_o in zip(s,op+['']):
        f += p_n + p_o
    ans += eval(f)

print(ans)

Solution (Python):
s = input()
ans = 0
for bit in range(2 ** (len(s) - 1)):
    i = 0
    tmp = []
    for j in range(1, len(s) + 1):
        if j != len(s) and bit >> (j - 1) & 1 == 0: continue
        tmp.append(int(s[i:j]))
        i = j
    ans += sum(tmp)
print(ans)

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

a = 0
for x in  range(2**n):
  ans = s[0]
  for y in range(n):
    if (x>>y)&1:
      ans = ans + "+" + s[y+1]
    else:
      ans = ans + s[y+1]
  a += eval(ans)
print(a)

Solution (Python):
S = input()

length = len(S)
ans = 0

for x in range(2 ** (length - 1)):
    res = ""
    b = str(format(x, '010b'))
    for i in range(length):
        res += str(S[i])
        if b[-(i + 1)] == "1":
            res += "+"
    res = res.split("+")
    ans += sum(list(map(int,res)))
        
print(ans)

Solution (Python):
S = input()

length = len(S)
ans = 0

for x in range(2 ** (length - 1)):
    res = ""
    b = str(format(x, '010b'))
    for i in range(length):
        res += str(S[i])
        if b[-(i + 1)] == "1":
            res += "+"
        else:
            pass
    ans += eval(res)
        
print(ans)

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

Solution (Python):
S = input()

s = len(S)-1
ans=0
for bit in range(1 << s):
    a = S[0]
    for i in range(s):
        if bit & (1<<i):
            a += "+"
        a += S[i+1]
    ans += sum(map(int,a.split("+")))
print(ans)

Solution (Python):
S = input()
n = len(S) - 1
sumLine = 0
for i in range(2 ** n):
  op = [0] * (n)
  e = ''
  for j in range(n):
    if (i >> j) & 1  :
      e += S[j] + '+'
    else:
      e += S[j]

  sumLine += eval(e+S[-1])
print(sumLine)

Solution (Python):


s=input()
n=len(s)

num=0
for i in range(2**(n-1)):
    flag=[]

    for j in range(n-1):
        if (i>>j)&1:
            flag.append(j)

    if len(flag)==0:
        num+=int(s)
        
    else:
        for i in range(len(flag)):
            flag[i]+=1
        flag.insert(0,0)
        flag_num=len(flag)
        for k in range(flag_num-1):
            num+=int(s[flag[k]:flag[k+1]])
            
        num+=int(s[flag[-1]:])
        

print(num)

Solution (Python):
S = input()
lenS = len(S)
ans = 0
def f(SUM,TMP,N):
    n = int(S[N])
    if N == lenS-1:
        SUM += TMP + n
        return SUM
    else:
        ret = f(SUM,(TMP+n)*10,N+1) + f(SUM+TMP+n,0,N+1)
        return ret

print(f(0,0,0))

Solution (Python):
import copy
S = [c for c in input()]

X = [[]]
for i in range(len(S) - 1):
    X0, X1 = [], []
    for x in X:
        x0 = copy.deepcopy(x)
        x0.append(0)
        X0.append(x0)
        x1 = copy.deepcopy(x)
        x1.append(1)
        X1.append(x1)
    X = X0 + X1
Y = []
for x in X:
    bf = ''
    for i in range(len(S)):
        bf = bf + str(S[i])
        if i == len(S) - 1 or x[i] == 1:
            Y.append(int(bf))
            bf = ''
    if bf != '':
        Y.append(int(bf))
print(sum(Y))

Solution (Python):
import sys
from math import sqrt
from collections import Counter, defaultdict, deque

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


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


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


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


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

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

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
def func(i,x,s,new):
    if i==x:
        count=0
        
        new+=s[-1]
        li=new.split("+")
        for j in li:
            count+=int(j)

        return count

    
    return func(i,x+1,s,new+s[x-1]+"+") + func(i,x+1,s,new+s[x-1])

new=""
S=input()
print(func(len(S),1,S,new))

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MAX = 10**18
MIN = -10**18
MOD = 998244353


def judge(li):
    c = s[0]
    for i in range(len(li)):
        if li[i] == False:
            c += s[i+1]
        else:
            c += "+" + s[i+1]
    return c
s = input()
n = len(s)-1
ans = 0
for i in range(2**n):
    li = [False]*(n)
    for j in range(n):
        if (i>>j)&1:
            li[n-j-1] = True
    a = judge(li)
    e = a[0]
    sumli = []
    for j in range(1,len(a)):
        if a[j] == "+":
            sumli.append(int(e))
            e = ""
        else:
            e += a[j]
    sumli.append(int(e))
    ans += sum(sumli)
print(ans)

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

def split_list(S):
  Slist.append(int(''.join(S)))
  N = len(S)
  if N == 1:
    return
  for n in range(1, N):
    S1 = ''.join(S[:n])
    r = 2**(N-n-1)
    
    for i in range(r):
    	Slist.append(int(S1))
    
    split_list(S[n:])
    
  

split_list(S)
ans = sum(Slist)
print(ans)

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

answer = 0
for i in range(2 ** (n - 1)):
    total_sum = 0
    tmp = S[0]
    for j in range(n - 1):
        if (1 << j) & i:
            total_sum += int(tmp)
            tmp = S[j + 1]
        else:
            tmp += S[j + 1]
    total_sum += int(tmp)
    answer += total_sum

print(answer)

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

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

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):
S = input()
N = len(S) - 1

ans = 0
for i in range(2 ** N):
    add_pos = []
    for j in range(N):
        if (i >> j) & 1:
            add_pos.append(j + 1)

    to_be_sumed = []

    if not add_pos:
        to_be_sumed.append(int(S))

    for i in range(len(add_pos)):
        if i == 0:
            to_be_sumed.append(int(S[:add_pos[i]]))
            if i == len(add_pos) - 1:
                to_be_sumed.append(int(S[add_pos[i]:]))
        else:
            to_be_sumed.append(int(S[add_pos[i - 1]:add_pos[i]]))
            if i == len(add_pos) - 1:
                to_be_sumed.append(int(S[add_pos[i]:]))
    
    ans += sum(to_be_sumed)
print(ans)

Solution (Python):
S = input()

def rec(n, s):
    if n == 1:
        ans = 0
        for i in s.split("+"):
            ans += int(i)
        return ans
    
    
    return rec(n-1, s) + rec(n-1, s[:-n+1]+"+"+s[-n+1:])

print(rec(len(S), S))

Solution (Python):
s=input()
l=len(s)-1
res = 0

for i in range(2**l):
    s_new = s[0]
    for j, c in enumerate(s[1:]):
        flag = True if (i>>j)%2==1 else False
        s_new += c if flag else "+"+c
    res += eval(s_new)
print(res)

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

ans=0
for i in range(2**(len_s-1)):
    tmp=0
    start=0
    end=0
    for j in range(len_s-1):
        if ((i>>j)&1):
            tmp+=int(s[start:end+1])
            start=j+1
            end=j+1
        else:
            end+=1
    tmp+=int(s[start:end+1])
    ans+=tmp
print(ans)

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

all_sum=0
def dfs(l,N,S):
    X=[[] for n in range(N+1)]
    X[0]=[S[0]]
    cnt=0
    temp=0
    if len(l)==N:
        global all_sum
        for n in range(N):
            if l[n]==0:
                X[cnt].append(S[n+1])
            else:
                cnt+=1
                X[cnt].append(S[n+1])
        for i in range(N+1):
            if X[i]!=[]:
                temp+=int("".join(X[i]))
        all_sum+=temp         
        return
    else:
        for n in range(2):
            l.append(n)
            dfs(l,N,S)
            l.pop()
dfs([],N,S)
print(all_sum)

Solution (Python):
S = input()
n = len(S)
N = []
M = []
for i in range(n):
    N.append(S[i])
Nsum = 0
a = 0
for Ni in N:
    n = len(S) - a
    m = 2 ** a
    Nsum += m * int(Ni) * 10 ** (n - 1)
    n -= 1
    while n > 0:
        Nsum += m * int(Ni) * 10 ** (n - 1)
        m *= 2
        n -= 1
    a += 1
print(Nsum)

Solution (Python):
S = input()
n = len(S)
N = []
M = []
for i in range(n):
    N.append(S[i])
Nsum = 0
a = 0
for Ni in N:
    n = len(S) - a
    m = 2 ** a
    Nsum += m * int(Ni) * 10 ** (n - 1)
    n -= 1
    while n > 0:
        Nsum += m * int(Ni) * 10 ** (n - 1)
        m *= 2
        n -= 1
    a += 1
print(Nsum)

Solution (Python):
import itertools

s = input()
sum_formula = 0
for pluses in itertools.product(['+', ''], repeat=len(s)-1):
    formula = s[0]
    for i in range(len(s) - 1):
        formula += pluses[i] + s[i + 1]
    sum_formula += eval(formula)
print(sum_formula)

Solution (Python):
import itertools

S = input()
ALL = list(itertools.product(["+",""],repeat=len(S)-1))


count = 0
for kigou in ALL:
    
    
    tmp = ""
    for i in range(len(S)-1):
        tmp += S[i]
        tmp += kigou[i]
    tmp += S[len(S)-1]
    
    count += eval(tmp)

print(count)

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

for i in range(2**space):
    t=[0]*space
    for j in range(space):
        if ((i>>j)&1)==1:
            t[-j-1]="+"

    fomula=s[0]
    for k in range(1, l):
        if t[k-1]==0:
            fomula=fomula+s[k]
        else:
            fomula=fomula+t[k-1]+s[k]
    
    add=eval(fomula)
    ans+=add

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

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

Solution (Python):
S = str(input())
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):
S = input()
n = len(S)
ans = 0
for i in range(2 ** (n-1)):
    F = [False] * (n-1)
    for j in range(n-1):
        if (i >> j) & 1:
            F[j] = True
    tmp = 0
    ct = 0
    prev = 0
    while tmp < n - 1:
        if F[tmp] == True:
            ct += int(S[prev : (tmp + 1)])
            prev = tmp + 1    
        tmp += 1
    ct += int(S[prev :])
    ans += ct
print(ans)

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

Solution (Python):
import itertools
s = list(input())
n = len(s) - 1
a = 0
for x in list(itertools.product(["+", ""], repeat=n)):
  x = list(x)
  x.append("")
  y = [d+e for d, e in zip(s, x)]
  a += eval("".join(y))
print(a)