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()
import itertools
a = itertools.product([0,1],repeat=len(s)-1)

ans = 0
for x in a: # x = (0,1)
  txt = s[0]
  for i,kigo in enumerate(x):
    if kigo:
      txt += "+" + s[i+1]
    else:
      txt += s[i+1]
  ans += sum(list(map(int,txt.split('+'))))

print(ans)

Submission status: Accepted

Solution code:
s=input()
n=len(s)-1
l=[]
l3=[]
Sum=0
for i in range(2**n):
  bag=[" "]*n
  #print("pattern:",i)
  for j in range(n):
    if ((i>>j) & 1):
      bag[j]="+"
  l.append(bag)
#print(l)

for b in l:
  ll=[]
  inc=0
  for ii in range(n):
    if b[ii] == "+":
      ll.append(int(s[inc:ii+1]))
      inc=ii+1
  ll.append(int(s[inc:len(s)]))
  #print(ll)
  Sum+=sum(ll)
print(Sum)

Submission status: Accepted

Solution code:
s = input()

sum = 0
tmp = 2 ** (len(s) -1)

for i in range(tmp):
    format_spec = '0{}b'.format(len(s)-1)
    flag = format(i, format_spec)
    my_sum = 0
    before = 0
    for j in range(len(s) - 1):
        if flag[j] == '1':
            my_sum += int(s[before:j+1])
            before = j+1
    my_sum += int(s[before:])
    sum += my_sum

print(sum)

Submission status: Accepted

Solution code:
from itertools import permutations, combinations,combinations_with_replacement,product
s = input()
t = product(["+",""],repeat=len(s)-1)
sum=0
for i1 in t:
    calc = ""
    for j,i2 in enumerate(i1):
        calc+=s[j]+i2
    calc += s[-1]
    sum+=eval(calc)

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import sys
from collections import deque
a=input()
ans=0
for i in range(2**(len(a)-1)):
  s=0
  c=int(a[0])
  for j in range(len(a)-1):
    if (i>>j) &1:
      s+=c
      c=int(a[j+1])
    else:
      c=10*c+int(a[j+1])
  ans+=s+c
print(ans)

Submission status: Accepted

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

def dfs(i, l):
    if i == n-1:
        return sum(list(map(int, l.split("+"))))
    return dfs(i+1, l+s[i+1])+dfs(i+1, l+"+"+s[i+1])

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

Submission status: Accepted

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

s = input()
k = len(s)

# def dfs(i, f) :
#     """
#     argument i : どこから始めるか
#     f :　最初の数
#     returen : falese or ture(作れるならtrue)
#     """
#     if i == k-1:
#         return sum(list(map(int, f.split('+'))))

#     return dfs(i+1, f + s[ i +1 ]) + \
#            dfs(i+1, f + '+' +  s[ i +1 ]) 

# print(dfs(0, s[0]))

#bit木を書いていきます

ans = 0

for bit in range(1 << (k-1)):
    f = s[0]
    
    for i in range(k-1):
        # if bit & (1 << i)で、bitにiが含まれているか（フラグが立っているか）を判定してくれるらしい
        if bit & (1 << i):
            f += '+'
        f += s[i + 1]
    ans += sum(list(map(int, f.split('+'))))

print(ans)

Submission status: Accepted

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

ans = 0

for bit in range(1 << (n - 1)):
    # 各場合で式 f を生成する
    f = s[0]

    for i in range(n - 1):
        if bit & (1 << i):
            # フラグが立っているならば "+" を式の末尾に追加する
            f += "+"
        f += s[i + 1]

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

print(ans)

Submission status: Accepted

Solution code:
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

s = sinput()
n = len(s) - 1

sum = 0
for i in range(2**n):
    plus = ["" for i in range(n)] + [""]
    for j in range(n):
        if i>>j&1: plus[j] = "+"
    equa = ""
    for k in range(n+1): equa += s[k] + plus[k]
    sum += eval(equa)

print(sum)

Submission status: Accepted

Solution code:
from sys import stdin
S = stdin.readline().rstrip()
n = len(S)
def dfs(i, f):
    if i == n-1:
        return sum(list(map(int, f.split('+'))))
    return dfs(i+1, f + S[i + 1]) + dfs(i + 1, f + '+' + S[i+1])
print(dfs(0, S[0]))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import sys
input = sys.stdin.readline
import itertools
 
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

s = str(input().rstrip())
s = tuple(int(s[i]) for i in range(len(s)))


mylist = [1, 0]
d = []

for i in itertools.product(mylist, repeat = len(s)-1):
    temp = s[0]
    result = 0
    for j, k in zip(s[1:], i):
        if k != 1:
            temp = temp * 10 + j
        else:
            result += temp
            temp = j
    result += temp
    d.append(result)
    
print(sum(d))

Submission status: Accepted

Solution code:
s=input()
l=len(s)
n=2**(l-1)
total=0
for i in range(n):
    buf=s[0]
    for j in range(l-1):
        if ((i>>j)&1):
            total+=int(buf)
            buf=s[j+1]
        else:
            buf+=s[j+1]
    total+=int(buf)
print(total)

Submission status: Accepted

Solution code:
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
s = rs()
n = len(s)
ans = 0
for bit in range(1 << n - 1):
    tmp = 0
    for i in range(n - 1):
        if bit & (1 << i):
            ans += int(s[tmp:i+1])
            tmp = i + 1
    ans += int(s[tmp:n])
print(ans)

Submission status: Accepted

Solution code:
s = input()
l = list(s)
sum_ = 0
for i in range(1 << len(l) -1):
    ll = []
    for j in range(len(l)):
#         print(i,j)
        ll +=[l[j]]
        if i & (1 << j):
            ll +=['+']
#     print(''.join(ll))    
    sum_ += eval(''.join(ll))
print(sum_)

Submission status: Accepted

Solution code:
# def bit():
#     S = input()
#     n = len(S) - 1
#     ieS = S[0]
#     for i in range(n):
#         ieS += '*'
#         ieS += S[i+1]
#     ans = 0
#     for i in range(2 ** n):
#         eS = ieS
#         for j in range(n):
#             if (i >> j) & 1:
#                 eS = eS[:(j+1)*2-1] + '+' + eS[(j+1)*2:]
#         ans += eval(eS.replace('*', ''))
#     print(ans)


def solve():
    S = input()
    eS = S[0]
    print(dfs(0, S, eS))


def dfs(i, S, eS):
    if i == len(S)-1:
        return eval(eS)
    return dfs(i+1, S, eS+(S[i+1])) + dfs(i+1, S, eS+'+'+(S[i+1]))


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
def solve():
    S = input()
    n = len(S) - 1
    ieS = S[0]
    for i in range(n):
        ieS += '*'
        ieS += S[i+1]
    ans = 0
    for i in range(2 ** n):
        eS = ieS
        for j in range(n):
            if (i >> j) & 1:
                eS = eS[:(j+1)*2-1] + '+' + eS[(j+1)*2:]
        ans += eval(eS.replace('*', ''))
    print(ans)





if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
s=input()
l=len(s)
n=2**(l-1)
total=0
for i in range(n):
    buf=s[0]
    for j in range(l-1):
        if ((i>>j)&1):
            total+=int(buf)
            buf=s[j+1]
        else:
            buf+=s[j+1]
    total+=int(buf)
print(total)

Submission status: Accepted

Solution code:
def solve(S):
    N = len(S) - 1
    ret = 0
    used_equation = set()
    for i in range(pow(2, N)):
        tmp_equation = ''
        last_j = -1
        for j in range(N):
            if i >> j & 1:
                tmp_equation = tmp_equation + '+' + S[last_j + 1: j + 1]
                last_j = j
        if last_j < N:
            tmp_equation = tmp_equation + '+' + S[last_j + 1:]
        ret += eval(tmp_equation) if tmp_equation not in used_equation else 0
        used_equation.add(tmp_equation)
    print(ret)

if __name__ == "__main__":
    S = input()
    solve(S)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(2 ** n):
  l = s[0]
  for j in range(n):
    if (i >> j) & 1:
      l += "+"
    l += s[j+1]
  ans += sum(map(int,l.split("+")))
print(ans)

Submission status: Accepted

Solution code:
from itertools import product
def main():
    s = list(input())
    koho = len(s) - 1
    pat = tuple(product(('+', ''), repeat = koho))
    r = 0
    for pate in pat:
        a = []
        for i, p in enumerate(pate):
            a.append(s[i])
            a.append(p)
        a.append(s[-1])
        r  += eval("".join(a))
    print(r)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s=list(input())
n=len(s)
ans=0
for i in range(2**(n-1)):
    d=0
    s=list(x for x in s if x!="a")
    for j in range(n-1):
        if (i >> j)&1:
            s.insert(-j-1-d,"a")
            d+=1
    z="".join(s)
    y=list(map(int,z.split("a")))
    ans+=sum(y)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    s = input()
    f = s[0]
    n = len(s) - 1
    ans = 0
    
    for i in range(2 ** (n)):
        res = [0] * (n)
        for j in range(n):
            if (i >> j) & 1:
                res[j] = 1
                f += '+'
            f += s[j+1]
        ans += sum(map(int, f.split("+")))
        # print(f)
        # print('b', res)
        f = s[0]
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

sum = 0
for bit in range(2 ** N):
    E = S[0]
    for i in range(N):
        if (bit & (1 << i)):
            E += ' + '
        E += S[i + 1]
    sum += eval(E)

print(sum)

Submission status: Accepted

Solution code:
s = input()
n = len(s) - 1
ans = 0
for bit in range(1 << n):
    now = 0
    for i in range(bit):
        if bit & (1 << i):
            ans += int(s[now : i + 1])
            now = i + 1
    ans += int(s[now : len(s)])
print(ans)

Submission status: Accepted

Solution code:
def dfs(i,f):
    if i==n-1:
        return sum(list(map(int,f.split("+"))))

    else:
        return dfs(i+1,f+s[i+1])+dfs(i+1,f+"+"+s[i+1])
s=input()
n=len(s)
print(dfs(0,s[0]))

Submission status: Accepted

Solution code:
A = list(map(int, list(input())))
 
ans = 0
from itertools import *
N = len(A)-1
for p in product([0,1],repeat=N):
    now = A[0]
    for i in range(N):
        if p[i] == 0:
            now = now*10+A[i+1]
        else:
            ans += now
            now = A[i+1]
    ans += now
print(ans)

Submission status: Accepted

Solution code:
S=list(input())
ans=0
for i in range(2**(len(S)-1)):
    kari=[""]*(len(S)-1)
    for j in range(len(S)-1):
        if ((i>>j)&1):
            kari[j]="+"
    hako=[]
    kasu=0
    gomi=0
    for j in range(len(kari)+len(S)):
        if j%2==0:
            hako.append(S[kasu])
            kasu+=1
        else:
            hako.append(kari[gomi])
            gomi+=1
    #print(hako)
    hako="".join(hako)
    #hako=hako.replace(",","")
    #print(hako)
    ans+=eval(hako)
print(ans)

Submission status: Accepted

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

ans = 0
from itertools import *
N = len(A)-1
for p in product([0,1],repeat=N):
    now = A[0]
    for i in range(N):
        if p[i] == 0:
            now = now*10+A[i+1]
        else:
            ans += now
            now = A[i+1]
    ans += now
print(ans)

Submission status: Accepted

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

n = len(s) - 1 # 隙間の数
plus_list = list(product(["+", ""], repeat=n))

ans = 0

for bit in range(1 << n):
    formula = s[0]
    for j, k in zip(plus_list[bit], s[1:]):
        formula += (j + k)
    ans += eval(formula)

print(ans)

Submission status: Accepted

Solution code:
S=list(input())
ans=0
for i in range(2**(len(S)-1)):
    kari=[""]*(len(S)-1)
    for j in range(len(S)-1):
        if ((i>>j)&1):
            kari[j]="+"
    hako=[]
    kotae=0
    kasu=0
    gomi=0
    for j in range(len(kari)+len(S)):
        if j%2==0:
            hako.append(S[kasu])
            kasu+=1
        else:
            hako.append(kari[gomi])
            gomi+=1
    #print(hako)
    hako="".join(hako)
    #hako=hako.replace(",","")
    #print(hako)
    kotae=eval(hako)
    ans+=kotae
print(ans)

Submission status: Accepted

Solution code:
S=list(input())
ans=0
for i in range(2**(len(S)-1)):
    kari=[""]*(len(S)-1)
    for j in range(len(S)-1):
        if ((i>>j)&1):
            kari[j]="+"
    hako=[]
    kotae=0
    kasu=0
    gomi=0
    for j in range(len(kari)+len(S)):
        if j%2==0:
            hako.append(S[kasu])
            kasu+=1
        else:
            hako.append(kari[gomi])
            gomi+=1
    #print(hako)
    hako=",".join(hako)
    hako=hako.replace(",","")
    #print(hako)
    kotae=eval(hako)
    ans+=kotae
print(ans)

Submission status: Accepted

Solution code:
n = input()

if len(n) < 2:
    print(n)
    exit()

kumi = []
iti = 0

for x in range(2 ** (len(n) -1)):
    for m in range(len(n) -1):
        if (x >> m) & 1:
            kumi.append(n[iti:m+1])
            iti = m+1
        if m == len(n) -2:
            kumi.append(n[iti:m+2])
    iti = 0

kumi_int =[int(s) for s in kumi]
print(sum(kumi_int))

Submission status: Accepted

Solution code:
import copy

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

for i in range(2 ** n):
    x = copy.deepcopy(s)
    y = 1
    for j in range(n):
        if ((i >> j) & 1): #フラグが立っていたら
            x = x[:j+y] + "+" + x[j+y:]
            y += 1
    ans += eval(x)

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin,setrecursionlimit
setrecursionlimit(10**6)
def S(): return stdin.readline().rstrip()

def f(ls,stock,save):
    if len(ls)<1:
        return int(stock)+save
    else:
        stock += ls.pop(0)
        sum = 0    
        if 0<len(ls):
            buff = ls[:]
            sum += f(buff,'0',save+int(stock))
        buff = ls[:]
        sum += f(buff,stock,save)
        return sum

s = S()
ls = list(s)
ans = f(ls,'0',0)
print(ans)

Submission status: Accepted

Solution code:
S = input()
ans = 0
for i in range(2**(len(S)-1)):
    moji = S[0]
    tmp = 0
    for j in range(len(S)-1):
        if ((i >>j) & 1):
            moji = moji + '+' + S[j +1]
        else:
            moji = moji + S[j+1]
    tmp = moji.split('+')
    for k in range(len(tmp)):
        ans += int(tmp[k])
print(ans)

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

s = ns()
ans = 0
n = len(s)
t = 2**(n-1)
for i in range(t):
    moji = list(s)
    for j in range(n):
        if (i >> j) & 1:
            moji.insert(n-j-1,'+')
    ans += eval(''.join(moji))
print(ans)

Submission status: Accepted

Solution code:
def main():
    S = input()
    ans = 0
    for i in range(len(S)):
        for j in range(1,len(S)-i+1):
            # 数値S[i]を下からj桁目の数として受け取るパターン数は
            # (1) (残りのSの長さ-1)個の場所に'+'をいれるパターン数 S[:i]
            # (2) (残りのSの長さ-1)個の場所に'+'をいれるパターン数 S[i:]
            # の積に他ならない
            ans += int(S[i])*(10**(j-1)) * (2**i) * (2**max(0,(len(S)-i-j-1)))
    print(ans)
main()

Submission status: Accepted

Solution code:
s = input()
n = len(s)
ans = 0
for i in range(2 ** (n-1)):
    tmp = []
    for k in range(n-1):
        tmp.append(s[k])
        if i>>k & 1:
            tmp.append("+")
    tmp.append(s[-1])
    ans += eval("".join(tmp))
print(ans)

Submission status: Accepted

Solution code:
s = input()
n = len(s) - 1
answers = []
sl = [s[i] for i in range(len(s))]
for i in range(2 ** n):
    tmp = []
    for j in range(n):
        if ((i >> j) & 1):
            tmp.append(j)
    ll = ['*']*len(s)
    for k in tmp:
        ll[k] = '+'
    ans = []
    for k, _ in zip(sl, ll):
        ans.append(k)
        ans.append(_)
    ans = [_ for _ in ans if _ != '*']
    ans = ''.join(ans)
    ans = ans.split('+')
    ans = [int(_) for _ in ans if _ != '+']
    ans = sum(ans)
    answers.append(ans)
print(sum(answers))

Submission status: Accepted

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

ans = 0
bit_n = n-1
for i in range(2**bit_n):
    tmp = 0
    res = int(s)
    mod = 10
    for j in range(bit_n):
        if ((i>>j)&1):
            tmp+=res%mod
            res//=mod
            mod=10
        else:
            mod*=10
    ans+=res
    ans+=tmp
print(ans)

Submission status: Accepted

Solution code:
s = input()
res_list = []
ls = len(s)
for i in range(2**(ls-1)):
    res = s[0]
    for j in range(ls-1):
        if (i >> j) & 1:
            res += '+'
        res += s[j+1]
    res_list.append(eval(res))
print(sum(res_list))

Submission status: Accepted

Solution code:
s = input()
n = len(s)
ans = 0
for i in range(2**(n-1)):
    x = []
    for j in range(n):
        x.append(s[j])
        if (i>>j) & 1:
            y = int("".join(x))
            ans += y
            x = []
        else:
            pass
    if x != []:
        y = int("".join(x))
        ans += y
print(ans)

Submission status: Accepted

Solution code:
S=input()

def f(s):
    sum=0
    if len(s)==1:
        return int(s)
    for i in range(1,len(s)):
        sum+=(2**(len(s)-i-1))*int(s[:i])+f(s[i:])
    return sum+int(s)

print(f(S))

Submission status: Accepted

Solution code:
S = input()
n = len(S)
import copy

ans = [0]

def rec(index,tmp,tmp_list):
    # print(tmp,tmp_list)
    if index > n-1:

        tmp_list.append(tmp)
        # print(tmp_list)
        # print(tmp_list)
        ans[0] += sum(tmp_list)
        return

    tmp_list1 = copy.deepcopy(tmp_list)
    tmp_list2 = copy.deepcopy(tmp_list)
    
    
    tmp_list1.append(tmp)
    rec(index+1,int(S[index]),tmp_list1)

    rec(index+1,10*tmp + int(S[index]),tmp_list2)
    return

rec(1,int(S[0]),[])
print(ans[0])

Submission status: Accepted

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

for i in range(2 ** n):
    l = s[0]
    for j in range(n):
        if (i >> j) & 1 == 1:
            l += '+'
        l += s[j + 1]
    ans += sum(map(int, l.split('+')))

print(ans)

Submission status: Accepted

Solution code:
st_N=input()
N=int(st_N)


output=0
for i in range(1<<(len(st_N)-1)):
    f=st_N[0]
    for j in range(len(st_N)-1):

        if((i>>j) & 1)==1:
            f=f+'+'
        f=f+st_N[j+1]
    #print(f)
    output=output+sum(map(int,f.split('+')))

print(output)

Submission status: Accepted

Solution code:
s = input()
n = len(s)
p = []
for i in range(2 ** (n-1)):
    tmp = [' '] * (n-1)
    for j in range(n-1):
        if i >> j & 1:
            tmp[j] = "+"
    p.append(tmp)
ans = []
s = list(s)
s_ = []
for i in range(n):
  if(i == n-1):
    s_.append(s[i])
    break
  s_.append(s[i])
  s_.append(" ")

s__ = []
for i in range(len(p)):
  tmp = s_
  tmp[1::2] = p[i]
  #print(tmp)
  tmp = [a for a in tmp if a != ' ']
  temp = ''.join(tmp)
  #print(temp)
  if("+" in temp):
    ans.append(eval(temp))
  else:
    ans.append(int(temp))
print(sum(ans))

Submission status: Accepted

Solution code:
S = list(input())
s = len(S)-1
from itertools import product
a = list(product(["+",""],repeat=s))
ans = 0
for i in a:
    b = ""
    for j in range(len(S)):
        if j<=s-1:
            b += S[j]
            b += i[j]
        else:
            b += S[j]
    ans += eval(b)
print(ans)

Submission status: Accepted

Solution code:
from itertools import product

S = input()

patterns = list(product(["","+"],repeat=len(S)-1))

ans = 0

for pattern in patterns:
    cnt = 0
    num = ""
    for i in range(len(pattern)+1):
        if i == 0:
            num = num + S[i]
        else:
            if pattern[i-1] == "+":
                cnt += int(num)
                num = S[i]
            else:
                num = num + S[i]
    cnt += int(num)
    ans += cnt


print(ans)

Submission status: Accepted

Solution code:
s = list(input())
n = (len(s)-1)
sum = 0
pt = []
for i in range(2 ** n):
  tmp = [""] * n
  for j in range(n):
    if (i >> j) &1 :
      tmp[j] = "+"
  pt.append(tmp)
  
for p in pt:
  fr = ""
  for j in range(n):
    
    fr += s[j] + p[j]
  sum += eval(fr+s[n])
    
print(sum)

Submission status: Accepted

Solution code:
s = input()
res_list = []
for i in range(2**(len(s)-1)):
    res = s[0]
    for j in range(len(s)-1):
        if(i >> j) & 1:
            res += '+'
        res += s[j + 1]
    res_list.append(eval(res))
print(sum(res_list))

Submission status: Accepted

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

ans = 0
for i in range(2**(n-1)):
    c = 10
    tmp = int(s)
    res = 0
    for j in range(n-1):
        if ((i>>j)&1):
            res+=tmp%c
            tmp=tmp//c
            c=10
        else:
            c*=10
    ans+=res+tmp
print(ans)

Submission status: Accepted

Solution code:
s = input()
sum=0
for bit in range(1 << len(s)-1):
  list_i  = [i for i in s]
  count=0
  for i in range(len(s)-1):
    if bit & (1<<i):
      count += 1
      list_i.insert(i+count,'+')
  ans=''
  for i in list_i:
    ans += i
  for i in ans.split('+'):
    sum += int(i)
print(sum)

Submission status: Accepted

Solution code:
ss = input()
ans = []

def bfs(exp, x):
    # 探索終了
    if x == len(ss):
        return exp
    nxt = None
    # まだ使っていない数字を求める
    if exp[-1] == '+':
        nxt = ss[x]
        ret = bfs(exp+nxt, x+1)
        if ret:
            s_ = sum([int(i) for i in ret.split("+")])
            ans.append(s_)
    else:
        nxt = ss[x]
        ret = bfs(exp+nxt, x+1)
        if ret:
            s_ = sum([int(i) for i in ret.split("+")])
            ans.append(s_)
        ret = bfs(exp+'+', x)
        if ret:
            s_ = sum([int(i) for i in ret.split("+")])
            ans.append(s_)
if len(ss) == 1:
    print(int(ss))
else:
    bfs(ss[0],1)
    print(sum(ans))

Submission status: Accepted

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

for n in range(1 << N-1):
    s = S
    cnt = 0
    for i in range(N-1):
        if (n >> i) & 1 == 1:
            s = s[:i+cnt+1] + "+" + s[i+cnt+1:]
            cnt += 1
    ans += eval(s)

print(ans)

Submission status: Accepted

Solution code:
import itertools
S=input()
lis = list(itertools.product([0,1], repeat=len(S)-1))
ans=0
for li in lis:
    st=0
    x=0
    for i in range(len(S)-1):
        if li[i]==1:
            x += int(S[st:i+1])
            st = i+1
            
    x += int(S[st:])
    
    ans += x         
print(ans)

Submission status: Accepted

Solution code:
def resolve():
    S = input()
    sumA = 0
    for i in range(2**(len(S) - 1)):
        Stmp = list(S)
        for j in range(len(S) - 2, -1, -1):
            if (i >> j) & 1:
                Stmp.insert(j + 1, "+")
        sumA += eval("".join(Stmp))
    print(sumA)


resolve()

Submission status: Accepted

Solution code:
s = input()
res_list = []
# 2^nはbit全探索が効果絶大！！
for i in range(2 ** (len(s) - 1)):
    res = s[0]
    for j in range((len(s) - 1)):
        if (i >> j) & 1:
            res += '+'
        res += s[j + 1]
    res_list.append(eval(res))

print(sum(res_list))

Submission status: Accepted

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

ans = 0

for bit in range(2 ** (l-1)):
    f = s[0]
    for i in range(l-1):
        if ((bit >> i) & 1):
            f += '+'
        f += s[i+1]

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

Submission status: Accepted

Solution code:
# C - たくさんの数式
from itertools import product
S = input()
n = len(S)-1
total =0
for i in list(product(["","+"],repeat=n)):
    bag=""
    for ind,val in enumerate(S):
        if ind ==0:
            bag+=val
        else:
            bag+=i[ind-1]+val
    total +=eval(bag)        
print(total)

Submission status: Accepted

Solution code:
# C - たくさんの数式
S =(input())
n = len(S)-1
total = 0
for i in range(2**n):
    bag = ""
    for ind,val in enumerate(S):
        bag+=val
        if ((i>>ind)&1):
            bag+="+"
    total+=eval(bag)
print(total)

Submission status: Accepted

Solution code:
s = input()
plus_len = len(s) - 1
num_search = 2 ** plus_len
result = 0
for i in range(num_search):
  x = ''
  for index,value in enumerate(s):
    x += value
    if (i >> index) & 1:
      x += '+'
  
  #print(x)
  #print(eval(x))
  result += eval(x)
print(result)

Submission status: Accepted

Solution code:
S = input()

def saiki(n, s=S[0]):
    _sum = 0
    
    if n==len(S)-1:
#         print(s)
        return eval(s)
    
    _sum += saiki(n+1, s + "+" + S[n+1])
    _sum += saiki(n+1, s + S[n+1])
    
    return _sum
    
print(saiki(0))

Submission status: Accepted

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

wa = 0
for i in range(2**n):
    lst = [""]*n
    for j in range(n):
        if i&(1<<j):
            lst[j] = "+"
    lst_s = [0]*(len(s) + n)
    lst_s[::2] = s
    lst_s[1::2] = lst
    #print(eval("".join(lst_s)))
    wa += eval("".join(lst_s))
print(wa)

Submission status: Accepted

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

ans = 0

for bit in range(1 << n-1):
    f = s[0]
    for i in range(n-1):
        if (bit & (1<<i)):
            f += "+"
        f += s[i+1]
    ans += sum(map(int , f.split("+")))

print(ans)

Submission status: Accepted

Solution code:
S = str(input())
N = 2 ** (len(S)-1)
l = [] # それぞれの和を格納
for i in range(N):
  m = [S] # 分けた数字を格納
  cnt = 0
  for j in range(len(S)-1):
    if (i >> j) & 1:
      m.append(m[-1][:cnt+1])
      m.append(m[-2][cnt+1:])
      del m[-3]
      cnt = 0
    else:
      cnt += 1
  m = [int(s) for s in m]
  l.append(sum(m))
print(sum(l))

Submission status: Accepted

Solution code:
S = input()
lng = len(S) - 1
#print(lng)
cnt = 0

for i in range(2**lng):
    A = format(i, '09b')
    A = A[-lng:]
    #print(A)
    slc = 0
    for j in range(lng):
        #print(j)
        #print(int(A[j]))
        if int(A[j]):
            #print(int(S[slc:j+1]))
            cnt += int(S[slc:j+1])
            #cnt += int(S[slc:j+1])
            slc = j +1
    #print(int(S[slc:]))
    cnt += int(S[slc:])
print(cnt)

Submission status: Accepted

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

ans = 0

for bit in range(1 << (l-1)):
    # print(bit)
    f = S[0]
    for i in range(l-1):
        if bit & (1 << i):
            f += "+"
        f += S[i+1]

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

Submission status: Accepted

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

Submission status: Accepted

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


def dfs(i, f):
    if i == n-1:
        return eval(f)

    return dfs(i+1, f+'+' + s[i+1]) + \
        dfs(i+1, f+s[i+1])


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

Submission status: Accepted

Solution code:
s = str(input())
l = len(s)
ans = 0
x = 2**(l-1)
dg = [[] for i in range(x)]
for i in range(x):
    b = 0#各桁の値
    d = 0#一つの値にするやつ
    tmp = 0 #数式計算用

    for j in range(l):
        b = int(s[j])
        d = d*10 +b
        if i>>j&1 :
            tmp += d
            dg[i].append(d)
            d = 0
    tmp += d
    ans += tmp
    dg[i].append(d)
# for i in range(x):
#     print(dg[i])
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


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


def resolve():
    s = input().rstrip()

    ans = 0
    int_list = []
    for bit in range(1<<len(s)-1):

        plus_list = []
        for i in range(len(s)-1):
            #print(bit, i)
            if bit & (1<<i):
                plus_list.append(i)

        #print(plus_list)

        if len(plus_list) == 0:
            int_list.append(s)
        else:
            pre = 0
            temp_list = []
            for i, plus in enumerate(plus_list):
                if i == 0:
                    temp_list.append(s[:plus+1])
                    temp_list.append(s[plus+1:])
                    pre = plus+1
                else:
                    temp_s = temp_list.pop(i)
                    temp_list.append(temp_s[:plus+1-pre])
                    temp_list.append(temp_s[plus+1-pre:])
                    pre = plus+1

            for s2 in temp_list:
                int_list.append(s2)


        #print(bit, i, int_list)


    for num in int_list:
        ans += int(num)




    print(ans)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
s = input()
n = len(s)
ans = 0
for bit in range(1 << (n-1)):
    f = s[0]
    for i in range(n-1):
        if bit & 1 << i:
            f += '+'
        f += s[i+1]
        
    ans += sum(map(int, f.split('+')))
    
print(ans)

Submission status: Accepted

Solution code:
S = input()

def saiki(i,s = S[0]):
    _sum = 0
    if i == len(S) - 1:
        ans = eval(s)
        return ans
    a = saiki(i + 1, s + "+" + S[i+1])
    b = saiki(i + 1, s + S[i+1])
    
    return a + b
    
print(saiki(0))

Submission status: Accepted

Solution code:
S = input()

def saiki(i,s = S[0]):
    _sum = 0
    if i == len(S) - 1:
        ans = eval(s)
        return ans
    _sum += saiki(i + 1, s + "+" + S[i+1])
    _sum += saiki(i + 1, s + S[i+1])
    
    return _sum
        
print(saiki(0))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    S = input()
    l = len(S)-1
    ret = 0
    for i in range(2**l):
        fs = S[0]
        for j in range(l):
            if (i>>j & 1) == 1:
                fs += '+'
            fs += S[j+1]
        ret += eval(fs)
    print(ret)

if __name__ == '__main__':
    main()