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

import sys
import itertools

def solve(S: str):
    LEN = len(S)
    bit_list = list(itertools.product([0, 1], repeat=LEN-1))
    s = S[::-1]
    answer=0
    for b in bit_list:
        a = 0
        keta =0 
        for i in range(LEN):
            a += int(s[i])*10**keta
            if i == LEN-1:
                break
            keta+=1
            if b[i] == 1:
                keta = 0
        answer += a
            
            
    print(answer)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)
    solve(S)

if __name__ == '__main__':
    main()

Solution (Python):
def f(s, t):
    if t == '':
        return sum(map(int, s.split('+')))
    else:
        return f(s + t[0], t[1:]) + f(s + '+' + t[0], t[1:])


S = input()
print(f(S[0], S[1:]))

Solution (Python):
import itertools

S = [ (n) for n in input()]
ans = []
n= len(S)-1

l = ["+", ""]
pattern = list(itertools.product(l, repeat=n))
for p in pattern:
    t = ""
    for i in range(n):
        t += S[i]+p[i]
    t=t+S[n]
    ans.append(eval(t))

print(sum(ans))

Solution (Python):


import itertools

S = input()

ans_list = []

for plus_pattern in list(itertools.product(["","+"], repeat = len(S)-1)):

    formula = ""
    for idx in range(len(S)-1):
        formula += S[idx]
        formula += plus_pattern[idx]

    formula += S[-1]
    ans_list.append(eval(formula))

print(sum(ans_list))

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

def func(n, s):
    n += 1
    if n==len(Sl)-1:
        a = sum([int(i) for i in (s+Sl[n]).split("+")])
        b = sum([int(i) for i in (s+"+"+Sl[n]).split("+")])
        return a + b
    else:
        return func(n, s+Sl[n]) + func(n, s+"+"+Sl[n])

if len(Sl)==1:
    print(Sl[0])
else:
    print(func(0, Sl[0]))

Solution (Python):
S = input().strip()

ans = 0
for i in range(2**(len(S)-1)):
  e = ['' if c == '0' else '+' for c in format(i,'b').zfill(len(S))]
  ans += eval(''.join(a+b for a,b in zip(e,S)))

print(ans)

Solution (Python):
l=list(input())
n=len(l)
if n==1:
    print(l[0])
    exit()
op=['0','1']
for i in range(n-2):
    tmp=[]
    for j in op:
        tmp.append(j+'0')
        tmp.append(j+'1')
    op=tmp
ans=0
for i in op:
    k=list(i)
    k.append('2')
    s=l[0]
    t=0
    for j in range(n):
        if k[j]=='1':
            s+=l[j+1]
        elif k[j]=='0':
            t+=int(s)
            s=l[j+1]
        else:
            t+=int(s)
    ans+=t
print(ans)

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

def SplitSum(i, t):
    if i == n-1:
        return sum(list(map(int, t.split('+'))))
    
    return SplitSum(i+1, t+S[i+1]) + SplitSum(i+1, t+'+'+S[i+1])

print(SplitSum(0, S[0]))

Solution (Python):
st = input()
total = int(st)
signs = len(st) - 1
for i in range(1, 2 ** signs):
    start = 0
    for j in range(1, signs + 1):
        if (i & (1 << (j - 1))) >> (j - 1) == 1:
            total += int(st[start:j])
            start = j
    total += int(st[start: ])
print(total)

Solution (Python):
s=input()
n=len(s)
def dfs(i,x):
    if i==n-1:
        return sum(list(map(int,x.split('+'))))
    return dfs(i+1,x+s[i+1])+dfs(i+1,x+'+'+s[i+1])
print(dfs(0,s[0]))

Solution (Python):
def splitter(str):
    for i in range(1, len(str)):
        start = str[0:i]
        end = str[i:]
        yield (start, end)
        for split in splitter(end):
            result = [start]
            result.extend(split)
            yield result


if __name__ == "__main__":
    s = str(input())
    possibilities = list(splitter(s))
    sum = int(s)
    for i in possibilities:
        for j in i:
            sum += int(j)
    print(sum)

Solution (Python):
S = input()
S_prime = ''
for c in S:
    S_prime += c + '+'
S_prime = S_prime[:-1]
def rem(s, N, target = '+'):
    cnt = -1
    ind = 0
    for i, c in enumerate(s):
        if c == target:
            cnt += 1
        if cnt == N:
            ind = i
            break
    return s[:i] + s[i+1:]
def f(s, N):
    
    
    
    tot = sum(map(int, s.split("+")))  
    for i in range(N, s.count("+")):
        tot += f(rem(s, i), i)
    return tot
print(f(S_prime, 0))

Solution (Python):
s=input()
n=len(s)
def dfs(i,x):
    if i==n-1:
        return sum(list(map(int,x.split('+'))))
    return dfs(i+1,x+s[i+1])+dfs(i+1,x+'+'+s[i+1])
print(dfs(0,s[0]))

Solution (Python):
s = input()

op_count = len(s) - 1
op_list = []
for i in range(2**op_count):
    op = [''] * op_count
    for j in range(op_count):
        if (i >> j) & 1:
            op[op_count - 1 - j] = '+'
    op_list.append(op)

ans = 0
for i in range(2**op_count):
    cur = 1
    t = s
    for j in range(op_count):
        if op_list[i][j] == '+':
            t = t[:j + cur] + "+" + t[j + cur:]
            cur += 1
    ans += eval(t)
print(ans)

Solution (Python):

S = input()
n = len(S)
 
def dfs(i, k):
    
    if i == n-1:
        return sum(list(map(int,k.split("+"))))
    
    return dfs(i+1,k+S[i+1])+dfs(i+1,k+"+"+S[i+1])
 
print(dfs(0,S[0]))

Solution (Python):
S = input()

patterns = []
def make_patterns(S, pairs, i = 1):
  global patterns
  
  if i == len(S):
    patterns.append(list(map(int, pairs.split("+"))))
  else:
  	make_patterns(S, pairs + "+" + S[i], i + 1)
  	make_patterns(S, pairs + S[i], i + 1)
  
make_patterns(S, pairs = S[0], i = 1)
print(sum([sum(pattern) for pattern in patterns]))

Solution (Python):
S = input()

if len(S) == 1:
  print(int(S))
else:
  ans = 0
  for i in range(1<<(len(S)-1)):
    SP = []
    for j in range(len(S)-1):
      if (i>>j)&1 == 1:
        SP.append(j)
    SP += [len(S)-1]
    
    idx = 0
    for sp in SP:
      ans += int(S[idx:sp+1])
      idx = sp+1
  print(ans)

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

def f(i,t):
    if i == n-1:
        return sum(list(map(int, t.split('+'))))
    
    return f(i+1,t+s[i+1]) + f(i+1,t+'+'+s[i+1]) 

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

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

s = input()
n = len(s)

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

Solution (Python):
from __future__ import print_function


import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

def lcm(n,m):
    return int(n*m/gcd(n,m))

import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace

from queue import PriorityQueue as pq

def reduce(p, q):
    common = fractions.gcd(p, q)
    return (p//common , q//common )



import random


def main():
    s=input().strip()
    n=len(s)-1
    NUM_CASE= 2**n
    sum=0
    for case in range(0,NUM_CASE):
        left=0
        for index in range(n):
            if (case>>index) & 1 == 1:
                sum+=int(s[left:index+1])
                left=index+1
            else:               
                continue
        index=n
        sum+=int(s[left:index+1])
    print(sum)  
    return

if __name__ == '__main__':
    main()

Solution (Python):
S = input()

N = len(S)
cnt = 0

for i in range(1 << (N - 1)):
    tmp = S[0]
    for j in range(N - 1):
        if (1 << j) & i:
            tmp += '+'
        tmp += S[j + 1]
    cnt += eval(tmp)

print(cnt)

Solution (Python):
import itertools
s=input()
li=["+",""]
lli=list(itertools.product(li,repeat=len(s)-1))
ans=0
for k in lli:
  val=""
  for i,j in zip(s,k):
    val+=i+j
  val+=s[-1]
  ans+=eval(val)
print(ans)

Solution (Python):
S = input()
ans = 0
for i in range(2**(len(S)-1)):
    tmp = []
    prev = 0
    for j in range(1, len(S)):
        if (i >> (j-1)) % 2 == 1:
            if len(S[prev:j]) != 0:
                tmp.append(int(S[prev:j]))
                prev = j
    if len(S[prev:]) != 0:
        tmp.append(int(S[prev:]))
    else:
        print(prev)
    ans += sum(tmp)
print(ans)

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


s_tmp = s[:]
s_str = ""
ans = 0

if len(s)==1:
    print(int(s[0]))
else:
    for i in range(pow(2,len(s_tmp)-1)):
        s_str = s.pop(0)
        j = 0
        while len(s) > 0:
            i_bin = list(format(i,"010b"))
            
            if i_bin[len(i_bin)-j-1] == "1":
                s_str += "+"
            s_str += s.pop(0)
            j += 1
        
        ans += eval(s_str)
        s = s_tmp[:]
        s_str = ""
    print(ans)

Solution (Python):
s = input()

sum = 0
for bit in range(1 << (len(s) - 1)):
    expr = s[0]
    for i in range(len(s) - 1):
        if bit & 1 << i:
            expr += '+'
        expr += s[i + 1]
    sum += eval(expr)

print(sum)

Solution (Python):


def calcA(S):
    Num=0
    for i in range (1,len(S)):
        A = int("".join(S[:i]))
        lenB=len(S[i:])
        Num += A*(2**(lenB-1))+calcA(S[i:])
    
    Num += int("".join(S))
    return Num


N = list(input())
print(calcA(N))

Solution (Python):
s = input().rstrip()
n = len(s)
res = 0
for i in range(2**(n - 1)):
    bs = bin(i)[2:].rjust(n - 1, '0')
    ss = s[0]
    for b, c in zip(bs, s[1:]):
        if b == '1':
            ss += '+'
        ss += c
    res += eval(ss)
print(res)

Solution (Python):
ans = 0

def go(s,index,cnt):
  if cnt == 0:
    temp = ''.join(s).replace(" ","")
    global ans
    ans+=eval(temp)
  else:
    for i in range(index,len(s),2):
      s[i] = '+'
      go(s,i+2,cnt-1)
      s[i] = ' '

s1 = input()
ans = int(s1)

s2 , k = "" , 0

for i in range(0,2*len(s1)-1):
  if i%2 == 0 : 
    s2+=s1[k]
    k+=1
  else:
    s2+=' '

s2 = list(s2)

for i in range(1,len(s1)):
  go(s2,1,i)

print(ans)

Solution (Python):
S = input()
ans = 0
pattern = [format(i, 'b').zfill(len(S) - 1) for i in range(2 ** (len(S) - 1))]

for i in pattern:
    temp = ''
    pm = i.translate(str.maketrans({'0': '-', '1': '+'}))
    for j in range(2 * len(S) - 1):
        if j % 2 == 0:
            temp += S[j // 2]
        else:
            temp += pm[j // 2]
    temp = temp.replace('-', '')
    ans += eval(temp)

print(ans)

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

li=[S[0]]

for i in range(1,N):
    f=[]
    for j in li:
        f.append(j+S[i])
        f.append(j+"+"+S[i])
        li=f
ans=0
for s in li:
    sum1=0
    temp=0
    for i in range(len(s)):
        if s[i]=="+":
            sum1+=temp
            temp=0
        else:
            temp=temp*10+int(s[i])
    sum1+=temp
    ans+=sum1

print(ans)

Solution (Python):
import itertools

S=list(input())
N=len(S)

lis=list(range(1,N))
combi=[]
for i in range(N):
    a=list(itertools.combinations(lis,i))
    combi.extend(a)

ans=0  
for s in combi:
    sum=0
    temp=[]
    for i in range(N):
        if i in s:
            sum+=int("".join(temp))
            temp=[S[i]]
        else:
            temp.append(S[i])
    sum+=int("".join(temp))
    ans+=sum
print(ans)

Solution (Python):

import functools


def eval_sum(s_index, i):
    
    if i == len(s_index) - 1:
        return eval(functools.reduce(lambda x, y: x + y[0] + y[1], s_index, ''))
    else:
        return eval_sum(s_index[:], i + 1) + eval_sum(s_index[:i] + [[s_index[i][0], '+']] + s_index[i + 1:], i + 1)


s = input()
s_index = list(map(lambda x: [x, ''], s))

print(eval_sum(s_index, 0))

Solution (Python):
import itertools
s = input()
li = ["+", ""]
lli = list(itertools.product(li, repeat=len(s)-1))
ans = 0
for k in lli:
  val = ""
  for i, j in zip(s, k):
    val += i + j
  val += s[-1]
  ans += eval(val)
print(ans)

Solution (Python):
s = input()

n = len(s)-1
ans = 0

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

print(ans)

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

Solution (Python):
S=input();l=len(S);print(sum(eval("".join(sum(zip(["+"*(i&2**j)for j in range(l)],S),())))for i in range(2**l))//2)

Solution (Python):
S=input();s=0;l=len(S)-1
for i in range(2**l):
    T=S
    for j in range(l):
        if i&(2**j):T=T[:l-j]+"+"+T[l-j:]
    s+=eval(T)
print(s)

Solution (Python):
import sys
input=sys.stdin.readline

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

if __name__ == '__main__':
    main()

Solution (Python):
import sys
input=sys.stdin.readline



def bins(n, m, k):
    
    s = ""
    while n > 0:
        s = str(n%m) + s
        n //= m
    s = "0"*(k-len(s)) + s
    return s

def main():
    s = input().strip()
    n = len(s)-1 
    ans = 0
    
    
    for i in range(2**n):
        b = bins(i,2,n)
        t = s[0]
        for j in range(n):
            if b[j] == "1":
                t += "+"
            t += s[j+1]
        ans += eval(t)
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
from sys import stdin
import itertools
S = (stdin.readline().rstrip())
ans = 0
s = ""
for k in list(itertools.product(["","+"],repeat=len(S)-1)):
    
    for i,j in itertools.zip_longest(S,k,fillvalue=""):
        s = s+i+j
        
    ans += eval(s)
    s = ""
print(ans)

Solution (Python):
import itertools
s = input()
num_place = len(s) - 1

if num_place == 0:
  result = int(s)
else:
  list_place_plus = list(itertools.product(range(2), repeat=num_place))
  result = 0
  for one_place in list_place_plus:
    start = 0
    for place, check in enumerate(one_place):
      if check == 1:
        result += int(s[start:place+1])
        start = place + 1
      if place + 1 == num_place:
        result += int(s[start:])
print(result)

Solution (Python):
import itertools as it

S = input()
ans = 0
for config in it.product(range(2), repeat=len(S) - 1):
    eq = ""
    for i in range(len(S) - 1):
        eq += S[i] + "+" if config[i] == 1 else S[i]
    eq += S[-1]
    ans += sum([int(i) for i in eq.split("+")])
print(ans)

Solution (Python):
from itertools import product

s = input()

ans = 0
for p in product("10", repeat=len(s)-1):
    formula = ""
    for i, l in enumerate(p):
        formula += s[i] + "+" * int(l)
    formula += s[-1]
    sol = eval(formula)
    ans += sol

print(ans)

Solution (Python):
S=input()
n=len(S)-1
comb=[[[] for i in range(n+1)] for j in range(n+1)]
for i in range(1,n+1):
    for j in range(1,n+1):
        if i>=1 and j==1:
            comb[i][j]=[[k] for k in range(1,i+1)]
        elif i==j:
            comb[i][j]=[[k for k in range(1,i+1)]]
        elif i>j:
            for m in range(len(comb[i-1][j-1])):
                comb[i][j]+=[comb[i-1][j-1][m]+[i]]
            comb[i][j]+=comb[i-1][j]
s=0
for i in range(1,n+1):
    cut_l=comb[n][i]
    for j in range(len(cut_l)):
        cut=[0]+cut_l[j]+[n+1]
        lis=[]
        for k in range(len(cut)-1):
            lis.append(int(S[cut[k]:cut[k+1]]))
        s+=sum(lis)
print(s+int(S))

Solution (Python):
def dfs(i,S):
    if i == n-1:
        return eval(S)
    return dfs(i+1,S+s[i+1]) + dfs(i+1,S+"+"+s[i+1])

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

Solution (Python):
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
n = len(s)
ans = 0
for flag in itertools.product([0,1], repeat=n-1):
    cnt = int(s[-1])
    c = 0
    for i,ff in enumerate(flag):
        if ff:
            cnt += int(s[n-i-2])
            c = 0
        else:
            cnt += int(s[n-i-2]) * 10 ** (c+1)
            c += 1
    
    ans += cnt
print(ans)

Solution (Python):
S = input()
N = len(S)
x = [0] * N
ans = 0
for i in range(N):
  x[i] = int(S[i])
for i in range(N):
  for j in range(N-i):
    if i+j == N-1:
      ans = ans + x[i] * pow(10, j) * pow(2,(N-j-1))
    elif i + j >= N:
      pass
    else:
      ans = ans + x[i] * pow(10, j) * pow(2,(N-j-2))
print(ans)

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

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

Solution (Python):
S = input()
N = len(S)-1
ans = 0

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

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7



S = input().rstrip()
l = list(S)
N = len(l)

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

def getbit(i, length):
    return format(i, '0' + str(length) + 'b')

bits = []
for i in range(2**(N-1)):
    bits.append(getbit(i, N-1))


ans = 0

for i in range(len(bits)):
    s = str(l[0])

    bitlist = list(bits[i])
    for j in range(len(bitlist)):
        if bitlist[j] == '0':
            pass
        else:
            s += '+'

        s += str(l[j+1])

    ans += eval(s)

print(ans)

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


result = 0
for i in range(2 ** (len(s) - 1)):
    
    
    
    
    
    
    
    num_str = s[0]
    for j in range(0, len(s) - 1):
        if ((i & (2 ** j)) >> j) == 1:
            
            num_str += '+'
        num_str += s[j + 1]
    result += eval(num_str)

print(result)

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

def f(i, a):
    if i == N-1:
        return sum(list(map(int, a.split('+')))) 
    
    return f(i+1, a + S[i+1]) + f(i+1, a + '+' + S[i+1])

print(f(0, S[0]))

Solution (Python):
s=input()
n=len(s)
ans=int(s)
for bit in range(1<<(n-1)):
    pattarn = []
    for j in range(n):
        if (bit & (1<<j)):
            pattarn.append(j)
    if len(pattarn)==0:
        continue
    left=0
    res=0
    for i in range(len(pattarn)):
        res+=int(s[left:pattarn[i]+1])
        left=pattarn[i]+1
    ans+=res+int(s[pattarn[-1]+1:])
print(ans)

Solution (Python):
Som=list(str(input()))
S=[]
for i in Som:
    S.append(int(i))
if len(S)>=3:
    nums=0
    for x in range(len(S)):
        if x==0:
            nums+=S[0]*(10**(len(S)-1))
        else:
            nums+=S[x]*(10**(len(S)-1-x))*(2**(x-1))
    for y in range(len(S)-1):
        nums+=(sum(S[:len(S)-y]))*(10**y)*(2**(len(S)-2-y))
    print(nums)
if len(S)==2:
    print(11*S[0]+2*S[1])

if len(S)==1:
    print(S[0])

Solution (Python):
S = input()

ans = 0
for i in range(1, len(S) + 1):
    for j in range(len(S) + 1 - i):
        left = j - 1
        right = len(S) - j - i - 1
        edge = (2 ** max(0, left)) * (2 ** max(0, right))
        
        ans += int(S[j:j + i]) * edge
print(ans)

Solution (Python):
def resolve():
    s = input()
    ls = len(s)
    ans = 0
    for bit in range(1 << (ls - 1)):
        f = ""
        for j in range(ls - 1):
            f += s[j]
            if 1 << j & bit:
                f += "+"
        f += s[-1]
        ans += eval(f)
    print(ans)


if __name__ == "__main__":
    resolve()

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

def f(i, a):
    if i == N-1:
        return sum(list(map(int, a.split('+'))))
    
    return f(i+1, a + S[i+1]) + f(i+1, a + '+' + S[i+1])

print(f(0, S[0]))

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

plus_minus = [[]]
for i in range(len(s) - 1):
  new = []
  for element in plus_minus:
    new.append(element + [0]) 
    new.append(element + [1])
    plus_minus = new
    
for element in plus_minus:
  formula = s
  plus_num = 0
  for i in range(0, len(s) - 1):
    if element[i] == 1:
      formula = (formula[:i + 1 + plus_num] + "+" + formula[i + 1 + plus_num:])
      plus_num += 1
  ans += eval(formula)
print(ans)

Solution (Python):
s=input();l=len(s)-1;print(sum(eval(s[0]+"".join("+"*(i>>j&1)+s[j+1]for j in range(l)))for i in range(2**l)))

Solution (Python):
s=input();l=len(s)-1;a=0
for i in range(2**l):
	t=s[0]
	for j in range(l):
		t+="+"*(i>>j&1)+s[j+1]
	a+=eval(t)
print(a)

Solution (Python):
import itertools
import copy

S = list(input())

answer = 0
length = len(S)
for pattern in itertools.product((True, False), repeat=length-1):
    S2 = S[:]
    for i in range(length-1):
        if pattern[i]:
            S2.insert(length-i-1, '+')
    answer += eval(''.join(S2))

print(answer)

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

A = [""] * (n*2-1)
j = 0
for i in range(0, n*2-1, 2):
    A[i] = s[j]
    j += 1

ans = 0

for i in range(2**(n-1)):
    i_b = format(i, '0'+str(n-1)+'b')
    
    B = A[:]
    j = 1
    for i in range(n-1):
        if i_b[i] == "1":
            B[j] = "+"
        j += 2
    
    ans += eval("".join(B))

print(ans)

Solution (Python):
S = input()
t = [0] * (2 ** (len(S) - 1))
t[0] = int(S)
for i in range(2 ** (len(S) - 1)):
  r = 0
  s = ""
  l = list(bin(i)[2:])
  l = [0] * (len(S) - len(l) - 1) + l
  
  for j in range(len(S)):
    if j == len(S) - 1:
      s += S[j]
      break
    if l[j] == "1":
      r += int(s + S[j])
      s = ""
    else:
      s += S[j]
  if s != "": r += int(s)
  
  t[i] = r
print(sum(t))

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
def resolve():
    s=input()
    n=len(s)
    ans=0
    from itertools import product
    for A in product(range(2),repeat=n-1):
        k=s[0]
        for i in range(n-1):
            k+='+' if A[i] else ''
            k+=s[i+1]
        ans+=eval(k)
    print(ans)
resolve()

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

for i in range(2 ** (n-1)):
    d = [0, n]
    for j in range(n-1):
        if ((i >> j) & 1):
            d.append(j+1)
    d.sort()
    for i in range(len(d)-1):
        ans += int(s[d[i]:d[i+1]])

print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
def resolve():
    s=input()
    n=len(s)
    ans=0
    from itertools import product
    for A in product(range(2),repeat=n-1):
        k=s[0]
        for i in range(n-1):
            k+='+' if A[i] else ''
            k+=s[i+1]
        ans+=eval(k)
    print(ans)
resolve()

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7

def resolve():
    s=input()
    n=len(s)
    ans=0
    from itertools import product
    for A in product(range(2),repeat=n-1):
        k=s[0]
        for i in range(n-1):
            k+='+' if A[i] else ''
            k+=s[i+1]
        ans+=eval(k)
    print(ans)
resolve()

Solution (Python):


S=input()
N=len(S)

l=[]*9
count=0
for i in range(2**(N-1)):
    prev=0
    for j in range(N-1):
        if i>>j&1==1:
            count+=int(S[prev:j+1])
            prev=j+1
    count+=int(S[prev:N])
print(count)

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

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

Solution (Python):
def main():                                                                     
    s = raw_input()                                                             
    to_eval = [s[0]]                                                            
    buf = []                                                                    
                                                                                
    for elem in s[1:]:                                                          
        for x in to_eval:                                                       
            buf.append(x+elem)                                                  
            buf.append(x+'+'+elem)                                              
        to_eval = buf[:]                                                        
        buf = []                                                                
                                                                                
    _sum = 0                                                                    
    for x in to_eval:                                                           
        _sum += eval(x)                                                         
    print(_sum)                                                                 
                                                                                
main()

Solution (Python):
S=input()
N=len(S)-1
total=0
for i in range(2**N):
    list=['+']*N
    for j in range(N):
        if ((i>>j)&1):
            list[N-j-1]=''
    formula=''
    for num,operator in zip(S,list+['']):
        formula+=(num+operator)
    total+=eval(formula)
print(total)

Solution (Python):
S=input()
total=0
if len(S)==1:
    print(S)
    exit(0)
for i in range(2**(len(S)-1)):
    a = int(S[0])
    t=format(i,'b').zfill(len(S)-1)
    for j in range(len(t)):
        if t[j]=='0':
            a=a*10+int(S[j+1])
        else:
            total+=a
            a=int(S[j+1])
    total+=a

print(total)

Solution (Python):
S=input()
result = 0

for i in range(1 << len(S)-1):
    
    hoge=S[0]
    for j in range( len(S)-1 ):
        if i>>j&1 :
            hoge+="+"
        hoge+=S[j+1]
    result += eval(hoge)
print(result)

Solution (Python):
s = input()

def dfs(s):
    ans = int(s)
    for i in range(1, len(s)):
        ans += int(s[:i]) * (1 << (len(s[i:])-1)) + dfs(s[i:])
    return ans

ans = dfs(s)
print(ans)

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

n = str(I())
ans = 0
space_num = len(n) - 1
for i in range(2 ** space_num):
    ret = n[0]
    for j in range(space_num):
        if i & 1 << j:
            ret += '+'
        ret += n[j + 1]
    ans += eval(ret)


print(ans)

Solution (Python):
s = input()

ans = 0



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


if len(s) == 1:
    print(s[0])
    exit()
    
    
print(ans)

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

Solution (Python):
from itertools import product
s=list(input())
cnt=0
pl=list(product(['','+'],repeat=len(s)-1))
for j in pl:
	for _ in range(len(s)):
		l=[s[0]]
		for i in range(len(s)-1):
			l.append(j[i])
			l.append(s[i+1])
	a="".join(l)
	cnt+=eval(a)
print(cnt)

Solution (Python):
S = str(input())
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]))

Solution (Python):
import itertools
num = str(input())

olist = [int(i+1) for i in range(len(num)-1)]
comblist = []
for i, _ in enumerate(olist, 1):     
    for j in itertools.combinations(olist, r=i):
        comblist.append(j)

L = []
for i in range(len(comblist)):
  t = num
  for j in range(len(comblist[i])):
    t = t[0:comblist[i][j]+j] + "," + t[comblist[i][j]+j:]
  L.append(t)

out = 0
for i in range(len(L)):
  t = L[i].split(",")
  for j in range(len(t)):
    out += int(t[j])
print(out+int(num))

Solution (Python):
S = input()


def solve():
    ans = 0

    for i in range(2**(len(S)-1)):
        value = list(S)
        bit = list(str(bin(i))[2:].zfill(len(S)-1))
        for i, p in enumerate(bit):
            if int(p):
                value[i] = value[i] + '+'
        values = ''.join(value).split('+')
        values = list(map(int, values))
        ans += sum(values)
    print(ans)

if __name__ == "__main__":
    solve()

Solution (Python):
S = input()
dp = len(S)*[0]
dp[0] = int(S[0])

for i in range(1,len(S)):
    dp[i]=int(S[:i+1])+sum(dp[j-1]+int(S[j:i+1])*2**(j-1) for j in range(1,i+1))
    
print(dp[-1])

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

a=[None]*n
a[0]=int(s[0])


for i in range(n-1):
  a[i+1]=a[i]*10+sum(int(j) for j in s[:i+2])*(2**i)+int(s[i+1])*(2**i)

print(a[n-1])