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



Sample input:
125


Sample output:
176

Submission status: Accepted

Solution code:
import copy

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

if l==1:
  ans+=int(s)
  print(ans)
  
else:
  for i in range(2**(l-1)):
    t=copy.deepcopy(s)
    f=[]
    ch=0
    for j in range(l-1):
      if ((i>>j)&1):
        t=t[:j+1+ch]+'+'+t[j+1+ch:]
        ch+=1
     
    if '+' in t:
      
      y=list(map(int,t.split('+')))
      for u in y:
        ans+=u
    else:
      ans+=int(t)
      
  print(ans)

Submission status: Accepted

Solution code:
S = input()

n = len(S)

def dfs(i,f):
    if i == n-1:
        return sum(list(map(int, f.split("+"))))

    return dfs(i+1, f+S[i+1]) + dfs(i+1, f+"+"+S[i+1])
print(dfs(0, S[0]))

Submission status: Accepted

Solution code:
S = input()

n = len(S)

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

Submission status: Accepted

Solution code:
s = input()

total = 0

for i in range(len(s)):
  for j in range(len(s) - i):
    n = int(s[j:j+i+1])
    if j == 0 or j == len(s) - i - 1:
      total += n * max([(2 ** (len(s) - i - 2)), 1])
    else:
      total += n * max([(2 ** (len(s) - i - 3)), 1])
      
print(total)

Submission status: Accepted

Solution code:
from itertools import product
s = input()
n = len(s)
if n == 1:
    print(int(s))
    exit()

plus_list = list(product([0, 1], repeat=n-1))
ans = 0
for plus in plus_list:
    next = 0
    for i in range(n-1):
        if plus[i] == 1:
            temp = s[next:i+1]
            #print(temp)
            ans += int(temp)
            next = i+1
        if i == n-2:
            temp = int(s[next:])
            #print(temp)
            ans += temp
print(ans)

Submission status: Accepted

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

from itertools import product

ans = 0
# 後ろから切っていく
for i in product([0, 1], repeat=n-1):
    ss = s
    num = 0
    for j in range(n-1):
        if i[j] == 1:
            num += int(ss[n-j-1:])
            ss = ss[:n-j-1]
    num += int(ss)
    ans += num

print(ans)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    s = input()
    ans = 0
    for i in range(2 ** (len(s) - 1)):
        num = s[0]
        for j in range(len(s) - 1):
            if (i >> j) & 1:
                ans += int(num)
                num = ""
            num += s[j + 1]
        if len(num) != 0:
            ans += int(num)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# @oj: atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-08-14 15:33
# @url:https://atcoder.jp/contests/abc045/tasks/arc061_a
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *
# region fastio

BUFSIZE = 8192

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------
def main():
    s=str(input())
    d=[int(x) for x in s[::-1]]
    cnt=[2**(len(s)-1)]
    ans=0
    for i in range(len(d)):
        if i!=0:
            cnt[-1]=cnt[-1]//2
            cnt.append(cnt[-1])
        for j in range(len(cnt)):
            ans+=d[i]*(10**j)*(cnt[j])
    print (ans)
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
l = len(s)
ans = 0
for i in range(2 ** (l-1)):
    tmp = ''
    sum = 0
    for j in range(l-1):
        tmp += s[j]
        if i >> j & 1:
            sum += int(tmp)
            tmp = ''
    sum += int(tmp + s[-1])

    ans += sum
print(ans)

Submission status: Accepted

Solution code:
import copy

s=list(input())
a=[]
for i in range(len(s)):
    a.append(s[i])
    if i !=len(s)-1:
        a.append("")

ans=0

for i in range(2**(len(s)-1)):
    l=copy.deepcopy(a)
    for j in range(len(s)-1):
        if (i>>j&1):
            l[2*j+1]="+"
    ans+=eval("".join(l))

print(ans)

Submission status: Accepted

Solution code:
S = input()
n = len(S)-1
result = 0
for i in range(2 ** n):
    sum = 0
    temp = ''
    for j in range(n):
        temp += S[j]
        if (i >> j) & 1:
            sum += int(temp)
            temp = ''
    sum += int(temp+S[-1])
    result += sum
print(result)

Submission status: Accepted

Solution code:
def dfs(i, f):
    if i == n - 1:
        return sum(list(map(int, f.split('+'))))

    return dfs(i + 1, f + a[i + 1]) + dfs(i + 1, f + '+' + a[i + 1])


a = input()
n = len(a)

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

Submission status: Accepted

Solution code:
s = input()
all_s = []
def ss(index, perm):
    if index == len(s):
        all_s.append(perm)
    else:
        perm1 = [i for i in perm]
        perm1[-1] += s[index]
        ss(index+1, perm1)

        perm2 = [i for i in perm]
        perm2.append(s[index])
        ss(index+1, perm2)

ss(1, [s[0]])
all_sum = 0
for way in all_s:
    tmp = 0
    for n in way:
        tmp += int(n)
    all_sum += tmp
print(all_sum)

Submission status: Accepted

Solution code:
a = input()

n = len(a)
ans = 0
for i in range(2**(n-1)):
    f = a[0]
    for j in range(n-1):
        if ((i >> j) & 1):
            f += '+'
        f += a[j+1]

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

print(ans)

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

Solution code:
from itertools import product

S=input()
N=len(S)
S2=S[0]
for i in range(N-1):
  S2 += '{}'+S[i+1]

ans=0
for p in product(['','+'],repeat=N-1):
  ans += eval(S2.format(*p))
  
print(ans)

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

Solution code:
s = input()
L = []
sigma = 0
def sprit_sum(string, sprit, num):
    global sigma
    for i in range(1,len(string)+num-sprit):
        str_front = string[:i]
        str_back = string[i:]
        L.append(int(str_front)) 
        if num < sprit:
            sprit_sum(str_back, sprit, num+1)
        else:
            L.append(int(str_back))
            for x in L:
                sigma += x
            L.pop()
        L.pop()
        
for j in range(len(s)):
    sprit_sum(s, j+1, 1)
sigma += int(s)
print(sigma)

Submission status: Accepted

Solution code:
s = input()
s_sum = []
for i in range(2**(len(s)-1)):
    sj = 0
    a = 0
    for j in range(len(s)-1):
        if ((i>>j) & 1):
            a += int(s[sj:j+1])
            sj = j+1
    a += int(s[sj:])
    s_sum.append(a)
print(sum(s_sum))

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())


def main():
    s= input()
    n = len(s)
    ans = 0
    for i in range(1<<(n-1)):
        idx = [0]
        for j in range(n-1):
            if (i>>j)&1:
                idx.append(j+1)
        idx.append(n)
        for j in range(1, len(idx)):
            ans += int(s[idx[j-1]:idx[j]])
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
S=len(s)
ans = ''
for i in range(2**(S-1)):
    ans+=s[0]
    for j in range(0,S-1):
        if i>>j&1:
            ans+=""+s[j+1]
        else:
            ans+=" "+s[j+1]
    ans+=" "
 

print(sum(map(int,ans.split())))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
import copy
import heapq
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD

def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD

def fact_and_inv(SIZE):
    inv = [0] * SIZE  # inv[j] = j^{-1} mod MOD
    fac = [0] * SIZE  # fac[j] = j! mod MOD
    finv = [0] * SIZE  # finv[j] = (j!)^{-1} mod MOD
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv

def renritsu(A, Y):
    # example 2x + y = 3, x + 3y = 4
    # A = [[2,1], [1,3]])
    # Y = [[3],[4]] または [3,4]
    A = np.matrix(A)
    Y = np.matrix(Y)
    Y = np.reshape(Y, (-1, 1))
    X = np.linalg.solve(A, Y)

    # [1.0, 1.0]
    return X.flatten().tolist()[0]

class TwoDimGrid:
    # 2次元座標 -> 1次元
    def __init__(self, h, w, wall="#"):
        self.h = h
        self.w = w
        self.size = (h+2) * (w+2)
        self.wall = wall
        self.get_grid()
        # self.init_cost()

    def get_grid(self):
        grid = [self.wall * (self.w + 2)]
        for i in range(self.h):
            grid.append(self.wall + getS() + self.wall)

        grid.append(self.wall * (self.w + 2))
        self.grid = grid
    def init_cost(self):
        self.cost = [INF] * self.size

    def pos(self, x, y):
        # 壁も含めて0-indexed 元々の座標だけ考えると1-indexed
        return y * (self.w + 2) + x
    def getgrid(self, x, y):
        return self.grid[y][x]
    def get(self, x, y):
        return self.cost[self.pos(x, y)]
    def set(self, x, y, v):
        self.cost[self.pos(x, y)] = v
        return
    def show(self):
        for i in range(self.h+2):
            print(self.cost[(self.w + 2) * i:(self.w + 2) * (i+1)])
    def showsome(self, tgt):
        for t in tgt:
            print(t)
        return
    def showsomejoin(self, tgt):
        for t in tgt:
            print("".join(t))
        return

    def search(self):
        grid = self.grid
        move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
        move_eight = [(0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
        # for i in range(1, self.h+1):
        #     for j in range(1, self.w+1):
        #         cx, cy = j, i
        #         for dx, dy in move_eight:
        #             nx, ny = dx + cx, dy + cy


def dfs(S):
    ret = int(S)
    for i in range(len(S)-1):
        ls = S[:i+1]
        rs = S[i+1:]
        ret += dfs(rs)
        ret += int(ls) * 2 ** (len(rs) - 1)

    return ret

def solve():
    print(dfs(getS()))
def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()

Submission status: Accepted

Solution code:
from functools import reduce

def original_sum(X, init):
    goukei = 0
    if(len(X) == 0):
        #print("aaa")
        #print(sum(init))
        return sum(init)
    else:
        for i in range(len(X)):
            lstm = init.copy()
            #print(len(X))
            num = int(reduce(lambda x, y: x + y, [str(x) for x in X[0:i+1]]))
            #print(num)
            #init = num
            lstm.append(num)
            Y = X[i+1:len(X)].copy()
            #print(len(Y))
            #if(len(X)-i-1 != 0):
            goukei = goukei + original_sum(Y, lstm)
            #else:
                #sum = sum + (len(X)-i-1)num + original_sum(Y)
            #print(sum)

    return goukei


number = list(input())
init = []
print(original_sum(number, init))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = input()
ans = ''
for i in range(1 << (len(s) - 1)):
    ans += s[0]
    for j in range(len(s) - 1):
      if i >> j & 1:
        ans += ' '
      ans += s[j+1]
    ans += ' '
print(sum(map(int, ans.split())))

Submission status: Accepted

Solution code:
s = input()

ans = 0

for i in range(1<<(len(s)-1)):
    t = list(s)
    for b in range(len(s)-1):
        if((i>>b)&1):
            t[b] = t[b] + '+'
    ans += eval(''.join(t))
print(ans)

Submission status: Accepted

Solution code:
def dfs(i, f):
    if i == n-1: #もし枝が最後のけたに到達したら、という条件式
        return sum (list(map(int, f.split('+'))))
    
    #式fの末尾に'+'を追加する/追加しないをして次の数字を追加
    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]))

Submission status: Accepted

Solution code:
N = str(int(input()))
total = 0
l = len(N)-1
if l == 0:
    print(N)
else:
    for i in range(2**l):
        b = format(i, '0'+str(l)+'b')
        subtotal = 0
        s = N[0]
        for j in range(len(b)):
            if int(b[j]):
                subtotal += int(s)
                s = N[j+1]
            else:
                s += N[j+1]

        subtotal += int(s)
        total += subtotal

    print(total)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

s=SI()
ans=0
for b in range(1<<(len(s)-1)):
    f=""
    for i,c in enumerate(s):
        f+=c
        if b>>i&1:f+="+"
    ans+=eval(f)
print(ans)

Submission status: Accepted

Solution code:
s = input()

n = len(s)-1
ans = 0
for i in range(2**n):
  t = s[0]
  for j in range(n):
    if i >> j & 1: t += "+" # 該当する場合のみ"+"を追加する
    t += s[j+1] # 次の文字を追加
  ans += eval(t) # 生成した文字列を計算
print(ans)

Submission status: Accepted

Solution code:
import itertools


def f(A):
    A = A[::-1]
    ret = 0
    for c, a in enumerate(A):
        ret += int(a) * 10 ** int(c)

    return ret


S = input()
ans = f(S)

# +の数
for n in range(1, len(S)):
    for k in itertools.combinations(range(1, len(S)), r=n):
        st = 0
        q = 0
        for i in k:
            q += f(S[st:i])
            st = i
        q += f(S[st:])
        ans += q

print(ans)

Submission status: Accepted

Solution code:
s = str(input())

result = 0


for i in  range(2**(len(s)-1)):
    b = []
    x = 0#範囲を覚えておく
    for j in range(len(s)-1):
        if ((i >> j) & 1):
            b.append(s[x:j+1])
            x = j+1
    b.append(s[x:len(s)])
    for k in b:
        result += int(k)
            
print(result)

Submission status: Accepted

Solution code:
import itertools

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

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

Submission status: Accepted

Solution code:
from itertools import product

S=input()
tf_li=list(product([True,False],repeat=len(S)-1))
ans=0
for x in tf_li:
  formula=S[0]
  for i in range(len(S)-1):
    if x[i]==False:
      formula+="+"
    formula+=S[i+1]
  ans+=eval(formula)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
#  +のかず 0 - len(S) - 1

r = 0

s = len(S) - 1

for i in range(2 ** s):
    bit = []
    for j in range(s):
        if (i >> j) & 1:
            bit.append(j+1)

    for o in range(len(bit)):
        if o == 0:
            r += int(S[0: bit[o]])
        else:
            r += int(S[bit[o - 1] : bit[o]])
            
    if len(bit) == 0:
        r += int(S)
    else:
        r += int(S[bit[-1] :])
        
print(r)

Submission status: Accepted

Solution code:
s = input()

res = 0
for i in range(2**(len(s)-1)):
    pos = 0
    for j in range(len(s)-1):
        if (i >> j) & 1:
            res += int(s[pos:j+1])
            pos = j + 1
    res += int(s[pos:])

print(res)

Submission status: Accepted

Solution code:
def rek(erg, rest):
    if not rest:
        return erg
 
    p = []
 
    for i in erg:
        p.append(i+"+"+rest[0])
        p.append(i+rest[0])
 
    return rek(p, rest[1:])
 
 
a = input()
 
erg = 0
comb = rek([a[0]], a[1:])
 
for i in comb:
    erg += eval(i)
 
print(erg)

Submission status: Accepted

Solution code:
from itertools import product
S = input()
A = ("+", "")
print(sum(eval("".join([s+i for s, i in zip(S, I)]+[S[-1]]))\
         for I in product(A, repeat=len(S)-1)))

Submission status: Accepted

Solution code:
s = str(input())
n = len(s)
#print(s,n)
ans = 0
for bit in range(1 << (n-1)):
    f = s[0]
    for j in range(n-1):
        if bit & (1 << j):
            f += '+'
        f += s[j+1]
    ans += sum(map(int,f.split('+')))
#    print(f)
print(ans)

Submission status: Accepted

Solution code:
s = input()

res = 0
for i in range(2**(len(s)-1)):
    pos = 0
    for j in range(len(s)-1):
        if (i >> j) & 1:
            res += int(s[pos:j+1])
            pos = j + 1
    res += int(s[pos:])

print(res)

Submission status: Accepted

Solution code:
#coding: utf-8

S = input()

N = len(S)-1

def calc(S, bit):
    retval = 0
    l = 0
    for i in range(N):
        if ((bit >> i) & 1):
            retval += int(S[l:i+1])
            l = i+1
    retval += int(S[l:])
    return retval 

ret = 0
for i in range(2 ** N):
    ret += calc(S, i)

print(ret)

Submission status: Accepted

Solution code:
import itertools

S = input()


def calculate(s):
    arr = list(s)

    totalLength = len(s)

    spliteIndexes = [i for i in range(1,totalLength)]

    result = 0
    for i in range(1, totalLength):
        for item in itertools.combinations(spliteIndexes, i):
            ttr = [0]
            ttr.extend(list(item))
            ttr.append(totalLength)


            for i in range(len(ttr) - 1):
                result += int("".join(arr[ttr[i]:ttr[i+1]]))
    print(result + int(s))


calculate(S)

Submission status: Accepted

Solution code:
s = input()
l = len(s)
ans = 0
for i in range(l):
  a = max(0,i-1)
  ans += sum([int(s[i:j])*(1<<a)*(1<<max(0,l-j-1)) for j in range(i+1,l+1)])
print(ans)

Submission status: Accepted

Solution code:
s = input()
l = len(s)
def dfs(n):
  if n == l:
    return [0]
  ret = []
  for i in range(n+1,l+1):
    ret += [int(s[n:i])+j for j in dfs(i)]
  return ret
print(sum(dfs(0)))

Submission status: Accepted

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

s = input()
ans = 0
for x in product(["","+"], repeat = len(s) - 1):
    tmp = ""
    for i in range(len(s)-1):
        tmp += s[i] + x[i]
    tmp += s[-1]
    ans += eval(tmp)
print(ans)

Submission status: Accepted

Solution code:
s = list(input())
digits = len(s)
lists = []
answer = 0

for bit in range(2 ** (digits - 1)):
    formula = s[0]
    for i in range(digits - 1):
        if ((bit >> i) & 1):
            formula += "+"
        formula += s[i + 1]
    lists.append(formula)

for i in range(len(lists)):
    answer += eval(lists[i])
print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from scipy.special import comb
import numpy as np
def get_keta_plusnum(n,m):
    if n<=m:
        print("error")
    else:
        hit_num=[0 for i in range(n)]
        for keta in range(1,n-m+1):
            for j in range(n+1-keta):
                if j!=n-keta:
                    hit_num[j]+=10**(keta-1)*comb(n-1-keta,m-1)
                else:
                    hit_num[j]+=10**(keta-1)*comb(n-keta,m)
    return np.array(hit_num,dtype="int64")

s=input()
n=len(s)

hit_num=np.array([0 for i in range(n)])

for m in range(n):
    hit_num+=get_keta_plusnum(n,m)
s=np.array([int(i) for i in s])
print(np.dot(hit_num,s))

Submission status: Accepted

Solution code:
S=input()
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]
    ans+=eval(tmp)
print(ans)

Submission status: Accepted

Solution code:
import itertools
import bisect
S=input()
T = []
M = int(S)
for i in S:
    T.append(int(i))
    T.append(0)
T.pop()
s = len(S)
for i in range(1,s):
    a = itertools.combinations(list(range(1,2*s-1,2)),i)
    for j in a:
        U = ""
        for k in range(2*s-1):
            if k in j:
                U += "+"
            else:
                U += str(T[k])
        U = U.replace("0","")
        M += eval(U)
print(M)

Submission status: Accepted

Solution code:
s = str(input())
n = len(s)
k = 0
ls =[]
for i in range(2**(n-1)):
    a = []
    for j in range(n-1):
        if (i >> j)&1:
            a.append(j)
    ls.append(a)
for p in range(len(ls)):
    l = list(s)
    for q in ls[p][::-1]:
        l = l[:q+1] + ["+"] + l[q+1:]
    b = eval("".join(l))
    k += b
print(k)

Submission status: Accepted

Solution code:
S = list(input())
N = len(S)
for i in range(N):
    S[i] = ord(S[i]) - ord('0')

S.append(0)

ans = 0
for i in range(1<<(N-1)):
    prev = 0
    for k in range(N):
        prev = prev * 10 + S[k]
        if (i & (1<<k)) > 0:
            ans += prev
            prev = 0
    ans += prev
print(ans)

Submission status: Accepted

Solution code:
S=input()
L=len(S)-1

from itertools import product

def divid_S(p):
    S_=[]
    p_s=0
    p_e=0

    for p_idx in range(len(p)):
        if p[p_idx] == 1:
            p_e = p_idx+1
            S_.append(S[p_s:p_e])
            p_s = p_idx+1

    S_.append(S[p_e:])
    
    return S_

def get_one_ans(S_):
    ans=0
    for s_ in S_:
        ans+=int(s_)
        
    return ans

ans = 0
for p in product(range(2),repeat=L):
    S_=divid_S(p)
    ans += get_one_ans(S_)
    
print(ans)

Submission status: Accepted

Solution code:
def f(s):
    if len(s)==1:
        return [s]
    l=[]
    for i in f(s[1:]):
        l.append(s[0]+"+"+i)
        l.append(s[0]+i)
    return l
print(sum(map(eval,f(input()))))

Submission status: Accepted

Solution code:
import copy
s=input()
def dfs(i,f,last):
    ans=0
    if i==len(s):
        for j in range(len(s)):
            ans+=int(f[j])
        return ans
    else:
        f1=copy.deepcopy(f)
        f2=copy.deepcopy(f)
        f1[last]+=s[i]
        ans+=dfs(i+1,f1,last)
        f2[last+1]+=s[i]
        ans+=dfs(i+1,f2,last+1)
        return ans
f=["0"]*len(s)
f[0]+=s[0]
print(dfs(1,f,0))

Submission status: Accepted

Solution code:
def Base_10_to_n(X, n):#10進数をbit_base進数に変換
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

def main():
  s = str(input())
  ans = 0
  for i in range(2**(len(s)-1)):
    bits = Base_10_to_n(i, 2)
    bits = bits.zfill(len(s)-1)
    now = 0
    for j, bit in enumerate(bits):
      if bit == '1':
        ans += int(s[now:j+1])
        now = j + 1
      if j == len(s)-2:
        ans += int(s[now:])
  if ans == 0:
    ans += int(s)
  print(ans)
  
if __name__ == "__main__":
  main()

Submission status: Accepted

Solution code:
from itertools import product
s = input()

def tolist(sign):
    # len(sign) == len(s)-1とする
    ans = [int(s[0])]
    for i in range(len(sign)):
        if sign[i]: # Trueの時+とする
            ans.append(int(s[i+1]))
        else:
            prev = ans.pop()
            ans.append(int(str(prev)+s[i+1]))
    return ans

ans = 0
for sign in product([True, False], repeat=len(s)-1):
    ans+=sum(tolist(sign))
print(ans)

Submission status: Accepted

Solution code:
s = input()
ans = 0
n = len(s)
m = n-1
t= s
for mask in range(0 , (1<<(n))):
	res=0
	cur=0
	for j in range(0 , n):
		if mask&(1<<j):
			res = res+cur
			cur = (ord(t[j])-ord('0'))
		else:
			cur = cur*10+(ord(t[j])-ord('0'))
	#print(res+cur)
	ans = ans+res+cur
print(ans//2)

Submission status: Accepted

Solution code:
S = input()

sum = 0

for n in range(1<<(len(S)-1)): #全通り
  i_before = 0
  for i in range(len(S)-1): #各桁
    if n & (1<<i): #bitチェック
      sum += int(S[i_before:i+1])
      i_before = i+1
  sum += int(S[i_before:]) #最後の桁

print(sum)

Submission status: Accepted

Solution code:
S=input()
L=len(S)

from itertools import product

P=product(range(2),repeat=L-1)

ans=0
for p in P:
    s=0
    temp=S[0]
    for i in range(L-1):
        if p[i]==1:
            s+=int(temp)
            temp=S[i+1]
        else:
            temp+=S[i+1]
    s+=int(temp)
    ans+=s
print(ans)

Submission status: Accepted

Solution code:
S = input()
n = len(S)
ans = 0
for i in range(2**(n-1)):
    B = bin(i)[2:].zfill(n)
    t = 0
    for j in range(n):
        if B[j]=='0':
            t = t*10+int(S[j])
        else:
            ans += t
            t = int(S[j])
    ans += t
print(ans)

Submission status: Accepted

Solution code:
#import time

def main():
    S = input()
    N = len(S) -1
    #print(S[2:3])
    ans = 0
    for i in range(1<<N):
        su = [0, N+1]
        for j in range(N):
            if i & (1<<j) == 0: continue
            su.append(j+1)
            su.sort()
            #print(su)
        for k in range(len(su)-1):
            ans += int(S[su[k]:su[k+1]])
    
    return ans

if __name__ == '__main__':
    #start = time.time()
    print(main())
    #elapsed_time = time.time() - start
    #print("経過時間:{}".format(elapsed_time * 1000) + "[msec]")

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

S = input()
leng = len(S)-1
ans = 0
for i in range(1<<leng):
    lis = []
    start = 0
    for j in range(leng):
        if (i>>j)&1:
            lis.append(int(S[start:j+1]))
            start = j+1
    if start!=leng+1: lis.append(int(S[start:]))
    ans += sum(lis)
print(ans)

Submission status: Accepted

Solution code:
N = str(input())
length = len(N)
#temp = list(N)
ans = 0
for i in range(2**(length-1)):
  temp = ""
  for j in range(length-1):
    if (i>>j)&1 == 1:
      temp += N[j]+"+"
    else:
      temp += N[j]
  temp += N[-1]
  kotae = eval(temp)
  ans += kotae
print(ans)

Submission status: Accepted

Solution code:
from itertools import product
S = input().strip()
N = len(S)
cnt = 0
for x in product((0,1),repeat=N-1):
    y = ""
    for i in range(N-1):
        y += S[i]
        if x[i]==1:
            y += "+"
    y += S[N-1]
    cnt += eval(y)
print(cnt)

Submission status: Accepted

Solution code:
def base10toN(num, base):
    converted_string, modstring = "", ""
    currentnum = num
    if not num:
        return '0'
    while currentnum:
        mod = currentnum % base
        currentnum = currentnum // base
        converted_string = chr(48 + mod + 7*(mod > 10)) + converted_string
    return converted_string
s=input()
n=len(s)
ans=0
for i in range(2**(n-1)):
  t=base10toN(i,2)
  r=[]
  for j in range(n-1-len(t)):
    r.append('0')
  for j in range(len(t)):
    r.append(t[j])
  k=[]
  k.append(s[0])
  for j in range(n-1):
    if r[j]=='0':
      k.append(s[j+1])
    else:
      ans+=int(''.join(k))
      k=[]
      k.append(s[j+1])
  ans+=int(''.join(k))
print(ans)