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()
n = len(S)-1
ans = 0
for i in range(2**n):
    add = 0
    expr = list(S)
    for j in range(n):
        if ((i >> j) & 1):
            expr.insert(j+1+add, "+")
            add += 1
    ans += eval("".join(expr))
print(ans)

Submission status: Accepted

Solution code:
S = input()
n = len(S)-1
ans = 0
for i in range(2**n):
    add = 1
    expr = list(S)
    for j in range(n):
        if ((i >> j) & 1):
            expr.insert(j+add, "+")
            add += 1
    ans += eval("".join(expr))
print(ans)

Submission status: Accepted

Solution code:
s=input()
cnt=len(s)-1
ans=0
for i in range(1<<(cnt)):
    op=[""]*cnt
    for j in range(cnt):
               if((i>>j)&1):
                op[j]="+"
    formula=""
    for k,l in zip(s,op+[""]):
        formula+=(k+l)
    ans+=eval(formula)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


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


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

Submission status: Accepted

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

S = input().strip()
#-----

digit_2 = len(S)-1
total=0
for i in range( 2**(digit_2) ):
    bin_str = format(i, 'b').zfill(digit_2)
    bin_str = bin_str[:] + "0"

    calc_str=""
    for j in range(len(S)):
        if bin_str[j] == "1":
            calc_str += S[j] + "+"
        else:
            calc_str += S[j]
    
    calc = sum(map(int, calc_str.split("+")))
    total += calc
    
print(total)

Submission status: Accepted

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

ans = 0
for i in range(1 << l-1):
    n = N
    for j in range(l-1)[::-1]:
        if (i >> j) & 1 == 1:
            n = n[:j+1] + "+" + n[j+1:]
    ans += sum(list(map(int, n.split("+"))))

print(ans)

Submission status: Accepted

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

ans = int(N)

for i in range(1,l):
    for j in range(l+1-i):
        if j == 0 or j == l-i:
            t = l - i - 1
        else:
            t = l - i - 2
        ans += int(N[j:j+i]) * (2 ** t)

print(ans)

Submission status: Accepted

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

N = len(S)

tens = [10**i for i in range(N)]

tens.reverse()

twos = [1]
twos.extend(2**i for i in range(N-1))

sums = 0
all_comb = sum(twos)
for i in range(N):
    tmp = [x*y for x, y in zip(tens[i:], twos)]
    exp = S[i] * sum(tmp) / sum(twos)
    sums = sums + exp
    del twos[-1]
print(int(sums * all_comb))

Submission status: Accepted

Solution code:
s = input()
l = len(s)
dig = [1]
for x in range(l-1):
  dig.append(2**x)

ans = 0
for x in range(l):
  n = int(s[x])
  for y in range(l):
    ans += n * dig[y] * (10**(l-y-1))
  dig[x] = 0
  if x < l-1:
    dig[x+1] *= 2
print(ans)

Submission status: Accepted

Solution code:
S = input()
ans = 0

for i in range(2**(len(S)-1)):
    now = ""
    for j, c in enumerate(S):
        now += c
        if i & (1 << j) != 0:
            ans += int(now)
            now = ""
    ans += int(now)

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python

def main():
    S = input()
    size = len(S)

    ans = 0
    for bit in range(1 << size-1):
        exp = S[0]
        for i in range(size-1):
            if (bit & (1 << i)):
                exp += '+'
            exp += S[i+1]
        ans += eval(exp)

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = list(input())
lenS = len(s)
sumS = 0

patterns = []
for i in range(2 ** (lenS - 1)):
    tmp = [False] * (lenS - 1)
    for j in range(lenS - 1):
        if i >> j & 1:
            tmp[j] = True
    patterns.append(tmp)

for pattern in patterns:
    a = s[0]
    for i in range(len(pattern)):
        if pattern[i] == True:
            pass
        else:
            sumS += int(a)
            a = "0"
        a += s[i+1]
    sumS += int(a)

print(sumS)

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

def main():
  S = ns()
  n = len(S) - 1

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

if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
s = list(input())
n = len(s) - 1
ans = 0
for i in range(2 ** n):
    op = [0] * n
    for j in range(n):
        op[j] = (i >> j) & 1
    val, idx = 0, 0
    for j in range(n):
        if op[j] == 0:
            pass
        else:
            mknum = ''
            for k in range(idx, j+1):
                mknum += s[k]
            val += int(mknum)
            idx = j+1
    mknum = ''
    for k in range(idx, n+1):
        mknum += s[k]
    val += int(mknum)
    ans += val
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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


s = input()
n = len(s)

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

Submission status: Accepted

Solution code:
s =input()
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:
S = list(input())
N = len(S)-1
ans = int("".join(S))
for i in range(1,2**N):
    s = []
    n = i
    for j in range(N):
        s.append(n%2)
        n//=2
    m = S[0]
    for j in range(N):
        if s[j]:m+="+"
        m+=S[j+1]
    ans+=eval(m)
print(ans)

Submission status: Accepted

Solution code:
s = input()
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:
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 = [int(i) for i in input()]
n = len(s)
ans = 0

for i in range(pow(2, n-1)):
    tmp = s[0]
    res = 0
    for j in range(n-1):
        if (i >> j) & 1:
            res += tmp
            tmp = s[j+1]
        else:
            tmp = tmp * 10 + s[j+1]
    res += tmp
    ans += res


print(ans)

Submission status: Accepted

Solution code:
def f(i):
    global m
    if i == len(b):
        c = []
        c = [s[0]]
        for j in range(len(b)):
            if not b[j] == 0:
                for k in range(len(c)):
                    m += int(c[len(c) - k - 1]) * 10 ** k
                c = []
            c.append(s[j + 1])
        for k in range(len(c)):
            m += int(c[len(c) - k - 1]) * 10 ** k
        c = []
        return
    f(i + 1)
    b[i] = 1
    f(i + 1)
    b[i] = 0

s = list(input())
b = [0] * (len(s) - 1)
m = 0
f(0)
print(m)

Submission status: Accepted

Solution code:
S=input();ans=0;
for b in range(2**(len(S)-1)):
  x=int(S[0]);
  for i in range(1,len(S)):
    if(b%2):
      ans+=x;
      x=0;
    else:
      x*=10;
    x+=int(S[i])
    b//=2;
  ans+=x;
print(ans)

Submission status: Accepted

Solution code:
S = [int(c) for c in input()]
N = len(S)
ans = S[-1]
for i in range(2,N + 1):
    num = S[-i]
    ans = 2 * ans + num * (10 ** (i - 1))
    for j in range(i - 1):
        ans += num * (10 ** j) * (2 ** (i - j - 2))
print(ans)

Submission status: Accepted

Solution code:
S = input()

amount = 0
for n in range(2 ** (len(S) - 1)):
    s = ""
    nn = n
    for i in range(len(S) - 1):
        s += S[i]
        if nn % 2 == 1:
            s += "+"
        nn >>= 1
    s += S[-1]
    amount += eval(s)
print(amount)

Submission status: Accepted

Solution code:
import numpy as np

import numpy as np
def Binary_Gen(n):
    bina = np.ones(2**n,dtype=object)
    for i in range(2**n):
        b = str(bin(i))[2:].zfill(n)
        bina[i] = b
    return bina


S =str(input())

add_ = Binary_Gen(len(S)-1)





count = 0

for i in add_:

    list_1 = [int(idx) for idx,j in enumerate(str(i)) if j == '1']

    if len(list_1)>0:
        comp = np.ones(len(list_1)+1)
        for k in range(len(comp)):
            if k==0:
                comp[k] = int(S[:list_1[k]+1])
            elif k == (len(comp)-1):
                comp[k] = int(S[list_1[k-1]+1:])
            else:
                comp[k] = int(S[list_1[k-1]+1:list_1[k]+1])

        count+= sum(comp)
    elif len(list_1)==0:
        count+=int(S)
        
print(int(count))

Submission status: Accepted

Solution code:
#045_C
s=[int(i) for i in input()]
n=len(s)
ans=0

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

Submission status: Accepted

Solution code:
s = input()
len_s = len(s)
sum_s = 0
for i in range(1 << (len_s - 1)):
    end = len_s
    for j in range(len_s - 1):
        if (i >> j) & 1:
            sum_s += int(s[(len_s - 1) - j:end])
            end = (len_s - 1) - j
    sum_s += int(s[0:end])
            
print(sum_s)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(S: str):
    DP = [0]*(len(S)+1)

    for i in range(len(S)):
        # print("-")
        DP[i+1] = DP[0] + int(S[:i+1])
        # print(DP[0] + int(S[i]))
        for j in range(i):
            DP[i+1] += DP[j+1]+int(S[j+1:i+1])*(2**j)
            # print(DP[j+1]+int(S[j+1:i+1])*(2**j))
    print(DP[-1])
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = str(next(tokens))  # type: int
    solve(S)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input().strip()

L = len(S) - 1
i = 2 ** L - 1

ans = 0

while i >= 0:
    tmp = str(S[0])
    for l in range(L):
        if i >> l & 1:  # "+"
            ans += int(tmp)
            tmp = S[l+1]
        else:
            tmp += str(S[l+1])
    ans += int(tmp)
    i -= 1
print(ans)

Submission status: Accepted

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

ans = 0
for bit in range(1 << n - 1):
    formula = ""
    for i in range(n):
        formula += s[i]
        if i != n - 1:
            formula += "+" if (bit & 1 << i) else ""
    ans += eval(formula)

if n == 0:
    print(0)
elif n == 1:
    print(int(s))
else:
    print(ans)

Submission status: Accepted

Solution code:
S = input()
size = len(S)

ans = 0

for bit in range(1 << size - 1):
    exp = S[0]
    for i in range(size - 1):
        if (bit >> i) & 1:
            exp += "+"
        exp += S[i + 1]
    ans += eval(exp)

print(ans)

Submission status: Accepted

Solution code:
S = input()
size = len(S)

ans = 0

for binary in range(1 << size - 1):
    exp = S[0]
    for i in range(size - 1):
        if (binary >> i) & 1:
            exp += "+"
        exp += S[i + 1]
    ans += eval(exp)

print(ans)

Submission status: Accepted

Solution code:
A = list(input())
n = len(A)
B = list(range(1,n))
m = len(B)
# v: +を入れる場所
v = []
for bit in range(1<<m):
    tmp = []
    for i in range(m):
        if 1 & (bit>>i):
            tmp.append(B[i])
    v.append(tmp)
v.sort(key=len)

res = 0
for b in v:
    tmp_index = 0
    if b==[]:
        res += int(''.join(A))
        continue
    # 末尾まで足したいのでAの長さを追加する
    b = b + [n]
    for i in b:
        res += int(''.join(A[tmp_index:i]))
        tmp_index = i
print(res)

Submission status: Accepted

Solution code:
def main():
    numbers = input()
    answer = 0
    for i in range(pow(2, len(numbers) - 1)):
        sign = bin(i)[2:].zfill(len(numbers) - 1).replace("1", "+").replace("0", "x")
        formula = numbers[0]
        for i in range(1, len(numbers)):
            formula += sign[i - 1] + numbers[i]
        answer += eval(formula.replace("x", ""))
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from itertools import chain, product, zip_longest
 
nums = list(input())
s = 0
for ops in product(('', '+'), repeat=len(nums) - 1):
    exp = ''.join(chain(*zip_longest(nums, ops, fillvalue='')))
    s += eval(exp)
print(s)

Submission status: Accepted

Solution code:
from itertools import chain, product, zip_longest

nums = list(input())
s = 0
for ops in product(('', '+'), repeat=len(nums) - 1):
    exp = ''.join(chain(*zip_longest(nums, ops, fillvalue='')))
    s += eval(exp)
print(s)

Submission status: Accepted

Solution code:
s=str(input())
n=len(s)-1#間間なので-1
#print(s,n)
#print(xy)
bit=[]#1が＋入れる0がいれない
ans=0
c=0
count=[]
def bit_search(bit):
    #print("DFGHNM")
    count=[]#分けたやつを補完するやつ
    global ans
    c=0
    if len(bit)==n:#2**n文の組み合わせを調べる加圧10を交互に入れるためのif
        for i in range(n):
            if bit[i]==1:
                #print(int(s[c:i+1]))
                count.append(int(s[c:i+1]))
                c=i+1#ここの＋１大事
        #print(int(s[c:n+1]))
        count.append(int(s[c:n+1]))
        ans+=sum(count)
        #print(ans,sum(count),bit,c)
        return 
    else:
       #再起化することによって最初にbitの配列を作る必要性をなくした
        #print(bit)
        bit_search(bit+[0])
        bit_search(bit+[1])

bit_search(bit)
print(ans)

Submission status: Accepted

Solution code:
# 回答見て

S_list = list(input())
n = len(S_list) - 1
answers = []
total_sum = 0
for i in range(2 ** n):
    # 足し算の位置を決める '1+25'に直す
    ans_str = S_list[0]
    for j in range(n):
        if ((i >> j) & 1):
            ans_str += '+'
            ans_str += S_list[j+1]
        else:
            ans_str += S_list[j+1]
    
    # '1+25'を＋で分割➡足す
    ans_list = ans_str.split('+')
    ans = 0
    for num in ans_list:
        ans += int(num)
    total_sum += ans
print(total_sum)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from itertools import product
import sys


def solve(S: str):
    ans = 0
    for cs in product(("", "+"), repeat=len(S) - 1):
        ans += eval("".join(
            Si + csi for Si, csi in zip(S, cs + ('',))))
    print(ans)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
ans = 0
for bit in range(2**(len(s)-1)):
    x = s[0]
    for i in range(len(s)-1):
        if ((bit>>i) & 1):
            x += "+"
        x += s[i+1]
    ans += eval(x)
print(ans)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    s = readline().strip()
    n = len(s) - 1

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s = input()
n = len(s) - 1
ans = 0
w = ""
for i in range(0, 2**n):
    for j, r in enumerate(s):
        x = i & 1
        i >>= 1
        w += r
        if j == n:
            continue
        if x:
            ans += int(w)
            w = ""
        else:
            pass
    ans += int(w)
    w = ""
print(ans)

Submission status: Accepted

Solution code:
S=str(input())
digits=len(S)-1
out=0
for i in range(2**digits):
    cs=0
    b=format(i,'0'+str(digits)+'b')
    for j in range(digits):
        if b[j]=='1':
            out+=int(S[cs:j+1])
            cs=j+1
    out+=int(S[cs:])
print(out)

Submission status: Accepted

Solution code:
s = input()
n = len(s)-1
ans = 0
for bit in range(1<<n):
    op = bin(bit)[2:].zfill(n)
    formula = ''
    for i in range(n):
        formula += s[i]
        if op[i] == '1':
            formula += '+'
    else:
        formula += s[len(s)-1]
        ans += eval(formula)
print(ans)

Submission status: Accepted

Solution code:
#C - たくさんの数式

S = input()

total = 0

for i in range(2**(len(S)-1)):
  bin_i = format(i,'0'+str(len(S)-1)+'b')
  p = 0
  total += (10**p)*int(S[-1])
  for j in range(len(S)-1):
    if bin_i[-(j+1)] == '0':
      p += 1 
    else:
      p = 0
    total += (10**p)*int(S[-(j+2)])
    
print(total)

Submission status: Accepted

Solution code:
S = input()
L = len(S)

def dfs(i, f):
    if i == L-1: return sum(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:
def dfs(i, f):
  if i == n - 1:
    return sum(list(map(int, f.split('+'))))
  
  return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + '+' + s[i + 1])

s = input()
n = len(s)
print(dfs(0, s[0]))

Submission status: Accepted

Solution code:
def main():
    s = input()
    n = len(s) - 1
    a = 0
    for k in range(2**n):
        o = ["+ "[i == "0"] for i in bin(k)[2:]]
        o = [" "] * (n - len(o)) + o + [" "]
        a += eval("".join((a + b).strip() for a, b in zip(s, o)))
    print(a)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S=input()
sigma=0
li2=[1]*(len(S)+1)
li10=[1]*(len(S))
for k in range(1, len(S)):
    li2[k+1]=int(li2[k])*2
for k in range(len(S)-1):
    li10[k+1]=int(li10[k])*10
for k in range(1,len(S)+1):
    for j in range(1,k+1):
        sigma+=int(S[-k])*(li10[j-1])*(li2[len(S)-k+1])*(li2[k-j])
print(sigma)

Submission status: Accepted

Solution code:
S = input()
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:
s = input()
list = [[0 for i in range(len(s) - 1)] for j in range(2**(len(s) - 1))]
for i in range(2**(len(s) - 1)):
    for j in range(len(s) - 1):
        if ((i >> j) & 1):
            list[i][j] = 1
ans = 0
for x in list:
    temp = 0
    for id in range(len(s)):
        if id == len(s) - 1 or x[id] == 1:
            temp += int(s[id]) 
            ans += temp
            temp = 0
        else:
            temp += int(s[id])
            temp *= 10
print(ans)

Submission status: Accepted

Solution code:
S = input()
num_cnt = len(S)
op_cnt = len(S) - 1  # すき間の個数
ope_sum = 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 j in range(num_cnt):
        if j==num_cnt-1:
            formula = formula + S[j]
            ope_sum = ope_sum + eval(formula)
            break
        formula = formula + S[j] + op[j]

print(ope_sum)

Submission status: Accepted

Solution code:
from itertools import product

S = list(map(int, input()))
S.reverse()
ans = 0

# 区切り方のパターン全列挙
for part in product(range(2), repeat = len(S) - 1):
	cur = 0
	keta = 1
	for j in range(len(S)):
		cur += keta * S[j]
		if j == len(S) - 1: break
		if part[j] == 1:
			ans += cur
			keta = 1
			cur = 0
		else:
			keta *= 10
	if cur != 0:
		ans += cur
			
print(ans)

Submission status: Accepted

Solution code:
S=list(input())
N=2**(len(S)-1)
ans=0
for i in range(N):
    A=S[0]
    I=i
    for j in range(len(S)-1):
        if I//(2**(len(S)-2-j))==1:
            A+="+"
        else:
            A+=""
        I%=(2**(len(S)-2-j))
        A+=S[j+1]
    ans+=eval(A)
print(ans)

Submission status: Accepted

Solution code:
S = input()
combination = 2 ** (len(S) - 1)

ans = 0
for i in range(combination):
    # 2進数に直す
    bin_str = bin(i)[2:]

    # 上の桁分を埋める
    bin_str = '0' * (len(S) - len(bin_str) - 1) + bin_str

    formula = ''
    for i, s_char in enumerate(S):
        # 0の場合はなし、1の場合は'+'を入れて計算させる
        plus = ''
        if len(S) - 1 != i and bin_str[i] == '1':
            plus = '+'

        formula += s_char + plus

    # 文字列から計算する
    ans += eval(formula)

print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations
S = input().strip()
N = len(S)
answer = int(S)
for c in range(1,N):
    for t in combinations(range(1,N), c):
        i = 0
        for j in t:
            answer += int(S[i:j])
            i = j
        j = N
        answer += int(S[i:j])

print(answer)

Submission status: Accepted

Solution code:
a = list(input())
l = len(a)-1

ans = 0
for i in range(1<<l):
    s = a[0]
    for j in range(l):
        if (i>>j)&1: s += "+"
        s += a[j+1]
    ans += eval(s)
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict

s = input()
memo = defaultdict(int)

def calc_sum(num, t):
  if len(t) == 1:
    return num + int(t)
  return num + int(t) + sum(calc_sum(num + int(t[:i]), t[i:]) for i in range(1, len(t)))

print(calc_sum(0, s))

Submission status: Accepted

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

answer = 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]
    answer += eval(tmp)

print(answer)

Submission status: Accepted

Solution code:
def a(al, s1, s2):
	if len(s1)==0:
		st = s2+s1
		n_list = st.split("+")
		ans = 0
		for n in n_list:
			ans = ans + int(n)
		al.append(ans)
	elif len(s2)==0:
		a(al, s1[1:], s2+s1[0])
	else:
		a(al, s1[1:], s2+s1[0])
		a(al, s1[1:], s2+"+"+s1[0])

s = input()
a_list = []
a(a_list, s, "")

ans = 0
for a in a_list:
	ans += a

print(ans)

Submission status: Accepted

Solution code:
S=input()
ans=0
opsize=len(S)-1
for i in range(2**opsize):
    ins=[""]*opsize
    for j in range(opsize):
        if((i>>j)&1):
            ins[j]="+"
    tmp=""
    ins+=[""]
    for k,p in zip(S,ins):
        tmp+=(k+p)
    ans+=eval(tmp)
print(ans)

Submission status: Accepted

Solution code:
import itertools
s = list(input())
ans = 0
l = list(itertools.product(["","+"],repeat=len(s)-1))
for d in l:
  f = ""
  for s1,s2 in zip(s,list(d)+[""]):
    f += s1+s2
  ans += eval(f)
print(ans)

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

s = list(input())
# s = list(map(int, s))
from itertools import product
num = len(s)-1
bits = product([0, 1], repeat=num)
L = []
for x in bits:
    l = []
    r = [s[0]]
    for i in range(len(x)):
        if x[i] == 0:
            r.append(s[i+1])
        if x[i] == 1:
            l.append(r)
            r = []
            r.append(s[i+1])
    l.append(r)
    L.append(l)
# print(L)
ans = 0
for equ in L:
    # print(equ)
    for y in equ:
        # print(y)
        ans += int("".join(y))
print(ans)

Submission status: Accepted

Solution code:
S = list(input())
ls = len(S)
n = ls - 1
ans = 0
from copy import deepcopy
for i in range(2 ** n):
    siki = deepcopy(S)
    add = 1
    for j in range(n):
        if ((i >> j) & 1):
            siki.insert(j+add, "+")
            add += 1
    # print("".join(siki))
    ans += eval("".join(siki))
print(ans)

Submission status: Accepted

Solution code:
s = str(input())
rs = s[::-1]

def str_to_num(pattern): 
  rp = pattern[::-1]
  r = []
  r.append(int(rs[0]))
  tmp = 0
  for i in range(0, len(rp)):
    if int(rp[i]):
      tmp += 1
    else:
      tmp = 0
    r.append(int(rs[i+1]) * 10**tmp)
  return r

def dfs45(i, p):
    if i == len(s) - 1:
        return str_to_num(p)
    else:        
        r_l =  dfs45(i + 1, p + "0")
        r_l += dfs45(i + 1, p + "1")
    return r_l
    
result = dfs45(0, "")
print(sum(result))

Submission status: Accepted

Solution code:
s=input()
L=len(s)
ans=0
import itertools as it
l=[ i for i in it.product(["", "+"], repeat=L-1)]
for ll in l:
    f=""
    for i,j in zip(s,list(ll)+[""]):
       f+=i+j
    ans+=eval(f)

print(ans)

Submission status: Accepted

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

ans=0
for i in range(2**(l-1)):
    ans_sub=0
    subst=s[0]
    for j in range(l-1):
        if (i>>j)&1:
            ans_sub+=int(subst)
            subst=s[j+1]
        else:
            subst+=s[j+1]
        if j==l-2:
            ans_sub+=int(subst)
    ans+=ans_sub
if l==1:
    print(int(s))
else:
    print(ans)

Submission status: Accepted

Solution code:
from itertools import product
S = input()
L = len(S) - 1
join = lambda x: "".join(x)
print(sum(eval(join(map(join, zip(S, list(p)+[""])))) for p in product(("", "+"), repeat=L)))

Submission status: Accepted

Solution code:
def f(n,x):
    C = []
    y = x
    for i in range(n):
        C.append(y%2)
        y//=2
    return C
S = input()
N = len(S)-1
ans = 0
for i in range(2**N):
    C = f(N,i)
    s = S[0]
    for i in range(N):
        s+=("+" if C[i] else "")+S[i+1]
    ans+=eval(s)
print(ans)

Submission status: Accepted

Solution code:
import itertools
S = [i for i in input()]

U = itertools.product(sorted(range(2)), repeat=len(S)-1)
ans = 0

for i in U:
  
  #print("i", i)  #0なら無視1なら数字を区切る
  #print("len(i)", len(i))
  # (0, 0) ... (1, 1) 1つのタプルにlen(S)-1個の要素が入ってる

  n1 = S
  #n2 = []
  for j in range(len(i))[::-1]:
    #print("----")
    #print("j", j)
    #print("i[j]", i[j])
    if i[j] == 1:
      ans += int("".join(n1[j+1:]))
      #n2.append(n1[j+1:])
      n1 = n1[:j+1]
      #print("n1", n1)
  #print("n1", n1, "type:", type("".join(n1)))
  ans += int("".join(n1))
  #n2.append(n1)
#print("======")
#print("n2", n2)
print(ans)

Submission status: Accepted

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

n = len(s)
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
S = input()

l = len(S) - 1
ans = 0
for i in range(1<<l):
    s = S
    n = []
    k = 0
    for j in range(l):
        k += 1
        if i&(1<<j):
            n.append(int(s[:k]))
            s = s[k:]
            k = 0
    else:
        n.append(int(s))
    ans += sum(n)

print(ans)

Submission status: Accepted

Solution code:
s = input()
y = int(s)
for i in range(1, 2**(len(s)-1)):
    t = []
    for j in range(len(s)-1):
        if ((i >> j) & 1):
            t.append(j+1)
    y += int(s[:t[0]])
    y += int(s[t[-1]:])
    if len(t) >= 2:
        for j in range(len(t)-1):
            y += int(s[t[j]:t[j+1]])
print(y)

Submission status: Accepted

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

total = int("".join(S))
siki = set()
for i in range(2 ** (n - 1)):
    S_ = copy(S)
    plus_count = 0
    for j in range(n - 1):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            S_.insert(plus_count + j + 1, "+")  # フラグが立っていたら bag に果物を詰める
            plus_count += 1
            siki.add("".join(S_))  # 買い物累計額にも加算
for s in list(siki):
    total += eval(s)
print(total)

Submission status: Accepted

Solution code:

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

ans = []

for i in range(2**N):
  tmp = ""
  for j in range(N):
    tmp += S[j]
    if (i >> j) & 1:
      tmp += "+"
  else:
    tmp += S[-1]

  ans.append(eval(tmp))

print(sum(ans))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
s = input()
ans = 0
for i in range(2**(len(s)-1)):
	k = i
	current_index = 0
	cnt_div = 0 # 2で割った回数 つまり+が計算されるのは何桁か
	while True:
		cnt_div += 1
		if k % 2: 
			ans += int(s[current_index:current_index+cnt_div])
			current_index = current_index+cnt_div
			cnt_div = 0 #もっと効率化できる？
		k = k //2
		if k == 0:
			ans += int(s[current_index:]) 
			break
print(ans)

Submission status: Accepted

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

if n == 0:
    print(s)
else:
    ans = 0
    for i in range(2 ** n):
        tmp = ''
        for j in range(n):
            tmp += s[j]
            if i & 1 << j:
                tmp += '+'
        tmp += s[j+1]
        if '+' in tmp:
            ans += eval(tmp)
        else:
            ans += int(tmp)

    print(ans)

Submission status: Accepted

Solution code:
a=list(input())
x=len(a)
b=[""]*(x-1)

c=[]
for aa,bb in zip(a,b):
    c.append(aa)
    c.append(bb)
c.append(a[-1])

import copy
ans=0
for i in range(2**(x-1)):
    cc=copy.deepcopy(c)
    for j in range(x-1):
        if (i>>j&1):
            cc[(j+1)*2-1]="+"
    ccc="".join(cc)
    ans+=eval(ccc)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=input()

n=len(x)-1
ans=0
for i in range(2**n):	
	cal=[]
	for j in range(n):
		cal.append(x[j])
		if (i >> j) & 1:
			cal.append('+')
	cal.append(x[n])
	y=''.join(cal)
	ans += eval(y)
print(ans)