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

if len(s) == 1:
    print(int(s))
    exit()

for i in range(1 << (len(s) - 1)):
    l = []
    num_sum = 0
    for j in range(len(s)-1):
        if (i >> j & 1) == 1:
            l.append(1)
        else:
            l.append(0)
    cur_num_str = s[0]
    for i in range(len(l)):
        if l[i] == 1:
            num_sum += int(cur_num_str)
            cur_num_str = s[i+1]
        else:
            cur_num_str += s[i+1]
    num_sum += int(cur_num_str)
    ans += num_sum
print(ans)

Submission status: Accepted

Solution code:
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main(): #startline-------------------------------------------
    s = input()
    sl = [i for i in s]
    anslist = [sl[0]]
    n = len(s) - 1
    sublist = [-1]*n
    ans = []
    for i in range(1 << n):
        for j in range(n):
            if i >> j & 1:
                sublist[j] = "+"
        for j in range(n):
            if sublist[j] == "+":
                anslist.append("+")
                anslist.append(sl[j+1])
            else:
                anslist.append(sl[j+1])
        ans.append(eval("".join(anslist)))
        sublist = [-1]*n
        anslist = [sl[0]]
    print(sum(ans))
        
if __name__ == "__main__":
    main() #endline===============================================

Submission status: Accepted

Solution code:
S = input()

total = 0

for m in range(1 << (len(S) - 1)):
  acm = ''
  for i, s in enumerate(S):
    acm += s
    if 1 << i & m:
      total += int(acm)
      acm = ''
  else:
    if acm:
      total += int(acm)

print(total)

Submission status: Accepted

Solution code:
def main():
    S = input()
    len_s = len(S)
    ans = 0
    for i in range(2**(len_s - 1)):
        begin = 0
        remain = i
        l = []
        for j in range(len_s):
            if (remain >> j) % 2 == 1:
                l.append(int(S[begin:j + 1]))
                begin = j + 1
        l.append(int(S[begin:len_s]))
        ans += sum(l)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = [int(x) for x in input()]
s.reverse()
box = []

def f(i, temp, k):
    if i != len(s)-1:
        f(i+1, temp + s[i+1], 1)
        f(i+1, temp + s[i+1]*10*k, 10*k)
    else:
        box.append(temp)

f(0,s[0],1)
print(sum(box))

Submission status: Accepted

Solution code:
N = int(input())
num=N
S=[]

while int(num) > 0:
    S.append(num % 10)
    num = int(num / 10)
S.reverse()

hako=[]
tmp=0
ans=0
for num in range(1<<(len(S)-1)):      
    tmp=S[0]
    sum=0
    for i in range(len(S)-1):
            if num & (1 << i):
                sum+=tmp
                tmp=0
            tmp = tmp * 10 + S[i+1]
    hako.append(sum+tmp)
    ans+=sum+tmp
        
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文の判定基準が理解できていません。
        if bit & (1 << i):
            f += "+"
        f += s[i + 1]

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

print(ans)

Submission status: Accepted

Solution code:
def solve():
    S = list(input())
    results = []
    dfs(S, 0, "", results)
    
    ans = 0
    for res in results:
        ans += eval(res)
    print(ans)

def dfs(S,idx,res,results):
    res += S[idx]
    if idx == len(S)-1:
        results.append(res)
        return
    dfs(S,idx+1,res+'+',results)
    dfs(S,idx+1,res,results)

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2000)

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

def rec(plus):
  if len(plus) == n:
    global ans
    si = s[0]
    for i in range(n):
      if plus[i] == '-':
        si += s[i+1]
      else:
        ans = ans + int(si)
        si = s[i+1]
    ans = ans + int(si)
  else:
    rec(plus+'-')
    rec(plus+'+')

if n == 0:
  print(1)
else:
  rec('-')
  rec('+')
  print(ans)

Submission status: Accepted

Solution code:
import itertools

target=input()
n = len(target)-1
#bit_list = [list(f"{i:0{n}b}") for i in range(2**n)]
status = [['0', '1'] for _ in range(n)]
bit_list = list(itertools.product(*status)) 


answer = 0

for bits in bit_list:
    one_number_indexes=[i for i, x in enumerate(bits) if x == '1']
    
    # ここで1がある場所を取得
    start=0    
    # 街灯の箇所で文字を区切る関数を実装
    for index in one_number_indexes:
        answer=answer+int(target[start:index+1])
        start=index+1
    answer=answer+int(target[start:n+1])

print(answer)

Submission status: Accepted

Solution code:
s = str(input())
# 1|2|3|4| Each vertical bar corresponds bit flag
all = []
for b in range(1 << len(s)-1):
    sub = []
    l = 0
    b |= 1 << len(s)-1
    for r in range(len(s)):
        if b & (1 << r):
            sub.append(int(s[l: r+1]))
            l = r+1
    all.append(sum(sub))

print(sum(all))

Submission status: Accepted

Solution code:
import itertools
N = input()

ans = 0
brank = len(N) -1

S = list(itertools.product([0,1],repeat=brank))

ans = 0
for K in S:
    s = 0
    for i,value in enumerate(K):
        if value == 1:
            ans += int(N[s:i+1])
            s = i + 1
    ans += int(N[s:])
print(ans)

Submission status: Accepted

Solution code:
from itertools import product
S = input().strip()
k = len(S)-1
cnt = 0
for x in product((0,1),repeat=k):
    A = []
    cur = 0
    for i in range(k):
        if x[i]==1:
            A.append(int(S[cur:i+1]))
            cur = i+1
    A.append(int(S[cur:k+1]))
    cnt += sum(A)
print(cnt)

Submission status: Accepted

Solution code:
#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''


import sys
input = sys.stdin.readline
import copy
ss=list(input())
ans=0
for i in range(2**(len(ss)-2)):
    s=copy.copy(ss)
    li=[]
    i=bin(i)[2:]
    for j in range(len(i)):
        if i[j]=="1":
            li.append(len(i)-j)
    #print(i,li)
    for i in range(len(li)):
        s.insert(li[i],"+")
    #print(s)
    ans+=eval("".join(s))
print(ans)

Submission status: Accepted

Solution code:
S = input()
n = len(S)
r = 0
for i in range(1<<(n-1)):
  s, _sum, f = S, 0, 0
  for j in range(n):
    if i>>j & 1:
      _sum += int(s[f:j+1])
      f = j + 1
  r += _sum + int(s[f:j+1])
print(r)

Submission status: Accepted

Solution code:
nums = list(map(int, list(input())))
n = len(nums) - 1

result = 0
for i in range(2 ** n):
    val = 0
    temp = nums[0]
    for j in range(n):
        if ((i >> j) & 1):
            temp *= 10
            temp += nums[j + 1]
        else:
            val += temp
            temp = nums[j + 1]
    val += temp
    result += val

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
import copy

S=input()  #数値入力 「N」だけの入力のとき
n=len(S)
a = []
for i in range(n):
	a.append(S[i])
result = 0
for bit in range(1 << (n-1)):
	a_tmp = []
	a_tmp.clear()
	a_tmp = copy.copy(a)
	count = 0
	for i in range(n-1):
		if(bit & (1 << i)):
			a_tmp.insert(i+count+1,'+')
			count = count + 1
	a_eval = ''.join(a_tmp)
	result = result + eval(a_eval)
print(result)

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
s=input()
l=len(s)
sum=0
for i in range(l):
  tmp=0
  for j in range(0,l-i+1):
    r=2**(max(j-1,0))*2**(max(l-j-i-1,0))
    #print(j,l-j-i,s[j:j+i],r)
    if not (s[j:j+i]==''):
    	tmp=int(s[j:j+i])*r
    sum+=tmp
print(sum+int(s))

Submission status: Accepted

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

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

f += "0"
print(eval(f))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
s = input()
n = len(s)
ans = 0
for i in range(2 ** (n-1)):
    l = [0] * (n-1)
    for j in range(n-1):
        if (i >> j) & 1 == 1:
            l[j] = ' '
        else:
            l[j] = ''
    num = ''
    for k in range(n-1):
        num += s[k] + l[k]
    num += s[-1]
    ans += sum(list(map(int, num.split())))
print(ans)

Submission status: Accepted

Solution code:
s=input()

m=int(s)
n=len(s)

for i in range(1,n):
    for j in range(0,n-i+1):
        if j==0 or j==n-i:
            m+=int(s[j:j+i])*2**(n-1-i)
        else:
            m+=int(s[j:j+i])*2**(n-2-i)
print(m)

Submission status: Accepted

Solution code:
h = input()
ans = 0

for bit in range(2 ** (len(h)-1)):
    s = ""
    for j in range(len(h)):
        s += h[j]
        if (bit >> j) & 1:
            s += "+"
    
    ans += eval(s)

print(ans)

Submission status: Accepted

Solution code:
S = list(input())
tmp = 0
for i in range(2**(len(S) - 1)):
    s = '0'
    for j in range(len(S)):
        s += S[j]
        if i & (1 << j):
            tmp += int(s)
 #           print(tmp)
            s = '0'
    tmp += int(s)
print(tmp)

Submission status: Accepted

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

def dfs(i,f):
    if i == gap:
        return sum(list(map(int, f.split("+"))))

    # 式 f の末尾に "+" を追加するかしないかして次の数字を追加
    return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + "+" + s[i + 1])

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

Submission status: Accepted

Solution code:
s = input()
mae = []
num = len(s)-1
for i in range(2**num):
    ato = []
    for j in range(num):
        if ((i >> j) & 1):
            ato.append("+")
        else:
            ato.append("")
    mae.append(ato)

li = list(s)
ans = []
for i in mae:
    word = ""
    for letter,en in zip(li,i):
        word += letter+en
    word += li[num]
    ans.append(eval(word))
print(sum(ans))

Submission status: Accepted

Solution code:
# C - たくさんの数式
from itertools import product
s=list(input())
n=len(s)
answer=0
pattern=list(product(['+',''],repeat=n-1))
for i in range(2**(n-1)):
    formula=s[0]
    for j,k in zip(pattern[i],s[1:]):
        formula+=(j+k)
    answer+=eval(formula)

print(answer)

Submission status: Accepted

Solution code:
import re
s = input()

def tasu(x):
  return x+1

wa = 0
for j in range(2**(len(s)-1)):
  bin_str = format(j, "0{}b".format(len(s)-1) ) #二進数の文字列を取得
  l_p = [ x.start() for x in re.finditer("1",bin_str)  ] 
  l_p = list( map(tasu,l_p) )
  l_p = [0]+l_p+[len(s)]

  for i in range(len(l_p)-1):
    wa = wa + int(s[ l_p[i] : (l_p[i+1]) ] )
print(wa) #なんかおかしい

Submission status: Accepted

Solution code:
_ = '_'


def solve(s):
    if _ in s:
        return solve(s.replace(_, "+", 1)) + solve(s.replace(_, "", 1))
    else:
        return eval(s)


s = _.join(list(input()))
print((solve(s)))

Submission status: Accepted

Solution code:
import itertools

s = input()
memo = list(itertools.product(['', '+'], repeat=len(s) - 1))
ans = 0
check = []
cnt = ''

for i in range(2 ** (len(s) - 1)):
    check = []
    cnt = ''
    for j in range(len(s) - 1):
        cnt += s[j]
        if memo[i][j] == '+':
            check.append(int(cnt))
            cnt = ''

    cnt += s[len(s) - 1]
    check.append(int(cnt))
    ans += sum(check)

print(ans)

Submission status: Accepted

Solution code:
S = list(input())# 各桁をリストに分配
n = len(S)-1 #桁数
ans = 0
for i in range(2**n): #隙間に+が入るかどうかの全パターン
    box = []
    for j in range(n): #隙間に+が入る場合の数
        if (i>>j) & 1:
            box.append(S[j])
            box.append("+")
        else:
            box.append(S[j])
    box.append(S[n])

    sub = 0
    plus = 0

    for k in range(len(box)):
        if box[k] == "+":
            sub += plus
            plus = 0
        else:
            if plus == 0:
                plus = int(box[k])
            else:
                plus *= 10
                plus += int(box[k])
    sub += plus
    ans += sub

print(ans)

Submission status: Accepted

Solution code:
def resolve():
    S = input()

    memo = []
    def dfs(s):
        if len(s) == len(S)-1:
            memo.append(s)
            return 
        dfs(s + "1")
        dfs(s + "0")

    dfs("")
    comb = []
    for c in memo:
        sub = []
        store = S[0]
        for i, flag in enumerate(c):
            if flag == "0":
                store += S[i+1]
            elif flag == "1":
                sub.append(store)
                store = S[i+1]
        sub.append(store)
        comb.append(sub)

    total = 0
    for c in comb:
        ilist = list(map(int, c))
        sum = 0
        for a in ilist:
            sum += a
        total += sum

    print(total)

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
s=input()
ans=0
d=len(s)-1
for i in range(2**d):
  c =bin(i)[2:].zfill(d).replace("0","#").replace("1","+")+"#"
  q="".join(["".join(a) for a in zip(s,c)]).replace("#","")
  ans+=eval(q)
print(ans)

Submission status: Accepted

Solution code:
import sys

S = input()

N = len(S)-1
sum = 0

for i in range(2**N):

    op = [""]*(N)
    for j in range(N):
        if (i>>j)&1:
            op[j] = "+"
    s = ""
    for j in range(N):
        s = s + S[j] + op[j]
    s = s + S[len(S)-1]
    sum = sum + eval(s)
print(sum)

Submission status: Accepted

Solution code:
S=input()
n=len(S)
sums=0
for i in range(2**(n-1)):
    op = [""]*n
    for j in range(n-1):
        if ((i >>j)) & 1: op[j] = "+"
    formula=""
    for s,o in zip(S, op):
        formula+=(s+o)
    sums+=eval(formula)
print(sums)

Submission status: Accepted

Solution code:
#ABC 45C - たくさんの数式
def main():
    s = (input())
    n = len(s)
    total = 0
    for i in range(2**(n-1)):
        op = [""]*(n-1)
        for j in range(n-1):
            if ((i >>j)) & 1:
                op[n-1-1-j] = "+"
        formula = ""
        for p_s, p_o in zip(s, op + [""]):
            formula += (p_s + p_o)
        total += eval(formula)
    print(total)
main()

Submission status: Accepted

Solution code:
S = input()
ans = 0
for k in range(2**(len(S)-1)):
    f = -1
    t = []
    for l in range(len(S)):
        if (k>>l)&1 == 1:
            t.append(S[f+1:l+1])
            f = l
    t.append(S[f+1:])
    for e in t:
        ans += int(e)
print(ans)

Submission status: Accepted

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

ans_list = []
for i in range(2 ** n):
    ans = s[0]
    for j in range(n):
        if ((i >> j) & 1):
            ans += "+" + s[j + 1]
        else:
            ans += s[j + 1]
    ans_list.append(ans)

sum_ = 0
for enume in ans_list:
    sum_ += eval(enume)
print(sum_)

Submission status: Accepted

Solution code:
s = input()
sl = [_ for _ in s]

answers = []
for i in range(2**(len(s)-1)):
    temp = []
    for j in range(len(s)-1):
        if (i >> j) & 1:
            temp.append(j)
    ll = ["*"] * len(s)
    for k in temp:
        ll[k] = "+"
    ans = []
    for sli, lli in zip(sl, ll):
        ans.append(sli)
        ans.append(lli)
    ans = [_ for _ in ans if _ != "*"]
    ans = "".join(ans)
    ans = ans.split("+")
    ans = [int(i) for i in ans]
    ans = sum(ans)
    answers.append(ans)

print(sum(answers))

Submission status: Accepted

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

tmp = 2 ** n
ans = 0

for i in range(tmp):
  p = bin(i)[2:]
  # print(p)
  p = '0' * (n - len(p)) + p
  # print(p)
  x = ''

  for j, k in enumerate(s):  # enumerate: インデックス番号，　要素の順番に取得可能
    # print(k)
    x += k
    if j != n and p[j] == '1':
      x += '+'
      # print(x)

  # print(x)
  ans += eval(x)

print(ans)

Submission status: Accepted

Solution code:
def main():
    #import sys
    #input = sys.stdin.readline
    S = input()
    S_list = list(S)
    dig = len(S) - 1
    insert_plus = format(0,"0"+str(dig)+"b")
    insert_plus_max = "1"*len(insert_plus)
    s = 0
    if len(S) == 1:
        print(int(S))
        exit()

    for i in range(int(insert_plus_max,2)+1):
        before = 0
        num_list = []
        now = format(i,"0"+str(dig)+"b")
        for j in range(len(now)):
            if now[j] == "1":
                num_list.append("".join(S_list[before:int(j)+1]))
                before = j+1
            if j == len(now)-1:
                num_list.append("".join(S_list[before:]))
        for num in num_list:
            s += int(num)
    print(s)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def f(n):
    if n <= 0:
        return 1
    return 2**(n-1)

s = input()

score = 0
for blocksize in range(1,len(s)+1):
    for startpoint in range(len(s)):
        if startpoint+blocksize >= (len(s)+1): continue
        block = s[startpoint:startpoint+blocksize]  
        ss = int(block) * f(startpoint) * f(len(s) - (startpoint+blocksize))
        # print("{} ({}, {}): {}".format(block, startpoint, len(s) - (startpoint + blocksize), ss))
        score += ss
print(score)
exit()

Submission status: Accepted

Solution code:
s = list(input())

leng = len(s) - 1
ans = 0
for i in range(2 ** leng):
    bit = []
    for j in range(leng):
        if ((i >> j) & 1):
            bit.append(s[j])
            bit.append("+")
        else:
            bit.append(s[j])
    bit.append(s[leng])
    sub = 0
    plus = 0
    for k in range(len(bit)):
        if bit[k] == "+":
            sub += plus
            plus = 0
        else:
            if plus == 0:
                plus = int(bit[k])
            else:
                plus *= 10
                plus += int(bit[k])
    sub += plus
    ans += sub

print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations
s = input()
ans = int(s)
li = [combinations([i for i in range(1,len(s))],j) for j in range(1,len(s)+1)]
for i in range(len(s)):
  for v in li[i]:
    tmp = []
    u = 0
    for j in v:
      tmp.append(int(s[u:j]))
      u = j
    tmp.append(int(s[u:]))
    ans += sum(tmp)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = [x for x in input()]
op_cnt = len(S) - 1  # すき間の個数
ans = 0

for i in range(2 ** op_cnt):

    ops = [""] * op_cnt

    for j in range(op_cnt):
        if (i >> j) & 1:
            ops[op_cnt - 1 - j] = "+"

    formula = S[0]
    for op, num in zip(ops, S[1:]):
        formula += op + num

    ans += eval(formula)

print(ans)

Submission status: Accepted

Solution code:
s = input()
n = [ i for i in s]
ans = 0

import itertools

for i in range(len(n)):
    for j in itertools.combinations(range(len(n)-1), i):
        temp = [i for i in s]
        for k in j[::-1]:
            temp.insert(k+1, "+")
        temp = "".join(temp)
        temp = temp.split("+")
        temp = map(int, temp)
        ans += sum(temp)

print(ans)

Submission status: Accepted

Solution code:
import itertools

s = input()
n = [i for i in s]
ans = 0

for i in range(len(n)):
    for j in itertools.combinations(range(len(n)-1), i):
        temp = [i for i in s]
        for k in j[::-1]:
            temp.insert(k+1, "+")
        temp = "".join(temp)
        temp = temp.split("+")
        temp = map(int, temp)
        ans += sum(temp)

print(ans)

Submission status: Accepted

Solution code:
def dfs(i, f):
    if i == len(s) - 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()
print(dfs(0,s[0]))

Submission status: Accepted

Solution code:
num = list(map(int,list(str(input()))))
num_len = len(num)

temp = 0
ans = 0

for i in range(2**(num_len-1)):
  sum = 0
  for j in range(0,num_len):
    temp = temp*10 + num[j]
    
    if j == num_len-1:
      sum = sum + temp
      temp=0
      break
    
    if((i >> j) & 1):
      sum = sum + temp
      temp=0
      
  ans = ans + sum
  
print(ans)

Submission status: Accepted

Solution code:
S = input()
S_list = list(S)
N = len(S_list)
L = []
for i in range(2**(N-1)):
    tmp = []
    for j in range(N-1):
        tmp.append(S_list[j])
        if i>>j&1:
            tmp.append("+")
        else:
            tmp.append("")
    tmp.append(S_list[N-1])
    calc = "".join(tmp)
    C = calc.split("+")
    L.append(sum(map(int, C)))
print(sum(L))

Submission status: Accepted

Solution code:
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main(): #startline--------------------------------------------
    s = input()
    sl = [i for i in s]
    n = len(s) - 1
    sublist = [-1]*n
    anslist = [sl[0]]
    ans = []
    for i in range(1 << n):
        for j in range(n):
            if i >> j & 1:
                sublist[j] = "+"
        for j in range(n):
            if sublist[j] == "+":
                anslist.append("+"+sl[j+1])
            else:
                anslist.append(sl[j+1])
        ans.append(eval("".join(anslist)))
        anslist = [sl[0]]
        sublist = [-1]*n
    print(sum(ans))
#endline===============================================
if __name__ == "__main__":
    main()

Submission status: Accepted

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

for i in range(2 ** op_cnt):
    op = ['+']*op_cnt
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[j] = ""
    op.append("")
    ans = []
    for num,plus in zip(S,op):
        ans.append(num)
        ans.append(plus)
    ans = [_ for _ in ans if _ != ""]
    ans = ''.join(ans)
    answer += eval(ans)
print(answer)

Submission status: Accepted

Solution code:
S = input()
ans = 0
for i in range(2 ** (len(S) - 1)):
    status = str(bin(i)[2:]).zfill(len(S) - 1)
    index = 0
    S_i = S
    for s in status:
        if s == str(1):
            S_i = S_i[:index] + S_i[index] + "+" + S_i[index + 1:]
            index += 1
        index += 1
    ans += eval(S_i)
print(ans)

Submission status: Accepted

Solution code:
s = str(input())

import itertools
ans = 0
rep = len(s) - 1
operators = ('', '+')

for opers in itertools.product(operators, repeat=rep):
  #print(opers)
  formula = s[0]
  for oper, num in zip(opers, s[1:]):
    formula += oper + num
  #print(formula)
  ans += sum(map(int, formula.split('+')))

print(ans)

Submission status: Accepted

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

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

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

if __name__ == '__main__':
    main2()

Submission status: Accepted

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

total = 0
for i in range(2 ** (n - 1)):
    tmp = [False] * (n - 1)
    for j in range(n - 1):
        if i >> j & 1:
            tmp[j] = True

    eq = [S[0]]
    for i in range(n - 1):
        if tmp[i]:
            eq.append(",")
        eq.append(S[i + 1])

    eq = ''.join(eq)
    eq = eq.split(',')

    sum_i = 0
    for i in eq:
        sum_i += int(i)
    # print(eq, sum_i)
    total += sum_i
print(total)

Submission status: Accepted

Solution code:
N = list(input())
n = len(N) - 1
a = ["+"] * n
ev = []
for bit in range(1 << n):
    for i in range(n + 1):
        ev.append(N[i])
        if bit & (1 << i):
            ev.append(a[i])
    ev.append("+")
ev = "".join(ev)[:-1]
print(eval(ev))

Submission status: Accepted

Solution code:
S = input()

S_len = len(S)
def insert_plus(exp, index=1):
    if index == S_len:
        return eval(exp)

    pn = exp.count("+")
    ans_in = insert_plus(exp[:index+pn]+"+"+exp[index+pn:], index+1)
    ans_ex = insert_plus(exp, index+1)
    return ans_in + ans_ex

print(insert_plus(S))

Submission status: Accepted

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

    for i in range(2**n):
        op = [""] * n
        for j in range(n):
            if (i>>j)&1:
                op[j] = "+"
        tmp = ""
        for a,b in zip(s,op + [""]):
            tmp += a + b
        ans += eval(tmp)

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from sys import stdin
s = stdin.readline().rstrip()
n = len(s)
total = 0
for i in range(2**(n-1)):
    li = []
    for j in range(n-1):
        if ((i >> j) & 1):
            li.append(j)
    point = 0
    for k,l in enumerate(s):
        point *= 10
        point += int(l)
        if k in li:
            total += point
            point = 0
    total += point
print(total)

Submission status: Accepted

Solution code:
import itertools

def main():
    S = list(input())
    ans = 0
    for syms in itertools.product(("+", ""), repeat=len(S)-1):
        v = S[0]
        for i, sym in enumerate(syms, start=1):
            if sym == "":
                v += S[i]
            else:
                ans += int(v)
                v = S[i]
        ans += int(v)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()
eS = list(" ".join(S))
exp = len(S)-1

res = 0
for i in range(2**exp):
    eS = list(" ".join(S))
    for j in range(exp):
        if (i >> j) & 1:
            eS[2*j+1] = "+"
    res += eval("".join(eS).replace(" ", ""))

print(res)

Submission status: Accepted

Solution code:
S=input()

Sum = 0
for ii in range( 1, 2**(len(S)-1) ):
    temp_list = []
    temp_s = S
    itr = 1
    for jj in range( (len(S)-1) ):
        bit = (ii>>jj) & 1
        if bit:
            temp_list.append( int(temp_s[0:itr]) )
            temp_s = temp_s[itr:]
            itr = 1
        else:
            itr += 1
    Sum += sum( int(i) for i in temp_list )
    Sum += int(temp_s)
Sum += int(S)
print(Sum)

Submission status: Accepted

Solution code:
S = input()
def f(X):
    if len(X) == 1:
      return(int(X))
    else:
      n = len(X)
      s = 0
      for i in range(1, n):
        s += f(X[:n-i]) + int(X[n-i:n])*(2**(n-i-1))
      s += int(X)
      return(s)
print(f(S))

Submission status: Accepted

Solution code:
S=input()
def bit_sum(list):
    if len(list)==1:
        return int(list[0])
    else:
        n=len(list)
        s=0
        for i in range(1,n):
            s+=(bit_sum(list[:i])+int(list[i:])*2**(i-1))
        s+=int(list)
        return s

print(bit_sum(S))

Submission status: Accepted

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

for i in range(1, 2**(len(s)-1)):
    binary = "{0:0>{1}b}".format(i, len(s)-1)
    idxes = [p for p, x in enumerate(binary) if x == '1']
    for j in range(len(idxes)):
        if j == 0:
            nums.append(int(s[:idxes[j]+1]))
        else:
            nums.append(int(s[idxes[j-1]+1:idxes[j]+1]))

    nums.append(int(s[idxes[j]+1:]))
            
    
print(sum(nums))

Submission status: Accepted

Solution code:
from itertools import combinations

s = [int(i) for i in list(str(input()))]
t = list(range(len(s) - 1))

ans = 0
for i in range(len(s)): #+を入れる個数
    tmp = list(combinations(t, i))
    for j in range(len(tmp)):
        plus = 0
        #print(s, tmp[j])
        for k in range(len(s)):
            if k - 1 in tmp[j]:
                ans += plus
                #print(plus)
                plus = s[k]
            else:
                plus = 10 * plus + s[k]
        ans += plus
        #print(plus)
print(ans)

Submission status: Accepted

Solution code:
S = list(input())

lenS = len(S)-1
ans = 0

for i in range(2**lenS) :
    pat = str("{:0>{}b}".format(i, lenS))
    for k in range(lenS) :
        S[k] = S[k].replace("+","")
        if pat[k] == "1" :
            S[k] = S[k] + "+"
    ans += eval("".join(S))

print(ans)