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

Solution (Python):

from itertools import combinations
s = input()

ret = 0
for i in range(len(s)):
    for c in combinations(range(1, len(s)), i):
        e = s
        for idx,j in enumerate(c):
            e = e[:idx+j]+"+"+e[idx+j:]
        exec("ret+="+e)
print(ret)

Solution (Python):

"""
Created on Thu Aug 16 04:23:00 2018

@author: Yuki
"""
def sum_from_bit(bit, string, bin_len):
    res = []
    tmp_str = string[0]
    for i in range(bin_len):
        if bit[i] == '0':
            tmp_str += string[1+i]
        else:
            res.append(int(tmp_str))
            tmp_str = string[1+i]
    res.append(int(tmp_str))
    return sum(res)

def main():
    S = input()
    
    n_bit = len(S)-1
    result = []
    for i in range(2**n_bit):
        tmp_bit = bin(i)[2:].zfill(n_bit)
        result.append(sum_from_bit(tmp_bit, S, n_bit))
    print(sum(result))
if __name__=='__main__':
    main()

Solution (Python):
s = input()
ans = 0
for n in range(1 << (len(s) - 1)):
    t = ""
    for j in range(len(s) - 1):
        t += s[j]
        if (n >> j & 1) == 1:
            t += "+"
    t += s[-1]


    sums = 0
    for i, c in enumerate(t):
        if c != "+":
            sums *= 10
            sums += int(c)
        elif c == "+":
            ans += sums
            sums = 0
        if i == len(t) -1:
           ans += sums

print(ans)

Solution (Python):
n = raw_input()
l = len(n)

ans = 0

t = 2**(l-1)

if l == 1:
	print n
	quit()

for i in range(t):
	bit = (bin(i)[2:]).zfill(l-1)
	formula = ''

	p = 0
	b = 0

	while b < len(bit):
		formula += n[p]
		formula += "+" if bit[b] == "1" else ""
		p += 1
		b += 1

	formula += n[-1]
	ans += eval(formula)

print ans

Solution (Python):
S = input()

cnt =0
for i in range(1<<(len(S)-1)):
    num = int(S[0])
    for j in range(len(S)- 1):
        if i & (1 << j):
            cnt += num
            num = 0
        num = num*10 + int(S[j+1])
    cnt += num

print(cnt)

Solution (Python):
s = list(input())
l = len(s) - 1

def calcBit(num):
    res = []
    for _ in range(l):
        res.append(num%2)
        num >>= 1
    return res[::-1]

res = 0
for i in range(2**l):
    b = calcBit(i)
    f = ''
    for j in range(l):
        f += s[j] + b[j]*'+'
    f += s[-1]
    res += eval(f)

print(res)

Solution (Python):
s = input()
n = len(s)
ans = 0
for b in range(1 << (n - 1)):
  sm = 0
  a = int(s[0])
  for i in range(n - 1):
    if b & (1 << i) != 0:
      sm += a
      a = 0
    a = a * 10 + int(s[i + 1])
  ans += (sm + a)
print(ans)

Solution (Python):
S=input()
ans=0
listS=[]
for i in range(len(S)):
    listS.append(int(S[i]))


for j in range(2**(len(listS)-1)):
    l=j
    list1=[]
    for k in range(len(listS)-1):
        if int(l/(2**(len(listS)-2-k)))==0:
            list1.append("")
        else:
            list1.append("+")
        l=l%(2**(len(listS)-2-k))
    
    SUB=str(listS[0])
    for m in range(len(list1)):
        SUB=SUB+list1[m]+str(listS[m+1])
    
    ans+=eval(SUB)
print(ans)

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

Solution (Python):
from itertools import product
S = [int(x) for x in list(input())]
N = len(S)
ans = 0
c = S[0]
for x in product(range(2), repeat = N-1):
    for i in range(1,N):
        if x[i-1] == 0:
            c = c*10 + S[i]
        else:
            ans += c
            c = S[i]
    ans += c
    c = S[0]
print(ans)

Solution (Python):
S = input()
ans = 0
for i in range (1<<(len(S)-1)):
	st = S[0]
	for j in range(len(S)-1):
		if i & (1<<j):
			st = st + '+' + S[j+1]
		else:
			st = st + S[j+1]
	ans = ans + eval(st)
	
print(ans)

Solution (Python):
s = input()








def solve(left, right):
    if len(left) == 0:
        return eval(right)
    return solve(left[:-1], left[-1] + right) + solve(left[:-1], left[-1] + '+' + right)


print(solve(s[:-1], s[-1]))

Solution (Python):
s = input()
a = len(s)

b = []
for i in range(2**(a-1)):
    c = []
    for j in range(a-1):
        if i|(2**j) == i:
            c.append(1)
        else:
            c.append(0)
    b.append(c)
ans = 0
for i in b:
    count = 0
    ss = s[:]
    for j in range(a-1):
        if i[j] == 1:
            ss = ss[:j+1+count]+'+'+ss[j+1+count:]
            count += 1
    ans += eval(ss)
print(ans)

Solution (Python):



def calc(num):
    backup = num
    ans = 0
    bit = 0b0
    
    while not(0b1 & (bit >> len(num)-1)):
        bit += 0b1
        
        count = 0
        for i in range(len(num)-1):
            if 0b1 & (bit >> i):
                num = num[:len(num)-i-count-1] + "," + num[len(num)-i-count-1:]
                count += 1
        
        li = num.split(',')
        for n in li:
            ans += int(n)
        num = backup
    return ans

num_input = input()

if len(num_input) == 1:
    print(num_input)
else:
    ans = calc(num_input)
    print(ans)

Solution (Python):
N=int(input())
m=list(map(int,str(N)))[::-1]
p=0
n=len(str(N))
if n==1:
    print(N)
    exit()
for i in range(2**(n-1)):
    s=(["0"]*8+list(bin(i)[2:]))[::-1]
    s=s[:n-1]
    p+=m[0]
    q=0
    for i in range(n-1):
        if s[i]=="0":
            q+=1
            p+=(10**q)*(m[i+1])
        else:
            q=0
            p+=m[i+1]
print(p)

Solution (Python):
s = input()

length = len(s) - 1
max = 2 ** length

ans = 0
for i in range(max):
    b = bin(i)[2:].zfill(length) + '1'
    index_s = 0
    l = []
    for j, flag in enumerate(b):
        if flag == '1':
            l.append(int(s[index_s:j+1]))
            index_s = j + 1
    
    ans += sum(l)

print(ans)

Solution (Python):
import math
s = list(map(int, input()))

sumofsum = 0

N = len(s)
def combin(n, k):
    com = math.factrial(n) * math.factrial(n - k) / math.factrial(k)
    return con

for i in range(N):
    for j in range(N - i):
        if j == 0:
            if i == 0:
                sumofsum += (10 ** (N - i - j - 1)) * s[i]
            else:
                sumofsum += (10 ** (N - i - j - 1) )* (2 ** (i))* s[i]
        else:
            if i == 0:
                sumofsum += (10 ** (N - i - j - 1)) * (2 ** (j - 1)) * s[i]
            else:
                sumofsum +=( 10 ** (N - i - j - 1)) * (2 ** (i))* (2 ** (j - 1)) * s[i]


print(sumofsum)

Solution (Python):
def calculate_num(index, number, _length, _ways):
    way_list = []
    __ways = _ways

    for i in range(_length - index):
        __ways = __ways/2
        way_list.append(int(__ways))
    way_list[-1] *= 2
    if way_list[-1] == 0:
        way_list[-1] = 1

    result = 0

    for i, way in enumerate(way_list):
        result += number * pow(10, i) * way

    return result


if __name__ == '__main__':
    num = input()
    num_list = [int(i) for i in str(num)]
    length = len(num_list)
    ways = pow(2, length - 1)
    sum_result = 0

    for num, value in enumerate(num_list):
        sum_result += calculate_num(num, value, length, ways)

    print(sum_result)
'''
    "1:1"
    "1:1:2"
    "1:1:2:4 2:2:4 4:4 8"
    "1:1:2:4:8"
    "12345"
'''

Solution (Python):
def main():
	s = input()
	ans = solve(s[0], s[1:])
	print(ans)

def solve(left, right):
	if len(right) == 0:
		return eval(left)
	return solve(left + right[0], right[1:]) + solve(left + '+' + right[0], right[1:])

if __name__ == '__main__':
	main()

Solution (Python):
s=input()
ans=0
def slove(left,right):
    if len(right)==0:
        return eval(left)
    return slove(left+right[0],right[1:])+slove(left+'+'+right[0],right[1:])
ans=slove(s[0],s[1:])
print(ans)

Solution (Python):
S = input()
formula_list = []
total_sum = 0

def calcformula(s) :
    return sum(list(map(int, s.split("+"))))

def stackformula(s, i) :
    
    if len(s) == 1 :
        formula_list.append(s)
        return 
    
    if i >= len(s) :
        return 
    
    formula_y = s[:i] + "+" + s[i:]
    formula_n = s
    
    formula_list.append(formula_y)
    stackformula(formula_y, i + 2)
        
    formula_list.append(formula_n)
    stackformula(formula_n, i + 1)


stackformula(S, 1)

for f in set(formula_list) :
    total_sum += calcformula(f)

print(total_sum)

Solution (Python):

s='+'.join(list(input()))
ans=0
memo=set()
def check(w,n):
    global ans
    if w in memo:
        return
    memo.add(w)
    ans+=eval(w)
    for i in range(1,n+1):
        count=0
        for j in range(len(w)):
            if w[j]=='+':
                count+=1
                if count==i:
                    check(w[:j]+w[j+1:],n-1)

check(s,(len(s)-1)//2)
print(ans)

Solution (Python):


from itertools import product

def calc(s, p):
    assert len(s) == len(p) + 1
    s2 = ""
    for i, c in enumerate(s):
        if i > 0 and p[i - 1]:
            s2 += "+"
        s2 += c
    return eval(s2)

def main():
    s = input()
    n = len(s)
    tf = [True, False]
    ip = list(product(*[tf for i in range(n - 1)]))
    res = 0
    for p in ip:
        res += calc(s, p)
    print(res)

main()

Solution (Python):
s = raw_input()
z = 0
for i in range(len(s)):
	t = 0
	for j in range(len(s) - i):
		t = t * 10 + [1, 2 ** (j - 1)][j > 0]
	z += int(s[i]) * 2 ** i * t
print z

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

Solution (Python):
from itertools import product

s = input()
s2 = '{}'.join(s)

betweenss = product(('', '+'), repeat=len(s)-1)
print(sum(eval(s2.format(*betweens)) for betweens in betweenss))

Solution (Python):
s = input()
n = len(s)
res = 0
for i in range(2**(n-1)):
    k = 0
    b = bin(i)[2:]
    for j in range(len(b)):
        if b[-(j+1)] == '1':
            res += int(s[k:j+1])
            k = j+1
    res += int(s[k:])

            
print(res)

Solution (Python):
import numpy
import re
import math

def main():
	"""
	テストコード実行
	:return:
	"""
	"""
	ビットマスクを用いた解法
	"""
	s = input()
	ans = 0
	for b in range(1 << len(s) - 1):
		x = ""
		for index, num in enumerate(s):
			x += num
			if index != len(s) - 1 and b >> index & 1: x += "+"
		ans += eval(x)
	print(ans)

if __name__ == '__main__':
	main()

Solution (Python):
import numpy
import re
import math

def main():
	"""
	テストコード実行
	:return:
	"""
	"""
	ビットマスクを用いた解法
	"""
	src = list(input())
	sum = 0
	for i in range(2 ** (len(src) - 1)):
		p = bin(i)[2:] 
		
		p = "0" * (len(src) - 1 - len(p)) + p 
		
		x = ""
		for index, num in enumerate(src):
			x += num
			if index != (len(src) - 1) and p[index] == "1":
				x += "+"
		sum += eval(x)
	print(sum)

if __name__ == '__main__':
	main()

Solution (Python):
from itertools import compress, product

s = input()
n = len(s)

indices = range(1, n)
index_maskss = product((0,1), repeat=n-1)
indicess = ([0]+list(compress(indices, masks))+[n] for masks in index_maskss)
ijss = (zip(indices, indices[1:]) for indices in indicess)
sums = (sum(int(s[i:j]) for i, j in ijs) for ijs in ijss)
 
print(sum(sums))

Solution (Python):
from itertools import compress, product
 
s = input()
n = len(s)

index_maskss = product((0,1), repeat=n-1)
indicess = ([0]+list(compress(range(1, n), masks))+[n] for masks in index_maskss)
ijss = (zip(indices, indices[1:]) for indices in indicess)
sums = (sum(int(s[i:j]) for i, j in ijs) for ijs in ijss)

print(sum(sums))

Solution (Python):
from itertools import compress, product

s = input()
n = len(s)

indicess = ([0]+list(compress(range(1, n), masks))+[n] for masks in product((0,1), repeat=n-1))
ijss = (zip(indices, indices[1:]) for indices in indicess)
sums = (sum(int(s[i:j]) for i, j in ijs) for ijs in ijss)
print(sum(sums))

Solution (Python):
from itertools import compress, product

s = input()
n = len(s)

total = 0
for index_masks in product((0,1), repeat=n-1):
  indices = [0] + list(compress(range(1, n), index_masks)) + [n]
  ijs = zip(indices, indices[1:])
  numbers = (int(s[i:j]) for i, j in ijs)
  total += sum(numbers)
print(total)

Solution (Python):
from itertools import count, product
s = input()
n = len(s)
split_indices = ([i*m for i, m in zip(count(1), ms) if m] for ms in product((0,1), repeat=n-1))
split_indices = ([0]+indices+[n] for indices in split_indices)
split_indices = (zip(indices, indices[1:]) for indices in split_indices)
split_indices = (map(lambda ix: int(s[ix[0]:ix[1]]), indices) for indices in split_indices)
print(sum(map(sum, split_indices)))

Solution (Python):
def F(S):
    if len(S) ==1:
        return S[0]
    else:
        S1 = [(10*S[0]+S[1])]+S[2:]
        S2 = S[1:]
        return F(S1)+F(S2)+S[0]*(2**(len(S)-2))

s = input()
x = [int(s[i]) for i in range(len(s))]
print(F(x))

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

bit=0

ans=0

for i in range(2**(N-1)):
    bit=bin(i)
    
    Z=[]
    sf=0
    for k in range(len(bit)-2):
        
        if bit[len(bit)-1-k] =="1":
            
            Z.append(S[sf:k+1])
            sf=k+1
    Z.append(S[sf:])
    
    for k in range(len(Z)):
        ans+=int(Z[k])
print(ans)

Solution (Python):
s = input()
n = len(s)
ans = 0
 
for i in range(2**(n-1)):
    l = list(s)
    for j in reversed(range(1, n)): 
        if (1<<(j-1)) & i > 0:
            l = l[:j] + ['+'] + l[j:] 
    ans += eval(''.join(l))
 
print(ans)

Solution (Python):
S = input()
ans = 0
for i in range(1 << (len(S)-1)):
    eq = S
    k = 0
    for j in range(len(S)-1):
        if i & (1 << j):
            eq = eq[:j+1+k] + "," + eq[j+1+k:]
            k +=1
        else:
            pass
    eq = eq.split(",")
    eq = list(map(int,eq))
    ans += sum(eq)
print(ans)

Solution (Python):
s = input()

n = len(s) - 1

c_list = [list(map(int,format(i,"b").zfill(n))) for i in range(2**n)]

ans = 0

for i in c_list:
    start = 0
    goal = 0
    for j, v in enumerate(i):
        if v == 1:
            goal = j + 1
            ans += int(s[start:goal])
            start = j +1
    else:
        ans += int(s[start:])

print(ans)

Solution (Python):
a = input()
l = len(a)
ans = 0
for i in range(l):
    j = sum([(2**max((k-1),0))*(10**(l-i-k-1)) for k in range(l-i)])
    ans += (2**(i))*j*int(a[i])
print(ans)

Solution (Python):
s = input()

def solve(s, i, bind, ans):
    if i == len(s) - 1:
        return ans + int(bind)
    return solve(s, i+1, s[i+1], int(bind) + ans) + solve(s, i+1, bind + s[i+1], ans)

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

Solution (Python):
def solve(s,i,bind,ans): 
	if i==len(s):
		return ans+int(bind)
	return solve(s,i+1,s[i],int(bind)+ans)+solve(s,i+1,bind+s[i],ans)

s = list(input())
print(solve(s,1,s[0],0))

Solution (Python):
S = input()
n_length = len(S)
result = 0
for i in range(2**(n_length-1)):
    a = bin(i)[2:].zfill(10)
    tmp = 0
    now = ''
    for n in range(len(S)):
        now = S[-n-1] + now
        if a[-n-1] == '1':
            tmp += int(now)
            now = ''
    tmp += int(now) 
    result += tmp
print(result)

Solution (Python):
s=str(input())
ans=0
for i in range(1<<(len(s)-1)):
  st=s[0]
  for j in range(len(s)-1):
    if i & (1<<j):
      st+="+"+s[j+1]
    else:
      st+=s[j+1]
  ans+=eval(st)
print(ans)

Solution (Python):
s = raw_input()
l = len(s)
ans = 0
for p in range(l):
    for q in range(p+1,l+1):
        ans += int(s[p:q]) * (2**max(p-1,0)) * (2**max(l-q-1,0))
print ans

Solution (Python):
S = input()

A = 0
for b in range(pow(2,len(S)-1)):
    ans = 0
    sub = int(S[0])
    for s in S[1:]:
        if b%2==1:
            ans += sub
            sub = int(s)
        else:
            sub *= 10
            sub += int(s)
        b //= 2
    ans += sub
    A += ans
    
print(A)

Solution (Python):
S = input()
R = 0
S = list(S)
temp = []
for i in range(2**(len(S)-1)):
    for m in range(len(S)-1):
        if i+1 & 2**(m) > 0:
            temp.append(S[m] + "+")
        else:
            temp.append(S[m])
    temp.append(S[len(S)-1])
    temp = "".join(temp)
    R += eval(temp)
    temp = []    
print(R)

Solution (Python):
S = list(input())

L = len(S)

plus = [False] * (L-1)

sum = 0

for n in range(1 << (L-1)):
    for i in range(L-1):
        if (n >> i) % 2:
            plus[i] = True
        else:
            plus[i] = False

    stack = []
    for i in range(L):
        stack.append(S[i])
        if i == L - 1:
            sum += int("".join(stack))
            stack = []
        elif plus[i]:
            sum += int("".join(stack))
            stack = []

print(sum)

Solution (Python):
S=input()

N=len(S)

ans=0

plus_place=[]



if int(S) == 1:
    print(1)
    exit()

for i in range(2**(N-1)):
    tmp_bin=bin(i)[2:]
    while(len(tmp_bin) < N-1):
        tmp_bin = '0' + tmp_bin
    plus_place.append(tmp_bin)


for s in plus_place:
    tmp = 0
    next_index=0
    for i,b in enumerate(s) :
        
        if b == "1":
            tmp += int(S[next_index:i+1])
            next_index=i+1
        if i == N-2:
            tmp += int(S[next_index:i+2])



    ans += tmp
                      
    
print(ans)

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

Solution (Python):
s = input()
sum = 0
n = [i for i in s]

l = len(n)

for i in range(2 ** (l-1)):
    
    
    s1 = []
    for j in range(l):
        
        if 1  & i >> j:
            s1.append(n[j])
            s1.append('+')
        else:
            s1.append(n[j])
    s2 = ''
    for i in s1:
        s2 += i
    s2 = s2.split('+')
    sum1 = 0
    for c in s2:
        sum1 += int(c)
    
    sum += sum1

print(sum)

Solution (Python):
from itertools import product

S = input()

summation = 0
for indices in product((0, 1), repeat=len(S) - 1):
    current_S = S[:]

    num_list = []
    counter = 0
    for i in indices:
        if i == 0:
            counter += 1
            continue
        else:
            appended_num, current_S = int(current_S[:counter + 1]), current_S[counter + 1:]
            num_list.append(appended_num)
            counter = 0
    else:
        num_list.append(int(current_S))

    summation += sum(num_list)
print(summation)

Solution (Python):


S = raw_input()
length = len(S)

def dfs(depth, S):

    if depth == length - 1:
        return eval(S)

    
    sum1 = dfs(depth + 1, S)

    
    sum2 = dfs(depth + 1, insert_plus(S, depth))

    return sum1 + sum2

def insert_plus(S, depth):
    d = depth + S.count("+") + 1
    return "{0}{1}{2}".format(S[:d],"+",S[d:])

print dfs(0,S)

Solution (Python):
s=input()
ret=0

for i in range(1<<(len(s)-1)):
    t=list(s)
    
    for j in reversed(range(1, len(s))):
        if i&(1<<(j-1)):
            t=t[:j]+["+"]+t[j:]
    ret+=eval("".join(t))
print(ret)

Solution (Python):
s=input()
def solve(decided, left, idx):
    if idx==len(s):
        return decided+left
    
    ret1 = solve(decided+left,int(s[idx]),idx+1)
    
    ret2 = solve(decided, left*10+int(s[idx]), idx+1)
    return ret1+ret2

print(solve(0,int(s[0]),1))

Solution (Python):
s = input()
ans = 0
for i in range(2**(len(s)-1)):
    tmp = s[0]
    for j in range(len(s)-1):
        if i & (1<<j):
            tmp += '+'
        tmp += s[j+1]
    ans += eval(tmp)
print(ans)

Solution (Python):



from itertools import product


def main():
    S = input()
    ANS = 0
    for c in product(('+', ''), repeat=len(S) - 1):
        shiki = S[0]
        for i in range(1, len(S)):
            shiki += c[i - 1] + S[i]
        ANS += eval(shiki)
    print(ANS)

if __name__ == '__main__':
    main()

Solution (Python):
def return_binary(n, s):
    t = bin(n)[2:]
    while s > len(t):
        t = '0' + t
    t = t + '1'
    return t


def add_up(n, b):
    temp = ''
    total = 0
    for x in range(len(n)):
        temp = temp + n[x]
        if b[x] == '1':
            total = total + int(temp)
            temp = ''
    return total


raw_input = input()
length = len(raw_input)
tot = 0

if length == 1:
    print(raw_input)
else:
    for i in range(2**(length-1)):
        binary = return_binary(i, length-1)
        tot = tot + add_up(raw_input, binary)
    print(tot)

Solution (Python):
S=input()
L=len(S)

total=0
for i in range(2**(L-1)):
    formula=S
    for b in range(L-1):
        if i&2**b!=0:
            formula=formula[:L-b-1]+'+'+formula[L-b-1:]
    ans=eval(formula)
    total+=ans
print(total)

Solution (Python):
import itertools

s=input()
l=len(s)

cand=("+"," ")

ans=0

for i in itertools.product(cand,repeat=l-1):
	siki=s[0]
	for j in range(len(i)):
		if i[j]=="+":
			siki=siki+i[j]+s[j+1]
		else:
			siki=siki+s[j+1]
	ans+=eval(siki)
  
print(ans)

Solution (Python):
def pt(s: list):
    if len(s) == 1:
        return eval(s[0])
    return pt([s[0]+s[1]]+s[2:]) + pt([s[0]+'+'+s[1]]+s[2:])
print(pt(list((input()))))

Solution (Python):
def plus_or_through(s):
    if len(s) <= 1:
        return eval(s[0])
    return plus_or_through([s[0]+s[1]]+s[2:]) + plus_or_through([s[0]+'+'+s[1]]+s[2:])
print(plus_or_through(list(input())))

Solution (Python):
def search(s):
    if len(s) <= 1:
        return eval(s[0])
    return search([s[0]+s[1]]+s[2:]) + search([s[0]+'+'+s[1]]+s[2:])
print(search(list(input())))

Solution (Python):
S = input()
ans = 0
for i in range(2**(len(S)-1)):  
    tmp = S[0]  
    for j in range(len(S)-1):   
        if i & (1<<j):  
            tmp += "+"
        tmp += S[j+1]
    ans += eval(tmp)
print(ans)

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

Solution (Python):
from itertools import product


S = input()
L = len(S)
Y = []

for X in product(['', '+'], repeat=len(S)-1):
    f = S[0]
    for x, s in zip(X, S[1:]):
        f += x + s
    Y.append(eval(f))

print(sum(Y))

Solution (Python):
s = str(input())
n = len(s) - 1
sum = ''
for i in range(1 << n):
    for j in range(len(s)):
        if i & 1 << j:
            sum += str(s[j])
        else:
            sum += str(s[j]) + '+'
sum = sum.rstrip('+')
print(eval(sum))

Solution (Python):
S = list(input())
ans = 0
for i in range(1<<(len(S)-1)):
    f = S[0]
    for j in range(len(S)-1):
        if i&(1<<j):
            f += '+'
        f += S[j+1]
    ans += eval(f)
print(ans)

Solution (Python):
from itertools import product
from collections import deque

S = list(input())
P = ['', '+']

sumN = 0
for pp in product(P, repeat=len(S) -1):
    eq = ''
    SQ = deque(S)
    PQ = deque(list(pp))
    while SQ:
        eq += SQ.popleft()
        if PQ:
            eq += PQ.popleft()
    sumN += eval(eq)

print(sumN)

Solution (Python):
ans = 0
S = list(input())
po = 1

for i in range(2**(len(S)-1)):
    buf = ""
    oper = bin(po)[2:].zfill(len(S))
    for j in range(len(S)-1):
        buf += S[j]
        if oper[j] == "0":
            continue
        elif oper[j] == "1":
            buf += "+"
    buf += S[-1]
    ans += eval(buf)
    if oper[-1] == "0" and i :
        po += 2
    else:
        po += 1
    
print(ans)

Solution (Python):
s = input()
len = len(s)
bit_len = 1 << (len - 1)
ans = 0

for b in range(bit_len):
    num= ord(s[0]) - ord('0')
    for i in range(len - 1):
        if (1 << i) & b != 0:
            ans += num
            num = 0
        num = num* 10 + ord(s[i+1]) - ord('0')
    ans += num

print(ans)

Solution (Python):
if __name__ == '__main__':
    S = input()

    bit_num = 2 ** (len(S) - 1)

    ans = 0
    for i in range(bit_num):
        formula = S[0]
        for j in range(len(S) - 1):
            if i & 2 ** j:
                formula += "+"
            formula += S[j + 1]

        ans += eval(formula)

    print(ans)

Solution (Python):
S = input()
tmp = ['']*len(S)
sum = 0
for i in range(len(S)):
    tmp[i] = S[i]
if len(S) < 2:
    print(int(S))
else:
    for j in range(pow(2,len(S)-1)):
        work = format(j,'b').zfill(len(S)-1)
        storeNUM = tmp[0]
        for k in range(len(work)):
            if work[k] == '1':
                sum += int(storeNUM)
                storeNUM = str(tmp[k+1])
            else:
                storeNUM = storeNUM + str(tmp[k+1])
        sum += int(storeNUM)
    print(sum)

Solution (Python):
s=list(input())
n=len(s)
ans=0
for i in range(1<<(n-1)):

    """
    ここで既に、n-1個の文字間のうち、どこに+を入れるかが決まる。入れるところにはbit
    が立ち(その桁が1となる)、入れないところにはbitが立たない(その桁が0となる)
    """

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

Solution (Python):
s=input()
n=len(s)
ans=0
for i in range(1<<n-1):
    num=s[0]
    for j in range(n-1):
        if i&(1<<j):
            num+="+"+s[j+1]
        else:
            num+=s[j+1]
    ans+=eval(num)
print(ans)

Solution (Python):
s=input()
n=len(s)
ans=0
for i in range(1<<n-1):
    ins=s[0]
    for j in range(n-1):
        if i&(1<<j):
            ins+="+"+s[j+1]
        else:
            ins+=s[j+1]
    ans+=eval(ins)
print(ans)

Solution (Python):
s = input()
a = []
sbox = []

for i in s:
    a.append(int(i))

n = len(a)

def f(i, box, k):
    if i == n-1:
        box += k
        sbox.append(box)
    else:
        f(i + 1, box + k, a[i + 1])
        f(i + 1, box, 10 * k + a[i + 1])

f(0, 0, a[0])
print(sum(sbox))

Solution (Python):
import functools
numbers = list(input())

expressions = set()

def subSum(currentIdx, expr):
    global expressions
    
    if currentIdx == 0:
        expressions.add(convertToString(expr))
        return

    next_expr1 = expr[:]
    next_expr2 = expr[:]
    next_expr2.insert(currentIdx, '+')

    subSum(currentIdx-1, next_expr1)
    subSum(currentIdx-1, next_expr2)

def convertToString(expr):
    ex = str(functools.reduce(lambda t, x: t + x, expr))
    return ex

def culc(expr):
    return sum(list(map(int, expr.split('+'))))

subSum(len(numbers) - 1, numbers)



print(sum(list(map(culc, list(map(str, expressions))))))

Solution (Python):

from itertools import product
def inpl(): return list(map(int, input().split()))

res = 0
S = input()
for P in product(range(2), repeat=len(S)-1):
    r = 0
    t = S[0]
    for p, s in zip(P, S[1:]):
        if p:
            t += s
        else:
            r += int(t)
            t = s
    r += int(t)
    res += r
print(res)

Solution (Python):
s = raw_input()

ans = 0

def dfs(s, nw):
    global ans
    if s == '':
        ans += eval(nw)
        return
    if nw == '':
        dfs(s[1:], nw + s[0])
    else:
        dfs(s[1:], nw + s[0])
        dfs(s[1:], nw + '+' + s[0])

dfs(s, '')
print ans

Solution (Python):
import numpy as np

def many_fomulas(digits):
    mat = np.zeros((len(digits), len(digits)), 'i')

    for i, _ in enumerate(digits):
        if i >= 0:
            mat[i, :i] = 2 ** (i - 1)
        mat[i, i] = 2 ** i

    total = 0
    for i, _ in enumerate(digits):
        for j, v in enumerate(digits):
            total += 10 ** (len(digits) - i - 1) * int(mat[i, j]) * v

    print(total)



many_fomulas([int(d) for d in input()])

Solution (Python):
S = str(input())
n = len(S)
ans = 0

for i in range(1 << n-1):
    ins = S[0]
    for j in range(n-1):
        if i & (1 << j):
            ins += "+" + S[j+1]
        else:
            ins += S[j+1]

    ans += eval(ins)

print(ans)

Solution (Python):
s=str(input())
ans=0
for i in range(1<<(len(s)-1)):
  st=s[0]
  for j in range(len(s)-1):
    if i & (1<<j):
      st+="+"+s[j+1]
    else:
      st+=s[j+1]
  ans+=eval(st)
print(ans)

Solution (Python):





def main():
    S = input()
    L = len(S)

    ans = 0

    for i in range(2**(L-1)):
        nums = S[0]
        for j in range(1, L):
            if i & (1<<(j-1)):
                nums += " "
            nums += S[j]
        
        subtotal = sum(map(int, nums.split()))
        ans += subtotal

    print(ans)

if __name__ == "__main__": main()

Solution (Python):

def rec(s, start, d):
    if d == 0:
        return [s[start:]]

    cand = []
    for i in range(start + 1, len(s)):
        c = rec(s, i, d - 1)
        for cc in c:
            cand.append(s[start:i] + '+' + cc)
    return cand


s = input()



N = len(s)
cnt = 0
for i in range(N):
    eqs = rec(s, 0, i)
    for eq in eqs:
        if len(eq.replace('+', "")) == N:
            cnt += eval(eq)
    
print(cnt)

Solution (Python):
s = list(input())
n = len(s)
ans = 0

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

    ans += eval(fomula)

print(ans)

Solution (Python):
def __main__():
    s = input()
    result = cal(s)
    print(result[0])


def cal(s):
    if len(s) == 0:
        return(0, 1)
    elif len(s) == 1:
        return (int(s), 1)
    else:
        sum, times = 0, 0
        for i in range(len(s)):
            num = int(s[0:(i + 1)])
            result = cal(s[(i + 1):len(s)])
            sum += num * result[1] + result[0]
            times += result[1]
        return (sum, times)
            
__main__()

Solution (Python):
s = list(input())
n = len(s)
ans = 0

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

print(ans)

Solution (Python):
def main():
    num = [int(x) for x in list(input())]
    num.reverse()
    tot = 0
    N = len(num)

    for m in range(N):
        tot += ((2**(N-4)) * (5**(m) - 1) + (2**(N-m-1)) * (10**(m))) * num[m]

    print(int(tot))

if __name__ == '__main__':
  main()

Solution (Python):


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

Solution (Python):
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)

Solution (Python):
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

Solution (Python):



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)