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 = [int(x) for x in input()]
count = len(s)-1
wa = 0
for bit in range(2**count):
    hugou = [""] * count
    for i in range(count):
        if (bit >> i) & 1:
            hugou[count-1-i] = "+"
    calc = ""
    for j in range(count):
        calc += str(s[j])
        calc += str(hugou[j])
    calc += str(s[-1])
    wa += eval(calc)
print(wa)

Submission status: Accepted

Solution code:
a=input()
b=[]
c=0
for i in range(len(a)):
  c=a[i]
  b.append(c)
c=int(a)
def s(b):
  cc=1
  for i in range(len(b)):
    if b[i]=="+":
      cc=i
  for i in range(cc,len(b)):
    if b[i-1]!="+" and b[i]!="+":
      ba=b[:i]
      bb=b[i:]
      bc=ba+["+"]+bb
      cc="".join(bc)
      cc=cc.split("+")
      for i in range(len(cc)):
        cc[i]=int(cc[i])
      global c
      c+=sum(cc)
      s(bc)
      
s(b)
print(c)

Submission status: Accepted

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

def culc(string):
    string = list(string)
    digit = []
    prev = 0
    for i, s in enumerate(string):
        if s == "+":
            digit.append(int("".join(string[prev:i])))
            prev = i+1
        if i == len(string)-1:
            digit.append(int("".join(string[prev:])))
    return sum(digit)

SUM = 0
for bit in range(0, 1<<N):
    string = S
    for i in reversed(range(N)):
        if (bit>>i) & 1:
            string = string[:i+1] + "+" + string[i+1:]
    SUM += culc(string)  

print(SUM)

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest

# 再起限界
import sys
sys.setrecursionlimit(4100000)


def resolve():
    original_s = list(sys.stdin.readline().split()[0])
    sum_list = []
    sum_list_append = sum_list.append

    def dfs(s, sum):
        if len(s) == 0:
            sum_list_append(sum)
            return
        if len(s) == 1:
            sum_list_append(sum + int(s[0]))
            return

        dfs(s[1:], sum + int(s[0]))

        dfs([s[0] + s[1]] + s[2:], sum)

    dfs(original_s, 0)
    print(sum(sum_list))


if __name__ == "__main__":
    resolve()


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """125"""
        output = """176"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """9999999999"""
        output = """12656242944"""
        self.assertIO(input, output)

Submission status: Accepted

Solution code:
S = input()
 
cnt = len(S) - 1 #数字の間の数
 
ans = 0
 
for i in range(2 ** cnt):
  sign = [""] * cnt
  for j in range(cnt):
    if ((i>>j)&1):
      sign[j] = "+"
            
  formula = ""      
  for k in range(cnt):
    formula += S[k] + sign[k]
  formula += S[cnt]   
  ans += eval(formula)
print(ans)

Submission status: Accepted

Solution code:
#bit全探索

def solve(S, bitls, bitlslen):
    splited = []
    splitlen = 0
    prev = 0
    for i in range(bitlslen):
        if bitls[i] == 1:
            splited.append(S[prev:i+1])
            prev = i+1
            splitlen += 1
    splited.append(S[prev:])
    splitlen += 1
    
    sum = 0
    for i in range(splitlen):
        sum += int(splited[i])
    return sum


S = input()
lenS = len(S)
#lenS-1箇所だけ+を入れる場所がある -> 2**(lenS-1)回試行
loop = 2**(lenS-1)

ans = 0
for i in range(loop):
    val = i
    bitls = []
    for j in range(lenS-1):
        bitls.append(val % 2)
        val //= 2
    ans += solve(S, bitls, lenS-1)
print(str(ans))

Submission status: Accepted

Solution code:
from copy import deepcopy
N=list(input())
lenn=len(N)-1
cnt=0
for i in range(2**lenn):
    n=deepcopy(N)
    b=(("0"*lenn)+bin(i)[2:])[-lenn:]
    for i in range(lenn-1,-1,-1):
        if b[i]=="1":
            n.insert(i+1,"+")
    cnt+=eval("".join(n))
print(cnt)

Submission status: Accepted

Solution code:
row = input().split()
s = list(row[0])
count = 0
for bit in range(1<<(len(s)-1)):
    S=[]
    S.append(s[0])
    for i in range(len(s)-1):
        if bit & (1<<i):
            S.append("+")
        S.append(s[i+1])
    S = "".join(S)
    S = S.split("+")
    S = list(map(int, S))
    count += sum(S)
print(count)

Submission status: Accepted

Solution code:
S = input()

op_cnt = len(S) - 1#数字の間の数

ans = 0

for i in range(2 ** op_cnt):
  sign = [""] * op_cnt
  for j in range(op_cnt):
    if ((i>>j)&1):
      sign[j] = "+"
       
  formula = ""      
  for k in range(op_cnt):
    formula += S[k] + sign[k]
  formula += S[op_cnt]
  ans += eval(formula)
print(ans)

Submission status: Accepted

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

n = list(input())
op_cnt = len(n) - 1
a = []
li = []
ctr = 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] = "+"
    for p_n, p_o in zip(n, op + [""]):
        a.append(p_n)
        a.append(p_o)
    li = list(map(int, ''.join(a).split("+")))
    ctr += sum(li)
    a.clear()
print(ctr)

Submission status: Accepted

Solution code:
S = input()

ans = 0
lenS = len(S)
divider = lenS - 1  # +を入れることのできる個数

for i in range(1, lenS + 1) :
    now = int(S[-i])
    mask = 0
    for j in range(i) :
        mask *= 10
        mask += now * 2**(max(0,j-1))

    ans += mask * 2**(divider - i + 1)

print(ans)

Submission status: Accepted

Solution code:
S = input()

ans = 0
divider = len(S) - 1  # +を入れることのできる個数

for i in range(1, len(S) + 1) :
    now = int(S[-i])
    mask = 0
    for j in range(i) :
        mask *= 10
        weight = 2**(max(0,j-1))
        mask += now * weight

    count = 2**(divider - i + 1)
    ans += mask * count

print(ans)

Submission status: Accepted

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

total = 0
for i in range(2**N):
    sign = [""] * N
    for j in range(N):
        if ((i >> j) & 1):
            sign[j] = "+"
    
    formula = ""
    for k in range(N):
        formula += S[k] + sign[k]
    formula += S[N]
    total += eval(formula)
print(total)

Submission status: Accepted

Solution code:
s=input()
t=len(s)-1
tmp=2**t
ans=0

for i in range(tmp):
    x = ''
    for j in range(len(s)):
        x += s[j]
        if ((i>>j)&1):
            x+='+'
    ans+=eval(x)
print(ans)

Submission status: Accepted

Solution code:
n=list(input())
k=len(n)-1

x=0
for i in range(2**k):
    v=[""]*k
    for j in range(k):
        if ((i>>j)&1):
            v[j]="+"
    ans=""
    for a,b in zip(n,v+[""]):
        ans+=(a+b)
    x+=eval(ans)
print(x)

Submission status: Accepted

Solution code:
N=input()
X=int(N)
L=len(str(N))
b=X
ch=[0 for i in range(L)]


for i in range (1,L+1):
  ch[-i]=b%10
  b=b//10



A=[[0 for i in range (L)] for j in range (L)]

for i in range (L-1):
  for j in range (L-i):
    A[i][j]=2**(L-i-2)

for i in range(L):
  A[i][L-i-1]=2**(L-i-1)

com=[]

for i in range(L):
  an=0
  for j in range (L):
    an+=A[j][i]*10**(j)
  com.append(an)

ans=0
for i in range(L):
  ans+=com[i]*ch[i]

print(ans)

Submission status: Accepted

Solution code:
s=input()
n=len(s)-1 #隙間の個数
ko=2**n
en=[""]*n
total=0
for i in range(ko):
    en=[""]*n
    for j in range(len(s)):
        if((i>>j)&1)==True:
            en[j]="+"
    formula=""
    for x,y in zip(s,en+[""]):
        formula+=(x+y)
    total+=eval(formula)
print(total)

Submission status: Accepted

Solution code:
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

S = sys.stdin.readline().rstrip()
N = len(S)
# 23:30
# 2**9=512通りなので全探索で

S = list(S)
ans = 0
for ops in itertools.product(['+', ''], repeat=N - 1):
    f = ''
    for c, op in zip(S[:-1], ops):
        f += c + op
    f += S[-1]
    ans += eval(f)
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
import time
import re
import math
import fractions

def main():
    global s
    s=input()
    print(hoge(0,"",0))
def hoge(index,now,total):
    global s
    if(index==len(s)):return total+int(now)
    if index==0:
        return hoge(index+1,now+s[index],total)
    else:
        return hoge(index+1,now+s[index],total)+hoge(index+1,s[index],total+int(now))
start=time.time()
main()
#print("処理速度 {}sec".format(time.time()-start))
#A=list(map(int,input().split()))
#A,B,C=map(int,input().split())
#n=int(input())
# global N,A,B,C,D,memo,mx,mn,temp

Submission status: Accepted

Solution code:
S = input()
N = 2 ** (len(S)-1)
sum = 0
for i in range(0, N):
	m = i
	k = S[0]
	minisum = 0
	for j in range(1, len(S)):
		if m % 2 == 1:
			minisum += int(k)
			k = S[j]
		else:
			k = k + S[j]
		m //= 2
	minisum += int(k)
	sum += minisum
print(sum)

Submission status: Accepted

Solution code:
def dfs(i, total):
    global ans
    if i == len(s)-1:
        ans += eval(total)
        return ans
    dfs(i + 1, total + "+" + s[i+1])
    dfs(i + 1, total + s[i+1])
    
ans = 0
s = input()
dfs(0, s[0])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for bits in range(1 << len(s) - 1):
    check = ''
    for i in range(len(s)):
        if (bits >> i & 1) == 1:
            check += s[i] + '+'
        else:
            check += s[i]
    ans += eval(check)
print(ans)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    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(str(state))
        # print(S[0] + ''.join(('+' if (state >> i & 1) else '')+x for i, x in enumerate(S[1:])))
        # print("------------------")
    print(ans)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    S = list(input())

    answer = 0
    for i in range(2**(len(S)-1)):

        operators = (list(format(i, '0' + str(len(S)-1) + 'b').replace('1', '+').replace('0', ' ')))

        state = S[0]
        for j in range(len(S)-1):
            state += operators[j] + S[j+1]
        state = state.replace(' ', '')

        answer += eval(state)

    print(answer)

Submission status: Accepted

Solution code:
from itertools import product, combinations
S = input()
N = len(S)

cum = 0
for pluses in product((0,1), repeat=N-1):
    sl = S[:]
    for i in range(N-1):
        if pluses[i] == 1:
            sl = sl[:-N+i+1] + '+' + sl[-N+i+1:]
    cum += sum(int(elm) for elm in sl.split('+'))

print(cum)

Submission status: Accepted

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

s = input()
n = len(s)
ans = 0

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

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

    tmp = int(s[0])

    for j in range(n - 1):

        if (i >> j) & 1:
            ans += tmp
            tmp = 0

        tmp = tmp * 10 + int(s[j + 1])

    ans += tmp

print(ans)

Submission status: Accepted

Solution code:
n=list(input())
k=2**(len(n)-1)
v=[]
for i in range(k):
    x=['+']*(len(n)-1)
    for j in range(len(n)-1):
        if (i>>j)&1:
            x[j]=''
    
    ans=''
    for a,b in zip(n,x+['']):
        ans+=(a+b)
    v.append(eval(ans))
print(sum(v))

Submission status: Accepted

Solution code:
def dfs(i, f):
    global ans
    if i == len(s) - 1:
        ans += sum(map(int, f.split("+")))
        return 0
    dfs(i +1, f + "+" + s[i + 1])
    dfs(i +1, f+ s[i + 1])

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

Submission status: Accepted

Solution code:
def calc(s):
    n = s.split("+")
    sum = 0
    for i in range(len(n)):
        sum += int(n[i])
    return sum

def bfs(S,n,s):
    if n == len(S):
        # 数式sを計算する
        return calc(s)
    else:
        return bfs(S,n+1,s+"+"+S[n]) + bfs(S,n+1,s+S[n])

S=input()
s=S[0]
print(bfs(S,1,s))

Submission status: Accepted

Solution code:
def resolve():

    s = input()

    ans = 0

    for i in range(2 ** (len(s) - 1)):

        pos = 0
        for j in range(len(s) - 1):

            if (i >> j) & 1:
                ans += int(s[pos:j+1])
                pos = j+1

        ans += int(s[pos:len(s)])

    print(ans)
    
resolve()

Submission status: Accepted

Solution code:
s = input()
lenth = len(s)
plus = lenth - 1
ans = 0
for i in range(1 << plus):
    right = lenth
    i_two = format(i,'b')
    ilen= len(format(i,'b'))
    for j in range(ilen):
        if i_two[ilen - 1 - j] == '1':
            ans += int(s[lenth - 1 - j:right])
            right = lenth - 1 - j
    ans += int(s[0:right])
print(ans)

Submission status: Accepted

Solution code:
def dfs(i, f):
    global ans
    if i == len(s) - 1:
        ans += sum(map(int, f.split("+")))
        return 0
    dfs(i + 1, f + "+" + s[i + 1])
    dfs(i + 1, f + s[i + 1])

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

Submission status: Accepted

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


def main():
    s = input()
    ans = 0
    ops = tuple(product(("", "+"), repeat=len(s) - 1))
    for op in ops:
        e = ""
        for i in range(len(s) - 1):
            e += s[i] + op[i]
        e += s[-1]
        ans += eval(e)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

ans = 0
if n == 1:
	ans = int(s[0])
else:
	for x in itertools.product(["", "+"], repeat = n - 1):
		tmp = ""
		for i in range(n - 1):
			tmp += s[i] + x[i]
		tmp += s[-1]
		ans += eval(tmp)
print(ans)

Submission status: Accepted

Solution code:
import itertools
S = input()
ans = 0
for p in itertools.product(['', '+'], repeat = len(S) - 1):
    cmd = ''.join([s + t for s, t in zip(S, p)]) + S[-1]
    ans += eval(cmd)
print(ans)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

S = S()
ans = 0

for i in range(1<<(len(S)-1)):
    tmp_ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

S = S()
ans = 0

for i in range(1<<(len(S)-1)):
    tmp_ans = 0
    bit = i

    for j in range(len(S)-1):
        if (bit & 1):
            tmp_ans *= 10
            tmp_ans += int(S[j])
            ans += tmp_ans
            tmp_ans = 0
        else:
            tmp_ans *= 10
            tmp_ans += int(S[j])
       
        bit >>= 1
    
    if (not tmp_ans):
        ans += int(S[-1])
    else:
        tmp_ans *= 10
        tmp_ans += int(S[-1])
        ans += tmp_ans

print(ans)

Submission status: Accepted

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

for i in range(2**n):# iでビット列を生成
    equ=s[0]
    for j in range(n):# jでポインタを操作
        if (i>>j)&1:# 下1桁のビットが立っているか判定
            equ+='+'+s[j+1]
        else:
            equ+=s[j+1]
    ans+=eval(equ)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
input=stdin.readline().rstrip()

#あえて文字列で
num_list=[input[x] for x in range(len(input))]
output=0
n=len(input)-1
#2**nの全パターンを探索
for i in range(2**n):
    #s_nowは"1+23"みたいになるイメージなので先頭の数字を入れておく
    s_now=num_list[0]
    #2進数表記なので最大n回右にずらせる
    for j in range(n):
        #bit演算　iを2進数表記し、j個分右にずらしてそこが1ならTrueを返す
        if ((i >> j) & 1):
            #1が入っているなら＋を書く 01(1)なら"12+3"、11(3)なら"1+2+3"となるようなイメージ
            s_now+=("+")
        #次の数字を書く
        s_now+=(num_list[j+1])

    #print(s_now)
    #eval:文字列を式として計算してくれる
    output+=eval(s_now)

print(output)

Submission status: Accepted

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

# 二進数で考えると、0, 1, 10, 11, 100 ... 1111
for i in range(2**(N-1)):
    exp = S[0]

    # 右に一つずつシフトしていき、
    for j in range(1, N):

        # 最初の桁が1であれば（&1でTrue）+, そうでなければスルー
        if (i >> (j-1)) & 1: exp += '+'
        exp += S[j]
        
    ans += eval(exp)

print(ans)

Submission status: Accepted

Solution code:
s = list(input())
size = len(s)
para = ["" for i in range(size-1)]
a = []
for i in range(size):
    if i == size-1:
        a.append(s[i])
    else:
        a.append(s[i])
        a.append(para[i])
ans = 0
for p in range(2**(size-1)):
    for j in range(size-1):
        if (p>>j) & 1 :
            a[2*j+1] = "+"
        else: 
            a[2*j+1] = ""
    ans += eval("".join(a))
print(ans)

Submission status: Accepted

Solution code:
num_lis = [int(x) for x in input()]
N = len(num_lis)
ans = 0
temp = 0

for b in range(1 << (N-1)):
    for c in range(N-1):
        if (b >> c) & 1:
            ans += temp + num_lis[c]
            temp = 0
        else:
            temp = (temp + num_lis[c]) * 10
    ans += temp + num_lis[-1]
    temp = 0

print(ans)

Submission status: Accepted

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

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

    list = S[0]
    for j in range(1, n):

        if (i >> (j - 1)) & 1:

            list = list + "+" + S[j]
            # print(i >> (j-1))

        else:
            list += S[j]

    ans += eval(list)

print(ans)

Submission status: Accepted

Solution code:
s = list(input())
N = len(s) - 1

ans = 0
for i in range(2 ** N):
    e = 0
    for j in range(N+1):
        ans += int(s[-(j+1)]) * (10 ** e)
        e += 1
        if ((i >> j) & 1):
            e = 0

print(ans)

Submission status: Accepted

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

for i in range(l):
  ans += sum([int(S[i]) * (10**k) * 2**(max(0,l-i-k-2)+i)  for k in range(l-i)])

print(ans)

Submission status: Accepted

Solution code:
s = input()

case = len(s)-1
allcase = 2 ** case
total = 0


for i in range(allcase):
    sum = s[0]
    #print(sum)
    for j in range(case):
        if ((i >> j) & 1):
            sum = sum + "+" + s[j+1]
        else:
            sum = sum + s[j+1]

    total =  total + eval(sum)
print(total)

Submission status: Accepted

Solution code:
#ARC61-C

s=input() #0～(n-1)番
n=len(s) 
total=0
for i in range(pow(2,(n-1))): 
    list=s[0]
    for j in range(1,n): #1～(n-1)
        if (i>>(j-1))&1: #(j-1)番目が１なら、s[j]を追加する前に＋を加える。
            list=list+"+"+s[j]
        else:
            list+=s[j]
    total+=eval(list)
    #print(list)

print(total)

Submission status: Accepted

Solution code:
S = input()

allSUM = 0
# print(len(S))

def dfs(i,strNum):
    # print("i: {} s: {}".format(i,strNum))


    if i == len(S)-1:
        tmp = strNum.split("+")

        for j in range(len(tmp)):
            tmp[j] = int(tmp[j])

        global allSUM
        allSUM += sum(tmp)

        return False

    if i+1 > len(S)-1:
        return False

    if(dfs(i+1,strNum+S[i+1])):
        return True

    if(dfs(i+1,strNum+"+"+S[i+1])):
        return True

    return False


dfs(0,S[0])

print(allSUM)

Submission status: Accepted

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

def getsum(t, total, sum_left=0):
  if len(t) == 1:
    total += sum_left + t[0]

  else:
    t0 = [t[0]*10 + t[1],] + t[2:]
    total = getsum(t0, total, sum_left)
    
    t1 = t[1:]
    sum_left += t[0]
    total = getsum(t1, total, sum_left)
  
  return total

print(getsum(s, 0))

Submission status: Accepted

Solution code:
S = input()
N = len(S)
nums = []
if N>2:
    for i in range(2**(N-1)):
        bi = bin(i)[2:].zfill(N-1)
        bi = '1' + bi + '1'
        l = 0
        for r in range(1,N+1):
            if bi[r] == '1':
                nums.append(int(S[l:r]))
                l = r
    res = sum(nums)
else:
    if N==1:
        res = int(S)
    else:
        res = int(S)+int(S[0]) + int(S[1])
print(res)

Submission status: Accepted

Solution code:
s = [int(x) for x in input()]
n = len(s)
result = 0

for i in range(2**(n-1)):
  sum = 0
  tmp = s[0]
  for j in range(n-1):
    if (i >> j) % 2 == 1:
      sum += tmp
      tmp = s[j+1]
    else:
      tmp = tmp * 10 + s[j+1]
  sum += tmp
  result += sum

print(result)

Submission status: Accepted

Solution code:
n=list(input())
k=len(n)-1
x=0
for i in range(2**k):
    v=[""]*k
    for j in range(k):
        if ((i >> j) & 1):
            v[j]="+"
    ans=""
    for a,b in zip(n,v+[""]):
        ans+=(a+b)
    x+=eval(ans)
print(x)

Submission status: Accepted

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

total = 0
for i in range(2**(n-1)):
  tmp = s[0]
  for j in range(1, n):
    if (i >> j-1) & 1:
      tmp = tmp + "+" + s[j]
    else:
      tmp = tmp + s[j]
  
  total = total + eval(tmp)

print(total)

Submission status: Accepted

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

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

print(total)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys

s = tuple(sys.stdin.readline().rstrip())

l = len(s)

# print(l)

def op(n):
  if n == "0":
    return ""
  else:
    return "+"


res = []
for i in range(2**(l-1)):
  
  ops = [op(x) for x in tuple(format(i*2, 'b').zfill(l))]
  
  # print(s)
  # print(ops)

  eq = ''
  for num, j in zip(s, ops):
    eq = eq + num + j
  
  res.append(eval(eq))

print(sum(res))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin

S=input()
andbit = 2**10 -1
ans = 0
length = 2**(len(S) -1)
    
for i in range (length):
  bitup = andbit & i
  bitcheck = 1
  tmp=0
  for j in range(1,len(S),1):
    if bitup & bitcheck > 0:
      ans += int(S[tmp:j])
      tmp = j
    bitcheck = bitcheck << 1
  ans += int(S[tmp:len(S)])
print(ans)

Submission status: Accepted

Solution code:
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


def main():
    s = input()
    su = 0

    for i in range(2 ** (len(s) - 1)):
        a = []
        for j in range(len(s)):
            a.append(s[j])
            if (j < len(s)-1 and (i >> j) & 1):
                a.append("+")
        # print(''.join(a))
        su += eval(''.join(a))

    print(su)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
S = str(int(raw_input()))

def calc_ans(S):
  if len(S) == 1:
    return int(S), 1
  
  s_len = len(S)
  sum = count = 0
  for i in range(0, s_len):
    if i > 0:
      S_new = S[i:]
      t_sum, t_count = calc_ans(S_new)
      t_sum = (int(S[:i])* t_count) + t_sum
    else:
      t_sum = int(S)
      t_count = 1
    sum += t_sum
    count += t_count
  return sum, count

sum, count = calc_ans(S)

print(sum)

Submission status: Accepted

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

for n in range(2 ** (N - 1)):
    B = bin(n)[2:]
    while len(B) < N - 1:
        B = "0" + B
    idx = 0
    for i, b in enumerate(B):
        if b == "1":
            ans += int(S[idx:i+1])
            idx = i+1
        if i == len(B) - 1:
            ans += int(S[idx:N])

print(ans)

Submission status: Accepted

Solution code:
from itertools import product
s = input()
ans = 0
for op in product(["", "+"], repeat=len(s)-1):
    op = list(op)
    op.append("")
    ans += eval(''.join( a + b for a, b in zip(s, op)))
print(ans)

Submission status: Accepted

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

ans_lst = []
for i in range(2**n):
    op = ["+"] * n 
    for j in range(n):
        if ((i >> j) & 1):
            op[n-j-1] = ""
    formula = ""
    for num,opp in zip(s, op + [""]):
        formula += (num + opp)
    ans_lst = ans_lst + [eval(formula)]

print(sum(ans_lst))

Submission status: Accepted

Solution code:
from itertools import zip_longest

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

total = 0
li = [0] * 2**n

for i in range(2**n):
  op = [""] * n
  for j in range(n):
    if (i >> j) & 1:
      op[j] = "+"
  li[i] = op
  
for i in li:
  siki = ""
  for j, k in zip_longest(i, s, fillvalue=""):
    siki += k+j
  total += eval(siki)
  
print(total)

Submission status: Accepted

Solution code:

S = ""

def rec(nums,step,N): #step → + を挿入する場所

    if step == N:
        nums = list(map(int,nums))
        return sum(nums)

    else:
        num = S[step]
        nums2 = nums[::]
        nums2[-1] += num
        nums.append(num)
        return rec(nums,step+1,N) + rec(nums2,step+1,N)
        #+を入れたパターン#+を入れなかったパターン



def func():
    global S
    S = input()
    N =len(S)
    print(rec([S[0]],1,N))

if __name__ == '__main__':
    func()

Submission status: Accepted

Solution code:
#input
S = list(input())
for i in range(len(S)):
    S[i] = int(S[i])
#print(S)
L = len(S)

sum_counter = 0
for i in range(L-1):
    for k in range(L-i-1):
        sum_counter += int(S[i] * (10**k) * (2**(L-i-2-k)) * (2**i))
        #print(sum_counter)
    sum_counter += int(S[i] * (10 ** (L-(i+1)) * (2**i - 1)))

#print(sum_counter)

#saigo no ketal
sum_counter += S[-1] * (2**(L-1)-1)

#print(sum_counter)

#zentai
for i in range(L):
    sum_counter += S[i] * (10**(L-i-1))

print(sum_counter)

Submission status: Accepted

Solution code:
S = input()

sum_value = 0
for n in range(2 ** (len(S) - 1)):
	line = ""
	for i, s in enumerate(S):
		line += s
		if (i < (len(S) - 1)) and (n >> i & 1):
			line += "+"
	sum_value += eval(line)
	#print(line)
print(sum_value)

Submission status: Accepted

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

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

    for x, y in zip(S, ope):
        ans += x+y
    ans += S[n] + '+'

print(eval(ans[:len(ans)-1]))

Submission status: Accepted

Solution code:
from itertools import product

S = input()
ans = 0
for lst in product(['', '+'], repeat=len(S)-1):
    formula = ''
    for s, p in zip(S[:-1], lst):
        formula += (s+p)
    formula += S[-1]
    ans += eval(formula)
print(ans)

Submission status: Accepted

Solution code:
def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    nums = list(map(lambda x: int(x), inputs[0]))
    opr_num = len(nums) - 1
    opr_pattern = 2 ** opr_num

    total = 0
    for opr_digit in range(opr_pattern):
        oprs = []
        tmp_opr_digit = opr_digit
        for _ in range(0, opr_num):
            # print(tmp_opr_digit)
            if tmp_opr_digit & 1 == 1:
                oprs.append("+")
            else:
                oprs.append("")
            tmp_opr_digit = tmp_opr_digit >> 1
        oprs.reverse()

        formula = ""
        for i, v in enumerate(oprs):
            formula += str(nums[i]) + str(oprs[i])
        formula += str(nums[-1])
        total += eval(formula)

    return total


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Submission status: Accepted

Solution code:
s = list(input())

op_cnt = len(s)-1
sum = 0
for i in range(2**op_cnt):
    op = ['']*op_cnt
    for j in range(op_cnt):
        if (i>>j) & 1:
            op[j] = '+'

    fomula = s[0]
    for j in range(op_cnt):
        fomula += op[j]
        fomula += s[j+1]
    
    sum += eval(fomula)

print(sum)

Submission status: Accepted

Solution code:
# import sys
# from collections import defaultdict
# sys.setrecursionlimit(10000)
# MOD = 10 ** 9 + 7
# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]

S = [int(x) for x in list(input())]
max_bits = 2 ** (len(S) - 1)

l = []
for n in range(max_bits):
    tmp = S[0]
    s = 0
    for i in range(len(S) - 1):
        if n & (1 << (len(S) - 2 - i)):
            tmp = 10 * tmp + S[i + 1]
        else:
            s += tmp
            tmp = S[i + 1]
    s += tmp

    l.append(s)

print(sum(l))