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: Runtime Error

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 solve(s):
    a = calc(len(s))
    cnt = 0
    n = len(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(solve(input()))

Submission status: Runtime Error

Solution code:
import itertools
s=input()
ans=0
L=len(s)
for sta in itertools.product(range(2),L):
  cut=[-1]+[i for i in range(L) 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: Runtime Error

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 = 0
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
    memo += int(af)
    ans += memo
print(ans)

Submission status: Runtime Error

Solution code:
from collections import deque

n,m=map(int,input().split())

tree=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  tree[a].append(b)
  tree[b].append(a)

dist=[-1 for i in range(n)]
dist[0]=0

dq=deque()
dq.append(0)

while dq:
  x=dq.popleft()

  if x==n-1:
    if dist[x]==2:
      print('POSSIBLE')
    else:
      print('IMPOSSIBLE')

  for i in tree[x]:
    if dist[i]==-1:
      dist[i]=dist[x]+1
      dq.append(i)

Submission status: Runtime Error

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

ans=0

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
print(ans)

Submission status: Runtime Error

Solution code:
S=list(input())
ans=0
for i in range(2**(len(S)-1)):
  bin_i= format(i, 'b')
  bin_i=str(bin_i.zfill(len(S)-1))
  s=0
  l=int(S[0])
  for j,k in enumerate(bin_i):
    if k=="0":
      l=l*10+int(S[j+1])
    else:
      s+=l
      l=int(S[j+1])
      
    if j==len(S)-2:
        s+=l
  ans+=s
print(ans)

Submission status: Runtime Error

Solution code:

ss = input()
n = len(ss)
s=[]
for i in range(n):
    s.append(int(ss[i]))

ans = 0
for i in range(2**(n-1)):
    d=[[]]
    bit = ValueToBits(i,n-1)
    for j in range(n-1):
        d[-1].append(s[j])
        if(bit[j]==1):
            d.append([])
    d[-1].append(s[n-1])
    #print(d)
    
    for j in d:
        for k in range(len(j)):
            ans += 10**(len(j)-1-k) * j[k]

            



print(ans)

Submission status: Runtime Error

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

ans=0
for bit in range(1<<(N-1)):
    f = S[0]
    for i in range(N-1):
        if bit & (1<<i):
            f +="+"
        f+=S[i+1]

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

Submission status: Runtime Error

Solution code:


patterns = []
for i in range(2**(l-1)):
    pattern = [''] * (l-1)
    for j in range(l-1):
        if (i >> j & 1):
            pattern[j] = '+'
    patterns.append(pattern)

ans = 0
for pattern in patterns:
    a = s[0]
    for i in range(l-1):
        if (pattern[i] == ''):
            a += s[i+1]
        else:
            ans += int(a)
            a = s[i+1]
    else:
        ans += int(a)

print(ans)

Submission status: Runtime Error

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: Runtime Error

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

start = time.time()

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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import copy
a = list(input())
n = len(a)-1
ans = 0
for i in range(2 ** n):
    l=[]
    l = copy.copy(a)
    dokoka = [0]*(n)
    for j in range(n):
        if ((i >> j)&1):
            dokoka[j] = 1
    x = l.pop(0)
    while True:
      d = dokoka.pop(0)
      if d == 0:
          x += l.pop(0)
      else:
          ans += int(x)
          x = l.pop(0)
      if not dokoka:
          ans += int(x)
          break
print(ans)

Submission status: Runtime Error

Solution code:
S = list(input())
t = 0
for n in range(2**(len(S) - 1)):
    f = S[0]
    b = bin(n)[2:]
    b = "0"*(len(S) - len(b) - 1) + b
    for a in range(len(b)):
        if b[a] == "1":
            f += "+"
        f += S[a+1]
    t += eval(f)
print(t)

Submission status: Runtime Error

Solution code:
def dfs(i, f):
    if i == len(s) - 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()
print(dfs(0, s[0]))

Submission status: Runtime Error

Solution code:
def dfs(i, f):
    if i == len(s) - 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()
print(dfs(0, s[0]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

N = len(S)

tens = [10**i for i in range(N)]

tens.reverse()

twos = [1]
twos.extend(2**i for i in range(N-1))

sums = 0
all_comb = sum(twos)
for i in range(N):
    tmp = [x*y for x, y in zip(tens[i:], twos)]
    exp = S[i] * sum(tmp) / sum(twos)
    print(exp)
    sums = sums + exp
    del twos[-1]
print(sums * all_comb)

sum(map(mul, tens,twos))

Submission status: Runtime Error

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 >> j) & 1) == 1:
            x+="+"
        x+=S[j+1]
    ans+=eval(x)
print(ans)

Submission status: Runtime Error

Solution code:
s=str(input())
n=len(s)-1
#print(s,n)
#print(xy)
bit=[]#1が正直0が嘘
ans=0
def bit_search(bit):
    global ans
    count=[]
    c=0
    if len(bit)==n:#2**n文の組み合わせを調べる加圧10を交互に入れるためのif
        for i in range(n):
            if bit[i]==1:
                count.append(int(s[c:i]))
                c=i
        count.append(int(s[c:n]))
        ans+=sum(count)
    else:
       #再起化することによって最初にbitの配列を作る必要性をなくした
        bit_search(bit+[0])
        bit_search(bit+[1])
bit_search(bit)
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
TA = []
for i in range(N):
    T, A = map(int, input().split())
    TA.append((T, A))

T, A = TA[0]
answer = T+A
p = 1
prev = p
pT, pA = T, A
for i in range(1,N):
    # (T+A) * p >= prev
    # p >= prev/(T+A)
    T, A = TA[i]
    s = T+A
    p = (answer+s-1)//s
    p1 = (pT+T-1)//T
    p2 = (pA+A-1)//A
    p = max([p,p1,p2])
    pT, pA = p*T, p*A
    answer =  pT+pA
    #print(T, A, p, answer, sep="\t")
print(answer)

Submission status: Runtime Error

Solution code:
from sys import stdin
n = int(stdin.readline().rstrip())
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]
point = 0
for i in range(101):
    for j in range(101):
        flag = True
        kizyun = False
        count = 0
        for a,b,c in li:
            if c != 0:
                count += 1
                if kizyun == False:
                    h = c+abs(a-i)+abs(b-j)
                    if h-abs(a-i)-abs(b-j) != c:
                        flag = False
                    kizyun = True
                else:
                    k = c+abs(a-i)+abs(b-j)
                    if h != k and kizyun == True:
                        flag = False
            if count == 1:
                print(a,b,c)
                exit()
        if flag == True:
            point += 1
            print(i,j,h)

Submission status: Runtime Error

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

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

print(ans)

Submission status: Runtime Error

Solution code:
a = input()
sum = int(a)
for i in range(len(a)):
  if i==0:
    continue
  sum += int(a[:i])+int(a[i+1:])
print(sum)

Submission status: Runtime Error

Solution code:
#045c
S = list(input())

#allは2**9=512なので全探索でOK

ans = 0

for i in range(0,2**(len(S)-1)):
    bit = str(bin(i))[2:].zfill(len(S)-1)
    #print(bit,":",end="") 
    number = int(S[0])
    
    for j in range(len(bit)):

        if bit[j] == "0":
            number = number*10 + int(S[j+1])
        else:
            #print("+",number,end="")
            ans += number
            number = int(S[j+1])
            
    #print("+",number)
    ans += number
    
print(ans)

Submission status: Runtime Error

Solution code:
ss

Submission status: Runtime Error

Solution code:
S = list(input())
form = "0"+str(len(S)-1)+"b"
ans = 0
for i in range(2**(len(S)-1)):
    b = format(i, form)
    eq = [S[0]]
    for j in range(len(b)):
        if b[j] == "1":
            sign = "+"
        else: sign = ""
        eq.append(sign)
        eq.append(S[j+1])
    eqstr = str("".join(eq))
    ans += eval(eqstr)
print(ans)

Submission status: Runtime Error

Solution code:
a = input()
ans = 0
for i in range(2**(len(a)-1)):
    b = format(i, 'b').zfill((len(a)-1))
    li = []
    num = [a[0]]
    for i in range(len(b)):
        if b[i] == '1':
            ans += int(''.join(num))
            num = [a[i+1]]
        else:
            num.append(a[i+1])
    ans += int(''.join(num))

print(ans)

Submission status: Runtime Error

Solution code:
import sys
import copy



S = input()
op_list = ["+"]*(len(S)-1)

sum = 0
for i in range(2**len(op_list)):

    for j in range(len(op_list)):

        if (i >> j) & 1:
            op_list[j] = ""
    s = ""
    for k in range(len(op_list)):
        s = s + S[k] + op_list[k]
    sum = sum + eval(s)


print(sum)

Submission status: Runtime Error

Solution code:
def main():
    S = input()
    lens = len(S)

    patterns = []
    ans = 0
    for i in range(2 ** (lens-1)):
        x = format(i, 'b').zfill(lens-1)

        stmt = S[0]
        for i, xi in enumerate(x):
            if xi == '1':
                stmt += '+'
            stmt += S[i+1]
        ans += eval(stmt)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from itertools import combinations

def main():
    S = input()
    lens = len(S)

    patterns = []
    ans = 0
    for i in range(2 ** (lens-1)):
        x = format(i, 'b').zfill(lens-1)

        stmt = S[0]
        for i, xi in enumerate(x):
            if xi == '1':
                stmt += '+'
            stmt += S[i+1]
        ans += eval(stmt)
    print(ans)



if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
S = input()
p = [1] * (len(S) - 1)
sumlst = [0] * len(S)
ans = 0
def dfs(i):
    global ans
    if i == (len(S) - 1):
        tmp = ''
        if p[0] == 1:
            tmp += S[0] + '+' + S[1]
        else:
            tmp += S[0] + S[1]
        for i in range(1, len(p)):
            if p[i] == 1:
                tmp += '+' + S[i + 1]
            else:
                tmp += S[i + 1]
        ans += eval(tmp)
        return

    p[i] = 1
    dfs(i + 1)
    p[i] = 0
    dfs(i + 1)
    return

dfs(0)

print(ans)

Submission status: Runtime Error

Solution code:
s=list(input())
n=len(s)
for i in range(2**(n-1)):
	ni=list(map(int,list(str(format(i,"b")))))
	while len(ni)<n-1:
		ni.insert(0,0)
	siki=s[0]
	for j in range(n-1):
		if ni[j]==1:
			siki+="+"
		siki+=s[j+1]
	ans+=eval(siki)
print(ans)

Submission status: Runtime Error

Solution code:
Sl = list(input())

def func(n, s):
    n += 1
    if n==len(Sl)-1:
        a = sum([int(i) for i in (s+Sl[n]).split("+")])
        b = sum([int(i) for i in (s+"+"+Sl[n]).split("+")])
        return a + b
    else:
        return func(n, s+Sl[n]) + func(n, s+"+"+Sl[n])

print(func(0, Sl[0]))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
print(dfs(0,s[0]))

Submission status: Runtime Error

Solution code:
S = input()
n = lens(S)

def dfs(i,k):
  if i == n-1:
    return(sum(list(map(int,f.split("+")))
  return dfs(i+1,K+S[i+1])+dfs(i+1,K+"+"+S[i+1])
print(dfs(0,S[0])

Submission status: Runtime Error

Solution code:
S = input()

if len(S) == 1:
  print(int(S))
else:
  ans = 0
  for i in range(1<<(len(S)-1)):
    SP = []
    for j in range(len(S)-1):
      if (i>>j)&1 == 1:
        SP.append(j)
    SP += [len(S)-1]
    #print(SP)
    idx = 0
    for sp in SP:
      ans += int(S[idx:sp+1])
      idx = sp+1
print(ans)

Submission status: Runtime Error

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

def f(i,t):
    if i == n-1:
        return sum(list(map(int, t.split('+'))))
    
    return f(i+1,f+s[i+1]) + f(i+1,f+'+'+s[i+1])

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

Submission status: Runtime Error

Solution code:
s = input()

sum = 0
for bit in range(1 << (len(s) - 1)):
    expr = s
    ins = 0
    for i in range(len(s) - 1):
        ins += i
        if bit & 1 << i:
            expr = expr[:ins+1] + '+' + expr[ins+1:]
            ins += 1
    sum += eval(expr)

print(sum)

Submission status: Runtime Error

Solution code:
s = input().rstrip()
n = len(s)
res = 0
for i in range(2**(n - 1)):
    bs = bin(i)[2:].rjust(n - 1, '0')
    ss = s[0]
    for j, b in enumerate(bs, 1):
        if b == '1':
            ss += '+'
        ss += s[j]
    res += eval(ss)
print(res)

Submission status: Runtime Error

Solution code:
import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    s = sys.stdin.readline()
    ans = 0
    n = len(s)
    for i in range(2**(n-1)):#数字文字列の間に「＋」を入れる/入れないの全パターン
        tmp=s[0]#左端の値をとってくる
        for j in range(n-1):#2進数のフラグチェック
            if i&(1<<j):#&は論理積。jを左に一回シフトして最下位の値がiかどうかチェック。
                tmp+="+"#入れる
            tmp+=s[j+1]#後半をつなぐ
            # print("tmp:",tmp)
        ans += eval(tmp) #eval()の引数に実行したい「式」を文字列として渡すと、その実行結果が帰ってくる
    print(ans)

Submission status: Runtime Error

Solution code:
s = sys.stdin.readline()
ans = 0
n = len(s)
for i in range(2**(n-1)):#数字文字列の間に「＋」を入れる/入れないの全パターン
    tmp=s[0]#左端の値をとってくる
    for j in range(n-1):#2進数のフラグチェック
        if i&(1<<j):#&は論理積。jを左に一回シフトして最下位の値がiかどうかチェック。
            tmp+="+"#入れる
        tmp+=s[j+1]#後半をつなぐ
        # print("tmp:",tmp)
    ans += eval(tmp) #eval()の引数に実行したい「式」を文字列として渡すと、その実行結果が帰ってくる
print(ans)

Submission status: Runtime Error

Solution code:
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    s = sys.stdin.readline()
    ans = 0
    n = len(s)
    for i in range(2**(n-1)):#数字文字列の間に「＋」を入れる/入れないの全パターン
        tmp=s[0]#左端の値をとってくる
        for j in range(n-1):#2進数のフラグチェック
            if i&(1<<j):#&は論理積。jを左に一回シフトして最下位の値がiかどうかチェック。
                tmp+="+"#入れる
            tmp+=s[j+1]#後半をつなぐ
            # print("tmp:",tmp)
        ans += eval(tmp) #eval()の引数に実行したい「式」を文字列として渡すと、その実行結果が帰ってくる
    print(ans)

Submission status: Runtime Error

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

S = input().rstrip()
l = list(S)
N = len(l)

def getbit(i, length):
    return format(i, '0' + str(length) + 'b')

bits = []
for i in range(2**(N-1)):
    bits.append(getbit(i, N-1))


ans = 0

for i in range(len(bits)):
    s = str(l[0])

    bitlist = list(bits[i])
    for j in range(len(bitlist)):
        if bitlist[j] == '0':
            pass
        else:
            s += '+'

        s += str(l[j+1])
    ans += eval(s)

print(ans)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=sys.stdin.readline
def resolve():
    s=input()
    n=len(s)
    ans=0
    from itertools import product
    for A in product(range(2),repeat=n-1):
        k=s[0]
        for i in range(n-1):
            k+='+' if A[i] else ''
            k+=s[i+1]
        ans+=eval(k)
    print(ans)
resolve()

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=sys.stdin.readline
def resolve():
    s=input()
    n=len(s)
    ans=0
    from itertools import product
    for A in product(range(2),repeat=n-1):
        k=s[0]
        for i in range(n-1):
            k+='+' if A[i] else ''
            k+=s[i+1]
        ans+=eval(k)
    print(ans)
resolve()

Submission status: Runtime Error

Solution code:
S=input()
total=0

for i in range(2**(len(S)-1)):
    a = int(S[0])
    t=format(i,'b').zfill(len(S)-1)
    for j in range(len(t)):
        if t[j]=='0':
            a=a*10+int(S[j+1])
        else:
            total+=a
            a=int(S[j+1])
    total+=a

print(total)

Submission status: Runtime Error

Solution code:
s = input()
n = len(s)
def dfs(i,f):
  if i == n:
    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,0))

Submission status: Runtime Error

Solution code:
S = input()

ans = 0
for i in range(2**(len(S)-1)):
    tmp = S[0]
    for j, b in enumerate(format(i, 'b').zfill(len(S)-1)):
        if b == '1':
            tmp += '+'
        tmp += S[j+1]
    ans += eval(tmp)
print(ans)

Submission status: Runtime Error

Solution code:
s = input()
answer = 0

if len(s) == 1:
    print(s)
for i in range(2**(len(s)-1)):
    f = s[0]
    for j,b in enumerate(str(format(i,'b').zfill(len(s)-1))):
        if b == '1':
           f += ','
        f += s[j+1]
    answer += sum(int(i) for i in f.split(','))
print(answer)

Submission status: Runtime Error

Solution code:
s = input()
answer = 0
for i in range(2**(len(s)-1)):
    f = s[0]
    for j,b in enumerate(str(format(i,'b').zfill(len(s)-1))):
        if b == '1':
           f += ','
        f += s[j+1]
    answer += sum(int(i) for i in f.split(','))
print(answer)

Submission status: Runtime Error

Solution code:
S = input()
stack = [S]
ans = int(S)
checked = []
while True:
  str_num = stack.pop()
  if len(str_num) <= 1:
    continue
  for i in range(len(str_num)):
    str1 = str_num[:i]
    str2 = str_num[i:]
    if not str1 in checked:
      checked.append(str1)
      ans += int(str1)
      stack.append(str1)
    if not str2 in checked:
      checked.append(str2)
      ans += int(str2)
      stack.append(str2)
print(ans)

Submission status: Runtime Error

Solution code:
from copy import *
from sys import *
import math
import queue
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)

#dp[i][j]: iまでからj枚えらんで和がkになるのは何通り
def main():
	s = input()
	ans = 0
	for i in range(0,2**(len(s)-1)):
		temp = []
		ix2 = base_10_to_n(i,2)
		for i in range(len(s)-len(ix2)-1):
			ix2 = '0' + ix2
		tmp = s[0]
		for j in range(len(ix2)):
			if(ix2[j]=='1'):
				temp.append(tmp)
				tmp = s[j+1]
			else:
				tmp = tmp + s[j+1]
		temp.append(tmp)
		for i in temp:
			ans+=int(i)
	print(ans)


def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Submission status: Runtime Error

Solution code:
n = str(input())
a = ["","+"]
l = list(itertools.product(a,repeat=len(n)-1))
l_n = list(n)
ans=0
for i in l:
    l_a = [None]*(len(n)*2-1)
    l_a[::2] = l_n
    l_a[1::2] = i
    ans+=eval("".join(l_a))
print(ans)

Submission status: Runtime Error

Solution code:
S = input()

N = len(S)
ans = 0
for i in range(2 ** (N - 1)):
    bit = ('{:0' + str(N - 1) + 'b}').format(i)
    formula = S[0]
    for j in range(len(bit)):
        if bit[j] == '1':
            formula += '+'
        formula += S[j + 1]
    ans += eval(formula)
print(ans)

Submission status: Runtime Error

Solution code:
S = input()

ans = 0
def dfs(num_string, p):
  global ans
  if p > len(S) - 1:
    #終わり
    ans += eval(num_string)
    return 
  
  #先頭の数字だけ扱いが微妙
  if p == 0:
    num_string  = "" + S[0]
    p = 1
  
  tmp = 0
  
  dfs(num_string + "+" + S[p], p+1)
  dfs(num_string + S[p], p+1)
  
  return

dfs(0,0)
print(ans)

Submission status: Runtime Error

Solution code:

from itertools import combinations


def read_input():
    s = input().strip()
    return s

def split_and_sum(s, indice):
    indice_e = [0, *indice, 10]

    result = []
    for start,end in zip(indice_e, indice_e[1:]):
        result.append(int(s[start:end]))

    return sum(result)

def submit():
    s = read_input()
    max_index = len(s)

    acc = 0
    for i in range(max_index):
        for c in combinations(range(1, max_index), i):
            acc += split_and_sum(s, c)

    print(acc)

if __name__ == '__main__':
    submit()

Submission status: Runtime Error

Solution code:
n=input()
m=[[]for _ in range(n)]
m[0]+=[[0,int(n[0])]]
for i in range(1,len(n)):
  a=int(n[i])
  for m0,m1 in m[i-1]:
    m[i]+=[[m0+m1,a]]
    m[i]+=[[m0,m1*10+a]]
ans=0
for m0,m1 in m[len(n)-1]:
  ans+=m0+m1
print(ans)

Submission status: Runtime Error

Solution code:
n=input()
ans=0
def dfs(i,flag):
  global ans
  if i!=len(n)-1:
    dfs(i+1,flag)
    dfs(i+1,flag|2**i)
  else:
    num=[]
    start=0
    for i in range(len(n)):
      if flag&2**i>0:
        num.append(n[start:i+1])
        start=i+1
    ans+=sum(num)

dfs(0,0)
print(ans)

Submission status: Runtime Error

Solution code:
n=input()
ans=0
def dfs(i,flag):
  if i!=len(n)-1:
    dfs(i+1,flag)
    dfs(i+1,flag|2**i)
  else:
    num=[]
    start=0
    for i in range(len(n)):
      if flag&2**i>0:
        num.append(n[start:i+1])
        start=i+1
    ans+=sum(num)

dfs(0,0)
print(ans)

Submission status: Runtime Error

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

if len(s) == 1:
    print(s[0])
    exit(1)

from collections import deque

cands=deque([[0],[1]])

while len(cands[0]) != len(s)-1:
    newcands = []
    for cand in cands:
        newcands.append(cand+[0])
        newcands.append(cand+[1])
    cands = newcands

memo = []
while cands:
    pos = cands.pop()
    siki = ''
    for i, p in enumerate(pos):
        siki += str(s[i])
        if p == 1:
            siki += '+'
    siki += str(s[-1])
    memo.append(eval(siki))

print(sum(memo))

Submission status: Runtime Error

Solution code:
import sys

S = input()
if len(S) == 1:
    print(int(S))
    sys.exit()

ls = []
a = [0, 1]
for i in itertools.product(a, repeat=len(S)-1):
    ans = 0
    start = 0
    for j, x in enumerate(i):
        if x == 1:
            ans += int(S[start:j+1])
            start = j + 1
    ans += int(S[start:len(S)])
    ls.append(ans)
print(sum(ls))

Submission status: Runtime Error

Solution code:
S = list(input())
cnt = 0
for i in range(1 << len(S)-1):
  f = S[0]
  for j, b in enumerate(format(i, 'b').zfill(len(S)-1)):
    if(b == '1'):
      f += '+'
    f += S[j+1]
  cnt += sum(map(int,f.split('+')))
print(cnt)

Submission status: Runtime Error

Solution code:
from sys import setrecursionlimit; setrecursionlimit(10**9)
S = input()

def res(S, A, B):
    if not S:
        B.append(sum(list(map(int, A))))
        return None
    A += [S[0]]
    res(S[1:], A, B)
    A.pop()
    A[-1] += S[0]
    res(S[1:], A, B)
    return B

B = res(S[1:], [S[0]], [])
print(sum(B))

Submission status: Runtime Error

Solution code:
S = input()

def res(S, A, B):
    if not S:
        B.append(sum(list(map(int, A))))
        return None
    A += [S[0]]
    res(S[1:], A, B)
    A.pop()
    A[-1] += S[0]
    res(S[1:], A, B)
    return B

B = res(S[1:], [S[0]], [])
print(sum(B))

Submission status: Runtime Error

Solution code:
a = input()
ar = []
for i in range(3):
    ar.append(a[i]) 
n = len(ar)
ret = 0
for i in range(n+1):
    s = "+"
    tmp = ""
    for j in range(n):
        if (1 & (i >> j)) == 1:
            tmp += ar[j]
            tmp += s
        else:
            tmp += ar[j]
    stmp = tmp.split("+")
    ret += sum(int(k) for k in stmp)
print(int(ret))

Submission status: Runtime Error

Solution code:
a = input()
ar = []
for i in range(3):
    ar.append(a[i]) 
n = len(ar)
ret = 0
for i in range(n+1):
    s = "+"
    tmp = ""
    for j in range(n):
        if (1 & (i >> j)) == 1:
            tmp += ar[j]
            tmp += s
        else:
            tmp += ar[j]
    stmp = tmp.split("+")
    ret += sum(int(k) for k in stmp)
print(ret)

Submission status: Runtime Error

Solution code:
n=input()
#print(n)

mynum=2**(len(n)-1)
#print(mynum)
data=['','+']
x=['0']*10000
#print(x)

for i in range(mynum):
  y=format(i, 'b')
  z=y.zfill(len(n)-1)
  x[i]=n[0]
  for j in range(len(z)):
    x[i]+=data[int(z[j])]+n[j+1]
#  print(x[i])           
x=[eval(i) for i in x]

print(n if len(n)==1 else sum(x))
#12656242944

Submission status: Runtime Error

Solution code:
n=input()
#print(n)
mynum=2**(len(n)-1)
#print(mynum)
data=['','+']
x=['0']*10000
#print(x)

for i in range(mynum):
  y=format(i, 'b')
  z=y.zfill(len(n)-1)
  x[i]=n[0]
  for j in range(len(z)):
    x[i]+=data[int(z[j])]+n[j+1]
#  print(x[i])           
x=[eval(i) for i in x]

print(sum(x))
#12656242944

Submission status: Runtime Error

Solution code:
n=input()
#print(n)
data=['','+']
x=['0']*10000
#print(x)
for i8 in range(2):
  for i7 in range(2): 
    for i6 in range(2): 
      for i5 in range(2): 
        for i4 in range(2): 
          for i3 in range(2): 
            for i2 in range(2): 
              for i1 in range(2): 
                for i0 in range(2):
                  x[i0+2*i1+4*i2+8*i3+16*i4+32*i5+64*i6+128*i7+256*i8]=(n[0]+data[i0]+n[1]
                         +data[i1]+n[2]
                         +data[i2]+n[3]
                         +data[i3]+n[4]
                         +data[i4]+n[5]
                         +data[i5]+n[6]
                         +data[i6]+n[7]
                         +data[i7]+n[8]
                         +data[i8]+n[9])        
        
x=[eval(i) for i in x]

print(sum(x))
#12656242944

Submission status: Runtime Error

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

kotae = 0
for i in range(2**(slen-1)):
    for j in range(slen-1):
        if i & 1<<j:
            si = si[:slen-j]+"+"+si[slen-j:]
        else:
            pass
    kotae += eval(si)

print(kotae)

Submission status: Runtime Error

Solution code:
s = input()
l = [s[0]]
d = len(s) - 1
def operate_1(string):
  return string
def operate_2(string):
  string += "+"
  return string
# l,d は未定義注意
def bfs(list_hoge = l,depth = 0,deepest = d):
    queue = []
    for e in list_hoge:
        for b in [0,1]:
            if b == 0:
                operated = operate_1(e)
                operated += s[depth + 1]
                queue.append(operated)
            elif b == 1:
                operated = operate_2(e)
                operated += s[depth + 1]
                queue.append(operated)
    list_hoge = queue[:]
    depth += 1
    if depth == deepest:
        return list_hoge
    else:
        return bfs(list_hoge,depth)
ans = 0
for e in bfs():
  ans += eval(e)
print(ans)

Submission status: Runtime Error

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