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

import sys





"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: 数
        """
        return int(self.input())

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        
        
        
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if ((i >> j) & 1) == 1:
                    """右からj+1番目のiが1かどうか判定"""
                    
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val


"""ここからメインコード"""


def main():
    
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    s = str(ip.I())
    ans = 0
    
    n = len(s) - 1

    
    for i in r(1 << n):
        
        p = ""
        for j in r(n):
            p += s[j]
            if (i >> j & 1) > 0:
                p += "+"
        p += s[-1]
        ans += eval(p)
    print(ans)


main()

Solution (Python):
s = input()
ans = 0
mita = set()
def f(x):
        global ans
        if x in mita:
                return
        ans += eval(x)
        mita.add(x)
        for i in range(1,len(x)):
                if x[i-1] != "+" and x[i] != "+":
                        f(x[:i]+"+"+x[i:])
f(s)
print(ans)

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

ans = 0
for b in range(2 ** N):
    now = int(S[0])
    for i in range(N):
        if b&(2**i):
            ans += now
            now = int(S[i+1])
        else:
            now = 10 * now + int(S[i+1])
    ans += now

print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    S = ii(str)
    ans = 0
    for i in range(1 << len(S) - 1):
        output = ""
        for j in range(len(S)):
            output += S[j]
            if ((i >> j) & 1) == 1:
                output += "+"
        ans += eval(output)
    return ans


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

Solution (Python):
def make_equation(i):
    key = i
    equation= ""
    for s in S[:-1]:
        equation += s
        if(key % 2 == 1):
            equation += "+"
        key = key // 2
    equation += S[-1]
    return equation

S = input().strip()
spaces = len(S) - 1
kinds = 2 ** spaces
ans = 0
for i in range(kinds):
    equation = make_equation(i)    
    ans += sum(map(int, equation.split("+")))
print(ans)

Solution (Python):
N=input()
slen=len(N)-1
if(slen==0):
    print(N)
    exit()
ans=0
for i in range(2<<(slen-1)):
    k=N
    ins=0
    for j in range(slen): 
        if((i>>j)&1):
            k=k[:j+1+ins]+"+"+k[j+1+ins:]
            ins+=1
    ans+=eval(k)
print(ans)

Solution (Python):

from collections import defaultdict
import math
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def LIR(n): return [LI() for i in range(n)]
mod = 1000000007








s = list(S())
lis = []
sign = ["","+"]
k = 2**(len(s)-1)
d = 10-len(s)
for i in range(d):
    s.insert(0,"0")
i = 0
for a0 in range(2):
    for a1 in range(2):
        for a2 in range(2):
            for a3 in range(2):
                for a4 in range(2):
                    for a5 in range(2):
                        for a6 in range(2):
                            for a7 in range(2):
                                for a8 in range(2):
                                    if i >= k:break
                                    lis.append(s[0]+sign[a0]+s[1]+sign[a1]+s[2]+sign[a2]+s[3]+sign[a3]+s[4]+sign[a4]+s[5]+sign[a5]+s[6]+sign[a6]+s[7]+sign[a7]+s[8]+sign[a8]+s[9])
                                    i += 1
ans = 0
for i in lis:
    ans += eval(i[d:])
print(ans)

Solution (Python):

"""
n,k =map(int, input().split())

print(k * (k - 1)**(n - 1)) 
"""


"""
import math
r, n, m = map(int, input().split())
kankaku = 2 * r / n
tyusin = n / 2
sum = 0
for i in range(1, n + m):
    if i - m < 0:
        yoko1 = 2 * math.sqrt(r ** 2 - ((tyusin - i) * kankaku)** 2)
        sum += yoko1
    elif i > n:
        yoko2 = 2*math.sqrt(r ** 2 - ((tyusin - i + m) * kankaku)** 2)
        sum += yoko2
    else:
        yoko1 = 2 * math.sqrt(r ** 2 - ((tyusin - i) * kankaku)** 2)
        yoko2 = 2 * math.sqrt(r ** 2 - ((tyusin - i + m) * kankaku)** 2)
        sum += max(yoko1, yoko2)
print(sum)
"""


"""
n = int(input())
an = list(map(int, input().split()))
ans = 0
for i in range(n):
    ans += an[i] - 1
print(ans)
"""


import itertools
s = input()
sum = int(s)
sb = list(s)
for i in range(1, len(s)):
    a = list(itertools.combinations(list(range(1,len(s))), i))
    for k in a:
        sb = list(s)
        f = 0
        for n in k:
            sb.insert(n + f, "+")
            f += 1
        b = ""
        for n in sb:
            if n == "+":
                sum += int(b)
                b = ""
            else:
                b += n
        sum += int(b)

print(sum)

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

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


def rec(now, depth):
    if depth == len(s):
        global ans
        ans += eval(now)
        return
    rec(now + '+'+s[depth], depth + 1)
    rec(now + s[depth], depth + 1)


rec(s[0], 1)
print(ans)

Solution (Python):
s = str(input())
n = len(s)
res = 0
for i in range(2**(n-1)):
    bit = bin(i)[2:].zfill(n-1)
    index = []
    for j in range(n-1):
        if bit[j]=='1':
            index.append(j+1)
    if len(index)>0:
        div = []
        for k in range(len(index)):
            if k==0:
                div.append(int(s[:index[k]]))
            else:
                div.append(int(s[index[k-1]:index[k]]))
        div.append(int(s[index[-1]:]))
        res += sum(div)
    else:
        res += int(s)
print(res)

Solution (Python):
S = list(input())
ans = 0
for bit in range(1 << len(S)-1) :
    BIT = []
    calc = ""
    for k in range(len(S)-1) :
        if bit & (1 << k) :
            BIT.append(1+k)
    for k in range(len(S)) :
        if k in BIT :
            calc += "+"
        calc += S[k]
    ans += eval(calc)
print(ans)

Solution (Python):

S = input()
N = len(S)
insert = []


for i in range(1<<(N-1)):
    
    tmp = []
    for j in range(N-1):
        if ((i>>j) & 1) == 1:
            
            
            tmp.append(j+1)
    insert.append(tmp)



split = []

for i in insert:
    s = []
    copy = S[:]
    prev = 0
    for j in i:
        
        if not (S[prev:j] == ""):
            s.append(int(S[prev:j]))
            copy = S[j:]
            prev = j
    s.append(int(copy))
    split.append(s)    


res = 0
for a in split:
    res += sum(a)
print(res)

Solution (Python):
import numpy as np
import itertools

def calc_sum(nums):
    if len(nums) == 1: return nums[0]
    idxs = np.arange(1, len(nums))
    masks = list(itertools.product([False, True], repeat=len(idxs)))

    ret = 0 
    for mask in masks:
        selected_idxs = [0] +list( idxs[ np.array(mask)]) + [len(nums)]
        for i in range(len(selected_idxs) - 1):
            ret += (int(''.join(nums[selected_idxs[i]: selected_idxs[i+1]])))
    return ret


S = input()
nums = [s for s in S]

print(calc_sum(nums))

Solution (Python):
s = list(input())
l = len(s)
t = [0] * l 
k = 2**(l-1)
for i in range(l):
    if i == 0:
        t[l-1] = k 
    else:
        t[l-1-i] = t[l-i] * 5 + k // 2
ret = 0 
for i in range(l):
    top = int(s[i])
    ret += top * t[i]
print(ret)

Solution (Python):
S = input()
sum_list = []

for i in range(1 << (len(S)-1)):
    temp = int(S[0])
    ans = 0
    for j in range(len(S)-1):
        if ((i >> j) & 1) == 1:
            ans += temp
            temp = int(S[j+1])
        else:
            temp = temp*10 + int(S[j+1])
    ans += temp
    sum_list.append(ans)
print(sum(sum_list))

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

N = 1 << (slen-1)

ans = 0
for i in range(N):
    eq = ''
    for j in range(slen):

        if i & 1<<j:
            eq += S[j:j+1] + '+'
        else:
            eq += S[j:j+1]

    ans += eval(eq)

print(ans)

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

n = len(S)

ans = 0

def calc(i=0, s=0, buf=''):
    global ans
    if i == len(S):
        if buf:
            s += int(buf)
        ans += s

    else:
        if buf:
            calc(i+1, s + int(buf), S[i])

        calc(i+1, s, buf + S[i])


calc()

print(ans)

Solution (Python):
S = input()
s = len(S)
n = 0
for i in range(s):
    n+= int(S[i])*(10**(s-1-i))*2**i
lis = []
for i in range(s-1):
    lis.append(2**i)
for i in range(s-1):
    for j in range(s-1-i):
        n += int(S[i])*(10**(s-2-i-j))*(lis[i+j])
print(n)

Solution (Python):
from itertools import combinations as ic
S = list(input())
pos = [i for i in range(1, len(S))]
total = 0
for p in range(len(S)):
  combs = ic(pos, p)
  for comb in combs:
    ans = ''
    for j, n in enumerate(S):
      if j in comb:
        ans += '+' + n
      else:
        ans += n
    total += eval(ans)
print(total)

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

A = []

while N>0:
    tmp = N%10
    A.append(tmp)
    N = (N-tmp)//10

dp = [[0 for i in range(len(A))] for j in range(len(A))]

dp[0][0] = 2**(len(A)-1)

for i in range(1, len(A)):
    for j in range(i-1):
        dp[i][j] = dp[i-1][j]
    dp[i][i-1] = dp[i-1][i-1]//2
    dp[i][i] =  dp[i-1][i-1]//2
    
ans = 0
    
for i in range(len(A)):
    for j in range(i+1):
        ans = ans + dp[i][j]*A[i]*(10**j)
        
print(ans)

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

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


def calc(i=0, s=0, buf=''):
    global ret
    if i == len(S):
        if buf:
            s += int(buf)
        ret += s
    else:
        if buf:
            calc(i + 1, s + int(buf), S[i])
        calc(i + 1, s, buf + S[i])


calc()
print(ret)

Solution (Python):
import itertools

s = input()
n = [i for i in s]

ans = 0

for i in range(len(n)):
    
    for j in itertools.combinations(range(len(n)-1), i):
        
        temp = [i for i in s]
        
        for k in j[::-1]:
            temp.insert(k+1, "+")
            
        
        temp = "".join(temp)
        
        temp = temp.split("+")
        
        temp = map(int, temp)
        ans += sum(temp)

print(ans)

Solution (Python):
S = input()

ans = 0

def dfs(i, s):
    global ans
    if i == 1:
        ans += eval(s)
        return
    dfs(i-1, s)
    dfs(i-1, s[:i-1]+'+'+s[i-1:])
    return

dfs(len(S),S)
print(ans)

Solution (Python):
def digit_gen(num_str, index):
    global S, sum_list
    if index == len(S):
        sum_list.append(num_str)
        return
    digit_gen(num_str + S[index], index + 1)
    digit_gen(num_str + S[index] + "+", index + 1)


if __name__ == "__main__":
    S = [c for c in input()]  
    index = 0
    sum_list = []
    num_str = ""
    digit_gen(num_str, index)
    sum_list = sum_list[::2]
    ans = 0
    a = "ans += "
    for num_str in sum_list:
        exec(a+num_str)
    print(ans)

Solution (Python):
import numpy as np


s = input()
size = len(s)

num = 0
for i in range(2**(size-1)):
    sp = np.array([(i >> j) & 1 for j in range(size)])
    st = ''.join([k + (' ' if sp[j] == 1 else '') for j, k in enumerate(s)])
    x = map(int, st.split())
    num += sum(x)
print(num)

Solution (Python):
def solve(x):
	if x == []:
		return 0
	if len(x) == 1:
		ans = x[0]
		return ans
	ans = x[0] * 2 ** (len(x) - 2) + solve(x[1:]) + solve([x[0] * 10 + x[1]] + x[2:])
	return ans
S = input()
T = []
for i in S:
	T.append(int(i))
print(solve(T))

Solution (Python):
s = str(input())
ans = 0
for bits in range(1 << len(s)-1):
    a = s[0]
    for i in range(len(s)-1):
        if (bits >> i & 1) == 1:
            a += '+'
        a += s[i+1]
    ans += eval(a)
print(ans)

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

Solution (Python):
S = [int(_) for _ in input()]
ans = 0
for i in range(len(S)):
    for j in range(i, len(S)):
        count = 2 ** i
        if j < len(S) - 1:
            count *= 2 ** (len(S) - 2 - j)
        ans += count * S[i] * 10 ** (j - i)
print(ans)

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

Solution (Python):
S=input()
t=list(int(S[i]) for i in range(len(S)))
s=2**(len(S)-1)
b=0
for i in range(len(S)):
    for j in range(i+1):
        b+=t[-(i+1)]*(10**j)*s//(2**min(i,j+1))
print(b)

Solution (Python):
S=input()
s=2**(len(S)-1)
b=0
for i in range(len(S)):
    for j in range(i+1):
        b+=int(S[-(i+1)])*(10**j)*s//(2**min(i,j+1))
print(b)

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

def DFS(plus=[], depth=0):
    global ans
    if depth >= n:
        command = s
        tmp = 1
        for i in plus:
            command = command[:tmp+i] + "+" + command[tmp+i:]
            tmp += 1
        
        ans += eval(command)
        return
    DFS(plus[::], depth+1)
    DFS(plus[::] + [depth], depth+1)

DFS([], 0)
print(ans)

Solution (Python):
s = input()
ans = 0
for i in range(1 << (len(s) - 1)):
    a = 0
    for j in range(len(s)):
        if (i >> j) & 1 == 1: 
            continue          
        ans += int(s[a:j + 1]) 
        a = j + 1
print(ans)

Solution (Python):
s = input()
s_list = list(s)
ans = 0
for i in range(1 << (len(s) - 1)):
    a = 0
    for j in range(len(s_list)):
        if (i >> j) & 1 == 1:
            continue
        ans += int(s[a:j + 1])
        a = j + 1
print(ans)

Solution (Python):
def getsum(S, delimiter, idx):
    if idx == len(S):
        retval = 0
        prev = 0
        for d in delimiter:
            retval += int(S[prev:d])
            prev = d
        retval += int(S[prev:])
        return retval
    return getsum(S, delimiter, idx+1) + getsum(S, delimiter + [idx], idx+1)


def main():
    S = input()

    print(getsum(S, [], 1))


if __name__ == "__main__":
    main()

Solution (Python):
S = list(input())
if len(S) == 1:
  print(int("".join(S)))
  exit()
l = []
for i in range(2*len(S) - 1):
    if i % 2 == 0:
        l.append(S[int(i/2)])
    elif i % 2 == 1:
        l.append("")
L_1 = []
L_2 = []
L_1.append(l)
def saiki(list_1,list_2,t): 
    for e in list_1:
        for b in [0,1]:
            if b == 0:
                list_2.append(e)
            elif t > len(e) - 1:
                print("error: t = {}, len(e) - 1 = {}".format(t,len(e) - 1))
            elif b == 1:
                e_copy = e[:]
                e_copy[t] = "+"
                list_2.append(e_copy)
    list_1.clear()
    if t < len(l) - 2:
        return saiki(list_2,list_1,t+2)
    else:
        return list_2
result = saiki(L_1,L_2,1)    
ans = 0
for e in result:
    ans += eval("".join(e))
print(ans)

Solution (Python):
S = input().strip()

L = len(S)

sum_ = 0
for p in range(1 << (L - 1)):
    val = 0
    for i, c in enumerate(S):
        c = int(c)
        val = val * 10 + c
        if i < L - 1:
            if p & (1 << i) != 0:
                sum_ += val
                val = 0
    sum_ += val
print(sum_)

Solution (Python):
s = input()

s_len = len(s)

sum_num = 0
for i in range(1<<(s_len-1), 1<<s_len):
	n, a = 0, 0
	for j in range(s_len):
		if (i>>j)%2 == 0:
			continue
		n += int(s[a:j+1])
		a = j+1
	sum_num += n

print(sum_num)

Solution (Python):

def main():
    buf = input()
    S = buf
    total = split_sum(S)
    print(total)

def split_sum(S):
    total = 0
    for i in range(int(2 ** (len(S) - 1))):
        factor = 1
        mask = 0b0000000001
        for j in range(len(S)):
            total += int(S[-j - 1]) * factor
            if i & (mask << j):
                factor = 1
            else:
                factor *= 10
    return total

if __name__ == '__main__':
    main()

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

Solution (Python):
if __name__=='__main__':
  S=input()
  sums=0
  num=[x for x in range(1,len(S))]
  for i in range(0,1<<len(num)):
    output=[]
    for j in range(len(num)):
      if ((i>>j)&1)==1:
        output.append(num[j])
    output.append(10)
    t=0
    for o in output:
      sums+=int(S[t:o])
      t=o
  print(sums)

Solution (Python):
s = input()

def manyformulas(s):
    if len(s)==1:
        return 1,int(s[0])
    else:
        sum = int(s)
        count = 1
        for i in range(len(s)-1):
            c, recursive = manyformulas(s[(i+1):])
            sum += c*int(s[:(i+1)]) + recursive
            count += c

        return count, sum

print(manyformulas(s)[1])

Solution (Python):
s = input()
x = []
l = len(s)
for i in range(l):
    x.append(int(s[i]))

sum = 0
for n in range(2**(l-1)):
    bin_str = format(n,'0'+str(l-1)+'b')
    prev = 0
    for i in range(l-1):
        if bin_str[i]=='0':
            prev = prev*10 + x[i]
        else:
            sum += prev*10 + x[i]
            prev = 0
    sum += prev*10 + x[l-1]

print(sum)

Solution (Python):

from itertools import zip_longest

s = input()

sum_num = 0
for i in range(0, 2**(len(s)-1)):
	sings = bin(i)[2:].zfill(len(s)-1).replace("1", "+").replace("0", " ")
	formula = ("".join("".join(t) for t in zip_longest(s, sings, fillvalue=" "))).replace(" ", "")
	sum_num += eval(formula)

print(sum_num)

Solution (Python):


s = input()

n = len(s)
int_s = []
for i in range(n):
    int_s.append(int(s[i]))
ans = 0
for i in range(n):
    for j in range(i, n):
        value = 0
        for k in range(j - i + 1):
            value += (10 ** k) * int_s[j - k]
        
        if i == 0:
            if j == n - 1:
                ans += value
            else:
                ans += value * (2 ** (n + i - j - 2))
        elif j == n - 1:
            ans += value * (2 ** (n + i - j - 2))
        else:
            ans += value * (2 ** (n + i - j - 3))

print(ans)

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

def dfs(i):
    global st,S,ans
    if i==n-1:
        st=S
        c=0
        off=0
        for j in lis:
            c+=1
            if j==1:
                S=S[:c+off]+'+'+S[c+off:]
                off+=1
        
        tm=S.split('+')
        for j in range(len(tm)):
            
            ans+=int(tm[j])

        S=st
        return
    lis.append(0)
    dfs(i+1)
    lis.pop(-1)
    lis.append(1)
    dfs(i+1)
    lis.pop(-1)
lis=[]
ans=0
dfs(0)
print(ans)

Solution (Python):
s = list(input())
total = []
n = len(s)

def search(i,s):
	if i == n-1:
		li = []
		s = "".join(s)
		li = list(map(int,s.split("+")))
		total.append(sum(li))
		return

	else:
		search(i+1,s)

		_s = s[:-(n-i)+1] + ["+"] + s[-(n-i)+1:]
		search(i+1,_s)

search(0,s)
print(sum(total))

Solution (Python):
def keta(N):
    bit_s = bin(N)[2:]
    bit_s = (bit_s.zfill(S_n))[::-1]
    
    res =[1]
    temp = 1
                               
    for i in range(len(bit_s)-1):
        if int(bit_s[i]):
            temp = 1
            res.insert(0, temp)
        else:
            temp *= 10
            res.insert(0, temp)
    
    return res


def solve():
    S_l = list(map(int, list(S)))
    res = 0
    
    for n in range(2**(S_n-1)):
        K_l = keta(n)
        for i in range(S_n):
            res += K_l[i] * S_l[i]
    
    return res
        

if __name__ == '__main__':
    S = input()
    S_n = len(S)
    
    print(solve())

Solution (Python):
S = input()
L = len(S)
goukei = 0

for i in range(2**(L-1)):
  f = ""
  for j in range(L-1):
    f += S[j]
    if i & 1:
      f += "+"
    i >>= 1
  goukei += eval(f+S[-1])

print(goukei)

Solution (Python):


import itertools

def all_comb(n):
    comb = []
    for i in range(0, n+1):
        comb.extend(list(itertools.combinations(range(n), i)))
    return comb

if __name__=='__main__':
    str = input()
    comb = all_comb(len(str)-1)
    tail = 0
    sum = 0
    for plus_positions in comb:
        head = 0
        for plus_position in plus_positions:
            num = int(str[head:plus_position+1])
            sum += num
            head = plus_position + 1
        num = int(str[head:])
        sum += num
    print(sum)

Solution (Python):
from itertools import product
s=list(input())
a=list(product(['','+'],repeat=len(s)-1))
a_list=[]
for i in a:
    an=[s[0]]
    for j,k in zip(i,s[1:]):
        an+=j+k
    a_list.append(an)
count=0
for i in a_list:
    count+=eval(''.join(i))
print(count)

Solution (Python):
answer = 0
S = input()
L = len(S)
for bit in range(2**(L-1)):
    string = ""
    for m in range(L-1):
        if bit & 2**m:
            string += S[m]
            answer += int(string)
            string = ""
        else:
            string += S[m]
    string += S[L-1]
    answer += int(string)
print(answer)

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

results = []

for i in range(2**(len(L)-1)) :
    calc = ""
    for j in range(len(L)-1) :
        calc += L[j]
        if i % 2 != 0 :
            calc += "+"
        i >>= 1
    f = calc + L[-1]
    results.append(eval(f))
print(sum(results))

Solution (Python):
import itertools

number = input()
answer = int(number)
length = len(number)

empty = [""] * length
plus = ["+"] * length

results = []
for i in range(2**(length - 1)):
    calc = ""
    for j in range(length - 1):
        calc += number[j]
        if i & 1:
            calc += "+"
        i >>= 1
    f = calc + number[-1]
    results.append(eval(f))
print(sum(results))

Solution (Python):
def su(s, k):
    count = 0
    for i in range(0, len(s)-1):
        tmp = k % 2
        k //= 2
        if(tmp == 1):
            s = s[:i+1+count] + '+' + s[i+1+count:]
            count += 1
    arr = s.split("+")
    arr = list(map(int, arr))
    return sum(arr)

s = input()
ans = 0
for i in range(0, (2 ** (len(s) - 1))):
    ans += su(s, i)
print(ans)

Solution (Python):
n = 0
nums = []

def dfs(i,num):
  if (i==n-1):
    nums.append(num)
    return False
  if (dfs(i+1,num+'+')):
    return True
  if (dfs(i+1, num + '_')):
    return True
  return False

def calc():
  ans = 0
  p = 0
  for num in nums:
    for i in range(n):
      if (i==n-1):
        ans += int(s[p:n])
      elif (num[i]=='+'):
        ans += int(s[p:i+1])
        p = i + 1
    p = 0

  return ans

s = input()
n = len(s)
dfs(0,"")
print(calc())

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

n = len(Ss)
ans = 0
for pat in range(1 << (n - 1)):
    num = 0
    temp = Ss[0]
    mask = 1
    for i in range(n - 1):
        if pat & mask:
            num += temp
            temp = Ss[i + 1]
        else:
            temp = temp * 10 + Ss[i + 1]
        mask <<= 1
    num += temp
    ans += num

print(ans)

Solution (Python):
s = input()

ans = 0

for i in range(1 << (len(s) - 1)):
    last = 0
    sm = 0
    for j in range(len(s) - 1):
        if (i >> j) & 1:
            sm += int(s[last:j + 1])
            last = j + 1
    sm += int(s[last:])
    
    ans += sm
print(ans)

Solution (Python):

S=input()
N = len(S)
result = 0
for i in range(2**(N-1)):
    T = str(S[0])
    for k in range(N-1):
        if (i>>k )& 1 == 1:
            T += "+" + str(S[k+1])
        else:
            T += str(S[k+1])
           
    result += eval(T)

print(result)

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

l = len(list(str(bin(2**(n-1))))) - 2
ans = [int(s)]

for i in range(1,2**(n-1)):
    bit = bin(i)
    bit = str(bit)
    bit = list(bit)
    bit.pop(0)
    bit.pop(0)
    for k in range(l-len(bit)):
        bit.insert(0,"0")
    
    temp = 0
    start = 0
    for k in range(l):
        if bit[k] == '1':
            temp += int(s[start:k])
            start = k
    temp += int(s[start:n])
    ans.append(temp)

print(sum(ans))

Solution (Python):
n = 0
eqs = []

def dfs(i, eq):

    if(i == n - 1):
        eqs.append(eq)
        return False

    if(dfs(i+1, eq + "+")):
        return True

    if(dfs(i+1, eq + "_" )):
        return True

    return False

def calc():
    ans = 0
    p = 0
    for eq in eqs:
        for i in range(n):
            if(i == n-1):
               
                ans += int(S[p:n])
            elif(eq[i] == "+"):
                
                ans += int(S[p:i+1])
                p = i + 1
        
        
        p = 0
    return ans

S = input()
n = len(S)
dfs(0, "")
print(calc())

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


for i in range(2**(n-1)):
    calc_str = s[0]
    operator_maker = str(format(i, 'b')).zfill(n-1)
    for j, c in enumerate(operator_maker):
        if c == '1':
            calc_str += '+'
        if n != 1:
            calc_str += s[j+1]
    answer += eval(calc_str)

print(answer)

Solution (Python):

S = input()
n = len(S)
ans = 0
for m in range(1 << (n - 1)):
    s = ''
    for i in range(n - 1):
        s += S[i]
        if m >> i & 1:
            s += '+'
    ans += eval(s + S[-1])
print(ans)

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

blist = []
for i in range(2**(n-1)):
    blist.append(list(map(int,list(bin(i)[2::].zfill(n-1)))))

ssum = 0
for k,num in enumerate(blist):
    bi = 0
    bsum = 0
    for i,j in enumerate(num):
        if j == 1:
            bsum += int(sr[bi:i+1])
            bi = i+1
        if i == (len(num)-1):
            bsum += int(sr[bi:])
    ssum += bsum
print(ssum)

Solution (Python):
S = input()
N = len(S)-1
B = []
ans = 0


for i in range(2**N):
    B.append(bin(i)[2:].zfill(N))
if N == 0:
    print(1)
    
else:
    for b in B:
        t = ""
        for i, plus in enumerate(b):
            t += S[i]
            if plus == "1":
                t += "+"

        t += S[-1]
        ans += sum([int(x) for x in t.split("+")])
        
    print(ans)

Solution (Python):
n = str(input())
ans = 0
if int(n) < 10:
  print(int(n))
  exit()
for i in range(2 ** (len(n) -1)):
  num = format(i,"b").zfill(len(n)-1)
  lis = ""
  for j in range(len(str(num))):
    if str(num[j]) == "1":
      lis += (str(n[j])+"+")
    else:
      lis += str(n[j])
  lis += n[-1]
  li = lis.split("+")
  for h in range(len(li)):
    li[h] = int(li[h])
  ans += sum(li)
print(ans)

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

ans = 0

for i in range(1 << (n - 1)):
    t = ''
    for j in range(n - 1):
        t += s[j]

        if (1 & i >> j) == 1:
            t += '+'

    t += s[-1]
    ans += eval(t)

print(ans)

Solution (Python):
S = input()
tmp = 0
ans = 0
if len(S) == 1:
    print(S)
else:
    for i in range(2**(len(S)-1)):
        form = ''
        for j, x in enumerate(format(i ^ 0, '0'+str(len(S)-1)+'b')):
            form += S[j]
            if x == '0':
                continue
            form += '+'
        form += S[-1]
        ans += eval(form)

    print(ans)

Solution (Python):
from itertools import product
import copy


def calc_sum(sub):
    ret = 0
    cnt = 0
    for i in sub[::-1]:
        if i == "+":
            cnt = 0
        else:
            ret += int(i) * 10 ** cnt
            cnt += 1
    return ret


s = list(input())
l = len(s)

ans = 0
for i in product((0, 1), repeat=l-1):
    sub = copy.copy(s)
    indexes = [m for m, x in enumerate(i) if x == 1]
    if sum(i) != 0:
        for k, ind in enumerate(indexes):
            sub.insert(ind+1+k, "+")
    ans += calc_sum(sub)

print(ans)

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

Solution (Python):
from itertools import product
s = input()
ans = 0
for p in product('+ ', repeat=len(s)-1):
    f = s[0]
    for i in range(len(s)-1):
        f += p[i]+s[i+1]
    ans += eval(f.replace(' ',''))
print(ans)

Solution (Python):
import itertools

s = input()
n = len(s)
num_list = [num for num in range(n-1)]
total = int(s)
for i in range(1,n):
    temp_list = list(itertools.combinations(num_list, i))
    temp_len = len(temp_list)
    for j in range(temp_len):
        temp_sum = 0
        for k in range(i):
            if k == 0:
                part1 = 0
            part2 = list(temp_list[j])[k]
            s_part = s[part1:part2+1]
            temp_sum += int(s_part)
            part1 = part2 + 1
            if k == i-1:
                temp_sum += int(s[part1:])
        total += temp_sum
print(total)

Solution (Python):
from itertools import combinations

S = input()
patterns = []

for i in range(1, len(S)):
    patterns += list(combinations(range(1, len(S)), i)) 

answer = int(S)
for pattern in patterns:
    s = 0 
    for pos in pattern:
        answer += int(S[s:pos])
        s = pos 
    answer += int(S[pos:])

print(answer)