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):
s = input()
ret = 0
for i in range(2**(len(s)-1)):
    t = ""
    for j in s:
        t += j
        if i%2==1:
            t += "+"
        i //= 2
    ret += eval(t)
print(ret)

Solution (Python):
from itertools import combinations_with_replacement, permutations, zip_longest
S = input()
cmb = list(combinations_with_replacement(["", "+"], (len(S)-1)))
prm = set()
for c in cmb:
    for p in permutations(c):
        prm.add(p)

formulas = []
for p in prm:
    formulas.append("".join(x+y for x, y in zip_longest(S, p, fillvalue="")))

ans = 0
for f in formulas:
    ans += eval(f)
print(ans)

Solution (Python):
import itertools
S=raw_input()


n=[i for i in range(1,len(S))]

pattern=[]
for i in range(1,len(S)):
	
	pattern+=list(itertools.combinations(n,i))



a=[]
a.append(S)
for i in pattern:
	prev=0
	n=len(i)
	for j in range(n):
		if j==0:
			if j==n-1:
				a.append(S[0:i[j]])
				a.append(S[i[j]:])
			else:
				a.append(S[0:i[j]])
				prev=i[j]
		elif j==n-1:
			a.append(S[prev:i[j]])
			a.append(S[i[j]:])
			break	
		else:
			a.append(S[prev:i[j]])
			prev=i[j]

print sum(int(i) for i in a)

Solution (Python):
def eval(d,mask):
    s = ''
    for i in xrange(len(mask)):
        s += d[i]
        if mask[i] == '1':
            s += '+'
    s += d[-1]
    l = s.split('+')
    res = sum(map(int,l))
    return res

d = list(raw_input())
tot = 0
for i in xrange(2**(len(d)-1)):
    mask = bin(2**(len(d)-1)+i)[3:]
    tot += eval(d,mask)
print tot

Solution (Python):
s = input()


def calc(formula):
    l = formula.split('+')
    ans = 0
    for n in l:
        ans += int(n)
    
    return ans


def rec(s, cnt, l):
    
    
    
    ret = 0
    if cnt < l:
        ret += rec(s, cnt+1, l)
        ret += rec(s[:cnt] + "+" + s[cnt:], cnt+2, l+1)
        return ret
    else:
        return calc(s)


print(rec(s, 1, len(s)))

Solution (Python):
from collections import defaultdict


def main():
    S = input()
    ans = 0
    
    n = len(S) - 1
    for b in range(2 ** n):
        p_list = [i for i in range(n) if b & 1 << i]
        x, s = [], S[:]
        for p in p_list[::-1]:
            a, s = s[p + 1:], s[:p + 1]
            x.append(a)
        if s:
            x.append(s)
        ans += eval("+".join(x))

    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
import itertools
S = input()
A = [0,1]
N = len(S)
pt = [list(i) for i in itertools.product(A,repeat=N-1)]
ans = 0
for p in pt:
	stack = ""
	for i in range(2*N-1):
		if i % 2 == 1:
			"""
			"+"を足し込むかどうか
			"""
			if i == 0:
				if p[0]: stack += "+"
			else:
				index = i // 2
				if p[index]: stack += "+"
		else:
			"""
			stackに普通に文字を入れていく
			"""
			index = i // 2
			stack+= S[index]
	ans += sum([int(x) for x in stack.split("+")])
print(ans)

Solution (Python):
S = list(map(int,list(input())))
N = len(S)

def func(a,n,l):
    if len(l) == 0:
        return a + n

    l2 = [i for i in l]
    m = l2.pop(0)

    return func(a,10*n+m,l2) + (func(a+n,m,l2))

n = S.pop(0)
print(func(0,n,S))

Solution (Python):
s = [int(x) for x in input()]

t = set()
def calc(p):
    total = 0
    tmp = 0
    for i in range(l):
        tmp = tmp * 10 + s[i]
        if p & (2**i):
            total += tmp
            tmp = 0
    return total + tmp

l = len(s)
total = 0
for i in range(2**(l-1)):
    total += calc(i)
print(total)

Solution (Python):
S = raw_input()

formulas = [S[0]]
for i in range(1,len(S)):
    f1 = formulas[:]
    f2 = formulas[:]
    f1 = map(lambda f: f + S[i], f1)
    f2 = map(lambda f: f + '+' + S[i], f2)
    formulas = f1 + f2

all_sum = 0
for formula in formulas:
    arr = map(int, formula.split('+'))
    all_sum += sum(arr)
print all_sum

Solution (Python):
S = raw_input()
N = len(S)
ans = 0
for i in range(2**(len(S)-1)):
    s = ""
    for j in range(N):
        s += S[j]
        if (i & (2**j)) > 0:
            s += '+'
    ans += eval(s)
print ans

Solution (Python):
s = map(int, raw_input())
l = len(s)
ret = 0
for p, n in enumerate(s):
    for d in range(l-p):
        ret += n * 10**d * 2**p * 2**max(l-2-p-d,0)
print ret

Solution (Python):
def main():
    S = list(str(input()))

    total = 0
    mask = 0
    n = len(S)
    while mask < (1<<(n-1)):
        i = 0
        s = S[:]
        while i < n-1:
            if mask & (1<<i):
                s[i] = s[i] + '+'
            i += 1
        total += eval(''.join(s))
        mask += 1

    print(total)

main()

Solution (Python):
from itertools import product as prod

def main():
    s = input()
    n = len(s)
    sum = 0
    for sym in prod(["","+"],repeat=n-1):
        exp = ""
        for i,c in enumerate(s[:-1]):
            exp += ( c + sym[i] )
        exp += s[-1:]
        sum += eval(exp)
    print(sum)

if __name__ == "__main__":
    main()

Solution (Python):

def main():
    s = input()
    n = len(s)
    sum = 0
    for i in range((1<<(n-1))):
        prev = 0
        exp = ""
        for j in range(n-1):
            if (i>>j)&1:
                exp += s[prev:j+1]
                prev = j+1
                exp += "+"
        exp += s[prev:]
        sum += eval(exp)
    print(sum)
        

if __name__ == "__main__":
    main()

Solution (Python):
import sys
from itertools import accumulate

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    S = [int(i) for i in input()]
    N = len(S)
    sac = [0] + list(accumulate(S))
    ans = 0

    for i in range(N):
        ans += (int(sac[i] * 2**(i - 1)) + 2**i * S[i]) * 10**(N - 1 - i)

    print(ans)

if __name__ == '__main__':
    solve()

Solution (Python):
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    S = input()
    N = len(S) - 1
    ans = 0

    for i in range(2**N):
        bi = bin(i)[2:].zfill(N)
        
        ans += calc(S, bi)

    print(ans)

def calc(S, bi):
    ret = 0
    k = 0

    for i in range(len(S)):
        if i == 0:
            continue
        else:
            if bi[i-1] == '1':
                ret += int(S[k:i])
                k = i

    ret += int(S[k:])

    return ret

if __name__ == '__main__':
    solve()

Solution (Python):
from itertools import product as prod

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

ans = 0
for sym in prod(["", "+"], repeat=n-1):
    form = []
    for i, c in enumerate(s[:-1]):
        form.append(c)
        form.append(sym[i])
    form.append(s[-1])
    ans += eval("".join(form))

print(ans)

Solution (Python):
from itertools import product
s = input()
ans = 0
op = ["", "+"]
for b in product(range(2), repeat = len(s) - 1):
    v = s[0]
    for j in range(1, len(s)):
        v += op[b[j - 1]] + s[j]
    ans += eval(v)

print(ans)

Solution (Python):
S = raw_input()
X = [str(S[0])]
NX = []
for s in S[1:]:
    for x in X:
        NX.append(x + s)
        NX.append(x + "+" + s)
    X = NX[:]
    NX = []
ret = 0
for x in X:
    ret += eval(x)
print ret

Solution (Python):
from collections import defaultdict



def all_split(s):
    if len(s) == 1:
        return [s]

    ans = []
    for i in range(2 ** (len(s) - 1)):
        b = list(map(int, format(i, "0" + str(len(s) - 1) + "b")))
        ans.append(split(s, b))
    return ans


def split(s, split_positions):
    assert len(s) - 1 == len(split_positions)

    ans = []
    pre = 0
    for i, is_split in enumerate(split_positions, start=1):
        if is_split:
            ans.append(s[pre:i])
            pre = i

    ans.append(s[pre:])
    return ans


def main():
    s = input()
    ans = 0
    for x in all_split(s):
        ans += eval("+".join(x))
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict


def split_all(s: str):
    n = len(s)

    ans = []
    for k in range(2 ** (n - 1)):
        t = s
        tmp = []
        b = format(k, "b").zfill(n - 1)
        for i in range(n - 2, -1, -1):
            if b[i] == "1":
                x, y = t[:i + 1], t[i + 1:]
                tmp.append(y)
                t = x
        if t:
            tmp.append(t)
        ans.append(tmp[::-1])

    return ans


def main():
    s = input()
    ans = 0
    for x in split_all(s):
        ans += eval("+".join(x))
    print(ans)



if __name__ == '__main__':
    main()

Solution (Python):
s=input();print(sum(eval(''.join(x+y for x,y in zip(s, t))+s[-1])for t in __import__('itertools').product(['','+'],repeat=len(s)-1)))

Solution (Python):
import itertools
total = 0
s = input()
for t in itertools.product(['', '+'], repeat=len(s) - 1):
    total += eval(''.join(c1 + c2 for c1, c2 in zip(s, t)) + s[-1])
print(total)

Solution (Python):
S = [int(n) for n in input()]
l = len(S)
ans = 0
for i in range(l):
	for j in range(l-i):
		if i+j == l-1:
			t = 1
		else:
			t = 2
		ans += S[i]*10**j*2**(l-j-t)
print(ans)

Solution (Python):
import itertools

s = input()
n = [i for i in s]
ans = 0


for i in range(len(n)):
    for j in itertools.combinations(range(len(n)-1), i):
        temp = [i for i in s]
        for k in j[::-1]:
            temp.insert(k+1, "+")
        temp = "".join(temp)
        temp = temp.split("+")
        temp = map(int, temp)
        ans += sum(temp)

print(ans)

Solution (Python):
s = map(int, list(raw_input()))
sum = 0
for i in xrange(0, int(1 << len(s) - 1)):
    temp_num = 0
    for j in xrange(0, len(s)):
        cur_num = s[j]
        if i % 2 == 1:
            temp_num += cur_num
            if j != len(s) - 1:
                sum += temp_num
                temp_num = 0
        else:
            temp_num += cur_num
        i /= 2
        if j == len(s) - 1:
            sum += temp_num
            temp_num = 0
        temp_num *= 10
print sum


def sum(total, s):
    r = 0
    for i in range(len(s)):
        if i == 0:
            r = total + int(s)
        else:
            r += sum(total + int(s[:i]), s[i:])
    return r

Solution (Python):
from itertools import combinations

S=input()
Sl=len(S)

def cin(pt):
    r=[]
    s=0
    for i in pt:
        t=s,i
        r.append(t)
        s=i
    t=s,Sl
    r.append(t)
    return r

def calc(pt):
    r=0
    for s,e in cin(pt):
        r+=int(S[s:e])
    return r

pl=[i for i in range(1,Sl)]
ans=0
for pn in range(Sl):
    for pt in combinations(pl,pn):
        ans+=calc(pt)
print(ans)

Solution (Python):
from itertools import combinations

def add_combination(S, cmb):
	new_S = ''
	
	for i in range(len(S)):
		new_S += S[i]
		if i in cmb:
			new_S += '+'
	
	return eval(new_S)
	
S = input()
sum_S = int(S)

for i in range(1, len(S)):
	for cmb in combinations(range(len(S)-1), i):
		sum_S += add_combination(S, cmb)

print(sum_S)

Solution (Python):


def f(s,res):
 temp=0
 for i in xrange(len(s)):
  if i==0:
   temp=res+int(s)
  else:
   temp+=f(s[i:],res+int(s[:i]))
 return temp
 
print f(raw_input(),0)

Solution (Python):
S = raw_input()
n = len(S)
total = 0
for i in xrange(1 << (n - 1)):
    value = 0
    for j in xrange(n):
        value = value * 10 + int(S[j])
        if (1 << j) & i:
            total += value
            value = 0
    total += value
print total

Solution (Python):


answer = 0


def calc(leftnum, sum, tempsum , is_insert):

    hitoketa = leftnum % 10
    leftnum = int(leftnum / 10)

    if tempsum == 0:
        tempsum = hitoketa
    else:
        tempsum = int(str(hitoketa) + str(tempsum))

    if is_insert:
        sum += tempsum
        tempsum = 0

    if leftnum == 0:
        if is_insert:
            global answer
            answer += sum
        return

    calc(leftnum, sum, tempsum, True)
    calc(leftnum, sum, tempsum, False)

if __name__ == '__main__':
    inp = int(input())
    calc(inp, 0, 0, True)
    calc(inp, 0, 0, False)
    print(answer)

Solution (Python):

S = input()
sum = 0
for i in range(1, 2**(len(S)-1) ):
    pos = format(i, 'b').zfill(len(S)-1)
    start = 0
    for (j, x) in enumerate(pos):
        if x == str(1):
            sum = sum + int(S[start:j+1])
            start = j+1
    sum = sum + int(S[start:len(S)])
print(sum+int(S))

Solution (Python):
S = map(int, list(raw_input()))

val_list = [S[0]]
exp_list = []

for i in xrange(1, len(S)):
    new_val_list = []
    new_exp_list = []
    for val in val_list:
        new_val_list.append(val + S[i])
        new_exp_list.append([val, S[i]])
    for exp in exp_list:
        new_val_list.append(exp[0] + (exp[1] * 10 + S[i]))
        new_exp_list.append([exp[0], exp[1] * 10 + S[i]])
    new_val_list.append(int(''.join(map(str, S[:i+1]))))
    val_list = new_val_list
    exp_list = new_exp_list

print sum(val_list)

Solution (Python):
def sum(total, s):
    r = 0
    for i in range(len(s)):
        if i == 0:
            r = total + int(s)
        else:
            r += sum(total + int(s[:i]), s[i:])
    return r

s = raw_input()
total = 0

print sum(total, s)

Solution (Python):
g=lambda s:max(1,sum(g(s[i+1:])for i in range(len(s))));f=lambda s:sum(int(s[:i])*g(s[i:])+f(s[i:])for i in range(1,len(s)+1));print(f(input()))

Solution (Python):
s = input()

s_p = []



for i in range(len(s)):
    s_p += s[i]
    s_p += "+"
s_p = s_p[:-1]


s_p_list = []

def bit_list(i, n, bit_str):
    
    tmp = bit_str[:]
    if (i*2+1 == n):
        tmp = "".join(tmp)
        tmp = tmp.split('+')
        tmp = sum(list(map(int, tmp)))
        

        s_p_list.append(tmp)
        return

    
    tmp[i*2+1] = ''
    bit_list(i+1, n, tmp)

    tmp[i*2+1] = '+'
    bit_list(i+1, n, tmp)


bit_list(0, len(s_p), s_p)

print(sum(s_p_list))

Solution (Python):
import math
import itertools

num = input()
ans = num

keta = int(math.log10(num) + 1)
s = [i for i in range(keta - 1)]

number = []
while num > 0:
    number.append(num % 10)
    num = int(num / 10)
number.reverse()

combination = []
for i in range(1, keta):
    combination.extend(list(itertools.combinations(s, i)))

for i in combination:
    temp = 0
    for j in range(keta):
        if j not in i:
            temp = temp * 10 + number[j]
        else:
            ans += temp * 10 + number[j]
            temp = 0
    ans += temp

print ans

Solution (Python):

S = raw_input()
P = len(S)


dp = [[0]*11 for i in range(11)]
def foo(p,a):
    if dp[a][p]:
        return dp[a][p]
    if p == P:
        dp[a][p] = [int(S[a:P])]
        return dp[a][p]
    
    
    if a == p:
        dp[a][p] = foo(p+1,a)
    else:
        num = int(S[a:p])
        dp[a][p] = foo(p+1,a) + map(lambda x:x+num,foo(p+1,p))
    return dp[a][p]
print sum(foo(0,0))

Solution (Python):
s = input().strip()
l = len(s)
print(sum(sum(int(s[i:j]) * 2 ** max(0, l - j - 1) for j in range(i + 1, l + 1)) * 2 ** max(0, i - 1) for i in range(l)))

Solution (Python):

import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

def calc(x, i):
    res = 0
    if i == N:
        j = 0
        for k in x:
            res += int(S[j:k])
            j = k
        return res
    for j in xrange(i + 1, N + 1):
        res += calc(x + [j], j)
    return res

S = raw_input()
N = len(S)
print calc([], 0)

Solution (Python):



def all_split(s):
    if len(s) == 1:
        return [s]
    
    ans = []
    for i in range(2 ** (len(s) - 1)):
        b = list(map(int, format(i, "0" + str(len(s) - 1) + "b")))
        ans.append(split(s, b))
    return ans


def split(s, split_positions):
    assert len(s) - 1 == len(split_positions)

    ans = []
    pre = 0
    for i, is_split in enumerate(split_positions, start=1):
        if is_split:
            ans.append(s[pre:i])
            pre = i

    ans.append(s[pre:])
    return ans


def main():
    s = input()
    ans = 0
    for a in all_split(s):
        ans += eval("+".join(a))
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
class NumExpression:
    def __init__(self, input_value, rank):
        self.raw_value = input_value
        self.rank = rank

    @property
    def value(self):
        list = self.expression.split("+")
        sum = 0
        for num in list:
            sum += int(num)
        return sum

    @property
    def expression(self):
        
        points = self.gen_points(self.rank, len(self.raw_value) - 1)
        
        expression = self.insert_plus(points)
        
        return expression

    def gen_points(self, num, width):
        """
        num → 2進数に変換してリストで返す
        """
        points = [0] * width
        temp = num
        i = 1
        while True:
            p = temp % 2 
            if p == 1:
                points[width - i] = 1
            temp = temp >> 1
            if temp == 0:
                break
            i += 1

        return points

    def insert_plus(self, points):
        """
        point位置に"+"を挿入する
        """
        i = 0 
        new_value = self.raw_value[0:i]
        for point in points:
            new_value += self.raw_value[i:i+1]
            if point == 1:
                new_value += "+"
            i += 1

        new_value += self.raw_value[i:]
        return new_value

class Calculator:
    def __init__(self, input_value):
        self.input_value = input_value
        self.expressions = self.make_expressions()

    def len(self):
        return len(self.input_value)

    def make_expressions(self):
        expressions = []
        for i in range(0, pow(2, self.len()-1)):
            expression = NumExpression(self.input_value, i)
            expressions.append(expression)
        return expressions

    def compute_sum(self):
        sum = 0
        for expression in self.expressions:
            sum += expression.value

        return sum

if __name__ == "__main__":
    num = input()
    c = Calculator(num)
    print(c.compute_sum())

Solution (Python):
import sys
from itertools import combinations

def add_combination(S, cmb):
    new_S = ""

    for i in range(len(S)):
        new_S += S[i]
        if i in cmb:
            new_S += "+"

    return eval(new_S)


S = input()
sum_S = int(S)

for i in range(1, len(S)):
    for cmb in combinations(range(len(S) - 1), i):
        sum_S += add_combination(S, cmb)

print(sum_S)

Solution (Python):
import math

def func(n_str, ptr):

    if len(n_str)==ptr:
        return int(eval(n_str))
    return func(n_str, ptr+1) + func(n_str[:ptr]+"+"+n_str[ptr:], ptr+2)
s = input()    
print(func(s, 1))

Solution (Python):
def SumIndicatedPoint(pcandid):
	point = list(str(pcandid))
	conNum = nums[0]
	count = 1
	sum = 0
	for p in point:
		if p == '0':
			conNum = conNum + nums[count]
		elif p == '1':
			sum = sum + int(conNum)
			conNum = nums[count]
		count = count + 1
	sum = sum + int(conNum)
	
	return sum
	
if __name__ == '__main__':	
	nums = list(input())
	
	ALLSUM = 0
	pcandidstr = '0' + str(len(nums) - 1) + 'b'
	pcandid = 0
	if len(nums) > 1:
		maxcandid = int('1' * (len(nums) - 1),2)
		
		while pcandid <= maxcandid:
			ALLSUM = ALLSUM + SumIndicatedPoint(format(pcandid,pcandidstr))
			pcandid = pcandid + 1
	elif len(nums) == 1:
		ALLSUM = int(nums[0])
	print(str(ALLSUM))

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

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

print(res)

Solution (Python):
import itertools


def sum_split_num(num, idxs):
    idxs.insert(0, 0)
    idxs.append(len(num))
    return sum(int(num[idxs[i]:idxs[i+1]]) for i in range(len(idxs)-1))


S = input()
ans = int(S)
all_idxs = list(range(1, len(S)))
for i in range(1, len(S)):
    for idxs in itertools.combinations(all_idxs, i):
        ans += sum_split_num(S, list(idxs))
print(ans)

Solution (Python):
s=str(input())
n=len(s)-1
sum_s=0
for i in range(2**n):
    k_str=format(i,'b').zfill(n)

    ans=''

    for i in range(n):
        ans += s[i]
        if k_str[i]=='0':
            ans= ans + ''
        else:
            ans= ans +','

    ans=ans+s[-1]
    sum_s += sum(list(map(int,ans.split(','))))

print(sum_s)

Solution (Python):
import itertools

S = raw_input()

n = len(S)-1
retu = range(n)
ans = 0
for r in range(n+1):
    for c in itertools.combinations(retu, r):
        if not c:
            ans += int(S)
        else:
            ans += int(S[0:c[0]+1])
            for i in range(r-1):
                ans += int(S[c[i]+1:c[i+1]+1])
            ans += int(S[c[r-1]+1:])

print ans

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

Solution (Python):
s = str(input())
b = 2**(len(s)-1)-1
suma = 0

for i in range(0,(2**(len(s)-1)-1)+1):
    ans = list(str(s))
    binlist = list(str(format(b,'0' + str(len(s)-1) + 'b')))
    a = 0
    for i in range(0,len(binlist)):
        if binlist[i] == '1':
            ans.insert((i+1)+a,"+")
            a+=1

    b-=1
    suma += eval(''.join(ans))

print(suma)

Solution (Python):
(lambda nums: (lambda index, itertools=__import__("itertools"): print(sum([eval("".join((lambda t: [[t.insert(j, "+") for j in reversed(i)], t][1])(list(nums)))) for i in itertools.chain(*[itertools.combinations(index, x) for x in range(len(index) + 1)])])))(range(1, len(nums))))(input())

Solution (Python):
orig_a = input().strip()
total = 0
l = len(orig_a)

for i in range(2 ** (l - 1)):
    a = orig_a[:]
    for j in range(l - 1):
        if (i >> j) % 2:
            a = a[:l-j-1] + "+" + a[l-j-1:]
    total += eval(a)
print(total)

Solution (Python):
def sum_loop(sum, s):
    r = 0
    for i in range(len(s)):
        if i == 0:
            r = sum + int(s)
        else:
            r += sum_loop(sum + int(s[:i]), s[i:])
    return r

s = raw_input()
print sum_loop(0, s)

Solution (Python):


def add_roop(pre_result, pro_s):
    result = 0

    for i in range(len(pro_s)):
        if i == 0 :
            result = pre_result + int(pro_s)
        else:
            result =  result + add_roop(pre_result + int(pro_s[:i]), pro_s[i:])

    return result

if __name__ == "__main__":
    
    s = raw_input()
    print add_roop(0, s)

Solution (Python):
S = input()


def f(s):
    if len(s)==1:
        return [s]
    def add(st,ls):
        return [st+s for s in ls]
    return add(s[0],f(s[1:])) +add(s[0]+'+',f(s[1:]))


print(sum(map(eval,f(S))))

Solution (Python):

import math

data = raw_input()
len_data = len(data)
split_point = []
range_max = 2**(len_data-1)
for i in xrange(range_max):
	split_point.append(format(i,"0"+str(int(math.log(range_max,2)))+"b"))













result = 0
bias = 0
for bit_str in split_point:
	origin = data
	for i in xrange(len(bit_str)):
		if bit_str[i] == "1":
			origin = origin[:i+1+bias] + "+" + origin[i+1+bias:]
			bias = bias+1
	result = result + eval(origin)
	bias = 0
print result

Solution (Python):
import sys

s = list(raw_input())
if len(s) == 1:
	print str(int(''.join(s)))
	sys.exit()

sequence = [x for x in range(2**( len(s) -1 ))]

total = 0
def get_binary(seq):
	r = ''
	while seq > 0:
		r = r + str(seq % 2)
		seq = seq / 2
	if (len(list(r)) < (len(s) - 1)):
		for _ in range(len(s) - 1 - len(list(r))):
			r = r + '0'
	return list(r)

for seq in sequence:
	subtotal = 0
	index = 1
	num = s[0]
	b = get_binary(seq)
	for x in b:
		if x == '0':
			num = num + s[index]
		else:
			subtotal = subtotal + int(num)
			num = s[index]
		index = index + 1
	total = total + subtotal + int(num)

print str(total)

Solution (Python):
import itertools

s = input()

sum = 0

for bs in itertools.product([0, 1], repeat = len(s) - 1):
    ps = list(itertools.compress(range(1, len(s)), bs))
    ls = [0] + ps
    rs = ps + [len(s)]
    for l, r in zip(ls, rs):
        sum += int(s[l:r])

print(sum)

Solution (Python):
S = input()
Slist = list(S)
def cut(l, i): 
    n = len(l)
    if n == 1:
        return int(l[0])+i 
    if n == 0:
        return 0
    else: 
        sum = int(''.join(l))+i 
        for jj in range(n-1):
            
            j=jj+1 
            
            sum += cut(l[j:n], int(''.join(l[0:j]))+i)
            
        return int(sum)
        
print(cut(Slist, 0))

Solution (Python):



def solve(s):
    n = len(s)
    base = list("+".join(s))
    ans = 0
    for t in range(1 << (n - 1)):
        xs = base[:]
        for i in range(n - 1):
            if t & (1 << i) > 0:
                xs[2 * i + 1] = ""
        eq = "".join(xs)
        ans += eval(eq)
    return ans


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


if __name__ == '__main__':
    main()

Solution (Python):
def rec(S, i):
    if len(S) < i+1:
        return [S]
    
    return rec(S[:i] + "+" + S[i:], i+2) + rec(S, i+1) + [S[:i] + "+" + S[i:], S]


S = raw_input()
print sum([eval(s) for s in list(set(rec(S, 1)))])

Solution (Python):
if __name__ == "__main__":
    S = input()
    N = len(S)
    result = 0
    for bit in range(1 << (N - 1)):
        tmp = ""
        for x in range(N - 1):
            tmp += S[x]
            if ((bit >> x) & 1):
                tmp += '+'
        tmp += S[-1]
        result += eval(tmp)
    print (result)

Solution (Python):
import ast

def pattern(li, el, space, acc, xs):
  if len(li) != 1:
    acc.append(el)
    acc.append(space)
    al = li.pop(0)
    pattern(list(li), al, '+', list(acc), xs)
    pattern(list(li), al, '', list(acc), xs)
  else:
    acc.append(el)
    acc.append(space)
    al = li.pop(0)
    acc.append(al)
    xs.append(ast.literal_eval(''.join(acc)))

li = list(input())
el = li.pop(0)
xs = []

if len(li) != 0:
  pattern(list(li), el, '+', [], xs)
  pattern(list(li), el, '', [], xs)

if len(li) != 0:
  print(sum(xs))
else:
  print(int(el))

Solution (Python):
class ManyFormulas:
	def getSum(self,string):
		length = len(string)
		ans = 0
		t = 0
		while t<1<<(length-1):
			num = int(string[0]) - int("0")
			for i in range(length-1):
				if t & (1<<i):
					ans += num
					num = 0
				num = num * 10 + int(string[i+1]) - int("0")
			ans += num
			t += 1
		print ans

if __name__ == "__main__":
	string = raw_input()
	m = ManyFormulas()
	m.getSum(string)

Solution (Python):
memo = set([])
def f(a):
    global ans
    ans += eval('+'.join(a))
    n = len(a)
    for i in range(n-1):
        b = a[:i] + [a[i]+a[i+1]] + (a[i+2:] if i != n-2 else [])
        s = '+'.join(b)
        if not s in memo:
            memo.add(s)
            f(b)
l = list(input())
ans = 0
f(l)
print(ans)

Solution (Python):
s = list(input())
ans=0
for i in range(2**(len(s)-1)):
    ops=[]
    d=i
    for j in range(len(s)-1):
        if d%2==1:
            ops.append('+')
        else:
            ops.append('')
        d//=2
    form=[]
    for i in range(len(ops)):
        form.append(s[i])
        form.append(ops[i])
    form.append(s[-1])
    
    ans+=eval(''.join(form))
print(ans)

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

totals = [[]] * len(S)
def rec(S, num, totals):
    totals[num] = [int(''.join(S[:num+1]))]
    for idx in range(num):
        for item in totals[idx]:
            totals[num].append( item + int(''.join(S[idx+1:num+1])) )
    return totals

sl = len(S)
num = 1
totals[0].append( int(S[0]) )
while num < sl:
    totals = rec(S, num, totals)
    num += 1

print( sum(totals[-1]) )

Solution (Python):
import itertools

def split(xs, t):
    total = 0
    tmp = []
    for i, x in enumerate(xs):
        if i in t:
            total += int(''.join(tmp))
            tmp = [x]
        else:
            tmp.append(x)
    if tmp:
        total += int(''.join(tmp))
    return total


def main():
    nums = list(input())
    length = len(nums)
    total = 0
    for i in range(length):
        for t in itertools.combinations(range(1, length), i):
            total += split(nums, t)
    print(total)

if __name__ == '__main__':
    main()

Solution (Python):
memo = set([])
def f(a):
    global ans
    ans += eval('+'.join(a))
    if len(a) < 3 : return
    for i in range(len(a)-1):
        b = a[:i] + [a[i]+a[i+1]]
        if i != len(a)-2 : b += a[-(len(a)-2-i):]
        c = '+'.join(b)
        if not c in memo:
            memo.add(c)
            f(b)
s = input()
l = list(s)
ans = int(s)
if len(l)>1:
    f(l)
print(ans)

Solution (Python):
import itertools

def spl(s, t):
    lst = list(s)
    for x in reversed(t):
        lst.insert(x, '+')
    return eval(''.join(lst))


def main():
    nums = input()
    length = len(nums)
    total = 0
    for i in range(length):
        for ts in itertools.combinations(range(1, length), i):
            total += spl(nums, ts)
    print(total)

if __name__ == '__main__':
    main()

Solution (Python):
from itertools import combinations
import copy

def add_combo(c, len_S, len_combo, S):
    S_copy = copy.deepcopy(S)
    total_len = len_S + len_combo
    combo_total = 0
    cnt = 1
    for i in c:
        S_copy.insert(i+cnt, '+')
        cnt += 1
    last = 0
    nums = []
    plus_count = 0
    for j in range(0, total_len):
        if S_copy[j] == '+':
            nums.append(S_copy[last:j])
            plus_count += 1
            if plus_count == len_combo:
                nums.append(S_copy[j+1:])
            last = j+1
    for n in nums:
        combo_total += int("".join(n))
    return combo_total


if __name__ == '__main__':
    S = list(input())
    no_plus = int("".join(S))
    len = len(S)
    all_plus = 0
    total = 0
    for x in S:
        all_plus += int(x)
    for i in range(1, len):
        combo = combinations(range(0, len-1), i)
        for c in combo:
            total += add_combo(c, len, i, S)
            
    total += no_plus
    
    print(total)

Solution (Python):

def combi(n):
  cmb = []
  end = 2 ** n
  for i in range(end):
    b = list(bin(i).replace('0b', ''))
    b = '0' * n + ''.join(b)
    b = b[-n:]
    cmb.append(list(b))
  return cmb


str = input()

n = len(str) - 1
cmb = combi(n)
sentences = []
for c in cmb:
  s = str
  for i in range(n - 1, -1, -1):
    if c[i] == '1':
      i += 1
      s = s[:i] + '+' + s[i:]
  sentences.append(s)

sum = 0
for sentence in sentences:
  nums = sentence.split('+')
  for num in nums:
    sum += int(num)
    
print(sum)