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:
#coding:utf-8
S=input()
n=len(S)-1
answer=0
for i in range(2**n):
  formula=list(S)
  for j in range(n):
    if ((i<<j)&1):
      formula=S.insart("+",j+1)
  for i,elem in enumerate(formula):
    num=""
    if elem=="+" or i==len(formula)-1:
      answer+=int(num)
      num=0
    else:
      num+=elem
print(answer)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
S = input()
ans = 0

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

print(ans)

Submission status: Runtime Error

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

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

func(int(s[0]),s[1:],0)
print(sum(cand))

Submission status: Runtime Error

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

for i in range(2**(n-1)):
  form = s
  bit = []
  for _ in range(n-1):
    bit.append(i%2)
    i =  i//2
  
  for j in range(n):
    if bit[j]:
      form = form[:n-j] + '+' + form[n-j:]
    
  ans += form.eval()
print(ans)

Submission status: Runtime Error

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

res = 0

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

Submission status: Runtime Error

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

res = 0

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

Submission status: Runtime Error

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

res = 0

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

Submission status: Runtime Error

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

res = 0

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

Submission status: Runtime Error

Solution code:
S = input()

n = len(S)
e = ""
s = 0

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

Submission status: Runtime Error

Solution code:
s = str(input())
s_list = []
for i in range(len(s)):
  s_list.append(s[i])

#print(s_list)
L = len(s_list)

sum_a = 0
for k in range(2**(L-1)):
  plus_list = [0]*(L-1)
  p = list(bin(k)[2:])
  for l in range(len(p)):
    plus_list[L-len(p)+l-1] = int(p[l])
  
  #print("p_list:",plus_list)
  #print("p:",p)
  num_list = []
  start = 0
  for i in range(len(plus_list)):
    if plus_list[i]:
      num_list.append(s_list[start:i+1])
      start = i+1
  num_list.append(s_list[start:])
  ans = 0
  for i in num_list:
    s = ''
    for j in i:
      s = s+j
    ans += int(s)
  sum_a += ans
  #print("num_list:",num_list)
  #print("ans:",ans)
print(sum_a)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
s = input()
n = len(s)
ans = 0
for i in range(1<<(n-1)):
    t = ''
    for j in range(n-1):
        t += s[j]
        if (i >> j) & 1:
            t += '+'
    else:
        t += s[n-1]
    ans += eval(t)
print(ans)

Submission status: Runtime Error

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

if n == 0:
    print(s)
    return

for bit in range(1 << n):
    eval_str = ''
    for i in range(n):
        eval_str += s[i]
        if bit & (1 << i):
            eval_str += '+'
    eval_str += s[i + 1]
    sum += eval(eval_str)

print(sum)

Submission status: Runtime Error

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

for bit in range(1 << n):
    eval_str = ''
    for i in range(n):
        eval_str += s[i]
        if bit & (1 << i):
            eval_str += '+'
    eval_str += s[i + 1]
    sum += eval(eval_str)

print(sum)

Submission status: Runtime Error

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

for i in 2**(len(s)-1):
    x = s[0]

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

Submission status: Runtime Error

Solution code:
S = 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 << (n-1)):
      f += "+"
    f += S[i+1]
    ans += sum(map(int,f.split("+")
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s=input()
n=len(s)-1
l=[]
for i in range(n):
    l.append("+")
sum = 0
for i in range(2 ** n):
    plus = []
    tmp = ""
    ans = 0
    for j in range(n):
        if ((i>>j) & 1):
            plus.append(l[j])
        else:
            plus.append("")
    for i in range(n):
        tmp += s[i]+plus[i]
        if i == n-1:
            tmp+=s[i+1]
    tmp2 = tmp.split("+")
    for i in range(len(tmp2)):
        ans += int(tmp2[i])
    sum+=ans
print(sum)

Submission status: Runtime Error

Solution code:
S = input()
n = len(S)
total = 0
for i in range(2**(n-1)) :
  ls = [""] * (n-1)
  
  for j in range(n) :
    if ((i >> j) & 1) :
      ls[j] = "+"
  for k in range(n) :
    if k==0 :
      fo = S[k] + ls[k]
    elif k==n-1 :
      fo = fo + S[k]
    else :
      fo = fo + S[k] + ls[k]  
  total += eval(fo)
print(total)

Submission status: Runtime Error

Solution code:
def dfs(splitted: "the list of integer", a: int, b: int, depth: int) -> int:
  if len(splitted) == depth:
    return a + b
  else:
    # 左のdfs() 呼び出し -> +を挿入しなかったとき
    # 右のdfs() 呼び出し -> +を挿入したとき
    return dfs(splitted, a, b * 10, depth + 1) + dfs(splitted, a + b, splitted[i], depth + 1)

s = [int(x) for x in input()]
print(dfs(s, 0, 0, 0))

Submission status: Runtime Error

Solution code:
def dfs(splitted: "the list of integer", a: int, b: int, depth: int) -> int:
  if len(splitted) == depth:
    return a + b
  else:
    # 左のdfs() 呼び出し -> +を挿入しなかったとき
    # 右のdfs() 呼び出し -> +を挿入したとき
    return dfs(splitted, a, b * 10, depth + 1) + dfs(s, a + b, splitted[i], depth + 1)

s = [int(x) for x in input()]
print(dfs(s, 0, 0, 0))

Submission status: Runtime Error

Solution code:
s=input()
n=len(s)-1
ans=0
for b in list(product(['+',''],repeat=n)):
    a=s[0]
    for i in range(n):
        a=a+b[i]+s[i+1]
    ans+=eval(a)
print(ans)

Submission status: Runtime Error

Solution code:
s=input()
n=len(s)-1
ans=0
for b in list(product(['+',''],repeat=n))
    a=s[0]
    for i in range(n):
        a=a+b[i]+s[i+1]
    ans+=eval(a)
print(ans)

Submission status: Runtime Error

Solution code:
S = int(input())
N = len(S) - 1
ans = 0

for i in range(2 ** N):
    k = 0
    for j in range(N):
        if (i >> j) & 1:
            ans += int(S[k:j + 1])
            k = j + 1
    ans += int(S[k:])
print(ans)

Submission status: Runtime Error

Solution code:
S = int(input())
N = len(S) - 1
ans = 0

for i in range(2 ** N):
    k = 0
    for j in range(N):
        # 復元
        if (i >> j) & 1:
            ans += int(S[k:j + 1])
            k = j + 1
    ans += int(S[k:])
print(ans)

Submission status: Runtime Error

Solution code:
n = input()
l = len(n)
ans = 0
for bit in range(1 << l-1):
  f = n[0]
  for i in range(1<<l):
    if bit & i:
      f += '+"
    f += n[i]
  ans += sum([int(x) for x in f.split('+')])
print(ans)

Submission status: Runtime Error

Solution code:
import sys
from collections import deque

sys.setrecursionlimit(1000000000)

def dfs(xs,q):
    if len(xs) == 0:
        return sum(int(i) for i in q)

    x = xs.popleft()

    if len(q) == 0:
        q.append(x)
        return dfs(xs,q)


    a1 = xs.copy()
    a2 = xs.copy()

    q1 = q.copy()
    q2 = q.copy()

    q1.append(x)

    y  = q2.pop()
    yx = y + x
    q2.append(yx)

    return dfs(a1,q1) + dfs(a2,q2)


s  = str(input())
xs = deque(list(s))

print(dfs(xs,deque([])))

Submission status: Runtime Error

Solution code:
import sys
from collections import deque

sys.setrecursionlimit(1000000000)

def dfs(xs):
    x = xs.popleft()

    if len(xs) == 0:
        return x

    # not +
    xs2 = xs.copy()
    y   = xs2.popleft()
    xy  = int(str(x)+str(y))
    xs2.appendleft(xy)
    b = dfs(xs2)

    # has +
    a = x + x + dfs(xs)


    return a+b


s  = str(input())
xs = list(map(int,s))
xs = deque(xs)

print(dfs(xs))

Submission status: Runtime Error

Solution code:
from collections import deque

def dfs(xs):
    x = xs.popleft()

    if len(xs) == 0:
        return x

    # not +
    xs2 = xs.copy()
    y   = xs2.popleft()
    xy  = int(str(x)+str(y))
    xs2.appendleft(xy)
    b = dfs(xs2)

    # has +
    a = x * 2 + dfs(xs)


    return a+b


s  = str(input())
xs = list(map(int,s))
xs = deque(xs)

print(dfs(xs))

Submission status: Runtime Error

Solution code:
from collections import deque

def dfs(xs):
    print("xs",xs)
    x = xs.popleft()

    if len(xs) == 0:
        return x

    # not +
    xs2 = xs.copy()
    y   = xs2.popleft()
    xy  = int(str(x)+str(y))
    xs2.appendleft(xy)
    b = dfs(xs2)

    # has +
    a = x * 2 + dfs(xs)


    return a+b


s  = str(input())
xs = list(map(int,s))
xs = deque(xs)

print(dfs(xs))

Submission status: Runtime Error

Solution code:
from collections import deque

def dfs(xs):

    x = xs.popleft()

    if len(xs) == 0:
        return x

    # not +
    xs2 = xs.copy()
    y   = xs2.popleft()
    xy  = int(str(x)+str(y))
    xs2.appendleft(xy)
    b = dfs(xs2)

    # has +
    a = x + dfs(xs)


    return a+b


s  = str(input())
xs = list(map(int,s))
xs = deque(xs)

print(dfs(xs))

Submission status: Runtime Error

Solution code:
def dfs(formula, index):
    if index + 1 == max_index:
        return sum(list(map(int, formula.split("+"))))

    return dfs(formula + "+" + S[index], index + 1) + dfs(formula + S[index], index)


S = input()
max_index = len(S)
dfs(S[0], 0)

Submission status: Runtime Error

Solution code:
def dfs(i, formula):
    if i + 1 == num_digits:
        return sum(list(map(int, formula.split("+"))))

    return sum(dfs(i + 1, formula + "+" + s[i + 1]), dfs(i + 1, formula + s[i + 1]))


s = input()
num_digits = len(s)

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

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+2,f+"+"+s[i+1])#+を入れない場合、+をいれる場合
    
print(dfs(0,s[0]))

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+2,f+"+"+s[i+1])#+を入れない場合、+をいれる場合
    
print(dfs(0,s[0])

Submission status: Runtime Error

Solution code:
def add_or_do_nothing(s, i, pos):
    if i == len(s):
        pre_i = 0
        ans = 0
        for pos_i in pos:
            print(s[pre_i:pos_i], pre_i, pos_i)
            ans += int(s[pre_i:pos_i])
            pre_i = pos_i
        
        if pre_i == 0:
            ans = int(s)
        else:
            ans += int(s[pre_i:len(s)] if pre_i != len(s) else '0')
        return ans

    f_ans = add_or_do_nothing(s, i+1, pos)
    
    pos.append(i)
    s_ans = add_or_do_nothing(s, i+1, pos)
    
    return f_ans + s_ans

s = input()

pos = []
ans = add_or_do_nothing(s, 1, pos)

print(ans)

Submission status: Runtime Error

Solution code:
nums = list(input().strip())
N = len(nums)
head = nums.pop(0)
print(sum(eval(head + "".join([f"{'' if (j >> i) % 2 else '+'}{n}" for i, n in enumerate(nums)])) for j in range(2 ** (N - 1))))

Submission status: Runtime Error

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

def dfs(tmp, s):
    if len(s) == 1:
        return int(tmp)+int(s)+int(tmp+s)
    
    return int(tmp)*2**(len(s)-1)+dfs(s[0], s[1:]) + dfs(tmp+s[0], s[1:])

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

Submission status: Runtime Error

Solution code:
s = input()

item = np.arange(len(s) - 1) + 1
n = len(item)
count = 0
for i in range(2 ** n):
    sidx = 0
    for j in range(n):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            eidx = item[j]
            count += int(s[sidx:eidx])
            sidx = eidx
    count += int(s[sidx:])
print(count)

Submission status: Runtime Error

Solution code:
import sys

input = sys.stdin.readline()

s = input()
n = len(s)

total_sum = 0
# +を挿入する事象は
# sが2文字なら2通り,3文字なら4通り,n文字なら2^(n-1)通りある
for i in range(2 ** (n - 1)):
    # iは各桁に+を挿入するかどうかを決定する
    # 例えば s=12345, i=0b0111, ss=1+2+3+45
    now_sum = 0
    reg = int(s[0])
    for j in range(n - 1):
        if i & 1 << j:
            now_sum += reg
            reg = 0
        reg *= 10
        reg += int(s[j + 1])
    now_sum += reg

    total_sum += now_sum

print(total_sum)

Submission status: Runtime Error

Solution code:
import sys

input = sys.stdin.readline

s = input()
n = len(s)

total_sum = 0
# +を挿入する事象は
# sが2文字なら2通り，3文字なら4通り，n文字なら2^(n-1)通りある
for i in range(2 ** (n - 1)):
    # iは各桁に+を挿入するかどうかを決定する
    # 例えば s=12345, i=0b0111, ss=1+2+3+45
    now_sum = 0
    reg = int(s[0])
    for j in range(n - 1):
        if i & 1 << j:
            now_sum += reg
            reg = 0
        reg *= 10
        reg += int(s[j + 1])
    now_sum += reg

    total_sum += now_sum

print(total_sum)

Submission status: Runtime Error

Solution code:
number = int(input())
num_digits = len(str(number))


def dfs(i, sum_number):
    if i == num_digits:
        return sum_number
    dfs(i + 1, sum_number)
    dfs(i + 1, sum_number + str(number)[i])


print(dfs(0, 0))

Submission status: Runtime Error

Solution code:
S = input()
s = S[0]
ans = 0
def dfs(n,S,s):
    global ans
    s_0 = s + "+" + S[n]
    s_1 = s + S[n]
    if n == len(S) - 1:
        ans += eval(s_0) + eval(s_1)
    else:
        dfs(n+1,S,s_0)
        dfs(n+1,S,s_1)
dfs(1,S,s)
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
S = str(input())

def plus(a,b,c):
    x = a[0:b+1] + c + a[b+1:len(a)]
    return(x)
A = [S]
while len(A) != 2**(len(S)):
    for i in range(len(S)-1):
        for j in range(len(A)):
            x = A[j]
            y = plus(x,i,'+')
            A.append(y)
s = 0
for i in range(len(A)):
    x = A[i]
    p = 0
    q = 0
    for j in range(len(x)):
        if x[j] == '+':
            q = j - 1
            m = x[p:q]
            s += int(m)
            p = j + 1
        elif j == len(x):
            q = len(x)
            m = x[p:q]
            s += int(m)
print(s)

Submission status: Runtime Error

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:i + 1])

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

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:i + 1])

    return total

total_of_all = 0

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

print(total_of_all)

Submission status: Runtime Error

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

main()

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
 
S = ns()
s = []
for i in S:
  s.append(i)
  s.append('')
del s[-1]

out = 0
for i in range(2**(len(S)-1)):
  for j in range(1, len(S)):
    if (i//(2**(j-1)))%2 == 1:
      s[-2*j] = '+'
    else:
      s[-2*j] = ''
  out += eval(''.join(s))
  
print(out)

Submission status: Runtime Error

Solution code:
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
 
S = ns()
s = []
for i in S:
  s.append(i)
  s.append('')
del s[-1]

out = 0
for i in range(2**(len(S)-1)):
  for j in range(1, len(S)):
    if (i//(2**(j-1)))%2 == 1:
      s[-2*j] = '+'
    else:
      s[-2*j] = ''
  # print(s)
  out += eval(''.join(s))
  
print(out)

Submission status: Runtime Error

Solution code:
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
 
S = ns()
s = []
for i in S:
  s.append(i)
  s.append('')
del s[-1]

out = 0
for i in range(2**(len(S)-1)):
  for j in range(1, len(S)):
    if (i//(2**(j-1)))%2 == 1:
      s[-2*j] = '+'
    else:
      s[-2*j] = ''
  out += eval(''.join(s))
  
print(out)

Submission status: Runtime Error

Solution code:
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
 
S = ns()
s = []
for i in S:
  s.append(i)
  s.append('')
del s[-1]

out = 0
for i in range(2**(len(S)-1)):
  for j in range(1, len(S)):
    if (i//(2**(j-1)))%2 == 1:
      s[-2*j] = '+'
    else:
      s[-2*j] = ''
  # print(s)
  out += eval(''.join(s))
  
print(out)

Submission status: Runtime Error

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

Solution code:
d,g=map(int, input().split())
table = []
alscr=0
cnt=0
for i in range(d):
  table.append( [(i+1) * 100] + list(map(int,input().split())) )

for i in range(0,d)[::-1]:
  scr=table[i][0]
  num=table[i][1]
  bns=table[i][2]
  for i in range(num):
    alscr+=scr
    cnt +=1
    if i == num-1:
      alscr += bns
    if alscr >= g:
      print(cnt)
      break

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
S = input()
S_len = len(S) - 1
p = []
for i in range(2 ** S_len):
    tmp = bin(i)[2::]
    while len(tmp) < S_len:
        tmp = "0" + tmp
    p.append(str(tmp))

sum = 0
for i in p:
    P = list(i)
    tmp = int(S[0])
    cnt = 1
    for j in P:
        if j == "0":
            tmp *= 10
            tmp += int(S[cnt])
        else:
            sum += tmp
            tmp = int(S[cnt])
        cnt += 1
    sum += tmp
print(sum)

Submission status: Runtime Error

Solution code:
S = int(input())

def dfs(res, depth, path, S):
    res.append(path)
    if depth == len(S) - 1:
        return
    for i in range(depth + 1, len(S)):
        dfs(res, i, int(S[depth:i+1]), S)

res = []

dfs(res, -1, [], S)
print(sum(res))

Submission status: Runtime Error

Solution code:
s = list(input())

def sum_list(S,stock):
    if len(S) == 2:
        return int(S[0]) + int(S[1]) + int(S[0]+S[1]) + stock * 2
    else:
        return sum_list(S[1:],int(S[0])+stock) + sum_list([S[0]+S[1]]+S[2:],stock)
                                                 
print(sum_list(s,0))

Submission status: Runtime Error

Solution code:
def clc(a, b, c, p, t):
    if c == 0:
        b = a[0]
        return clc(a, b, c + 1, True, t) + clc(a, b, c + 1, False, t)
    elif c == len(a)-1:
        if p:
            return t + int(b) + int(a[c])
        else:
            return t + int(b + a[c])
    else:
        if p:
            t += int(b)
            b = a[c]
        else:
            b += a[c]
        return clc(a, b, c + 1, True, t) + clc(a, b, c + 1, False, t)


s = input()
print(clc(s, "", 0, True, 0))

Submission status: Runtime Error

Solution code:
S = str(input())

ans = ""

for mask in range(1 << (len(S)-1)):
    for i in range(len(S)):
        if ((mask >> i) & 1):
            ans += f"{S[i]}+"
        else:
            ans += f"{S[i]}"
    ans += "+"

print(int(eval(ans[:-1])))

Submission status: Runtime Error

Solution code:
S = str(input())

ans = ""

for mask in range(1 << (len(S)-1)):
    for i in range(len(S)):
        if (mask >> i) & 1:
            ans += f"{S[i]}+"
        else:
            ans += f"{S[i]}"
    ans += "+"
print(int(eval(ans[:-1])))

Submission status: Runtime Error

Solution code:
S = str(input())

ans = ""

for mask in range(1 << (len(S)-1)):
    for i in range(len(S)):
        if (mask >> i) & 1:
            ans += f"{S[i]}+"
        else:
            ans += f"{S[i]}"
    ans += "+"
print(eval(ans[:-1]))

Submission status: Runtime Error

Solution code:
def f(a, b, le, tf):
    b[le] = tf
    if le == len(b)-1:
        t = ""
        s1 = 0
        for i in range(len(b)):
            t += a[i]
            if b[i] == 1:
                s1 += int(t)
                t = ""
        t += a[len(b)]
        s1 += int(t)
        return s1
    else:
        return f(a, b, le+1, 0) + f(a, b, le+1, 1)


aa = input()
bb = [0] * (len(aa)-1)
if len(a) == 1:
    print(a)
else:
    print(f(aa, bb, 0, 0) + f(aa, bb, 0, 1))

Submission status: Runtime Error

Solution code:
def f(a, b, le, tf):
    b[le] = tf
    if le == len(b)-1:
        t = ""
        s1 = 0
        for i in range(len(b)):
            t += a[i]
            if b[i] == 1:
                s1 += int(t)
                t = ""
        t += a[len(b)]
        s1 += int(t)
        return s1
    else:
        return f(a, b, le+1, 0) + f(a, b, le+1, 1)


aa = input()
bb = [0] * (len(aa)-1)
print(f(aa, bb, 0, 0) + f(aa, bb, 0, 1))

Submission status: Runtime Error

Solution code:
s = input()

op_n = len(s) - 1

ans = 0

for i in range(1 << op_n):
  sign = [""] * op_n
  for j in range(op_n):
    if ((i>>j)&1):
      sign[j] = "+"
  formula = ""
  for k in range(op_n):
    formula += s[k] + sign[k]
  formula += s[op-n] 
  ans += eval(formula)
print(ans)

Submission status: Runtime Error

Solution code:
s=input()

op_n=len(s) - 1

ans=0

for i in range(1 << op_n):
  sign = [""] * op_n
  for j in range(op_n):
    if ((i>>j)&1)==1:
      sign[j] = "+"
  formula = ""
  for k in range(op_n):
    formula += s[k] + sign[k]
  formula += s[op-n] 
  ans += eval(formula)
print(ans)

Submission status: Runtime Error

Solution code:
s=input()

op_n=len(s) - 1

ans=0

for i in range(1 << len(s)):
  sign = [""] * op_n
  for j in range(op_n):
    if ((i>>j)&1)==1:
      sign[j] = "+"
  formula = ""
  for k in range(op_n):
    formula += s[k] + sign[k]
  formula += s[op-n] 
  ans += eval(formula)
print(ans)

Submission status: Runtime Error

Solution code:
s=input()

op_n=len(s) - 1

ans=0

for i in range(1 << len(s)):
  sign = [""] * op_n
  for j in range(op_n):
    if ((i>>j) and 1)==1:
      sign[j] = "+"
  formula = ""
  for k in range(op_n):
    formula += s[k] + sign[k]
  formula += s[op-n] 
  ans += eval(formula)
print(ans)

Submission status: Runtime Error

Solution code:
s=input()

op_n=len(s) - 1

ans=0

for i in range(1 << len(s)):
  sign = [""] * op_n
  for j in range(op_n):
    if ((i>>j)==1):
      sign[j] = "+"
  formula = ""
  for k in range(op_n):
    formula += s[k] + sign[k]
  formula += s[op-n] 
  ans += eval(formula)
print(ans)

Submission status: Runtime Error

Solution code:
s=input()

op_n=len(s) - 1

ans=0

for i in range(1 << len(s)):
  sign = [""] * op_n
  for j in range(op_n):
    if ((i>>j)==1):
      sign[j] = "+"
  formula = ""
  for k in range(op_n):
    formula += s[k] + sign[k]
  formula += s[op-n] 
  ans = eval(formula)
print(ans)

Submission status: Runtime Error

Solution code:
S = input()
print(S[0],S[1]) 
cnt = len(S) - 1 #数字の間の数
 
ans = 0
 
for i in range(2 ** cnt):
  sign = [""] * cnt
  for j in range(cnt):
    if ((i>>j)&1):
      sign[j] = "+"
            
  formula = ""      
  for k in range(cnt):
    formula += S[k] + sign[k]
    print(sign)
  formula += S[cnt]
  print(formula,i)       
  ans += eval(formula)
print(ans)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

"""
(駅、会社)を頂点にグラフを持つ。頂点数O(M)。
そのまま辺を貼ると辺が多くなりすぎる。
(駅、会社) -> (駅、無属性) -> (駅、会社)
"""

N,M = map(int,input().split())
PQC = [[int(x) for x in input().split()] for _ in range(M)]

U = 10 ** 6

V = set(range(1,N+1))
V |= set(p + c * U for p,q,c in PQC)
V |= set(q + c * U for p,q,c in PQC)
V = tuple(V)
v_to_i = {v:i for i,v in enumerate(V)}

# グラフを作成
rows, cols = [],[]
rows += [i for i,pc in enumerate(V) if pc > U]
cols += [v_to_i[pc % U] for i,pc in enumerate(V) if pc > U]
wt = [1] * len(rows)
rows += [v_to_i[p + c * U] for p,q,c in PQC]
cols += [v_to_i[q + c * U] for p,q,c in PQC]
wt += [0] * M

graph = csr_matrix((wt, (rows, cols)), (len(V), len(V)))

start = v_to_i[1]
goal = v_to_i[N]

Submission status: Runtime Error

Solution code:
S = input()
ans = 0
for p in itertools.product(['', '+'], repeat = len(S) - 1):
    cmd = ''.join([s + t for s, t in zip(S, p)]) + S[-1]
    ans += eval(cmd)
print(ans)

Submission status: Runtime Error

Solution code:
from sys import stdin

def main():
    S=input()
    andbit = 2**10 -1
    ans = 0
    length = 2**(len(S) -1)
    
    for i in range (length):
      bitup = andbit & i
      bitcheck = 1
      tmp=0
      for j in range(1,len(S),1):
        if bitup & bitcheck > 0:
          ans += int(S[tmp:j])
          tmp = j
        bitcheck = bitcheck << 1
      ans += int(S[tmp:len(S)])
    print(ans)

input = lambda: stdin.readline()
main()