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=list(map(int,input()))
s=len(S)
if s==1:
    print(S[0])
else:

    s=s-1
    t=pow(2,s)
    l=len(list(format(t-1,'b')))
    x=0
    for i in range(t):
        k=list(format(i,'b'))
        L=[0]*l
        x+=S[-1]
        v=1
        for i in range(l):
            if i+1<=len(k):
                L[l-i-1]=k[-1-i]
            if int(L[l-i-1])==0:
                v=v*10
                x+=v*S[len(S)-2-i]
            else:
                v=1
                x+=S[len(S)-2-i]
    print(x)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for i in range(2**n):
    data = []
    for j in range(n):
        if((i >> j) & 1):
            data.append(1)
        else:
            data.append(0)
    # print(data)
    num = s[0]
    x = []
    for i in range(n-1):
        if data[i] == 1:
            x.append(int(num))
            num = s[i+1]
        else:
            num += s[i+1]
    if data[-1] == 0:
        num += s[-1]
        x.append(int(num))
    else:
        x.append(int(num))
        x.append(int(s[-1]))
    ans += sum(x)
    # print(x)
print(ans)

Submission status: Accepted

Solution code:


def susiki(n, s, dest):
    if n == len(s):
        tmp = 0
        pre = 0
        for d in dest:
            tmp += int(s[pre:d])
            pre = d
        tmp += int(s[pre:])
        return tmp
    return susiki(n+1, s, dest+[n]) + susiki(n+1, s, dest)

s = input()
l = len(s)

print(susiki(1, s, []))

Submission status: Accepted

Solution code:
S = input()
S_damy = S
sum_S = 0
plus = 2**(len(S)-1)
for i in range(plus):
    for j in range(len(S)-1):
        if i >> j & 0b1:
            sum_S += int(S_damy[len(S)-1-j:])
            if S_damy:
                S_damy = S_damy[:len(S)-1-j]

        if j == len(S)-2 and S_damy:
            sum_S += int(S_damy)
    S_damy = S
if len(S) == 1:
    print(S)
else:
    print(sum_S)

Submission status: Accepted

Solution code:
s=input()

l=len(s)

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

print(count)

Submission status: Accepted

Solution code:
N=input()

num=list(N)
sum=0;
for i in range(1 << len(num)-1):
    l=[]
    for j in range(len(num)):
        l+=num[j]
        if (j != len(num)-1):
            if (i & (1<<j)):
                l+=['+']
        
    sum+=eval("".join(l))
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

def add(n, s):
    if n == 0:
        tmp = 0
        for i in s.split('+'):
            tmp += int(i)
        return tmp
    else:
        st = s[:n] + '+' + s[n:]
        return add(n-1, st) + add(n-1, s)

print(add(N, S))

Submission status: Accepted

Solution code:
s = input()
sa = [i for i in s]
r = 0
for i in range(2**(len(s)-1)):  # 状態数
    si = sa[0]
    for j in range(len(s) - 1):
        t = 2 ** j  # 2^jなので常に2の倍数、
        if i & t:  # どこのビットが1か判定できる 2進数のビット判定を10進数のままやってるイメージ
            si += '+'  # 1なら+を挿入
        si += sa[j+1]
    r += eval(si)  # evalは文の実行なので文字列を都合よく数字に解釈してくれる

print(r)

Submission status: Accepted

Solution code:
from itertools import product

S = input()

s = 0
for bits in product((False, True), repeat=len(S) - 1):
    buf = S
    for i in range(len(bits)):
        if bits[i]:
            sep = len(S) - (i + 1)
            buf = buf[:sep] + ' ' + buf[sep:]
    s += sum(map(int, buf.split()))

print(s)

Submission status: Accepted

Solution code:
from itertools import chain, combinations


def powerset(iterable):
    s = list(iterable)
    return chain.from_iterable(combinations(s, r) for r in range(len(s) + 1))


def s_to_num(s):
    numlst = list(map(int, s))
    res = 0
    for i in numlst:
        res *= 10
        res += i
    return res


s = input()
length = len(s)
res = 0
for i in powerset(range(1, length)):
    if not i:
        res += int(s)
    else:
        jlst = [0] + list(i) + [length]
        for j in range(len(jlst) - 1):
            res += s_to_num(s[jlst[j]:jlst[j + 1]])
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = input()
res = int(s)
length = len(s)
for i in range(1, 2**(length-1)):
    res_i = 0
    b = bin(i)[2:].zfill(length-1)
    s_ = s[0]
    idx = 0
    while idx < length - 1:
        for bi in b:
            if int(bi):
                res_i += int(s_)
                idx += 1
                s_ = s[idx]
            else:
                idx += 1
                s_ += s[idx]
    res_i += int(s_)
    res += res_i
print(res)

Submission status: Accepted

Solution code:
S = list(input())
num_cnt = len(S) - 1
total = 0

for i in range(2 ** num_cnt):
    temp_sum = S[0]
    for j in range(num_cnt):
        if ((i >> j) & 1):
            temp_sum = temp_sum + '+' + str(S[j+1])
        else:
            temp_sum = temp_sum  + S[j+1]
    total += eval(temp_sum)

print(total)

Submission status: Accepted

Solution code:
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    S_arr = _in[0]  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    N = len(S_arr)-1
    cnt = 0
    for bit in range(1<<N):
        # bit = 0: '', 1: '+'
        tmp = []
        pointa = 0
        for i in range(N):
            if bit&(1<<i):
                tmp.append(int(S_arr[pointa:i+1]))
                pointa = i+1
        else:
            tmp.append(int(S_arr[pointa:]))
        cnt += sum(tmp)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

import sys


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


def all_search(s, i, i_sum: int, temp):
    n = int(s[i])

    if i == len(s)-1:
        # ベースケース
        i_sum += temp + n
        return i_sum
    else:
        ret = all_search(s, i+1, i_sum, (temp+n)*10) + all_search(s, i+1, i_sum+temp+n, 0)
        return ret




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

    print(all_search(s, 0, 0, 0))



if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
N = str(input())
t = len(N)
bi_li =[]
li_formula = []
total = 0

for i in range(2**(t-1)):
    temp =[0 for _ in range(t-1)]
    for p in range(t-1):
        if ((i >> p) & 1):
            temp[p] =1
    bi_li.append(temp)

for k in bi_li:
    formula =""
    for j in range(t+len(k)):
        if j%2==0:
            formula+=N[int(j/2)]
        else:
            if k[j//2] == 1:
                formula+="+"
    li_formula.append(formula)

for l in li_formula:
    total += eval(l)
print(total)

Submission status: Accepted

Solution code:
s = input()

ans = 0
n = len(s) - 1
for i in range(2 ** n):
    op = [''] * n
    for j in range(n):
        if ((i >> j) & 1):
            op[n - j - 1] = '+'
    f = ''

    for p_n, p_o in zip(s,op+['']):
        f += p_n + p_o
    ans += eval(f)

print(ans)

Submission status: Accepted

Solution code:
s = input()
ans = 0
for bit in range(2 ** (len(s) - 1)):
    i = 0
    tmp = []
    for j in range(1, len(s) + 1):
        if j != len(s) and bit >> (j - 1) & 1 == 0: continue
        tmp.append(int(s[i:j]))
        i = j
    ans += sum(tmp)
print(ans)

Submission status: Accepted

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

a = 0
for x in  range(2**n):
  ans = s[0]
  for y in range(n):
    if (x>>y)&1:
      ans = ans + "+" + s[y+1]
    else:
      ans = ans + s[y+1]
  a += eval(ans)
print(a)

Submission status: Accepted

Solution code:
S = input()

length = len(S)
ans = 0

for x in range(2 ** (length - 1)):
    res = ""
    b = str(format(x, '010b'))
    for i in range(length):
        res += str(S[i])
        if b[-(i + 1)] == "1":
            res += "+"
    res = res.split("+")
    ans += sum(list(map(int,res)))
        
print(ans)

Submission status: Accepted

Solution code:
S = input()

length = len(S)
ans = 0

for x in range(2 ** (length - 1)):
    res = ""
    b = str(format(x, '010b'))
    for i in range(length):
        res += str(S[i])
        if b[-(i + 1)] == "1":
            res += "+"
        else:
            pass
    ans += eval(res)
        
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
# 125
s = len(S)-1
ans=0
for bit in range(1 << s):
    a = S[0]
    for i in range(s):
        if bit & (1<<i):
            a += "+"
        a += S[i+1]
    ans += sum(map(int,a.split("+")))
print(ans)

Submission status: Accepted

Solution code:
S = input()
n = len(S) - 1
sumLine = 0
for i in range(2 ** n):
  op = [0] * (n)
  e = ''
  for j in range(n):
    if (i >> j) & 1  :
      e += S[j] + '+'
    else:
      e += S[j]

  sumLine += eval(e+S[-1])
print(sumLine)

Submission status: Accepted

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

s=input()
n=len(s)

num=0
for i in range(2**(n-1)):
    flag=[]

    for j in range(n-1):
        if (i>>j)&1:
            flag.append(j)

    if len(flag)==0:
        num+=int(s)
        #print(int(s))
    else:
        for i in range(len(flag)):
            flag[i]+=1
        flag.insert(0,0)
        flag_num=len(flag)
        for k in range(flag_num-1):
            num+=int(s[flag[k]:flag[k+1]])
            #print(int(s[flag[k]:flag[k+1]]))
        num+=int(s[flag[-1]:])
        #print(int(s[flag[-1]:]))

print(num)

Submission status: Accepted

Solution code:
S = input()
lenS = len(S)
ans = 0
def f(SUM,TMP,N):
    n = int(S[N])
    if N == lenS-1:
        SUM += TMP + n
        return SUM
    else:
        ret = f(SUM,(TMP+n)*10,N+1) + f(SUM+TMP+n,0,N+1)
        return ret

print(f(0,0,0))

Submission status: Accepted

Solution code:
import copy
S = [c for c in input()]

X = [[]]
for i in range(len(S) - 1):
    X0, X1 = [], []
    for x in X:
        x0 = copy.deepcopy(x)
        x0.append(0)
        X0.append(x0)
        x1 = copy.deepcopy(x)
        x1.append(1)
        X1.append(x1)
    X = X0 + X1
Y = []
for x in X:
    bf = ''
    for i in range(len(S)):
        bf = bf + str(S[i])
        if i == len(S) - 1 or x[i] == 1:
            Y.append(int(bf))
            bf = ''
    if bf != '':
        Y.append(int(bf))
print(sum(Y))

Submission status: Accepted

Solution code:
import sys
from math import sqrt
from collections import Counter, defaultdict, deque

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


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

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def func(i,x,s,new):
    if i==x:
        count=0
        #print(i,x,s,new+[s[-1]])
        new+=s[-1]
        li=new.split("+")
        for j in li:
            count+=int(j)

        return count

    #print(i,x,s,new)
    return func(i,x+1,s,new+s[x-1]+"+") + func(i,x+1,s,new+s[x-1])

new=""
S=input()
print(func(len(S),1,S,new))

Submission status: Accepted

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MAX = 10**18
MIN = -10**18
MOD = 998244353


def judge(li):
    c = s[0]
    for i in range(len(li)):
        if li[i] == False:
            c += s[i+1]
        else:
            c += "+" + s[i+1]
    return c
s = input()
n = len(s)-1
ans = 0
for i in range(2**n):
    li = [False]*(n)
    for j in range(n):
        if (i>>j)&1:
            li[n-j-1] = True
    a = judge(li)
    e = a[0]
    sumli = []
    for j in range(1,len(a)):
        if a[j] == "+":
            sumli.append(int(e))
            e = ""
        else:
            e += a[j]
    sumli.append(int(e))
    ans += sum(sumli)
print(ans)

Submission status: Accepted

Solution code:
S = list(input())
Slist = list()

def split_list(S):
  Slist.append(int(''.join(S)))
  N = len(S)
  if N == 1:
    return
  for n in range(1, N):
    S1 = ''.join(S[:n])
    r = 2**(N-n-1)
    
    for i in range(r):
    	Slist.append(int(S1))
    
    split_list(S[n:])
    
  

split_list(S)
ans = sum(Slist)
print(ans)

Submission status: Accepted

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

answer = 0
for i in range(2 ** (n - 1)):
    total_sum = 0
    tmp = S[0]
    for j in range(n - 1):
        if (1 << j) & i:
            total_sum += int(tmp)
            tmp = S[j + 1]
        else:
            tmp += S[j + 1]
    total_sum += int(tmp)
    answer += total_sum

print(answer)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

ans = 0
for i in range(2 ** N):
    add_pos = []
    for j in range(N):
        if (i >> j) & 1:
            add_pos.append(j + 1)

    to_be_sumed = []

    if not add_pos:
        to_be_sumed.append(int(S))

    for i in range(len(add_pos)):
        if i == 0:
            to_be_sumed.append(int(S[:add_pos[i]]))
            if i == len(add_pos) - 1:
                to_be_sumed.append(int(S[add_pos[i]:]))
        else:
            to_be_sumed.append(int(S[add_pos[i - 1]:add_pos[i]]))
            if i == len(add_pos) - 1:
                to_be_sumed.append(int(S[add_pos[i]:]))
    # print(to_be_sumed)
    ans += sum(to_be_sumed)
print(ans)

Submission status: Accepted

Solution code:
S = input()

def rec(n, s):
    if n == 1:
        ans = 0
        for i in s.split("+"):
            ans += int(i)
        return ans
    
    # 文字列の後ろからn番目に"+"を入れるか否か
    return rec(n-1, s) + rec(n-1, s[:-n+1]+"+"+s[-n+1:])

print(rec(len(S), S))

Submission status: Accepted

Solution code:
s=input()
l=len(s)-1
res = 0

for i in range(2**l):
    s_new = s[0]
    for j, c in enumerate(s[1:]):
        flag = True if (i>>j)%2==1 else False
        s_new += c if flag else "+"+c
    res += eval(s_new)
print(res)

Submission status: Accepted

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

ans=0
for i in range(2**(len_s-1)):
    tmp=0
    start=0
    end=0
    for j in range(len_s-1):
        if ((i>>j)&1):
            tmp+=int(s[start:end+1])
            start=j+1
            end=j+1
        else:
            end+=1
    tmp+=int(s[start:end+1])
    ans+=tmp
print(ans)

Submission status: Accepted

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

all_sum=0
def dfs(l,N,S):
    X=[[] for n in range(N+1)]
    X[0]=[S[0]]
    cnt=0
    temp=0
    if len(l)==N:
        global all_sum
        for n in range(N):
            if l[n]==0:
                X[cnt].append(S[n+1])
            else:
                cnt+=1
                X[cnt].append(S[n+1])
        for i in range(N+1):
            if X[i]!=[]:
                temp+=int("".join(X[i]))
        all_sum+=temp         
        return
    else:
        for n in range(2):
            l.append(n)
            dfs(l,N,S)
            l.pop()
dfs([],N,S)
print(all_sum)

Submission status: Accepted

Solution code:
S = input()
n = len(S)
N = []
M = []
for i in range(n):
    N.append(S[i])
Nsum = 0
a = 0
for Ni in N:
    n = len(S) - a
    m = 2 ** a
    Nsum += m * int(Ni) * 10 ** (n - 1)
    n -= 1
    while n > 0:
        Nsum += m * int(Ni) * 10 ** (n - 1)
        m *= 2
        n -= 1
    a += 1
print(Nsum)

Submission status: Accepted

Solution code:
import itertools

s = input()
sum_formula = 0
for pluses in itertools.product(['+', ''], repeat=len(s)-1):
    formula = s[0]
    for i in range(len(s) - 1):
        formula += pluses[i] + s[i + 1]
    sum_formula += eval(formula)
print(sum_formula)

Submission status: Accepted

Solution code:
import itertools
#まず＋を入れる場合と入れない場合、すべてのパターンをALLにリストとして入れる
S = input()
ALL = list(itertools.product(["+",""],repeat=len(S)-1))
#たとえばSが125の三文字なら、ALLには以下の４種類が入る。
#[('+', '+'), ('+', ''), ('', '+'), ('', '')]
count = 0
for kigou in ALL:
    #Sの文字と文字の間に、ALLのパターン通りに＋を入れるか入れないかして、
    #1+2+5、1+25、12+5のような式を文字列として生成し、tmpとする
    tmp = ""
    for i in range(len(S)-1):
        tmp += S[i]
        tmp += kigou[i]
    tmp += S[len(S)-1]
    #tmpとして生成した式を計算する。Pythonではevalを使えば済む。
    count += eval(tmp)
#print(ALL)
print(count)

Submission status: Accepted

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

for i in range(2**space):
    t=[0]*space
    for j in range(space):
        if ((i>>j)&1)==1:
            t[-j-1]="+"

    fomula=s[0]
    for k in range(1, l):
        if t[k-1]==0:
            fomula=fomula+s[k]
        else:
            fomula=fomula+t[k-1]+s[k]
    
    add=eval(fomula)
    ans+=add

print(ans)

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()
n = len(s)

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

Submission status: Accepted

Solution code:
S = str(input())
def F(S):
    yield int(S)
    for i in range(len(S)-1):
        left = S[:i+1]
        right = S[i+1:]
        x = int(left)
        for y in F(right):
            yield x + y
answer = sum(F(S))
print(answer)

Submission status: Accepted

Solution code:
S = input()
n = len(S)
ans = 0
for i in range(2 ** (n-1)):
    F = [False] * (n-1)
    for j in range(n-1):
        if (i >> j) & 1:
            F[j] = True
    tmp = 0
    ct = 0
    prev = 0
    while tmp < n - 1:
        if F[tmp] == True:
            ct += int(S[prev : (tmp + 1)])
            prev = tmp + 1    
        tmp += 1
    ct += int(S[prev :])
    ans += ct
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
s = list(input())
n = len(s) - 1
a = 0
for x in list(itertools.product(["+", ""], repeat=n)):
  x = list(x)
  x.append("")
  y = [d+e for d, e in zip(s, x)]
  a += eval("".join(y))
print(a)

Submission status: Accepted

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

num = [int(i) for i in input()]
n = len(num)

total = 0
for s in range(2**(n-1)):
    dig = [0] * n
    dig[0] = num[0]
    for i in range(n-1):
        if (s >> i & 1):
            dig[i+1] = num[i+1]
        else:
            dig[i+1] = dig[i]*10 + num[i+1]
            dig[i] = 0
    for i in range(n):
        total += dig[i]

print(total)

Submission status: Accepted

Solution code:
s = input()
ans = 0
for i in range(2**(len(s)-1)):
    l = [""]*(len(s)-1)
    x = 0
    sx = ""
    for j in range(len(s)-1):
        if ((i>>j)&1):
            l[x]="+"
        x+=1
    for si,p in zip(s,l):
        sx+=si
        sx+=p
    ans+=eval(sx+s[-1])
print(ans)

Submission status: Accepted

Solution code:
from itertools import product
s = list(input())
n = len(s)-1

ans = 0
for x in list(product(["", "+"], repeat=n)):
    x = list(x)
    x.append("")
    
    strs = [i+j for i, j in zip(s, x)]
    ans += eval("".join(strs))
print(ans)

Submission status: Accepted

Solution code:
'''


'''
# from collections import deque # キュー、スタックに利用
# import math # 数学的計算に利用
# import numpy as np # 行列計算などに利用

# sys.stdin.readline() # 標準入力の高速化に利用
import sys
input = sys.stdin.readline

def main():
    '''メイン処理'''
    all_sum = 0
    # 最後の改行を除いて受け取り
    S = input().strip()
    # +を入れる位置は、len(S)-1の数だけある。まずは空文字を入れておく
    n = (len(S)-1)    
    # +を入れるパターンは、2**n通り
    for i in range(2**n):
        ope_list = [""] * n
        # n桁の2進数文字列を生成
        bin_str = bin(i)[2:].zfill(n)
        # 2進数で1の立っている桁をフラグとみなし、opを1へ書き換え
        for j in range(n):
            if bin_str[j] == '1':
                ope_list[j] = "+"
        
        calc_str = S[0]
        for s, ope in zip(S[1:], ope_list):
            calc_str += ope+s
        all_sum += eval(calc_str)
    
    print(all_sum)


if __name__ == "__main__":
    # ファイル実行時に、main()関数を実行
    main()

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)
ans=0

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

Submission status: Accepted

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

ans = 0
for bit in range(2**(n-1)):
    tmp_total = 0
    tmp = s[0] #文字列
    for i in range(n-1):
        if (1<<i) & bit: #プラスがある時
            tmp_total += int(tmp)
            tmp = s[i+1]
        else:
            tmp += s[i+1] #tmpは文字列
    tmp_total += int(tmp)
    ans += tmp_total
print(ans)

Submission status: Accepted

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

# 場合の数 2^(l-1)

# bit全探索
# https://drken1215.hatenablog.com/entry/2019/12/14/171657
# https://qiita.com/gogotealove/items/11f9e83218926211083a

ans = 0
for bit in range(1<<(length-1)):  # for bit in range(2 ** (length-1)):
  # print(bin(bit))
  p = []
  f = s[0]
  sub_ans = 0
  for i in range(length-1):
    if bit & (1 << i):   # if ((bit >> i) & 1):
      p.append(i)
      f += "+"
    f += s[i + 1]
  sub_ans = sum(map(int, f.split("+")))
  ans += sub_ans
  # print('sub',p,sub_ans)
print(ans)

Submission status: Accepted

Solution code:
def main():
    S = input()
    n = len(S)
    bit = 0
    total = 0
    for bit in range(1<<n-1):
        tmp_total = 0
        tmp = S[0]
        for i in range(n-1):
            # print(bin(bit))
            # print(i, (1<<i) & bit)
            if (1<<i) & bit:
                tmp_total += int(tmp)
                tmp = S[i+1]
            else:
                tmp += S[i+1]
        tmp_total += int(tmp)
        total += tmp_total
    print(total)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()

sum = 0

if len(s) > 1:

    l = ["+"] * (len(s) - 1)

    n = 2 ** (len(s) - 1)

    for i in range(n):
        l = ["+"] * (len(s) - 1)
        for j in range(len(l)):
            ls = list(s)
            if (i >> j) & 1:
                l[j] = ""
            for x in range(len(l)):
                
                ls.insert(2*x+1,l[x])
    
        

        maped_list = map(str, ls) 
        mojiretu = ''.join(maped_list)

        sum = sum + eval(mojiretu)

    print(sum)
else:
    print(s)

Submission status: Accepted

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

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

Submission status: Accepted

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

def dfs(i,s = S[0]):
    if i == n-1:
        global ans
        ans += eval(s)
        return
    dfs(i+1,s+"+"+S[i+1])
    dfs(i+1,s+S[i+1])

dfs(0)
print(ans)

Submission status: Accepted

Solution code:
def get_int(s, si, ei=None):
    #print(f'get_int: s={s}, si={si}, ei={ei}')
    if ei is None:
        value = int(s[si:])
    else:
        value =  int(s[si:ei])
    #print(f'value={value}')
    return value


BIT = 1

str_s = input()
s = int(str_s)
slen = len(str_s)

result = 0
for i in range(2 ** (slen - 1) ):
    #print(f'======= i={bin(i)} ========')
    s_index = 0
    for k in range(slen - 1):
        bit = (i >> k) & BIT        
        if bit == 0:
            continue
        e_index = k + 1
        value = get_int(str_s, s_index, e_index)
        result += value
        s_index = e_index
    value = get_int(str_s, s_index)
    result += value

print(result)

Submission status: Accepted

Solution code:
S = input()
N = len(S)
ans = 0
def dfs(i, s=S[0]):
    if i == N-1:
        global ans
        ans += eval(s)
        return
    dfs(i+1, s+'+'+S[i+1])
    dfs(i+1, s+S[i+1])
dfs(0)
print(ans)

Submission status: Accepted

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

item = [i for i in range(n)]

res = 0
for i in range(2**n):
    bag = []
    for j in range(n):
        if (i>>j) & 1:
            bag.append(item[j])

    sp = ''
    for i, keta in enumerate(s):
        sp += keta
        if i in bag: sp += '+'
    
    sl = sp.split('+')
    sl = list(map(int, sl) )
    res += sum(sl)
print(res)

Submission status: Accepted

Solution code:
s = input()
n = len(s) - 1
plus_all = []
def cal(a):
  count = 0
  left = 0
  for i in range(len(a)):
    if a[i] == True:
          count+= int(s[left:i+1])
          left = i + 1
          
  count += int(s[left:])
  return count
result = []
def dfs(A):
  if len(A) == n:
    result.append(cal(A))
    return A
  else:
    for i in range(2):
      if i == 0:
        A.append(True)
      else:
        A.append(False)
      dfs(A)
      A.pop(-1)
dfs([])
print(sum(result))

Submission status: Accepted

Solution code:
S = input()

def div_plus(i, s):
    if i == len(S):
        s_list = [int(i) for i in s.split("+")]
        return sum(s_list)
    
    pos = i - len(S)
    # プラスを挿入しない場合
    d1 = div_plus(i+1, s)
    
    # プラスを挿入する場合
    d2 = div_plus(i+1, s[:pos]+"+"+s[pos:])
    return d1 + d2

print(div_plus(1, S))

Submission status: Accepted

Solution code:
S = input()

def div_plus(i, s):
    if i == len(S):
        s_list = [int(i) for i in s.split("+")]
        return sum(s_list)
    
    pos = i - len(S)
    # プラスを挿入しない場合
    d1 = div_plus(i+1, s)
    
    # プラスを挿入する場合
    d2 = div_plus(i+1, s[:pos]+"+"+s[pos:])
    return d1 + d2

print(div_plus(1, S))

Submission status: Accepted

Solution code:
import math
import copy
from queue import Queue
import heapq

MOD = 1000000007

#n = int(input())
#b = int(input())
#n, m = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for j in range(n)]
#table = [list(input()) for n in range(h)]
#s = [int(i) for i in input().split()]
#s = [int(i) for i in range(n)]
#s = [int(input()) for i in range(n)]
s = input()
#list = list(s)
# dp = [[0 for _ in range(2)] for _ in range(13)]

#a = [[0 for _ in range(n+1)] for _ in range(n+1)]
#b = [[0 for _ in range(n+1)] for _ in range(n+1)]

num = len(s) - 1
kotae = 0

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

    formula = ""
    for p_n, p_o in zip(s, op + [""]):
        formula += (p_n + p_o)

    kotae += eval(formula)

print(kotae)

Submission status: Accepted

Solution code:
n=[int(x) for x in input()]
k=len(n)-1#間に入れるから-1
ans=0
for i in range(2**k):#+ or - の2択
    op=[""]*k
    for j in range(k):
        if (i>>j)&1:
            op[k-j-1]="+"
    formula=""
    for p_y,p_n in zip(n,op+[""]):
        formula+=(str(p_y)+p_n)
    ans+=eval(formula)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
n = len(S)
ans = 0
for i in range(2 ** (n - 1)):
    p = [''] * (n - 1)
    for j in range(n - 1):
        if i >> j & 1:
            p[j] = '+'
    s = [None] * (2 * n - 1)
    s[::2] = list(S)
    s[1::2] = p
    s = ''.join(s)
    ans += eval(s)
print(ans)

Submission status: Accepted

Solution code:
s = input()
n = len(s)
def dfs(i: int, t: str):
  if i == n-1: #i = n - 1に到達したら終了
    # + で区切った数字をint型に変換して足し算
    return sum(list(map(int, t.split('+'))))
  # 文字列で次の数字をそのまま連結するパターンと、+で区切るパターン
  return dfs(i+1, t+s[i+1]) + dfs(i+1, t + '+' + s[i+1])
# 初期値でsの一文字目を入れておく
print(dfs(0, s[0]))

Submission status: Accepted

Solution code:
S = list(input())
l = len(S)
ans = 0
for i in range(2**(l-1)):
    start = 0
    c = 0
    for j in range(l-1):
        if (i>>j)&1:
            end = j+1
            ans += int("".join(S[start:end]))
            start = j+1
    ans += int("".join(S[start:]))
print(ans)