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:
# -*- coding: utf-8 -*-

def solve(s):
    return sum(resolve(s, pfs) for pfs in range(2 ** (len(s) - 1)))

def resolve(s, pfs):
    return eval(addp(s, pfs))

def addp(s, pfs):
    if len(s) == 1:
        return s
    if pfs & 1:
        return addp(s[:-1], pfs >> 1) + '+' + s[-1]
    else:
        return addp(s[:-1], pfs >> 1) + s[-1]

def main():
    s = input()
    print(solve(s))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a=input()
an=0
for i in range(len(a)):
  for j in range(i,len(a)):
   if len(a)-j-2>0:
       k1=len(a)-j-2
   else:
       k1=0
   if i-1>0:
       k2=i-1
   else:
       k2=0
   an+=int(a[i:j+1])*(2**(k1+k2))
print(an)

Submission status: Accepted

Solution code:
S = raw_input()
N = len(S)
S_list = map(int, list(S))
S_list.reverse()
res = 0
for i in range(N):
    res += S_list[i] * ((5**(i+1) - 1) / 4 + 5**i)
if N == 1:
    res /= 2
else:
    res *= (2**(N-2))

print res
# N-1 places
# 2^(N-1)
# k
# k=1 2^(N-2) + 2^(N-2) = 2^(N-2) * (1 + 1)
# k=2 2^(N-2), 2^(N-2) = 2^(N-2) * (1+5 + 5)
# k=3 2^(N-2), 2^(N-3), 2^(N-3) =  2^(N-2) * (1 + 5 + 25 + 25)

Submission status: Accepted

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

from __future__ import division, print_function, absolute_import, unicode_literals

s = input()
ans = 0

N = len(s)
for i in range(1<<(N-1)):
    tmp = s[0]
    for n in range(N-1):
        if ((1 << n) & i):
            tmp += '+'
        tmp += s[n+1]
    ans += eval(tmp)
print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations

s = raw_input()
l = len(s)

allstrs = [[s]]
for n in range(1, l):
    pluses = combinations(range(1, l), n)
    for plus in pluses:
        strs = [s[:plus[0]]] + [s[plus[i]:plus[i+1]] for i in range(0,
            len(plus)-1)] + [s[plus[-1]:]]
        allstrs.append(strs)

print(sum([sum([int(x) for x in strs]) for strs in allstrs]))

Submission status: Accepted

Solution code:
dp=["","+"]
s=input()
su=0
for i in range(2**(len(s)-1)):
    val=""
    b=bin(i)[2:].zfill(len(s)-1)
    for j in range(len(s)-1):
        val+=s[j]+dp[int(b[j])]
    val+=s[len(s)-1]
    su+=eval(val)
print(su)

Submission status: Accepted

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

l = len(numbers)

total = 0
all_pattern =  pow(2,l-1)

for (i,n) in enumerate(map(int,list(reversed(numbers)))):
   remain_pattern = all_pattern
   p = 0
   for j in xrange(i):
     remain_pattern /= 2
     total += n * (pow(10,p)) * remain_pattern
     #print total,n , (pow(10,p)) , remain_pattern
     p += 1
   total += n * pow(10,p) * remain_pattern
   #print total,n , (pow(10,p)) , remain_pattern
print total

Submission status: Accepted

Solution code:
# coding: utf-8
# Here your code !
n = input()
s = list(str(n))


d = {}
    
def solve(l):
    if len(l) == 1:
        return int(l[0])
    # if str(l) in d:
        # return d[str(l)]
    sum = int("".join(l))
    for i in xrange(1,len(l)):
        # print  l[:i],l[i:]
        # print int("".join(l[:i]))*2**(len(l[i:])-1)
        d[str(l)]= int("".join(l[:i]))*2**(len(l[i:])-1) + solve(l[i:])
        sum += d[str(l)]
    return sum
        
print solve(s)

Submission status: Accepted

Solution code:
def f(S):
    n = len(S)
    ret = int(S)
    for i in range(1, n):
        x = int(S[:i])
        ret += 2**(n-i-1)*x + f(S[i:])
    return ret

S = input()
print(f(S))

Submission status: Accepted

Solution code:
import itertools
nums = input()
index = range(1, len(nums))
def resolve(i):
    t = list(nums)
    for j in reversed(i): t.insert(j, "+")
    return eval("".join(t))

print(sum([resolve(i) for i in itertools.chain(*[itertools.combinations(index, x) for x in range(len(index) + 1)])]))

Submission status: Accepted

Solution code:
def solve(digits, pos, x, y):
    if pos == len(digits):
        return x + y
    a = solve(digits, pos + 1, x + y, digits[pos])
    b = solve(digits, pos + 1, x, 10 * y + digits[pos])
    return a + b

digits = list(map(int, list(raw_input())))
result = solve(digits, 1, 0, digits[0])
print(result)

Submission status: Accepted

Solution code:
def gen(s):
	if len(s)==1:
		yield s
	else:
		for ss in gen(s[:-1]):
			yield ss + s[-1]
			yield ss + '+' + s[-1]

s = input()
print(sum(map(eval, gen(s))))

Submission status: Accepted

Solution code:
from itertools import product

S = tuple(input())
N = len(S)
res = 0
for ops in product(["+", ""], repeat=N-1):
    exp = "".join([n + op for n, op in zip(S, ops+("",))]).strip("+")
    res += eval(exp)
print(res)

Submission status: Accepted

Solution code:
#!/usr/bin/env python2.7

root_s = raw_input()

'''
for length n, there are n-1 places to put the plus sign
'''

total = 0

n = len(root_s)
for mask in xrange(2**(n-1)):
    new_s = ''
    for i, c in enumerate(root_s):
        new_s += c
        if mask & (1 << i):
            new_s += '+'
    #print new_s
    total += eval(new_s)

print total

Submission status: Accepted

Solution code:
def get(s):
    length = len(s)
    sum = 0
    for i in range(length):
        sum += int(s[0:i+1])
        sum += get(s[i+1:])
        if len(s[i+1:]) != 0:
            sum += (2**(len(s[i+1:])-1)-1)*int(s[0:i+1])
    return int(sum)

def main():
    string = str(input())
    print(int(get(string)))

main()

Submission status: Accepted

Solution code:
result = 0
def BT(k, current, s):
    global result
    if k == len(a) :
        if current == 0 :
            result += s
    else :
        BT(k+1, int(a[k]), s+current)
        BT(k+1, current* 10 + int(a[k]), s)

a = input()+'0'
BT(1,int(a[0]),0)
print(result)

Submission status: Accepted

Solution code:
result = 0
def BT(k, current, s):
    global result
    if k >= len(a)-1 :
        if current == 0 :
            result += s
        # print(k,current,s,result)
    else :
        BT(k+1, int(a[k+1]), s+current)
        BT(k+1, current* 10 + int(a[k+1]), s)

a = input()+'0'
BT(0,int(a[0]),0)
print(result)

Submission status: Accepted

Solution code:
S = str(input())
N = len(S)
B = [[0 for k in range(N)] for k in range(N)]

t = 1
for p in range(N):
    for q in range(N):
        if p == q:
            t *= 2
        if p >= q:
            B[q][p] = t//2

ans = 0
for k in range(N):
    for j in range(N):
        ans += int(S[k])*B[k][j]*10**(N-j-1)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def addPlus(s,n):
    total = 0
    ps = [s]
    org = s
    for i in range(1,len(org)):
        ps.append(org[:i] + '+' + org[i:])

    for i in range(1,n):
        curr = ps[:]
        for itm in curr:
            for j in range(1,len(itm)):
                pros = itm[:j] + '+' + itm[j:]
                if pros not in ps:
                    if '++' not in pros:
                        ps.append(pros)
    # print(ps)
    for itm in ps:
        total += eval(itm)

    print(total)

if __name__ == '__main__':
    s = input()
    addPlus(s,len(s) - 1)

Submission status: Accepted

Solution code:
dp = {}
def rec(s):
    if s in dp:
        return dp[s]
    ret = int(s)
    for i in range(1,len(s)):
        ret += int(s[:i] )* (2**(len(s) - i - 1)) + rec(s[i:])
    dp[s] = ret
    return ret
print(rec(input()))

Submission status: Accepted

Solution code:
from sys import stdin
a = stdin.readline().strip()
ans = 0
n = len(a)
plus = n-1
b = [a[0]]
for i in xrange(1,n):
    b.append('')
    b.append(a[i])
    
total = 1<<plus
#print b,total
for i in xrange(total):
    x = ''
    c = list(b)
    #print "mask",i,c
    for j in xrange(n-1):
        if i & (1<<j):
            c[2*j+1] = '+'
    #print c            
    #print ''.join(c)
    ans += eval(''.join(c))
print ans

Submission status: Accepted

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

res = 0

for i in range(1<<N):
    t = ''
    for j in range(N):
        t += S[j]
        if((i>>j&1) > 0): t += '+'
    t += S[-1]
    res += eval(t)
print(res)

Submission status: Accepted

Solution code:
s = map(int, raw_input())

def dfs(c, nums):
    if c==len(s):
        return sum(nums)
    res = 0
    res += dfs(c+1, nums + [s[c]])
    if c:
        nums2 = nums[:]
        nums2[-1] = nums2[-1]*10 + s[c]
        res += dfs(c+1, nums2)
    return res

print dfs(0, [])

Submission status: Accepted

Solution code:
n = raw_input()


def weight(i, j):
    l = len(n)
    return 2 ** (max(i-1, 0) + max(l-j-2, 0))

s = 0
for i in range(len(n)):
    for j in range(i, len(n)):
        num = int(n[i:j+1])
        s += int(num) * weight(i, j)

print s

Submission status: Accepted

Solution code:
import sys
perm = sys.stdin.readline().strip()
total = 0

# Add n * '+' to inp
def addPlus(inp, n):
    total = 0
    possible = [inp]
    orig = inp

    for i in range(1, len(orig)):
        possible.append(orig[:i] + '+' + perm[i:])

    for i in range(1, n):
        curr = possible[:]
        for item in curr:
            for j in range(1, len(item)):
                processed = item[:j] + '+' + item[j:]
                if processed not in possible:
                    if '++' not in processed:
                        possible.append(processed)

    for item in possible:
        total += eval(item)

    return total


print(addPlus(perm, len(perm) - 1))

Submission status: Accepted

Solution code:
dp = {}

def rec(s):
    if s in dp:
        return dp[s]
    ret = int(s)
    for i in range(1, len(s)):
        ret += int(s[:i]) * (2**(len(s)-i-1)) + rec(s[i:])
    dp[s] = ret
    return ret

print(rec(input()))

Submission status: Accepted

Solution code:
S = str(raw_input())

n = len(S)
table = []

SS = []
for s in S:
    SS.append(int(s))

for i in range(n):
    x = [0] * n
    for j in range(i):
        x[j] = 2 ** (i-1)
    x[i] = 2 ** i
    table.append(x)

ret = 0
for i in range(n):
    p = n - 1 - i
    for j in range(i+1):
        if table[i][j] > 0:
            ret += SS[j] * (10**p) * table[i][j]

print ret

Submission status: Accepted

Solution code:
import itertools,math,bisect,pprint,sys
s = raw_input()
n = len(s)
ans = []
for i in range(n):
    for j in list(itertools.combinations(range(n-1),i)):
        S = s
        a = 0
        for k in reversed(j):
            a += int(S[k+1:])
            S = S[:k+1]
        else:
            a += int(S)
        ans.append(a)
print sum(ans)

Submission status: Accepted

Solution code:
import sys

s = sys.stdin.readline().strip()
def mypowerof2(exp):
        ret = 1
        for i in range(exp):
                ret *= 2
        return ret
def mypowerof10(exp):
        ret = 1
        for i in range(exp):
                ret *= 10
        return ret
res = 0
for i in reversed(xrange(len(s))):
        for j in xrange(len(s)-i):
                base = int(s[i]) * mypowerof10(j)
                rate = mypowerof2(i) * mypowerof2((len(s)-1) - i - j - 1)
                res += base * rate
#               print "base is", base
#               print "rate is", rate                                                                            

print res

Submission status: Accepted

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

exp_sum = 0
for i in range(1 << keta-1):
    newS = S
    offset = 1
    for j in range(keta):
        if i & (1 << j):
            newS = newS[:j+offset] + "+" + newS[j+offset:]
            offset += 1
    exp_sum += eval(newS)

print(exp_sum)

Submission status: Accepted

Solution code:
def calc(s, f):
    n = len(s)
    li = []
    t = ""
    for i in range(n):
        t += s[i]
        if f & 1:
            li.append(t)
            t = ""
        f >>= 1
    if t:
        li.append(t)
    return sum(map(int, li))


s = input()
ans = 0
for i in range(1 << (len(s) - 1)):
    ans += calc(s, i)
print(ans)

Submission status: Accepted

Solution code:
def dfs(arr, accm=0):
	if len(arr) == 1:
		return arr[0]

	s1 = arr[0] * (2 ** (len(arr) - 2)) + dfs(arr[1:])

	_arr = list(arr[1:])
	_arr[0] += arr[0] * 10
	s2 = dfs(_arr)

	return s1 + s2

s = input()
arr = [int(a) for a in s]

print(dfs(arr))

Submission status: Accepted

Solution code:
def ans(s):
	if len(s) == 1:
		return int(s)
	else:
		length = len(s)
		res = int(s)
		for i in range(1, length):
			x = 1 << (length - i - 1)
			res += int(s[0: i]) * x + ans(s[i:len(s)])
		return res

s = input()
print(ans(s))

Submission status: Accepted

Solution code:
s = raw_input()

def solve(add, s):
	if s ==  "":
		return 0
	else:
		res = add + int(s)
		for i in range(1, len(s)):
			res += solve(add + int(s[:i]), s[i:])
		return res

print solve(0, s)

Submission status: Accepted

Solution code:
s = input()
ans = 0
l = len(s)-1
for i in range(2**(len(s)-1)):
    bs = ("{0:0>"+str(l)+"b}").format(i)
    s1 = 0
    temp = s[:]
    j = 0
    for b in bs:
        j+=1
        if b == '1':
            s1 += int(temp[:j])
            temp = temp[j:]
            j = 0
    s1 += int(temp)
    ans += s1
print(ans)

Submission status: Accepted

Solution code:
import sys
def line():return sys.stdin.readline().strip()

S = line()
L = list(S)
ans = 0
for i in range(1 << (len(S) - 1)):
    A = ""    
    for j in range(len(S)):
        A+=L[j]
        if i & (1 << j):
            A+="+"
    ans+=eval(A)
print(ans)

Submission status: Accepted

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


def convert(s):
    lst = []
    for i in range(N):
        if (s >> i) & 1 == 1:
            lst.append(i)
    return lst


def calc(lst):
    if len(lst) == 0:
        return int(S)
    elif len(lst) == 1:
        return int(S[:lst[0] + 1]) + int(S[lst[0] + 1:])
    else:
        tmp = [S[:lst[0] + 1]]
        for i in range(len(lst) - 1):
            tmp.append(S[lst[i] + 1:lst[i+1] + 1])
        tmp.append(S[lst[-1] + 1:])
        ans = 0
        for t in tmp:
            ans += int(t)
        return ans

ans = 0
for i in range(1 << (N - 1)):
    lst = convert(i)
    ans += calc(lst)
print(ans)

Submission status: Accepted

Solution code:
import bisect
import sys
import math
import itertools
sys.setrecursionlimit(10000)

INF = float('inf')

# input macro
def i():
    return int(raw_input())
def ii():
    return map(int,raw_input().split(" "))
def ilist():
    return map(int,list(raw_input()))
def s():
    return raw_input()
def ss():
    return raw_input().split(" ")
def slist():
    return list(raw_input())
#

def join(s):
    return ''.join(s)

#iterate macro
def piter(n,m):
    return itertools.permutations(n,m)
def citer(n,m):
    return itertools.combinations(n,m)

#modulo macro
def modc(a,b,m):
    c = 1
    for i in xrange(b):
        c = c * (a - i) % m
        c = c * modinv(i + 1,m) % m
    return c
 
def gcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
 
def modinv(a, m):
    (inv, q, gcd_val) = gcd(a, m)
    return inv % m

#bisect macro
def index(a, x):
    #Locate the leftmost value exactly equal to x
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    return -1

#memoize macro
def memoize(f):
    cache = {}
    def helper(*args):
        if args not in cache:
            cache[(args)] = f(*args)
        return cache[args]
    return helper

@memoize
def nck(a,b,m):
    b = min([a-b,b])
    if (b>a or b<0 or a<0):
        return 0
    elif a == 0:
        return 1
    return (nck(a-1,b-1,m)+nck(a-1,b,m)) % m

nh=zip([1,0,-1,0],[0,1,0,-1])

###########

sl=ilist()
n=len(sl)
sm=0
for j in range(n+1):
    for k in range(j+1,n+1):
        p=int(join(map(str,sl[j:k])))
        if j==0 and k==n:
            sm+=p
        elif j!=0 and k==n:
            sm+=p*(2**(j-1))
        elif j==0 and k!=n:
            sm+=p*(2**(n-k-1))
        else:
            sm+=p*(2**(j+n-k-2))

print sm

Submission status: Accepted

Solution code:
from itertools import permutations as perm
S = raw_input()
n = len(S)
dp = [[] for i in xrange(n)]
dp[0].append(int(S[0]))
for i in xrange(1,n):
	dp[i].append(int(S[:i+1]))
	for j in xrange(i):
		for k in dp[j]:
			dp[i].append(k+int(S[j+1:i+1]))
print sum(dp[n-1])

Submission status: Accepted

Solution code:
s=raw_input()
n=len(s)
ans=0
for i in xrange(1<<n-1):
    new=[]
    for j in xrange(n-1):
        if i>>j&1:
            new.append(j)
    news=""
    for j in xrange(n):
        if j in new:
            news+=s[j]+"+"
        else:
            news+=s[j]
    tmp=""
    for j in news:
        if j=="+":
            ans+=int(tmp)
            tmp=""
        else:
            tmp+=j
    if tmp!="":
        ans+=int(tmp)
print(ans)

Submission status: Accepted

Solution code:
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# 


s = input()
l = len(s)

if l == 1:
	print(int(s))
else:
	ans = 0

	m = int('1'*(l-1), 2)
	for i in range(m+1):
		now = format(i, 'b').zfill(l-1)
		tmp = s[0]
		for k in range(l-1):
			if now[k] == '0':
				tmp += s[k+1]
			else:
				ans += int(tmp)
				tmp = s[k+1]
		ans += int(tmp)
	print(ans)

Submission status: Accepted

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

import itertools

S = input()
signs = [['+',''] for _ in range(len(S)-1)]

ans = 0
for comb in itertools.product(*signs):
    expr = ''
    for i in range(len(S)-1):
        expr += (S[i] + comb[i])
    expr += S[-1]
    ans += eval(expr)
print(ans)

Submission status: Accepted

Solution code:

s = input()

n = len(s) - 1
ans = 0
for mask in range(0, 1 << n):
    num = int(s[0])
    cur = 0
    for i in range(0, n):
        if mask & (1 << i):
            cur += num
            num = 0
        num = num * 10 + int(s[i + 1])
    cur += num
    ans += cur

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
len_s = len(s)
n = 2**(len_s-1)
total = 0
for i in range(n):
    buf = s[0]
    for j in range(len_s-1):
        if i & (2**j):
            total += int(buf)
            buf = s[j+1]
        else:
            buf += s[j+1]
    total += int(buf)
print(total)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**9


def f():
    s = input()
    l = len(s)
    sa = [c for c in s]
    m = 2**(l-1)
    r = 0
    for i in range(m):
        si = sa[0]
        for j in range(l-1):
            t = 2**j
            if i & t:
                si += '+'
            si += sa[j+1]
        r += eval(si)
    return r

print(f())

Submission status: Accepted

Solution code:
#import string,itertools,fractions,heapq,re,array,bisect
#from math import *
#from collections import Counter
def rl(s): return xrange(len(s))


INF = 2147483647


import sys
stdin = sys.stdin

T =   stdin.readline().strip() 

N = len(T)
ts = ['' for _ in range(2*N)]
for i in range(N):
    ts[2*i] = T[i]

rr = 0
for i in range(1 << (N-1)):
    here = ts[:]
    for k in range(N):
        if i & (1 << k):
            here[2*k+1] = '+'

    rr += eval(''.join(here))

print rr

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:
import itertools
S = raw_input()
ans = 0
for p in itertools.product([True, False], repeat=len(S)-1):
  t = ''
  for i in xrange(len(S)):
    t += S[i]
    if i != len(S)-1 and p[i]:
      t += '+'
  ans += eval(t)

print ans

Submission status: Accepted

Solution code:
s = raw_input()
n = len(s)
ans = 0
for msk in range(0, (1 << (n - 1))):
    t = ''
    for i in range(n):
        t += s[i]
        if ((msk >> i) & 1) == 1:
            t += '+'
    ans += eval(t)
print ans

Submission status: Runtime Error

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

print(total)

Submission status: Runtime Error

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

s = int(input())
n = len(s) - 1
answer = 0
for i in range(2 ** n):
    operation = [""] * n
    for j in range(n):
        if (i >> j) & 1:
            operation[n - 1 -j] = "+"
    
    formula = ""
    for p_n, p_o in zip(s, operation + [""]):
        formula += (p_n + p_o)
    
    answer += eval(formula)

print(answer)

Submission status: Runtime Error

Solution code:
a

Submission status: Runtime Error

Solution code:
s = input()

for i in range(2**(len(s)-1)):
    plus = [""]*(len(s))
    fomula = ""
    for j in range(len(s)-1):
        if(i >> j & 1):
            plus[j] = "+"
    for k in range(len(s)):
        fomula += s[k] + plus[k]
    ans += eval(fomula)
print(ans)

Submission status: Runtime Error

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

S = input()
n = len(S)

tot = 0

for i in range(2**(n-1)):
  f = S[0]
  for j in range(n-1):
       if ((i >> j) & 1):
        f += " "
       f += S[j+1]
  
  tot += sum(map(int, f.split(" ")))

print(tot)

Submission status: Runtime Error

Solution code:
n = [int(x) for x in input()]
op_cnt = len(n) - 1  
out=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] = "" 
        box=""  
    for a,b in zip(n,op+[""]):
        box+=(str(a)+b)
    box=box.split('+')
    ou=0
    for k in box:
        out+=int(k)
print(out)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# from typing import *
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

def mystoi(S):
    num = 0;
    for i in range(len(S)-1, 0, -1):
        num += int(S[i]) * (10**(len(S)-1-i));
    return num;


S = input()
N = len(S)
ans = 0
for bit in range(2**N):
    j = 0
    for i in range(N):
        if bit & (1<<i):
            ans += mystoi(S[j:(i-j)])
            j = i+1
    ans += mystoi(S[j:])
    
print(ans)





    


'''
cd ~/Desktop/Programming/AtCoder/practice/arc061/arc061_a && sh shellscripts/test_py.sh
cd ~/Desktop/Programming/AtCoder/practice/arc061/arc061_a && sh shellscripts/etest_py.sh
cd ~/Desktop/Programming/AtCoder/practice/arc061/arc061_a && sh shellscripts/submit_py.sh
'''

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# from typing import *
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

def mystoi(S):
    num = 0;
    for i in range(len(S)-1, 0, -1):
        num += int(S[i]) * (10**(len(S)-1-i));
    return num;


def solve(S):
    N = len(S)
    ans = 0
    for bit in range(2**N):
        j = 0
        for i in range(N):
            if bit & (1<<i):
                ans += mystoi(S[j:(i-j)])
                j = i+1
        ans += mystoi(S[j:])
    
    print(ans)



def main():
    S = input()
    solve(S)

if __name__ == '__main__':
    main()


'''
cd ~/Desktop/Programming/AtCoder/practice/arc061/arc061_a && sh shellscripts/test_py.sh
cd ~/Desktop/Programming/AtCoder/practice/arc061/arc061_a && sh shellscripts/etest_py.sh
cd ~/Desktop/Programming/AtCoder/practice/arc061/arc061_a && sh shellscripts/submit_py.sh
'''

Submission status: Runtime Error

Solution code:
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: Runtime Error

Solution code:

N, M = map(int, input().split())

L = [0] * M
R = [0] * M


LR = [0] * M
for i in range(M):
    L[i], R[i] = map(int, input().split())

ans = min(R) - max(L) 
if ans >=0:
    print(ans + 1)
    
else:
    print(0)
    
#print(max(L))
#print(min(R))

Submission status: Runtime Error

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: Runtime Error

Solution code:
#入力
#関数へ
#関数
    #
def a(t,i):
    if j = 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: Runtime Error

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: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
def a(s,i):
    if i == n-1:
        return eval(s)
    return a(s[i]+s[i+1],i+1)+ a(s[i]+"+"+s[i+1])

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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)):
    if a[j]==1:
      b.insert(-j-1,'+')
  sm+=eval(''.join(b))
print(sm)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: Runtime Error

Solution code:
s = input()
total = 0
for i in product('01', repeat=len(s)-1):
    buf = s[0]
    for j in range(len(s)-1):
        if i[j] == '1':
            total += int(buf)
            buf = s[j+1]
        else:
            buf += s[j+1]
    total += int(buf)
print(total)

Submission status: Runtime Error

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

# def dfs(i, f) :
#     """
#     argument i : どこから始めるか
#     f :　最初の数
#     returen : falese or ture(作れるならtrue)
#     """
#     if i == k-1:
#         return sum(list(map(int, f.split('+'))))

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

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

#bit木を書いていきます

ans = 0

for bit in range(1 << (k-1)):
    f = s[0]
    
    for i in range(k-1):
        # if bit & (1 << i)で、bitにiが含まれているか（フラグが立っているか）を判定してくれるらしい
        if bit & (1 << i):
            f += '+'
        f += f[i + 1]
    ans += sum(list(map(int, f.split('+'))))

print(ans)

Submission status: Runtime Error

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

# def dfs(i, f) :
#     """
#     argument i : どこから始めるか
#     f :　最初の数
#     returen : falese or ture(作れるならtrue)
#     """
#     if i == k-1:
#         return sum(list(map(int, f.split('+'))))

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

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

#bit木を書いていきます

ans = 0

for bit in range(1 << k-1):
    f = s[0]
    
    for i in range(k-1):
        # if bit & (1 << i)で、bitにiが含まれているか（フラグが立っているか）を判定してくれるらしい
        if bit & (1 << i):
            f += '+'
        f += f[i + 1]
    ans += sum(list(map(int, f.split('+'))))

print(ans)

Submission status: Runtime Error

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

ans = 0

for bit in range(1 << k-1):
    f = s[0]
    
    for i in range(k-1):
        # if bit & (1 << i)で、bitにiが含まれているか（フラグが立っているか）を判定してくれるらしい
        if bit & (1 << i):
            f += '+'
        f += f[i + 1]
    ans += sum(list(map(int, f.split('+'))))

print(ans)

Submission status: Runtime Error

Solution code:
from sys import stdin
S = stdin.readline().rstrip()
n = len(S)
def dfs(i, f):
    if i = n-1:
        return sum(list(map(int, f.split('+'))))
    return dfs(i+1, f + S[i + 1]) + dfs(i + 1, f + '+' + s[i-1])
print(dfs(0, S[0]))

Submission status: Runtime Error

Solution code:
from sys import stdin
S = stdin.readline().rstrip()
n = len(S)
def dfs(i, f):
    if i = n-1:
        return sum(list(map(int, f.split('+'))))
    return dfs(i+1, f + S[i + 1]) + dfs(i + 1, f + '+' s[i-1])
print(dfs(0, S[0]))

Submission status: Runtime Error

Solution code:
from sys import stdin
S = stdin.readline().rstrip()
n = len(S)
def dfs(i, f):
    if i = n-1:
        return sum(list(map(int, f.split('+'))))
    return dfs(i+1, f + S[i + 1]) + dfs(i + 1, f + '+' s[i-1])
#最初が＋なし、次が＋あり
print(dfs(0, S[0]))

Submission status: Runtime Error

Solution code:
from sys import stdin
S = stdin.readline().rstrip()
n = len(S)
def dfs(i, f):
    if i = n-1:
        return sum(list(map(int, f.split('+'))))
    return dfs(i+1, f + S[i + 1]) + dfs(i + 1, f + '+' s[i-1])
#最初が＋なし、次が＋あり
print(def(0, S[0]))

Submission status: Runtime Error

Solution code:
from sys import stdin
S = stdin.readline().rstrip()
n = len(S)
def dfs(i, f):
    if i = n-1:
        return sum(list(map(int, f.split('+'))))
    return dfs(i+1, f + S[i + 1]) + dfs(i + 1, f + '+' s[i-1])
#最初が＋なし、次が＋あり
print(def(0, s[0]))

Submission status: Runtime Error

Solution code:
aqqn = list(input())
ans = 0
for i in range(2**(len(n)-1)):
    plus = [""]*(len(n))
    fomula = ""
    for j in range(len(n)-1):
        if(i>>j & 1):
            plus[j] = "+"
    for i in range(len(n)):
        fomula += n[i] + plus[i]
    ans += eval(fomula)
print(ans)

Submission status: Runtime Error

Solution code:
s=input()
ans=0
for i in range(1 << len(s)-1):
    l=[]
    for j in range(len(s)-1):
        if (i>>j)&1==1:
            l.append(s[j])
            l.append("+")
        else:
            l.append(s[j])
    l.append(s[len(s)-1])
    sum+=eval(''.join(l))
print(sum)

Submission status: Runtime Error

Solution code:
s=input()
ans=0
for i in range(1 << len(s)-1):
    l=[]
    for j in range(len(s)-1):
        if (i>>j)&1==1:
            l.append(s[j])
            l.append("+")
        else:
            l.append(S[j])
    l.append(s[len(s)-1])
    sum+=eval(''.join(l))
print(sum)