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:
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())

    def calc_sep_add(s, pattern):
        n = len(s)
        pattern = [True] + pattern + [True]
        ans = 0
        i = 0
        for j in range(1, n+1):
            if pattern[j]:
                ans += int(s[i:j])
                i = j
        return ans
    
    s = input()
    n = len(s)
    ans = 0
    if n == 1:
        print(int(s))
    else:
        for pattern in product([True, False], repeat=n-1):
            # print(pattern)
            # print(calc_sep_add(s, list(pattern)))
            ans += calc_sep_add(s, list(pattern))
        print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
import itertools

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    # 1234
    #a,b,c=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    #n=int(readline())
    ss=readline().rstrip()
    p=len(ss)-1
    loops=[[0,1] for i in range(p)]
    ans=0
    for one in itertools.product(*loops):
        bef=-1
        for i in range(len(one)):
            if one[i]==1:
                ans+=int(ss[bef+1:i+1])
                bef=i
        ans+=int(ss[bef+1:])
    print(ans)
    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

Submission status: Accepted

Solution code:
def dfs(string, k):
  ans = 0
  if k == len(s):
    ans += sum(list(map(int, string.split('+'))))
  else:
    ans += dfs(string + s[k], k+1)
    if k != 0 and string[-1] != '+':
      ans += dfs(string + '+', k)
  return ans

s = input()
print(dfs("", 0))

Submission status: Accepted

Solution code:
S = list(input())
N = len(S)
ans = 0

for i in range(2 ** (N - 1)):#n=1234なら，iは000, 001, 010, 011, 100, 101, 110, 111
    s = S[:]
    for j in range(N):
        if i & 2**j:#AND論理積,jは000, 001, 010, 100
            s[j] = s[j] + '+'
    #print(''.join(s))
    ans += eval(''.join(s))
print(ans)

Submission status: Accepted

Solution code:
S = input()
cand = [0 for _ in range(2 **(len(S) - 1))]
for i in range(2 ** (len(S) - 1)):
    now = 0
    tmp = []
    for k in range(len(S) - 1):
        if i & (1 << k):
            tmp.append(S[now:k + 1])
            now = k + 1
    tmp.append(S[now:])
    for x in tmp:
        if x == '':
            continue
        else:
            cand[i] += int(x)
print(sum(cand))

Submission status: Accepted

Solution code:
from itertools import product

S=input()
N=len(S)
a=product(["+",""],repeat=N-1)
ans=0

for i,p in enumerate(a):
  bun = S[0]
  for j in range(N-1):
    bun += p[j]+S[j+1]
  nums=bun.split("+")
  tmp=0
  for num in nums:
    tmp+=int(num)
  ans+=tmp
print(ans)

Submission status: Accepted

Solution code:
from itertools import*
s = list(input())
l = len(s)
p = list(chain.from_iterable(zip(s, " "*l)))[:-1]
S = 0
for i in product([0,1], repeat=~-l):
    q = p[:]
    for k, j in enumerate(i):
        if j:
            q[k*2 + 1] = "+"
    S += eval("".join(q).replace(" ", ""))
print(S)

Submission status: Accepted

Solution code:
s = input()

n = len(s)-1
s = int(s)
ans = 0

for i in range(1 << n):
    num = s
    c = 1
    for j in range(n):
        if i >> j & 1:
            ans += num % (10**c)
            num //= (10**c)
            c = 1
        else:
            c += 1
    ans += num

print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**8)
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 li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
import itertools #list(accumulate(A))

S = sys.stdin.readline().rstrip()
S_int = list(map(int, list(S)))
N = len(S)

if N==1:
    print(S)
    exit()

cnt = 0
for l in list(itertools.product([0, 1], repeat=N-1)):
    tmp = S_int[0]
    for i, kigo in enumerate(l):
        if kigo == 1:
            cnt += tmp
            tmp = S_int[i+1]
        else:
            tmp = tmp * 10 + S_int[i+1]
    cnt += tmp

print(cnt)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**8)
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 li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
import itertools #list(accumulate(A))

S = sys.stdin.readline().rstrip()
S_int = list(map(int, list(S)))
N = len(S)
cnt = 0

if N==1:
    print(S)
    exit()

for l in list(itertools.product([0, 1], repeat=N-1)):
    if l[0] == 0:
        tmp = S_int[0]
    else:
        tmp = 0
        cnt += S_int[0]

    for i, kigo in enumerate(l):
        if kigo == 1:
            cnt += tmp
            tmp = S_int[i+1]
        else:
            tmp = tmp * 10 + S_int[i+1]
    cnt += tmp

print(cnt)

Submission status: Accepted

Solution code:
s = input()
n = len(s)
sums = 0
for i in range(2 ** (n - 1)):
    plus = []
    for j in range(n - 1):
        if i & (1 << j):
            plus.append(j)
    numbers = []
    prev = -1
    if len(plus) == 0:
        numbers.append(int(s))
    else:
        for p in plus:
            if prev == -1:
                numbers.append(int(s[:p + 1]))
            else:
                numbers.append(int(s[prev + 1: p + 1]))
            prev = p
        numbers.append(int(s[prev+1:]))
    sums += sum(numbers)
print(sums)

Submission status: Accepted

Solution code:
def main():
    s = input()
    n = len(s)
    ans = 0
    for i in range(n + 1):
        for j in range(i + 1, n + 1):
            x = int(s[i:j])
            p = 2 ** max(0, i - 1)
            q = 2 ** max(0, n - j - 1)
            ans += x * p * q

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    s = str(input())
    n = len(s)
    ans = 0
    for i in range(n + 1):
        for j in range(i + 1, n + 1):
            x = int(s[i:j])
            p = 2 ** max(0, i - 1)
            q = 2 ** max(0, n - j - 1)
            ans += x * p * q

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    s = input()
    n = len(s)
    ans = 0
    for i in range(n + 1):
        for j in range(i + 1, n + 1):
            x = int(s[i:j])
            p = 2 ** max(0, i - 1) * 2 ** max(0, n - j - 1)
            ans += x * p

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()
n = len(S)
def kei(i,f):
    if i == n - 1:
        return sum(list(map(int,f.split("+"))))
    return kei(i+1,f+S[i+1])+\
           kei(i+1,f+"+"+S[i+1])
               
print(kei(0,S[0]))

Submission status: Accepted

Solution code:
s = input()
le = len(s)-1
su = 0

for i in range(2**le):
  moji = s[0]
  for j in range(le):
    if (i>>j)&1:
      moji += '+'
    moji += s[j+1]
  su += eval(moji)
  
print(su)

Submission status: Accepted

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

for i in range(2**(n-1)):
    s_tmp = s
    nbin = str(bin(i))[2:]
    nbin = nbin.zfill(n-1)
    for j in range(len(nbin)-1, -1, -1):
        if nbin[j] == '1':
            s_tmp = s_tmp[:j+1] + '+' + s_tmp[j+1:]

    ans += eval(s_tmp)
print(ans)

Submission status: Accepted

Solution code:
def calc(n):
    if n <= 1:
        return 1
    else:
        return 2 ** (n - 1)


def solution(s):
    n = len(s)
    dp = [None for i in range(len(s))]
    cnt = 0
    for i in range(n):
        a = s[:i]
        b = s[i:]
        cnt += calc(len(a)) * int(b)
        cnt2 = 0
        for j in range(len(a)):
            c = a[:j]
            d = a[j:]
            cnt2 += calc(len(c)) * int(d)
            if len(c) == 1:
                cnt2 += int(c)
            elif len(c) > 1:
                cnt2 += dp[len(c)]
        dp[i] = cnt2
        cnt += dp[i]
    return cnt


print(solution(input()))

Submission status: Accepted

Solution code:
def calc(n):
    if n <= 1:
        return 1
    else:
        return 2 ** (n - 1)


def normailze(s, n):
    return (n - len(s)) * '0' + s


def solution(s):
    a = calc(len(s))
    cnt = 0
    n = len(s)
    if n ==1:
        return int(s)
    for i in range(a):
        binary = normailze(bin(i)[2:], n - 1)
        b = s[0]
        f = 1
        for j in binary:
            if int(j) == 1:
                cnt += int(b)
                b = s[f]
                f += 1
            else:
                b += s[f]
                f += 1
        cnt += int(b)
    return cnt

print(solution(input()))

Submission status: Accepted

Solution code:
import itertools
s=input()
ans=0
L=len(s)
for sta in itertools.product(range(2),repeat=L-1):  
  cut=[-1]+[i for i in range(L-1) if sta[i]]+[L-1]
  for i in range(len(cut)-1):
    ans+=int(s[cut[i]+1:cut[i+1]+1])
print(ans)

Submission status: Accepted

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]

from collections import defaultdict, deque
from sys import exit
import heapq
import math
import copy
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)

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,s = len(s),int(s)

ans=0
for i in range(2**(n-1)):
    num = s
    cut=1
    for j in range(n-1):
        if ((i>>j)&1):
            ans+=num%(10**cut)
            num=num//(10**cut)
            cut=1
        else:
            cut+=1
    ans+=num

print(ans)

Submission status: Accepted

Solution code:
S=str(input())
X=[int(i) for i in S]
n=len(X)-1
sum=0
s=''

for i in range(2**n):
    s=str(X[0])
    for j in range(n):
        if i>>j&1:
            sum+=int(s)
            s=str(X[j+1])
        else:
            s=s+str(X[j+1])
    else:
        sum+=int(s)
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#abc 045 C
import itertools
s= input() # e.g 125
n = len(s)
zentan = itertools.product([0,1],repeat = n-1)
output = 0
for i in zentan: #e.g  i = (0,1)
    total_i = 0
    ln = s[0]
    for j,k  in enumerate(i): # j= 0~ len(n)-1, k = i[?]
        if k == 0:
            ln +=s[j+1]
        elif k == 1:
            total_i += int(ln)
            ln = s[j+1]
    total_i += int(ln)
    output += total_i
    
print(output)

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

s = [int(i) for i in STR()]
l = len(s)
ans = 0
for i in range(2 ** (l - 1)):
    tmp = 0
    for j in range(l):
        tmp *= 10
        tmp += s[j]
        if i >> j & 1:
            ans += tmp
            tmp = 0
    ans += tmp
print(ans)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from itertools import product

s = read().rstrip().decode()
ans = int(s[-1]) * (2 ** (len(s) - 1))
for bit in product(['', '+'], repeat=len(s) - 1):
    memo = 0
    for i, (bf, af) in enumerate(zip(s, s[1:])):
        memo += int(bf)
        if bit[i] == '+':
            ans += memo
            memo = 0
        else:
            memo *= 10
    ans += memo
print(ans)

Submission status: Accepted

Solution code:
from itertools import product

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

sum = 0
for bit in product([0,1],repeat=n-1):
    x = ["+"] * n
    siki = ""
    for i,j in enumerate(bit):
        #print(bit,i,j)
        if j == 1:
            x[i] = ""
    for k in range(n):
        if k != n-1:
            siki = siki + str(s[k])+str(x[k]) 
        else:
            siki = siki + str(s[k])
    sum += eval(siki)
print(sum)

Submission status: Accepted

Solution code:
from itertools import product

s = input()
n = len(s)

cnt = 0
for bit in product([0, 1], repeat=n - 1):
    tmp = []
    for i, j in enumerate(bit):
        if j == 1:
            tmp.append("+")
        else:
            tmp.append("")
    s_ = s[0]
    for i in range(n - 1):
        s_ += tmp[i] + s[i + 1]
    cnt += eval(s_)
print(cnt)

Submission status: Accepted

Solution code:
"""
abc167でC問題にてbit全探索を解けなかったので猛省
"""

N = list(input())

L = len(N)
ans = 0

for i in range(0, 1 << L-1):
    s = []
    minus = [N[0]]
    for j in range(L-1):
        if (i >> j) & 1:
            s.append(int("".join(minus)))
            minus = [N[j+1]]
        else:
            minus.append(N[j+1])
    s.append(int("".join(minus)))
    ans += sum(s)
print(ans)

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()
sl=len(s)

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

ans=0
for i in range(2**(sl-1)):
  l=['' for j in range(sl-1)]
  for k in range(sl-1):
    if (i>>k)&1:
      l[k]='+'

  t_ans=0
  t_s=s[0]

  for k in range(1,sl):
    if l[k-1]=='+':
      t_ans+=int(t_s)
      t_s=s[k]
    else:
      t_s+=s[k]

  t_ans+=int(t_s)
  ans+=t_ans

print(ans)

Submission status: Accepted

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

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

ans=0
for i in range(2**(sl-1)):
  l=['' for j in range(sl-1)]
  for k in range(sl-1):
    if (i>>k)&1:
      l[k]='+'

  t_ans=0
  t_s=s[0]

  for k in range(1,sl):
    if l[k-1]=='+':
      t_ans+=int(t_s)
      t_s=s[k]
    else:
      t_s+=s[k]

    if k==sl-1:
      t_ans+=int(t_s)

  ans+=t_ans

print(ans)

Submission status: Accepted

Solution code:
from itertools import groupby, accumulate, product, permutations, combinations

def solve():
    ans = 0
    S = list(map(int,list(input())))
    for p in product([0,1],repeat=len(S)-1):
        total = S[0]
        for i in range(len(S)-1):
            if p[i]==1:
                ans += total
                total = S[i+1]
            else:
                total *= 10
                total += S[i+1]
        ans += total
    return ans
print(solve())

Submission status: Accepted

Solution code:
S = input()
l = len(S)
ans = 0
for i in range(1<<(l-1)):
    tmp = 0
    for j in range(l):
        tmp = tmp*10+int(S[j])
        if i >> j & 1:
            ans += tmp
            tmp = 0
    ans += tmp
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
s=list(S)

ans=0

if len(S)!=1:
    for i in range(2**(len(s)-1)):
        judge=str(bin(i))[2:].rjust(len(s)-1,"0")
        sum=0
        plus=s[0]
        #print(judge)
        for j,jud in enumerate(judge):
            if jud=="0":
                plus+=s[j+1]
                #print(plus)
            else:
                sum+=int(plus)
                plus=""
                plus+=s[j+1]
        if len(plus)!=0:
            sum+=int(plus)
            #print(plus)
        #print(sum)
        ans+=sum
else:
    ans=int(S)
print(ans)

Submission status: Accepted

Solution code:
S = input()

n = 2**(len(S)-1)
ans = 0
for i in range(n):
  bs ="0" + format(i,"0{}b".format(len(S)-1))
  res = 0
  l = []
  for j in range(len(bs)):
    if bs[j] == "1":
      l.append(int(S[res:j]))
      res = j
  l.append(int(S[res:len(S)]))
  ans += sum(l)
print(ans)

Submission status: Accepted

Solution code:
def main():
    import sys
    sys.setrecursionlimit(10 ** 7)

    s = input()

    def calc(cur=1, t=s[0]):
        if cur == len(s):
            return eval(t)
        return calc(cur + 1, t + s[cur]) + calc(cur + 1, t + '+' + s[cur])

    print(calc())


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

s=input().rstrip()
n=len(s)
plus=[[] for i in range(2**(n-1))]
for i in range(2**(n-1)):
    for j in range(n-1):
        x=(i>>j) %2
        #print(x,end=" ")
        if x==1:
            plus[i].append(j+1)
            #print(j)
    plus[i].append(n)
#print(plus)
ans=0
strs=[]
for i in range(2**(n-1)):
    strs=[]
    start=0
    endi=plus[i][0]
    '''print(start,end=" ")
    print(endi,end=" ")
    print(int(s[start:endi]))'''
    #print(endi)
    #len(plus[i])!=0:
    strs.append(int(s[start:endi]))
    for j in range(len(plus[i])-1):
        start=endi
        endi=plus[i][j+1]
        '''print(start,end=" ")
        print(endi,end=" ")
        print(int(s[start:endi]))'''
        strs.append(int(s[start:endi]))
    ans+=sum(strs)
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 = S[0]
    for i in range(N-1):
        if x[i]==1:
            y += "+"
        y += S[i+1]
    cnt += eval(y)
print(cnt)

Submission status: Accepted

Solution code:

def main():
    S = list(input())
    lenS = len(S)-1

    ans = 0
    for i in range(2**lenS):
        Stmp = S.copy()
        jtmp = []
        for j in range(lenS):
            if (i>>j)&1:
                jtmp.append(j+1)
        for j in range(len(jtmp)):
            k = jtmp.pop()
            Stmp.insert(k, '+')
        listS = ''.join(Stmp).split('+')
        intS = [int(x) for x in listS]
        ans += sum(intS)

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def convert(s): 
  
    # initialization of string to "" 
    new = "" 
  
    # traverse in the string  
    for x in s: 
        new += x  
  
    # return string  
    return new 
n=input()
ans=0
for i in range(len(n)):
  for j in range(len(n)-i):
    if j==len(n)-i-1:
      ans+=int(n[i])*(2**(len(n)-j-1))*(10**j)
    else:
      ans+=int(n[i])*(2**(len(n)-j-2))*(10**j)
print(ans)

Submission status: Accepted

Solution code:
S = list(input())

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

print(res)

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:
import itertools
s = input()
n = len(s) - 1

ans = 0
op = [x for x in itertools.product(["+", ""], repeat=n)]
for i in range(2 ** n):
  f = s[0]
  for j, k in zip(op[i], s[1:]):
    f += (j+k)
  ans += eval(f)
print(ans)

Submission status: Accepted

Solution code:
s = input()
l = len(s)-1
ans = 0

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

Submission status: Accepted

Solution code:
def main():
    s = input()
    sukima = len(s)-1
    res = 0
    for i in range(2**sukima):
        op = ['']*sukima
        for j in range(sukima):
            if ((i>>j)&1): # bit check
                op[sukima-1-j] = '+'
        s1 = [s[i//2] if i%2 == 0 else op[i//2] for i in range(len(s)*2-1)]
        res += eval(''.join(s1))
    print(res)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = list(input())
N = len(S)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
  ans = 0
  s = input()
  n = len(s)-1
  for i in range(1<<n):
    eq = ""
    for j in range(len(s)):
      eq += s[j]
      if (j < n and ((i>>j) & 1)):
        eq += "+"
    ans += eval(eq)
  print(ans)
  return

if __name__ == "__main__":
  resolve()

Submission status: Accepted

Solution code:
import sys
from itertools import product

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    S = input()
    n = len(S)
    res = 0
    for pattern in product([0, 1], repeat=n - 1):
        pattern = list(pattern) + [""]
        fomula = []
        for s, op in zip(S, pattern):
            fomula.append(s)
            fomula.append("+") if op == 1 else None

        fomula = "".join(fomula)
        res += eval(fomula)

    print(res)


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
S=input()
N=len(S)
n=N-1

ans=0
for b in range(2**n):
    pre=0
    for i in range(n):
        if b>>i&1==1:
            s=S[pre:i+1]
            ans+=int(s)
            pre=i+1
    ans+=int(S[pre:])
print(ans)

Submission status: Accepted

Solution code:
from itertools import product
def main():
    s = input()
    ans = 0
    for v in product([True, False], repeat=len(s)+1):
        if not v[0] or not v[len(s)]:
            continue
        l, r = 0, 1
        while r < len(s)+1:
            if v[r]:
                x = int(s[l:r])
                ans += x
                l = r
            r += 1
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = input()
op_cnt = len(S) - 1
ops = []
ans = 0
for i in range(2 ** op_cnt):
    op = [""] * op_cnt 
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"
    formula = ""
    for p_n, p_o in zip(S, op + [""]):
        formula += (p_n + p_o)
    ans += eval(formula)

print(ans)

Submission status: Accepted

Solution code:
def main():
    S = input()
    N = len(S)-1
    ans = 0
    for bit in range(1 << N):
        op = ["" for _ in range(N)]
        for i in range(N):
            if bit & (1 << i):
                op[i] = "+"
        s = "".join(S[i]+op[i] for i in range(N)) + S[-1]
        ans += sum(int(t) for t in s.split('+'))
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()
op_cnt = len(S) - 1  # すき間の個数
ops = []
ans = 0
for i in range(2 ** op_cnt):
    op = [""] * op_cnt  # あらかじめ ["-", "-", "-"] というリストを作っておく
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"  # フラグが立っていた箇所を "+" で上書き
    formula = ""
    for p_n, p_o in zip(S, op + [""]):  # 少々モヤッとする
        formula += (p_n + p_o)
    ans += eval(formula)

print(ans)

Submission status: Accepted

Solution code:
s = input()
n = len(s)
score = 0
for i in range(2**(n - 1)):
    temp = s[0]
    for j in range(n - 1):
        #j桁目が1の時
        if (i>>j)&1:
            temp += '+' + s[j + 1]
        #ｊ桁目が0の時
        else:
            temp += s[j + 1]
    score += eval(temp)

print(score)

Submission status: Accepted

Solution code:
S = list(map(int, list(input())))
N = len(S) - 1
ans = 0
prev = 0
for i in range(2**N):
    prev = 0
    for j in range(N):
        prev *= 10
        prev += S[j]
        if (i >> j) % 2 == 1:
            ans += prev
            prev = 0
    prev *= 10
    prev += S[-1]
    ans += prev
print(ans)

Submission status: Accepted

Solution code:
import sys
# input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

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

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

print (ans)

Submission status: Accepted

Solution code:
def main():
    s = list(input())
    length = len(s)
    answer = 0
    for i in range(pow(2, length - 1)):
        op = ["" for _ in range(length - 1)]
        for j in range(length - 1):
            if (i >> j) & 1:
                op[j] = "+"
        formula = s[0]
        for j in range(length - 1):
            formula += op[j] + s[j + 1]
        answer += eval(formula)
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 0
for d in range(1 << (N - 1)):
    ret = 0
    T = S[0]
    for i, s in enumerate(S[1:]):
        if (d & (1 << i)) > 0 and len(T) > 0:
            ret += int(T)
            T = ''
        T += s
    if len(T) > 0:
        ret += int(T)
    ans += ret
print(ans)

Submission status: Accepted

Solution code:
n = input()
l = len(n)
t = 0
for i in range(2**(l-1)):
	chk = [False] * (l)
	for j in range(l-1):
		if (i >> j) & 1:
			chk[j] = True
	v = ""
	for j in range(l):
		v += n[j]
		if chk[j]:
			v += ","
	u = v.split(",")
	for i in u:
		t += int(i)
print (t)