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



Sample input:
125


Sample output:
176

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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     
  #print(pat, subtotal)
  ans += subtotal
  
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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])
            #print(i, j, key)
            snum += 1
        ans += key
    print(ans)
else:
    print(S)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
S = input()
plus_list = list(itertools.product([0, 1], repeat=len(S) - 1)) #0:+を入れない, 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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

len_s = len(s)
ans = 0

for i in range(2**(len_s-1)):
    num = s[0]
    rnum = 0
    for j in range(len_s-1):
        flag = i >> j & 1
        if flag == 1:
            rnum += int(num)
            num = s[j+1]
        else:
            num += s[j+1]
    ans += rnum + int(num)

print(ans)

Submission status: Accepted

Solution code:
s = input()

d = len(s) - 1

def dfs(depth: int, cur:int, s: str, res: str) -> int:
    if depth == d:
        tmp = s + res[:1]
        return cur + int(tmp)
    
    else:
        tmp = s + res[:1]
        return dfs(depth+1, cur+int(tmp), "", res[1:]) \
                + dfs(depth+1, cur, tmp, res[1:])
                
ans = dfs(0, 0, "", s)

print(ans)

Submission status: Accepted

Solution code:
S = input()
ans = 0
for b in range(2**(len(S)-1)):
    opes = []
    for i in range(len(S)-1):
        if b&(1<<i):
            opes.append('+')
        else:
            opes.append('')
    formula = ''.join([c+o for c,o in zip(S, opes)])
    ans += eval(formula + S[-1])
print(ans)

Submission status: Accepted

Solution code:
S=str(input())
formula=[""]*(len(S)*2-1)
ans=0
for i in range(len(S)*2-1):
    if i%2==0:
        formula[i]=S[i//2]
place=pow(2,len(S)-1)-1
for i in range(place+1):
    for j in range(len(bin(i))-2):
        #strしたbinには0bのprefixが付く。
        if int(str(bin(i))[-j-1])==1:
            formula[2*j+1]="+"
    ans+=eval(''.join(formula))
    for k in range((len(formula)-1)//2):
        formula[2*k+1]=""
print(ans)

Submission status: Accepted

Solution code:
from itertools import zip_longest, chain

s = input()

sign_amount = len(s)-1
table = str.maketrans("01", " +")

sum_num = 0
for i in range(2 ** sign_amount):
	bin_str = bin(i)[2:].zfill(sign_amount)
	signs = bin_str.translate(table)
	formula = "".join(chain(*zip_longest(s, signs, fillvalue=" "))).replace(" ", "")
	sum_num += eval(formula)

print(sum_num)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

S = list(input())
N = len(S)-1

ans = 0
# 間に+を入れるかどうかでビット全検索
for i in range(1 << N):
    offset = 0
    for j in range(N):
        if (i>>j) & 1 == 1:
            # 該当のビットが1なら+を挿入
            S.insert(j+1+offset, '+')
            # +を入れた分リストが長くなるので、次回の位置を調整
            offset += 1
            # リスト→文字列→式にして答えに足す
    ans += eval(''.join(S))
    # +を削除
    S = [j for j in S if j != '+']

print(ans)

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-
import itertools

def main():
    s = list(input())
    string = []
    for i in s:
        string.append(i)
        string.append('')
    position = [x for x in range(1, len(string)-1, 2)]
    ans = 0

    for i in range(len(s)):
        places = list(itertools.combinations(position, i))
        for place in places:
            string_cp = string[:]
            for p in place:
                string_cp[p] = '+'
            ans += eval(''.join(string_cp))

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
n = len(s)
num = 0
for i in range(1 << n):
    if i % 2 == 0:
        continue
    pre = 0
    tmp = []
    for j in range(n):
        if i & 1 << j:
            if len(s[pre:j]) != 0:
                tmp.append(int(s[pre:j]))
            pre = j
    tmp.append(int(s[pre:]))
    num += sum(tmp)

print(num)

Submission status: Accepted

Solution code:
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

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

S = input()
L = len(S)-1
flags = []
for i in range(2**L):
	t = format(i,'010b')
	flags.append(list(t[10-L:]))


ans = 0

for flag in flags:
	tmp_li = [0]
	for i,fl in enumerate(flag):
		if fl == '1':
			tmp_li.append(i+1)
	tmp_li.append(L+1)

	for i in range(len(tmp_li)-1):
		l = tmp_li[i]
		r = tmp_li[i+1]
		ans += int(S[l:r])

print(ans)

Submission status: Accepted

Solution code:
from itertools import product, chain
S = input()
ans = 0
if len(S) == 1:
    print(S)
    exit()

for i in product(['+', ''], repeat=len(S) - 1):
    ans += eval(S[0] + ''.join(chain.from_iterable(zip(i, S[1:]))))
print(ans)

Submission status: Accepted

Solution code:
from itertools import product, chain
S = input()
ans = 0
for i in product(['+', ''], repeat=len(S) - 1):
    ans += eval(S[0] + ''.join(chain(*zip(i, S[1:]))))
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Aug  8 21:43:24 2018
ABC045C
@author: maezawa
"""

s = input()
n = len(s)-1
sums = 0

for i in range(2**n):
    signs =[]
    for j in range(n):
        if i & (1<<j):
            signs.append('+')
        else:
            signs.append('')
    #print(signs)
    eq = ''
    for k in range(n):
        eq += s[k] + signs[k] 
    eq += s[n]
    #print(eq)
    sums += eval(eq)
    
print(sums)

Submission status: Accepted

Solution code:
# bit 全探索
# https://beta.atcoder.jp/contests/abc045/tasks/arc061_a

if __name__ == '__main__':
    s = input()
    # s = '125'
    d = len(s) - 1

    ans = 0
    for bit in range(1 << d):
        sum_i = 0
        prev_pos = 0
        for i in range(d):
            if bit & (1 << i) != 0:
                sum_i += int(s[prev_pos:i + 1])
                prev_pos = i + 1

        ans += sum_i + int(s[prev_pos:d + 1])

    print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations as c
s=input()
r=0
for j in range(1,len(s)):
  for i in c(range(1,len(s)),j):
    k=[0]+list(i)+[len(s)]
    v=sum(map(int,[s[k[i]:k[i+1]] for i in range(j+2-1)]))
    r+=v
print(r+int(s))

Submission status: Accepted

Solution code:
S = input()

ans = 0

def dfs(s, sum_, n):
    if n == len(S)-1:
        return int(s) + sum_

    return dfs(s+S[n+1], sum_, n+1) + dfs(S[n+1], sum_+int(s), n+1)

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

Submission status: Accepted

Solution code:
S = input()

allsum = 0

def calcStr(s) :
    return sum(list(map(int, s.split("+"))))

def dosum(s, idx) :
    global allsum
    if idx >= len(s) :
        allsum += calcStr(s)
        # do sum
    else :
        if len(s) > idx :
            dosum(s[0:idx] + "+" + s[idx:len(s)], idx + 2)
            dosum(s, idx + 1)
            
dosum(S, 1)
print(allsum)

Submission status: Accepted

Solution code:
from itertools import zip_longest

s = input()
s = list(s)
cnt_pos = len(s) - 1#記号の入り得る位置の数
formula_cnt = 2 ** (cnt_pos)#式数

ans = 0
for i in range(formula_cnt):
    sgns = ['+' if (i & (2 ** x) != 0) else '' for x in range(cnt_pos)]
    formula = ''
    for c, sgn in zip_longest(s, sgns, fillvalue=''):
        formula += c + sgn
    #print(i, s, sgns, formula)
    ans += eval(formula)
print(ans)

Submission status: Accepted

Solution code:
from itertools import product

S = input()
n = len(S) - 1
ans = 0
for p in product([True, False], repeat=n):
    x = 0
    s = ''
    for i in range(n):
        s += S[i]
        if p[i]:
            x += int(s)
            s = ''
    s += S[-1]
    x += int(s)
    ans += x
print(ans)

Submission status: Accepted

Solution code:
import itertools

s = input()

tfs = []
tfset = (True, False)
for i in itertools.product(tfset, repeat=len(s)-1):
    tfs.append(i)

allsum = 0
for tf in tfs:
    sum = 0
    digit = 0
    for i, seed in enumerate(tf):
        if seed:
            sum += int(s[digit:i+1])
            digit = i+1
    sum += int(s[digit:])
    allsum += sum

print(allsum)

Submission status: Accepted

Solution code:
S = input()
tf_str = ""

ans = 0

def dfs(tf_str,S):
    global ans
    if len(tf_str) != len(S)-1:
        dfs(tf_str + "f",S)
        dfs(tf_str + "t",S)
    else:
        frm = 0
        for to in range(1,len(S)):
            if tf_str[to-1] == "t":
                ans += int(S[frm:to])
                frm = to
        
        ans += int(S[frm:])


dfs(tf_str,S)   
print(ans)

Submission status: Accepted

Solution code:
import sys

S = input()

# 2^n-1の2進数は全組み合わせを表す
combs = pow(2, len(S) - 1)
if len(S) == 1:
    print(S)
    sys.exit()

total = 0
for i in range(combs):
    # i番目の組み合わせ（2進数）
    comb_i = format(i, '0' + str(len(S)) + 'b')
    if len(comb_i) > 1:
        comb_i = comb_i[1:]

    tmp = S[0]
    for j in range(len(comb_i)):
        b = int(comb_i[j])
        if b == 1:
            tmp += "+"
        tmp += S[j + 1]
    total += eval(tmp)
print(total)

Submission status: Accepted

Solution code:
import copy
from itertools import combinations
S = input()

result = 0
for n_plus in range(len(S)):
    for plus_indices in combinations(range(1, len(S)), n_plus):
        S_new = copy.deepcopy(S)
        for i, plus_idx in enumerate(plus_indices):
            S_new = S_new[:plus_idx+i] + '+' + S_new[plus_idx+i:]
        result += eval(S_new)
print(result)

Submission status: Accepted

Solution code:
import itertools
S = list(input())

SUM = 0
for pattern in itertools.product('+ ', repeat=len(S)-1):
    form = ''
    for i in range(len(S)-1):
        form += S[i] + pattern[i]
    form += S[-1]
    SUM += eval(form.replace(' ', ''))
print(SUM)

Submission status: Accepted

Solution code:
import functools
S = input()
C = [S[0]]
for s in S[1:]:
  C = functools.reduce(lambda x, y: x + y, [[c + s, c + '+' + s] for c in C])
ans = 0
for c in C:
  ans += sum([int(x) for x in c.split('+')])
print(ans)

Submission status: Accepted

Solution code:
import copy
from itertools import combinations
S = input()

result = 0
for n_plus in range(len(S)):
    for plus_indices in combinations(range(1, len(S)), n_plus):
        S_new = copy.deepcopy(S)
        c = 0
        for i, plus_idx in enumerate(plus_indices):
            S_new = S_new[:plus_idx+i] + '+' + S_new[plus_idx+i:]
        result += eval(S_new)
print(result)

Submission status: Accepted

Solution code:
s = input()

m = {}
def f(t):
    ret = []
    for i in range(1, len(t) + 1):
        hd,tl = t[:i], t[i:]
        if tl == '':
            ret.append(int(hd))
            continue
        if tl in m:
            ret = ret + m[tl]
            continue
        ihd = int(hd)
        ret = ret + [ihd + x for x in f(tl)]
    return ret
print(sum(f(s)))

Submission status: Accepted

Solution code:
from copy import deepcopy
s = input()
length = len(s)

ans = 0
def solve(s_split, s, i):
    if i == length:
        # print(s_split)
        global ans
        ans += sum(list(map(int, s_split)))
    else:
        tmp1 = deepcopy(s_split)
        tmp1[-1] += s[0]
        solve(tmp1, s[1:], i+1)

        tmp2 = deepcopy(s_split)
        tmp2.append(s[0])
        solve(tmp2, s[1:], i+1)
        
solve([s[0]], s[1:], 1)
print(ans)

Submission status: Accepted

Solution code:
from copy import deepcopy
s = input()
length = len(s)

ans = 0
def solve(s_split, s, i):
    if i == length:
        # print(s_split)
        global ans
        ans += sum(list(map(int, s_split)))
    else:
        tmp1 = deepcopy(s_split)
        tmp1[-1] += s[0]
        solve(tmp1, s[1:], i+1)

        tmp2 = deepcopy(s_split)
        tmp2.append(s[0])
        solve(tmp2, s[1:], i+1)
        
solve(['0'], s, 0)
print(int(ans/2))

Submission status: Accepted

Solution code:
import sys

s = input()
plus_num = len(s) - 1
if plus_num == 0:
    print(s)
    sys.exit(0)

f = '0%sb' % plus_num
plus_list = [format(i, f) for i in range(2 ** plus_num)]
result = 0

for plus in plus_list:
    ans = 0
    tmp = int(s[0])
    for i, v in enumerate(s[1:]):
        if plus[i] == '0':
            tmp = tmp * 10 + int(v)
        else:
            ans += tmp
            tmp = int(v)
    ans += tmp
    result += ans

print(result)

Submission status: Accepted

Solution code:
s = input()
plus_num = len(s) - 1
if plus_num == 0:
    print(s)
    exit(0)

f = '0%sb' % plus_num
plus_list = [format(i, f) for i in range(2 ** plus_num)]
result = 0

for plus in plus_list:
    ans = 0
    tmp = int(s[0])
    for i, v in enumerate(s[1:]):
        if plus[i] == '0':
            tmp = tmp * 10 + int(v)
        else:
            ans += tmp
            tmp = int(v)
    ans += tmp
    result += ans

print(result)

Submission status: Accepted

Solution code:
import itertools as it

S = input()
ans = 0

for bits in it.product((True, False), repeat=len(S)-1):
    A = ''
    for s, bit in zip(S, bits + (0,)):
        A += s + '+'*bit
    ans += eval(A)

print(ans)

Submission status: Accepted

Solution code:
from itertools import product
s=input()

r=0
for i in product([0,1],repeat=len(s)-1):
    t=''
    for c,j in zip(s,list(i)+[0]):
        t+=c+'+'*j
    r+=eval(t)
    
print(r)

Submission status: Accepted

Solution code:
a=input()
x=0
for i in range(2**(len(a)-1)):
    s=''
    for j in range(len(a)-1):
        s+=a[j]+'+'*int(format(i,'010b')[-j-1])
    s+=a[-1]
    x+=eval(s)
print(x)

Submission status: Accepted

Solution code:
s=input()
ans=0

def slove(left,right):
    if len(right)==0:
        return eval(left+right)
    return slove(left+right[0],right[1:])+slove(left+'+'+right[0],right[1:])

ans=slove(s[0],s[1:])
print(ans)

Submission status: Accepted

Solution code:
from itertools import chain, product, zip_longest
 
s = input()
assert all(c in '123456789' for c in s)

betweens = product(('', '+'), repeat=len(s)-1)
def make_string(between):
  return ''.join(chain.from_iterable(zip_longest(s, between, fillvalue='')))
strings = (make_string(between) for between in betweens)
print(sum(map(eval, strings)))

Submission status: Accepted

Solution code:
from itertools import chain, product

s = input()
assert all(c in '123456789' for c in s)

betweens = product(('', '+'), repeat=len(s)-1)
strings = (s[0] + ''.join(chain.from_iterable(zip(between, s[1:]))) for between in betweens)
print(sum(map(eval, strings)))

Submission status: Accepted

Solution code:
from itertools import product

s = input()
assert all(c in '123456789' for c in s)

def make_string(mask):
    return s[0] + ''.join(('+' if m else '') + c for m, c in zip(mask, s[1:]))

masks = product((0,1), repeat=len(s)-1)
print(sum(eval(make_string(mask)) for mask in masks))

Submission status: Accepted

Solution code:
s = input()
assert all(c in '123456789' for c in s)

def dfs(i, s1):
    if i == len(s):
        yield eval(s1)
        return
    yield from dfs(i+1, s1+s[i])
    yield from dfs(i+1, s1+'+'+s[i])

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

Submission status: Accepted

Solution code:
S = str(input())
t = len(S)
ans =0
for i in range(1<<t-1):
    k=S[0]
    for x in range(t-1):
        if i & 1<<x:
            k=k+'+'+S[x+1]
        else:
            k+=S[x+1]
    ans +=eval(k)
print(ans)

Submission status: Accepted

Solution code:
S = str(input())
t = len(S)
ans =0
for i in range(1<<t-1):
    s =int(S[0])
    for x in range(t-1):
        if i & 1<<x:
            ans+=s
            s=int(S[x+1])
        else:
            s = 10*s+int(S[x+1])
    ans +=s
print(ans)

Submission status: Accepted

Solution code:
s=input()
ans=0
for i in range(2**(len(s)-1)):
  t=""
  for j in range(len(s)-1):
    if format(i,"0"+str(len(s)-1)+"b")[j] == '1':
      t+=s[j]+"+"
    else:
      t+=s[j]
  t+=s[-1]
  ans+=eval(t)
print(ans)

Submission status: Accepted

Solution code:
S = input()
ans = 0
for b in range(2**(len(S)-1)):
    opes = []
    for k in range(len(S)-1):
        if b&(1<<k):
            opes.append('+')
        else:
            opes.append('')
    formula = ''.join([a+o for a,o in zip(S,opes)]) + S[-1]
    ans += eval(formula)

print(ans)

Submission status: Accepted

Solution code:
def main():
    S = input()

    AC(S)


def AC(S):
    n = len(S)
    a = [0] * (n-1)

    def rec(i, n):
        ans = 0
        if i == n:
            ss = list(S)
            for j, x in enumerate(a):
                if x == 1:
                    ss[j] = ss[j] + "+"
            #print("".join(ss))
            for x in "".join(ss).split("+"):
                ans += int(x)
            return ans

        a[i] = 1
        ans += rec(i + 1, n)
        a[i] = 0
        ans += rec(i + 1, n)
        return ans
    ans = rec(0, n-1)
    print(ans)


def WA(S):
    ans = 0
    for n in range(len(S)):
        x = f(S, n)
        ans += x

    print(ans)


def f(S, n):
    ans = 0
    if n == 0:
        ans = int(S)
    elif len(S) - 1 == n:
        ans = sum(map(int, S))
    elif n == 1:
        for i in range(len(S)-1):
            x = int(S[:i+1]) + int(S[i+1:])
            ans += x
            print(S, n, i, x)
    else:
        for i in range(len(S)-1):
            x = S[:i+1]
            y = S[i+1:]
            if len(y) > n - 1:
                ans += int(x) + f(y, n-1)

    print(S, n, ans, sep="\t")
    return ans


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C


def dfs(i: int):
    global count

    if i == n - 1:
        count += eval(''.join(numbers))
        return

    numbers[2 * i + 1] = ""
    dfs(i + 1)
    numbers[2 * i + 1] = "+"
    dfs(i + 1)


if __name__ == '__main__':
    s = input()
    n = len(s)
    numbers = [""] * (2 * n - 1)
    count = 0

    for i in range(n):
        numbers[2 * i] = s[i]

    dfs(0)
    print(count)

Submission status: Accepted

Solution code:
from itertools import product
s=input().strip()
ans=0
for i in product(["","+"] , repeat=len(s)-1):
  t=s[0]
  n=1
  for j in i:
    t+=j+s[n]
    n+=1
  ans+=eval(t)
  
print(ans)

Submission status: Accepted

Solution code:
s=list(input())
sl=len(s)
ans=0
for i in range(1<<sl-1):
    temp=s[0]
    for j in range(sl-1):
        if i&(1<<j):
            temp+="+"
        temp+=s[j+1]
    ans+=eval(temp)
print(ans)

Submission status: Accepted

Solution code:
def my_add(arg: list):
    if len(arg) == 1:
        return eval(arg[0])
    return my_add([arg[0]+arg[1]]+arg[2:]) + my_add([arg[0]+'+'+arg[1]]+arg[2:])

print(my_add(list(input())))

Submission status: Accepted

Solution code:
S = input()
ans = 0

for b in range(2**(len(S)-1)):
    opes = []
    for k in range(len(S)-1):
        if b & (1 << k):
            opes.append('+')
        else:
            opes.append('')
    formula = ''.join([d + o for d,o in zip(S,opes)])
    ans += eval(formula + S[-1])
print(ans)

Submission status: Accepted

Solution code:
def cul(num, idx):
    if idx == len(num):
        return eval(num)

    return cul(num[:idx]+"+"+num[idx:], idx+2) + cul(num, idx+1)


def main():
    s = input()
    print(cul(s, 1))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = int(input())
sl = list(str(s))
sl_n = len(sl) - 1
l = ['a','b']
def a_or_b(x):
    if len(list(str(x[0]))) == sl_n:
        return x
    else:
        ll = []
        for i in range(len(x)):
            ll.append(x[i] + 'a')
        for i in range(len(x)):
            ll.append(x[i] + 'b')
        x = ll
        return a_or_b(x)
    
lll = []
ans = 0

if len(sl) == 1:
    ans = s
else:
    lll = a_or_b(l)
    kkk = []
    for i in range(len(lll)):
        p = sl
        q = list(str(lll[i]))
        st = ''
        for j in range(len(p) - 1):
            if q[j] == 'a':
                st = st + p[j] +'+'
            else:
                st = st + p[j] + ''
        st = st + sl[-1]
        res = eval(st)
        ans += res
        
print(ans)

Submission status: Accepted

Solution code:
s=list(input())
sl=len(s)
ans=0
for i in range(1<<sl-1):
    temp=s[0]
    for j in range(sl-1):
        if i&(1<<j):
            temp+="+"
        temp+=s[j+1]
    ans+=eval(temp)
print(ans)

Submission status: Accepted

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

def ops(x):
    o = []
    for i in range(len(S)-1):
        o.append(x%2 == 1)
        x //= 2
    return o

ans = 0
for i in range(2**(len(S)-1)):
    op = ops(i)
    x = S[0]
    for i in range(len(S)-1):
        if op[i]:
            ans += x
            x = S[i+1]
        else:
            x = x*10 + S[i+1]
    ans += x
print(ans)

Submission status: Accepted

Solution code:
def exp2(n):
	ans = 1
	for i in range(0, n):
		ans = ans * 2
	return ans

S = list(raw_input())
opnumber = exp2(len(S)-1)
ans = 0

for i in range(0, opnumber):
	tmp = i
	numlst = []
	n = S[0]
	for j in range(1, len(S)):
		if tmp%2 == 1:
			numlst.append(int(n))
			n = ''
		n = n + S[j]
		tmp = tmp / 2
	numlst.append(int(n))
	for j in range(0, len(numlst)):
		ans = ans + numlst[j]

print ans

Submission status: Accepted

Solution code:
def c_many_formulas(S):
    import itertools
    # 文字数-1個の演算子の列と解釈(1は'+',0は空文字)
    string = itertools.product('01', repeat=len(S) - 1)
    ans = 0
    for s in string:
        operator = ['+' if x == '1' else '' for x in s] + ['']  # 空文字を番兵
        tmp = ''  # 数字の間に演算子を入れた文字列(数式と解釈する)
        for value, op in zip(S, operator):
            tmp += (value + op)  # 末尾には番兵(空文字)が入るので問題ない
        ans += eval(tmp)
    return ans

S = input().strip()
print(c_many_formulas(S))

Submission status: Accepted

Solution code:
def li(s):
    lis = [[] for i in range(2**(len(s)-1))]
    bi = []
    if len(s) == 1:
        return [[int(s)]]
    for i in range(2**(len(s)-1)):
        bi.append(bin(i)[2:])
        while len(bi[i]) != len(s)-1:
            bi[i] = "0"+bi[i]

    for i in range(len(bi)):
        v = 0
        for j in range(len(bi[i])):
            if bi[i][j] == "1":
                lis[i].append(int(s[v:j+1]))
                v = j+1
            if j == len(bi[i])-1:
                lis[i].append(int(s[v:]))
    return lis

s = input()
ans = 0
lis = li(s)

for i in lis:
    for j in i:
        ans += j
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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