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()
n=len(s)-1
sum=0
for i in range(1<<n):
    p=0
    for j in range(n):
        if i & (1<<j):
            sum+=int(s[p:j+1])
            p=j+1
    sum+=int(s[p:])
print(sum)

Solution (Python):
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
import numpy as np

Mod = 1000000007
import sys
sys.setrecursionlimit(1000000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): 
    s = input()
    sl = [i for i in s]
    n = len(s)-1
    ans = []
    anslist = []
    sublist = [-1]*n
    for i in range(1 << n):
        for j in range(n):
            if (i>>j)&1:
                sublist[j] = "+"
        anslist.append(sl[0])
        for j in range(n):
            if sublist[j] == "+":
                anslist.append("+")
                anslist.append(sl[j+1])
            else:
                anslist.append(sl[j+1])
        ans.append(eval("".join(anslist)))
        anslist = []
        sublist = [-1]*n
    print(sum(ans))
if __name__ == "__main__":
    main()

Solution (Python):
s=input()
n=len(s)-1
sum=0
for bit in range(1<<n):
    p=0
    for i in range(n):
        if bit & (1<<i):
            sum+=int(s[p:i+1])
            p=i+1
    sum+=int(s[p:])
print(sum)

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

total = 0
for bit in range(2 ** l):
    n_list = []
    index = 0
    for i in range(l):
        if bit & (1 << i):
            total += int(S[index:i+1])
            index = i+1
    total += int(S[index:])
print(total)

Solution (Python):
import sys
import math
import fractions
import bisect
import queue
import heapq
import collections
import itertools
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint=====================================
N, K = map(int, input().split())
N, M = map(int, input().split())
A, B = map(int, input().split())

H, W = map(int, input().split())

L, R = map(int, input().split())

1行のstring=================================
S, T = input().split()

1行の整数配列================================
P = list(map(int,input().split()))

A = list(map(int,input().split()))
B = list(map(int,input().split()))

D = list(map(int,input().split()))

L = list(map(int,input().split()))
R = list(map(int,input().split()))

T = list(map(int,input().split()))

改行あり整数==================================
X = []
Y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    X.append(x1)
    Y.append(y1)

A = []
for i in range(N):
    a=int(input())
    A.append(a)

Pair = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    Pair.append((x1, y1))
    
2次元整数配列=====================================
A = []
for i in range(N):
    tmp = list(map(int,input().split()))
    A.append(tmp)


N行M列の初期化====================================
dp = [[VAL] * RETU for i in range(GYO)]

'''



S = input()

S = S[::-1]



ans = int(S[0]) * (2**(len(S)-1))
for i in range(1, len(S)):
    final = 0    
    for keta in range(0, i+1):
        if keta == i:
            final = 1
        ans += int(S[i]) * (10**keta) * (2**int(len(S)-2-keta+final))
        
print(ans)

Solution (Python):
import itertools

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

for item in itertools.product([0, 1], repeat=n-1):
    s_new = s[0]
    for i in range(len(item)):
        if item[i]:
            s_new += '+' + s[i+1]
        else:
            s_new += s[i+1]
    ans += sum([int(item) for item in s_new.split('+')])
print(ans)

Solution (Python):
s = input() 
l = len(s) -1
n = 2**l
cnt = 0

for i in range(n):
    ls = []
    for j in range(l):
        if (n-i >> j) & 1:
            ls.append(j+1)
    ls.append(l+1)
    a = 0
    for z in ls:
        cnt += int(s[a:z])
        a = z
print(cnt)

Solution (Python):
import itertools

S = input()
S_list = list(S)
keta = len(S)

plus=list(itertools.product([0,1], repeat = keta-1))

All = 0
for posi in plus:
    preserved = [S_list[0]]
    for k in range(len(posi)):
        if posi[k] == 1:
            preserved.append(S_list[k+1])
        else:
            All += int("".join(str(n) for n in preserved))
            preserved = [S_list[k+1]]
    All += int("".join(str(n) for n in preserved))

print(All)

Solution (Python):



s = list(input())
g,s_len=0,len(s)
for i in range(2**(s_len-1)):
    siki = s[0]
    for j in range(s_len-1):
        if i&(1<<j): siki+='+'
        siki+=s[j+1]
    tmp=0
    for j in range(len(siki)):
        if siki[j]!='+':
            tmp = tmp*10+int(siki[j])
        else:
            g+=tmp
            tmp=0
    g+=tmp
print(g)

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

ans=0
for bit in range(1<<n):
  l=[s[0]]
  for i in range(n):
    if (bit>>i)&1:
      l.extend(['+',s[i+1]])
    else:
      l.append(s[i+1])
  ans+=eval(''.join(l))
print(ans)

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

def dfs(i,s):
  if i==n-1:
    return eval(''.join(s))
  else:
    s1,s2=s.copy(),s.copy()
    s1.insert(2*i+1,'+')
    s2.insert(2*i+1,'')
    return dfs(i+1,s1)+dfs(i+1,s2)
  
print(dfs(0,s))

Solution (Python):
s=input()

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

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

Solution (Python):

S = input()
ans = 0
for i in range(1<<(len(S)-1)):
    chars = S[0]
    for j in range(len(S)-1):
        if ((i >> j) & 1) == 1:
            chars += '+' + S[j+1]
        else:
            chars += S[j+1]
    ans += eval(chars)
print(ans)

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

ans = 0

for bit in range(1 << n):
	L = []
	f = 0
	s = 0
	for i in range(n):
		if bit & (1 << i):
			s = i + 1
			L.append(int(S[f:s]))
			f = s
	L.append(int(S[s:]))
	ans += sum(L)

print(ans)

Solution (Python):
S = input()
bit = 0
sum = 0
while bit < (1<<len(S)-1):
    b = 0
    keta = 0
    for i in range(len(S)):
        if bit & (1<<i):
            sum += b + int(S[len(S)-1-i])*(10**keta)
            b = 0
            keta = 0
        else:
            b += int(S[len(S)-1-i])*(10**keta)
            keta += 1
            if i == len(S) - 1:
                sum += b
    bit += 1
print(sum)

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

for i in range(2 ** n):
    sep = [0] * n
    nums = []
    for j in range(n):
        if (i >> j) & 1:
            sep[j] = 1
    for ind, su in enumerate(s):
        tmp += su
        if ind < len(sep):
            if sep[ind] == 1:
                tmp += ","
    ans += sum(list(map(int, tmp.split(","))))
    tmp = ""

print(ans)

Solution (Python):
S = input()
n = len(S)
ans = 0
def eval(s):
    ls = s.split("+")
    return sum(map(int,ls))
b = list("x".join(list(S)))
for i in range(2**(n-1)):
    a = b.copy()
    for j in range(n-1):
        if i >> j & 1:
            a[j*2+1] = "+"
        else:
            a[j*2+1] = ""
    ans += eval("".join(a))
print(ans)

Solution (Python):
def main():
  s=str(input())
  l=len(s)
  ans=0
  
  for i in range(2**(l-1)):
    j=bin(i)[::-1]
    t=s
    c=1
    for k in j:
      if k=="1":
        ans+=int(t[-c:])
        t=t[:-c]
        c=1
      else:
        c+=1
    else:
      ans+=int(t)
    
  print(ans)
  
  
if __name__=="__main__":
  main()

Solution (Python):
def main():
  s=str(input())
  l=len(s)
  ans=0
  
  for i in range(2**(l-1)):
    j=bin(i)[::-1]
    tmp=[]
    t=s
    c=1
    for k in j:
      if k=="1":
        tmp.append(int(t[-c:]))
        t=t[:-c]
        c=1
      else:
        c+=1
    else:
      tmp.append(int(t))
    ans+=sum(tmp)
    
  print(ans)
  
  
if __name__=="__main__":
  main()

Solution (Python):
def main():
  s=str(input())
  l=len(s)
  ans=0
  
  for i in range(2**(l-1)):
    j=bin(i)[::-1]
    tmp=[]
    t=s
    c=1
    for k in j:
      if k=="1":
        tmp.append(t[-c:])
        t=t[:-c]
        c=1
      else:
        c+=1
    else:
      tmp.append(t)
    ans+=sum(map(int,tmp))
    
  print(ans)
  
  
if __name__=="__main__":
  main()

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

        for j in range(len(b)):
            c += s[j]
            if b[j] == "1":
                c += "+"
        c += s[-1]
        total = sum(map(int, c.split("+")))
        ans += total
    print(ans)

Solution (Python):

str_input = input()
sum_all = 0






n = len(str_input)



plus_pattern_2 = (2**(n-1))-1



for value in range(plus_pattern_2+1):
    
    
    right = n
    
    tmp_number = 0

    for i in range(1, n+1):
        
        
        result = value & 1
        if result == 1:
            
            tmp_number = int(str_input[n-i:right])
            
            sum_all += tmp_number
            right = n-i
        value = value >> 1
        
        

    

    tmp_number = int(str_input[n-i:right])
    
    sum_all += tmp_number
    

print(sum_all)

Solution (Python):
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue


Mod = 1000000007
import sys

sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)


class Dijkstra:
 
    def __init__(self, rote_map, start_point, goal_point=None):
        self.rote_map = rote_map
        self.start_point = start_point
        self.goal_point = goal_point
 
    def execute(self):
        num_of_city = len(self.rote_map)
        dist = [float("inf") for _ in range(num_of_city)]
        prev = [float("inf") for _ in range(num_of_city)]
 
        dist[self.start_point] = 0
        heap_q = []
        heapq.heappush(heap_q, (0, self.start_point))
        route_count = [0 for _ in range(num_of_city)]
        route_count[self.start_point] = 1
        while len(heap_q) != 0:
            prev_cost, src = heapq.heappop(heap_q)
 
            if dist[src] < prev_cost:
                continue
 
            for dest, cost in self.rote_map[src].items():
                if cost != float("inf") and dist[dest] > dist[src] + cost:
                    dist[dest] = dist[src] + cost
                    heapq.heappush(heap_q, (dist[dest], dest))
                    prev[dest] = src
                if dist[dest] == dist[src] + cost:
                    route_count[dest] += route_count[src]
 
        if self.goal_point is not None:
            return self._get_path(self.goal_point, prev)
        else:
            return dist, route_count
 
    def _get_path(self, goal, prev):
        path = [goal]
        dest = goal
 
        while prev[dest] != float("inf"):
            path.append(prev[dest])
            dest = prev[dest]
 
        return list(reversed(path))

        
def main(): 
    s = input()
    sl = [i for i in s]
    n = len(s)-1
    ans = []
    anslist = []
    sublist = [-1]*n
    for i in range(1 << n):
        for j in range(n):
            if (i>>j)&1:
                sublist[j] = "+"
        anslist.append(sl[0])
        for j in range(n):
            if sublist[j] == "+":
                anslist.append("+")
                anslist.append(sl[j+1])
            else:
                anslist.append(sl[j+1])
        ans.append(eval("".join(anslist)))
        anslist = []
        sublist = [-1]*n
    print(sum(ans))
if __name__ == "__main__":
    main()

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

def count(s,l):
    return int(s)+sum([2**(l-i-1)*int(s[:i])+count(s[i:],l-i) for i in range(1,l)])

print(count(s,n))

Solution (Python):
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue


Mod = 1000000007
import sys

sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)


class Dijkstra:
 
    def __init__(self, rote_map, start_point, goal_point=None):
        self.rote_map = rote_map
        self.start_point = start_point
        self.goal_point = goal_point
 
    def execute(self):
        num_of_city = len(self.rote_map)
        dist = [float("inf") for _ in range(num_of_city)]
        prev = [float("inf") for _ in range(num_of_city)]
 
        dist[self.start_point] = 0
        heap_q = []
        heapq.heappush(heap_q, (0, self.start_point))
        route_count = [0 for _ in range(num_of_city)]
        route_count[self.start_point] = 1
        while len(heap_q) != 0:
            prev_cost, src = heapq.heappop(heap_q)
 
            if dist[src] < prev_cost:
                continue
 
            for dest, cost in self.rote_map[src].items():
                if cost != float("inf") and dist[dest] > dist[src] + cost:
                    dist[dest] = dist[src] + cost
                    heapq.heappush(heap_q, (dist[dest], dest))
                    prev[dest] = src
                if dist[dest] == dist[src] + cost:
                    route_count[dest] += route_count[src]
 
        if self.goal_point is not None:
            return self._get_path(self.goal_point, prev)
        else:
            return dist, route_count
 
    def _get_path(self, goal, prev):
        path = [goal]
        dest = goal
 
        while prev[dest] != float("inf"):
            path.append(prev[dest])
            dest = prev[dest]
 
        return list(reversed(path))

        
def main(): 
    s = input()
    sl = [i for i in s]
    n = len(s)-1
    ans = []
    sublist = [-1]*n
    anslist = []
    for i in range(1 << n):
        for j in range(n):
            if (i >> j)&1:
                sublist[j] = "+"
        anslist.append(sl[0])
        for j in range(n):
            if sublist[j] == "+":
                anslist.append("+")
                anslist.append(sl[j+1])
            else:
                anslist.append(sl[j+1])
        ans.append(eval("".join(anslist)))
        anslist = []
        sublist = [-1]*n

    print(sum(ans))
if __name__ == "__main__":
    main()

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

ans = 0
for i in range(2 ** (len(S) - 1)):
    bit = format(i,  '0' + str(len(S) - 1) + 'b')
    formula = str("")
    
    for j in range(len(S) - 1):
        formula = formula + (S[j] + "+" * int(bit[j]))
    
    formula = formula + S[-1]
    
    ans += eval(formula)

print(ans)

Solution (Python):
s = list(input())
n = len(s)
total = 0
for i in range(2 ** (n-1)):
    bag = []
    for j in range(n):
        if ((i >> j) & 1):
            bag.append(s[j])
            bag.append('+')
        else:
            bag.append(s[j])
        
    bag = ''.join(bag)
    
    for m in bag.split('+'):
        total += int(m)
print(total)

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

for bit in range(1 << len(s)-1):
  lis = s[0]
  for i in range(len(s)-1):
    if ((bit>>i) & 1):
      lis += "+"
    lis += s[i+1]
  total += sum(map(int, lis.split("+")))

print(total)

Solution (Python):
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue


Mod = 1000000007
import sys

sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): 
    s = input()
    sl = [i for i in s]
    n = len(s)-1
    sublist = [-1]*n
    anslist = []
    ans = []
    for i in range(1<<n):
        for j in range(n):
            if (i>>j)&1:
                sublist[j] = "+"
        anslist.append(sl[0])
        for j in range(n):
            if sublist[j] == "+":
                anslist.append(sublist[j])
                anslist.append(sl[j+1])
            else:
                anslist.append(sl[j+1])
        ans.append(eval("".join(anslist)))
        anslist = []
        sublist = [-1]*n
    print(sum(ans))
if __name__ == "__main__":
    main()

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

Solution (Python):
S = list(input())
listbit = []
lenplus = len(S)-1
for i in range(2**lenplus):
    suuji = ''
    for j in range(len(S)):
        suuji += S[j]
        if (i >> j & 1):
            suuji += '+'
    listbit.append(suuji)

ans = 0
for i in listbit:
    ans += eval(i)
print(ans)

Solution (Python):
from itertools import zip_longest as Zip
s=input()
l=len(s)-1
ans=0
for i in range(2**l):
  d=s
  ans+=eval("".join([x+y for x,y in Zip(d,format(i,"b").zfill(l).replace("0","
print(ans)

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

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

Solution (Python):
def main(s):
    sumval = 0
    
    for i in range(2 ** (len(s) - 1)):
        
        t = ""
        for j in range(len(s)):
            t += s[j]
            if (i >> j) & 1:
                t += "+"
        lst = list(map(int, t.split("+")))
        sumval += sum(lst)
    return sumval

s = input()
print(main(s))

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

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

Solution (Python):
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue


Mod = 1000000007
import sys

sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): 
    s = input()
    sl = [i for i in s]
    n = len(s)-1
    sublist = [-1]*n
    anslist = []
    ans = []
    for i in range(1<<n):
        for j in range(n):
            if (i>>j)&1:
                sublist[j] = "+"
        anslist.append(sl[0])
        for j in range(n):
            if sublist[j] == "+":
                anslist.append(sublist[j])
                anslist.append(sl[j+1])
            else:
                anslist.append(sl[j+1])
        ans.append(eval("".join(anslist)))
        anslist = []
        sublist = [-1]*n
    print(sum(ans))
if __name__ == "__main__":
    main()

Solution (Python):

S=str(input())
n=len(S)-1
answer=0
for i in range(2**(n)):
  formula=S[0]
  for j in range(n):
    if ((i>>j)&1):
      formula+="+"
    formula+=S[j+1]
  answer+=sum(map(int,formula.split("+")))
print(answer)

Solution (Python):
s = input()
s_len = len(s)
s_ary = list(s)


sowa = 0

for i in range(2**(s_len-1)):
    x="{:0" + str(s_len-1) + "b}"
    keisan = list(str(x.format(i)))
    
    zentai = 0
    flag = 0
    for j in range(s_len-1):
        
        zentai += int(s_ary[s_len-1-j])*10**flag
        if(keisan[j]=="0"):
            flag = 0
        else:
            flag += 1
    
    
    zentai += int(s_ary[0])*10**flag
    sowa += zentai

print(sowa)

Solution (Python):
s=list(input())
n=len(s)
if n == 1:
    print(int(s[0]))
else:    
    n2 = 2**(n-1)
    
    n3 = (n-1)*-1
    
    ans=0
    for i in range(n2):
        li = list(format(i,'010b'))
        li = li[n3:]
        
        tmpstr=s[0]
        tmpnum=0
        index = 0
        for j in li:
            
            if j == '0':
                
                tmpstr=tmpstr+s[index+1]
            else:
                
                if tmpstr =="":
                    tmpnum=0
                else:
                    tmpnum=int(tmpstr)
                    tmpstr=s[index+1]
                    ans=ans+tmpnum
            index += 1
        if tmpstr != "":
            
            tmpnum=int(tmpstr)
            ans=ans+tmpnum
    print(ans)

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

ans=0

for b in range(1<<(n-1)):
  f=s[0]
  for i in range(n-1):
    if b&(1<<i):
      f+='+'
    f+=s[i+1]
  ans+=sum(map(int,f.split('+')))
print(ans)

Solution (Python):
from itertools import zip_longest as Zip
s=input()
ans=0
g=len(s)
for i in range(2**(g-1)):
  d=s
  k=bin(i)[2:]
  k="0"*(g-len(k)-1)+k+"0"
  ans+=eval("".join([d[j]+ ("+" if k[j]=="1" else "") for j in range(g)]))
print(ans)

Solution (Python):
import sys
stdin = sys.stdin
from itertools import product

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

s = ns()
n = len(s) - 1

ans = 0
for plus in product([0,1], repeat=n):
    num = []
    a = s[0]
    for i, flag in enumerate(plus):
        if flag == 0:
            a = a + s[i+1]
        else:
            num.append(a)
            a = s[i+1]
    num.append(a)
    ans += sum(map(int, num))
print(ans)

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

Solution (Python):
def calc(S,n):
    if n==len(S):
        return eval(S)
    return calc(S,n+1)+calc(S[:n]+"+"+S[n:],n+2)

def main():
    S=input()
    print(calc(S,1))

main()

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

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

answer = 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]

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

print(answer)

Solution (Python):
from itertools import product
n = list(input())
L = (1,0)
ss = ""
li = []
for v in product(L,repeat =len(n)-1):
    v = list(v)+[0]
    for i in range(len(n)):
        ss += str(n[i])
        
        if v[i] == 1:
            ss += "+"
    li.append(eval(ss))
    ss = ""
print(sum(li))

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

def part_sum(cur, i, res):
    if i < n-1:
        part_sum(cur+s[i], i+1, res)
        part_sum(cur+s[i]+"+", i+1, res)
    else:
        cur += s[i]
        res.append(sum(list(map(int, cur.split("+")))) )
    return res
  
res = part_sum("", 0, [])
print(sum(res))

Solution (Python):
S = input()

total = 0
n = len(S)
ans = 0

for i in range(2**(n-1)):
    form = S
    bit = []
    for _ in range(n-1):
        bit.append(i%2)
        i =  i // 2
    eq = ""
    for i, b in enumerate(bit):
        eq += (form[i])
        if b == 1:
            eq += ('+')
    eq += form[-1]

    ans += eval(eq)

print(ans)

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

def func(ac,yet,sum):
  next = int(yet[0])
  
  
  if len(yet) ==1:
    cand.append(sum+ ac+ next)
    cand.append(sum+ ac*10+ next)
  else:
    func(next, yet[1:],ac+sum)
    func(ac*10+next, yet[1:],sum)

func(0,s,0)
print(sum(cand)//2)

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

for i in range(2**(n-1)):
  form = s
  bit = []
  for _ in range(n-1):
    bit.append(i%2)
    i =  i//2

  for j in range(n-1):
    if bit[j]:
      form = form[:n-j-1] + '+' + form[n-j-1:]

    
  ans += eval(form)
print(ans)

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

plus = []
for i in range(2**(n-1)):
    tmp = [""] * n
    for j in range(n-1):
        if i >> j & 1:
            tmp[j] = "+"
    plus.append(tmp)

ans = 0
for p in plus:
    s = ""
    for i in range(n):
        s = s + S[i] + p[i]
    ans += eval(s)
print(ans)

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

def part_sum(cur, i, res):
    if i < n-1:
        part_sum(cur+s[i], i+1, res)
        part_sum(cur+s[i]+"+", i+1, res)
    else:
        cur += s[i]
        res.append(sum(list(map(int, cur.split("+")))) )
    return res
  
res = part_sum("", 0, [])
print(sum(res))

Solution (Python):
def dfs(arr: list, index: int, length: int, S: str) -> int :

    if index == length-1:
        return cal(arr, S)

    index += 1
    return dfs(arr+[index], index, length, S) + dfs(arr, index, length, S)


def cal(arr: list, S: str) -> int :
    s = 0
    tmp = arr[0]

    for a in arr[1:]:
        s += int(S[tmp:a])
        tmp = a
    s += int(S[arr[-1]:])
    
    

    return s

S = input()

arr = [0]
ans = dfs(arr, 0, len(S), S)

print(ans)

Solution (Python):
def manyformula(S):
    T=int(S)
    if len(S)==1:
        return int(S)
    else:
        m=0
        for i in range(1,len(S)):
            a=T%(10**i)
            b=T//(10**i)
            m=m+b*(2**(len(str(a))-1))+manyformula(str(a))
        return T+m

S=input()
print(manyformula(S))

Solution (Python):
s = input()
n = 0
for i in range(2**(len(s)-1)):
    b = list("{0:010b}".format(i))
    b.reverse()
    
    index = 0
    for j in range(len(s)):
        if b[j] == "1":
            n += int(s[index:j+1])
            index = j+1
    if index != j+1:
        n += int(s[index:j+1])
    
print(n)