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

n = len(S)
s = []
for c in S:
    s.append(c)

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

    operator.append(op)

F = []
for op in operator:
    f = "".join(a+b for a, b in zip(s,op))
    F.append(f.split('+'))

res = 0
for elem in F:
    sum_elem=0
    for i in elem:
        sum_elem+=int(i)
    res += sum_elem

print(res)

Submission status: Accepted

Solution code:
S = input()
N = len(S)
ans = 0
for i in range(1 << (N - 1)):
    tmp = 0
    for j in range(N):
        if i & 1 << j:
            tmp = tmp * 10 + int(S[j])
            ans += tmp
            tmp = 0
        else:
            tmp = tmp * 10 + int(S[j])

    ans += tmp

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
S = input()
s = ''
for c in S:
    s += c
    s += '+'
s = s[:-1]

result = eval(s)
memo = [s]
for i in range(len(S)):
    for ss in memo:
        cache = []
        for j in range(1,len(ss)):
            if ss[j] == '+':
                kouho = ss[:j] + ss[j+1:]
                if not kouho in memo:
                    result += eval(kouho)
                    cache.append(kouho)
        memo.extend(cache)

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

S = input()
t = len(S)-1
ans = 0

for i in range(2**t):
    p = bin(i)[2:]
    p = "0"*(t-len(p))+p
    x = ""

    for j, k in enumerate(S):
        x += k
        if j != t and p[j] == "1":
            x += "+"
    # print(x)
    ans += eval(x)
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
S = list(map(int, input()))
s = 0
ta = 0
for i in range(2 ** (len(S) - 1)):
    t = 0
    for j in range(len(S) - 1):
        ta = S[j]
        if (i >> j) & 1:
            s += ta + t * 10
            t = 0
        else:
            t = t * 10 + ta
    s += t * 10 + S[len(S) - 1]
print(s)

Submission status: Accepted

Solution code:
def main():
    s = input()
    ops = [i for i in range(len(s) - 1)]

    powset = []
    for i in range(1 << len(ops)):
        powset.append([ops[j] for j in range(len(ops)) if ((i >> j) & 1) == 1])

    # print(powset)

    expressions = []
    for places in powset:
        f = ''
        for i, char in enumerate(s):
            if i in places:
                f += char + '+'
            else:
                f += char
        expressions.append(f)

    # print(expressions)

    total = sum(map(eval, expressions))
    print(total)


main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import product

S = input()
ans = 0
for i in product(['+', ''], repeat=len(S)-1):
    ans += eval("".join([S[s] + i[s] for s in range(len(S)-1)] + [S[len(S)-1]]))
print(ans)

Submission status: Accepted

Solution code:
import itertools as itr
S = input().rstrip()

ans = 0
for param in range(2**(len(S)-1)):
	tmp = ""
	for i in range(len(S)):
		tmp += S[i]+ ["","+"][((param >> i)&1) if i != len(S)-1 else 0]
	ans += eval(tmp)

print(ans)

Submission status: Accepted

Solution code:
def sumS(s):
  L = []
  if len(s) == 1:
    L.append(s)
  else:
    for formula in sumS(s[1:]):
      L.append(s[0] + "+" + formula)
      L.append(s[0] + formula)
  return L

S = input()
result = 0
for formula in sumS(S):
  result += eval(formula)

print(result)

Submission status: Accepted

Solution code:
s = input()
n = len(s)
a=[0] #aはiのフラグが立っている位置、sのスライスのために使う
sum = 0
if n == 1:
    print(s)
else:
    for i in range(2 ** (n-1)): # iは二進数表記にしたとき隙間に+を入れるかどうかのフラグ
        for j in range(n-1):
            if i >> j & 1: a.append(j+1) # 二進数表記iをj右にシフトしフラグが立っているかどうか判断しその位置をaに加える
        else:
            a.append(n)
            for k in range(len(a)-1):
                sum += int(s[a[k]:a[k+1]])
            else:
                a = [0]
    else:
        print(sum)

Submission status: Accepted

Solution code:
import itertools

def calcsum(s, ary):
    converted = ''
    for i, d in enumerate(s):
        converted += d
        if i in ary:
            converted += '+'
    return eval(converted)


def sumup(s):
    count = 0
    for n in range(len(s)):
        for lst_index_pos in itertools.combinations(range(len(s) - 1), n):
            count += calcsum(s, lst_index_pos)

    return count


s = input()
print(sumup(s))

Submission status: Accepted

Solution code:
S=[int(i) for i in input()]
ans=0
for x in range(1<<len(S)-1):
    a=S[0]
    for n in range(len(S)-1):
        if x>>n & 1:
            ans+=a
            a=0
        a = a * 10 + S[n+1]
    ans += a
print(ans)

Submission status: Accepted

Solution code:
s=input()
ans=0

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

for i in range(2 ** (len(s)-1)):
  bin_i = bin(i)[2:].rjust(len(s)-1,"0")
  li=[]
  n=s[0]
  for ix,sign in enumerate(bin_i):
    if sign=="0":
      n+=s[ix+1]
    else:
      li.append(int(n))
      n=s[ix+1]
  li.append(int(n))
  ans+=sum(li)

print(ans)

Submission status: Accepted

Solution code:
s  = str(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] = '+'
  # print(op)
  op = op + ['']
  formula = ''
  for s_, p_ in zip(list(s), op):
      formula += s_ + p_
  ans += eval(formula)
print(ans)

Submission status: Accepted

Solution code:
#ABC 045 C たくさんの数式
S = [int(i) for i in list(input())]

sum = 0
for i in range(2**(len(S)-1)):
  a = S[0]
  for j in range(len(S)-1):
    if (i >> j) & 1:
      sum += a
      a = 0
      
    a = a * 10 + S[j+1]
  sum += a
print(sum)

Submission status: Accepted

Solution code:
def dfs(i,sep,s,tot):
    n = len(s)
    i += 1

    # 最深部まで到達した時
    if i == n:
        ans = 0
        if len(sep)>1:
            for j in range(len(sep)-1):
                ans += int(s[sep[j]:sep[j+1]])
        ans += int(s[sep[-1]:])
        return ans

    # i番目に+を入れる時
    sep.append(i)
    tot += dfs(i,sep,s, 0)

    # i番目に+を入れない時
    sep.pop()
    tot += dfs(i,sep,s, 0)

    return tot

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

Submission status: Accepted

Solution code:
s = input()
len_s = len(s)
ans=0
def dfs(x,len_x,i=0):
        global ans
        if i < len_x:
                dfs(x,len_x,i=i+1)
                x=x[:i+1] + "+" + x[i+1:]
                dfs(x,len_x + 1,i=i+2)
                ans+=sum([int(k) for k in x.split("+")])
dfs(s,len_s-1)
print(ans+int(s))

Submission status: Accepted

Solution code:
ans=0
def dfs(x,len_x,i=0):
        global ans
        if i < len_x:
                dfs(x,len_x,i=i+1)
        if i < len_x:
                x=x[:i+1] + "+" + x[i+1:]
                dfs(x,len_x + 1,i=i+2)
                ans+=sum([int(k) for k in x.split("+")])
        
s = input()
dfs(s,len(s)-1)
print(ans+int(s))

Submission status: Accepted

Solution code:
ans=0
def dfs(x,len_x,i=0):
        global ans
        if i < len_x:
                dfs(x,len_x,i=i+1)
        if i < len_x:
                x=x[:i+1] + "+" + x[i+1:]
                dfs(x,len_x + 1,i=i+2)
                ans+=sum([int(k) for k in x.split("+")])
        if i == len_x:
                return sum([int(k) for k in x.split("+")])

        else:
                return 0
s = input()
dfs(s,len(s)-1)
print(ans+int(s))

Submission status: Accepted

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

S = input()
sl = list(S)
ans = 0
for i in range(1 << len(S)): # 階乗(1,2,4,8...)
    string = str(0)
    tmp = 0
    for j in range(len(S)):
        if ((i >> j) & 1) == 1: # j,j+1桁目の間が+なら
            tmp+=int(string)
            string = "0"
        else:
            string += str(S[j])
    tmp=tmp+int(string)
    ans+=tmp
print(ans)

Submission status: Accepted

Solution code:
s = list(input())

ans = 0
for i in range(1 << len(s) - 1):
  ans += eval(s[0] + "".join(("+" if i >> j & 1 else "") + x for j, x in enumerate(s[1:])))
print(ans)

Submission status: Accepted

Solution code:
S = raw_input()
n = 1
for i in range(0, len(S)-1):
	n = n * 2
lstlst = []
for i in range(0, n):
	lst = []
	m = i
	for j in range(0, len(S)-1):
		if m%2 == 1: lst.append(True)
		else: lst.append(False)
		m = m/2
	lstlst.append(lst)
sum = 0
for i in range(0, n):
	tmp = S[0]
	a = 0
	for j in range(0, len(S)-1):
		if lstlst[i][j]:
			a += int(tmp)
			tmp = S[j+1]
		else:
			tmp = tmp + S[j+1]
	sum += a + int(tmp)

print sum

Submission status: Accepted

Solution code:
S = list(input())
ans = 0

for state in range(1 << len(S)-1):
    ans += eval(S[0] + ''.join(('+' if state >> i & 1 else '') + x for i, x in enumerate(S[1:])))

print(ans)

Submission status: Accepted

Solution code:
S = [int(x) for x in list(input())]
ans = 0

for i in range(2**(len(S)-1)):
    dig = 0
    for j in range(len(S)-1):
        if int(i/(2**j)) % 2 == 0:
            dig += 1
        else:
            dig = 0
        ans += S[-j-2] * (10**dig)

ans += S[-1]*(2**(len(S)-1))
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
#S = str(input())
S = str(input())
N = len(S) - 1

def honyaku(ini,n):
    ans = np.zeros(n)
    for i in range(n-1,-1,-1):
        ans[i] = ini % 2
        ini = ini // 2
    return ans

def sum_list(list_domain,list_S):
    tmp = list_S[0]
    ans = 0
    for i in range(len(list_domain)):
        if list_domain[i] == 0:
            tmp = tmp*10 + list_S[i+1]
        else:
            ans += tmp
            tmp = list_S[i+1]
    return tmp + ans

list_S = np.zeros(N+1)
for i in range(N+1):
    list_S[i] = int(S[i])
ans = 0    
for i in range(2**N):
    list_domain = honyaku(i,N)
    ans += sum_list(list_domain,list_S)
    
print(int(ans))

Submission status: Accepted

Solution code:
s = input()
ans = 0
memo = []
for i in range(1 << len(s) -1):
    tmp = s[0]
    for j in range(len(s)-1):
        if ((i >> j) & 1):
            tmp+="+"
        tmp += s[j+1]
    if tmp not in memo:
        ans+=eval(tmp)
        memo.append(tmp)
print(ans)

Submission status: Accepted

Solution code:
S = input()
addition = 0
for i in range(2 ** (len(S)-1)):
    a = ''.join([c + ('+' if j < len(S)-1 and (i & 2 ** j == 2 ** j) else '') for j, c in enumerate(S)])
    for k in a.split('+'):
        addition += int(k)
print(addition)

Submission status: Accepted

Solution code:
S = input()

ans = 0
memo = []
for i in range(1 << len(S)-1):
  tmp = S[0]
  for j in range(len(S)-1):
    if ((i >> j) & 1) == 1:
      tmp += "+"
    tmp += S[j+1]
  if tmp not in memo:
    ans += eval(tmp)
    memo.append(tmp)
print(ans)

Submission status: Accepted

Solution code:
import sys
# import bisect
# import math
# import itertools
# import numpy as np
# import collections

"""Template"""


class IP:
    """
    入力を取得するクラス
    """

    def __init__(self):
        self.input = sys.stdin.readline

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

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

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

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

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

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

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

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

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

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

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

    def S(self, s, r=0, m=-1):
        """
        ソート関係行います。色々な設定あります。
        :param s: 元となるリスト
        :param r: reversするかどうか 0=False 1=True
        :param m: （2次元配列）何番目のインデックスのソートなのか
        :return: None
        """
        r = bool(r)
        if m == -1:
            s.sort(reverse=r)
        else:
            s.sort(reverse=r, key=lambda x: x[m])

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

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

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x // y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)

    def gcd(self, x, y):
        if y == 0:
            return x
        else:
            return self.gcd(y, x % y)


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


def main():
    # 1文字に省略
    r, e, p = range, enumerate, print
    ip = IP()
    id = Idea()
    mod = 10 ** 9 + 7

    """この下から書いてね"""
    s = str(ip.I())
    ans = 0
    for i in r(1 << len(s) - 1):
        output = 0
        res = 0
        for j in r(len(s) - 1):
            if (i >> j) & 1:
                output += int(s[res:j + 1])
                res = j + 1
        output += int(s[res:len(s)])
        ans += output
    p(ans)


main()

Submission status: Accepted

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

s = list(input())
n = len(s)
can = []

def dfs(i,left,sum):
    if i + 1 == n:
        sum += int("".join(s[left:]))
        can.append(sum)
        return
    dfs(i + 1,left,sum)
    dfs(i + 1,i + 1,sum + int("".join(s[left:i+1])))
    return

dfs(0,0,0)
print(sum(can))

Submission status: Accepted

Solution code:
S = input()

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
S=input()
if len(S)==1:
    print(S)
else:
    bs=[bin(i)[2:].zfill(len(S)-1) for i in range(2**(len(S)-1))]
    operators=[['' if b[i]=='0' else '+' for i in range(len(S)-1)] for b in bs]
    formulas=[''.join([S[j]+operator[j] for j in range(len(S)-1)])+S[-1] for operator in operators]
    print(sum([eval(formula) for formula in formulas]))

Submission status: Accepted

Solution code:
import itertools

S = input()

total = 0
prev = 0
for p in itertools.product([False, True], repeat=len(S)-1):
    prev = 0
    for i in range(len(p)):
        if p[i]:
            total += int(S[prev:i+1])
            prev = i+1
    total += int(S[prev:])

if total == 0:
    total = int(S)
print(total)

Submission status: Accepted

Solution code:
s=input()
l=len(s)
ans=0
for i in range(1<<( l-1)):
    res=0
    tmp=int(s[0])
    for j in range(l-1):
        if ((i>>j) & 1) == 1:
            res+=tmp
            tmp=int(s[j+1])
        else:
            tmp=tmp*10+int(s[j+1])
    res+=tmp
    ans+=res
print(ans)

Submission status: Accepted

Solution code:
S = input()
ans = 0
for i in range(1<<(len(S)-1)):
    li = []
    last = 0
    for j in range(len(S)-1):
        if((i>>j & 1)==1):
            li+=[int(S[last:j+1])]
            last = j+1
    if(last!=len(S)):
        li+=[int(S[last:])]
    ans += sum(li)
print(ans)

Submission status: Accepted

Solution code:
def DepthFirst_search(S,pre) :
    global out
    #print(pre)
    #print(out)
    if len(S) == 1 :
        for i in range(len(pre)) :
            if i == len(pre)-1 :
                out += pre[i]*10 + int(S[0]) + pre[i] + int(S[0])
            else :
                out += 2*pre[i]
        return False

    pre.append(int(S[0]))
    if DepthFirst_search(S[1:len(S):],pre) :
        return False
    pre.pop()
    if len(pre) != 0:
        pre.append(pre.pop()*10 + int(S[0]))
        if DepthFirst_search(S[1:len(S):],pre):
            return False

    return False

out = 0
pre = []
S = input()
if len(S) == 1:
    out = int(S[0])
else :
    DepthFirst_search(S,pre)

print(out)

Submission status: Accepted

Solution code:
S = input()
result = 0

for i in range(1 << (len(S)-1)):
	k = 0
	T = 0
	for j in range(len(S)):
		if ((i >> j) & 1) == 1:
			T += int(S[k:j+1])
			k = j+1
	T += int(S[k:len(S)])
	result += T
print(result)

Submission status: Accepted

Solution code:
S = list(str(input()))
s = [i for i in range(2*len(S)-1) if i % 2 == 1]
ans = 0
for i in range(1 << len(s)):
    L = [S[(i+1)//2] if i % 2 == 0 else "" for i in range(2*len(S)-1)]
    output = []
    for j in range(len(s)):
        if ((i >> j) & 1) == 1:
            output.append(s[j])
    for i in range(len(L)):
        if i in output:
            L[i] = "+"
    ans += eval("".join(L))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

ans = 0

for i in range(2**(len(S)-1)):
    p = [0]
    for j in range(len(S)-1):
        if (i>>j)&1:
            p.append(j+1)
    p.append(len(S))
    
    for l,r in zip(p[:-1],p[1:]):
        ans += int(S[l:r])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#[全部作る]
s = input() 
S = [_ for _ in s]
N = len(S)-1
ans_lis = []
pra_lis = []
calis = []
for x in range(2**N):
    lis = [''] * (N)
    for y in range(N):
        if((x >> y) & 1):
            lis[N-1-y] = "+"
    pra_lis.append(lis)
for z in pra_lis:
    z.append('')
    for x in range(len(S)):
        calis.append(S[x])
        calis.append(z[x])
 #   print('calis',calis)
    calis = []
    ans_lis.append(calis)
ans = 0
for l in ans_lis:
    ans_num = '0'
    for r in l:
        if r == '':
            pass
        elif r == '+':
            ans += int(ans_num)
         #   print(ans_num)
            ans_num = '0'
        else:
            ans_num += r
        #print(ans_num)
    ans += int(ans_num)
print(ans + int(s))

Submission status: Accepted

Solution code:
S = input()

N = len(S)-1
sumsum = 0


for i in range(2**N):
    binary = bin(i)
    binary = binary[2:].zfill(N)
    
    tmps = S[0]
    for j in range(N):
        if binary[j] == '0':
            tmps = tmps + S[j+1] 
        else :
            sumsum += int(tmps)
            tmps = S[j+1]

    sumsum += int(tmps)

if N == 0:
    sumsum = int(S)

print(sumsum)

Submission status: Accepted

Solution code:
from itertools import product
S = input()
s_len = len(S)
output=0
l_plus=[]
for i in range(s_len-1):
    l_plus.append(S[i])
    l_plus.append("")
l_plus.append(S[s_len-1])
for l in product(["", '+'],repeat=s_len-1):
    for i in range(s_len-1):
        l_plus[2*i+1]=l[i]
    output+=eval("".join(l_plus))
print(output)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from itertools import product
s = list(input())
n = len(s)
x = []
for i in range(n-1):
    x.append(s[i])
    x.append("")
x.append(s[n-1])

res = 0
for l in product(["","+"],repeat=n-1):
    for i in range(n-1):
        x[2*i+1] = l[i]
    res += eval("".join(x))
print(res)

Submission status: Accepted

Solution code:
s=str(input())
slist=list(s)

cnt=len(s)-1
ans=0
for i in range(2**cnt):
    ln = [""]*cnt
    tlist=list(slist)
    for j in range(cnt):
        if ((i>>j)&1):
            ln[cnt-j-1]="+"
    for k in range(len(s)-1):
        tlist.insert(k*2+1,ln[k])
    ans+=sum(list(map(int,"".join(tlist).split("+"))))
print(ans)

Submission status: Accepted

Solution code:
from collections import deque
S=input()
queue=deque()
lst=[]
lst.append([0,0])
for i in range(0,len(S)):
    l=len(lst)
    for _ in range(l):
        x,y=lst.pop(0)
        lst.append([x,y*10+int(S[i])])#plus
        lst.append([x+y*10+int(S[i]),0])
l=len(lst)
for _ in range(l):
    x,y=lst.pop(0)
    lst.append(x+y)
print(int(sum(lst)/2))

Submission status: Accepted

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

total = [0] * (l + 1)
count = [1] * (l + 1)

for i in range(l - 1, -1, -1):
    total[i] = sum(int(s[i:j]) * count[j] + total[j] for j in range(i + 1, l + 1))
    count[i] = sum(count[j] for j in range(i + 1, l + 1))

print(total[0])

Submission status: Accepted

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

for i in range(1<<(len-1)):
    temp = [c for c in S]
    plus = 0
    for j in range(len-1):
        if ((i>>j) & 1) == 1:
            temp.insert(j+1+plus, '+')
            plus += 1
    ans += eval("".join(temp))

print(ans)

Submission status: Accepted

Solution code:
import copy
s = list(input())
t = []
t.append(s[0])
for i in range(1,len(s)):
    t.append('+')
    t.append(s[i])
# print(t)
# print(''.join(t))

sum = 0
for i in range(1 << (len(s)-1)):
    tmp = copy.deepcopy(t)
    for j in range(len(s)):
        if ( i >> j & 1 ):
            # print(j)
            tmp[(j+1)*2-1] = ''
            # print(eval(''.join(tmp)))
    sum += eval(''.join(tmp))
    # print(tmp)
    # print('loop end')
print(sum)

Submission status: Accepted

Solution code:
s = input()
space = len(s) - 1
total = []
for i in range(2 ** space):
    pluses = [''] * space
    for j in range(space):
        if (i >> j) & 1:
            pluses[j] = '+'
    re = ''
    for a, b in zip(s, pluses + ['']):
        re += (a + b)
    total.append(eval(re))
ans = sum(total)
print(ans)

Submission status: Accepted

Solution code:
S = input()
goukei = 0

for i in range(1 << len(S) - 1):
    f = ""
    for j in range(len(S) - 1):
        f += S[j]
        if (i >> j) & 1:
            f += '+'
    goukei += eval(f + S[-1])

print(goukei)

Submission status: Accepted

Solution code:
s = input()
op_cnt = len(s) - 1
ans = []
for i in range(2**op_cnt):
    op = ['']*op_cnt
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = '+'
    f = s[0]
    for p, q in zip(op, s[1:]):
        f += p + q
    ans.append(f)
sums = 0
for i in ans:
    sums += eval(i)
print(sums)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import copy

def main():
	S = input()
	S = list(S)
	length = len(S)
	
	con = []
	for i in range(2 ** (length-1)):
		tmp = []
		for j in range(length):
			if (i >> j) & 1 == 1:
				tmp.append("+")
			else:
				tmp.append("")
		con.append(tmp)
	
	ans = 0
	for i, val in enumerate(con):
		counts = 0
		tmp = copy.deepcopy(S)
		for j, vol in enumerate(val):
			if vol == "+":
				counts += 1
				tmp.insert(j + counts, "+")
				
		lin = "".join(tmp)
		lin = lin.split("+")
		for i in lin:
			ans += int(i)
	
	print(ans)
	
if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
import itertools
S = input()
N = len(S)
A = [0,1]
ans = 0
plus = []
for i in itertools.product(A, repeat = N-1):
    plus.append(i)
for op in plus:
    eq = S
    for index in range(N-1):
        if op[index] == 1:
            eq = eq[:N-index-1] + ',' +eq[N-index-1:]
    eq = eq.split(',')
    le = len(eq)
    for i in range(le):
        ans += int(eq[i])
print(ans)

Submission status: Accepted

Solution code:
n=input()
anslist=[]

def saiki(n,x,a,k):
    if k==len(n):
        anslist.append(eval(x))
        return
    else:
        for i in a:
            y=x
            x=x+i+n[k]
            saiki(n,x,a,k+1)
            x=y       

saiki(n,n[0],['','+'],1)
print(sum(anslist))

Submission status: Accepted

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

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

    formula = ""
    for p_S, p_o in zip(S, op + [""]):
        formula += (p_S + p_o)

    ResSum += eval(formula)

print(ResSum)

Submission status: Accepted

Solution code:
S=input()

ans=0

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

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
def main(S):
    sum = 0
    for i in range(1 << (len(S)-1)):
        res = S[0]
        for j in range(len(S)-1):
            if((i >> j) & 1):
                res += "+"
            res += S[j+1]    
        sum += eval(res)
    print(sum)
            
if(__name__ == "__main__"):
    S = list(input())
    
    main(S)

Submission status: Accepted

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

ans=0
mylist=list(itertools.product('01',repeat=length-1))

for j in range(len(mylist)):
    tmp=s[0]
    for i in range(length-1):
        if mylist[j][i]=='1':
            tmp+="+"+s[i+1]
        else:
            tmp+=s[i+1]
    tmp=eval(tmp)
    ans+=tmp
print(ans)

Submission status: Accepted

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

ans = 0
for i in range(2**(n-1)):
    L = []
    for i,c in enumerate(bin(i)[2:].zfill(n)):
        if c == '1':
            L.append(i)
    L.append(n)
    S_ = []
    l_prev = 0
    for l in L:
        S_.append(int(S[l_prev:l]))
        l_prev = l
    ans += sum([int(s_) for s_ in S_])

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())
sum = 0
for i in range(2 ** (len(s)-1)):
  st = str(s[0])
  for j in range(len(s)-1):
    if (i >> j) & 1:
      st = st + "+" + str(s[j+1])
    else:
      st = st + str(s[j+1])
      
  for item in st.split('+') :
    sum += int(item)
print(sum)

Submission status: Accepted

Solution code:
S = list(input())
n = len(S)
def dfs(count,s):
    if count == n:
        # 最後に数式を足す
        return eval(s)
    # + を挟むか否か
    plus = dfs(count+1, s+'+'+S[count]) #挟んだ場合
    nothing = dfs(count+1, s+S[count])  #挟まない場合
    return plus + nothing

print(dfs(1,S[0]))

Submission status: Accepted

Solution code:
S = input()
l = len(S)
ans = 0
for i in range(2 ** (l - 1)):
    tmp = ''
    for j, c in enumerate(S):
        tmp += c
        if i & (1 << j):
            tmp += '+'
    ans += eval(tmp)
print(ans)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc045/tasks/arc061_a
s = input()
if len(s) == 1:
    print(s)
    exit()
o = []
sum = 0
for i in range(1 << len(s) - 1):
    bit = format(i, "0" + str(len(s) - 1) + "b")
    o.append(bit.replace("1", "+").replace("0", " "))
for t in o:
    r = ""
    for s1, s2 in zip(s, t):
        r += (s1 + s2)
    r += s[-1]
    r = r.replace(" ", "")
    sum += eval(r)
print(sum)

Submission status: Accepted

Solution code:
s = input()
s_list = []
for i in range(1 << (len(s) - 1)):
  s_ = ''
  for j in range(len(s) - 1):
    s_ += s[j:j+1]
    if (i >> j) % 2 == 1:
      s_ += '+'
  s_ += s[-1]
  s_list += [s_]

res = 0
for s_ in s_list:
  res += sum(map(int, s_.split('+')))
print(res)

Submission status: Accepted

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


def dfs(count, str):
    if count == N:
        return eval(str)
    plus = dfs(count + 1, str + '+' + S[count])
    noaction = dfs(count + 1, str + S[count])
    return plus + noaction


print(dfs(1, S[0]))

Submission status: Accepted

Solution code:
s = input()
n = len(s)
ans = 0
for i in range(2**(n-1)):
  tmp = ''
  for j, c in enumerate(s):
    tmp += c
    if i&(1<<j):
        tmp+='+'
  ans+=eval(tmp)
print(ans)