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):
def alllist(n,stre):
    if n == 0:
        return [[stre]]
    else:
        oldlist = alllist(n-1,stre)
        newlist = oldlist[:]
        for elements in oldlist:
            new1 = elements[:]
            temp1 = new1[0][:(len(stre) - n)]
            temp2 = new1[0][(len(stre) - n):]
            new1 = new1[1:]
            new1.insert(0,temp1)
            new1.insert(1,temp2)
            newlist.append(new1)
        return newlist

s=input()

lista=alllist(len(s)-1,s)
aaaaa=0

for elemens in lista:
    for i in elemens:
        listb=[]
        listb.append(int(i))
        aaaaa += sum(listb)

print(aaaaa)

Solution (Python):
S = input()
p = ["+", ""]

count = 0
for i in range(2 ** (len(S) - 1)):
    t = S[0]
    for j in range(len(S) - 1):
        t += p[i >> j & 1] + S[j + 1]
    
    count += eval(t)
print(count)

Solution (Python):
S = input()
p = ["+", ""]

count = 0
for i in range(2**(len(S)-1)):
  t = S[0]
  for j in range(len(S)-1):
    t += p[i>>j&1] + S[j+1]
  count += eval(t)
print(count)

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

for i in range(1 << n):
    op = [""] * n
    for j in range(n):
        if i & (1 << j):
            op[j] = "+"
    f = "".join([S[i//2] if i % 2 == 0 else op[i//2] for i in range(2*(n+1)-1)])
    ans += eval(f)
print(ans)

Solution (Python):
S = input()
length = len(S) - 1
sum = 0
for i in range(2**length):
	plus = [0]
	for j in range(length):
		if ((2**j) & i) // (2**j) == 1:
			plus.append(j + 1)
	plus.append(length + 1)
	for j in range(len(plus) - 1):
		sum += int(S[plus[j]:plus[j+1]])
print(sum)

Solution (Python):

S=input()  
ans=0
num=0

def count(S,binnumber,i):
    if i==1:
        if binnumber[0]=="1":
            return int(S[0])+int(S[1:])
        return int(S)
    elif binnumber[i-1]=="1":
            return int(S[i:])+count(S[:i],binnumber,i-1)
    return count(S,binnumber,i-1)

for i in range(len(S)-1):
    num=num+2**i

for i in range(num+1): 
    binnumber=str(format(i,"b").zfill(len(S)-1))
    j=len(binnumber)
    ans=ans+count(S,binnumber,j)
    
print(ans)

Solution (Python):


import sys

sys.setrecursionlimit(10**7)


input = sys.stdin.readline


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h(typ) if m > 1 else typ(input()) for _ in range(n)]


def main():
    S, = read_h(typ=str)
    n = len(S) - 1

    total = 0
    for i in range(2**n):
        prev = 0
        for j in range(n):
            
            if ((i >> j) & 1):
                
                m = int(S[prev:j + 1])
                
                total += m
                prev = j + 1

        m = int(S[prev:])
        
        total += m

    print(total)


if __name__ == '__main__':
    main()

Solution (Python):
def clc(a, b, c, p, t):
    if c == 0:
        b = a[0]
        return clc(a, b, c + 1, True, t) + clc(a, b, c + 1, False, t)
    elif c == len(a)-1:
        if p:
            return t + int(b) + int(a[c])
        else:
            return t + int(b + a[c])
    else:
        if p:
            t += int(b)
            b = a[c]
        else:
            b += a[c]
        return clc(a, b, c + 1, True, t) + clc(a, b, c + 1, False, t)


s = input()
print(clc(s, "", 0, True, 0) if len(s) != 1 else s)

Solution (Python):
s = input()
n = len(s)-1
ss = s
sum = 0
for x in range(2**n):
    s = list(s)
    j = 0
    for i in range(n):
        if (x>>i)&1:
            s.insert(i+j+1,"+")
            j += 1

    s = "".join(s)
    sum += eval(s)
    s = ss



print(sum)

Solution (Python):
S = input()
n = len(S)
sum = 0
for i in range(2**(n-1)):
    B = [""] * (n-1)
    f = ""
    for j in range(n-1):
        if((i>>j)&1):
            B[j] = "+"
            
    for a,b in zip(S, B+[""]):
        
        f += a
        f += b
        
    sum += eval(f)

print(sum)

Solution (Python):
S=input()

n=len(S)-1
total=0
for i in range(2**n):
    SS=S[0]
    x=format(i,'0'+str(n)+'b')
    
    for j in range(n):
        if x[j]=='1':
            SS+="+"
        SS+=S[j+1]
        
    total+=eval(SS)
print(total)

Solution (Python):
S = input()
len_s = len(S)
a = [int(S[i]) for i in range(len(S))]
sum_list = []

def f(pos, one_sum, block):
    if pos == len_s - 1:
        one_sum += block
        sum_list.append(one_sum)

    else:
        f(pos+1, one_sum + block, a[pos+1])
        f(pos+1, one_sum, 10*block+a[pos+1])

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

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

ans = ""

for mask in range(1 << (len(S)-1)):
    for i in range(len(S)):
        if ((mask >> i) & 1):
            ans += str(S[i]) + "+"
        else:
            ans += str(S[i])
    ans += "+"

print(int(eval(ans[:-1])))

Solution (Python):
S = input()
def partial_sum(pseq):
    
    
    if len(pseq) > 0:
        return int(pseq) + sum(int(pseq[:i])*(2**(len(pseq)-i-1)) +  partial_sum(pseq[i:]) for i in range(1, len(pseq)))
    else:
        return 0
print(partial_sum(S))

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

ans = 0
if n == 0:
    ans = int(s)
else:
    for i in range(2 ** n):
        calc = [0 for i in range(n)]
        for j in range(n):
            if ((i >> j) & 1):
                calc[- 1 - j] = 1
        str_num = s[0]
        for k in range(n):
            if calc[k] == 0:
                str_num += s[k+1]
            elif calc[k] == 1:
                ans += int(str_num)
                str_num = s[k+1]
            if k == n-1:
                ans += int(str_num)

print(ans)

Solution (Python):

def solve(S):
    a = _iter(S, '')
    return a


def _iter(s, t):
    if s == '':
        if t.endswith('+'):
            return 0
        return eval(t)
    a = s[0]
    b = s[1:]
    return _iter(b, t+a) + _iter(b, t+a+'+')


if __name__ == '__main__':
    S = input()
    print(solve(S))

Solution (Python):
S = input()

def calc(n):
    P = [(n >> i) % 2 for i in range(len(S)-1)]
    tmp = ""
    for i, s in enumerate(S):
        tmp += s
        if i < len(S)-1 and P[i] == 1:
            tmp += "+"
    return eval(tmp)

ans = 0
for i in range(2 ** (len(S)-1)):
    ans += calc(i)
print(ans)

Solution (Python):
import itertools

s = input().split()[0]

start_index = 0

sum_list = []


sum_list.append(int(s))


for spliter_n in range(1, len(s)):
	

	comb_list = list(itertools.combinations(list(range(0, len(s)-1)), spliter_n))
	
	
	for comb_set in comb_list:
		s_copy = s
		number_list = []
		comb_set_list = list(comb_set)
		comb_set_list = [-1] + comb_set_list
		

		for i, a in enumerate(comb_set_list):

			if a == comb_set_list[-1]:
				
				s_i = comb_set_list[i]+1
				number_list.append(s[s_i:])
				
			else:
				
				s_i, e_i = comb_set_list[i]+1, comb_set_list[i+1]+1
				number_list.append(s[s_i:e_i])

		debug_text = (' + ').join(number_list)
		

		number_list = [int(x) for x in number_list]
		
		sum_list.append(sum(number_list))
	


answer = sum(sum_list)
print(answer)

Solution (Python):
S = list(input())
N = len(S) - 1
res = 0
for bits in range(0,2**N):
    pos = [0] * N
    for i in range(N):
        if bits & (1<<i):
            pos[i] = 1
    acc = 0
    for i in range(N):
        acc += pos[i]
        if pos[i] == 1:
            pos[i] = acc
    s = list(S)
    for i in range(N):
        if pos[i] > 0:
            p = pos[i] + i
            s.insert(p, '+')

    expr = "".join(s)
    res += eval(expr)

print(res)

Solution (Python):
s = input()

def calc_str(st):
  lst = st.split('+')
  lst = map(int, lst)
  return sum(lst)
  
prev = []
for c in s:
  if prev != []:
    new_prev = []
    for elem in prev:
      new_prev.append(elem + c)
      new_prev.append(elem + "+" + c)
    prev = new_prev
  else:
    prev.append(c)

sums = 0
for elem in prev:
  sums += calc_str(elem)
print(sums)

Solution (Python):
s = input()
len_s = len(s)
a = [int(s[i]) for i in range(len_s)]
sum_list = []


def f(pos,one_sum,block):
    if pos == len_s - 1:
        one_sum += block
        sum_list.append(one_sum)
    else:
        f(pos+1,one_sum+block,a[pos+1])
        f(pos+1,one_sum,10*block+a[pos+1])
    

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

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

Solution (Python):
s = input()
len = len(s)
ns = list(map(int,s))
total_sum = 0
for bit in range(1 << (len-1)):
  
  sum_ = 0
  num = ns[0]
  for i in range(1, len):
    if (bit & 1) > 0:
     
      sum_ += num
      num = ns[i]
    else:
      num = (num * 10 + ns[i])
    bit = bit >> 1
  total_sum += sum_ + num
print(total_sum)

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

count = len(s)-1
sum = 0
for bit in range(2**count):
    hugou = [""] * count
    
    for i in range(count):
        if (bit >> i) & 1:
            hugou[count-1-i] = "+"
            
    calc = ""
   
    for j in range(count):
        calc += str(s[j])
        
        calc += str(hugou[j])
        
        
    calc += str(s[-1])
    
    sum += eval(calc)
print(sum)

Solution (Python):
def f(a, b, le, tf):
    b[le] = tf
    if le == len(b)-1:
        t = ""
        s1 = 0
        for i in range(len(b)):
            t += a[i]
            if b[i] == 1:
                s1 += int(t)
                t = ""
        t += a[len(b)]
        s1 += int(t)
        return s1
    else:
        return f(a, b, le+1, 0) + f(a, b, le+1, 1)


aa = input()
bb = [0] * (len(aa)-1)
if len(aa) == 1:
    print(aa)
else:
    print(f(aa, bb, 0, 0) + f(aa, bb, 0, 1))

Solution (Python):
s = list(input())
n = len(s)-1
total=0
for i in range(2**n):
  bitl = list(bin(i)[2:].zfill(len(s)-1))
  tmp=''
  for j in range(len(s)-1):
    bitl[j] = bitl[j].replace('1','+').replace('0','')
    tmp+=s[j]+bitl[j]
  tmp+=s[len(s)-1]
  total+=eval(tmp)
print(total)

Solution (Python):
import itertools
s = list(input())
bit=['','+']
total=0
for i in itertools.product(bit, repeat=len(s)-1):
  siki=s[0]
  k=0
  for j in s[1:]:
    siki+=i[k]+j
    k+=1
  total+=eval(siki)
print(total)

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
import math
mod = 10**9 + 7
def I(): return int(input())
def II(): return map(int, input().split())
def L(): return list(map(int, input().split()))
def TWO(M):
  L=[0]*M
  R=[0]*M
  for i in range(M):
    L[i],R[i] = II()
  return L, R

from itertools import product
S = I()
mark = list(product(['','+'],repeat=len(str(S))-1))
ans = 0
for a in mark:
  form = ''
  for i in range(len(str(S))*2-1):
    if i%2==0:
      form += str(S)[i//2]
    else:
      form += a[i//2]
  ans += eval(form)
print(ans)

Solution (Python):
s = input()

op_n = len(s) - 1

ans = 0

for i in range(1 << op_n):
  sign = [""] * op_n
  for j in range(op_n):
    if ((i>>j)&1):
      sign[j] = "+"
  formula = ""
  for k in range(op_n):
    formula += s[k] + sign[k]
  formula += s[op_n] 
  ans += eval(formula)
print(ans)

Solution (Python):
s=input()
l=2**(len(s)-1)
count=0
for i in range(l):
    n=0
    buf=0
    while(i):
        if i & 1 ==1:
            count+=int(s[buf:n+1])
            buf=n+1
        n+=1
        i=i>>1
    count+=int(s[buf:])
print(count)

Solution (Python):
from itertools import product

S = input()
ans = 0
for symbol in product(['+', ''], repeat=len(S) - 1):
    string = ''
    for i in range(len(S) - 1):
        string += S[i] + symbol[i]
    ans += eval(string + S[-1])

print(ans)

Solution (Python):
S = input()
S_list = list(S)
n = len(S) 
a = []

list_0or1 = [0] * (n-1)
check = []

def f(i):
    if i == n-1 :
        check.append(list_0or1.copy())
    if i != n-1:
        list_0or1[i] = 0
        f(i+1)
    if i != n-1:
        list_0or1[i] = 1
        f(i+1)
f(0)

sum_list = []
for i in range(len(check)):
    S_list_copy = S_list.copy()
    for j in range(n-1) :
        if check[i][j] == 1 :
            S_list_copy[j+1] = '+' + S_list_copy[j+1]
    S_list_copy = ''.join(S_list_copy)
    S_list_copy = list(map(int,S_list_copy.split('+')))
    s = sum(S_list_copy)
    sum_list.append(s)
print(sum(sum_list))

Solution (Python):
input_num = str(input())

def calc_adding(left_str, skip_cnt, const):
  
  if len(left_str) <= 1 + skip_cnt:
    return int(left_str) + const

  
  
  res_np = calc_adding(left_str, skip_cnt + 1, const)

  
  const += int(left_str[:1 + skip_cnt])
  res_p = calc_adding(left_str[1 + skip_cnt:], 0, const)

  return res_np + res_p

res = calc_adding(input_num, 0, 0)
print(res)

Solution (Python):
s = [int(x) for x in input()]
count = len(s)-1
wa = 0
for bit in range(2**count):
    hugou = [""] * count
    for i in range(count):
        if (bit >> i) & 1:
            hugou[count-1-i] = "+"
    calc = ""
    for j in range(count):
        calc += str(s[j])
        calc += str(hugou[j])
    calc += str(s[-1])
    wa += eval(calc)
print(wa)

Solution (Python):
a=input()
b=[]
c=0
for i in range(len(a)):
  c=a[i]
  b.append(c)
c=int(a)
def s(b):
  cc=1
  for i in range(len(b)):
    if b[i]=="+":
      cc=i
  for i in range(cc,len(b)):
    if b[i-1]!="+" and b[i]!="+":
      ba=b[:i]
      bb=b[i:]
      bc=ba+["+"]+bb
      cc="".join(bc)
      cc=cc.split("+")
      for i in range(len(cc)):
        cc[i]=int(cc[i])
      global c
      c+=sum(cc)
      s(bc)
      
s(b)
print(c)

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

def culc(string):
    string = list(string)
    digit = []
    prev = 0
    for i, s in enumerate(string):
        if s == "+":
            digit.append(int("".join(string[prev:i])))
            prev = i+1
        if i == len(string)-1:
            digit.append(int("".join(string[prev:])))
    return sum(digit)

SUM = 0
for bit in range(0, 1<<N):
    string = S
    for i in reversed(range(N)):
        if (bit>>i) & 1:
            string = string[:i+1] + "+" + string[i+1:]
    SUM += culc(string)  

print(SUM)

Solution (Python):
import sys
from io import StringIO
import unittest


import sys
sys.setrecursionlimit(4100000)


def resolve():
    original_s = list(sys.stdin.readline().split()[0])
    sum_list = []
    sum_list_append = sum_list.append

    def dfs(s, sum):
        if len(s) == 0:
            sum_list_append(sum)
            return
        if len(s) == 1:
            sum_list_append(sum + int(s[0]))
            return

        dfs(s[1:], sum + int(s[0]))

        dfs([s[0] + s[1]] + s[2:], sum)

    dfs(original_s, 0)
    print(sum(sum_list))


if __name__ == "__main__":
    resolve()


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """125"""
        output = """176"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """9999999999"""
        output = """12656242944"""
        self.assertIO(input, output)

Solution (Python):
import sys
from io import StringIO
import unittest


import sys
sys.setrecursionlimit(4100000)


def resolve():
    original_s = list(sys.stdin.readline().split()[0])
    sum_list = []
    sum_list_append = sum_list.append

    def dfs(s, sum):
        if len(s) == 0:
            sum_list_append(sum)
            return
        if len(s) == 1:
            sum_list_append(sum + int(s[0]))
            return

        dfs(s[1:], sum + int(s[0]))

        dfs([s[0] + s[1]] + s[2:], sum)

    dfs(original_s, 0)
    print(sum(sum_list))


if __name__ == "__main__":
    resolve()


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """125"""
        output = """176"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """9999999999"""
        output = """12656242944"""
        self.assertIO(input, output)

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

Solution (Python):


def solve(S, bitls, bitlslen):
    splited = []
    splitlen = 0
    prev = 0
    for i in range(bitlslen):
        if bitls[i] == 1:
            splited.append(S[prev:i+1])
            prev = i+1
            splitlen += 1
    splited.append(S[prev:])
    splitlen += 1
    
    sum = 0
    for i in range(splitlen):
        sum += int(splited[i])
    return sum


S = input()
lenS = len(S)

loop = 2**(lenS-1)

ans = 0
for i in range(loop):
    val = i
    bitls = []
    for j in range(lenS-1):
        bitls.append(val % 2)
        val //= 2
    ans += solve(S, bitls, lenS-1)
print(str(ans))

Solution (Python):
from copy import deepcopy
N=list(input())
lenn=len(N)-1
cnt=0
for i in range(2**lenn):
    n=deepcopy(N)
    b=(("0"*lenn)+bin(i)[2:])[-lenn:]
    for i in range(lenn-1,-1,-1):
        if b[i]=="1":
            n.insert(i+1,"+")
    cnt+=eval("".join(n))
print(cnt)

Solution (Python):
row = input().split()
s = list(row[0])
count = 0
for bit in range(1<<(len(s)-1)):
    S=[]
    S.append(s[0])
    for i in range(len(s)-1):
        if bit & (1<<i):
            S.append("+")
        S.append(s[i+1])
    S = "".join(S)
    S = S.split("+")
    S = list(map(int, S))
    count += sum(S)
print(count)

Solution (Python):
S = input()

op_cnt = len(S) - 1

ans = 0

for i in range(2 ** op_cnt):
  sign = [""] * op_cnt
  for j in range(op_cnt):
    if ((i>>j)&1):
      sign[j] = "+"
       
  formula = ""      
  for k in range(op_cnt):
    formula += S[k] + sign[k]
  formula += S[op_cnt]
  ans += eval(formula)
print(ans)

Solution (Python):



n = list(input())
op_cnt = len(n) - 1
a = []
li = []
ctr = 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] = "+"
    for p_n, p_o in zip(n, op + [""]):
        a.append(p_n)
        a.append(p_o)
    li = list(map(int, ''.join(a).split("+")))
    ctr += sum(li)
    a.clear()
print(ctr)

Solution (Python):
S = input()

ans = 0
lenS = len(S)
divider = lenS - 1  

for i in range(1, lenS + 1) :
    now = int(S[-i])
    mask = 0
    for j in range(i) :
        mask *= 10
        mask += now * 2**(max(0,j-1))

    ans += mask * 2**(divider - i + 1)

print(ans)

Solution (Python):
S = input()

ans = 0
divider = len(S) - 1  

for i in range(1, len(S) + 1) :
    now = int(S[-i])
    mask = 0
    for j in range(i) :
        mask *= 10
        weight = 2**(max(0,j-1))
        mask += now * weight

    count = 2**(divider - i + 1)
    ans += mask * count

print(ans)

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

total = 0
for i in range(2**N):
    sign = [""] * N
    for j in range(N):
        if ((i >> j) & 1):
            sign[j] = "+"
    
    formula = ""
    for k in range(N):
        formula += S[k] + sign[k]
    formula += S[N]
    total += eval(formula)
print(total)

Solution (Python):
s=input()
t=len(s)-1
tmp=2**t
ans=0

for i in range(tmp):
    x = ''
    for j in range(len(s)):
        x += s[j]
        if ((i>>j)&1):
            x+='+'
    ans+=eval(x)
print(ans)

Solution (Python):
n=list(input())
k=len(n)-1

x=0
for i in range(2**k):
    v=[""]*k
    for j in range(k):
        if ((i>>j)&1):
            v[j]="+"
    ans=""
    for a,b in zip(n,v+[""]):
        ans+=(a+b)
    x+=eval(ans)
print(x)

Solution (Python):
N=input()
X=int(N)
L=len(str(N))
b=X
ch=[0 for i in range(L)]


for i in range (1,L+1):
  ch[-i]=b%10
  b=b//10



A=[[0 for i in range (L)] for j in range (L)]

for i in range (L-1):
  for j in range (L-i):
    A[i][j]=2**(L-i-2)

for i in range(L):
  A[i][L-i-1]=2**(L-i-1)

com=[]

for i in range(L):
  an=0
  for j in range (L):
    an+=A[j][i]*10**(j)
  com.append(an)

ans=0
for i in range(L):
  ans+=com[i]*ch[i]

print(ans)

Solution (Python):
N=input()
X=int(N)
L=len(str(N))
b=X
ch=[0 for i in range(L)]


for i in range (1,L+1):
  ch[-i]=b%10
  b=b//10



A=[[0 for i in range (L)] for j in range (L)]

for i in range (L-1):
  for j in range (L-i):
    A[i][j]=2**(L-i-2)

for i in range(L):
  A[i][L-i-1]=2**(L-i-1)

com=[]

for i in range(L):
  an=0
  for j in range (L):
    an+=A[j][i]*10**(j)
  com.append(an)

ans=0
for i in range(L):
  ans+=com[i]*ch[i]

print(ans)

Solution (Python):
s=input()
n=len(s)-1 
ko=2**n
en=[""]*n
total=0
for i in range(ko):
    en=[""]*n
    for j in range(len(s)):
        if((i>>j)&1)==True:
            en[j]="+"
    formula=""
    for x,y in zip(s,en+[""]):
        formula+=(x+y)
    total+=eval(formula)
print(total)

Solution (Python):
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

S = sys.stdin.readline().rstrip()
N = len(S)



S = list(S)
ans = 0
for ops in itertools.product(['+', ''], repeat=N - 1):
    f = ''
    for c, op in zip(S[:-1], ops):
        f += c + op
    f += S[-1]
    ans += eval(f)
print(ans)

Solution (Python):

import time
import re
import math
import fractions

def main():
    global s
    s=input()
    print(hoge(0,"",0))
def hoge(index,now,total):
    global s
    if(index==len(s)):return total+int(now)
    if index==0:
        return hoge(index+1,now+s[index],total)
    else:
        return hoge(index+1,now+s[index],total)+hoge(index+1,s[index],total+int(now))
start=time.time()
main()

Solution (Python):
S = input()
N = 2 ** (len(S)-1)
sum = 0
for i in range(0, N):
	m = i
	k = S[0]
	minisum = 0
	for j in range(1, len(S)):
		if m % 2 == 1:
			minisum += int(k)
			k = S[j]
		else:
			k = k + S[j]
		m //= 2
	minisum += int(k)
	sum += minisum
print(sum)

Solution (Python):
def dfs(i, total):
    global ans
    if i == len(s)-1:
        ans += eval(total)
        return ans
    dfs(i + 1, total + "+" + s[i+1])
    dfs(i + 1, total + s[i+1])
    
ans = 0
s = input()
dfs(0, s[0])
print(ans)

Solution (Python):
s = input()
n = len(s)
total = 0
for i in range(2 ** (n-1)):
    num = ""
    for j in range(n):
        if j == n-1:
            num += s[j]
        elif ((i >> j) & 1):
            num += s[j] + ","
        else:
            num += s[j]
    num2 = list(num.split(","))
    map(int,num2)
    for k in num2:
        total += int(k)
print(total)

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

ans = 0
for bits in range(1 << len(s) - 1):
    check = ''
    for i in range(len(s)):
        if (bits >> i & 1) == 1:
            check += s[i] + '+'
        else:
            check += s[i]
    ans += eval(check)
print(ans)

Solution (Python):
if __name__ == '__main__':
    S = list(input())
    ans = 0
    for state in range(1 << (len(S)-1)):
        ans += eval(S[0] + ''.join(('+' if (state >> i & 1) else '')+x for i, x in enumerate(S[1:])))
        
        
        
    print(ans)

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

    answer = 0
    for i in range(2**(len(S)-1)):

        operators = (list(format(i, '0' + str(len(S)-1) + 'b').replace('1', '+').replace('0', ' ')))

        state = S[0]
        for j in range(len(S)-1):
            state += operators[j] + S[j+1]
        state = state.replace(' ', '')

        answer += eval(state)

    print(answer)

Solution (Python):
from itertools import product, combinations
S = input()
N = len(S)

cum = 0
for pluses in product((0,1), repeat=N-1):
    sl = S[:]
    for i in range(N-1):
        if pluses[i] == 1:
            sl = sl[:-N+i+1] + '+' + sl[-N+i+1:]
    cum += sum(int(elm) for elm in sl.split('+'))

print(cum)

Solution (Python):


s = input()
n = len(s)
ans = 0

if n == 1:
    print(int(s))
    exit()

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

    tmp = int(s[0])

    for j in range(n - 1):

        if (i >> j) & 1:
            ans += tmp
            tmp = 0

        tmp = tmp * 10 + int(s[j + 1])

    ans += tmp

print(ans)

Solution (Python):
n=list(input())
k=2**(len(n)-1)
v=[]
for i in range(k):
    x=['+']*(len(n)-1)
    for j in range(len(n)-1):
        if (i>>j)&1:
            x[j]=''
    
    ans=''
    for a,b in zip(n,x+['']):
        ans+=(a+b)
    v.append(eval(ans))
print(sum(v))

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

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

Solution (Python):
def calc(s):
    n = s.split("+")
    sum = 0
    for i in range(len(n)):
        sum += int(n[i])
    return sum

def bfs(S,n,s):
    if n == len(S):
        
        return calc(s)
    else:
        return bfs(S,n+1,s+"+"+S[n]) + bfs(S,n+1,s+S[n])

S=input()
s=S[0]
print(bfs(S,1,s))

Solution (Python):
def resolve():

    s = input()

    ans = 0

    for i in range(2 ** (len(s) - 1)):

        pos = 0
        for j in range(len(s) - 1):

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

        ans += int(s[pos:len(s)])

    print(ans)
    
resolve()

Solution (Python):
s = input()
lenth = len(s)
plus = lenth - 1
ans = 0
for i in range(1 << plus):
    right = lenth
    i_two = format(i,'b')
    ilen= len(format(i,'b'))
    for j in range(ilen):
        if i_two[ilen - 1 - j] == '1':
            ans += int(s[lenth - 1 - j:right])
            right = lenth - 1 - j
    ans += int(s[0:right])
print(ans)

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

s = input()
ans = 0
dfs(0, s[0])
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):
import itertools
s = list(input())
n = len(s)

ans = 0
if n == 1:
	ans = int(s[0])
else:
	for x in itertools.product(["", "+"], repeat = n - 1):
		tmp = ""
		for i in range(n - 1):
			tmp += s[i] + x[i]
		tmp += s[-1]
		ans += eval(tmp)
print(ans)

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

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

S = S()
ans = 0

for i in range(1<<(len(S)-1)):
    tmp_ans = 0

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

print(ans)

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

S = S()
ans = 0

for i in range(1<<(len(S)-1)):
    tmp_ans = 0
    bit = i

    for j in range(len(S)-1):
        if (bit & 1):
            tmp_ans *= 10
            tmp_ans += int(S[j])
            ans += tmp_ans
            tmp_ans = 0
        else:
            tmp_ans *= 10
            tmp_ans += int(S[j])
       
        bit >>= 1
    
    if (not tmp_ans):
        ans += int(S[-1])
    else:
        tmp_ans *= 10
        tmp_ans += int(S[-1])
        ans += tmp_ans

print(ans)

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

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

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

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


num_list=[input[x] for x in range(len(input))]
output=0
n=len(input)-1

for i in range(2**n):
    
    s_now=num_list[0]
    
    for j in range(n):
        
        if ((i >> j) & 1):
            
            s_now+=("+")
        
        s_now+=(num_list[j+1])

    
    
    output+=eval(s_now)

print(output)

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


for i in range(2**(N-1)):
    exp = S[0]

    
    for j in range(1, N):

        
        if (i >> (j-1)) & 1: exp += '+'
        exp += S[j]
        
    ans += eval(exp)

print(ans)