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=list(input())
N=2**(len(S)-1)
ans=0
for i in range(N):
    A=S[0]
    I=i
    for j in range(len(S)-1):
        if I//(2**(len(S)-2-j))==1:
            A+="+"
        else:
            A+=""
        I%=(2**(len(S)-2-j))
        A+=S[j+1]
    ans+=eval(A)
print(ans)

Solution (Python):
S = input()
combination = 2 ** (len(S) - 1)

ans = 0
for i in range(combination):
    
    bin_str = bin(i)[2:]

    
    bin_str = '0' * (len(S) - len(bin_str) - 1) + bin_str

    formula = ''
    for i, s_char in enumerate(S):
        
        plus = ''
        if len(S) - 1 != i and bin_str[i] == '1':
            plus = '+'

        formula += s_char + plus

    
    ans += eval(formula)

print(ans)

Solution (Python):
from itertools import combinations
S = input().strip()
N = len(S)
answer = int(S)
for c in range(1,N):
    for t in combinations(range(1,N), c):
        i = 0
        for j in t:
            answer += int(S[i:j])
            i = j
        j = N
        answer += int(S[i:j])

print(answer)

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

ans = 0
for i in range(1<<l):
    s = a[0]
    for j in range(l):
        if (i>>j)&1: s += "+"
        s += a[j+1]
    ans += eval(s)
print(ans)

Solution (Python):
from collections import defaultdict

s = input()
memo = defaultdict(int)

def calc_sum(num, t):
  if len(t) == 1:
    return num + int(t)
  return num + int(t) + sum(calc_sum(num + int(t[:i]), t[i:]) for i in range(1, len(t)))

print(calc_sum(0, s))

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

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

print(answer)

Solution (Python):
def a(al, s1, s2):
	if len(s1)==0:
		st = s2+s1
		n_list = st.split("+")
		ans = 0
		for n in n_list:
			ans = ans + int(n)
		al.append(ans)
	elif len(s2)==0:
		a(al, s1[1:], s2+s1[0])
	else:
		a(al, s1[1:], s2+s1[0])
		a(al, s1[1:], s2+"+"+s1[0])

s = input()
a_list = []
a(a_list, s, "")

ans = 0
for a in a_list:
	ans += a

print(ans)

Solution (Python):
S=input()
ans=0
opsize=len(S)-1
for i in range(2**opsize):
    ins=[""]*opsize
    for j in range(opsize):
        if((i>>j)&1):
            ins[j]="+"
    tmp=""
    ins+=[""]
    for k,p in zip(S,ins):
        tmp+=(k+p)
    ans+=eval(tmp)
print(ans)

Solution (Python):
import itertools
s = list(input())
ans = 0
l = list(itertools.product(["","+"],repeat=len(s)-1))
for d in l:
  f = ""
  for s1,s2 in zip(s,list(d)+[""]):
    f += s1+s2
  ans += eval(f)
print(ans)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

s = list(input())

from itertools import product
num = len(s)-1
bits = product([0, 1], repeat=num)
L = []
for x in bits:
    l = []
    r = [s[0]]
    for i in range(len(x)):
        if x[i] == 0:
            r.append(s[i+1])
        if x[i] == 1:
            l.append(r)
            r = []
            r.append(s[i+1])
    l.append(r)
    L.append(l)

ans = 0
for equ in L:
    
    for y in equ:
        
        ans += int("".join(y))
print(ans)

Solution (Python):
S = list(input())
ls = len(S)
n = ls - 1
ans = 0
from copy import deepcopy
for i in range(2 ** n):
    siki = deepcopy(S)
    add = 1
    for j in range(n):
        if ((i >> j) & 1):
            siki.insert(j+add, "+")
            add += 1
    
    ans += eval("".join(siki))
print(ans)

Solution (Python):
s = str(input())
rs = s[::-1]

def str_to_num(pattern): 
  rp = pattern[::-1]
  r = []
  r.append(int(rs[0]))
  tmp = 0
  for i in range(0, len(rp)):
    if int(rp[i]):
      tmp += 1
    else:
      tmp = 0
    r.append(int(rs[i+1]) * 10**tmp)
  return r

def dfs45(i, p):
    if i == len(s) - 1:
        return str_to_num(p)
    else:        
        r_l =  dfs45(i + 1, p + "0")
        r_l += dfs45(i + 1, p + "1")
    return r_l
    
result = dfs45(0, "")
print(sum(result))

Solution (Python):
s=input()
L=len(s)
ans=0
import itertools as it
l=[ i for i in it.product(["", "+"], repeat=L-1)]
for ll in l:
    f=""
    for i,j in zip(s,list(ll)+[""]):
       f+=i+j
    ans+=eval(f)

print(ans)

Solution (Python):
s=input()
t=list(s)
l=len(s)

ans=0
for i in range(2**(l-1)):
    ans_sub=0
    subst=s[0]
    for j in range(l-1):
        if (i>>j)&1:
            ans_sub+=int(subst)
            subst=s[j+1]
        else:
            subst+=s[j+1]
        if j==l-2:
            ans_sub+=int(subst)
    ans+=ans_sub
if l==1:
    print(int(s))
else:
    print(ans)

Solution (Python):
from itertools import product
S = input()
L = len(S) - 1
join = lambda x: "".join(x)
print(sum(eval(join(map(join, zip(S, list(p)+[""])))) for p in product(("", "+"), repeat=L)))

Solution (Python):
def f(n,x):
    C = []
    y = x
    for i in range(n):
        C.append(y%2)
        y//=2
    return C
S = input()
N = len(S)-1
ans = 0
for i in range(2**N):
    C = f(N,i)
    s = S[0]
    for i in range(N):
        s+=("+" if C[i] else "")+S[i+1]
    ans+=eval(s)
print(ans)

Solution (Python):
import itertools
S = [i for i in input()]

U = itertools.product(sorted(range(2)), repeat=len(S)-1)
ans = 0

for i in U:
  
  
  
  

  n1 = S
  
  for j in range(len(i))[::-1]:
    
    
    
    if i[j] == 1:
      ans += int("".join(n1[j+1:]))
      
      n1 = n1[:j+1]
      
  
  ans += int("".join(n1))
  


print(ans)

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

n = len(s)
ans = 0

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

print(ans)

Solution (Python):
S = input()

l = len(S) - 1
ans = 0
for i in range(1<<l):
    s = S
    n = []
    k = 0
    for j in range(l):
        k += 1
        if i&(1<<j):
            n.append(int(s[:k]))
            s = s[k:]
            k = 0
    else:
        n.append(int(s))
    ans += sum(n)

print(ans)

Solution (Python):
s = input()
y = int(s)
for i in range(1, 2**(len(s)-1)):
    t = []
    for j in range(len(s)-1):
        if ((i >> j) & 1):
            t.append(j+1)
    y += int(s[:t[0]])
    y += int(s[t[-1]:])
    if len(t) >= 2:
        for j in range(len(t)-1):
            y += int(s[t[j]:t[j+1]])
print(y)

Solution (Python):
from copy import copy
S = list(input())
n = len(S)

total = int("".join(S))
siki = set()
for i in range(2 ** (n - 1)):
    S_ = copy(S)
    plus_count = 0
    for j in range(n - 1):  
        if ((i >> j) & 1):  
            S_.insert(plus_count + j + 1, "+")  
            plus_count += 1
            siki.add("".join(S_))  
for s in list(siki):
    total += eval(s)
print(total)

Solution (Python):

S = input()
N = len(S) - 1

ans = []

for i in range(2**N):
  tmp = ""
  for j in range(N):
    tmp += S[j]
    if (i >> j) & 1:
      tmp += "+"
  else:
    tmp += S[-1]

  ans.append(eval(tmp))

print(sum(ans))

Solution (Python):

s = input()
ans = 0
for i in range(2**(len(s)-1)):
	k = i
	current_index = 0
	cnt_div = 0 
	while True:
		cnt_div += 1
		if k % 2: 
			ans += int(s[current_index:current_index+cnt_div])
			current_index = current_index+cnt_div
			cnt_div = 0 
		k = k //2
		if k == 0:
			ans += int(s[current_index:]) 
			break
print(ans)

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

if n == 0:
    print(s)
else:
    ans = 0
    for i in range(2 ** n):
        tmp = ''
        for j in range(n):
            tmp += s[j]
            if i & 1 << j:
                tmp += '+'
        tmp += s[j+1]
        if '+' in tmp:
            ans += eval(tmp)
        else:
            ans += int(tmp)

    print(ans)

Solution (Python):
a=list(input())
x=len(a)
b=[""]*(x-1)

c=[]
for aa,bb in zip(a,b):
    c.append(aa)
    c.append(bb)
c.append(a[-1])

import copy
ans=0
for i in range(2**(x-1)):
    cc=copy.deepcopy(c)
    for j in range(x-1):
        if (i>>j&1):
            cc[(j+1)*2-1]="+"
    ccc="".join(cc)
    ans+=eval(ccc)
print(ans)

Solution (Python):
s=input()
n=len(s)-1
ans=0
for bit in range(1<<n):
    f=s[0]
    for i in range(n):
        if ((bit>>i)&1):
            f+="+"
        f+=s[i+1]
    for i in f.split("+"):
        ans+=int(i)
print(ans)

Solution (Python):
x=input()

n=len(x)-1
ans=0
for i in range(2**n):	
	cal=[]
	for j in range(n):
		cal.append(x[j])
		if (i >> j) & 1:
			cal.append('+')
	cal.append(x[n])
	y=''.join(cal)
	ans += eval(y)
print(ans)

Solution (Python):
import itertools
s=input()
t=len(s)
seq=[0,1]
l=itertools.product(seq,repeat=t-1)
m=[]
for i in l:
  tmp=""
  for j in range(t-1):
    tmp+=s[j]+"+"*i[j]
  tmp+=s[-1]
  m.append(tmp)

ans=0  
for j in m:
  ans+=eval(j)
  
print(ans)

Solution (Python):
import itertools
s=input()
t=len(s)
seq=[0,1]
l=itertools.product(seq,repeat=t-1)
m=[]
for i in l:
  tmp=""
  for j in range(t-1):
    tmp+=s[j]+"+"*i[j]
  tmp+=s[-1]
  m.append(tmp)

ans=0  
for j in m:
  ans+=eval(j)
  
print(ans)

Solution (Python):
s=input()

def dfs(i,f):
    global ans
    if i==len(s)-1:
        ans+=eval(f)
    else:
        
        dfs(i+1,f+'+'+s[i+1])
        dfs(i+1,f+s[i+1])

    return ans

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

Solution (Python):
*s, = map(str, input())

a = [""]*(len(s))
ans = 0

def rec(i:int, a:list) -> None:
    if i == len(s)-1:
        global ans
        ans += eval("".join(_s+_a for _s, _a in zip(s, a)))
        return

    a[i] = ""
    rec(i+1, a)
    a[i] = "+"
    rec(i+1, a)

rec(0, a)
print(ans)

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

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

def main():
    S = input().strip()

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

        ans += tmp

    print(ans)

    
    

if __name__ == '__main__':
    main()

Solution (Python):
def insert(pos, s, x):
    return x.join([s[:pos], s[pos:]])


s = input()
length = len(s)
ret = 0

for i in range(2 ** (length-1)):
    my_str = s
    cnt = 0
    for j in range(length):
        if ((i >> j) & 1):
            my_str = insert(j+cnt+1, my_str, "+")
            cnt = cnt + 1
    ret = ret + eval(my_str)

print(ret)

Solution (Python):

S=input()
n=len(S)

ans=0
for i in range(2**(n-1)):
    a = [1&(i>>j) for j in range(n)]
    ind = set([i for i, x in enumerate(a) if x==1])
    nums=[]
    tmp=0
    for j in range(n):
        tmp = tmp*10 + int(S[j])
        if j in ind:
            nums += [tmp]
            tmp=0
    nums += [tmp]
    
    ans += sum(nums)

print(ans)

Solution (Python):
import sys


def main():
    N = str(input())
    M = len(N)-1
    ans = 0
    for i in range(2**M):
        u = [0]
        for j in range(M):
            if (i>>j)&1:
                u.append(j+1)
        u.append(M+1)
        l = len(u)
        for k in range(l-1):
            num = int(N[u[k]:u[k+1]])
            ans += num
            
    print(ans)

if __name__ == "__main__":
    main()

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

Solution (Python):
S = input()

beautify = lambda s: s.rstrip('+').lstrip('+').replace('++', '+')

def dfs(depth, formula):
    if depth+1 >= len(formula):
        return eval(beautify(formula))

    res = 0
    res += dfs(depth+2, "{}{}{}".format(
        formula[:depth+1],
        '+',
        formula[depth+1:],
    ))
    res += dfs(depth+1, formula)

    return res

ans = dfs(0, S)
print(ans)

Solution (Python):
s = input()
 
def dfs( i,  f ):
    if i == len( s ) - 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):
s = str(input())
n = len(s)-1
t = 2**n

result = 0
for i in range(t):
  p = str(bin(i))[2:]
  p = '0'*(n-len(p))+p
  exList = []
  for j,k in enumerate(s):
    exList.append(k)
    if j != n and  p[j] == '1':
      exList.append('+')
  result += eval(''.join(exList))

print(result)

Solution (Python):
s = 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 sys
input = sys.stdin.readline
s=list(input().strip())
n=len(s)
ans=0
for i in range(1<<(n-1)):
    sum=0
    for j in range(n):
        sum*=10
        sum+=int(s[j])
        if 1&i>>j:
            ans+=sum
            sum=0
    ans+=sum
print(ans)

Solution (Python):
s = input()

ans = 0
n = len(s) - 1
for bit in range(1 << n):
    siki = s[0]

    for i in range(n):
        if bit & (1 << i):
            siki += "+"
        siki += s[i + 1]

    for i in siki.split("+"):
        ans += int(i)

print(ans)

Solution (Python):

S = list(input())


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

  for i in range(0,2**(len(S)-1)):
      bit = str(bin(i))[2:].zfill(len(S)-1)
      
      number = int(S[0])

      for j in range(len(bit)):

          if bit[j] == "0":
              number = number*10 + int(S[j+1])
          else:
              
              ans += number
              number = int(S[j+1])

      
      ans += number

  print(ans)

Solution (Python):
s=input()

def dfs(i,f):
    global s_sum
    if i==len(s)-1:
        s_sum+=sum(map(int,f.split('+')))

    else:
        dfs(i+1,f+'+'+s[i+1])
        dfs(i+1,f+s[i+1])

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

Solution (Python):
s=input()
from collections import deque
ans=0
d=deque()
d.append(s[0])
for i in range(len(s)-1): 
    for j in range(len(d)):
        tmp=d.popleft()
        d.append(tmp+"+"+s[i+1])
        d.append(tmp+s[i+1])
for i in range(len(d)):
    tmp=d.popleft()
    ans+=sum(list(map(int, tmp.split("+"))))
    
print(ans)

Solution (Python):



S=list(map(int,input()))
ans=0
for i in range(2**(len(S)-1)):
    bin_str=format(i,"0{}b".format(len(S)-1))
    ans+=S[-1]
    k=1
    for j in range(len(S)-1):
        if bin_str[-j]=="1":
            k=0
        ans+=S[-(2+j)]*(10**k)
        k+=1

print(ans)

Solution (Python):

s = input()
ans = 0
for bit in range(2**(len(s)-1)):
    tmp = ""
    for j in range(len(s)):
        if (bit >> j) & 1 == 1:
            tmp += s[j]
            tmp += "+"
        else:
            tmp += s[j]
    ans += eval(tmp)
print(ans)

Solution (Python):
s=input()


n=len(s)-1
ans=0
for i in range(2**n):
    f=s[0]
    for j in range(n):

        if (i>>j)&1:
            f+='+'
        f+=s[j+1]

    ans+=sum(map(int,f.split('+')))
print(ans)

Solution (Python):
def dfs(i, f, s, l):
    if i == l-1:
        return sum(list(map(int, f.split("+"))))
    
    return dfs(i+1, f+s[i+1], s, l) + dfs(i+1, f+"+"+s[i+1], s, l)

def main():
    s = input()
    l = len(s)

    print(dfs(0, s[0], s, l))
    
if __name__ == '__main__':
    main()

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

Solution (Python):
s = input()

n = len(s) - 1
ans = 0

for i in range(2 ** n):
    k = 0
    nm = []
    for j in range(n):
        if ((i >> j) & 1):
            nm.append(int(s[k:j + 1]))
            k = j + 1
        
        if j == n - 1:
            nm.append(int(s[k:n + 1]))
    
    ans += sum(nm)

if n == 0:
    print(int(s))
else:
    print(ans)

Solution (Python):
S = input()
Sum = 0
N = 2 ** (len(S) - 1)
for i in range(N):
  A = []
  for j in range(len(S) - 1):
    A.append(i % 2)
    i //= 2
  T = S[0]
  T2 = 0
  for j in range(len(S) - 1):
    if A[j] == 0:
      T = T[:] + S[j+1]
    else:
      T2 += int(T)
      T = S[j+1]
  T2 += int(T)
  Sum += T2
print(Sum)

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

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-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())

ans = 0
S = 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):
S = list(input())
form = "0"+str(len(S)-1)+"b"
ans = 0
if len(S)==1:
    print(int(S[0]))
else:
    for i in range(2**(len(S)-1)):
        b = format(i, form)
        eq = [S[0]]
        for j in range(len(b)):
            if b[j] == "1":
                sign = "+"
            else: sign = ""
            eq.append(sign)
            eq.append(S[j+1])
        eqstr = str("".join(eq))
        ans += eval(eqstr)
    print(ans)

Solution (Python):
s = input()
n = len(s)
ans = 0
for bit in range(1 << (n - 1)):
    f = s[0]
    for i in range(n - 1):
        if bit & (1 << i):
            f += "+"
        f += s[i + 1]
    ans += sum(map(int, f.split("+")))
print(ans)

Solution (Python):
import itertools

S = input()
N = len(S)


ans = 0
for v in itertools.product([1,0],repeat=N-1):
    start = 0
    for i in range(N-1):
        if v[i] == 1:
            stop = i+1
            ans += int(S[start:stop])
            start = stop
    ans += int(S[start:N])

print(ans)

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

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


ans = 0
for bit in range(1<<N):
    s = ''
    for i, num in enumerate(S):
        if bit & 1<<i:
            s += num + '+'
        else:
            s += num
    ans += eval(s)
print(ans)

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

Solution (Python):


a=input()
s=list(a)
a=s
cnt=[]

aa=0
for i in range(2**(len(s)-1)):
    su=a[0]
    cnt=[]
    for j in range(len(s)-1):
        if (i>>j)&1==1:
            aa+=int(su)
            su=a[j+1]
            
        elif (i>>j)&1==0:
            su+=a[j+1]
    aa+=int(su)
    
            
        
    
     
      
print(aa)

Solution (Python):
n=input()
res=0
for i in range(2**len(n)):
    f=[0]
    for j in range(1,len(n)):
        if (i>>j)&1:
            f.append(j)
    f.append(len(n))
    
    pre=0
    for j in range(len(f)-1):
        
        pre+=int(n[f[j]:f[j+1]])
    
    res+=pre
print(res//2)

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

Solution (Python):
s = input()

CNT_MAX = 1 << (len(s) - 1)

def get_sum(s, sp):
    ret = 0
    start = end = len(s)
    for i in range(len(bin(sp))-2):
        if bool((sp >> i) & 1):
            start = len(s) - i - 1
            ret += int(s[start:end])
            end = start
    ret += int(s[0:end])
    return ret
    
ans = 0
for i in range(CNT_MAX):
    ans += get_sum(s, i)
    
print(ans)

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

ans = 0
for i in range(1<<(n-1)):
	b = 1
	
	for j in range(n):
		
		ans += int(s[-1-j])*b
		
		if i&(1<<j):
			b *= 10
		else:
			b = 1

print(ans)

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

Solution (Python):
S = input()
N = len(S)
ans = 0
for sep in range(2**(N-1)):
    p = 0
    for i in range(N):
        if (sep>>i)&1 or i==N-1:
            ans += int(S[p:i+1])
            p = i+1

print(ans)

Solution (Python):
S=input()

N=len(S)
if N==1:
    print(eval(S))
    exit()
t=[S[0]]*(2*N-1)
for i in range(1,N):
    t[2*i-1]=''
    t[2*i]=S[i]
ans=0
for i in range(1<<(N-1)):
    p=t[:]
    j=1
    while i:
        if i&1:
            p[2*j-1]='+'
        i>>=1
        j+=1
    ans+=eval(''.join(p))
print(ans)

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

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

print(ans)

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

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

print(ans)

Solution (Python):
S = input()
Ans = 0
box = []

for i in range(2 ** (len(S)-1)):  
    for j in range((len(S)-1)):
        box.append(S[j])
        
        if (i >> j) & 1:
            Ans += int("".join(box))
            box.clear()
            
    box.append(S[-1])
    Ans += int("".join(box))
    box.clear()

print(Ans)

Solution (Python):
*s, = map(int, list(input()))
gap = len(s)
ans = 0
for i in range(2 ** (gap - 1)): 
    fmr = ""
    for j in range(gap):
        fmr += str(s[j])
        if (i >> j) & 1:
            fmr += "+"
    ans += eval(fmr)
print(ans)

Solution (Python):


import sys
input = sys.stdin.readline

S = input()

M = len(S)
N = 2 ** (M-1)

res = 0

for i in range(N):
    T = S[:]
    for j in range(M-1,-1,-1):
        if ((i >> j) & 1):
            temp = T[j:]
            T = T[:j]
            
            if temp != '':
                res += int(temp)
    if T != '':
        
        res += int(T)

print(res//2)

Solution (Python):
N_0 = input()
N = list(N_0)
m = len(N)
ans = 0


numbers = list(range(1,m))

n = len(numbers)
box = []

for i  in range(2 ** n):
    box_0 = []
    for j in range(n):
        if ((i >> j)&1):
            box_0.append(numbers[j])
            

    box.append(box_0)

box[0]=0

for j in range(len(box)):
    M = list(N_0)
    if j == 0:
        ans+=int(N_0)
    else:
        for k in range(len(box[j])):
            if k ==0:
                M.insert(box[j][k],"+")
            else:
                M.insert(box[j][k]+k,"+")
                
            
                
        ans += eval("".join(M))
            
print("{}".format(ans))

Solution (Python):
n = str(input())
N = n
ans = 0
for i in range(2 ** int(len(n)-1)):
    n = N
    tmplist = []
    for j in range(1,len(n)):
        if (i >> j-1) & 1:
            
            tmplist.append(int(n[:j]))
            n = n[j:].zfill(len(n))
    if not n == "":
        tmplist.append(int(n))

    ans += sum(tmplist)
    
    
print(ans)

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

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):
n = input()
op_cnt = len(n) - 1  
ans = 0
for i in range(2 ** op_cnt):
    op = [""] * op_cnt  
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"  

    formula = ""
    for p_n, p_o in zip(n, op + [""]):
        formula += (p_n + p_o)
    ans += eval(formula)
print(ans)

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

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

Solution (Python):
s = input()


def dfs(i,f):
  if i == len(s)-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):
a = input()
if len(a) == 1:
    print(int(a))
    exit()
ans = 0
for i in range(2**(len(a)-1)):
    b = format(i, 'b').zfill((len(a)-1))
    li = []
    num = [a[0]]
    for i in range(len(b)):
        if b[i] == '1':
            ans += int(''.join(num))
            num = [a[i+1]]
        else:
            num.append(a[i+1])
    ans += int(''.join(num))

print(ans)

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

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

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

d = len(s)-1
ans = 0

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

    formula = ''
    for a, b in zip(s, op):
        formula += a + b

    ans += eval(formula)

print(ans)

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

Solution (Python):
import sys
import copy



S = input()
op_list = ["+"]*(len(S)-1)

sum = 0
for i in range(2**len(op_list)):
    op_list = ["+"]*(len(S)-1)
    for j in range(len(op_list)):

        if (i >> j) & 1:
            op_list[j] = ""
    s = ""
    for k in range(len(op_list)):
        s = s + S[k] + op_list[k]
    s = s + S[len(S)-1]
    sum = sum + eval(s)


print(sum)

Solution (Python):
from collections import deque

S = input().rstrip("\n")

max_plus = len(S) -1

answer = 0
for i in range(2 ** max_plus):
    state = i
    index = deque()
    for j in range(max_plus):
        
        if (state >> j) & 1:
            index.append(j+1)
    start = 0
    while index:
        idx = index.popleft()
        answer += int(S[start:idx])
        start = idx
    answer += int(S[start:])

print(answer)

Solution (Python):
S = input()
N = len(S)
ans = 0
pl = ["", "+"]

for n in range(2**(N-1)):
  b = "{:012b}".format(n)
  b = b[12-N+1:]
  eval_str=""
  for i in range(N-1):
    eval_str = eval_str + S[i] + pl[int(b[i])]
  eval_str = eval_str + S[N-1]
  ans = ans + eval(eval_str)
print(ans)

Solution (Python):
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

S = one_str()

num_list = list(S)

start_bit=2**(len(S)-1)
end_bit = 2**(len(S))

def get_sums(array, bit):
    sums = 0
    start = 0
    end = 0
    for i,s in enumerate(bit):
        if s=="1":
            end = i+1
            sums+=int("".join(array[start:end]))
            start=i+1
    if end==start==0:
        return int("".join(array))
    else:
        sums+=int("".join(array[start:]))
    return sums

sums = 0
for i in range(start_bit, end_bit):
    bits = str(bin(i))[3:]
    sums += get_sums(num_list, bits)

print(sums)

Solution (Python):
s = input()



n = len(s)
ans = 0

for m_i in range(2**(n-1)):
  temp = ''
  for n_i in range(n):
    temp += s[n_i]
    if m_i & (1 << n_i):
      temp += '+'
  
  ans += eval(temp)
  
print(ans)

Solution (Python):
import itertools as it

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

Solution (Python):
s = input()
N = 2**(len(s) - 1)
ans = 0
for n in range(N):
    li, ci = 0, 0
    while n > 0:
        if n & 1 == 1:
            ans += int(s[li:ci + 1])
            li = ci + 1
        n = n >> 1
        ci += 1
    ans += int(s[ci:])

print(ans)

Solution (Python):
s = input()

ans = 0
for i in range(2 ** (len(s) - 1)):
    js = []
    for j in range(len(s) - 1):
        if (i >> j) & 1:
            js.append(j)

    if js == []:
        ans += int(s)
    else:
        prev = 0
        for j in range(len(js)):
            ans += int(s[prev:js[j] + 1])
            prev = js[j] + 1
        ans += int(s[prev:])
print(ans)

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