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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
import sys
import math

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

    ans += eval(s)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
_='_'
r=lambda f: int(r(f.replace(_,'+',1))+int(r(f.replace(_,'',1)))) if _ in f else eval(f)
print(r(_.join(list(input()))))

Submission status: Accepted

Solution code:
a="*"
def r(f): return int(r(f.replace(a,"+",1))+int(r(f.replace(a, "", 1)))) if a in f else eval(f)
print(r(a.join(list(input()))))

Submission status: Accepted

Solution code:
S = input()
K = len(S) - 1
A = 0

for i in range(1 << K):
    s = S[0]
    for j in range(K):
        if (i >> j) & 1:
            s += "+"
        s += S[j+1]        
    A += eval(s)
print(A)

Submission status: Accepted

Solution code:
def r(f):
    if "*" in f:
        return int(r(f.replace('*',"+",1))+int(r(f.replace('*','',1))))
    return eval(f)
print(r("*".join(list(input()))))

Submission status: Accepted

Solution code:
def r(f):
    if not "*" in f:
        return eval(f)
    return int(r(f.replace('*',"+",1)) + int(r(f.replace('*',"",1))))
print(r("*".join(list(input()))))

Submission status: Accepted

Solution code:
def rec(formula):
    if not "*" in formula:
        return eval(formula)
    return int(rec(formula.replace('*', "+", 1)) + int(rec(formula.replace('*', "", 1))))
print(rec("*".join(list(input()))))

Submission status: Accepted

Solution code:
s= input()
n = len(s) - 1
total = 0

import itertools
li = list(itertools.product({0, 1}, repeat=n))
for i in range(len(li)):
    start = 0
    for j in range(n+1):
        if j == n:
            total += int(s[start:n+1])
        elif li[i][j] == 1:
            total += int(s[start:j+1])
            start = j+1

        else:
            pass

print(total)

Submission status: Accepted

Solution code:
s = input()
n = len(s) - 1  # スキマの数
sum_ = 0
keep = 0
for i in range(2**n):  # +かつなげるか
    p_or_no = [""] * n
    for j in range(n):
        if ((i >> j) & 1) == 1:
            p_or_no[n-1-j] = "+"

    for k in range(n):
        if p_or_no[k] == "+":
            sum_ += int(s[k]) + keep
            keep = 0
        else:
            keep = int(s[k]) * 10 + keep * 10
        if k == n-1:
            sum_ += int(s[-1]) + keep
            keep = 0
if len(s) == 1:
    sum_ = int(s)
print(sum_)

Submission status: Accepted

Solution code:
s=input()
n=len(s)
ans=0
for i in range(2**(n-1)):
    binary=bin(i)[2:].zfill(n-1)
    m=[0]+[j+1 for j in range(n-1) if binary[j]=="1"]+[n]
    ans+=sum( int(s[m[j-1]:m[j]]) for j in range(1,len(m)) )
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
S = str(input())
S_list =[S]
total = 0

def X(li,X):
	for j in range(len(li)):
		dis = -len(S)+len(li[j])
		li.append(li[j][:X+1+dis]+ '!' + li[j][-len(li[j])+X+1+dis:])

	return li
			
for i in range(len(S)-1):
	S_list = X(S_list,i)
	
for i in range(len(S_list)):
	temp = S_list[i].split('!')
	for j in range(len(temp)):
		total = total + int(temp[j])
		
print(total)

Submission status: Accepted

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

for bit in range(2**n):
    s_calc = s
    for i in reversed(range(n)):
        if (1 << i) & bit:
            ls.append(int(s_calc[i+1:]))
            s_calc = s_calc[:i+1]
    if s_calc:
        ls.append(int(s_calc))
print(sum(ls))

Submission status: Accepted

Solution code:
S = input()
n = len(S)
res = 0
for i in range(1 << (n-1)):
	l = []
	for j in range(n-1):
		if (i >> j) & 1:
			l.append(j+1)	
	l.insert(0,0)
	l.append(n)	
	for i in range(len(l)-1):
		res += int(S[l[i]:l[i+1]])
print(res)

Submission status: Accepted

Solution code:
s=input()
length=len(s)
ans=0
for i in range(2**(length-1)):
  bi=bin(i)[2:].zfill(length-1) #0埋め2進数
  temp=0
  for index,j in enumerate(bi):
    if j=="1":
      ans+=int(s[temp:index+1])
      temp=index+1
  ans+=int(s[temp:]) #最後の+より後ろを足す
print(ans)

Submission status: Accepted

Solution code:
s = input()
n = len(s)
res = 0
l = []
for i in range(1 << (n-1)):
    cnt = 1
    l = [0]
    for j in range(n-1):
        if (i >> j) & 1:
            l.append(j+1)
    l.append(n)
    for k in range(len(l) - 1):
        res += int(s[l[k]:l[k+1]])  # 何番目の数字までを一つにするかという事を示している

print(res)

Submission status: Accepted

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

for bit in range(1 << (l-1)):
    f = s[0]

    for i in range(l-1):
        if bit & (1 << i):
            f += "+"
        f += s[i+1]

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

print(ans)

Submission status: Accepted

Solution code:
s=input()
ans=0
def two(x):
	p=bin(x)
	return "0"*(len(s)-len(p)+1)+p[2:]
for i in range(2**(len(s)-1)):
	p=two(i)
	q=s[0]
	k=0
	for j in range(len(s)-1):
		if p[j]=="1":
			q+=s[j+1]
		else:
			k+=int(q)
			q=s[j+1]
	if len(q)>0:
		k+=int(q)
	ans+=k
print(ans)

Submission status: Accepted

Solution code:
numbers = input()
numbers

def dfs(i, indices):
    total = 0

    if i == len(numbers) - 1:
        indices = [0] + indices + [None]
        for n in range(len(indices) - 1):
            total += int(numbers[indices[n]:indices[n+1]])
        return total

    total += dfs(i+1, indices)
    total += dfs(i+1, indices + [i+1])

    return total
  
print(dfs(0, []))

Submission status: Accepted

Solution code:
s = input()
n = len(s)
res = 0
l =[]

for i in range(1 << (n-1)):
    cnt = 1
    l = [0]
    for j in range(n-1):
        if (i >> j) & 1:
            l.append(j+1)
    l.append(n)
    for k in range(len(l)-1):
        res += int(s[l[k]:l[k+1]])

print(res)

Submission status: Accepted

Solution code:
S = input()

def func(num, code):
    total = 0
    start = 0
    length = len(num)

    for i in range(1, length):
        if code & 1 == 1: #一番下にビットが立ってるなら
            total = total + int(num[start:i])
            start = i
        code = code >> 1

    total = total + int(num[start:length])

    return total

total_of_all = 0

for i in range(2 ** (len(S) - 1)):
    total_of_all = total_of_all + func(S, i)

print(total_of_all)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
ls=list(map(int,[S[i] for i in range(len(S))]))
l=len(S)
if l==1:
  print(S)
  exit()
su=0
sl=[]
a=0
for i in range(1<<l-1):
  ls=[]
  j=0
  x=0
  while j<l-1:
    if i&(1<<j):
      ls.append(S[x:j+1])
      x=j+1
    j+=1
    if j==l-1:
      ls.append(S[x:])
  su=sum(map(int,[ls[k] for k in range(len(ls))]))
  a+=su
print(a)

Submission status: Accepted

Solution code:
import itertools

S = list(input())
A = [0,1]
Comb = list(itertools.product(A, repeat=len(S)-1))

ans = 0
for i in range(len(Comb)):
  tmp = list(Comb[i])
  num1 = []
  num2 = S[0]
  for j in range(len(tmp)):
    if(tmp[j] == 0): num2 += S[j+1]
    else:
      if(num2 != ''): num1.append(int(num2))
      num2 = S[j+1]
  if(num2 != ''): num1.append(int(num2))
  num = sum(num1)
  ans += num
  
print(ans)

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/arc061/tasks/arc061_a

s = input()

def xxx(residue, l):
    if len(s)==1:
        return [[1]] 
    elif residue==len(s)-1:
        return [l + [residue, len(s)], l + [len(s)]]
    else:
        return xxx(residue+1, l + [residue]) + (xxx(residue+1, l))

flaglist = xxx(1, [])

sum = 0
for value in flaglist:
    for i in range(len(value)):
        if i==0:
            sum += int(s[:value[i]])
        else:
            sum += int(s[value[i-1]:value[i]])

print(sum)

Submission status: Accepted

Solution code:
def main():
    S = input()
    N = len(S)
    ans = 0
    for bit in range(1<<(N-1)):
        pre = 0
        for i in range(N-1):
            if bit&(1<<i):
                ans += int(S[pre:i+1])
                pre = i + 1
        else:
            ans += int(S[pre:])
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    S = input()
    N = len(S)
    ans = 0
    for bit in range(1<<(N-1)):
        cur = []
        for i in range(N-1):
            if bit&(1<<i):
                cur.append(i)
        else:
            cur.append(N-1)
        pre = 0
        for c in cur:
            num = int(S[pre:c+1])
            ans += num
            pre = c+1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

        tmp += s[j+1]

    list_tmp = tmp.split("+")

    for j in list_tmp:
        sum += int(j)

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
T=len(S)-1
count=0

for i in range(2**T):
  op=['']*T
  for j in range(T):
    if((i>>j)&1):
      op[T-1-j]='+'
        
  formula=''
  for a,b in zip(S,op+['']):
    formula+= (a+b)
  count+= eval(formula)
    
print(count)

Submission status: Accepted

Solution code:
S = input()
n = len(S)-1
n_list = []
total = 0

for i in range(2**n):
    op = [""] * n
    for j in range(n):
        if((i >> j) & 1):
            op[n-1-j] = "+"
    formula=""
    for x,y in zip(S,op + [""]):
        formula += (x + y)
    total += eval(formula)
print(total)

Submission status: Accepted

Solution code:
from functools import lru_cache, reduce
import itertools
import math
import sys


sys.setrecursionlimit(10**6)

N = input()

def main():
    a = [list(i) for i in itertools.product(["", "+"], repeat=len(N)-1)]
    [i.append("") for i in a]
    b = list(map(lambda ops: [N[i]+ops[i] for i in range(len(N))], a))
    print(sum(list(map(lambda x: eval("".join(x)), b))))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = input()
len_S = len(S)-1
ans = 0
for s in range(1<<len_S):
  now = ""  
  now += S[0]  
  for i in range(len_S):    
    if s & (1<<i): # 間に"+"を入れる
      now += "+"
    now += S[i+1]    
  ans += eval(now)
print(ans)

Submission status: Accepted

Solution code:
import copy

s = input()

def value(s, adding_list):
    insert_index = []
    for index in range(len(adding_list)):
        if adding_list[index]:
            insert_index.append(index)

    if len(insert_index) == 0:
        return int(s)

    value_list = []

    for index in range(len(insert_index)):
        if index == 0:
            value_list.append(s[0:insert_index[index]+1])
        if index < len(insert_index)-1:
            value_list.append(s[(insert_index[index]+1) : insert_index[index+1]+1])

        if index == len(insert_index)-1:
            value_list.append(s[insert_index[index]+1:])

    ret_val = 0
    for value in value_list:
        ret_val += int(value)

    return ret_val

def dfs(adding_list, changing_index):
    sum = 0
    if changing_index == len(s)-2:
        return value(s, adding_list)
    else:
        changing_index += 1
        new_adding_list = copy.copy(adding_list)
        sum += dfs(new_adding_list, changing_index)

        new_adding_list = copy.copy(adding_list)
        new_adding_list[changing_index] = True
        sum += dfs(new_adding_list, changing_index)
        return sum

def main():
    if len(s) > 1:
        ret_val = 0
        plus_list = [False for _ in range(len(s)-1)]
        ret_val += dfs(plus_list, 0)

        plus_list = [False for _ in range(len(s)-1)]
        plus_list[0] = True
        ret_val += dfs(plus_list, 0)
        print(ret_val)
    else:
        print(s)

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(idx: int, l: list) -> None:
  if idx >= len(l)-1:
    res.append(sum(map(int, "".join(l).split("+"))))
    return
  solve(idx+1, l)
  copied = l.copy()
  copied.insert(idx+1, "+")
  solve(idx+2, copied)

S = list(input())
res = []
solve(0, S.copy())
print(sum(res))

Submission status: Accepted

Solution code:
n = int(input())
s = len(str(n))
if s == 1:
    print(n)
else:
    #print(s)
    a0 = n % 10
    a = [a0]
    for i in range(2,s+1):
        b = n % (10**i)
        #print(b)
        d = 0
        for k in range(2,i+1):
            d = d + (2**(i-k))*(b//(10**(i+1-k))) + a[i-k]
            #print(d)
        a.append(d+b)
        #print(a)
    print(a[s-1])

Submission status: Accepted

Solution code:
def solve():
    sum = 0 # 求める合計値

    n = input()
    op_cnt = len(n) - 1 # 隙間の個数 op:operator
    for i in range(2 ** op_cnt): # iは2進数で000, 001, 010, 011...,111と遷移する
        op = [""] * op_cnt # あらかじめ["", "", ""]というリストを作っておく
        for j in range(op_cnt):
            if ((i >> j) & 1): # 5 = 0b101の場合["+", "", "+"]となる
                op[op_cnt - 1 - j] = "+"

        formula = "" # formula:式
        # 演算子の数はn-1個なので個数を合わせる
        # p_n: part_of_n?
        for p_n, p_o in zip(n, op + [""]):
            formula += (p_n + p_o)
        sum += eval(formula)
    print(sum)
solve()

Submission status: Accepted

Solution code:
S = [int(i) for i in input()]

N = len(S)
ans = 0
for i in range(N):
    left = i
    right = N - i - 1
    score = 1
    for k in range(0, right + 1):
        if right - k > 0:
            ans += S[i] * score * (1 << left) * (1 << (right - k - 1))
        else:
            ans += S[i] * score * (1 << left)
        score *= 10

print(ans)

Submission status: Accepted

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

n = len(s)
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:

def main():
    s = input()
    num = 2**(len(s)-1)
    bit_len = len(bin(num))

    def func(ｎ):
        n = bin(n)
        n_len = len(n)
        n = "0"*( bit_len - n_len - 1 ) + n[-len(n)+2:]
        indexes = [i+1 for i, x in enumerate(ｎ) if x == "1"]
        ans = 0
        temp = 0
        for i in indexes:
            ans += int(s[temp:i])
            temp = i
        else:
            if temp != bit_len-2:
                ans += int(s[temp:])

        return ans

    ans = 0
    for i in range(num):
        ans += func(i)
    print(ans)

main()

Submission status: Accepted

Solution code:
s = int(input())
S = []
while s > 0:
    S.append(s % 10)
    s //= 10
S.reverse()

N = len(S)
ans = 0
for i in range(N):
    left = i
    right = N - i - 1
    score = 1
    for k in range(0, right + 1):
        if right - k > 0:
            ans += S[i] * score * (1 << left) * (1 << (right - k - 1))
        else:
            ans += S[i] * score * (1 << left)
        score *= 10

print(ans)

Submission status: Accepted

Solution code:
S = input()

L = []
for i in range(len(S)):
    L.append(S[i])
    
ans = 0

for i in range(2**(len(S)-1), 2**(len(S))):
    c = 0
    temp = bin(i)
    for j in range(3, len(temp)):
        if temp[j] == "1":
            temp_list = L[c:j-2]
            ans += int("".join(temp_list))
            c = j-2
    temp_list = L[c:]
    ans += int("".join(temp_list))
            
print(ans)

Submission status: Accepted

Solution code:
import sys


def log(s):
    print("| " + str(s), file=sys.stderr)
    pass


def output(x):
    print(x, flush=True)


def input_ints():
    return list(map(int, input().split()))


def main():
    s = input()
    n = len(s) - 1
    sum = 0
    for k in range(2 ** n):
        q = list(s)
        i = n
        while k > 0:
            if k & 1:
                q.insert(i, "+")
            k >>= 1
            i -= 1
        sum += eval("".join(q))
    print(sum)


main()

Submission status: Accepted

Solution code:
import itertools

s = input()
n = len(s)

l = []
for i in range(1,n):
	l.append(i)

ans = []

for i in range(1,n):
	index = list(itertools.combinations(l,i))
	for j in range(len(index)):
		start = 0
		for k in index[j]:
			ans.append(int(s[start:k]))
			start = k
		ans.append(int(s[k:n]))

print(sum(ans) + int(s))

Submission status: Accepted

Solution code:
s = input()

ans = 0
for bit in range(2 ** (len(s) - 1)):
    cnt = 0
    now = int(s[0])
    for i in range(len(s) - 1):
        if bit >> i & 1:
            cnt += now
            now = int(s[i + 1])
        else:
            now = now * 10 + int(s[i + 1])
    
    cnt += now
    ans += cnt

print(ans)

Submission status: Accepted

Solution code:
s = input()
n = len(s) - 1  # スキマの数
sum_ = 0
keep = 0
for i in range(2**n):  # +かつなげるか
    p_or_no = ["no"] * n
    for j in range(n):
        if ((i >> j) & 1) == 1:
            p_or_no[n-1-j] = "+"

    for k in range(n):
        if p_or_no[k] == "+":
            sum_ += int(s[k]) + keep
            keep = 0
        else:
            keep = int(s[k]) * 10 + keep * 10
        if k == n-1:
            sum_ += int(s[-1]) + keep
            keep = 0
if len(s) == 1:
    sum_ = int(s)
print(sum_)

Submission status: Accepted

Solution code:
#!/usr/bin/python3

import sys

def dprint(*args):
    return
    print(*args)

def solve(s_str):
    ans = 0
    s_len = len(s_str)
    for bits in range(0, 1 << (s_len - 1)):
        dprint("bits: {0:b}".format(bits))
        rev_str = list(reversed(s_str))
        #dprint(f"rev_str: {rev_str}")
        cur_num_rev_str = ""
        # 12345
        for rev_i in range(0, s_len):
            dprint("rev_i: %d" % rev_i)
            plus_index = rev_i
            cur_num_rev_str += rev_str[0]
            rev_str = rev_str[1:]
            dprint("cur_num_rev_str: %s" % cur_num_rev_str)
            if rev_i == s_len - 1 or bits & (1 << plus_index):
                ans += int(''.join(list(reversed(cur_num_rev_str))))
                cur_num_rev_str = ""
    return ans

def main():
    s_str = sys.stdin.read().rstrip()
    dprint(s_str)
    print(solve(s_str))

main()

Submission status: Accepted

Solution code:
#!/usr/bin/python3

import sys

def dprint(*args):
    pass
    #print(*args)

def solve(s_str):
    ans = 0
    s_len = len(s_str)
    for bits in range(0, 1 << (s_len - 1)):
        dprint("bits: {0:b}".format(bits))
        rev_str = list(reversed(s_str))
        #dprint(f"rev_str: {rev_str}")
        cur_num_rev_str = ""
        # 12345
        for rev_i in range(0, s_len):
            dprint("rev_i: %d" % rev_i)
            plus_index = rev_i
            cur_num_rev_str += rev_str[0]
            rev_str = rev_str[1:]
            dprint("cur_num_rev_str: %s" % cur_num_rev_str)
            if rev_i == s_len - 1 or bits & (1 << plus_index):
                ans += int(''.join(list(reversed(cur_num_rev_str))))
                cur_num_rev_str = ""
        if cur_num_rev_str != "":
            #dprint(f"ans: {ans}")
            ans += int(''.join(list(reversed(cur_num_rev_str))))
    return ans

def main():
    s_str = sys.stdin.read().rstrip()
    dprint(s_str)
    print(solve(s_str))

main()

Submission status: Accepted

Solution code:
s = input()
def calc(s,op):
    ans = 0
    tmp = 0
    for i in range(len(s)):
        tmp += int(s[i])
        if i == len(s) - 1:
            ans += tmp
            break
        if op[i] == 0:
            tmp = tmp * 10
        else:
            ans += tmp
            tmp = 0
    return ans 
i_max = 2**(len(s)-1)
ans = 0
for i in range(i_max):
    op = [0]*(len(s) - 1)
    for j in range(len(op)):
        op[j] = i % 2
        i = i // 2
    ans += calc(s,op)
print(ans)

Submission status: Accepted

Solution code:
from functools import reduce

s = list(map(int, list(input())))
max_len = len(s) - 1
li = []
for bit in range(1 << max_len):
    tmp = s[0]
    for n in range(max_len):
        if (bit & 1 << n) != 0:
            li.append(tmp)
            tmp = 0
        else:
            tmp *= 10
        tmp += s[n + 1]
    li.append(tmp)
print(reduce(lambda x, y: x + y, li))

Submission status: Accepted

Solution code:
S = input()

ans = 0
for i in range(2 ** (len(S)-1)):
    c = ''
    for j in range(len(S)-1):  # このループが一番のポイント
        c = S[len(S)-1-j]+c
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            ans += int(c)
            c = ''
    c = S[0]+c
    ans += int(c)

print(ans)

Submission status: Accepted

Solution code:
S = input()
sum = 0
for j in range(2**(len(S)-1)):
    shiki = ""
    for i in range(len(S)):
        bin_str = str(format(j, 'b').rjust(10, '0'))
        shiki += S[i]
        if bin_str[-i - 1] == "1":
            shiki = shiki + "+"
    sum += eval(shiki)
print(sum)

Submission status: Accepted

Solution code:
s = input()

s_len  = len(s)
mul = [1,1,2,4,8,16,32,64,128,256]

ans = 0
for i in range(s_len):
    num = int(s[(s_len-1-i)])

    temp = 0
    for j in range(i+1):
        temp += num*(10**j)*mul[(i-j)]

    ans = ans*2 + temp

print(ans)

Submission status: Accepted

Solution code:
S = int(input())
numbers = str(S)
L = len(numbers)
prev = 0
for bit in range(1<<L-1):
    now = int(numbers[0])
    for i in range(L-1):
        if bit & (1<<i):
            prev += now
            now = int(numbers[i+1])
        else:
            now = now * 10 + int(numbers[i+1])
    prev += now
print(prev)

Submission status: Accepted

Solution code:
import itertools
S = input()

ans = 0
for ptn in itertools.product(['+',''], repeat=len(S)-1):
    f = ''
    for i in range(len(S)):
        f += S[i]
        if i < len(ptn): f += ptn[i]
    ans += eval(f)
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:
def dfs(i, f):
    if i == n - 1:
        return sum(list(map(int, f.split("+"))))
        # return sum(list(map(eval,f)))

    # 式 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
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        S = input().rstrip()

        ans = int(S)
        for i in range(1, len(S)):
            for c in itertools.combinations(range(1, len(S)), i):
                tmp = S
                for j, v in enumerate(c):
                    index = j + v
                    tmp = tmp[:index] + '+' + tmp[index:]
                ans += eval(tmp)

        print(ans)


# Run main
if __name__ == '__main__':
    AtCoder().main()

Submission status: Accepted

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]

s = input()
n = len(s) - 1
total = 0
for i in range(2 ** n):
    indice = []
    sumup = 0
    for j in range(n):
        if (i >> j) & 1:
            indice.append(j)
    if indice == []:
        sumup += int(s)
    else:
        last_point = 0
        count = 0
        for i in indice:
            sumup += int(s[last_point:i+1])
            last_point = i+1
            count += 1
            if count == len(indice):
                sumup += int(s[last_point:])
    total += sumup

print(total)

# print(total)

Submission status: Accepted

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

s = 0
for i in range(1<<(len_S-1)):
    t = S[0]
    for j in range(len_S-1):
        if (i>>j)%2:
            t += "+"
        t += S[j+1]
    s += eval(t)

print(s)

Submission status: Accepted

Solution code:
def main():
    s = input()
    n = len(s)
    ans = 0
    for i in range(2**(n-1)):
        num = ""
        # print("pattern{}: ".format(i), end="")
        # print("a")
        for j in range(n):
            num += s[j]
            if ((i >> j) & 1):
                num += "+"
        # print(eval(num))
        ans += eval(num)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s=input()

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

Submission status: Accepted

Solution code:
s = input()
N = len(s)
value = []
for i in range(2**(N - 1)):
    x = []
    so = s
    cnt = 1
    for j in range(N - 1):
        if (i >> j) &  1:
            x.append(j)
    if len(x) > 0:
        val = 0 
        ind = 0
        for k in (x):
            val += int(s[ind:k+1])
            ind = k+1
        val += int(s[k+1:])
        value.append(val)
    else:
        value.append(int(s))
print(sum(value))

Submission status: Accepted

Solution code:
def func(s, r=0, t=0):
    if len(s)==1:
        return int(s)+r+t
    else:
        a = func(s[1:], (int(s[0])+r)*10, t)
        b = func(s[1:], 0, int(s[0])+r+t)
        return a+b

s, = [list(map(int, s.split())) for s in open(0)][0]
s = str(s)

ans = func(s)
print(ans)

Submission status: Accepted

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

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

    ans+=eval(num)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=str(input())
s=s[::-1]
n=len(s)
ans=0

c=[[(2**(n-1))]]
for i in range(n-1):
    if i>=1:
        d=c[i][:-1]
    else:
        d=[]
    d.append(c[i][-1]//2)
    d.append(c[i][-1]//2)
    #d=d[::-1]
    c.append(d)
for i in range(n):
    for j in range(len(c[i])):
        ans+=c[i][j]*(10**j)*int(s[i])
        #print(c[i][j]*(10**j)*int(s[i]))
#print(c)
print(ans)

Submission status: Accepted

Solution code:
def recur(i, buf, current, S):
  global result
  if i == len(S) - 1:
    result += current + buf * 10 + S[i]
    return
  # +を入れる
  recur(i + 1, 0, current + buf * 10 + S[i], S)

  # +を入れない
  recur(i + 1, buf * 10 + S[i], current, S)

S = list(map(int, list(input())))
result = 0
recur(0, 0, 0, S)
print(result)

Submission status: Accepted

Solution code:
S=input()
ls=[int(ss) for ss in S]
ans=0
for i in range(2**(len(S)-1)):
    #lnum=[]
    #while :#足す項
    #while i&1
    num=ls[0]
    for j in range(len(S)-1):
        if i&1:
            ans+=num
            num=ls[j+1]
            #i=i>>1
            i>>=1
        else:
            num=10*num+ls[j+1]
            i>>=1
    ans+=num

print(ans)

Submission status: Accepted

Solution code:
S = input()
s = list(map(int, list(S)))

ans = 0
op_cnt = len(s) - 1
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] = "+"
    op += ["-"]

    expr = "".join([n+o for n, o in zip(S, op)]).replace("-", "")
    ans += eval(expr)
print(ans)

Submission status: Accepted

Solution code:
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    S = input()
    N = len(S)
    sumv = 0
    for bit in range(1 << N-1):
        T = S[0]
        for i in range(N-1):
            if bit & (1 << i):
                T += "+"
            T += S[i + 1]
        sumv += eval(T)
    print(sumv)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#arc061_C - たくさんの数式 / Many Formulas
s = list(str(input()))
l = len(s)
def dfs(i,f):
    if i == l-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=[i for i in input()]
op_num = len(s)-1
sum=0

for i in range(2**op_num):
    op=['-' for i in range(op_num)]
    for j in range(op_num):
        if (i>>j)&1:
            op[j]='+'
    op+='+'
    sn=0
    for k in range(len(op)):
        if op[k]=='+':
            sum+=int(''.join(s[sn:k+1]))
            sn=k+1
print(sum)