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):
ans = 0
 
def dfs(i, cur, sum_v):
    global ans, S
    if i == len(S)-1:
        ans += sum_v
        return 
    dfs(i+1, int(S[i+1]), sum_v+int(S[i+1]))
    dfs(i+1, cur*10+int(S[i+1]), sum_v+cur*9+int(S[i+1]))
 
S = input()
dfs(0, int(S[0]), int(S[0]))
print(ans)

Solution (Python):
ans = 0
 
def dfs(S, i, cur, sum_v):
    global ans
    if i == len(S)-1:
        ans += sum_v
        return 
    dfs(S, i+1, int(S[i+1]), sum_v+int(S[i+1]))
    dfs(S, i+1, cur*10+int(S[i+1]), sum_v+cur*9+int(S[i+1]))
 
S = input()
dfs(S, 0, int(S[0]), int(S[0]))
print(ans)

Solution (Python):
S = input()

L = len(S) - 1
cand = []

for bit in range(1 << L):
    wh = []
    for i in range(L):
        if (bit & (1 << i)):
            wh.append(i)
    tmp = []
    prev = 0
    for i in wh:
        tmp.append(int(S[prev:i+1]))
        prev = i+1
    tmp.append(int(S[prev:]))
    cand.append(sum(tmp))
print(sum(cand))

Solution (Python):





ans = 0

def dfs(S, i, cur, sum_v):
    global ans
    
    if i == len(S)-1:
        ans += sum_v
        return 
    dfs(S, i+1, int(S[i+1]), sum_v+int(S[i+1]),)
    dfs(S, i+1, cur*10+int(S[i+1]), sum_v+cur*9+int(S[i+1]))

S = input()
dfs(S, -1, 0, 0)
print(ans//2)

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

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

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

Solution (Python):
from itertools import product
s = input()
firstnum = s[0]
s = s[1:]
ans = 0
for c in product(range(2),repeat=(len(s))):
    formula = firstnum
    for i in range(len(s)):
        if c[i] == 1:
            formula += '+'
        formula += s[i]
    ans += eval(formula)

print(ans)

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

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

Solution (Python):
a = input()
ar = []
for i in range(len(a)):
    ar.append(a[i])
n = len(ar)
ret = 0
for i in range(2**(n-1)):
    s = "+"
    tmp = ""
    for j in range(n):
        if (1 & (i >> j)) == 1:
            tmp += ar[j]
            tmp += s
        else:
            tmp += ar[j]
    stmp = tmp.split("+")
    ret += sum(int(k) for k in stmp)
print(int(ret))

Solution (Python):

S = input()
n = len(S) - 1 
Sum = 0
for i in range(2**n):
    
    pl = ''
    for j in range(n):
        pl += S[j]
        
        if format(i,'0'+str(n)+'b')[j]=='1': pl += '+' 
    pl += S[n]
    
    Sum += sum([int(x) for x in pl.split('+')])
print(Sum)

Solution (Python):

import math

S = int(input())

sum = 0
def gen(n, post, sum):
    
    if n<10: 
        
        if post==0: return n+sum
        else: return n * 10**int(math.log10(post)+1) + post + sum
    else:
        nxn = n//10
        d = n%10
        if post==0: nxpost = d
        else: nxpost = d * 10**int(math.log10(post)+1) + post
        
        
        pluson = gen(nxn, 0, nxpost+sum)  
        plusoff = gen(nxn, nxpost, sum) 
        
        return pluson + plusoff
print(gen(S, 0, 0))

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

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

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


ans=0
for i in range(2**(size-1)):
    z=format(i,'b').zfill(size-1)

    string=n[0]
    for j in range(size-1):
        if z[j]=='1':
            string+='0'+n[j+1]
        elif z[j]=='0':
            string+=n[j+1]
    string=string.replace('0','+')
    ans+=eval(string)

print(ans)

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

ans = 0
ops = list(product("+ ", repeat=len(S)-1))
for op in ops:
    ans += eval((S[0]+"".join(x+y for (x,y) in zip(op,S[1::]))).replace(" ",""))

print(ans)

Solution (Python):
import copy
s = input()
n=len(s)
ints=int(s)



all_sum=[0]
num = []

while ints != 0:
  
  num.append(str(ints % 10))
  ints //= 10
num.reverse()



def DFS(num,count,sum):
    if count==n:
        
        
        all_sum[0]+=sum
        return
    
    num_coppy = copy.deepcopy(num)
    
    
    sum+=int(num_coppy[count])
    
    count+=1
    DFS(num_coppy,count,sum)

    count-=1

    
    if count<=n-2:
        
        num_coppy[count+1]=num_coppy[count]+num_coppy[count+1]
        sum -= int(num_coppy[count])
        count+=1
        DFS(num_coppy,count,sum)


    
    return

    
    
    
DFS(num,0,0)
    

print(all_sum[0])

Solution (Python):
s = input()
S = len(s)
c = 0
for i in range(2**(S-1)):
    t = ''
    for j in range(S):
        t += s[j]
        if i & (1<<j):
            t += '+'
    c += eval(t)
print(c)

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

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

for i in range(2**(n-1)):
    eq = ''
    for j,c in enumerate(s):
        eq += c
        if i & (1<<j):
            eq += '+'
    ans += eval(eq)

print(ans)

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

kotae = 0
for i in range(2**(slen-1)):
    si = s
    for j in range(slen-1):
        if i & 1<<j:
            si = si[:slen-j-1]+"+"+si[slen-j-1:]
        else:
            pass
    kotae += eval(si)

print(kotae)

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

def keisan(s):
    smod = s
    wa = 0
    while smod.count("+") != 0:
        wa += int(smod[:smod.index("+")])
        smod = smod[smod.index("+")+1:]
    wa += int(smod)
    return wa

kotae = 0
for i in range(2**(slen-1)):
    ibin = bin(i)[2:]
    si = s
    for j in range(1, len(ibin)+1):
        if ibin[-j] == "1":
            si = si[:slen-j]+"+"+si[slen-j:]
        else:
            pass
    kotae += keisan(si)

print(kotae)

Solution (Python):
N = list(input())
l = []

for i in range(2**len(N)):
    eq = ''
    for j in range(len(N)):
        if j == len(N)-1:
            eq += N[j]
            break
        if (i >> j) % 2 == 1:
            eq += N[j] + '+'
        else:
            eq += N[j]
    l.append(eq)

ans = 0
for l_ in l:
    ans += eval(l_)
print(ans//2)

Solution (Python):
S = input()
N = len(S)
total = 0
for i in range(2**(N - 1)):
    eq = ''
    for j, c in enumerate(S):
        eq += c
        if i & (1 << j):
            eq += '+'
    total += eval(eq)
print(total)

Solution (Python):
s = input()
l = [s[0]]
d = len(s) - 1
if d == 0:
  print(s)
  exit()
def operate_1(string):
  return string
def operate_2(string):
  string += "+"
  return string

def bfs(list_hoge = l,depth = 0,deepest = d):
    queue = []
    for e in list_hoge:
        for b in [0,1]:
            if b == 0:
                operated = operate_1(e)
                operated += s[depth + 1]
                queue.append(operated)
            elif b == 1:
                operated = operate_2(e)
                operated += s[depth + 1]
                queue.append(operated)
    list_hoge = queue[:]
    depth += 1
    if depth == deepest:
        return list_hoge
    else:
        return bfs(list_hoge,depth)
ans = 0
for e in bfs():
  ans += eval(e)
print(ans)

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

Solution (Python):
import itertools
s = input()
s2 = s

t = []
t2 = []
u = []
ans = int(s)
p = 0
digit = 0
for i in range(len(s)):
    u.append([])
for i in range(len(s)):
    t.append(i)
    if i != len(s) - 1:
        t2.append(i)
    u[i].append(i)
    u[i].append(s[i])
addli = []
for k in range(1, len(s)):
    for balls in itertools.combinations(t2, k):
        for call in balls:
            if p != 0:
                call = call - digit
            r2 = s2
            s3 = r2[:call + 1]
            s2 = r2[call + 1:]
            ss3 = s3
            addli.append(int(ss3))
            p += 1
            digit += len(s3)
            if len(balls) == p:
                addli.append(int(s2))
        ans += sum(addli)

        addli = []
        p = 0
        s2 = s
        digit = 0
print(ans)

Solution (Python):



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

sum =0
for bit in range(1 << len(S) -1):
    l = []
    tmpS = [s for s in S]
    for i in range(len(S) -1):
        if(bit & (1 << i)):
            l.append(i)
    for i in l:
        tmpS[i] += "+"
    sum+=eval("".join(tmpS))

print(sum)

Solution (Python):
s = input()
s_split = [s[i] for i in range(len(s))]
result = 0

for i in range(2**(len(s)-1)):
    b = bin(i)[2:]
    b = b.zfill(len(s)-1)
    tmp = s_split.copy()

    for j in range(len(b)-1, -1, -1):
        if b[j] == "1":
            tmp.insert(-j-1, "+")


    result += eval("".join(tmp))
print(result)

Solution (Python):
s = input()
s_split = [s[i] for i in range(len(s))]
result = 0

for i in range(2**(len(s)-1)):
    b = bin(i)[2:]
    b = b.zfill(len(s)-1)
    tmp = s_split.copy()

    for j in range(len(b)-1, -1, -1):
        if b[j] == "1":
            tmp.insert(-j-1, "+")

    before = ""
    num = 0
    for x in range(len(tmp)):
        if tmp[x] == "+":
            num += int(before)
            before = ""
        else:
            before += tmp[x]
    if len(before) != 0:
        num += int(before)
    result += num
print(result)

Solution (Python):
import itertools


def main():
    s = input()
    res = int(s)
    all_indices = list(range(1, len(s)))
    for r in range(1, len(all_indices) + 1):
        for indices in itertools.combinations(all_indices, r):
            ss = s[:]
            for i in sorted(indices, reverse=True):
                ss = ss[:i] + '+' + ss[i:]
            res += eval(ss)
    print(res)


if __name__ == '__main__':
    main()

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

for i in range(2**(N-1)):
    s = S[:]
    for j in range(N):
        if i & 2**j:
            s[j] = s[j]+ '+'
    ans += eval(''.join(s))

print(ans)

Solution (Python):
import itertools

S=input()
L=len(S)
ITER=list(itertools.product([0,1],repeat=(L-1)))
ANS=0

for iter in ITER:
    PLUS=S[0]
    for j in range(L):
        if  j==L-1:
            ANS+=int(PLUS)
        elif iter[j]==0:
            ANS+=int(PLUS)
            PLUS=S[j+1]
        else:
            PLUS+=S[j+1]

print(ANS)

Solution (Python):

S = list(map(int, list(input())))
N = len(S)

def ans(bits):
    term = 0
    ret = 0
    for i, Si in enumerate(S):
        term = term * 10 + Si
        bit = (bits >> i) % 2
        if bit == 1:
            ret += term
            term = 0
    ret += term
    
    return ret

def acm(pos, bits):
    
    
    if pos == N - 1: return ans(bits)
    
    return acm(pos + 1, bits) + acm(pos + 1, bits + (1 << pos))

print(acm(0, 0))

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

N = [i for i in range(len(s)-1)]  

sum = 0
for i in range(1 << len(N)):
    output = []
    tmp = s[0]
    for j in range(len(N)):
        if ((i >> j) & 1) == 1:
            tmp += "+" + s[j + 1]
            output.append(j)  
        else:
            tmp += s[j+1]
    
    
    sum += eval(tmp)
print(sum)

Solution (Python):

l = [int(x) for x in list(input())]

N = len(l)
ans = 0

for i in range(N):
    for k in range(N - i - 1):
        ans += (2 ** i) * (2 ** (N - i - k - 2)) * (10 ** k) * l[i]
    ans += (2 ** i) * (10 ** (N - i - 1)) * l[i]

print(ans)

Solution (Python):

l = [int(x) for x in list(input())]

N = len(l)
ans = 0

for i in range(N):
    for k in range(N - i - 1):
        ans += (2 ** i) * (2 ** (N - i - k - 2)) * (10 ** k) * l[i]
    ans += (2 ** i) * (10 ** (N - i - 1)) * l[i]

print(ans)

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

for i in range(2**(N-1)):
    Scop = S[:] 
    for j in range(N-1):
        if i & 2**j:
            Scop[j] = Scop[j]+'+'
    ans += eval(''.join(Scop))
    

print(ans)

Solution (Python):
def dfs(nums):
    if len(nums) == 1:
        return int(nums[0])
    if len(nums) == 0:
        return 0
    curr_sum = 0
    curr_sum += int(''.join(nums))
    for i in range(len(nums)-1):
        a = nums[:i+1]
        b = nums[i+1:]
        a_sum = int(''.join(a))
        curr_sum += dfs(b) + a_sum * pow(2, len(b)-1)
    return curr_sum


S = input()
s = list(S)
print(dfs(s))

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

Solution (Python):
s=input()
if len(s)!=1:
  l=[]
  for k in range(2**(len(s)-1)):
    l.append(format(k,'0'+str(len(s)-1)+'b'))
  c=0
  for i in range(2**(len(s)-1)):
    m=list(l[i])
    m.append('1')
    x=0;y=0
    for j in range(len(s)):
      if m[j]=='0':y+=1
      else:
        c+=int(s[x:x+y+1])
        x=j+1
        y=0
  print(c)
else:print(int(s))

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

ans = 0
for b in reversed(range(2**(n-1))):
    sb = s
    for i in reversed(range(n-1)):
        if (b>>i)&1 == 1:
            sb = sb[:i+1] + "+" + sb[i+1:]

    ans += eval(sb)
    
print(ans)

Solution (Python):
import sys
import math
import collections
import itertools
import array
import inspect


sys.setrecursionlimit(1000000)



def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))



def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v



def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk



def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False



dp = None


def main():
    S = input()
    ans = 0

    for n in range(2**(len(S)-1)):
        B = to_bin(n)

        B = "0" * (len(S) - len(B) - 1) + B

        expr = S[0]
        for b,s in zip(B, S[1:]):
            if b == "1":
                expr += "+"
            expr += s


        ans += eval(expr)

    print(ans)


main()

Solution (Python):
S = input()

def func(S, i):
    if len(S) <= i:
        return eval(S)
    S1 = S[:i] + '+' + S[i:]
    return func(S, i + 1) + func(S1, i + 2)

print(func(S, 1))

Solution (Python):
S = input()

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

Solution (Python):
S = raw_input()
N = len(S)
r = 0
for i in range(1<<(N-1)):
  t = S[N-1]
  si = 0
  for j in range(N-1):
    x = S[N-2-j]
    if (1<<j & i)>0:
      si += int(t)
      t = x
    else:
      t = x+t
  si += int(t)
  r += si
print r

Solution (Python):
S = input()
cnt = 0
for p in range(2 ** (len(S) - 1)):
  F = S[0]
  for i in range(len(S) - 1):
    F += '+' if p % 2 else ''
    F += S[i + 1]
    p //= 2
  cnt += sum([int(f) for f in F.split('+')])
print(cnt)

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

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

Solution (Python):
s=list(input())
b=0
a=[[0 for i in range(len(s))] for j in range(len(s))]
if len(s)>=3:
    a[0][0],a[0][1]=1,1
    for i in range(2,len(s)):
        a[0][i]=a[0][i-1]*2
    for i in range(1,len(s)):
        for j in range(i,len(s)):
            a[i][j]=a[i-1][j-1]*2
    for i in range(len(s)):
        for j in range(len(s)):
            b+=int(s[i])*a[i][j]*10**(len(s)-j)
    print(b//10)
elif len(s)==2:
    print(11*int(s[0])+2*int(s[1]))
else:
    print(int(s[0]))

Solution (Python):
def culc(s):
    if len(s) == 0:
        return 0
    elif len(s) == 1:
        return int(s)
    count = 0
    for i in range(len(s)):
        count += culc(s[0:i])
        count += int(s[i:len(s)]) * (2 ** max(0, len(s[0:i])-1))
    return count

print(culc(input()))

Solution (Python):

S = list(map(int,list(input())))

p_num = 2**(len(S) - 1)
p = []
for i in range(p_num):
    temp_list = []
    temp = i
    for j in range(len(S) - 1):
        temp_list.append(temp % 2)
        temp //= 2

    p.append(temp_list)

g_sum = 0
for p_list in p:
    s_sum = S[0]
    add = 0
    for i in range(1,len(S)):
        if p_list[i-1] == 1:
            add += s_sum
            s_sum = S[i]
        else:
            s_sum = s_sum*10 + S[i]
    add += s_sum
    g_sum += add

print(g_sum)

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


p_num = 2**(len(S) - 1)
p = []
for i in range(p_num):
    temp_list = []
    temp = i
    for j in range(len(S) - 1):
        temp_list.append(temp % 2)
        temp //= 2

    p.append(temp_list)

g_sum = 0
for p_list in p:
    s_sum = S[0]
    add = 0
    for i in range(1,len(S)):
        if p_list[i-1] == 1:
            add += s_sum
            s_sum = S[i]
        else:
            s_sum = s_sum*10 + S[i]
    add += s_sum
    g_sum += add
    
    

print(g_sum)

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

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

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

Solution (Python):
S = input()
n = len(S)-1
ans = 0
for i in range(2**n):
    i = bin(i)[2:]
    i = '0'*(n-len(i))+i
    s = ''
    for j in range(n):
        if i[j]=='1':
            s = s+S[j]+'+'
        else:
            s = s+S[j]
    s = s+S[-1]
    s = s.split('+')
    for x in s:
        ans += int(x)
print(ans)

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

Solution (Python):

def slow_solve(S):
    l = 2 ** (len(S) - 1)
    sum = 0
    for i in range(l):
        bi = ("{:0%db}" % (len(S) - 1)).format(i)
        ope = []
        for b in bi:
            if b == "0":
                ope.append("")
            else:
                ope.append("+")
        ope.append("")
        p = ""
        for s, o in zip(S, ope):
            p += s
            p += o
        sum += eval(p)
    return sum

if __name__ == "__main__":
    print(slow_solve(input()))

Solution (Python):


s=input()

ans=tmp=0
t=len(s)

for i in range(1<<(t-1)):

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

Solution (Python):
import itertools


def main():
    s = input()
    ans = 0
    
    for i in range(len(s)):
        
        for ind in itertools.combinations(range(1, len(s)), i):
            
            c = 0
            st = s
            for j in ind:
                st = st[:j + c] + '+' + st[j + c:]
                c += 1
            ans += eval(st)
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
s = input()
n = len(s)
a = 0
for i in range(n):
  d = int(s[i])
  for k in range(n-i):
    a += (2**i)*int(2**(k-1)+0.5)*(10**(n-i-k-1))*d
print(a)

Solution (Python):

from sys import stdin

s = stdin.readline().rstrip()
ans_list = []
ans = 0

for i in range(2**(len(s)-1)):
    s_plus = ""
    b = "{:0{}b}".format(i,len(s)-1)
    for j in range(len(s)-1):
        s_plus += s[j]
        if b[j] == "1":
            s_plus += ","
        else:
            s_plus += ""
    s_plus += s[-1]
    ans_list = s_plus.split(",")
    ans_list_int = [int(i) for i in ans_list]
    ans += sum(ans_list_int)
print(ans)

Solution (Python):
S = input()

ans = 0
N = 2**(len(S) - 1)

if len(S) == 1:
    print(S)
    exit()
for i in range(N):
    bit = bin(i)[2:]
    if len(bit) != len(S):
        bit = '0'*(len(S)-len(bit) - 1) + bit

    tmp = S[0]

    for i,b in enumerate(bit):
        if b == '0':
            tmp += S[i+1]
        else:
            ans += int(tmp)
            tmp  = S[i+1]

    if len(tmp) > 0:
        ans += int(tmp)
print(ans)

Solution (Python):
sS = input().rstrip()
iTotal = 0
iL = len(sS) - 1
iP = 2**(iL)
for i in range(iP):
    sB = ("{:0"+str(iL)+"b}").format(i)
    sThis = sS
    for i in range(len(sB)-1,-1,-1):
        if sB[i] == "1":
            sThis = "+".join([sThis[0:i+1],sThis[i+1:]])
    iTotal += eval(sThis)
print(iTotal)

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

print(ans)

Solution (Python):
s = str(input())
list_s = list(s)
list_comma = [0]*(len(list_s)-1)
list_memo = []
ans = 0
for i in range(2**(len(s)-1)):
    list_memo = []
    bib = bin(i)[2:]
    bib = str(bib).zfill(len(s)-1)
    list_bib = list(bib)
    for j in range(len(list_bib)):
        if list_bib[j] == "0":
            list_bib[j] = ""
        else:
            list_bib[j] = ","
    for l in range(len(list_s)-1):
        list_memo.append(list_s[l])
        list_memo.append(list_bib[l])
    list_memo.append(list_s[-1])
    calc = "".join(list_memo)
    calc_list = list(calc.split(","))
    for number in calc_list:
        ans += int(number)
print(ans)

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b

ans = 0
def dfs(i, S, l):
    global ans
    if i >= len(S) - 1:
        pre = 0
        for j in l + [len(S) - 1]:
            ans += int(S[pre:j + 1])
            pre = j + 1
        return

    dfs(i + 1, S, l[:] + [i])
    dfs(i + 1, S, l[:])


def main():
    S = input()
    dfs(0, S, [])
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
S=input()
ans=0
for i in range(1<<len(S)-1):
    tmp=[]
    end=0
    for j in range(len(S)):
        if i&(1<<j):
            tmp.append(int(S[end:j+1]))
            end=j+1
    tmp.append(int(S[end:len(S)]))
    ans+=sum(tmp)
print(ans)

Solution (Python):
Num = int(input())
S = list(str(Num))
power = len(S)-1
ans = 0
for i in range(2**power):
    if i == 0:
        sum = Num
    else:
        P = list(format(i, "b").zfill(power))
        sum, temp = 0, int(S[0])
        for j in range(len(P)):
            if P[j] == "0":
                temp = temp*10 + int(S[j+1])
            else:
                sum += temp
                temp = int(S[j+1])
        sum += temp
    ans += sum
print(ans)

Solution (Python):
from itertools import product
STR = input()
n = len(STR)
ans = 0
for x in product((True,False), repeat = n-1):
    tmp = 0
    i = 0
    j = 1
    for y in x:
        if y:
            tmp += int(STR[i:j])
            i, j = j, j + 1
        else:
            j += 1
    tmp += int(STR[i:])
    ans += tmp
print(ans)

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

Solution (Python):
from itertools import product

S = input()

ans = 0
Stack = []
for pat in product((0,1), repeat = len(S)-1):
  subtotal = 0
  for i in range(len(S)-1):
    if pat[i] == 0:
      Stack.append(int(S[i]))
    else:
      subtotal += int(S[i])
      power = 1
      while Stack:
        subtotal += Stack.pop() * (10 ** power)
        power += 1
  Stack.append(int(S[len(S)-1]))
  power = 0
  while Stack:
    subtotal += Stack.pop() * (10 ** power)
    power += 1     
  
  ans += subtotal
  
print(ans)

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

ans = 0
for plusbits in range(2 ** (L - 1)):
    subset = []
    left = 0
    for b in range(L - 1):
        if plusbits & (1 << b):
            right = b + 1
            subset.append(s[left:right])
            left = right
    subset.append(s[left:])
    ans += sum([int(i) for i in subset])

print(ans)

Solution (Python):
def make(x):
    x = bin(x)[2:]
    while len(x) < len(S) - 1:
        x = "0" + x
    return list(x)

S = input()
a = pow(2, len(S) - 1)
b = []

for i in range(0, a):
    b.append(make(i))

i = 0
j = 0
key = int(S[0])
snum = 1
ans = 0
if len(S) != 1:
    for i in b:
        snum = 1
        key = int(S[0])
        for j in i:
            if j == "0":
                key *= 10
                key += int(S[snum])
            elif j == "1":
                ans += key
                key = int(S[snum])
            
            snum += 1
        ans += key
    print(ans)
else:
    print(S)

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

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

for i in range(1 << s_len):
    temp  = int(s[0])
    value = 0
    for j in range(s_len):
        if i>>j & 1:
            value += temp
            temp  =  int(s[j+1])
        else:
            temp  = 10*temp + int(s[j+1])
    value += temp
    ans += value

print(ans)

Solution (Python):
S = input()

ans = 0
count_list = [[2 ** (len(S)-1)]]

for i in range(1, len(S)):
    if i == 1:
        count_list.append([2 ** (len(S)-2), 2 ** (len(S)-2)])
    else:
        a = []
        for j in count_list[i-1][:i-1]:
            a.append(j)
        a.append(count_list[i-1][-1]//2)
        a.append(count_list[i-1][-1]//2)
        count_list.append(a)

count_list = count_list[::-1]

for i in range(len(S)):
    flag = 1
    for j in count_list[i]:
        ans += int(S[i]) * flag * j
        flag *= 10

print(ans)

Solution (Python):
import itertools
S = input()
plus_list = list(itertools.product([0, 1], repeat=len(S) - 1)) 

res = 0

for plus in plus_list:
    res_list = []
    tmp = 0
    for i in range(len(S) - 1):
        if plus[i] == 1:
            res += int(S[tmp:i+1])
            tmp = i + 1
    res += int(S[tmp:])
            
print(res)

Solution (Python):
s=input()
l=len(s)
ans=0
for i in range( 1<< (l-1)):
    temp=int(s[0])
    value=0
    for j in range(l-1):
        if i>>j &1:
            value+=temp
            temp=int(s[j+1])
        else :
            temp=10*temp+int(s[j+1])
    value+=temp
    ans+=value
    
    
print(ans)

Solution (Python):
s=input()
tt=[bin(2**(len(s)-1)+i)[3::] for i in range(2**(len(s)-1))]
ans=0
for t in tt:
    a=[]
    for i in range(len(t)):
        a.append(s[i])
        if t[i]=='1':
            a.append("+")
    a.append(s[-1])
    x="".join(a)
    ans+=eval(x)
print(ans)

Solution (Python):
from itertools import product
s = input()
rep = len(s)-1
ans = 0

for op in product(["+", ""], repeat=rep):
  temp = ""
  for j in range(rep):
    temp += s[j]
    temp += op[j]
  temp += s[-1]
  ans += eval(temp)

print(ans)

Solution (Python):
from itertools import permutations, combinations,combinations_with_replacement,product
s=input()
al=sorted(list(product(['','+'],repeat=len(s)-1)))
ans=0
for i in al:
    word=''
    for s1,i1 in zip(s[:-1],i):
        word+=s1+i1
    word+=s[-1]
    ans+=eval(word)
print(ans)

Solution (Python):
import sys
S = input()
ans = 0
ans += int(S)
pow2 = [1,2,4,8,16,32,64,128,256,512]
for i in range(1,pow2[len(S)-1]):
    v = []
    for j in range(9):
        if i&pow2[j]:
            v.append(j)
    v.append(10)
    j = -1
    for x in v:
        sys.stderr.write(str(j+1)+' '+str(x+1)+' '+ S[j+1:x+1] + '\n')
        ans += int(S[j+1:x+1])
        j = x
print(ans)