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


num = [int(i) for i in input()]
n = len(num)

total = 0
for s in range(2**(n-1)):
    dig = [0] * n
    dig[0] = num[0]
    for i in range(n-1):
        if (s >> i & 1):
            dig[i+1] = num[i+1]
        else:
            dig[i+1] = dig[i]*10 + num[i+1]
            dig[i] = 0
    for i in range(n):
        total += dig[i]

print(total)

Solution (Python):
s = input()
ans = 0
for i in range(2**(len(s)-1)):
    l = [""]*(len(s)-1)
    x = 0
    sx = ""
    for j in range(len(s)-1):
        if ((i>>j)&1):
            l[x]="+"
        x+=1
    for si,p in zip(s,l):
        sx+=si
        sx+=p
    ans+=eval(sx+s[-1])
print(ans)

Solution (Python):
from itertools import product
s = list(input())
n = len(s)-1

ans = 0
for x in list(product(["", "+"], repeat=n)):
    x = list(x)
    x.append("")
    
    strs = [i+j for i, j in zip(s, x)]
    ans += eval("".join(strs))
print(ans)

Solution (Python):
'''


'''





import sys
input = sys.stdin.readline

def main():
    '''メイン処理'''
    all_sum = 0
    
    S = input().strip()
    
    n = (len(S)-1)    
    
    for i in range(2**n):
        ope_list = [""] * n
        
        bin_str = bin(i)[2:].zfill(n)
        
        for j in range(n):
            if bin_str[j] == '1':
                ope_list[j] = "+"
        
        calc_str = S[0]
        for s, ope in zip(S[1:], ope_list):
            calc_str += ope+s
        all_sum += eval(calc_str)
    
    print(all_sum)


if __name__ == "__main__":
    
    main()

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


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

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

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

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

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

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







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

Solution (Python):
def main():
    S = input()
    n = len(S)
    bit = 0
    total = 0
    for bit in range(1<<n-1):
        tmp_total = 0
        tmp = S[0]
        for i in range(n-1):
            
            
            if (1<<i) & bit:
                tmp_total += int(tmp)
                tmp = S[i+1]
            else:
                tmp += S[i+1]
        tmp_total += int(tmp)
        total += tmp_total
    print(total)

if __name__ == '__main__':
    main()

Solution (Python):
s = input()

sum = 0

if len(s) > 1:

    l = ["+"] * (len(s) - 1)

    n = 2 ** (len(s) - 1)

    for i in range(n):
        l = ["+"] * (len(s) - 1)
        for j in range(len(l)):
            ls = list(s)
            if (i >> j) & 1:
                l[j] = ""
            for x in range(len(l)):
                
                ls.insert(2*x+1,l[x])
    
        

        maped_list = map(str, ls) 
        mojiretu = ''.join(maped_list)

        sum = sum + eval(mojiretu)

    print(sum)
else:
    print(s)

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

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

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

def dfs(i,s = S[0]):
    if i == n-1:
        global ans
        ans += eval(s)
        return
    dfs(i+1,s+"+"+S[i+1])
    dfs(i+1,s+S[i+1])

dfs(0)
print(ans)

Solution (Python):
def get_int(s, si, ei=None):
    
    if ei is None:
        value = int(s[si:])
    else:
        value =  int(s[si:ei])
    
    return value


BIT = 1

str_s = input()
s = int(str_s)
slen = len(str_s)

result = 0
for i in range(2 ** (slen - 1) ):
    
    s_index = 0
    for k in range(slen - 1):
        bit = (i >> k) & BIT        
        if bit == 0:
            continue
        e_index = k + 1
        value = get_int(str_s, s_index, e_index)
        result += value
        s_index = e_index
    value = get_int(str_s, s_index)
    result += value

print(result)

Solution (Python):
S = input()
N = len(S)
ans = 0
def dfs(i, s=S[0]):
    if i == N-1:
        global ans
        ans += eval(s)
        return
    dfs(i+1, s+'+'+S[i+1])
    dfs(i+1, s+S[i+1])
dfs(0)
print(ans)

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

item = [i for i in range(n)]

res = 0
for i in range(2**n):
    bag = []
    for j in range(n):
        if (i>>j) & 1:
            bag.append(item[j])

    sp = ''
    for i, keta in enumerate(s):
        sp += keta
        if i in bag: sp += '+'
    
    sl = sp.split('+')
    sl = list(map(int, sl) )
    res += sum(sl)
print(res)

Solution (Python):
s = input()
n = len(s) - 1
plus_all = []
def cal(a):
  count = 0
  left = 0
  for i in range(len(a)):
    if a[i] == True:
          count+= int(s[left:i+1])
          left = i + 1
          
  count += int(s[left:])
  return count
result = []
def dfs(A):
  if len(A) == n:
    result.append(cal(A))
    return A
  else:
    for i in range(2):
      if i == 0:
        A.append(True)
      else:
        A.append(False)
      dfs(A)
      A.pop(-1)
dfs([])
print(sum(result))

Solution (Python):
S = input()

def div_plus(i, s):
    if i == len(S):
        s_list = [int(i) for i in s.split("+")]
        return sum(s_list)
    
    pos = i - len(S)
    
    d1 = div_plus(i+1, s)
    
    
    d2 = div_plus(i+1, s[:pos]+"+"+s[pos:])
    return d1 + d2

print(div_plus(1, S))

Solution (Python):
S = input()

def div_plus(i, s):
    if i == len(S):
        s_list = [int(i) for i in s.split("+")]
        return sum(s_list)
    
    pos = i - len(S)
    
    d1 = div_plus(i+1, s)
    
    
    d2 = div_plus(i+1, s[:pos]+"+"+s[pos:])
    return d1 + d2

print(div_plus(1, S))

Solution (Python):
import math
import copy
from queue import Queue
import heapq

MOD = 1000000007









s = input()






num = len(s) - 1
kotae = 0

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

    formula = ""
    for p_n, p_o in zip(s, op + [""]):
        formula += (p_n + p_o)

    kotae += eval(formula)

print(kotae)

Solution (Python):
n=[int(x) for x in input()]
k=len(n)-1
ans=0
for i in range(2**k):
    op=[""]*k
    for j in range(k):
        if (i>>j)&1:
            op[k-j-1]="+"
    formula=""
    for p_y,p_n in zip(n,op+[""]):
        formula+=(str(p_y)+p_n)
    ans+=eval(formula)
print(ans)

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

Solution (Python):
S = input()
n = len(S)
ans = 0
for i in range(2 ** (n - 1)):
    p = [''] * (n - 1)
    for j in range(n - 1):
        if i >> j & 1:
            p[j] = '+'
    s = [None] * (2 * n - 1)
    s[::2] = list(S)
    s[1::2] = p
    s = ''.join(s)
    ans += eval(s)
print(ans)

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

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

Solution (Python):
S = list(input())
l = len(S)
ans = 0
for i in range(2**(l-1)):
    start = 0
    c = 0
    for j in range(l-1):
        if (i>>j)&1:
            end = j+1
            ans += int("".join(S[start:end]))
            start = j+1
    ans += int("".join(S[start:]))
print(ans)

Solution (Python):

import sys


def solve(S: int):
    s_array = list(str(S))
    N = len(s_array) - 1

    sum = 0
    for bit in range(2 ** N):
        num_string = s_array[0]
        for i in range(N):
            if bit & 1 << i:
                sum += int(num_string)
                num_string = s_array[i + 1]
            else:
                num_string += s_array[i + 1]
        sum += int(num_string)
    print(sum)
    
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  
    solve(S)

if __name__ == '__main__':
    main()

Solution (Python):

import sys


def solve(S: int):
    s_array = list(str(S))
    N = len(s_array) - 1

    sum = 0
    for bit in range(2 ** N):
        num_string = s_array[0]
        for i in range(N):
            if not (bit & 1 << i):
                sum += int(num_string)
                num_string = ""
            num_string += s_array[i + 1]
        sum += int(num_string)
    print(sum)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  
    solve(S)

if __name__ == '__main__':
    main()

Solution (Python):

import sys


def solve(S: int):
    s_array = list(str(S))
    N = len(s_array) - 1

    sum = 0
    for bit in range(2 ** N):
        num_string = s_array[0]
        for i in range(N):
            if not (bit & 1 << i):
                sum += int(num_string)
                num_string = ""
            num_string += s_array[i + 1]
        sum += int(num_string)
    print(sum)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  
    solve(S)

if __name__ == '__main__':
    main()

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys

def main():
    S  = input()
    n  = len(S) - 1
    sum = 0
    for i in range(2 ** n):
        ichi = 0
        for j in range(n): 
            if ((i >> j) & 1):
                sum += int(S[ichi:j+1])
                ichi = j+1
        sum += int(S[ichi:n+1])
    print(sum)



if __name__ == '__main__':
    main()

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[n-1-j] = ""
  
  a = ""
  for N,P in zip(s, op+[""]):
    a += N + P
  ans += eval(a)
print(ans)

Solution (Python):
S = [int(n) for n in list(input())]
n = len(S)
sbox = []

def f(i, box, k):
  if i==n-1:
    box += k
    sbox.append(box)
  else:
    f(i + 1, box+k, S[i+1])
    f(i + 1, box, 10*k + S[i+1])
    
f(0, 0, S[0])
print(sum(sbox))

Solution (Python):
s = input()
ln = len(s) - 1
pat = []

for i in range(2**ln):
    tmp = ['']
    for j in range(ln):
        if i >> j & 1:
            tmp.append('+')
        else:
            tmp.append('')
    pat.append(tmp)

ans = 0
for p in pat:
    tmp = ''
    for i, j in zip(p, s):
        tmp += i+j
    ans += eval(tmp)

print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
S = list(input())

l = len(S)
anss = []

for i in range(1<<l-1):
	i = list("{:b}".format(i).zfill(l-1))
	ans = []
	S_ = S.copy()
	ans.append(S_.pop(0))
	while S_ != []:
		if i.pop(0) == "1":
			ans.append("+")

		ans.append(S_.pop(0))

	anss.append(eval("".join(ans)))

print(sum(anss))

Solution (Python):

import sys
import itertools


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


def ir(): return int(sr())


def lr(): return list(map(int, sr().split()))


S = sr()
SIZE = len(S)
ans = 0


def dfs(depth, p_list):
    global ans

    if depth == SIZE - 1:
        sum_list = []
        T = S
        for j, p in enumerate(p_list):
            if p:
                sum_list.append(int(S[SIZE - len(T): j + 1]))
                T = S[j + 1:]
        if T:
            sum_list.append(int(T))
        
        ans += sum(sum_list)

        return

    for i in range(2):
        p_list[depth] = i
        dfs(depth + 1, p_list)


def main():

    p_list = [0] * (SIZE - 1)
    dfs(0, p_list)

    print(ans)


main()

Solution (Python):
S = input()

def dfs(a,s,n): 
    if(len(s) == 1):
        return int(s)
    elif(len(s) == n+1):
        return int(s[len(s)-1]) + int(s[:len(s)-1]) + int(s) + 2*a
    else:
        return dfs(a,s,n+1) + dfs(a+int(s[:n]),s[n:],1)

print(dfs(0,S,1))

Solution (Python):
s = str(input())
li = list(s)
sum_ = 0

for i in range(1 << len(s) -1):
    r =''
    for j in range(len(s) ):
        r += li[j]
        if i & (1 << j):
            r += '+'

    sum_ += eval(r)
print(sum_)

Solution (Python):
import numpy as np
S = np.array(list(input()), dtype=str)
l = len(S) - 1
print(sum(eval("".join(np.vstack((np.char.replace(np.char.replace(np.array(list(format(n, "0%db" % (l + 1))), dtype=str), "0", ""), "1", "+"), S)).T.ravel())) for n in range(1 << l)))

Solution (Python):
from functools import lru_cache


@lru_cache(maxsize=4096)
def solve(idx, S, num):
    if len(S) == 1 or len(S) == idx:
        return int(S) + num
    
    ret = solve(1, S[idx:], num+int(S[:idx]))
    
    ret += solve(idx+1, S, num)
    return ret


S = input()
print(solve(1, S, 0))

Solution (Python):
S = input()
op = len(S) - 1
res = 0
for i in range(2 ** op):
    string = ""
    bag = []
    for j in range(op):
        if (i >> j) & 1 == 1:
            bag.append("+")
        else:
            bag.append("")
    for s, b in zip(S, bag + [""]):
        string = string + s + b
    res += eval(string)
print(res)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
S = list(input())

l = len(S)
ans = []

for i in range(1<<l-1):
	anss = []
	i = list("{:b}".format(i).zfill(l-1))
	SS = S.copy()
	anss.append(SS.pop(0))
	while SS != []:
		if i.pop(0) == "1":
			anss.append("+")
		anss.append(SS.pop(0))

	ans.append(eval("".join(anss)))


print(sum(ans))

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
S = list(input())

l = len(S)

anss = []
for i in range(1<<l-1):
	ans = []
	i = list("{:b}".format(i).zfill(l-1))
	
	S_ = S.copy()
	ans.append(S_.pop(0))
	while S_ != []:
		if i.pop(0) == "1":
			ans.append("+")
		ans.append(S_.pop(0))
		
	anss.append(eval("".join(ans)))

print(sum(anss))

Solution (Python):
N = input()
b = N[0]
c = 0
for i in range(2**(len(N)-1)):
    a = "0"*20+str(bin(i))[2:]
    for j in range(1,len(N)):
        if a[-j] == "0":
            b += N[j]
        elif a[-j] == "1":
            c += int(b)
            b = N[j]
    c += int(b)
    b = N[0]
print(c)

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

s = input()
n = len(s)

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

Solution (Python):
s=input()

length=len(s)

keta=len(s)

gross=0

for i in s:
    i=int(i)
    
    gross+=2**(len(s)-keta)*i*(2**(keta-4)*(5**(keta-1)-1)+10**(keta-1))
    
    keta-=1
    
print(int(gross))

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

ans = 0

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

print(ans)

Solution (Python):

def inputlist(): return [int(k) for k in input().split()]
def base10to(n, b):
    if (int(n/b)):
        return base10to(int(n/b), b) + str(n%b)
    return str(n%b)

S = input()
ans = 0
n = len(S)
for i in range(2**(n-1)):
    k = base10to(i,2)
    tmp = S[0]
    if len(k)<n-1:
        for j in range(n-1-len(k)):
            k = '0'+k
    for l in range(1,n):
        if k[l-1] == '0':
            tmp+= S[l]
        else:
            ans += int(tmp)
            tmp = S[l]
    ans += int(tmp)
print(ans)

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


import itertools


count = 0


for i in range(len(s)):
    
    bet = len(s) -1
    
    betindex = [i for i in range(bet)]
    

    
    for v in itertools.combinations(betindex, i):
            
        li = []
        





        v = list(v)
        v = [i+1 for i in v]
        v.insert(0, 0)
        v += [len(s)]
        for j in range(len(v) - 1):
            li += [s[v[j]:v[j+1]]]
            

        li = [int(i) for i in li]
        count += sum(li)
            
            
print(count)

Solution (Python):
"""
def bs(num_array, max_element, min_element):
    from collections import deque
    if(num_array == max_element - min_element + 1):
        que = deque(deque([i for i in range(min_element, max_element+1, 1)]))
        return que
    else:        
        
        que = deque([deque([])])
        que.extend(bs(num_array, max_element, min_element + 1))
        
        subset_yes = bs(num_array-1, max_element, min_element + 1)
        for e in subset_yes:
            e.appendleft(min_element)
        
        que.extendleft(subset_yes)
        return que
"""
def solve(S):
    from itertools import combinations
    from collections import deque
    n = len(S)
    answer = 0
    for i in range(n):
        for item in combinations(list(range(1, n, 1)), i):
            char_list = [c for c in S]
            que = deque(item)
            while que:
                index = que.pop()
                char_list.insert(index, " ")
            split_s = ""
            for c in char_list:
                split_s += c
            
            answer += sum(map(int, split_s.split()))
    return answer

def main():
    S = input()

    print(solve(S))


main()

Solution (Python):
"""
def bs(num_array, max_element, min_element):
    from collections import deque
    if(num_array == max_element - min_element + 1):
        que = deque(deque([i for i in range(min_element, max_element+1, 1)]))
        return que
    else:        
        
        que = deque([deque([])])
        que.extend(bs(num_array, max_element, min_element + 1))
        
        subset_yes = bs(num_array-1, max_element, min_element + 1)
        for e in subset_yes:
            e.appendleft(min_element)
        
        que.extendleft(subset_yes)
        return que
"""
def solve(S):
    from itertools import combinations
    from collections import deque
    n = len(S)
    answer = 0
    for i in range(n):
        for item in combinations(list(range(1, n, 1)), i):
            char_list = [c for c in S]
            que = deque(item)
            while que:
                index = que.pop()
                char_list.insert(index, " ")
            split_s = ""
            for c in char_list:
                split_s += c
            
            answer += sum(map(int, split_s.split()))
    return answer

def main():
    S = input()

    print(solve(S))


main()

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

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

print(ans)

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

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


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()
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()
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) - 1
ans = 0
for i in range(2 ** n):
    b = 0
    for j in range(n):
        if (i >> j) & 1 == 1:
            ans += int(S[b:j + 1])
            b = j + 1
        else:
            pass
    ans += int(S[b:])
print(ans)

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

n = len(S)
ans = 0
for P in product([0, 1], repeat= n - 1):
    b = 0
    tmp = 0
    for i in range(len(P)):
        if P[i] == 1:
            tmp += int(S[b:i + 1])
            b = i + 1
        else:
            pass
    tmp += int(S[b:n])
    ans += tmp
print(ans)

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):
s = list(input())
def dfs(s, rest):
    if len(rest) != 0:
        r = rest.pop(0)
        return dfs(s[:] + ['+'] + [r], rest[:]) + dfs(s[:] + [r], rest[:])
    else:
        return eval(s)
def eval(s):
    sum = 0
    c = ""
    for i in s:
        if i == "+":
            sum += int(c)
            c = ""
        else:
            c += i
    return sum + int(c)
r = s.pop(0)
print(dfs([r],s))

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

mask = 0b0
end = 2**(n-1)
ans = 0
for i in range(2**10):
    if(mask >= end):
        break
    word = s[0]
    for j in range(n-1):
        if(mask & 1<<j):
            word += '+'
        word += s[j+1]
    ans += eval(word)
    mask += 1
print(ans)

Solution (Python):
Sin=input()
S=[int(Sin[i]) for i in range(len(Sin))]

def sums(a):
  n=len(a)
  if n==1:
    return a[0]
  else:
    s=0
    for i in range(n):
      s+=10**(n-i-1)*a[i]
    
    for i in range(n-1):
      t=0
      b=a[i+1:]
      c=a[:i+1]
      for j in range(i+1):
        t+=(10**(i-j))*c[j]
      n2=len(b)-1
      s+=t*(2**n2)+sums(b)
      
    return s
  
print(sums(S))

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

ans=0
for i in enzan:
  S_f=S
  now=0
  for j in range(len(S)-1):
    if i[j]=='+':
      now+=int(S_f[:j+1])
      S_f="0"*len(S_f[:j+1])+S_f[j+1:]

  now+=int(S_f)
  ans+=now
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):
def main() -> None:
    S = input()
    print(sum(bit(S)))


def bit(S) -> list:
    list = []
    list.append(int(S))
    for i in range(len(S)-1):
        left = S[:i+1]
        right = S[i+1:]
        x = int(left)
        for y in bit(right):
            list.append(x + y)
    return list


if __name__ == '__main__':
    main()

Solution (Python):
def Recursion(S):
    list = []
    list.append(int(S))
    for i in range(len(S)-1):
        left = S[:i+1]
        right = S[i+1:]
        x = int(left)
        for y in Recursion(right):
            list.append(x + y)
    return list

S = input()
print(sum(Recursion(S)))

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

ans = 0
for bit in range(2**(n-1)):
    cand = []
    j = 0
    for i in range(n):
        if (bit >> i) & 1:
            cand.append(S[j:i+1])
            j = i + 1
    cand.append(S[j:])
    ans += sum(map(int, cand))
    

print(ans)

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

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

Solution (Python):
class cal():
    def __init__(self):
        self.sum = 0
    def N(self,T):
        for x in range(1,len(T)+1):
            nan = 2**(len(T[x:])-1)
            if nan < 1:
                nan = 1
            self.sum += int(T[:x]) * nan
            self.N(T[x:])
        return self.sum

T = cal()
print(T.N(input()))

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

Solution (Python):
S = input()
l = len(S)
n = pow(2, l-1) 
ans = 0

for i in range(n): 
  f = S[0] 
  for j in range(l-1):
    if i >> j & 1: 
      f += '+' 
    f += S[j+1] 
  ans += sum(map(int, f.split('+'))) 
print(ans)

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

Solution (Python):
s=str(input())
ans=0
for i in range(1<<(len(s)-1)):
  st=s[0]
  for j in range(len(s)-1):
    if i & (1<<j):
      st+="+"+s[j+1]
    else:
      st+=s[j+1]
  ans+=eval(st)
print(ans)

Solution (Python):
s = list(map(int, input()))
s = s[::-1]
n = len(s)
ans = 0

for bit in range(1<<n-1):
    digit = 0
    for i in range(n):
        ans = ans + s[i] * (10 ** digit)
        if (bit & (1<<i)):
            digit = 0
        else:
            digit = digit + 1

print(ans)

Solution (Python):

S = input()
ans = 0

import itertools
ans = 0
for ptn in itertools.product([0, 1], repeat=len(S)-1):
    bgn = 0
    for i in range(len(S) - 1):
        if ptn[i] == 1:
            ans += int(S[bgn:i+1])
            bgn = i + 1
    ans += int(S[bgn: len(S)])

print(ans)

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

S = read().rstrip().decode('utf-8')

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

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

def main():
    mod=10**9+7
    S=input()
    N=len(S)
    ans=0
    
    import itertools
    
    for ite in itertools.product([0,1], repeat=(N-1)):
        L=list(ite)+[1]
        L2=[0]
        for i in range(N):
            if L[i]==1:
                L2.append(i+1)
        
        temp=0
        
        for i in range(1,len(L2)):
            temp+=int(S[L2[i-1]:L2[i]])
            
        ans+=temp
        
    print(ans)
        

main()

Solution (Python):
s = input()
ans = 0
n = len(s) - 1
m = 2 ** n
for i in range(m):
    bit = bin(i)[2:len(bin(i))]
    a = n - len(bit)
    if a != 0:
        bit = '0'*a + bit
    tmp = int(s[0])
    for j in range(n):
        if bit[j] == '0':
            tmp = 10*tmp + int(s[j+1])
        elif bit[j] == '1':
            ans += tmp
            tmp = int(s[j+1])
    ans += tmp
print(ans)

Solution (Python):
def dfs(i, Ope, sum):
    if i == N-1:
        start = 0
        for j in range(N-1):
            if Ope[j] == "+":
                
                sum += int(S[start:j+1])
                start = j+1
        
        sum += int(S[start:N])
        return sum
    else:
        Ope_plus = Ope + ["+"]
        Ope_null = Ope + [""]
        sum = dfs(i+1, Ope_plus, sum)
        sum = dfs(i+1, Ope_null, sum)
        return sum

S = input()
N = len(S)
Operator = []
print(dfs(0, Operator, 0))

Solution (Python):


s = input()

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

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

Solution (Python):
def calc_ssum(s):
    if len(s) == 1:
        res = [[s]]
        return res
    else:
        resprev = calc_ssum(s[:len(s)-1])
        res = []
        for string in resprev:
            tmp = string + [s[-1]]
            res.append(tmp)
            tmp2 = string
            tmp2[-1] = tmp2[-1] + s[-1]
            res.append(tmp2)
        return res

s = input()
all_s = calc_ssum(s)

result = 0
for l in all_s:
    l_int = list(map(int, l))
    result += sum(l_int)

print(result)