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()
l = len(s)
fin_ans = 0
#print(s)
for i in range(2**(l-1)):###*
    ans = 0
    left = 0
    right = 1
    for j in range(l):
        if (i>>j) & 1 == 0 and right<l:
            right += 1
        elif right<l:
            ans += int(s[left:right])
            left = right
            right += 1
    ans += int(s[left:right])
    fin_ans += ans
    #print(bin(i),ans,fin_ans)
print(fin_ans)

Submission status: Accepted

Solution code:
S = input()
answer = eval(S)


def search(x, s):
    global answer
    for i in range(x + 1, len(s)):
        formula = "{}+{}".format(s[:i], s[i:])
        answer += eval(formula)
        search(i + 1, formula)


search(0, S)
print(answer)

Submission status: Accepted

Solution code:
S = list(input())
n = len(S)
total = 0
for i in range(2**(n-1)):
    b = bin(i)[2:].zfill(n-1)
    t = S[:]
    for j in range(n):
        if j == 0:
            continue
        if b[j-1] == '1':
            t[j] = '+' + t[j]
    total += eval(''.join(t))
print(total)

Submission status: Accepted

Solution code:
s = input()


def dfs(pos, fm):
    if (pos >= len(s)):
        #print(pos, fm, eval(fm))
        return eval(fm)
    #print(pos, fm)
    return dfs(pos+1, fm+s[pos])+dfs(pos+1, fm+'+'+s[pos])


print(dfs(0, '')//2)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys


#input
lines = [x.strip() for x in sys.stdin.readlines()]
memo={}

def slv(lines):
    ans = rec(str(lines[0]),len(str(lines[0])))

    return ans

def rec(s,n):
    if memo.get(s,None) is not None:
        return memo[s]
    re = 0
    if len(s) ==1:
        return int(s)
    for i in range(0,len(s)):
        l=s[:i]
        r=s[i:]
        if len(l)<1:
            re+=int(r)
        else:
            re += int(l)*(2**(n-i-1))+ rec(r,len(r))
     


    memo[s]=re
    return re


if __name__ == "__main__":
    print(slv(lines))

Submission status: Accepted

Solution code:
from itertools import zip_longest
s = input()
sum = 0
gap_cnt = len(s) - 1
for i in range(2**gap_cnt):
  operators = [" "] * gap_cnt
  for j in range(gap_cnt):
    if((i>>j) &1):
      operators[gap_cnt-1-j] = "+"
  formula = ""
  for p_s,p_o in zip_longest(s,operators,fillvalue=" "):
    formula += (p_s+p_o)
  #if formula.find("+") == -1:
    #sum += int(formula.replace(" ",""))
  #else:
  sum += eval(formula.replace(" ",""))
print(sum)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(100000)

S=int(input())
def saiki(T,c):
    T=str(T)
    if len(T) == 0:
        return 0
    for i in range(len(T)):
        c += int(T[:i+1])*2**(len(T[i+1:])-1 if len(T[i+1:]) != 0 else 0) + saiki(T[i+1:],0)
    return c
print(saiki(S,0))

Submission status: Accepted

Solution code:
ans=0
def f(cnt,div):
    global ans
    if cnt==0:
        ans+=eval(div)
    else:
        f(cnt-1,div[:cnt]+'+'+div[cnt:])
        f(cnt-1,div[:cnt]+div[cnt:])

n=input()
f(len(n)-1,n)
print(ans)

Submission status: Accepted

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

# In[34]:


s = input()


# In[35]:


import itertools

lens = len(s)
sum_ = int(s)

for i in range(1, lens):
    for comb in itertools.combinations(range(1, lens), i):
        #comb = (1, 2)
        sum_ += int(s[:comb[0]])
        for j in range(i-1):
            sum_ += int(s[comb[j]:comb[j+1]])
        sum_ += int(s[comb[-1]:])
        
print(sum_)


# In[ ]:

Submission status: Accepted

Solution code:
S=input()

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

Submission status: Accepted

Solution code:
def calc(pat,S):
    ans = 0
    n = int(S[0])
    for i in range(len(S)-1):
        if pat[i] == '0':
            n = n*10+int(S[i+1])
        else:
            ans += n
            n = int(S[i+1])
    ans += n
    return ans

S = input()
SList=[ int(S[i]) for i in range(len(S))]

n = len(S)-1
binformat = '0'+str(n)+'b'

ans = 0
for i in range(2**n):
    pat = format(i,binformat)
    ans += calc(pat,SList)
print(ans)

Submission status: Accepted

Solution code:
import copy
S = input()
n = len(S)
ans = 0
for i in range(2**(n-1)):
    temp = ""
    for s,j in zip(S, range(n)):
        temp += s
        if i>>j & 1:
            temp += "+"
    ans += eval(temp)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def make_plus_index(S_list):
  s_index = [S_list[0]]
  for S in S_list[1:]:
    new_index = []
    for s in s_index:
      new_index.append(s+'+'+S)
      new_index.append(s+S)
    s_index = new_index
  return s_index

def run():
  S_list = list(input())
  s_lists = make_plus_index(S_list)
  total = 0
  for s in s_lists:
    total += sum(map(int, s.split('+')))
  print(total)
  
if __name__ == '__main__':  
  run()

Submission status: Accepted

Solution code:
import sys


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


def bitall(s, n):
    ans = 0
    for bit in range(1 << n):
        f = s[0]

        for i in range(n):
            if bit & (1 << i):
                f += "+"
            f += s[i + 1]

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

    return ans


def main():
    s = input()
    n = len(s) - 1

    ans = bitall(s, n)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys


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


def main():
    s = input()
    n = len(s) - 1

    ans = 0

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

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

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()

ans,calc =0,0
for i in range(2 ** (len(S) - 1)):
    for j in range(len(S)):
        if (i >> (len(S)-1-j)) & 1:
            ans += calc
            calc = int(S[j])
        else:
            calc = calc*10 + int(S[j])
    ans += calc
    calc = 0
print(ans)

Submission status: Accepted

Solution code:
S = input()

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

print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations

S=input()
N=len(S)
ans=int(S)
for i in range(1,N):
	for v in combinations(range(1,N),i):
		p=0
		for j in v:
			ans+=int(S[p:j])
			p=j
		ans+=int(S[p:])

print(ans)

Submission status: Accepted

Solution code:
s = input().rstrip();

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

print(ans);

Submission status: Accepted

Solution code:
s = input()

length = len(s)-1
bit = 0
re = 0
for i in range(2**length):
    count = 0
    temp_list = list(s)
    for j in range(length):
        if (bit >> j) & 1 == 1:
            # print('bit {}, j {}'.format(bin(bit), j))
            temp_list.insert(j + 1 + count, '+')
            count += 1
    temp_str = 're += ' + ''.join(temp_list)
    # print('bit {}, temp_str {}'.format(bin(bit), temp_str))
    exec(temp_str)
    bit += 1
print(re)

Submission status: Accepted

Solution code:
def func(S,n):
  if n==0:
    return sum(map(int,S.split("+")))
  return func(S[0:n]+"+"+S[n:],n-1)+func(S,n-1)
S=input()
print(func(S,len(S)-1))

Submission status: Accepted

Solution code:
def func(S, n):
    if n == 0:
        return sum(map(int, S.split('+')))
    return func(S[0:n]+'+'+S[n:], n-1) + func(S, n-1)
S = input()
print(func(S, len(S)-1))

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10000)
S=input()
ans=0
def func(n,now):
    global ans
    if n==0:
        ans+=eval(now)
    else:
        func(n-1,now[:-n]+'+'+now[-n:])
        func(n-1,now[:-n]+now[-n:])
func(len(S)-1,S)
print(ans)

Submission status: Accepted

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

def dfs(i, now, depth):
    ans = 0
    if depth == n - 1:
        elements = map(int, now.split('+'))
        return sum(elements)
    else:
        ans += dfs(i + 1, now, depth + 1)
        now = now[:i] + '+' + now[i:]
        ans += dfs(i + 2, now, depth + 1)
    return ans
print(dfs(1, s, 0))

Submission status: Accepted

Solution code:
def func(S, n):
    if n == 0:
        return sum(map(int, S.split('+')))
    return func(S[0:n]+'+'+S[n:], n-1) + func(S, n-1)
S = input()
print(func(S, len(S)-1))

Submission status: Accepted

Solution code:
s=input()
num=len(s)-1
if num==0:
  print(int(s))
else:
  bit=2**num
  bitlist=[]
  sum=0
  for i in range(bit):
    num1=i
    bitsub=[]
    while num1!=0:
      bitsub.append(num1%2)
      num1//=2
    while len(bitsub)!=num:
      bitsub.append(0)
    bitlist.append(bitsub)
  for i in range(bit):
    sum1=0
    num2=s[0]
    for j in range(num):
      if bitlist[i][j]==0:
        num2+=s[j+1]
      else:
        sum1+=int(num2)
        num2=""
        num2+=s[j+1]
    sum1+=int(num2)
    sum+=sum1
  print(sum)

Submission status: Accepted

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

#ビット演算を使ってみる
s = input()
#print(s)

n = len(s)
#print(n)
#長さnだとn-1桁の2進数が欲しい。2^n-1通り試さないと行けない

tasu_ichi = []
cnt = 0

for i in range(2 ** (n-1)):
    #iは2^n-1通りに変化する。
    #何番目にフラグが立っているか全部回収する
    k=0
    for j in range(n-1):
        if (i>>j)&1 == 1:
            #何番目に+を入れるか判定する。参照用の二進数iの右から何番目に1が入るかで判定
            #0から数え始める
            cnt += int(s[k:(j+1)])
            k = (j+1)
    cnt += int(s[k:])
print(cnt)

Submission status: Accepted

Solution code:
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
import numpy as np

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    S = list(input().rstrip())
    N = len(S)

    ans = 0
    for bit in range(1<<N-1):
        str = S[:]
        cnt = 0
        for i in range(N-1):
            if bit & 1<<i:
                str.insert(cnt+i+1, '+')
                cnt += 1
        ans += sum(map(int, ''.join(str).split('+')))
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
import numpy as np

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

S = list(input().rstrip())
N = len(S)
FIN_L = N*2-1

def calc(lst, idx):
    if idx == N:
        return sum(list(map(int, ''.join(lst).split('+'))))
    else:
        return calc(lst+['',S[idx]], idx+1) + calc(lst+['+',S[idx]], idx+1)

def main():
    """ main """
    print(calc(S[:1],1))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def dfs(i, now,  count):
    ans = 0
    if count == len(s)-1:
        calc = list(map(int, now.split('+')))
        return sum(calc)
    else:
        ans += dfs(i + 1, now, count+1)
        now = now[:i] + '+' + now[i:]
        ans += dfs(i + 2, now, count+1)
    return ans


s = input()
print(dfs(1, s, 0))

Submission status: Accepted

Solution code:
def resolve():
    import copy
    s = list(input())
    n = len(s)-1
    c = 0
    for i in range(2**n):
        tmp = copy.deepcopy(s)
        d = 0
        for j in range(n):
            if (i // 2**j) % 2 == 1:
                tmp.insert(j+d+1, '+')
                d += 1
        tmp = ''.join(tmp).split('+')
        c += sum(map(int, tmp))
    print(c)
resolve()

Submission status: Accepted

Solution code:
n = [x for x in input()]
op_cnt = len(n) - 1
sum = int(0)

for index in range(2 ** op_cnt):
  op = [""] * op_cnt
  for index2 in range(op_cnt):
    if ((index >> index2) & 1):
      op[op_cnt - 1 - index2] = "+"
  
  formula = [None]*(len(n)+len(op))
  formula[::2] = n
  formula[1::2] = op
  
  sum += eval("".join(formula))

print(sum)

Submission status: Accepted

Solution code:
s = ""

def rec(i, word):
    if i == len(s):
        return eval("".join(word))
    ans = 0
    word.append('+')
    word.append(s[i])
    ans += rec(i+1, word)
    word.pop()
    word.pop()
    word.append(s[i])
    ans += rec(i+1, word)
    word.pop()
    return ans

def main():
    global s
    s = input()
    print(rec(1, [s[0]]))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

#まずは全部の和を出してから足す
s = input()
#print(s)

n = len(s)
#print(n)
#長さnだとn-1桁の2進数が欲しい。2^n-1通り試さないと行けない

hoge = '0' + str(n-1) + 'b'
cnt = 0

for i in range(2 ** (n-1)):
#    print("計" + str(cnt))
    sep = s
    bn_str = format(i, hoge)
#    print(bn_str)
    for j in range(n-1):
        if bn_str[j] == "1":
            cnt += int(sep[:j+1])
            sep = "0" * (j+1) + sep[j+1:]
            #0うめしないと2回以上切ったときにエラーが出る
#            print(cnt)
#            print(sep)
    cnt += int(sep)
print(cnt)

Submission status: Accepted

Solution code:
# ARC61, C

S = input()
sum_all = 0

#指定した位置で分割
def func(s, idx):
    if len(idx) == 0:
        return int(s)
    sum_ = 0
    start=0
    for j in idx:
        sum_ += int(s[start:(j+1)])
        start = j + 1
    sum_ += int(s[idx[-1]+1:])
    return sum_

for bit in range(1<<(len(S)-1)):
    idx = [i for i in range(len(S)-1) if (bit & (1<<i))]
    sum_all += func(S, idx)
print(sum_all)

Submission status: Accepted

Solution code:
S = list(input())
len_s = len(S)
ans = 0
for num in range(2**(len_s-1)):
  temp = S[0]
  for i in range(len_s-1):
    if num>>i&1:
      ans += int(temp)
      temp = S[i+1]
    else:
      temp += S[i+1]
  ans += int(temp)
print(ans)

Submission status: Accepted

Solution code:
S = list(input())
N = len(S)
List = []
for i in range(2**(N-1)):
    tmp = ''
    for j in range(N-1):
        if ((i>>j) & 1):
            tmp += '1'
        else:
            tmp += '0'
    List.append(list(tmp))
ans = 0
for i in range(len(List)):
    start = 0
    tmp = ''
    for j in range(len(List[i])):
        if List[i][j] == '0':
            tmp += S[j]
        if List[i][j] == '1':
            tmp += S[j]
            ans += int(tmp)
            tmp = ''
    tmp += S[-1]
    ans += int(tmp)

            
print(ans)

Submission status: Accepted

Solution code:
a=input()
l=len(a)
ans=0

for i in range(2**(l-1)):
    i=("0"*l+bin(i)[2:])[-l+1:]
    cnt=a[0]
    for j in range(l-1):
        if i[j]=="0":
            cnt+=a[j+1]
        else:
            ans+=int(cnt)
            if j<l-1:
                cnt=a[j+1]
            else:
                cnt=""
    if cnt!="":
        ans+=int(cnt)
print(ans)

Submission status: Accepted

Solution code:
import sys
import  math
import bisect
from statistics import *
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

s = input()
li = [int(x) for x in s]
l = len(s)
ans = 0
if l == 1:
    print(li[0])
else:
    for i in range(1 << (l - 1)):
        k = li[0]
        ct = 0
        for j in range(l - 1):
            if i >> j & 1:
                ct += k
                k = li[j + 1]
            else:
                k = k * 10 + li[j + 1]
            if j == l - 2:
                ct += k
                ans += ct
    print(ans)

Submission status: Accepted

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

a = []

for i in range(2 ** (l-1)):
    f = []
    b = '{:b}'.format(i).zfill(l-1)
    for j, c in enumerate(s):
        f.append(c)
        if j < l-1 and b[j] == '1':
        	f.append('+')
    a.append(eval(''.join(f)))

print(sum(a))

Submission status: Accepted

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

sum = 0
for i in range(1 << (length - 1)):
    s = S[0]
    for j in range(length - 1):
        if i & (1 << j):
            s += "+"
        s += S[j + 1]
    sum += eval(s)
print(sum)

Submission status: Accepted

Solution code:
import itertools
S = input()
op = list(itertools.product('+ ', repeat=len(S)-1))
calcs = []
for i in range(len(op)):
  calc = ""
  for j in range(len(S)-1):
    calc += S[j] + op[i][j]
  calc += S[-1]
  calcs.append(calc)

for i in range(len(calcs)):
  calcs[i] = eval(calcs[i].replace(" ",""))

print(sum(calcs))

Submission status: Accepted

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

n = len(S)
ans = []
def f(ind, cnt, keta):
	if ind == 0:
		ans.append(cnt)
		return

	f(ind-1, cnt+S[ind-1], 0)
	f(ind-1, cnt+S[ind-1]*(10**(keta+1)), keta+1)


f(len(S)-1, S[-1], 0)

print(sum(ans))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 20 17:21:41 2019

@author: Owner
"""

from collections import deque

S = input()

lens = len(S)
    
def rec(i, cp, s, tot):
    if i == lens:
        #print(s)
        tmp = list(map(int, s.split("+")))
        return sum(tmp)
    
    tot += rec(i+1, cp+1, s[:i+cp]+"+"+s[i+cp:], tot) + rec(i+1, cp, s, tot)
    return tot
    

def main():    
    return print(rec(1, 0, S, 0))
             
                
                
            
            
                

    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import itertools
s = str(input())

s4  = []
for l in range(2 ** (len(s)-1)):
    s3 = list(s)
    h = 0
    for i in range(len(s)-1):
        if (l >> i) & 1:
            s3.insert(i+h+1,'+')
            h += 1
    s4.append(s3)
print(sum([eval(''.join(i)) for i in s4]))

Submission status: Accepted

Solution code:
import itertools
s = str(input())

lst = [i for i in itertools.product([0,1],repeat = len(s) - 1)]
s4  = []
for l in lst:
    s3 = list(s)
    h = 0
    for i in range(0, len(s)-1):
        if l[i] == 1:
            s3.insert(i+h+1,'+')
            h += 1
    s4.append(s3)
print(sum([eval(''.join(i)) for i in s4]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
num = len(S) - 1
sum = 0

for i in range(2**num):
  k = 0
  for j in range(num):
    if ((i >> j) & 1):
      sum += int(S[k:j+1])
      k = j + 1
  sum += int(S[k:])

print(sum)

Submission status: Accepted

Solution code:
S = input()
num = len(S) - 1
sum = 0

for i in range(2**num):
  op = [''] * (num+1)
  formula = ''
  for j in range(num):
    if ((i >> j) & 1):
      op[j] = '+'
  for a,b in zip(S,op):
    formula += a + b
  sum += eval(formula)

print(sum)

Submission status: Accepted

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

for i in range(2**n):
    l=list(s)
    c=1
    for j in range(n):
        if (i>>j)&1:
            l.insert(j+c,"+")
            c+=1
    a+=eval("".join(l))
print(a)

Submission status: Accepted

Solution code:
s = list(input())
s.reverse()
n = len(s)
l = []
for i in range(n):
    s[i] = int(s[i])
for i in range(1,n):
    l.append(i)
bit = []
for i in range(2**(n-1)):
    b = []
    for j in range(n-1):
        if ((i >> j)& 1):
            b.append(l[j])
    bit.append(b)
ans = 0
for i in range(2**(n-1)):
    count = 0
    x = 0
    for j in bit[i]:
        c = 1
        while x < j:
            count += s[x]*c
            x += 1
            c = c * 10
    c = 1
    while x < n:
        count += s[x]*c
        x += 1
        c = c * 10
    #print(count)
    ans += count
print(ans)

Submission status: Accepted

Solution code:
import itertools

user_input = input()
S = list(user_input)
N = int(user_input)
l = len(S)
bit_max = l-1

A = ["","+"]

if l == 1:
    print(N)

else:
    bit_max = l-1
    A = ["","+"]
    ans = 0

    for i in itertools.product(A,repeat=bit_max): 
        tmp = []
        for j,v in enumerate(S):
            tmp.append(v)
            if i[j] == "+":
                tmp.append("+")
            if j == bit_max -1:
                tmp.append(S[j+1])
                break
        
        values = "".join(tmp)
        values2 = values.split("+")

        tmp3 = 0
        for k in values2:
            tmp3 += int(k)
        
        ans += tmp3

    print(ans)

Submission status: Accepted

Solution code:
import sys
from pprint import pprint
from collections import deque

s = sys.stdin.readline().strip()

n = len(s)
q = deque()
q.append([])
for _ in range(n-1):
    q_tmp = deque()
    while q:
        tmp = q.popleft()
        # pprint(tmp)
        for i in [0, 1]:
            tmp2 = tmp[:]
            tmp2.append(i)
            q_tmp.append(tmp2)
    q = q_tmp
# pprint(q)

ans = 0
while q:
    code = q.popleft()
    tmp_str = s[0]
    for i, s_i in enumerate(s):
        if i == 0:
            continue
        tmp_str += "" if code[i-1] == 0 else "+"
        tmp_str += s_i
    # print(tmp_str)
    ans += sum(map(int, tmp_str.split("+")))

print(ans)

Submission status: Accepted

Solution code:
s = input()
n = len(s) - 1
bit = 0
total = 0
while bit < (1 << n):
    siki = s[0]
    for i in range(n):
        if bit & 1 << i:
            siki += '+'
        siki += s[i + 1]
    total += eval(siki)
    bit += 1
print(total)

Submission status: Accepted

Solution code:
a = list(input())
ans = 0
for i in range(1<<(len(a)-1)):
  s = a[0]
  for j in range(len(a)-1):
    if (i >> j) & 1:
      s += "+"
    s += a[j+1]
  ans += eval(s)

print(ans)

Submission status: Accepted

Solution code:
# ARC061C - たくさんの数式 / Many Formulas (ABC045C)
from itertools import product


def main():
    S = input()
    ans = 0
    for ops in tuple(product(("", "+"), repeat=len(S) - 1)):
        ops = ops + ("",)  # operators
        exp = "".join(i + j for i, j in zip(S, ops))  # expression
        ans += eval(exp)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s = list(map(str, input()))
n = len(s)
ans = 0
for i in range(2**(n-1)):
  bag = []
  t = s[:]
  for j in range(n):
    if (i>>j) & 1:
      bag += [j]

  for num in bag[::-1]:
    t.insert(num+1, '+')
  ans += eval(''.join(t))
print(ans)

Submission status: Accepted

Solution code:
s = input()

def bit():
    if len(s) == 1:
        print(s)
    else:
        total = 0
        for i in range((2 ** (len(s) - 1))):
            bit = format(i, '0{}b'.format(len(s) - 1))
            e = ''
            for j in range(len(s) - 1):
                e += s[j]
                if bit[j] == '1':
                    e += '+'
            e += s[-1]
            total += eval(e)
        print(total)

def recursive():
    def _recurs(s):
        if len(s) == 1:
            return [s]
        with_plus = []
        without_plus = []
        for i in _recurs(s[1:]):
            with_plus.append('{}+{}'.format(s[0], i))
            without_plus.append('{}{}'.format(s[0], i))
        return with_plus + without_plus
    ans = _recurs(s)
    print(sum(eval(a) for a in ans))

answer = recursive
answer()

Submission status: Accepted

Solution code:
s = input()

if len(s) == 1:
    print(s)
else:
    total = 0
    for i in range((2 ** (len(s) - 1))):
        bit = format(i, '0{}b'.format(len(s) - 1))
        e = ''
        for j in range(len(s) - 1):
            e += s[j]
            if bit[j] == '1':
                e += '+'
        e += s[-1]
        total += eval(e)
    print(total)

Submission status: Accepted

Solution code:
def calc(S, n):
    if n == 0:
        return sum(map(int, S.split("+")))
    return calc(S[0:n]+"+"+S[n:], n-1) + calc(S, n-1)

S = input()
print(calc(S, len(S)-1))

Submission status: Accepted

Solution code:
s=list(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:
            t=s[s_:j+1]
            if len(t)!=0:
                f.append("".join(t))

            s_=j+1

    t=s[s_:]
    if len(t)!=0:
        f.append("".join(t))

    ans+=eval("+".join(f))

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
s = list(input())
n = len(s)

# 組合せで出現する全ての数式結果の積算値
total_sum = 0
for i in range(2**(n-1)):
    # print(str(bin(i)))

    sub_sum = 0
    tmp_str = [s[0]]
    for j in range(n-1):
        # 間に+演算子を挟むケース
        if (i >> j) & 1:
            sub_sum += int("".join(tmp_str))
            tmp_str = [s[j+1]]
            # print("True: " + str(sub_sum) + " is added.")
        # 間に+演算子を挟まないケース
        else:
            tmp_str.append(s[j+1])
            # print("False: tmp_str is " + str(tmp_str) + " .")
    sub_sum += int("".join(tmp_str))
    # print("This equation's sum is: " + str(sub_sum))
    total_sum += sub_sum

print(total_sum)

Submission status: Accepted

Solution code:
S = input()

def fact(n):
    if n == 0:
        return 1
    return n * fact (n-1)
def comb(n,r):
    return fact(n) // (fact(r) * fact(n-r))
def calc(s,n):
    if n == 0:
        return int(s)
    ans = 0
    for i in range(len(s)-n):
        ln = len(s[i+1:])
        ans += int(s[:i+1])*comb(ln-1, n-1)+calc(s[i+1:],n-1)
    return ans
ans = 0
for i in range(len(S)):
    ans += calc(S, i)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = input()
n = len(s)
ans = 0
for bit in range(1 << n-1):
    string = ""
    for i in range(n-1):
        if bit & (1 << i):
            string += "+"

        string += s[i+1]
    string = s[0] + string
    ans += sum(list(map(int, string.split("+"))))
print(ans)

Submission status: Accepted

Solution code:
l_s = input()
sum = 0
for i in range(2**(len(l_s)-1)):
    m_s = list(l_s)
    countj = 0
    for j in range(len(l_s)-1):
        if ((i >> j) & 1):
            m_s.insert(j+1+countj,'+')
            countj += 1
    m_s = ''.join(m_s)
    sum += eval(m_s)
print(sum)

Submission status: Accepted

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

# coding: utf-8
# Your code here!

s = input()
sList = list(s)
sList = [int(i) for i in s]
sCount = len(sList)
#print(sCount)

aaa = 0

for i in range(2**(sCount-1)):

    binaryNumber = format(i,'b')
    binaryNumber = binaryNumber.zfill(sCount-1)
    binaryNumber = list(binaryNumber)
    binaryNumber = [int(i) for i in binaryNumber]
    
    
    for i in range(sCount-1):
        if binaryNumber[i] == 1 :
            binaryNumber[i] = '+'
    
    #print(sList)
    #print(binaryNumber)
    
    result = [None]*(len(sList)+len(binaryNumber))
    result[::2] = sList
    result[1::2] = binaryNumber
    
    while 0 in result:
        result.remove(0)
    
    #print(result)    
    result = map(str, result)
    resultStr = ''.join(result)
    
    aaa = aaa + eval(resultStr)
    
print(aaa)

Submission status: Accepted

Solution code:
import itertools
s = list(input())
op = ["+", ""]
tt = 0
for i in itertools.product(op, repeat=len(s)-1):
    t = 0
    ts = ""
    for j, v in enumerate(s):
        ts += v
        if j < len(i) and i[j] != "":
            t += int(ts)
            ts = ""
    t += int(ts)
    tt += t
print(tt)

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 = list(map(str, input()))

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)


ans = 0

for i in range(2**(len(s)-1)):
	if i == 0:
		ans += int("".join(s))
		continue

	b = Base_10_to_n(i,2).rjust(len(s)-1, "0")
	ind = [j for j in range(len(b)) if b[j] == "1"]

	temp = []

	if len(ind) == 1:
		temp.append("".join(s[:ind[0]+1]))
		temp.append("".join(s[ind[0]+1:]))
		ans += sum(list(map(int, temp)))
		continue

	if len(ind) >= 2:
		for k in range(len(ind)):
			if k == 0:
				temp.append("".join(s[:ind[k]+1]))
			if 0 < k <= len(ind)-1:
				temp.append("".join(s[ind[k-1]+1:ind[k]+1]))
			if k == len(ind)-1:
				temp.append("".join(s[ind[k]+1:]))

		ans += sum(list(map(int, temp)))
		continue

print(ans)

Submission status: Accepted

Solution code:
l_s = input()
sum = 0
for i in range(2**(len(l_s)-1)):
    m_s = list(l_s)
    countj = 0
    for j in range(len(l_s)-1):
        if  i & (1<<j):
            m_s.insert(j+1+countj,'+')
            countj += 1
    m_s = ''.join(m_s)
    sum += eval(m_s)
print(sum)

Submission status: Accepted

Solution code:
def calc(S):
  out = int(S)
  for i in range(1, len(S)):
    out += (2**(len(S[i:]) - 1)) * int(S[:i]) + calc(S[i:])
  return out

S = input()
print(calc(S))

Submission status: Accepted

Solution code:
S = input()
n = len(S)-1
total_num = 0
if n == 0:
    total_num = S[0]
else:
    for i in range(2**n):
        num = '' 
        for j in range(n):
            if i & 2**j:
                num += S[j]
                total_num += int(num)
                num = ''
            else:
                num += S[j]
        num += S[-1]
        total_num += int(num)
print(total_num)

Submission status: Accepted

Solution code:
import itertools
S=input()
max_plus_number=len(S)-1

def convert_sum(l):
    sums=0
    start=0
    for i in l:
        sums+=int(S[start:i+1])
        start=i+1
    return sums+int(S[i+1:])

total_1=int(S)
for i in range(1,max_plus_number+1):
    places=list(itertools.combinations(range(len(S)-1),i))
    total_2=0
    for p in places:
        total_2+=convert_sum(list(p)) 
    total_1+=total_2

print(total_1)