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
l = len(s)
for i in range(2**(l-1)):
  nums = [s]
  idx = 0
  #print(f'i={i}')
  for j in range(l-1):
    if i>>j&1:
      a = s[idx:j+1]
      b = s[j+1:]
      #print(f'j={j}')
      #print(f'idx={idx}, a={a}, b={b}')
      idx = j+1
      nums[-1] = a
      if b != '':
        nums.append(b)
  ans += sum(list(map(int, nums)))
  #print(nums)
  #print('----------------')
print(ans)

Submission status: Accepted

Solution code:
s = input()
n = len(s) - 1
ans = 0
for i in range(1 << n):
    tmp_l = []
    sep = 0
    for j in range(n):
        if (i >> j) & 1:
            tmp_l.append(int(s[sep:j + 1]))
            sep = j + 1
    tmp_l.append(int(s[sep:]))
    ans += sum(tmp_l)
print(ans)

Submission status: Accepted

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

ans = 0
for i in range(1<<(n-1)):
    form = ""
    for j in range(n-1):
        form += s[j]
        if i & 1<<j:
            form += "+"
    form += s[-1]
    ans += eval(form)

print(ans)

Submission status: Accepted

Solution code:
s = str(input())
n = len(s)
m = [0 for _ in range(n)]
for i in range(n):
  m[i] = int(s[i])
a = 0
for i in range(2**(n-1)):
  ai = 0
  tmp = 0
  for j in range(n-1):
    if ((i>>j)&1) == 1:
      ai += tmp*10+m[j]
      tmp = 0
    else:
      tmp = tmp*10+m[j]
  tmp = tmp*10 + m[n-1]
  ai += tmp
  a += ai
print(a)

Submission status: Accepted

Solution code:
import sys
import numpy as np
import math
import collections
import copy
from collections import deque 
from functools import reduce
from itertools import product

# input = sys.stdin.readline
S = input()
total = 0
for p in (product((0, 1), repeat=len(S)-1)):
    ns = S[0]
    for i, pp in enumerate(p, 1):
        if pp == 0:
            ns += S[i]
        else:
            total += int(ns)
            ns = S[i]
    total += int(ns)
print(total)

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# C - たくさんの数式
# https://atcoder.jp/contests/arc061/tasks/arc061_a
S = input()
n = len(S)
ans = 0
# 計算量: O(2**n*n)
for i in range(1 << n - 1):
    # 0からn-1番目までの数のうち、何番目の後にj番目に+を挿入するか
    x = S[0]
    for j in range(n - 1):
        if i & 1 << j:
            # +をjとj+1の間に挿入する
            x += '+'
        x += S[j + 1]
    ans += sum(map(int, x.split('+')))
print(ans)

Submission status: Accepted

Solution code:
import itertools
S = list(input())
ans = []
a = S[0]
pl = ["+",""]

for i in itertools.product(pl, repeat=len(S)-1):
    for j in range(len(S)-1):
        a += i[j]+S[j+1]
    ans.append(eval(a))
    a = S[0]

print(sum(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
N = len(S)
Sum = 0
for i in range(2**(N-1)):
    exp = []
    for j in range(N):
        exp.append(S[j])
        if ((i >> j) & 1):
            exp.append('+')
    
    a = ''
    for j in range(len(exp)):
        if exp[j] == '+':
            Sum += int(a)
            a = ''
        else:
            a += exp[j]
        if j == (len(exp)-1):
            Sum += int(a)
    
print(Sum)

Submission status: Accepted

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


def RecSum(S, i):
    if i > len(S) - 1:
        return eval(''.join(S))
    SS = S.copy()
    SS.insert(i, "+")
    return RecSum(S, i+1) + RecSum(SS, i+2)


S = list(input().rstrip('\n'))
print(RecSum(S, 1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

res = [[S[0]]]

for c in S[1:]:
    buf = []
    for dp in res[-1]:
        buf.append(dp+c)
        buf.append(dp+'+'+c)
    res.append(buf)
sum_num = 0

for string in res[-1]:
    sum_num += sum(map(int, string.split('+')))
print(sum_num)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
S = input()

ans = 0
for v in itertools.product([1,0], repeat=len(S)-1):
    idx = 0
    sum = 0
    for i in range(1,len(S)):
        if v[i-1] == 1:
            sum += int(S[idx:i])
            idx = i
    ans += int(S[idx:])
    ans += sum
print(ans)

Submission status: Accepted

Solution code:
import itertools
import copy
S = input()

ans = 0
for v in itertools.product([1,0], repeat=len(S)-1):
    S_copy = copy.deepcopy(S)
    idx = 0
    sum = 0
    for i in range(1,len(S)):
        if v[i-1] == 1:
            sum += int(S[idx:i])
            idx = i
    ans += int(S[idx:])
    ans += sum
print(ans)

Submission status: Accepted

Solution code:
#入力
#関数へ
#関数
    #
def a(t,i):
    if i == len(s)-1:
        return sum(map(int,t.split('+')))
    return a(t+s[i+1],i+1) + a(t+'+'+s[i+1],i+1) #関数の中に入れると最後の項でまとめて処理できる
s = input()
print(a(s[0],0))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys
S = sys.stdin.readline().rstrip()
N = len(S)
def solve(i,c,s):
    #print(i,c,s)
    if i == N:
        return [s+c]
    ret = []
    ret.extend(solve(i+1,0,s+c*10+int(S[i])))
    ret.extend(solve(i+1,c*10+int(S[i]),s))
    return ret
#print(solve("25"))
print(sum(solve(0,0,0))//2)
#print(sum(solve(S)))

Submission status: Accepted

Solution code:
S = input()
answer = 0
for bit in range(2 ** (len(S) - 1)):
    f = S[0]
    for i in range(len(S) - 1):
        if bit & (1 << i):
            f += '+'
        f += S[i + 1]
    answer += sum(map(int, f.split('+')))
print(answer)

Submission status: Accepted

Solution code:
s=input()
n=len(s)-1
sum=0
for bit in range(1<<n):
	left=0
	right=0
	for i in range(n+1):
		if (bit & (1<<i)):
			left=right
			right=i+1
			sum+=int(s[left:right])
	sum+=int(s[right:n+1])
print(sum)

Submission status: Accepted

Solution code:
from itertools import product

S=input()
ans=0
for i in list(product([False,True],repeat=len(S)-1)):
  b=0
  a=S[0]
  for j in range(len(S)-1):
    if i[j]==False:
      a+=S[j+1]
    else:
      b+=int(a)
      a=S[j+1]
  b+=int(a)
  ans+=b
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def separate_and_calc(S,plus_list):
    if plus_list == []:
        return array_to_num(S)
    
    result = 0
    for i in range(len(plus_list)):
        if i == len(plus_list)-1:
            result += array_to_num(S[plus_list[i]:])
        if i == 0:
            result += array_to_num(S[0:plus_list[i]])
            continue
        result += array_to_num(S[plus_list[i-1]:plus_list[i]])

    return result

def array_to_num(S):
    result = 0
    for i in range(len(S)):
        result += int(S[len(S) -1 - i]) * (10**(i))
    return result

S = input()
N = len(S)
result = 0
for bit in range(2**N):
    plus_list = []
    if bit & 1 or bit & (1<<N):
        continue

    for i in range(N):
        if (bit & (1<<i)):
            plus_list.append(i)
    
    result += separate_and_calc(S,plus_list)
    
    # print(" }")
print(result)

Submission status: Accepted

Solution code:
S = input()
n=len(S) - 1 
shiki = ""
output = 0
for i in range(2**n):
  result = list()
  shiki = S[0]
  for j in range(n):
    if ((i>>j)&1):
      shiki = shiki + '+' + S[j+1]
    else:
      shiki = shiki + S[j+1]
  result = list(map(int,shiki.split('+')))
  for k in range(len(result)):
    output += result[k]
print(output)

Submission status: Accepted

Solution code:
def abc061_c():
    s = str(input())

    l = []
    def saiki(i,moji):
        if i == len(s)-1:
            #print(moji)
            l.append(sum(list(map(int,moji.split("+")))))
            return

        #いれる
        saiki(i+1,moji+"+"+s[i+1])
        #いれない
        saiki(i+1,moji+s[i+1])

    saiki(0,s[0])

    print(sum(l))


abc061_c()

Submission status: Accepted

Solution code:
import copy

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

ans = 0
for bit in range(1 << n):

    #print(bin(bit))

    p = []
    for i in range(n):
        if bit & (1 << i):
            p.append(i)
    #print(p)

    m = 1
    s_ = copy.copy(s)
    for idx in p:
        s_[idx+m:idx+m] = '+'
        m += 1
    #print(s_)

    ss = ''.join(s_)
    #print(ss)
    ans += sum([int(n) for n in ss.split('+')])

print(ans)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

S = list(input())
leng = len(S)
ans = 0
for i in range(1<<(leng-1)):
    lis = [S[0]]
    for j in range(leng-1):
        if (i>>j)&1:
            ans += int(''.join(lis))
            lis = []
        lis.append(S[j+1])
    else:
        if lis:
            ans += int(''.join(lis))
print(ans)

Submission status: Accepted

Solution code:
s = input()

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

for i in range(n):
  bin_n = bin(i)[2:]
  bin_n = '0' * ((len(s) - 1) - len(bin_n)) + bin_n
  current_address = 0
  for j in range(len(bin_n)):
    if bin_n[j] == '1':
      result += int(s[current_address:j+1])
      current_address = j+1

  result += int(s[current_address:])

print(result)

Submission status: Accepted

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

for bit in range(0, 1<<n):
    st=s
    for i in range(n+1):
        if (bit>>i)%2==0:
            continue
        st=st[:n-i]+'+'+st[n-i:]

    ans+=sum(list(map(int,st.split('+'))))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
len_s = len(s)
def calc_one_sum(n):
    r = len_s
    l = len_s - 1
    i = 0
    one_sum = 0
    while l > 0:
        if n & 1<<i != 0:
            one_sum += int(s[l:r])
            r = l
            l -= 1
        else:
            l -= 1
        i += 1
    one_sum += int(s[l:r])
    return one_sum
ans = 0
for i in range(2**(len_s - 1)):
    ans += calc_one_sum(i)
print(ans)

Submission status: Accepted

Solution code:
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


s = S()
n = len(s)
ans = 0
for i in range(2 ** (n - 1)):
    res = '' + s[0]
    for j in range(n - 1):
        if i >> j & 1:
            res += '+'
        res += s[j + 1]
    res = list(map(int, res.split('+')))
    ans += sum(res)
print(ans)

Submission status: Accepted

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

s = 0
for i in range(1 << (N - 1)):
    bs = format(i, f'0{N - 1}b')[::-1]
    t = S[0]
    for j in range(N - 1):
        if bs[j] == '1':
            s += int(t)
            t = S[j + 1]
        else:
            t += S[j + 1]
    s += int(t)
print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def a(t,i):
    if i == n-1:
        return sum(map(int,t.split("+")))
    return a(t+s[i+1],i+1)+ a(t+"+"+s[i+1],i+1)

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

Submission status: Accepted

Solution code:
s=list(input())
n=len(s)
ans=0
for i in range(2**(n-1)):
    a=list(bin(i)[2:])
    a=['0']*(n-1-len(a))+a
    j=0
    num=s[0]
    while j<n-1:
        if a[j]!='0':
            ans += int(num)
            num=''
        j+=1
        num+=s[j]
    ans+=int(num)
print(ans)

Submission status: Accepted

Solution code:
def sum(list, index):
    if (len(list) > 1):
        d = len(list[:-1]) - 1
        return (sum(list[:-1], 0) + list[-1] * 10**index * 2**d ) + (sum(list[:-1], index + 1 ) + list[-1] * 10**index * 2**d)
    else:
        return (list[-1] * 10**index)

def resolve():
    s = list(map(int,input()))
    print(sum(s,0))


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
S = input()

buf = [[0]]
for i in range(1, len(S)):
    buf2 = [b + [i] for b in buf] + buf
    buf = buf2
buf = [b + [len(S)] for b in buf]

ans = 0
for b in buf:
    for i in range(len(b) - 1):
        right, left = b[i], b[i+1]
        ans += int(S[right: left])
print(ans)

Submission status: Accepted

Solution code:
S=input()
N=len(S)
goukei=0
for i in range(2 **(N-1)):
    T=[]
    T.append(S[0])
    for j in range(N-1):
        if ((i >> j) & 1):
            #print(i,j)のjbitがONの意味
            #print(i,j)
            T.append("+")
            T.append(S[j+1])
        else:
            T.append(S[j+1])
    
    #T.append(S[N-1])
    #print(T)
    tmp=[]
    for m in T:
        if m!="+":
            tmp.append(m)
        else:
            Z=[str(a) for a in tmp]
            Z="".join(Z)
            goukei+=int(Z)
            tmp=[]
    Z=[str(a) for a in tmp]
    Z="".join(Z)
    goukei+=int(Z)
    
print(goukei)

Submission status: Accepted

Solution code:
from itertools import product

s = str(input())
a = list(product(['+', ''], repeat=len(s)-1))


ans = 0
tmp = ""
for i in a:
    tmp = ""
    for j in range(len(s)-1):
        tmp += (s[j]+i[j])
    tmp += s[len(s)-1]
    ans += eval(tmp)
print(ans)

Submission status: Accepted

Solution code:
import copy
a=list(input())
ano=list(range(1,100,2))
n=len(a)-1
ans=0
for i in range(2**n):
    c=copy.deepcopy(a)
    b=['']*n
    for j in range(n):
        if ((i>>j)&1)==1:
            b[j]='+'
    for k in range(n):
        c.insert(ano[k],b[k])
    ans+=eval(''.join(c))
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n,*p = map(int, read().split())


s = input()

L = len(s)
ans = 0
from itertools import product
for a in product(["+",""],repeat=L-1):
    t = s[0]
    for si,i in zip(s[1:],a):
        t += i + si
        
    #print(t)
    ans += eval(t)

print(ans)

Submission status: Accepted

Solution code:
__DEUBG__ = 0
num = input()
pattern = len(num) -1

if pattern == 0:
    print(num)
    exit(0)
total = 0
fmt = '0' + str(pattern) + 'd'
if __DEUBG__:
    print(fmt)
total = 0
for i in range(2**pattern):
    binary = format(int(bin(i)[2:]), fmt)
    if __DEUBG__:
        print('binary', binary)

    equation = ''
    for idx, sign in enumerate(binary):
        equation += num[idx] + ('+' if sign == '1' else '')
        if __DEUBG__:
            print(equation)

    equation += num[-1]
    if __DEUBG__:
        print(equation, eval(equation))
        print()
    total += eval(equation)

print(total)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

from itertools import product

S = input()
l = len(S)

res = 0
for a in product(*[[0,1],]*(l-1)):
    c = 0
    st = S[0]
    for i, b in enumerate(a, start=1):
        if b == c:
            st += S[i]
        else:
            res += int(st)
            st = S[i]
        c = b
    res += int(st)

print(res)

Submission status: Accepted

Solution code:
s0 = input()
def convert(n, m):
  ans = ""
  while n > 0:
    amari = n % m
    ans += str(amari)
    n //= m
  return ans
n = len(s0) - 1
SUM = int(s0)
for i in range(1, 2**n):
  s1 = " ".join(list(s0))
  i = convert(i, 2)
  list_index = []
  for j in range(len(i)):
    list_index.append(i.find("1", j))
  list_index = list(set([x for x in list_index if x != -1]))
  for k in list_index:
    s1 = s1[:2*k+1] + "+" + s1[2*(k+1):]
  s1 = s1.replace(" ", "")
  sum_list = list(map(int, s1.split("+")))
  SUM += sum(sum_list)
print(SUM)

Submission status: Accepted

Solution code:
from collections import deque

def main():
    N = list(input())
    Nq = deque(N)
    anstmp = []
    ans = 0

    for bit in range(2**(len(N) - 1)):
        for i in range(len(N)):
            anstmp.append(str(Nq.popleft()))
            if ((bit >> i) & 1): 
                anstmp.append("+")
        # print("".join(anstmp))
        ans += eval("".join(anstmp))

        Nq = deque(N) 
        anstmp = []  

    print(ans)
    
        

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = input() #l桁の数字を文字列型で入力
l = len(S) # 文字列の長さ
n = l - 1 # 文字列の間の数
ans = 0
for bit in range(1 << n): # 0から((1をnだけ右シフトした数)-1)までのfor文
    s = S[0]
    for i in range(n):
        if (bit & (1 << i)):
            s += '+'
        s += S[i+1]
    ans += sum(map(int, s.split('+')))
print(ans)

Submission status: Accepted

Solution code:
# ume 20/06/21
def dfs(s, seq, res):
  if len(s)==0: return
  for i in range(1, len(s)):
    seq.append(int(s[:i]))
    res[0] += sum(seq) + int(s[i:])
    dfs(s[i:], seq, res)
    seq.pop()
    

S = input()
seq = []
res = [int(S)]
dfs(S, seq, res)
print(res[0])

Submission status: Accepted

Solution code:
def main():
  # S = list(input())
  S = input()

  sum_ = 0
  for bit in range(1 << len(S)-1):
    pre = 0
    for i in range(len(S)-1):
      mask = 1 << i
      if (bit & mask):
        # print(S[pre:i+1])
        sum_ += int(S[pre:i+1])
        pre = i+1
      # print('bit:', bin(bit))
      # print('mask', bin(mask))
    # print(S[pre:])
    sum_ += int(S[pre:])
  print(sum_)


if(__name__ == '__main__'):
  main()

Submission status: Accepted

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

def a(t,i):
    if i==l-1:
        return sum(map(int,t.split("+")))
    return a(t+s[i+1],i+1)+a(t+"+"+s[i+1],i+1)

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

Submission status: Accepted

Solution code:
def a(t,i):
    if i == l-1:
        return sum(map(int,t.split("+")))
    return a(t+s[i+1],i+1)+a(t+"+"+s[i+1],i+1)
s = input()
l = len(s)
print(a(s[0],0))

Submission status: Accepted

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

import os
import sys
import itertools


# atcoder.main
# Date: 2020/06/20
# Filename: main 
# Author: acto_mini

def splitter(str):
    for i in range(1, len(str)):
        start = str[0:i]
        end = str[i:]
        yield (start, end)
        for split in splitter(end):
            result = [start]
            result.extend(split)
            yield result


def main():
    S = input()
    A = list(splitter(S))

    ans = int(S)
    for i in range(len(A)):
        for j in range(len(A[i])):
            ans += int(A[i][j])

    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from itertools import product
s = input()
op = list(product(["", "+"], repeat=len(s)))
op = [a for a in op if not a[-1] == "+"]
ans = 0
for q in op:
    e = ""
    for w in range(len(q)):
        e += s[w] + q[w]
    ans += eval(e)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
S=input()
S_seq=[]
for i in S:
    S_seq.append(i)
if(len(S_seq)==1):
    print(int(S))
    sys.exit()
separate=[]
for i in range(len(S_seq)-1):
    a=[]
    if(i==0):
        a.append("*")
        a.append("_")
    else:
        for j in separate:
            a.append(j+"*")
            a.append(j+"_")
    separate=a

separated=[]
for i in separate:
    a=[]
    for j in i:
        a.append(j)
    separated.append(a)

pre_calculated=[]
for i in separated:
    a=[]
    for j in range(len(S_seq)-1):
        a.append(S_seq[j])
        if(i[j]=="*"):
            a.append("+")
        elif(i[j]=="_"):
            continue
    a.append(S_seq[-1])
    pre_calculated.append(a)

sumation=0
for i in pre_calculated:
    number=[]
    for j in range(len(i)):
        new_number=[]
        if(j==len(i)-1):
            for k in number:
                sumation+=k*10
            sumation+=int(i[j])
        elif(i[j]=="+"):
            for k in number:
                sumation+=k
            number=[]
        else:
            for k in number:
                new_number.append(k*10)
            new_number.append(int(i[j]))
        
        number=new_number
print(sumation)

Submission status: Accepted

Solution code:
s=list(input())
ans=[]
for i in range(1<<(len(s)-1)):
    tmp=0
    num=s[0]
    for j in range(len(s)-1):
        if (i>>j)%2==0:
            num+=s[j+1]
        else:
            tmp+=int(num)
            num=s[j+1]
        #print(num)
    tmp+=int(num)
    ans.append(tmp)
print(sum(ans))

Submission status: Accepted

Solution code:
def main():
    S = input()
    ans = 0
    for n in range(2**(len(S)-1)):
        fig = S[0]
        index = 1
        for _ in range(len(S)-1):
            if n % 2:
                fig += "+"+S[index]
            else:
                fig += S[index]
            n >>= 1
            index += 1
        ans += eval(fig)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

s = input()

s_list = list(s)
operator_box = list(range(len(s_list) - 1))
operators = dict(zip(operator_box, list(map(lambda x: False, operator_box))))

result = 0

# あるオペレータの組み合わせにおける数の和を出す
def calc(nums, operators):
    sums = 0
    _index = 0
    for index, operator in operators.items():
        if operator:
            if _index == index:
                chars = [nums[_index]]
            else:
                chars = nums[_index: int(index) + 1]

            _index = int(index) + 1
            number = ''.join(chars)
            sums += int(number)

    chars = nums[_index:]
    sums += int(''.join(chars))
    return sums

length = len(operators)

for i in range(2 ** length):
    _operators = operators
    for j in range(length):
        if ((i >> j) & 1):
            _operators[length - 1 - j] = True
        else: 
            _operators[length - 1 - j] = False

    result += calc(s_list, _operators)

print(result)

Submission status: Accepted

Solution code:
import sys, re
from math import ceil, floor, sqrt, pi, factorial#, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    s = s_input()

    count = 0
    for bit in list(product([0,1], repeat=len(s)-1)):
        eval_s = s[0]
        for i in range(len(bit)):
            if bit[i] == 1:
                eval_s += '+'
            eval_s += s[i+1]
        count += eval(eval_s)

    print(count)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

total = 0
#digit loop
for b in range(2**n):
    nums = []
    index = 0
    #bit loop / looking for plus location until number of digit
    for i in range(n):
        if ( b & (1 << i) ):
            nums.append(int(s[index:i+1]))
            index = i+1
    nums.append(int(s[index:]))
    total = total + sum(nums)
print(total)

Submission status: Accepted

Solution code:
# ARC061A

import itertools

s = list(input())
n = len(s)
bin = list(itertools.product(['', '+'''], repeat=n - 1))
count = 0
for i in bin:
    t = []
    for j in range(n-1):
        t.append(s[j])
        t.append(i[j])
    t.append(s[-1])
    formula = ''.join(t)
    # print(t)
    count += eval(formula)
print(count)

Submission status: Accepted

Solution code:
S = input()
ans = 0
for i in range(2 ** (len(S) - 1)):
    txt = S[0]
    for j in range(len(S) - 1):
        if i >> j & 1:
            txt += " " + S[j + 1]
        else:
            txt += S[j + 1]
    ans += sum(list(map(int, txt.split())))
print(ans)

Submission status: Accepted

Solution code:
from itertools import product

a=list(input())
sum=0
text=""
for i in product(["","+"],repeat=len(a)-1):
    text=""
    for j in range(len(a)-1):
        text+=a[j]+i[j]
    text+=a[len(a)-1]
    sum+=eval(text)
print(sum)

Submission status: Accepted

Solution code:
s=input()
m=len(s)
sm=0
for i in range(2**(m-1)):
  a=list(str(bin(i)))[::-1]
  b=list(s)
  for j in range(len(a)-1,-1,-1):
    if a[j]=='1':
      b.insert(-j-1,'+')
  sm+=eval(''.join(b))
print(sm)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
s = input()
l = len(s)-1
ans = 0
ops = []

# +あり/なしのbit全探索(桁数-1の2乗の範囲)
for i in range(1 << l):
    op = [''] * l
    for j in range(l):
        if ((i >> j) & 1) == 1:
            op[l-1-j] = '+'
    ops.append(op)

for op in ops:
    num = [digit for digit in s]
    for k in range(len(op)):
        # 演算子は奇数番目
        num.insert(2*k+1, op[k])
    ans += eval(''.join(num))

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
s = input()
l = len(s)-1
ans = 0
ops = []

# +あり/なしの全探索のため、桁数-1の2乗
for i in range(2**l):
    op = [""] * l
    for j in range(l):
        if ((i >> j) & 1) == 1:
            op[l-1-j] = "+"
    ops.append(op)

for o in ops:
    str = [str for str in s]
    for k in range(len(o)):
        str.insert(2*k+1, o[k])
    ans += eval(''.join(str))

print(ans)

Submission status: Accepted

Solution code:
FS, *S = input()
L = len(S)
ans = 0
for bit in range(1 << L):
    tmp = FS
    f = []
    for i, s in enumerate(S):
        if bit >> i & 1:
            f.append(tmp)
            tmp = s
        else:
            tmp += s
    f.append(tmp)
    ans += sum(map(int, f))
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
S = input()

n = len(S)

sum_formula = 0
# bit全探索
for bit in range(2 ** (n-1)):
    nums = []
    # 何ビットシフトさせるか
    num = S[0]
    for shift in range(n-1):
        if not ((bit >> shift)&1):
            num = num + S[shift+1]
        else:
            nums.append(int(num))
            num = S[shift+1]
    nums.append(int(num))
    sum_formula += sum(nums)

print(sum_formula)


# 再帰関数
def calc_all_formula(S, i, lists):
    '''
    listsの要素: ([数字list], temp_str)
    '''
    new_lists = []
    # i - i+1番目の間に+が入る
    new_lists.extend(
        [(lst[0]+[int(lst[1])], S[i+1]) for lst in lists]
    )
    new_lists.extend(
        [(lst[0], lst[1]+S[i+1]) for lst in lists]
    )

    # base case
    if i == len(S)-2:
        new_lists = [
            lst[0]+[int(lst[1])] for lst in new_lists
        ]
        return new_lists
    
    return calc_all_formula(S, i+1, new_lists)

# base_cand = [([], S[0])]

# if len(S) >= 2:
#     sum_formula = sum([sum(lst) for lst in calc_all_formula(S, 0, base_cand)])
#     print(sum_formula)
# else:
#     print(int(S))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
s = list(input())
n = len(s)-1
trueans = []
for i in range(2**n):
    bag = []
    for j in range(n):
        bag.append(s[j])
        if (i>>j) & 1:
            bag.append("+")
    bag.append(s[-1])
    bag.append("+")
    kai = ""
    ans = []
    if "+" in bag:
        for j in bag:
            if j != "+":
                kai += j
            else:
                ans.append(int(kai))
                kai = ""
    trueans.append(sum(ans))
print(sum(trueans))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = input()
n = len(s)
 
ans = 0
 
for bit in range(2 ** (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)