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

lis = []

keta = len(S)-1

if keta == 0:
    print (S)
    
else:
    
    for i in range(2 ** keta):
        
        lis.append(format(i,"b").zfill(keta))
        
    
    
    ans = 0
    
    for i in lis:
        
        Q = S[0]
        
        for j in range(len(S)-1):
            
            if i[j] == "1":
                ans += int(Q)
                Q = ""
            
            Q += S[j + 1]
            
        ans += int(Q)
        
        Q = ""
        
    print (ans)

Solution (Python):
s = input()
rs = 0
sz = len(s) - 1
for mask in range(2 ** sz):
    curr, total = 0, 0
    for i in range(sz):
      curr *= 10
      curr += int(s[i])
      if mask & (1 << i):
        total += curr
        curr = 0
    curr *= 10
    curr += int(s[-1])
    rs += total + curr
print(rs)

Solution (Python):


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

ans = 0
S = []
for i in range(2*n-1):
    if i % 2 == 0:
        S.append(s[i//2])
    else:
        S.append('')

for i in range(2**(n-1)):
    b = [0]*(n-1)
    for j in range(n-1):
        if (i>>j) & 1:
            b[j] = 1
    x = S.copy()
    k = 0
    for j in range(n-1):
        if b[j] == 1:
            x[k+1] = '+'
        k += 2
    preans = ''
    for j in range(2*n-1):
        if x[j] != '+':
            preans += x[j]
        if x[j] == '+' or j == 2*n-2:
            ans += int(preans)
            preans = ''
print(ans)

Solution (Python):
from itertools import combinations

S = input()

ret = 0
for i in range(len(S)) :
    for comb in combinations(range(1, len(S)), i) :
        comb = [0] + list(comb) + [len(S)]
        for i in range(1, len(comb)) :
            ret += int(S[comb[i-1]:comb[i]])
         
print(ret)

Solution (Python):
def resolve():

    s = input()
    n = len(s)

    ans = 0

    for i in range(2 ** (n - 1)):

        cnt = 0
        for j in range(n - 1):

            if (i >> j) & 1:
                ans += int(s[j-cnt:j+1])
                cnt = 0

            else:
                cnt += 1

        ans += int(s[n-cnt-1:n])

    print(ans)
    
resolve()

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

Solution (Python):
s=input()
ans=chk=0
for i in range(2**(len(s)-1)):
    d=bin(i)[2:]
    d=("0"*(9-len(d))+d)[::-1]
    t=int(s[0])
    for i in range(len(s)-1):
        if d[i]=="0":
            t*=10
            t+=int(s[i+1])
        else:
            ans+=t
            t=int(s[i+1])
    ans+=t

print(ans)

Solution (Python):
S = input()

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

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

for i in range(2**(len(s)-1)):
        b = bin(i)[2:].zfill(len(s)-1)
        tmp = s.copy()
        cc = 1
        for j in range(len(s)-1):
                if b[j]=="1":
                        tmp.insert(int(j)+cc, "+");
                        cc += 1
        ans += eval("".join(tmp))
print(ans)

Solution (Python):
S=input()
ans=0
for i in range(1<<(len(S)-1)):
    j=format(i,"b").zfill(len(S)-1)
    s,memo=S,0
    for n in range(len(S)-1):
        if j[n]=="0":memo+=1
        else:
            ans+=int(s[:memo+1])
            s=s[memo+1:]
            memo=0
    ans+=int(s)
print(ans)

Solution (Python):
def main():
    s = list(map(int,input()))
    n = len(s)
    sq = [2**i for i in range(10)]
    ans = 0
    for i in range(n):
        ans += s[i]*2**i*10**(n-1-i)
    for i in range(n-1):
        for j in range(n-1-i):
            ans += s[i]*2**(n-2-j)*10**j

    print(ans)

if __name__ == '__main__':
    main()

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

Solution (Python):
import itertools
n = str(input())
a = ["","+"]
l = list(itertools.product(a,repeat=len(n)-1))
l_n = list(n)
ans=0
for i in l:
    l_a = [None]*(len(n)*2-1)
    l_a[::2] = l_n
    l_a[1::2] = i
    ans+=eval("".join(l_a))
print(ans)

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

ans=0
for pat in range(2**(s_len-1)):
    evalstr=str(s[0])
    pat=format(pat,'0'+str(s_len-1)+'b')
    for i in range(1,s_len):
        if pat[i-1]=="1":
            evalstr+="+"
        evalstr+=str(s[i])
    ans+=eval(evalstr)
print(ans)

Solution (Python):
S=list(input())
N=len(S)
ans = 0
for b in range(2**(N-1)):
  bit = list(str(bin(b))[2:].zfill(N-1).replace('0','_').replace('1','+'))
  f = S[0]
  for bi, si in zip(bit, S[1:]):
    f += str(bi) + str(si)
  ans += eval(f.replace('_', ''))
print(ans)

Solution (Python):

from itertools import product


def main():
    s = input()
    ans = 0
    ops = tuple(product(("", "+"), repeat=len(s) - 1))
    for op in ops:
        e = ""
        for i in range(len(s) - 1):
            e += s[i] + op[i]
        e += s[-1]
        ans += eval(e)
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
S = input()
ls = len(S)
if ls == 1:
    print(S)
else:
    g = 0
    for i in range(2**(ls-1)):
        w = ''
        for u,v in zip(format(i,'
            if u=='1':w=w+v+'+'
            else:w=w+v
        else:w=w+S[-1]
        g += eval(w)
    print(g)

Solution (Python):
S = input()
ans = 0
for i in range(2 ** (len(S) - 1)):
	bit = bin(i)[2:].rjust(len(S) - 1, "0")
	start = 0
	tmp = 0
	for j in range(len(bit)):
		if bit[j] == "1":
			tmp += int(S[start: j + 1])
			start = j + 1
		if j == len(bit) - 1:
			tmp += int(S[start:])
	ans += tmp
print(ans)

Solution (Python):
S = input()
ans = 0
for i in range(2 ** (len(S) - 1)):
	bit = bin(i)[2:].rjust(len(S) - 1, "0")
	start = 0
	tmp = 0
	for j in range(len(bit)):
		if bit[j] == "1":
			tmp += int(S[start: j + 1])
			start = j + 1
		if j == len(bit) - 1:
			tmp += int(S[start:])
	ans += tmp
print(ans)

Solution (Python):
S = input()
ans = 0
for i in range(2 ** (len(S) - 1)):
	bit = bin(i)[2:].rjust(len(S) - 1, "0")
	
	start = 0
	tmp = 0
	for j in range(len(bit)):
		if bit[j] == "1":
			tmp += int(S[start: j + 1])
			start = j + 1
			
		if j == len(bit) - 1:
			tmp += int(S[start:])
	
	ans += tmp
print(ans)

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

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

Solution (Python):
s = input()
a = []
for i in range(2**(len(s)-1)):
    p = format(i, "0"+str(len(s)-1)+"b")
    num = ""
    for j in range(len(p)):
        if p[j] == "1":
            num += s[j]
            a.append(int(num))
            num = ""
        else:
            num += s[j]
    num += s[-1]
    a.append(int(num))
if len(s) != 1:
    print(sum(a))
else:
    print(s)

Solution (Python):
S = input()

def F(L,R):
  
  if R < L:
    return 1,0
  if L == R:
    return 1, int(S[L])
  c,s = 0,0
  for r in range(L,R+1):
    x = int(S[L:r+1])
    c1,s1 = F(r+1,R)
    c += c1
    s += x * c1 + s1
  return c,s

answer = F(0,len(S)-1)[1]
print(answer)

Solution (Python):
import sys
import itertools

S = input()

num_list = []
list_S =list(S)

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

for i in range(len(S)):
    if i == 0:
        num_list.append(int(S))
        continue
    combi_list = list(itertools.combinations(kugiri, i))
    for j in range(len(combi_list)):
        temp_num_list = []
        for k in range(len(combi_list[j])):
            if k == 0:
                temp_num_list.append(int(S[:combi_list[j][k]]))
            if k == len(combi_list[j]) - 1:
                temp_num_list.append(int(S[combi_list[j][k]:]))
            else:
                temp_num_list.append(int(S[combi_list[j][k]:combi_list[j][k+1]]))
        num_list.append(sum(temp_num_list))

print(sum(num_list))

Solution (Python):
s=input()
n=len(s)
def dfs(l, r):
	if r==n:
		return int(s[l:r])
	return int(s[l:r])*pow(2,n-r-1)+dfs(r,r+1)+dfs(l,r+1)
print(dfs(0,1))

Solution (Python):
s = input()
a = len(s)
ans = 0
for i in range(1 << (a-1)):
    su = []
    st = -1
    for j in range(a-1):
        if (i>>j)&1 == 1:
            if st == -1:
                b = int(s[:j+1])
            else:
                b = int(s[st+1:j+1])
            su.append(b)
            st = j
    else:
        if st == -1:
            su.append(int(s))
        else:
            su.append(int(s[st+1:]))
    
    ans += sum(su)
print(ans)

Solution (Python):

import copy
import random
import bisect 
import fractions 
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) 

S = str(input())

ans = 0
N = len(S)
for i in range(1,N+1): 
    for j in range(N-i+1):
        left = max(len(S[:j])-1,0)
        right = max(len(S[j+i:])-1,0)

        ans += int(S[j:j+i]) * (2**(left+right))

print(ans)

Solution (Python):
s = list(map(str, input()))
n = len(s)
sum = 0
for i in range(2 ** (n-1)):
  bag = []
  t = s[:]
  for j in range(n):
    if (i >> j) & 1:
      bag.append(j)   
  bag = sorted(bag, reverse=True)
  for k in range(len(bag)):
    t.insert(bag[k]+1, '+')
  
  sum += eval(''.join(t))

print(sum)

Solution (Python):
s=input()
s2="".join([c+" " for c in s])
res=0
for i in range(2**(len(s)-1)):
    t=list(s2)
    for j in range(len(s)-1):
        if (i>>j)&1:
            t[2*j+1]="+"
    res+=eval("".join([c for c in t if c!=" "]))
print(res)

Solution (Python):

s = input()
len_s = len(s)

ret = 0
def calc_cumsum(idx,right_str):
    if idx == len(right_str):
        return int(right_str)
    _ifplus = int(right_str[0:idx])* (2**(len(right_str[idx:len_s]) -1 )) + calc_cumsum(1,right_str[idx:len_s])
    _ifnotplus = calc_cumsum(idx+1,right_str)
    return (_ifplus+_ifnotplus)
print(calc_cumsum(1,s))

Solution (Python):

S = input()


def f(i, c):
    
    if i == len(S):
        if c[-1] == "+":
            return int(eval(c[:-1]))
        else:
            return int(eval(c))
    
    if i == 0 or c[-1] == "+":
        return f(i + 1, c + S[i])
    else:
        return f(i, c + "+") + f(i + 1, c + S[i])


print(f(0, ""))

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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()


def ten2n(a,n):
  x=a//n
  y=a%n
  if x:
    return ten2n(x,n)+str(y)
  return str(y)

def main():
  n=S()

  l=list(n)

  l2=[]
  for i in range(pow(2,len(n)-1)):
    l2.append(list(ten2n(i,2).zfill(len(n)-1)))

  sm=0
  for x in l2:
    s=''
    for i in range(len(x)):
      if x[i]=='0':
        s+=l[i]
      else:
        s+=l[i]+'+'
    if len(l)>1:
      s+=l[-1]
    sm+=eval(s)

  return sm


print(main())

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):
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()
def dfs(s, d=0, plus=[]):
    if len(s) -1 == d:
        equation = []
        for i in range(len(s)-1):
            equation.append(s[i])
            equation.append(plus[i])
        equation.append(s[-1])
        
        return eval(''.join(equation))
    
    total = 0
    total += dfs(s, d+1, plus+[''])
    total += dfs(s, d+1, plus+['+'])    
    
    return total

print(dfs(s))

Solution (Python):
if __name__ == '__main__':
    S = list(input())
    N = len(S) - 1
    
    total = 0
    for i in range(1 << N):
        p = []
        for j in range(N):
            if ((i >> j) & 1) == 1:
                p.append(j+1)
        p.append(10)
        
        b = 0
        a = 0
        for x in p:
            
            a += int(''.join(S[b:x])) 
            b = x
        total += a
    print(total)

Solution (Python):
S = input()
ans = 0
digit  = len(S)-1
for i in range(2**digit):
    bit = format(i,"0"+str(digit)+"b")
    temp = []
    num = S[0]
    for j in range(digit):
        if j == digit - 1:
            if bit[j] == "1":
                temp.append(int(num))
                temp.append(int(S[j+1]))
            else:
                temp.append(int(num+S[j+1:]))
        else:
            if bit[j] == "1":
                temp.append(int(num))
                num = S[j+1]     
            else:
                num += S[j+1]
    ans += sum(temp)
print(int(S) if digit == 0 else ans)

Solution (Python):
def pow2(n):
	v = 1
	for i in range(0, n):
		v *= 2
	return v

S = input()
opspattern = pow2(len(S)-1)
sum = 0
for i in range(0, opspattern):
	m = i
	psum = 0
	number = S[0]
	for j in range(0, len(S)-1):
		if m%2 == 1:
			psum += int(number)
			number = ''
		number = number + S[j+1]
		m = m // 2
	psum += int(number)
	sum += psum
print(sum)

Solution (Python):
n = list(input())
d = len(n)-1
anslist = [ None for i in range(2**d)]
for i in range(2**d):
	x = bin(i)[2:].zfill(d)
	
	s = n[0]
	for j in range(d):
		if x[j] == "1":
			s += "+" 
		s += n[j+1]
	anslist[i] = s


anslist = list(map(eval, anslist))
print(sum(anslist))

Solution (Python):

s = input()
d = []
ans = 0
for i in range(2 ** (len(s) - 1)):
    tmp = s[0]
    for j in range(len(s) - 1):
        
        
        
        if i & (1 << j):
            tmp += "+"
        tmp += s[j+1]
        
        d.append(tmp)
    ans += eval(tmp)


print(ans)

Solution (Python):
S = input()

N = len(S)
ans = 0
for i in range(2 ** (N - 1)):
    bit = '{:010b}'.format(i)[11 - N:]
    formula = S[0]
    for j in range(len(bit)):
        if bit[j] == '1':
            formula += '+'
        formula += S[j + 1]
    ans += eval(formula)
print(ans)

Solution (Python):
s = input()
ans = 0
for i in range(2 ** (len(s) - 1)):
    q = '{:0>10b}'.format(i)[::-1]
    formula = s[0]
    for j in range(1, len(s)):
        if q[j - 1] == '1':
            formula += '+'
        formula += s[j]
    ans += eval(formula)
    
print(ans)

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

for i in range(2**n):
    num = []
    bi = format(i, '0'+str(n)+'b')
    for j in range(n):
        num.append(s[j])
        if bi[j] == '1':
            num.append('+')
    num.append(s[-1])
    calc = ''.join(num)
    ans += eval(calc)

print(ans)

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

ans = 0
for b in range(0, pow(2, len(a) - 1)):
    subans = 0
    for i in range(0, len(a)):
        subans += a[i]
        if b >> i & 1 == 1:
            ans += subans
            subans = 0
        elif i < len(a) - 1:
            subans *= 10
    ans += subans
print(ans)

Solution (Python):
s=input()
ans=0
for i in range(2**(len(s)-1)):
    bit="{:010b}".format(i)[11-len(s):]
    formula = s[0]
    for j in range(len(bit)):
        if bit[j] =="1":
            formula+="+"
        formula+=s[j+1]
    ans+=eval(formula)
print(ans)

Solution (Python):
s = input()
ans = 0
for i in range(2**(len(s)-1)):
    bit = "{:010b}".format(i)[11-len(s):]
    formula = s[0]
    for j in range(len(bit)):
        if bit[j] == "1":
            formula += "+"
        formula += s[j+1]
    ans += eval(formula)
print(ans)

Solution (Python):
s = list(map(int,list(input())))
n = len(s)
m = 0
for i in range(n):
  for j in range(n-i):
    m += s[i]*2**i*10**j*2**(max(n-i-j-2,0))
print(m)

Solution (Python):
def main():
    s_input = input()

    n_s = len(s_input) - 1

    result_sum = 0
    for i in range(2 ** n_s):
        add_op = [''] * n_s
        for j in range(n_s):
            if ((i >> j) & 1):
                add_op[(n_s - 1) - j] = '+'

        formula = '0+'
        for k_ in range(len(s_input)):
            if k_ == 0:
                formula += s_input[0]
            else:
                formula += (add_op[k_ -1] + s_input[k_])

        result_sum += eval(formula)

    print(result_sum)

if __name__ == "__main__":
    main()

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

dp = [[0]*10 for i in range(10)]
s = ''
slen = 0

def get_dp(i, j):

    if i>j:
        return 0
    if dp[i][j]!=0:
        return dp[i][j]


    ans = 0
    for k in range(i, j+1):
        ans += int(s[i:k+1]) *  (1 <<max(0,(j-k-1))) + get_dp(k+1,j)

    
    dp[i][j] = ans
    return ans



def solve():
    global s, slen
    s = input()

    slen = len(s)

    print(get_dp(0, slen-1))

solve()

Solution (Python):
import math
import fractions
import copy

def j(q):
    if q==1: print("YES")
    elif q == 0:print("NO")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in a:
        print(i)
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)





a = input()                                  








s = 0
n = len(a)
bit = [0 for i in range(n-1)]
while sum(bit)<len(bit):
    r = 0
    bit[0]+=1
    if bit[0]==2:
        p = 0
        while bit[p] == 2:
            bit[p]=0
            p+=1
            bit[p]+=1
    str = []
    for i in range(n-1):
        str.append(a[i])
        if bit[i]:str.append(',')
    str.append(a[n-1])
    pa  = ''.join(str)
    ans = pa.split(',')
    for i in range(len(ans)):
        ans[i] = int(ans[i])
    s+=sum(ans)
print(s+int(a))

Solution (Python):

import sys
import itertools

def solve(S: int):
    se = ('+', '_')
    S = list(str(S))

    ans = 0
    for i in itertools.product(se,repeat=(len(S)-1)):
        t =[]
        t.append(S[0])
        for j,x in enumerate(i):
            t.append(x) 
            t.append(S[j+1])

        t = [x for x in t if(x != '_')]
        ts = ''.join(t)
        
        ans += sum(list(map(int,ts.split('+'))))
        
    print(ans)

    return



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

if __name__ == '__main__':
    main()

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

Solution (Python):
import itertools

s = input()
l = len(s)
ans = int(s)
for i in range(1, l):
    x = list(itertools.combinations(list(range(1, l)), i))
    for xi in x:
        p = 0
        for q in xi:
            ans += int(s[p:q])
            p = q
        ans += int(s[q:])
print(ans)

Solution (Python):
import itertools


def sum_strlong(strlong):
    ans = int(strlong)
    for i in range(1, len(strlong)):
        for comb in itertools.combinations(range(len(strlong)-1), i):
            integer = ''
            for j, digit in enumerate(strlong):
                integer += digit
                if j in comb:
                    integer += '+'
            ans += eval(integer)
    return ans


def main():
    print(sum_strlong(input()))


main()

Solution (Python):
s = input()
n = len(s)
ans = []

for i in range(2**(n-1)):
    test = ""
    num = str(bin(i))[2:].zfill(n-1)
    for j in range(n-1):
        test += s[j]
        if num[j] == '1':
            test += '+'
    test += s[-1]
    ans.append(eval(test))
print(sum(ans))

Solution (Python):
s=input()
n=int(len(s))
cnt=int(s)
s=list(map(int,s))
if n==1:
    cnt=cnt
elif n==2:
    cnt+=s[0]+s[1]
else:
    cnt=0
    cnt+=s[0]*10**(n-1)
    for i in range(0,n-1):
        cnt+=(10**i)*(sum(s[:n-i])+s[n-i-1])*2**(n-i-2)
print(cnt)

Solution (Python):
s=input()
l=len(s)
ans=int(s)
for i in range(1,2**(l-1)):
  f=format(i,'b')
  if len(f)<l:
    f='0'*(l-1-len(f))+f
  pos=[]
  for j in range(len(f)):
    if f[j]=='1':
      pos.append(j+1)
  n=[]
  if len(pos)==1:
    n.append(int(''.join(map(str,s[:pos[0]]))))
    n.append(int(''.join(map(str,s[pos[0]:]))))
  else:
    n.append(int(''.join(map(str,s[:pos[0]]))))
    for j in range(1,len(pos)):
      n.append(int(''.join(map(str,s[pos[j-1]:pos[j]]))))
    n.append(int(''.join(map(str,s[pos[len(pos)-1]:]))))
  ans+=sum(n)
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()
d=len(s)-1
ans=0
for i in range(2**d):
    i=list(map(int,list(bin(i)[2:].zfill(d))))
    x=s[0]
    for j in range(d):
        if i[j]==1:x+="+"
        x+=s[j+1]
    ans+=eval(x)
print(ans)

Solution (Python):
S = input()

sum = 0
for i in range(2 ** (len(S) - 1)):
    P = ["+" if (i >> j) & 1 else "" for j in range(len(S) - 1)] + [""]
    T = "".join(s + p for s, p in zip(S, P))
    sum += eval(T)
print(sum)

Solution (Python):
s = input()
if len(s)==1:
    print(s)
    exit()
list = [[0]*(len(s)-1)]
def dfs(l,cnt):
    if cnt==len(s)-1:
        return 0
    ret = l.copy()
    ret[cnt] += 1
    if not l in list:
        list.append(l)
    list.append(ret)
    dfs(l,cnt+1)
    dfs(ret,cnt+1)
    return 0
dfs([0]*(len(s)-1),0)
ans = 0
for l_ in list:
    start = 0
    for i in range(len(l_)):
        if l_[i]==1:
            ans += int(s[start:i+1])
            start = i+1
        if i==len(l_)-1:
            ans += int(s[start:])

print(ans)

Solution (Python):
s = input()

n = len(s)
res = 0
for i in range(2**(n-1)):
    idx = n-1
    ss = s
    r = i
    while r>0:
        if r & 1:
            ss = ss[:idx]+'+'+ss[idx:]
        idx -= 1
        r>>=1
    res += sum([int(c) for c in ss.split('+')])
print(res)

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

ans = 0

for i in range(2 ** l):
    bin_str = format(i, "09b")[::-1] + "0"

    new_s = "".join([x + "+" if bin_str[idx] == "1" else x + "" for idx, x in enumerate(s)])

    ans += eval(new_s)

print(ans)

Solution (Python):
import itertools
import copy

num_list = [chr for chr in input()]
TF_list = [True, False]

boundary_list = list(itertools.product(TF_list, repeat = len(num_list) - 1))

num_sum = 0

for boundary in boundary_list:
    
    num_list_copy = copy.copy(num_list)
    boundary = list(boundary)
    boundary.append(True)
    boundary_list.reverse
    temp = []
    
    while num_list_copy:
        temp.append(num_list_copy.pop(0))
        if boundary.pop(0):
            post_temp = int(''.join(temp))
            num_sum += post_temp
            temp = []
            
print(num_sum)

Solution (Python):
from math import factorial
from sys import exit, stdin
S = list(stdin.readline().rstrip())
N = len(S)-1
ans = 0
for i in range(1 << N):
    tmp = []
    tmp.append(S[0])
    for j in range(N):
        if ((i >> j) & 1):
            tmp.append("+")
            tmp.append(S[j+1])
        else:
            tmp.append(S[j+1])
    ans += eval("".join(tmp))
print(ans)

Solution (Python):
from itertools import product

ss = input()
ans = []
for pattern in product(range(2),repeat=len(ss)-1):
    if sum(list(pattern)) is 0:
        continue
    tmp = ''
    for s,p in zip(ss,pattern):
        tmp += s
        if p == 1:
            tmp += '+'
    tmp += ss[-1]
    ans.append(eval(tmp))
print(sum(ans)+int(ss))

Solution (Python):
S = input()


def dfs(num_string, p):


  
  if len(S) == 1:
    ans = int(S)
    return ans
  
  if p > len(S) - 1:
    
    ans = eval(num_string)
    return ans
  
  
  ret = 0
  
  ret += dfs(num_string + "+" + S[p], p+1)
  ret += dfs(num_string + S[p], p+1)
  
  return ret

ans = dfs(S[0],1)
print(ans)

Solution (Python):
S = input()

ans = 0
def dfs(num_string, p):

  global ans
  
  if len(S) == 1:
    ans = int(S)
    return
  
  if p > len(S) - 1:
    
    ans += eval(num_string)
    return 
  
  
  if p == 0:
    num_string  = "" + S[0]
    p = 1
  
  tmp = 0
  
  dfs(num_string + "+" + S[p], p+1)
  dfs(num_string + S[p], p+1)
  
  return

dfs(0,0)
print(ans)

Solution (Python):
s=[i for i in input()]
t=len(s)-1
tmp=2**t
ans=0
for i in range(tmp):
    p=bin(i)[2:]
    p="0"*(t-len(p))+p
    x=""
    for j,k in enumerate(s):
        x+=k
        if j!=t and p[j]=="1":
            x+="+"
    ans+=eval(x)
print(ans)

Solution (Python):
from itertools import product, chain

S = input()
ans = 0

for plus in product(('', '+'), repeat=len(S)-1):
    ans += eval(''.join(chain.from_iterable(zip(S, list(plus)+['']))))
    
print(ans)

Solution (Python):
S = input()

def sumS(nums):
    p = 0
    if len(nums) == len(S)-1:
        num = int(S[0])
        for n, s in zip(nums, S[1:]):
            if n == 0:
                num = num * 10 + int(s)
            else:
                p += num
                num = int(s)
        p += num
        return p
    
    for i in range(2):
        nums.append(i)
        p += sumS(nums)
        nums.pop()
    return p

print(sumS([]))

Solution (Python):
from itertools import product, chain
S = input()
num = 0
for plus in product(("", "+"), repeat=len(S) - 1):
    num += eval("".join(chain.from_iterable(zip(S, list(plus) + [""]))))
print(num)

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

if __name__ == '__main__':
	main()

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

Solution (Python):
S=input()
n=len(S)
ans=0
for i in range(2**(n-1)):
  key=str(bin(i))[2:].zfill(n-1)
  f=S[0]
  for j in range(1,n):
    if key[j-1]=="0":
      f+=S[j]
    else:
      f+="+"+S[j]
  ans+=eval(f)
print(ans)

Solution (Python):
n = input()
l = len(n)
ans = 0
for i in range(2**(l-1)):
    m = n
    b = list(bin(i)[2:])
    if len(b) < l-1:
        b = ["0"]*(l - 1 - len(b)) + b
    temp = 0
    for j, bb in enumerate(b):
        if bb == "1":
            ans += int(m[temp:j+1])
            temp = j+1
    ans += int(m[temp:])
print(ans)

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

def dfs(s, n):
  if n == N:
    tmp = list(map(int, s.split('+')))
    
    return sum(tmp)
  c = 0
  for i in ['', '+']:
    c += dfs(s + i + S[n+1], n+1)
  return c

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

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

x = len(S) 
y = x-1 

S = [int(s) for s in S] 


ans = 0
for i in range(0, x): 
    
    j=1
    a =S[i] 
    while y-j >= i:
        
        ans += a * (10 ** (j-1)) * (2**(y-j))
        j += 1
    if y-j < i:
        ans += a * (10 ** (j-1)) * (2 ** i)

print (ans)

Solution (Python):

from itertools import combinations


def read_input():
    s = input().strip()
    return s

def split_and_sum(s, indice):
    indice_e = [0] + indice + [10]

    result = []
    for start,end in zip(indice_e, indice_e[1:]):
        result.append(int(s[start:end]))

    return sum(result)

def submit():
    s = read_input()
    max_index = len(s)

    acc = 0
    for i in range(max_index):
        for c in combinations(range(1, max_index), i):
            acc += split_and_sum(s, list(c))

    print(acc)

if __name__ == '__main__':
    submit()

Solution (Python):
S = input()


def D2NC(D: int, N: int, link=False) -> list:
    alp = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    res = []
    while D > 0:
        if D % N > 9:
            tmp = alp[D % N - 10]
            res.insert(0, str(tmp))
        else:
            res.insert(0, str(D % N))
        D //= N
    if not res:
        res.append('0')
    if link:
        res = ''.join(res)
    return res


n = len(S)
Sum = 0
for i in range(2**(n-1)):
    op = D2NC(i, 2, link=True).zfill(n-1)
    idx = 0
    num = []
    for i in range(len(op)):
        if op[i] == '1':
            num.append(int(S[idx:i+1]))
            idx = i+1
    num.append(int(S[idx:]))
    Sum += sum(num)

print(Sum)

Solution (Python):

import copy

def solve(S):
    res = 0
    for i in range(1<<(len(S)-1)):
        A = []
        A.append(S[0])
        for j in range(len(S)-1):
            if((i>>j)&1):
                A.append("+")
                A.append(S[j+1])
            else:
                A.append(S[j+1])
        res += eval("".join(A))
    print(res)
                
if __name__ == '__main__':
    S = list(input())
    solve(S)

Solution (Python):


import sys
import math


S = str(input())
ret = 0

def solve(i,n,sm):
  if i == len(S)-1:
    return sum(sm+[n*10+int(S[i])])

  ret = 0
  
  ret += solve(i+1, 0, sm+[n*10+int(S[i])])
  
  ret += solve(i+1, n*10+int(S[i]), sm)
  return ret

if __name__ == "__main__":
  print(solve(0,0,[]))

Solution (Python):


S = input()
N = 2 ** (len(S) - 1)
ans = 0
for i in range(N):
    l = ""  
    for j in range(len(S) - 1):
        l += S[j]
        if((i >> j) & 1):
            l += "+"
    l += (S[len(S) - 1])
    
    li = list(map(int,l.split("+")))
    for num in li:
        ans += num

print(ans)

Solution (Python):
n=input()
m=[[]for _ in range(len(n))]
m[0]+=[[0,int(n[0])]]
for i in range(1,len(n)):
  a=int(n[i])
  for m0,m1 in m[i-1]:
    m[i]+=[[m0+m1,a]]
    m[i]+=[[m0,m1*10+a]]
ans=0
for m0,m1 in m[len(n)-1]:
  ans+=m0+m1
print(ans)

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

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):
s = input().rstrip()
length = len(s) - 1

ans = 0
for i in range(2**length):
    val = 0
    nums = s[:]
    prev_j = 0
    for j in range(length):
        if i >> j & 1:
            val += int(nums[prev_j:j+1])
            prev_j = j+1
    val += int(nums[prev_j:])
    ans += val
print(ans)