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 copy

s = input()

def value(s, adding_list):
    insert_index = []
    for index in range(len(adding_list)):
        if adding_list[index]:
            insert_index.append(index)

    if len(insert_index) == 0:
        return int(s)

    value_list = []

    for index in range(len(insert_index)):
        if index == 0:
            value_list.append(s[0:insert_index[index]+1])
        if index < len(insert_index)-1:
            value_list.append(s[(insert_index[index]+1) : insert_index[index+1]+1])

        if index == len(insert_index)-1:
            value_list.append(s[insert_index[index]+1:])

    ret_val = 0
    for value in value_list:
        ret_val += int(value)

    return ret_val

def dfs(adding_list, changing_index):
    sum = 0
    if changing_index == len(s)-2:
        return value(s, adding_list)
    else:
        changing_index += 1
        new_adding_list = copy.copy(adding_list)
        sum += dfs(new_adding_list, changing_index)

        new_adding_list = copy.copy(adding_list)
        new_adding_list[changing_index] = True
        sum += dfs(new_adding_list, changing_index)
        return sum

def main():
    if len(s) > 1:
        ret_val = 0
        plus_list = [False for _ in range(len(s)-1)]
        ret_val += dfs(plus_list, 0)

        plus_list = [False for _ in range(len(s)-1)]
        plus_list[0] = True
        ret_val += dfs(plus_list, 0)
        print(ret_val)
    else:
        print(s)

main()

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

Solution (Python):
def solve(idx: int, l: list) -> None:
  if idx >= len(l)-1:
    res.append(sum(map(int, "".join(l).split("+"))))
    return
  solve(idx+1, l)
  copied = l.copy()
  copied.insert(idx+1, "+")
  solve(idx+2, copied)

S = list(input())
res = []
solve(0, S.copy())
print(sum(res))

Solution (Python):
n = int(input())
s = len(str(n))
if s == 1:
    print(n)
else:
    
    a0 = n % 10
    a = [a0]
    for i in range(2,s+1):
        b = n % (10**i)
        
        d = 0
        for k in range(2,i+1):
            d = d + (2**(i-k))*(b//(10**(i+1-k))) + a[i-k]
            
        a.append(d+b)
        
    print(a[s-1])

Solution (Python):
def solve():
    sum = 0 

    n = input()
    op_cnt = len(n) - 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] = "+"

        formula = "" 
        
        
        for p_n, p_o in zip(n, op + [""]):
            formula += (p_n + p_o)
        sum += eval(formula)
    print(sum)
solve()

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

N = len(S)
ans = 0
for i in range(N):
    left = i
    right = N - i - 1
    score = 1
    for k in range(0, right + 1):
        if right - k > 0:
            ans += S[i] * score * (1 << left) * (1 << (right - k - 1))
        else:
            ans += S[i] * score * (1 << left)
        score *= 10

print(ans)

Solution (Python):
S = input()
s = [v for v in S]

n = len(s)
ans = 0

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

print(ans)

Solution (Python):
S = input()
s = [v for v in S]

n = len(s)
ans = 0

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

print(ans)

Solution (Python):

def main():
    s = input()
    num = 2**(len(s)-1)
    bit_len = len(bin(num))

    def func(ｎ):
        n = bin(n)
        n_len = len(n)
        n = "0"*( bit_len - n_len - 1 ) + n[-len(n)+2:]
        indexes = [i+1 for i, x in enumerate(ｎ) if x == "1"]
        ans = 0
        temp = 0
        for i in indexes:
            ans += int(s[temp:i])
            temp = i
        else:
            if temp != bit_len-2:
                ans += int(s[temp:])

        return ans

    ans = 0
    for i in range(num):
        ans += func(i)
    print(ans)

main()

Solution (Python):
s = int(input())
S = []
while s > 0:
    S.append(s % 10)
    s //= 10
S.reverse()

N = len(S)
ans = 0
for i in range(N):
    left = i
    right = N - i - 1
    score = 1
    for k in range(0, right + 1):
        if right - k > 0:
            ans += S[i] * score * (1 << left) * (1 << (right - k - 1))
        else:
            ans += S[i] * score * (1 << left)
        score *= 10

print(ans)

Solution (Python):
S = input()

L = []
for i in range(len(S)):
    L.append(S[i])
    
ans = 0

for i in range(2**(len(S)-1), 2**(len(S))):
    c = 0
    temp = bin(i)
    for j in range(3, len(temp)):
        if temp[j] == "1":
            temp_list = L[c:j-2]
            ans += int("".join(temp_list))
            c = j-2
    temp_list = L[c:]
    ans += int("".join(temp_list))
            
print(ans)

Solution (Python):
import sys


def log(s):
    print("| " + str(s), file=sys.stderr)
    pass


def output(x):
    print(x, flush=True)


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


def main():
    s = input()
    n = len(s) - 1
    sum = 0
    for k in range(2 ** n):
        q = list(s)
        i = n
        while k > 0:
            if k & 1:
                q.insert(i, "+")
            k >>= 1
            i -= 1
        sum += eval("".join(q))
    print(sum)


main()

Solution (Python):
import itertools

s = input()
n = len(s)

l = []
for i in range(1,n):
	l.append(i)

ans = []

for i in range(1,n):
	index = list(itertools.combinations(l,i))
	for j in range(len(index)):
		start = 0
		for k in index[j]:
			ans.append(int(s[start:k]))
			start = k
		ans.append(int(s[k:n]))

print(sum(ans) + int(s))

Solution (Python):
s = input()

ans = 0
for bit in range(2 ** (len(s) - 1)):
    cnt = 0
    now = int(s[0])
    for i in range(len(s) - 1):
        if bit >> i & 1:
            cnt += now
            now = int(s[i + 1])
        else:
            now = now * 10 + int(s[i + 1])
    
    cnt += now
    ans += cnt

print(ans)

Solution (Python):
s = input()
n = len(s) - 1  
sum_ = 0
keep = 0
for i in range(2**n):  
    p_or_no = ["no"] * n
    for j in range(n):
        if ((i >> j) & 1) == 1:
            p_or_no[n-1-j] = "+"

    for k in range(n):
        if p_or_no[k] == "+":
            sum_ += int(s[k]) + keep
            keep = 0
        else:
            keep = int(s[k]) * 10 + keep * 10
        if k == n-1:
            sum_ += int(s[-1]) + keep
            keep = 0
if len(s) == 1:
    sum_ = int(s)
print(sum_)

Solution (Python):


import sys

def dprint(*args):
    return
    print(*args)

def solve(s_str):
    ans = 0
    s_len = len(s_str)
    for bits in range(0, 1 << (s_len - 1)):
        dprint("bits: {0:b}".format(bits))
        rev_str = list(reversed(s_str))
        
        cur_num_rev_str = ""
        
        for rev_i in range(0, s_len):
            dprint("rev_i: %d" % rev_i)
            plus_index = rev_i
            cur_num_rev_str += rev_str[0]
            rev_str = rev_str[1:]
            dprint("cur_num_rev_str: %s" % cur_num_rev_str)
            if rev_i == s_len - 1 or bits & (1 << plus_index):
                ans += int(''.join(list(reversed(cur_num_rev_str))))
                cur_num_rev_str = ""
    return ans

def main():
    s_str = sys.stdin.read().rstrip()
    dprint(s_str)
    print(solve(s_str))

main()

Solution (Python):


import sys

def dprint(*args):
    pass
    

def solve(s_str):
    ans = 0
    s_len = len(s_str)
    for bits in range(0, 1 << (s_len - 1)):
        dprint("bits: {0:b}".format(bits))
        rev_str = list(reversed(s_str))
        
        cur_num_rev_str = ""
        
        for rev_i in range(0, s_len):
            dprint("rev_i: %d" % rev_i)
            plus_index = rev_i
            cur_num_rev_str += rev_str[0]
            rev_str = rev_str[1:]
            dprint("cur_num_rev_str: %s" % cur_num_rev_str)
            if rev_i == s_len - 1 or bits & (1 << plus_index):
                ans += int(''.join(list(reversed(cur_num_rev_str))))
                cur_num_rev_str = ""
        if cur_num_rev_str != "":
            
            ans += int(''.join(list(reversed(cur_num_rev_str))))
    return ans

def main():
    s_str = sys.stdin.read().rstrip()
    dprint(s_str)
    print(solve(s_str))

main()

Solution (Python):
s = input()
def calc(s,op):
    ans = 0
    tmp = 0
    for i in range(len(s)):
        tmp += int(s[i])
        if i == len(s) - 1:
            ans += tmp
            break
        if op[i] == 0:
            tmp = tmp * 10
        else:
            ans += tmp
            tmp = 0
    return ans 
i_max = 2**(len(s)-1)
ans = 0
for i in range(i_max):
    op = [0]*(len(s) - 1)
    for j in range(len(op)):
        op[j] = i % 2
        i = i // 2
    ans += calc(s,op)
print(ans)

Solution (Python):
from functools import reduce

s = list(map(int, list(input())))
max_len = len(s) - 1
li = []
for bit in range(1 << max_len):
    tmp = s[0]
    for n in range(max_len):
        if (bit & 1 << n) != 0:
            li.append(tmp)
            tmp = 0
        else:
            tmp *= 10
        tmp += s[n + 1]
    li.append(tmp)
print(reduce(lambda x, y: x + y, li))

Solution (Python):
S = input()

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

print(ans)

Solution (Python):
S = input()
sum = 0
for j in range(2**(len(S)-1)):
    shiki = ""
    for i in range(len(S)):
        bin_str = str(format(j, 'b').rjust(10, '0'))
        shiki += S[i]
        if bin_str[-i - 1] == "1":
            shiki = shiki + "+"
    sum += eval(shiki)
print(sum)

Solution (Python):
s = input()

s_len  = len(s)
mul = [1,1,2,4,8,16,32,64,128,256]

ans = 0
for i in range(s_len):
    num = int(s[(s_len-1-i)])

    temp = 0
    for j in range(i+1):
        temp += num*(10**j)*mul[(i-j)]

    ans = ans*2 + temp

print(ans)

Solution (Python):
S = int(input())
numbers = str(S)
L = len(numbers)
prev = 0
for bit in range(1<<L-1):
    now = int(numbers[0])
    for i in range(L-1):
        if bit & (1<<i):
            prev += now
            now = int(numbers[i+1])
        else:
            now = now * 10 + int(numbers[i+1])
    prev += now
print(prev)

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

ans = 0
for ptn in itertools.product(['+',''], repeat=len(S)-1):
    f = ''
    for i in range(len(S)):
        f += S[i]
        if i < len(ptn): f += ptn[i]
    ans += eval(f)
print(ans)

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):
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):
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):
import itertools
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        S = input().rstrip()

        ans = int(S)
        for i in range(1, len(S)):
            for c in itertools.combinations(range(1, len(S)), i):
                tmp = S
                for j, v in enumerate(c):
                    index = j + v
                    tmp = tmp[:index] + '+' + tmp[index:]
                ans += eval(tmp)

        print(ans)



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

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

s = input()
n = len(s) - 1
total = 0
for i in range(2 ** n):
    indice = []
    sumup = 0
    for j in range(n):
        if (i >> j) & 1:
            indice.append(j)
    if indice == []:
        sumup += int(s)
    else:
        last_point = 0
        count = 0
        for i in indice:
            sumup += int(s[last_point:i+1])
            last_point = i+1
            count += 1
            if count == len(indice):
                sumup += int(s[last_point:])
    total += sumup

print(total)

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

s = 0
for i in range(1<<(len_S-1)):
    t = S[0]
    for j in range(len_S-1):
        if (i>>j)%2:
            t += "+"
        t += S[j+1]
    s += eval(t)

print(s)

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


if __name__ == "__main__":
    main()

Solution (Python):
s=input()

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

Solution (Python):
s = input()
N = len(s)
value = []
for i in range(2**(N - 1)):
    x = []
    so = s
    cnt = 1
    for j in range(N - 1):
        if (i >> j) &  1:
            x.append(j)
    if len(x) > 0:
        val = 0 
        ind = 0
        for k in (x):
            val += int(s[ind:k+1])
            ind = k+1
        val += int(s[k+1:])
        value.append(val)
    else:
        value.append(int(s))
print(sum(value))

Solution (Python):
def func(s, r=0, t=0):
    if len(s)==1:
        return int(s)+r+t
    else:
        a = func(s[1:], (int(s[0])+r)*10, t)
        b = func(s[1:], 0, int(s[0])+r+t)
        return a+b

s, = [list(map(int, s.split())) for s in open(0)][0]
s = str(s)

ans = func(s)
print(ans)

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

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

    ans+=eval(num)

print(ans)

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

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

c=[[(2**(n-1))]]
for i in range(n-1):
    if i>=1:
        d=c[i][:-1]
    else:
        d=[]
    d.append(c[i][-1]//2)
    d.append(c[i][-1]//2)
    
    c.append(d)
for i in range(n):
    for j in range(len(c[i])):
        ans+=c[i][j]*(10**j)*int(s[i])
        

print(ans)

Solution (Python):
def recur(i, buf, current, S):
  global result
  if i == len(S) - 1:
    result += current + buf * 10 + S[i]
    return
  
  recur(i + 1, 0, current + buf * 10 + S[i], S)

  
  recur(i + 1, buf * 10 + S[i], current, S)

S = list(map(int, list(input())))
result = 0
recur(0, 0, 0, S)
print(result)

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

print(ans)

Solution (Python):
S = input()
s = list(map(int, list(S)))

ans = 0
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] = "+"
    op += ["-"]

    expr = "".join([n+o for n, o in zip(S, op)]).replace("-", "")
    ans += eval(expr)
print(ans)

Solution (Python):
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    S = input()
    N = len(S)
    sumv = 0
    for bit in range(1 << N-1):
        T = S[0]
        for i in range(N-1):
            if bit & (1 << i):
                T += "+"
            T += S[i + 1]
        sumv += eval(T)
    print(sumv)

if __name__ == '__main__':
    main()

Solution (Python):

s = list(str(input()))
l = len(s)
def dfs(i,f):
    if i == l-1:
        return sum(list(map(int,f.split("+"))))
    
    return dfs(i + 1, f + s[i+1]) + \
           dfs(i + 1, f + "+" +s[i + 1])
print(dfs(0,s[0]))

Solution (Python):
s=[i for i in input()]
op_num = len(s)-1
sum=0

for i in range(2**op_num):
    op=['-' for i in range(op_num)]
    for j in range(op_num):
        if (i>>j)&1:
            op[j]='+'
    op+='+'
    sn=0
    for k in range(len(op)):
        if op[k]=='+':
            sum+=int(''.join(s[sn:k+1]))
            sn=k+1
print(sum)

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

for i in range(2**(l-1)):
    ans = 0
    left = 0
    right = 1
    for j in range(l):
        if (i>>j) & 1 == 0 and right<l:
            right += 1
        elif right<l:
            ans += int(s[left:right])
            left = right
            right += 1
    ans += int(s[left:right])
    fin_ans += ans
    
print(fin_ans)

Solution (Python):
S = input()
answer = eval(S)


def search(x, s):
    global answer
    for i in range(x + 1, len(s)):
        formula = "{}+{}".format(s[:i], s[i:])
        answer += eval(formula)
        search(i + 1, formula)


search(0, S)
print(answer)

Solution (Python):
S = list(input())
n = len(S)
total = 0
for i in range(2**(n-1)):
    b = bin(i)[2:].zfill(n-1)
    t = S[:]
    for j in range(n):
        if j == 0:
            continue
        if b[j-1] == '1':
            t[j] = '+' + t[j]
    total += eval(''.join(t))
print(total)

Solution (Python):
s = input()


def dfs(pos, fm):
    if (pos >= len(s)):
        
        return eval(fm)
    
    return dfs(pos+1, fm+s[pos])+dfs(pos+1, fm+'+'+s[pos])


print(dfs(0, '')//2)

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

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

Solution (Python):
import sys



lines = [x.strip() for x in sys.stdin.readlines()]
memo={}

def slv(lines):
    ans = rec(str(lines[0]),len(str(lines[0])))

    return ans

def rec(s,n):
    if memo.get(s,None) is not None:
        return memo[s]
    re = 0
    if len(s) ==1:
        return int(s)
    for i in range(0,len(s)):
        l=s[:i]
        r=s[i:]
        if len(l)<1:
            re+=int(r)
        else:
            re += int(l)*(2**(n-i-1))+ rec(r,len(r))
     


    memo[s]=re
    return re


if __name__ == "__main__":
    print(slv(lines))

Solution (Python):
from itertools import zip_longest
s = input()
sum = 0
gap_cnt = len(s) - 1
for i in range(2**gap_cnt):
  operators = [" "] * gap_cnt
  for j in range(gap_cnt):
    if((i>>j) &1):
      operators[gap_cnt-1-j] = "+"
  formula = ""
  for p_s,p_o in zip_longest(s,operators,fillvalue=" "):
    formula += (p_s+p_o)
  
    
  
  sum += eval(formula.replace(" ",""))
print(sum)

Solution (Python):
import sys
sys.setrecursionlimit(100000)

S=int(input())
def saiki(T,c):
    T=str(T)
    if len(T) == 0:
        return 0
    for i in range(len(T)):
        c += int(T[:i+1])*2**(len(T[i+1:])-1 if len(T[i+1:]) != 0 else 0) + saiki(T[i+1:],0)
    return c
print(saiki(S,0))

Solution (Python):
ans=0
def f(cnt,div):
    global ans
    if cnt==0:
        ans+=eval(div)
    else:
        f(cnt-1,div[:cnt]+'+'+div[cnt:])
        f(cnt-1,div[:cnt]+div[cnt:])

n=input()
f(len(n)-1,n)
print(ans)

Solution (Python):






s = input()





import itertools

lens = len(s)
sum_ = int(s)

for i in range(1, lens):
    for comb in itertools.combinations(range(1, lens), i):
        
        sum_ += int(s[:comb[0]])
        for j in range(i-1):
            sum_ += int(s[comb[j]:comb[j+1]])
        sum_ += int(s[comb[-1]:])
        
print(sum_)

Solution (Python):
S=input()

ans=0
for i in range(1 << len(S)-1):
    s=S[:]
    for j in reversed(range(len(S)-1)):
        if ((i >> j) & 1) == 1:
            s=s[:j+1] + "+" + s[j+1:]
    ans+=eval(s)
print(ans)

Solution (Python):
def calc(pat,S):
    ans = 0
    n = int(S[0])
    for i in range(len(S)-1):
        if pat[i] == '0':
            n = n*10+int(S[i+1])
        else:
            ans += n
            n = int(S[i+1])
    ans += n
    return ans

S = input()
SList=[ int(S[i]) for i in range(len(S))]

n = len(S)-1
binformat = '0'+str(n)+'b'

ans = 0
for i in range(2**n):
    pat = format(i,binformat)
    ans += calc(pat,SList)
print(ans)

Solution (Python):
import copy
S = input()
n = len(S)
ans = 0
for i in range(2**(n-1)):
    temp = ""
    for s,j in zip(S, range(n)):
        temp += s
        if i>>j & 1:
            temp += "+"
    ans += eval(temp)
print(ans)

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

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

Solution (Python):
def make_plus_index(S_list):
  s_index = [S_list[0]]
  for S in S_list[1:]:
    new_index = []
    for s in s_index:
      new_index.append(s+'+'+S)
      new_index.append(s+S)
    s_index = new_index
  return s_index

def run():
  S_list = list(input())
  s_lists = make_plus_index(S_list)
  total = 0
  for s in s_lists:
    total += sum(map(int, s.split('+')))
  print(total)
  
if __name__ == '__main__':  
  run()

Solution (Python):
import sys


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


def bitall(s, n):
    ans = 0
    for bit in range(1 << n):
        f = s[0]

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

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

    return ans


def main():
    s = input()
    n = len(s) - 1

    ans = bitall(s, n)

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys


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


def main():
    s = input()
    n = len(s) - 1

    ans = 0

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

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

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
S = input()

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

Solution (Python):
S = input()

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

print(ans)

Solution (Python):
from itertools import combinations

S=input()
N=len(S)
ans=int(S)
for i in range(1,N):
	for v in combinations(range(1,N),i):
		p=0
		for j in v:
			ans+=int(S[p:j])
			p=j
		ans+=int(S[p:])

print(ans)

Solution (Python):
s = input().rstrip();

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

print(ans);

Solution (Python):
s = input()

length = len(s)-1
bit = 0
re = 0
for i in range(2**length):
    count = 0
    temp_list = list(s)
    for j in range(length):
        if (bit >> j) & 1 == 1:
            
            temp_list.insert(j + 1 + count, '+')
            count += 1
    temp_str = 're += ' + ''.join(temp_list)
    
    exec(temp_str)
    bit += 1
print(re)

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

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

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):
import sys
sys.setrecursionlimit(10000)
S=input()
ans=0
def func(n,now):
    global ans
    if n==0:
        ans+=eval(now)
    else:
        func(n-1,now[:-n]+'+'+now[-n:])
        func(n-1,now[:-n]+now[-n:])
func(len(S)-1,S)
print(ans)

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

def dfs(i, now, depth):
    ans = 0
    if depth == n - 1:
        elements = map(int, now.split('+'))
        return sum(elements)
    else:
        ans += dfs(i + 1, now, depth + 1)
        now = now[:i] + '+' + now[i:]
        ans += dfs(i + 2, now, depth + 1)
    return ans
print(dfs(1, s, 0))

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

Solution (Python):
s=input()
num=len(s)-1
if num==0:
  print(int(s))
else:
  bit=2**num
  bitlist=[]
  sum=0
  for i in range(bit):
    num1=i
    bitsub=[]
    while num1!=0:
      bitsub.append(num1%2)
      num1//=2
    while len(bitsub)!=num:
      bitsub.append(0)
    bitlist.append(bitsub)
  for i in range(bit):
    sum1=0
    num2=s[0]
    for j in range(num):
      if bitlist[i][j]==0:
        num2+=s[j+1]
      else:
        sum1+=int(num2)
        num2=""
        num2+=s[j+1]
    sum1+=int(num2)
    sum+=sum1
  print(sum)

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

Solution (Python):




s = input()


n = len(s)



tasu_ichi = []
cnt = 0

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

Solution (Python):
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
import numpy as np

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    S = list(input().rstrip())
    N = len(S)

    ans = 0
    for bit in range(1<<N-1):
        str = S[:]
        cnt = 0
        for i in range(N-1):
            if bit & 1<<i:
                str.insert(cnt+i+1, '+')
                cnt += 1
        ans += sum(map(int, ''.join(str).split('+')))
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
import numpy as np

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

S = list(input().rstrip())
N = len(S)
FIN_L = N*2-1

def calc(lst, idx):
    if idx == N:
        return sum(list(map(int, ''.join(lst).split('+'))))
    else:
        return calc(lst+['',S[idx]], idx+1) + calc(lst+['+',S[idx]], idx+1)

def main():
    """ main """
    print(calc(S[:1],1))

if __name__ == '__main__':
    main()

Solution (Python):
def dfs(i, now,  count):
    ans = 0
    if count == len(s)-1:
        calc = list(map(int, now.split('+')))
        return sum(calc)
    else:
        ans += dfs(i + 1, now, count+1)
        now = now[:i] + '+' + now[i:]
        ans += dfs(i + 2, now, count+1)
    return ans


s = input()
print(dfs(1, s, 0))

Solution (Python):
def resolve():
    import copy
    s = list(input())
    n = len(s)-1
    c = 0
    for i in range(2**n):
        tmp = copy.deepcopy(s)
        d = 0
        for j in range(n):
            if (i // 2**j) % 2 == 1:
                tmp.insert(j+d+1, '+')
                d += 1
        tmp = ''.join(tmp).split('+')
        c += sum(map(int, tmp))
    print(c)
resolve()

Solution (Python):
n = [x for x in input()]
op_cnt = len(n) - 1
sum = int(0)

for index in range(2 ** op_cnt):
  op = [""] * op_cnt
  for index2 in range(op_cnt):
    if ((index >> index2) & 1):
      op[op_cnt - 1 - index2] = "+"
  
  formula = [None]*(len(n)+len(op))
  formula[::2] = n
  formula[1::2] = op
  
  sum += eval("".join(formula))

print(sum)

Solution (Python):
s = ""

def rec(i, word):
    if i == len(s):
        return eval("".join(word))
    ans = 0
    word.append('+')
    word.append(s[i])
    ans += rec(i+1, word)
    word.pop()
    word.pop()
    word.append(s[i])
    ans += rec(i+1, word)
    word.pop()
    return ans

def main():
    global s
    s = input()
    print(rec(1, [s[0]]))

if __name__ == '__main__':
    main()

Solution (Python):



s = input()


n = len(s)



hoge = '0' + str(n-1) + 'b'
cnt = 0

for i in range(2 ** (n-1)):

    sep = s
    bn_str = format(i, hoge)

    for j in range(n-1):
        if bn_str[j] == "1":
            cnt += int(sep[:j+1])
            sep = "0" * (j+1) + sep[j+1:]
            


    cnt += int(sep)
print(cnt)

Solution (Python):


S = input()
sum_all = 0


def func(s, idx):
    if len(idx) == 0:
        return int(s)
    sum_ = 0
    start=0
    for j in idx:
        sum_ += int(s[start:(j+1)])
        start = j + 1
    sum_ += int(s[idx[-1]+1:])
    return sum_

for bit in range(1<<(len(S)-1)):
    idx = [i for i in range(len(S)-1) if (bit & (1<<i))]
    sum_all += func(S, idx)
print(sum_all)

Solution (Python):
S = list(input())
len_s = len(S)
ans = 0
for num in range(2**(len_s-1)):
  temp = S[0]
  for i in range(len_s-1):
    if num>>i&1:
      ans += int(temp)
      temp = S[i+1]
    else:
      temp += S[i+1]
  ans += int(temp)
print(ans)

Solution (Python):
S = list(input())
N = len(S)
List = []
for i in range(2**(N-1)):
    tmp = ''
    for j in range(N-1):
        if ((i>>j) & 1):
            tmp += '1'
        else:
            tmp += '0'
    List.append(list(tmp))
ans = 0
for i in range(len(List)):
    start = 0
    tmp = ''
    for j in range(len(List[i])):
        if List[i][j] == '0':
            tmp += S[j]
        if List[i][j] == '1':
            tmp += S[j]
            ans += int(tmp)
            tmp = ''
    tmp += S[-1]
    ans += int(tmp)

            
print(ans)