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:
S = input()
op_cnt = len(S) - 1
ans = 0
for i in range((2 ** op_cnt)):
    k = 0
    for j in range(op_cnt):
        if ((i >> j) & 1):
            ans += int(S[k:j+1])
            k = j+1
    ans += int(S[k:])

print(ans)

Submission status: Accepted

Solution code:
s = input()


value = 0

def compute(state,s):
	x = 0
	start_pos = 0
	end_pos = 0
	for i in range(len(s)-1):
		if state[i] == '0':
			continue
		else:
			end_pos = i+1
			x += int(s[start_pos:end_pos])
			start_pos = i+1
	if s[end_pos:] != '':
		x += int(s[end_pos:])
	return x


for i in range(2**(len(s)-1)):
	state = format(i,'0%ib'%(len(s)-1))
	value += compute(state,s)
print(value)

Submission status: Accepted

Solution code:
s = input()

ans = 0
for i in range(2 ** (len(s) - 1)):
    fml = ''
    for j in range(len(s) - 1):
        fml += s[j]
        fml += '+' if '{:0>10b}'.format(i)[::-1][j] == '1' else ''
    fml += s[-1]
    ans += eval(fml)
    
print(ans)

Submission status: Accepted

Solution code:
import copy

def culc(array):
    summy = 0
    indexes = [i for i, x in enumerate(array) if x == '+']
    ff = 0
    for i in indexes:
        summy += int("".join(array[ff:i]))
        ff = i+1
    summy += int("".join(array[ff:]))
    return summy

nums = list(input())
ans = 0

for i in range(2**(len(nums)-1)):
    bit = bin(i)
    obj = copy.deepcopy(nums)
    k = 0
    for j in range(len(nums)-1):
        if ( i >> j) & 1:
            obj.insert(j+1+k,'+')
            k += 1
    ans += culc(obj)

print(ans)

Submission status: Accepted

Solution code:
S=input()
n=len(S)
ans=0
for i in range(1<<(n-1)):
    k=0
    for j in range(n):
        if 1&(i>>j):
            ans+=int(S[k:j+1])
            k=j+1
    ans+=int(S[k:])
        
print(ans)

Submission status: Accepted

Solution code:
s = input()
l = len(s)

#全部で2**(l-1)パターンある
ans = 0
for i in range(2 ** (l-1)):
    eq = s[0]
    for j in range(l-1):
        if i & (1<<j):
            eq += '+'+s[j+1]
        else:
            eq += s[j+1]
    tmp = list(map(int, eq.split('+')))
    ans += sum([int(chr) for chr in tmp])

print(ans)

Submission status: Accepted

Solution code:
import sys
import re

S=str(input())
ans=0
for i in range(1<<(len(S)-1)):
  start=0
  score=0
  for j in range(len(S)-1):
    if (i>>j)&1==0:
      score+=int(S[start:j+1])
      start=j+1
  score+=int(S[start:len(S)])
  ans+=score

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
C - たくさんの数式 / Many Formulas
"""
import types
#import copy

# Input
abcd = input()
n = len(abcd) - 1 # 閾の数
sum_ = 0

# Print
for i in range( 2**n ):
    op = n * ["+"]

    # Create operation list
    # example: ['', '+', '']
    for j in range(n):
        if ( i >> j ) & 1:
            op[n-1 -j] = ""
            
    formula = ""
    for p_n, p_o in zip(abcd, op+[""]):
        formula += (p_n + p_o)
    #print(formula)

    sum_ += eval(formula)

print(sum_)

Submission status: Accepted

Solution code:
S=input()

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

Submission status: Accepted

Solution code:
S = input()
c = 0


op_cnt = len(S) - 1  # すき間の個数

for i in range(2 ** op_cnt):
  T = ""
  for j in range(op_cnt):
    T += S[j]
    if ((i >> j) & 1):
      T += "+"
  T += S[op_cnt]
  c += eval(T)
print(c)

Submission status: Accepted

Solution code:
s=input()
sl=[]
ans=0
if len(s)==1:
  print(int(s))
else:
  for iii in range(2**(len(s)-1)):
    sind='{:0'+str(len(s)-1)+'b}'
    astr=sind.format(iii)
    astr=astr.replace("1","+")
    astr=astr.replace("0","x")
    lans=s[0]
    for jjj in range(len(astr)):
      lans+=astr[jjj]+s[jjj+1]
    lans=lans.replace("x","")
    ans+=int(eval(lans))
  print(ans)

Submission status: Accepted

Solution code:
s = input()

ans = 0
for i in range(2 ** (len(s) - 1)):
    s_start = 0
    for j in range(len(s)):
        if i >> j & 1:
            ans += int(s[s_start:j+1])
            s_start = j+1
#            print(ans)
    ans += int(s[s_start:])
print(ans)

Submission status: Accepted

Solution code:
s = input()

max_plus = len(s) - 1

numList = [int(c) for c in s]

sMax = (1 << max_plus) - 1

ans = 0

for plus_pos in range(sMax + 1):
    sum = 0

    num = numList[0]

    for i in range(max_plus):
        if ((plus_pos >> i) & 1) == 1:
            sum += num
            num = numList[i + 1]
        else:
            num = num * 10 + numList[i + 1]

    sum += num
    ans += sum

print(ans)

Submission status: Accepted

Solution code:
n = input()
x = 0

a = len(n) - 1

for i in range(2 ** a):
    op = ['']*(a+1)
    for j in range(a):
        if ((i>>j) & 1):
            op[j] = '+'
    formula = ''
    for p,q in zip(n, op):
        formula += p + q
    x += eval(formula)
    
print(x)

Submission status: Accepted

Solution code:
from itertools import combinations

S = input()

pllst = [i for i in range(1, len(S))]
exp = []
for i in range(len(pllst)+1):
    exp.extend(list(combinations(pllst, i)))

ans = ''
for lst in exp:
    if len(lst) == 0:
        ans += S
    else:
        pivot = 0
        for order in lst:
            ans += '+' + S[pivot:order]
            pivot = order
        ans += '+' + S[pivot:]
print(eval(ans))

Submission status: Accepted

Solution code:
S = input()
SL = [i for i in S]
sublist = [-1]*(len(S)-1)
anslist = []
ans = []
for i in range(1<<len(S)-1):
    for j in range(len(S)-1):
        if ((i>>j)&1)==1:
            sublist[j] = "+"
    anslist.append(SL[0])
    for j in range(len(S)-1):
        if sublist[j] == "+":
            anslist.append(sublist[j])
            anslist.append(SL[j+1])
        else:
            anslist.append(SL[j+1])
    ans.append(eval("".join(anslist)))
    anslist = []
    sublist = [-1]*(len(S)-1)
print(sum(ans))

Submission status: Accepted

Solution code:
S = input()
op_cnt = len(S)-1
sum = 0
for i in range(2**op_cnt):
    op = [""] * op_cnt
    for j in range(op_cnt):
        if ((i>>j) & 1):
            op[j] = "+"
    formula = ""
    for p_n, p_o in zip(S, op + [""]):
        formula += (p_n + p_o)
    sum += eval(formula)
#    print(formula)
print(sum)

Submission status: Accepted

Solution code:
s = input()
sum = 0
for i in range(2**(len(s)-1)):
    term = 0
    for j in range(len(s)-1):
        term *= 10
        if (i//(2**j))%2 == 0:
            sum += term + int(s[j])
            term = 0
            if j == len(s)-2:
                sum += int(s[-1])
        else:
            term += int(s[j])
            if j == len(s)-2:
                sum += term*10 + int(s[-1])
if len(s) == 1:
    sum = int(s)

print(sum)

Submission status: Accepted

Solution code:
s = str(input())
sum_ = 0

for i in range(2**(len(s)-1)):
    l = []
    for b in range(len(s)):
        bit = 2**b
        if i & bit > 0:
            l.append(b)
    if len(l) == 0:
        cal_l = [int(s)]
    else:
        pre = 0
        cal_l = []
        for index in l:
            cal_l.append(int(s[pre:index+1]))
            pre = index+1
        cal_l.append(int(s[pre:]))
    sum_ += sum(cal_l)
print(sum_)

Submission status: Accepted

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

if n == 1:
    print(S)
    exit()

for i in range(2**(n-1)):
    sum = 0
    start = 0
    for j in range(n-1):
        if ((i>>(n-j-2)) & 1):
            sum += int(S[start:j+1])
            start = j+1
    sum += int(S[start:])
    ans += sum
print(ans)

Submission status: Accepted

Solution code:
S = input()

ans = 0
num = len(S) - 1

for i in range(2**num):
    tmp_s = S
    for j in range(num):
        if((i >> j) & 1):
            tmp_s = tmp_s[:num-j] + "+" + tmp_s[num-j:]
    ans += sum(list(map(int, tmp_s.split("+"))))

print(ans)

Submission status: Accepted

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

for i in range(2**n):
    num = []
    bi = format(i, '0'+str(n)+'b')
    for j in range(n):
        num.append(s[j])
        if bi[j] == '1':
            num.append('+')
    num.append(s[-1])
    j_num = ''.join(num)
    ans += eval(j_num)

print(ans)

Submission status: Accepted

Solution code:
from itertools import product

s = input()

li = product(['', '+'], repeat=len(s))
st = set()
for c in li:
    ss = ''.join([a + b for (a, b) in zip(s,c)])
    if ss[-1] != '+':
        st.add(ss)
ans = 0
for sss in st:
    ans += eval(sss)

print(ans)

Submission status: Accepted

Solution code:
S = input()
ans = 0
for i in range(2 ** (len(S) - 1)):
    js = 0
    for j in range(len(S)):
        if i >> j & 1 == 1:
            ans += int(S[js:j+1])
            js = j+1
        elif j == len(S)-1:
            ans += int(S[js:j+1])
            
print(ans)

Submission status: Accepted

Solution code:
s = [w for w in input()]
length = len(s)
sum = 0

for i in range(2 ** (length-1)):
    start = 0
    b = format(i, 'b')[::-1]
    for end, flag in enumerate(b):
        if flag == '1':
            extract_s = ''.join(s[start: end + 1])
            sum += int(extract_s)
            start = end + 1
    if start != length:
        extract_s = ''.join(s[start:])
        sum += int(extract_s)

print(sum)

Submission status: Accepted

Solution code:
def bi(x, length):
    ret = "".join(["0" for _ in range(length)])
    return (ret + str(bin(x))[2:])[-length:]


def solve(inp):
    l = len(inp) - 1
    tot = 0
    for i in range(2**l):
        binary = bi(i, l)
        expression = "".join([inp[j] + "+" if binary[j] == "1" else inp[j] for j in range(l)] + [inp[-1]])

        tot += sum(int(e) for e in expression.split("+"))
    return tot

inp = input()
print(solve(inp))

Submission status: Accepted

Solution code:
def bi(x,n):
    o = [0]*n
    c = 0
    while x:
        o[c] = x%2
        x //= 2
        c += 1
    return o

S = input()
l = len(S)-1
ans = 0
for i in range(2**l):
    o = bi(i,l)
    j = ''.join([S[x]+['+',''][o[x]] for x in range(l)]+[S[-1]])
    for k in j.split('+'):
        ans += int(k)

print(ans)

Submission status: Accepted

Solution code:
s = input()
n = len(s)
sum = 0
for i in range(2**(n-1)):
  k = i
  a = 0
  b = 0
  for j in range(n):
    b += 1
    if(k%2==1):
      sum += int(s[a:b])
      a = b
    elif(k==0):
      sum += int(s[a:n])
      break;
    k = k//2
print(sum)

Submission status: Accepted

Solution code:
S = input()

symbol = ['+', '']

solve = []
for i in range(1 << len(S)-1):
  equation = [S[0]]
  for j in range(len(S)-1):
    equation.extend([symbol[(i >> j) & 1], S[j+1]])
  solve.append(eval(''.join(equation)))

ans = sum(solve)
print(ans)

Submission status: Accepted

Solution code:

num = input()
num_array = [i for i in num]

splits = len(num) - 1
n = 2 ** splits

sum = 0

if splits > 0:
    for i in range(n):
        bin = format(i, "0{}b".format(splits))
        bin_array = [i for i in bin]
        tmp_num = str(num_array[0])
        for index, value in enumerate(bin_array):
            if value == "0":
                tmp_num += num_array[index+1]
            else:
                sum += int(tmp_num)
                tmp_num = num_array[index+1]
        sum += int(tmp_num)
else:
    sum = num

print(sum)

Submission status: Accepted

Solution code:
def calc(ds):
    sum = 0
    cnt = 0
    if len(ds) == 0:
        return (0, 1)
    x = 0
    for i in range(len(ds)):
        x = 10*x + ds[i]
        (s, c) = calc(ds[i+1:])
        sum += s + c * x
        cnt += c
    return (sum, cnt)

def main():
    S = input().strip()
    ds = [int(c) for c in S]
    (answer, _) = calc(ds)
    print(answer)
    
main()

Submission status: Accepted

Solution code:
import sys


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


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

Submission status: Accepted

Solution code:
s = input()
answer = 0
sumList = []
numStr = ""
if len(s) == 1:
  print(s)
else:
  for i in range(2**(len(s)-1)):
    bit = "0" + str(len(s) - 1) + "b"
    iStr = format(i, bit)
    numStr += s[0]
    for j in range(len(iStr)):
      if iStr[j] == "1":
        sumList.append(int(numStr))
        numStr = s[j+1]
      else:
        numStr += s[j+1]
    sumList.append(int(numStr))
    numStr = ""
    answer += sum(sumList)
    sumList = []
  print(answer)

Submission status: Accepted

Solution code:
S = input()

length = len(S) - 1
ans = 0

for i in range(2 ** length):
    bit = bin(i)[2:].zfill(length)
    T = ""
    for j in range(len(S)):
        if j == 0:
            T += S[j]
            continue
        else:
            b = bit[j-1]
            if b == "1":
                T += "+"
            T += S[j]
    ans += eval(T)
print(ans)

Submission status: Accepted

Solution code:
l=list(input())
keta=len(l)
i=0
S=[0]*keta
while i<keta:
    if i==0:
        S[i]=int(l[-1])
    else:
        a=10**i
        for j in range(i):
            a=a+(2**(i-1-j))*(10**j)
        S[i]=2*S[i-1]+int(l[-(i+1)])*a
    i=i+1
print(S[-1])

Submission status: Accepted

Solution code:
from itertools import combinations

S = str(input())
n = len(S)

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

Submission status: Accepted

Solution code:
from itertools import combinations

S = str(input())
pos = [i for i in range(len(S)-1)]
insert_indices = [comb for i in range(len(S)) for comb in combinations(pos, i)]

ans = 0

for inds in insert_indices:
    cur_ix = 0
    cur_ans = 0
    while cur_ix < len(S):
        cur_ans += int(S[cur_ix])
        if cur_ix == len(S)-1:
            break
        if cur_ix in inds:
            ans += cur_ans
            cur_ans = 0
        else:
            cur_ans *= 10
        cur_ix += 1
    ans += cur_ans
    
print(ans)

Submission status: Accepted

Solution code:
n = input()
le = len(n)
s  = 0

for i in range(2 ** (le-1)):
    l = [""] * (le-1)
    for j in range(le):
        if i >> j & 1:
            l[j] = "+"
    
    f = ""
    for j, k in zip(n, l + [""]):
        f += (j + k)
        
    s += eval(f)

print(s)

Submission status: Accepted

Solution code:
from itertools import product
import bisect
import sys


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

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}
# b = list(map(lambda x: math.ceil(x/10)*10, a))


S = input()
ans = 0
for p in product(range(2), repeat=len(S)-1):
    tmp = ''
    for i in range(len(S)-1):
        if p[i] == 1:
            tmp += S[i]+'+'
        else:
            tmp += S[i]
    ans += eval(tmp+S[-1])
print(ans)

Submission status: Accepted

Solution code:
from itertools import product
S=input()
ans=0
for p in product(range(2),repeat=len(S)-1):
    tmp=''
    for i in range(len(S)-1):
        if p[i]==1:
            tmp+=S[i]+'+'
        else:
            tmp+=S[i]
    ans+=eval(tmp+S[-1])
print(ans)

Submission status: Accepted

Solution code:
s = list(map(int, list(input())))
n=len(s)
ans=0

for i in range(n):
	for j in range(n-i-1):
		ans += (2**i) * (2**(n-i-j-2) * (10**j) * s[i])
	ans += (2**i)*(10**(n-i-1))*s[i]
print(ans)

Submission status: Accepted

Solution code:
S = list(input())
N = len(S)

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

print(ans)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappop, heappush, heapify, heappushpop
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S = list(input())

l = len(S)

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

Submission status: Accepted

Solution code:
import itertools
N=input()
ans=0
l=itertools.product(range(2),repeat=len(N)-1)
for i in l:
	tmp=''
	for j in range(len(i)):
		if i[j]==0:
			tmp+=N[j]
		else:
			tmp+=N[j]+'+'
	tmp+=N[-1]
	ans+=eval(tmp)
print(ans)

Submission status: Accepted

Solution code:
from itertools import product
s = input()
ans = 0
for p in product(range(2),repeat=len(s)-1):
    tmp = ''
    for i in range(len(s)-1):
        if p[i] == 1:
            tmp += s[i]+'+'
        else:
            tmp += s[i]
    ans += eval(tmp+s[-1])
print(ans)

Submission status: Accepted

Solution code:
import itertools
def make_list(length, i):
    seq = []
    for j in range(length-1):
        seq.append(j)
    return list(itertools.combinations(seq, i))
if __name__ == '__main__':
    s = input()
    lst = []
    ans = 0
    for i in range(len(list(s))):
        lst += make_list(len(list(s)), i)
    expr = ''
    for l in lst:
        if len(l) == 0:
            expr = s
        else:
            before = 0
            expr = ''
            for i in range(len(l)):
                if before == l[i]:
                    expr += s[before] + '+'
                else:
                    expr += s[before:l[i]+1] + '+'
                before = l[i] + 1
                if i == len(l) - 1:
                    expr += s[before:]
        ans += eval(expr)
    print(ans)

Submission status: Accepted

Solution code:
S=input()
ans=0
if len(S)-1==0:
    print(int(S))
    quit()
for i in range(2**(len(S)-1)):
    k=bin(i)[2:].zfill(len(S)-1)
    l=int(S[0])
    for j in range(len(k)):
        t=int(k[j])
        if t==1:
            ans+=l
            l=int(S[j+1])
        else:
            l=l*10+int(S[j+1])
    ans+=l
print(ans)

Submission status: Accepted

Solution code:
S = input()
ans = 0

def f(shiki, index):
	global ans
	l = len(shiki)
	if index < l - 1:
		f(shiki, index + 1)
		f(shiki[: index + 1] + '+' + shiki[index + 1:], index + 2)
		
	else:
		ans += sum(list(map(lambda x: int(x), shiki.split('+'))))

f(S, 0)
print(ans)

Submission status: Accepted

Solution code:
s=input()
ls=len(s)-1
ans=0
for i in range(2**ls):
    mask=str(bin(i))[2:]
    mask=mask.zfill(ls)
    a=""
    for j in range(ls):
        a+=s[j]
        if mask[j]=='1':
            a+="+"
    a+=s[-1]
    ans+=eval(a)
print(ans)

Submission status: Accepted

Solution code:
import itertools
s=input()
ans=0
n=len(s)
l=[i for i in range(1,n)]
for i in range(1,n):
    for x in list(itertools.combinations(l, i))[::-1]:
        ss=list(s)
        for xx in x[::-1]:
            ss.insert(xx,'+')
        ans+=eval(''.join(ss))

ans+=int(''.join(s))
print(ans)

Submission status: Accepted

Solution code:
import sys
import bisect
input = sys.stdin.readline

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

ans = 0
for i in range(1 << N):
    t = []
    
    for j in range(N):
        if (i >> j) & 1:
            t.append(j)

    if len(t) == 0:
        ans += int("".join(map(str, S)))
    else:
        a = S[0]
        for i in range(N):
            if i in t:
                a += "+{}".format(S[i + 1])
            else:
                a += str(S[i + 1])
                
        ans += eval(a)

print(ans)

Submission status: Accepted

Solution code:
S = list(map(str, input()))
S_tmp = []
sum_all = 0
sum_tmp = []

for i in range(len(S)*2-1):
    if i % 2 == 0:
        S_tmp.append(S[int(i/2)])
    
    else:
        S_tmp.append(" ")

def bubunwa1(i, S_tmp, sum_all):
    if i < len(S)-1:
        S_tmp[2*i + 1] = '+'
        bubunwa1(i+1, S_tmp, sum_all)

        S_tmp[2*i + 1] = ''
        bubunwa1(i+1, S_tmp, sum_all)

    elif i == len(S)-1:
        sum_all = eval(''.join(S_tmp).replace(' ', ''))
        sum_tmp.append(sum_all)

bubunwa1(0, S_tmp, sum_all)
print(sum(sum_tmp))

Submission status: Accepted

Solution code:
S = input()
n = len(S)
s = [int(S[i]) for i in range(n)]
def solve(i, su, re):
    if i == n - 1:
        return(su + re * 10 + s[i])
    else:
        return(solve(i + 1, su + re * 10 + s[i], 0) + solve(i + 1, su, re * 10 + s[i]))
print(solve(0,0,0))

Submission status: Accepted

Solution code:
import itertools
S=list(input())
l=['','+']
L=list(itertools.product(l,repeat=len(S)-1))
ans=0
for i in range(2**(len(S)-1)):
    a = S[0]
    for j in range(len(S)-1):
        a+=L[i][j]+S[j+1]
    ans+=eval(a)
print(ans)

Submission status: Accepted

Solution code:
import itertools
S = input()
op = ['+','']
length = len(S) -1
ans = 0

for o in itertools.product(op, repeat=length):
	exp = ""
	for i in range(length):
		exp += S[i]+o[i]
	exp += S[length]
	ans += eval(exp)

print(ans)

Submission status: Accepted

Solution code:
s = input()

import itertools
n = list(itertools.product([0,1], repeat=len(s)-1))

int_list = []
for x in n:
    start = 0
    end = 1
    for y in x:
        if y == 1:
            end+=1
        else:
            int_list.append(int(s[start:end]))
            start=end
            end+=1
    int_list.append(int(s[start:end]))
    
print(sum(int_list))

Submission status: Accepted

Solution code:
s = input()
length = len(s)
ns = list(map(int,s))
total_sum = 0
for mask in range(2 ** (length-1)):
  sum_ = 0
  num = ns[0]
  for i in range(1, length):
    if (mask & 1) > 0:
      sum_ += num
      num = ns[i]
    else:
      num = (num * 10 + ns[i])
    mask = mask >> 1
  total_sum += sum_ + num
print(total_sum)

Submission status: Accepted

Solution code:
S = input()
ans = 0
s = ""
for bit in range(2**(len(S)-1)):
    s = "".join(list(map(lambda i,x: x+"+" if ((bit>>i) & 1 and (i<len(S)-1)) else x, range(len(S)), S)))
    ans += eval(s)
print(ans)

Submission status: Accepted

Solution code:
S = input()
ret = 0
for i in range(2**(len(S)-1)):
    #print("i:" + str(iå))
    s = S
    bin_i = format(i, 'b')
    bin_i =bin_i[::-1]
    #print(bin_i)
    for j in range(len(bin_i)):
        #print(bin_i[j])
        
        #print(bin_i)
        if bin_i[j] == "1":
            #print("入った")
            #s = s[:j + 1] + "+" + s[j + 1:]
            s = s[:-len(S) + j + 1] + "+" + s[-len(S) + j + 1:]
    #print(s)
    ret += eval(s)
print(ret)

Submission status: Accepted

Solution code:
S = input()

if len(S) == 1:
    print(int(S))
    exit()

ans = 0
pluses = [""]*(len(S)-1)
for i in range(2 ** (len(S) - 1)):
    for j in range(len(S)-1):
        if (i >> j) & 1:
            pluses[j] = "+"
        else:
            pluses[j] = ""  
    Ss = ""
    for k, p in zip(S[:-1], pluses):
        Ss += k + p
    Ss += S[-1]
    ans += eval(Ss)
print(ans)

Submission status: Accepted

Solution code:
S = input()
ret = 0
for i in range(2**(len(S)-1)):
    s = ""
    for j in range(len(S)):
        s += S[j]
        if (i >> j) & 1 and j < len(S)-1:
            s += "+"
    ret += eval(s)
print(ret)

Submission status: Accepted

Solution code:
s = input()
plus = ''
ans = 0
if len(s) == 1:
    print(s)
else:
    for i in range(2**(len(s)-1)):
        for j in range(len(s)):
            plus += s[j]
            if ((i >> j) & 1):
                ans += int(plus)
                plus = ''
            if j == len(s) - 1 and len(plus) != 0:
                ans += int(plus)
                plus = ''
    print(ans)

Submission status: Accepted

Solution code:
S=list(map(int,list(input())))
def manyformulas(s):
    if len(s)==1:
        return s[0]
    return s[0]*2**(len(s)-2)+manyformulas(s[1:])+manyformulas([s[0]*10+s[1]]+s[2:])
print(manyformulas(S))

Submission status: Accepted

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

Submission status: Accepted

Solution code:

S = input()

txts = [S[0]]
for i in range(1, len(S)):
    new_txts = []
    for t in txts:
        new_txts.append(t+S[i])
        new_txts.append(t+'+'+S[i])
    txts = new_txts

results = 0
for t in txts:
    numbers = list(map(int, t.split('+')))
    results += sum(numbers)
print(results)

Submission status: Accepted

Solution code:
def f(S, i):
    if i == len(S)-1:
        return S
    else:
        s = S[:i+1] + '+' + S[i+1:]
        return f(s, i+2) + '+' + f(S, i+1)

if __name__ == '__main__':
    S = input()
    print( eval(f(S, 0)) )

Submission status: Accepted

Solution code:
num_list = list(input())
ops_cnt = len(num_list)-1

g= 0

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

    for num,op in zip(num_list,op_list + [""]):
      f += num + op
    g += eval(f)

print(g)

Submission status: Accepted

Solution code:
S = input()

   
ans = 0
for i in range(2 ** (len(S)-1)):
    oparr = []
    for j in range(len(S)-1):
        if (i >> j) & 1:
            oparr.insert(0,"+")
        else:
            oparr.insert(0,"")
    oparr.append("")
    tmp = ""
    for k in range(len(S)):
        tmp += S[k] + oparr[k]
    ans += eval(tmp)

print(ans)

Submission status: Accepted

Solution code:
S = input()

def d2n(d, n, p):
    x = '' # Output
    while d > 0:
        x = str(d % n) + x
        d = int(d / n)
    return x.zfill(p)

def compute(b):
    s = S[:]
    ptr = 1
    for i in range(len(S)-1):
        if b[i] == "1":
            s = s[:ptr] + "+" + s[ptr:]
            ptr += 1 # "+"を入れた分進める
        ptr += 1
    return eval(s)

ans = 0
# 2進数に変換した時、1になっているところに"+"を入れる
cnt = 0
while cnt < 2 ** (len(S) - 1):
    b = d2n(cnt, 2, len(S)-1)
    ans += compute(b)
    cnt += 1
print(ans)

Submission status: Accepted

Solution code:
S = input()

def func(s, split_list):
#     print("Start:",s, split_list)
    l = len(s)
    if l == 0:
        result = 0
        for sl in split_list:
            result += int(sl)
        return result
    
    result = 0
    for i in range(1,l+1):
        result += func(s[i:], split_list[:]+[s[:i]])
#         print(result)
#     print("End:",s, split_list, result)
    return result
        
# func(S)
result = func(S,[])
print(result)

Submission status: Accepted

Solution code:
s = input()
cnt = len(s) - 1
bitlist = []
sums = 0
for i  in range(2**cnt):
    op = [True] * cnt 
    for j in range(cnt):
        if ((i >> j) & 1):
            op[cnt - 1 - j] = False
    bitlist.append(op)
ans = []           
for i in range(2**cnt):
    now = 0
    for j in range(cnt):
        if bitlist[i][j]:
            ans.append(int(s[now:(j+1)]))
            now = j + 1
    ans.append(int(s[now:(cnt + 1)]))
    sums += sum(ans)
    ans=[]
print(sums)

Submission status: Accepted

Solution code:
from itertools import product
S = input()
ans = 0

for string in product(["","+"],repeat=len(S) - 1):
    string = list(string)
    string.append("")
    sum_ = [a + b for a,b in zip(S,string)]
    ans += eval("".join(sum_))

print(ans)

Submission status: Accepted

Solution code:
# https://arc061.contest.atcoder.jp/tasks/arc061_a

import sys
import itertools as it

sys.setrecursionlimit(2000)


def solve(s, i):
    # print(s, i)
    if s == "":
        yield 0
    elif i == len(s):
        yield int(s)
    else:
        for x in solve(s[i:], 1):
            yield x + int(s[:i])
        yield from solve(s, i + 1)


S = input().strip()
res = sum(solve(S, 1))
print(res)

Submission status: Accepted

Solution code:
n = input()
op_cnt = len(n) - 1
ans = 0
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)
    ans += eval(formula)

print(ans)

Submission status: Accepted

Solution code:
from itertools import product


def main():
    S = input()

    ans = 0
    for op in product(["", "+"], repeat=len(S) - 1):
        op = list(op)
        op.append("")
        ans += eval(''.join(a + b for a, b in zip(S, op)))

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from itertools import product
S = input()
ans = 0

# '+'と''の直積集合
for s in product(["", "+"], repeat=len(S) - 1):
  s = list(s)
  s.append("")
  ans += eval("".join(a+b for a,b in zip(S,s)))
 
print(ans)

Submission status: Accepted

Solution code:
S = input()
ans = 0
if len(S) == 1:
    ans += int(S)
for i in range(2**(len(S)-1)):
    binary =list(bin(i)[2:].zfill(len(S)-1))
    S_divide = []
    index = 0
    for j in range(len(S)-1):
        if binary[j] == "1":
            S_divide.append(S[index:j+1])
            index = j+1
        if j == len(S)-2:
            S_divide.append(S[index:])
#    print(S_divide)
    for k in range(len(S_divide)):
        ans += int(S_divide[k])
print(ans)

Submission status: Accepted

Solution code:
from itertools import product
S = input()
sm = 0

for s in product(["", "+"], repeat=len(S) - 1):
    s = list(s)
    s.append("")
    sm += eval("".join(a+b for a,b in zip(S,s)))
print(sm)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import copy

S = list(input())

ans_list = list()

for i in range(2**(len(S)-1)):
    tmp = copy.copy(S)
    for j in range(len(S)-1):
        if((i>>j)&1) == 1:
            tmp.insert(len(S)-j-1,'+')
    ans_list.append(tmp)
    
cnt = 0
for ans in ans_list:
    cnt += sum(map(int,(''.join(ans).split('+'))))
print(cnt)

Submission status: Accepted

Solution code:
import itertools

S = input()
N = len(S)

ans = 0

fs = []
for op in itertools.product(['','+'], repeat=N-1):
	op = list(op)
	op.append('')
	f = ''.join(a+b for a,b in zip(S,op))
	fs.append(f.split('+'))

for f in fs:
    sum_t = 0
    for t in f:
        sum_t += int(t)
    ans += sum_t

print(ans)