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()

def cal_sum(s, is_plus):
    s_idx = 0
    result = 0
    for p_idx, p in enumerate(is_plus):
        if p == '1':
            result += int(s[s_idx:p_idx+1])
            s_idx = p_idx + 1
    result += int(s[s_idx:])
    return result

res = 0
for i in range(2**(len(s)-1)):
    is_plus ='{i:0={width}b}'.format(i=i, width=len(s)-1) 
    res += cal_sum(s, is_plus)
print(res)

Submission status: Accepted

Solution code:
S=input()
w=len(S)-1
l=[]
L=[]
#S一桁の時の例外処理
if w==0:
    print(int(S))
else:
    for i in range(2**w):
        #format（i,'0?b'）で好きな長さの2進数表示にできる
        l.append(format(i, '0{}b'.format(w)))
    #＋が入るなら区切り、入らないなら⋆10して足す
    for e in l:
        q=[]
        x=int(S[0])
        for i in range(len(e)):
            if e[i]=='0':
                x=x*10+int(S[i+1])
            else:
                q.append(x)
                x=int(S[i+1])
        q.append(x)
        L.append(sum(q))
    print(sum(L))

Submission status: Accepted

Solution code:
s=int(input())
S=str(s)
w=len(str(s))-1
l=[]
L=[]
if w==0:
    print(s)
else:
    for i in range(2**w):
        l.append(format(i, '0{}b'.format(w)))
    for e in l:
        q=[]
        x=int(S[0])
        for i in range(len(e)):
            if e[i]=='0':
                x=x*10+int(S[i+1])
            else:
                q.append(x)
                x=int(S[i+1])
        q.append(x)
        L.append(sum(q))
    print(sum(L))

Submission status: Accepted

Solution code:
import copy
S=input()
lst=[]
def Sum(l,S):
    if S=="A":
        return sum(l)
    a=l.pop()
    x=copy.copy(l)
    x.append(a*10+int(S[0]))
    y=copy.copy(l)
    y.extend([a,int(S[0])])
    return Sum(x,S[1:])+Sum(y,S[1:])
S+="A"
lst.append(int(S[0]))
print(Sum(lst,S[1:]))

Submission status: Accepted

Solution code:
s = list(input())
ans = 0
for i in range(1<<len(s)-1):
    nums = []
    cnt = 0
    for j in range(len(s)):
        if (i>>j) & 1 == 1:
            nums.append(s[cnt:j+1])#j番目の要素までのスライス
            cnt = j+1
    nums.append(s[cnt:len(s)+1])#上のループではLen(s)-1 番目の要素まで、Len(s)番目はここで
    for k in range(len(nums)):
        ans += int("".join(nums[k]))
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
def func(S):
	l = []
	# マスクパターン数(0～桁数-1(4桁なら111=7))分、周回する
	for mask in range(2 ** (len(S) - 1)):
		# マスクパターンが0になるまで周回する
		end = len(S)
		begin = end - 1
		mask_t = mask
		while(0 < mask_t):
			# マスクが0でないなら、1にヒットするまで下の桁から数える
			while(0 == mask_t & 0x01):
				mask_t >>= 1
				begin -= 1
			# 下の桁から数えて、前回～今回の桁分、加算する数のリストに加える
			l.append(int(S[begin:end]))
			# マスクを1ビット右シフトする、カウンタを保持する
			mask_t >>= 1
			end = begin
			begin = end - 1
		# 残った数を、加算する数のリストに加える
		l.append(int(S[:end]))
	return str(sum(l))

def main():
	print(func(input()))
	#print("OK" if (func("125") == "176") else "NG")
	#print("OK" if (func("9999999999") == "12656242944") else "NG")
	return

if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
s = input()
l = len(s)
# def cal():
total = 0
for i in range(2 ** (l - 1)):
    str_bin = '{0:0=9b}'.format(i)
    str_bin = str_bin[10 - l:]
    list_cut = [0] + [k + 1 for k, cur_num in enumerate(str_bin) if cur_num == "1"] + [l]
    cur_total = []
    for j in range(len(list_cut) - 1):
        cur_total.append(int(s[list_cut[j]:list_cut[j + 1]]))
    total += sum(cur_total)

print(total)

Submission status: Accepted

Solution code:
S = str(input())
p = ["+",""]
total = 0

for i in range(2**(len(S)-1)):
    t = S[0]
    for j in range(len(S)-1):
        t = t + p[i>>j&1] + S[j+1]
    total += eval(t)
print(total)

Submission status: Accepted

Solution code:
S = input()

n = len(S) - 1
ans = ''

for i in range(1 << n):
    tmp = S[0]
    for j in range(n):
        if (i >> j) % 2:
            # もしビットが1だったら＋ことにする
            tmp += '+'+S[j+1]
        else:
            tmp += S[j+1]
    ans += '+'+tmp


print(eval(ans[1:]))

Submission status: Accepted

Solution code:
s = input()
n = len(s)-1
ans=0
for i in range(1 << n):
  k=0
  # print(bin(i))
  for j in range(n):
    # print("","j=",j,bin(i>>j),True if (i>>j)&1 else False,s[k:j+1])
    if i>>j&1 == 0:
      continue
    else:
      ans += int(s[k:j+1])
      k=j+1
  ans += int(s[k:])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

def dfs(string,cur):
  global ans
  if cur==n:
    ans+=eval(string)
    return
  ret0=dfs(string+"+"+s[cur],cur+1)
  ret1=dfs(string+s[cur],cur+1)
dfs(s[0],1)
print(ans)

Submission status: Accepted

Solution code:
ans = 0
s = input()


def rec(now, depth):
    if depth == len(s):
        global ans
        ans += eval(now)
        return
    rec(now + '+'+s[depth], depth + 1)
    rec(now + s[depth], depth + 1)


rec(s[0], 1)
print(ans)

Submission status: Accepted

Solution code:
import numpy as np

S = input()
b = np.zeros(len(S)-1)
num = 0
for i in range(2**(len(S)-1) -1):
    str = S[0]
    for k in range(len(S)-1):
        if b[k] == 0:
            str = str + S[k+1]
        else:
            str = str + "+" + S[k+1]
            
    num += eval(str)
    
    b[0] += 1
    for k in range(len(S)-1):
        if b[k] == 2:
            b[k+1] += 1
            b[k] = 0
            
str = S[0]
for k in range(len(S)-1):
    if b[k] == 0:
        str = str + S[k+1]
    else:
        str = str + "+" + S[k+1]
            
    
num += eval(str)

print(num)

Submission status: Accepted

Solution code:
S = input()
length = len(S) - 1
ans = ''
for bit in range(2 ** length):
    x = [i for i in range(length) if bit & (2 ** i)]
    tmp = S
    # print(x)
    for i in range(len(x)):
        tmp = tmp[:x[i] + i + 1] + '+' + tmp[x[i] + i + 1:]
    # print(tmp)
    ans += tmp + '+'
print(sum(map(int, ans[:-1].split('+'))))

Submission status: Accepted

Solution code:
target = input()
length = len(target)
binary = length - 1
target_list = []
answers = 0
for i in range(length):
    if i:
        target_list.append("")
    target_list.append(target[i])
for bit in range(2 ** binary):
    temp = target_list.copy()
    for i in range(binary):
        if bit & (1 << i):
            temp[1 + 2 * i] = "+"
    # print(temp, bit)
    answers += eval("".join(temp))
print(answers)

Submission status: Accepted

Solution code:
def to_bit(num,digit):
    bit = [0] * digit
    for i in range(digit):
        bit[i] = num % 2
        num = int((num - (num % 2)) / 2)
    return bit

a = list(input())
a = [int(i) for i in a]

sum_ = 0
for i in range(2 ** (len(a) - 1)):
    bit = to_bit(i,len(a) - 1)

    now_f = 0
    now_n = 0
    #print(bit)
    for j in range(len(a)):
        if j == len(a) - 1 or bit[j] == 1:
            now_n = now_n * 10 + a[j]
            now_f += now_n
            now_n = 0
        else:
            now_n = now_n * 10 + a[j]
    #print(now_f)
    sum_ += now_f


print(sum_)

Submission status: Accepted

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

sum_num = 0
for i in range(1<<n):
    t = S[0]
    for j in range(n):
        if (i>>j)%2:
            t += "+"
        t += S[j+1]
    sum_num += eval(t)

print(sum_num)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys
inp = sys.stdin.readline

S = inp().replace('\n', '')

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

Submission status: Accepted

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

def comb(num):
    if num <= 0:
        return 1
    return 2 ** (num - 1)

ans = 0
for l, n in enumerate(ns):
    rmax = len(ns) - l
    for r in range(rmax):
        co = comb(l + 1) * comb(rmax - r - 1)
        ans += n * 10**r * co

print(ans)

Submission status: Accepted

Solution code:
S = input()

def search(string, flg, sum):
    if flg >= len(string):
        return sum + int(string)
    before = search(string[flg:], 1, sum + int(string[:flg]))
    after = search(string, flg + 1, sum)
    sum = before + after
    return sum

print(search(S, 1, 0))

Submission status: Accepted

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


S = input()

ans = 0
for i in range(2**(len(S) - 1)):
    tmp = S[0]
    for j in range(len(S) - 1):
        # print(i, j, i >> j)
        if (i >> j) % 2 == 1:
            ans += int(tmp)
            tmp = ""
        tmp += S[j + 1]
    ans += int(tmp)
print(ans)

Submission status: Accepted

Solution code:
#!/mnt/c/Users/moiki/bash/env/bin/python
# N,M = map(int, input().split())
S = input()

# for i in range(len(S)-1): #125 0
ans = 0
for i in range(1<<(len(S)-1)):
    bef = 0
    lst = []
    # if i == 0: continue
    for j in range(len(S)-1):

        if i & 1<<j:
            lst.append( int(S[bef:j+1]) ) 
            # print("S[bef:{bef}:j+1:{jp1}]:{S}".format(bef=bef, jp1=j+1, S=S[bef:j+1]))
            bef = j+1
    lst.append( int(S[bef:]) ) 
    # ans = max(ans, sum(lst))
    ans += sum(lst)
    # print(lst)
    # break
print(ans)

Submission status: Accepted

Solution code:
import itertools

S = input()

seq = (0, 1)
ptr = itertools.product(seq, repeat=len(S)-1)
res = 0 

for p in ptr:
    tmp = 0
    tmps = S[0]
    
    for i in range(len(S)-1):
        if p[i] == 0:
            tmps += S[i+1]
        else:
            tmp += int(tmps)
            tmps = S[i+1]
            
    if tmps != '':
        tmp += int(tmps)     
        
    res += tmp
     
print(res)

Submission status: Accepted

Solution code:
"""
＋を挟むか挟まないかは2**N通り。(Nはlen(s))
二進数で表してi番目のビットが0ならi番目の数字の右に＋を挟む。1なら挟まないという方針
"""
s=input()
l=list(s)
#lst=[]
lst_2=0
'''
bi=[bin(2**i) for i in range(0,len(s))]
print(bi)
'''
for i in range(1<<(len(s)-1)):#2**(len(s)-1)と同じ
    st=l[0]#l[0]の左に＋が来ることはない
    for j in range(len(s)-1):#sを二進数で表示した時に数字の間にプラスを挟むかどうかを決めるループ
        if (i>>j)&1:#iのj+1番目のビットが1だったら+を挟まない。
            st+=l[j+1]
        else:#iのj+1番目のビットが0だったら＋を挟む
            st+='+'+l[j+1]
    #lst.append(eval(st))
    lst_2+=eval(st)
    #print(lst)
    #print(lst_2)
#print(sum(lst))
print(lst_2)

Submission status: Accepted

Solution code:
s = input()

answer = 0
for canditate in range(1 << len(s)-1):
    combi = s[0]
    for n_digit in range(len(s) - 1):
        if (canditate >> n_digit) & 1:
            combi += '+'
        combi += s[n_digit+1]  # 足される数's[0]'を除いた数値部分を取り出す
    answer += eval(combi)

print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ARC061 C 沢山の数式
S=input()
def bubunwa(S):
    total=int(S)
    for i in range(1,len(S)):
        total=total+int(S[:i])*(2**(len(S[i:])-1))+bubunwa(S[i:]) 
#(2**(len(S[i:])-1))は分割数
    return total
print(bubunwa(S))
#最終的な答え

Submission status: Accepted

Solution code:
p=[]
s=input()
for i in range(2**(len(s)-1)):
    k=s[:]
    d=bin(i)[2:]
    d="0"*(len(s)-len(d)-1)+d
    c=s[0]
    for i in range(len(s)-1):
        if d[i]!="0":
            c+="+"+s[i+1]
        else:
            c+=s[i+1]
    else:
        p.append(eval(c))
print(sum(p))

Submission status: Accepted

Solution code:
S = input()

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
S = input()

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
S = input()

ans = 0

for i in range(1 << len(S) - 1):
    op = []
    for j in range(len(S) - 1):
        if i >> j & 1:
            op.append('+')
        else:
            op.append('')
    op.append('')
    exp = ''
    for e in zip(S, op):
        exp += ''.join(e)
    ans += eval(exp)

print(ans)

Submission status: Accepted

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

revS = list(reversed(S))
ans = 0

for i in range(loop):
    ans += int(revS[0])
    multi_ten = 10
    for j in range(power):
        digit = bin(i>>j)[-1]
        if digit == "0":
            ans += int(revS[j+1])*multi_ten
            multi_ten *= 10
        else:
            ans += int(revS[j+1])
            multi_ten = 10
print(ans)

Submission status: Accepted

Solution code:
s=input()

ans=0
for i in range(1<<(len(s)-1)):
    sum=0
    temp=int(s[0])
    for j in range(len(s)-1):
        if i>>j&1:
            temp=temp*10+int(s[j+1])
        else :
            sum+=temp
            temp=int(s[j+1])
    sum+=temp
    ans+=sum
print(ans)

Submission status: Accepted

Solution code:
#2-1-1 #ARC061C
s=input()
lenth=len(s)
kugiri=set()
def roop(before,now,kugiri):
    if now==lenth:
        kugiri|={before,}
        return kugiri
    kugiri = roop(before+(0,),now+1,kugiri)
    kugiri = roop(before+(1,),now+1,kugiri)
    return kugiri


def calc(ans,kugiri,s):
    test=s
    now=test[0]
    test=test[1:]
    for i in range(len(s)-1):
        k=kugiri[i]
        if k==0:
            now+=test[0]
        elif k==1:
            ans+=int(now)
            now=test[0]
        test=test[1:]
        if i==len(s)-2:ans+=int(now)
    return ans
            
ans=0
if len(s)!=1:
    kugiri = roop((0,),2,kugiri)
    kugiri = roop((1,),2,kugiri)
    for i in kugiri:
        ans=calc(ans,i,s)
    print(ans)
elif len(s)==1:print(int(s))

Submission status: Accepted

Solution code:
S = list(input())

def bit_search(s):
    # print('s:',s,'len:',len(s))
    if len(s)==1:
        # print('len=1,s:',s,len(s), int(s[0]))
        return int(s[0]),1 # 第二返り値は場合の数
    else:
        # print('s[0],type:',s[0],type(s[0]))
        sum1, cases1 = bit_search(s[1:])
        tmp1 = int(s[0])*cases1+sum1
        tmp = [s[0]+s[1]]+s[2:]
        # print('tmp:',tmp)
        tmp2, cases2 = bit_search(tmp)
        return tmp1+tmp2, cases1+cases2

# print('initial S',S)
print(bit_search(S)[0])

Submission status: Accepted

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

S = list(input())
# print(S)

answer = 0
for i in range(1 << (len(S)-1)):
    expression = []
    for j in range(len(S)):
        if ((i >> j) & 1) == 1:
            expression.append("{}+".format(S[j]))
        else:
            expression.append(S[j])
    # print(eval("".join(expression)))
    answer += eval("".join(expression))

print(answer)

Submission status: Accepted

Solution code:
s=input()
l=list(s)
lst=[]
# bi=[bin(2**i) for i in range(0,len(s))]
for i in range(1<<(len(s)-1)):
    st=l[0]
    for j in range(len(s)-1):
        if (i>>j)&1:
            st+=l[j+1]
        else:
            st+='+'+l[j+1]
    lst.append(eval(st))
print(sum(lst))

Submission status: Accepted

Solution code:
S = input()
power = 0
answer = 0
temps = int(S)
while True:
    if temps < 10:
        break
    temps = temps/10
    power += 1

SS = list(S)

for i in range(1 << power):
    output = []
    for j in range(power):
        if (i>>j)&1 == 1:
            output.append(SS[j])
            output.append('+')
        else:
            output.append(SS[j])
    output.append(SS[power])
    temp_string = ''.join(output)
    answer += eval(temp_string)
    
print(answer)

Submission status: Accepted

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

import itertools

S = input()
l = len(S)

cs = itertools.product(['+', ''], repeat=l-1)

ans = 0
for c in cs:
    ex = ''.join([S[i] + c[i] for i in range(l-1)] + [S[-1]])
    exec("ans += {}".format(ex))

print(ans)

Submission status: Accepted

Solution code:
s = input()

def split_by_num(s, bits):
    i, j = 0, 0
    res = 0
    while j < len(bits):
        if bits[j] == "1":
            res += int(s[i:min(len(s), j+1)])
            j += 1
            i = j
        else:
            j += 1

    res +=  int(s[i:])
    return res


res = 0
for i in range(0, 1 << (len(s) - 1)):
    tar_bin = format(i, 'b')
    if len(tar_bin) != len(s) - 1:
        tar_bin = "0" * (len(s) - 1 - len(tar_bin)) + tar_bin
    
    res += split_by_num(s, tar_bin)
print(res)

Submission status: Accepted

Solution code:
s = input()
nums = [int(v) for v in s]

l = len(s)

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

Submission status: Accepted

Solution code:
inputs = list(map(int, list('125')))


def prepare():
    global inputs
    inputs = list(map(int, list(input())))


def solve():
    total = 0
    slot = len(inputs) - 1
    cases = range(1 << slot)
    for case in cases:
        sum = inputs[slot]
        power = 0
        for i in range(slot):
            if case & (1 << i):
                power = 0
            else:
                power += 1
            sum += inputs[slot - (i + 1)] * 10**power
        total += sum
    return total


prepare()
output = solve()
print(output)

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
# import bisect
# import math
# import numpy as np


"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: 数
        """
        return int(self.input())

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        # 参考
        # https://blog.rossywhite.com/2018/08/06/bit-search/
        # https://atcoder.jp/contests/abc105/submissions/4088632
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    # output.append(a[j])
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)


"""ここからメインコード"""


def main():
    # 1文字に省略
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    s = str(ip.I())
    ans = 0
    # 最後に+は付けられない
    # bit全探索
    for i in r(1 << len(s) - 1):
        # sの中に+を入れて計算する
        p = ""
        for j, d in e(s):
            p += d
            if id.bit_n(i, j):
                p += "+"
            if j == len(s) - 1:
                break
        ans += eval(p)
    print(ans)


main()

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
# import bisect
# import math
# import numpy as np


"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: 数
        """
        return int(self.input())

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        # 参考
        # https://blog.rossywhite.com/2018/08/06/bit-search/
        # https://atcoder.jp/contests/abc105/submissions/4088632
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    # output.append(a[j])
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)


"""ここからメインコード"""


def main():
    # 1文字に省略
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    s = str(ip.I())
    ans = 0
    # 最後に+は付けられない
    n = len(s) - 1

    # bit全探索
    for i in r(1 << n):
        # sの中に+を入れて計算する
        p = ""
        for j, d in e(s):
            p += d
            if id.bit_n(i, j):
                p += "+"
            if j == n:
                break
        # p += s[-1]
        ans += eval(p)
    print(ans)


main()

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
# import bisect
# import math
# import numpy as np


"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: 数
        """
        return int(self.input())

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        # 参考
        # https://blog.rossywhite.com/2018/08/06/bit-search/
        # https://atcoder.jp/contests/abc105/submissions/4088632
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if ((i >> j) & 1) == 1:
                    """右からj+1番目のiが1かどうか判定"""
                    # output.append(a[j])
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val


"""ここからメインコード"""


def main():
    # 1文字に省略
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    s = str(ip.I())
    ans = 0
    # 最後に+は付けられない
    n = len(s) - 1

    # bit全探索
    for i in r(1 << n):
        # sの中に+を入れて計算する
        p = ""
        for j, d in e(s):
            p += d
            if (i >> j & 1) > 0:
                p += "+"
            if j == n:
                break
        # p += s[-1]
        ans += eval(p)
    print(ans)


main()

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
# import bisect
# import math
# import numpy as np


"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: 数
        """
        return int(self.input())

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        # 参考
        # https://blog.rossywhite.com/2018/08/06/bit-search/
        # https://atcoder.jp/contests/abc105/submissions/4088632
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if ((i >> j) & 1) == 1:
                    """右からj+1番目のiが1かどうか判定"""
                    # output.append(a[j])
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val


"""ここからメインコード"""


def main():
    # 1文字に省略
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    s = str(ip.I())
    ans = 0
    # 最後に+は付けられない
    n = len(s) - 1

    # bit全探索
    for i in r(1 << n):
        # sの中に+を入れて計算する
        p = ""
        for j in r(n):
            p += s[j]
            if (i >> j & 1) > 0:
                p += "+"
        p += s[-1]
        ans += eval(p)
    print(ans)


main()

Submission status: Accepted

Solution code:
s = input()
ans = 0
mita = set()
def f(x):
        global ans
        if x in mita:
                return
        ans += eval(x)
        mita.add(x)
        for i in range(1,len(x)):
                if x[i-1] != "+" and x[i] != "+":
                        f(x[:i]+"+"+x[i:])
f(s)
print(ans)

Submission status: Accepted

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

ans = 0
for b in range(2 ** N):
    now = int(S[0])
    for i in range(N):
        if b&(2**i):
            ans += now
            now = int(S[i+1])
        else:
            now = 10 * now + int(S[i+1])
    ans += now

print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(200000)


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


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    S = ii(str)
    ans = 0
    for i in range(1 << len(S) - 1):
        output = ""
        for j in range(len(S)):
            output += S[j]
            if ((i >> j) & 1) == 1:
                output += "+"
        ans += eval(output)
    return ans


if __name__ == "__main__":
    print(solve())

Submission status: Accepted

Solution code:
def make_equation(i):
    key = i
    equation= ""
    for s in S[:-1]:
        equation += s
        if(key % 2 == 1):
            equation += "+"
        key = key // 2
    equation += S[-1]
    return equation

S = input().strip()
spaces = len(S) - 1
kinds = 2 ** spaces
ans = 0
for i in range(kinds):
    equation = make_equation(i)    
    ans += sum(map(int, equation.split("+")))
print(ans)

Submission status: Accepted

Solution code:
N=input()
slen=len(N)-1
if(slen==0):
    print(N)
    exit()
ans=0
for i in range(2<<(slen-1)):
    k=N
    ins=0
    for j in range(slen): 
        if((i>>j)&1):
            k=k[:j+1+ins]+"+"+k[j+1+ins:]
            ins+=1
    ans+=eval(k)
print(ans)